/* --- 1. Негизги Жалпы Стиль --- */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-image: url("bg.png");
    text-align: center;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

h1 {
    margin: 20px;
    font-size: 32px;
    color: #333;
}

/* --- 2. Баштоо/Жеңиш Экрандары (Модальдар) --- */
#startScreen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#startModal {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    color: #333;
    width: 80%;
    max-width: 600px;
}
#startModal h2 {
    font-size: 36px;
    margin-bottom: 30px;
    color: #1A237E;
}

/* ⭐ ЖАҢЫ КОШУЛГАН СТИЛЬ: ТАТААЛДЫКТЫ ТАНДОО ⭐ */
.difficulty-setup {
    margin-bottom: 30px;
    padding: 15px;
    border: 1px dashed #4A148C; /* Күлгүн түс менен сызык */
    border-radius: 10px;
}
.difficulty-setup h3 {
    margin-top: 0;
    font-size: 20px;
    color: #4A148C; /* Күлгүн */
    margin-bottom: 15px;
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap; /* Баскычтар кичине экрандарга жылышы үчүн */
}

.diff-btn {
    padding: 10px 15px;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: #f4f4f4;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    flex: 1 1 auto; /* Кичине экранда жайылышы үчүн */
    max-width: 30%; /* Максималдуу туурасы */
    white-space: nowrap;
}

.diff-btn:hover {
    background: #eee;
}

.diff-btn.active {
    background: #4A148C; /* Активдүү түс - Күлгүн */
    color: white;
    border-color: #4A148C;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}
/* ⭐ ТАТААЛДЫК СТИЛИ БҮТТҮ ⭐ */


.teamSetup {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
    justify-content: center;
}
.teamBox {
    border: 1px solid #ccc;
    padding: 15px;
    border-radius: 10px;
}
.teamBox input {
    width: 90%;
    padding: 10px;
    font-size: 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
    text-align: center;
    margin-top: 10px;
    font-family: inherit;
}

/* Баштоо баскычы */
#startBtn {
    padding: 15px 50px;
    font-size: 28px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px #27ae60;
    transition: all 0.1s;
}
#startBtn:active {
    transform: translateY(2px);
    box-shadow: 0 2px #27ae60;
}
 
/* Жеңиш экраны */
#winnerScreen { 
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #A11C28, #1A237E); 
    color: white; 
    display: none; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    z-index: 100;
    text-shadow: 2px 2px #000;
}
#winnerScreen h2 { font-size: 40px; }

/* Артка саноо */
#countdown {
    font-size: 100px;
    font-weight: bold;
    position: absolute;
    z-index: 99;
    color: white; 
    text-shadow: 0 0 10px #e74c3c, 0 0 20px #e74c3c; 
    display: none;
    animation: scaleIn 0.5s ease-out;
}
#countdown.go {
    font-size: 50px;
    color: #2ecc71;
    text-shadow: 0 0 5px #27ae60, 0 0 15px #27ae60;
    animation: pulse 0.8s infinite; 
}

/* Анимациялар */
@keyframes scaleIn {
    from { transform: scale(0.5); opacity: 0.5; }
    to { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}


/* --- 3. Калькулятор Панелдери --- */
.main-game-container {
    display: flex;
    align-items: flex-start;
    gap: 20px; 
}

.panel {
    width: 320px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    padding-bottom: 15px;
}
.header {
    padding: 15px; border-top-left-radius: 15px; border-top-right-radius: 15px;
    color: white; font-size: 24px; font-weight: bold;
}
#leftPanel .header { background: #1A237E; } /* Көк */
#rightPanel .header { background: #A11C28; } /* Кызыл */

.problem-box {
    height: 60px; display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: bold; color: white;
    margin: 10px 0;
}
#leftProblem { background: #3f51b5; }
#rightProblem { background: #b42444; }

.input-display {
    width: 80%;
    padding: 10px;
    margin: 10px auto;
    display: block;
    font-size: 24px;
    text-align: center;
    border: 2px solid #ccc;
    border-radius: 5px;
    font-family: inherit;
}

/* Клавиатура */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 20px;
}
.btn {
    padding: 15px 5px;
    font-size: 20px;
    border: none;
    border-radius: 8px;
    background: #eee;
    box-shadow: 0 3px #ccc;
    cursor: pointer;
    transition: all 0.1s;
}
.btn:active {
    transform: translateY(3px);
    box-shadow: none;
}
.btn-clear { background: #e74c3c; color: white; box-shadow: 0 3px #c0392b; }
.btn-zero { grid-column: span 1; }
.btn-go { background: #3498db; color: white; box-shadow: 0 3px #2980b9; }

/* --- 4. АРКАН АРЕНАСЫ ЖАНА СҮРӨТТҮ БАШКАРУУ --- */
#arena {
    width: 630px;
    height: 400px;
    position: relative;
    overflow: hidden; 
    margin-top: 50px;
}

#winLine {
    position: absolute; left: 49%; top: 0; bottom: 0;
    border-right: 2px dashed #333;
    z-index: 2; 
}

/* Сүрөттү кармап турган контейнер */
#imageContainer {
    width: 700px; 
    height: 100%;
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%); 
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.5, 1); 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

#tugOfWarImage {
    width: 100%; 
    height: auto;
    display: block;
}


/* --- 5. Анимациялар --- */
.shake-input { animation: shake-input 0.5s; }
@keyframes shake-input {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* КОНФЕТТИ ҮЧҮН СТИЛЬ */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    pointer-events: none;
    z-index: 101;
    border-radius: 50%;
}

#winnerScreen { 
    justify-content: center;
    align-items: center;
}

#winnerAnimation {
    height: 250px; 
    margin-bottom: 20px;
}

/* --- АРЕНА ИЧИНДЕГИ ЖЕҢИШ ЭКРАНЫ --- */
#arena {
    position: relative;
    overflow: hidden; 
}

#arenaWinnerDisplay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10; 
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#winGifContainer {
    width: 100%;
    height:auto; 
    margin-bottom: 10px;
    margin-top: -230px;
    overflow: hidden;
}

.win-gif {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%; 
    height: auto;
    max-height: 100%;
    display: none;
    z-index: -1;
}

.winner-text {
    margin: 5px 0;
    font-size: 32px;
    font-weight: bold;
    color: #009688; 
}
.winner-text-small {
    margin: 5px 0 20px 0;
    font-size: 18px;
    color: #9c27b0; 
}

/* --- КОНФЕТТИ (САЛЮТ) СТИЛДЕРИ (АРЕНА ИЧИНДЕ) --- */
.confetti-arena {
    position: absolute;
    width: 8px;
    height: 8px;
    opacity: 0;
    pointer-events: none;
    z-index: 15; 
    border-radius: 50%;
}


/* ========================================================= */
/* --- 6. МЕДИА СУРООЛОР (КИЧИНЕ ЭКРАНДАР ҮЧҮН) --- */
/* ========================================================= */

@media (max-width: 1024px) {
    .main-game-container {
        flex-direction: column; /* Панелдерди вертикалдуу жайгаштыруу */
        align-items: center;
        gap: 10px;
    }
    
    .panel {
        width: 90%; /* Панелдер экранга ылайыктуу болсун */
        max-width: 400px;
        margin-bottom: 5px;
    }
    
    #arena {
        width: 90%; /* Арена да экранга ылайыктуу болсун */
        max-width: 600px;
        height: 250px; /* Бийиктигин кичирейтүү */
        margin-top: 20px;
    }
    
    .keypad {
        padding: 0 10px;
    }

    #startModal {
        padding: 20px;
        width: 95%;
    }
    
    .teamSetup {
        flex-direction: column; /* Команда аттарын вертикалдуу жайгаштыруу */
        gap: 10px;
        margin-bottom: 20px;
    }

    .diff-btn {
        padding: 8px 10px;
        font-size: 12px;
        max-width: 45%; /* Эки баскыч бир катарга сыйдыруу */
    }
    
    .difficulty-buttons {
        gap: 5px;
        justify-content: space-around;
    }
    
    .teamBox input {
        font-size: 18px;
    }

    h1 {
        font-size: 24px;
        margin: 10px 0;
    }
}
/* ... (Башка стилдер) ... */

@media (max-width: 1024px) {
    /* ... (Башка стилдер калат) ... */

    .diff-btn {
        padding: 8px 10px;
        font-size: 12px;
        /* max-width: 45%; - Бул сызыкты алып салыңыз же өзгөртүңүз */
        flex: 1 1 45%; /* Эки баскычты бир катарга жайгаштыруу үчүн */
    }
    
    .difficulty-buttons {
        gap: 10px; /* Аралыкты көбөйтүү */
        justify-content: center;
    }

    /* ... (Башка стилдер калат) ... */
}