/* ===========================================
   GAME SCREEN - MAIN CONTAINER
   =========================================== */
#gameScreen {
    background: linear-gradient(135deg, #fdfcfb 0%, #f7f3f0 100%);
    display: flex;
    flex-direction: column;
    height: 100%;
}


/* ===========================================
   GAME HEADER SECTION (10% height) - PERBAIKAN FINAL
   =========================================== */
.game-header {
    background: var(--primary-gradient);
    color: var(--white);
    padding: 22px 25px;
    
    position: relative;
    overflow: hidden;
    height: 10%;
    min-height: 65px;
    flex-shrink: 0;
    
    /* >>> PERBAIKAN: Menggunakan Flexbox untuk Penataan Vertikal <<< */
    display: flex; 
    flex-direction: column; /* Mengatur item dari atas ke bawah */
    
    /* Memusatkan item di tengah secara vertikal */
    justify-content: center; 
    /* Memusatkan item di tengah secara horizontal */
    align-items: center; 
}

/* ===========================================
   EFEK VISUAL LATAR BELAKANG
   =========================================== */
.game-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
}

/* ===========================================
   GAYA JUDUL UTAMA (H2)
   =========================================== */
.game-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    position: relative;
    z-index: 1; 
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
    background: var(--warning-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0; 
}

/* ===========================================
   GAYA JUDUL BIMBEL (H3) - Menggunakan ID
   =========================================== */
#gameHeaderBimbel { 
    font-size: 1.0rem;
    font-weight: 700;
    position: relative;
    z-index: 2; 
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
    
    /* Penting: Menghilangkan margin bawaan H3 */
    margin: 0;
    
    /* Tambahkan sedikit jarak antara H2 dan H3 jika diinginkan */
    margin-top: 5px; 
}


/* ===========================================
   GAME INFO BAR (12% height)
   =========================================== */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: var(--white);
    height: 10%;
    min-height: 70px;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 2;
    border-bottom: 3px solid #E5E7EB;
    border-image: repeating-linear-gradient(
            90deg,
            #FF6B6B 0px, #FF6B6B 20px,
            #FFD93D 20px, #FFD93D 40px,
            #6BCF7F 40px, #6BCF7F 60px,
            #4D96FF 60px, #4D96FF 80px,
            #9D4BFF 80px, #9D4BFF 100px
        ) 1;
}

.info-item {
    text-align: center;
    flex: 1;
    padding: 0 10px;
}

.info-label {
    font-size: 0.85rem;
    color: var(--medium-text);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.info-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.score .info-value {
    background: var(--warning-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.timer .info-value {
    background: var(--info-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.progress .info-value {
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===========================================
   QUESTION AREA (38% height)
   =========================================== */
.question-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px;
    background: white;
    position: relative;
    overflow: visible !important;
    height: auto !important; 
    min-height: 38%; 
    flex-shrink: 0;
    perspective: 1000px;
}

/* QUESTION BOX STYLES */
.question-box {
    background: white;
    border-radius: 15px;
    padding: 5px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    
    border: 3px dashed transparent;
    background: 
        linear-gradient(white, white) padding-box,
        repeating-linear-gradient(
            45deg,
            #FF6B6B 0px, #FF6B6B 10px,
            #FFD93D 10px, #FFD93D 20px,
            #6BCF7F 20px, #6BCF7F 30px,
            #4D96FF 30px, #4D96FF 40px,
            #9D4BFF 40px, #9D4BFF 50px
        ) border-box;
    
    width: 100%;
    min-height: 200px; 
    height: auto !important; 
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    position: relative;
    overflow: visible !important; /* Visible, bukan hidden */
}

/* Animated dashes */
.question-box {
    animation: moveDashes 3s linear infinite;
}

@keyframes moveDashes {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 50px 50px;
    }
}

/* Flip animation */
.question-box.flip-out {
    animation: flipAnimation 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes flipAnimation {
    0% {
        transform: rotateX(0deg) translateY(0);
        opacity: 1;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    }
    49% {
        transform: rotateX(-90deg) translateY(-10px);
        opacity: 0.7;
        box-shadow: 0 20px 50px rgba(102, 126, 234, 0.3);
    }
    50% {
        transform: rotateX(-90deg) translateY(-10px);
        opacity: 0.3;
    }
    100% {
        transform: rotateX(0deg) translateY(0);
        opacity: 1;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    }
}

/* Question text */
.question {
    font-size: clamp(1.8rem, 4vw, 4rem);
    font-weight: 800;
    color: #333;
    letter-spacing: 2px;
    line-height: 1;
    white-space: normal; 
    overflow: hidden; 
    overflow-y: hidden; 
    padding: 0 10px;
    width: 100%;
    text-align: center;
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    word-wrap: break-word; 
    word-break: break-word;
}

/* Fade effect for flip */
.question-box.flip-out .question {
    animation: contentFade 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes contentFade {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.2;
        transform: scale(0.95);
    }
}

/* Hide scrollbar */
.question::-webkit-scrollbar {
    display: none;
}

/* Question elements */
.number, .operator {
    display: inline-block;
    margin: 0 5px;
}

.number {
    color: #667eea;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.operator {
    color: var(--primary-purple);
    font-weight: 800;
}

.question-mark {
    color: #ff6b35;
    margin-left: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Hover effects */
.question-box:hover:not(.flip-out) {
    transform: translateY(-5px);
}

/* ===========================================
   COUNTING OPERATIONS (Buah, Hewan, Benda)
   =========================================== */

/* Container untuk semua jenis hitung */
.question-box .counting-question {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
    overflow: visible !important;
}

/* Display container */
.question-box .counting-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100% !important; 
    flex: 1 1 auto; 
    overflow: visible !important; 
    min-height: 150px;
}

/* Baris untuk item - NOWRAP untuk 8 icon per baris */
.question-box .counting-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    line-height: 1.2; 
    white-space: nowrap;
    flex-wrap: nowrap !important;
    gap: 0.2vw !important;
    margin: 0.5vh 0 !important; 
    min-height: 50px !important; 
    height: auto !important; 
    flex-shrink: 0;
    overflow: visible !important; 
    padding: 5px 10px;
    max-width: 100%;
}

/* Individual icon - tidak boleh mengecil */
.question-box .counting-icon {
    display: inline-block;
    line-height: 1.2;
    text-align: center;
    flex-shrink: 0 !important;
    min-width: fit-content;
    height: auto !important; 
    min-height: 1em;
    vertical-align: middle;
}

/* =============== UKURAN ICON PER LEVEL - FIXED =============== */
.question-box .level-1 .counting-display { 
    font-size: 5vh !important;  
    min-height: 70px !important;
}

.question-box .level-2 .counting-display { 
    font-size: 5vh !important;
    min-height: 70px !important;
}

.question-box .level-3 .counting-display { 
    font-size: 5vh !important;
    min-height: 70px !important;
}

.question-box .level-4 .counting-display { 
    font-size: 5vh !important;
    min-height: 70px !important;
}

.question-box .level-5 .counting-display { 
    font-size: 4vh !important;
    min-height: 70px !important;
}

/* ===========================================
   OPTIONS AREA (35% height)
   =========================================== */
.options-area {
    padding: 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    position: relative;
    height: 30%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 10px;
}

.options-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--warning-gradient);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    height: 100%;
}

.option-box {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border: 3px solid #e2e8f0;
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--dark-text);
    min-height: 100px;
    box-shadow: var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.option-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.option-box:hover:not(:disabled)::before {
    transform: translateX(100%);
}

.option-box:hover:not(:disabled) {
    border-color: #4D96FF;
    background: linear-gradient(135deg, 
        rgba(187, 222, 251, 0.9), 
        rgba(240, 248, 255, 0.9));
    color: #1565C0;
    transform: translateY(-3px);
    box-shadow: 
        0 10px 30px rgba(77, 150, 255, 0.25),
        0 0 0 3px rgba(255, 217, 61, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.option-box:active:not(:disabled) {
    transform: translateY(-1px);
}

.option-box:disabled {
    cursor: not-allowed;
    opacity: 0.9;
}

/* Correct answer */
.option-box.correct {
    animation: stampCorrect 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    background: var(--success-gradient) !important;
    border-color: transparent !important;
    color: white !important;
    box-shadow: 
        0 10px 30px rgba(67, 233, 123, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@keyframes stampCorrect {
    0% {
        transform: scale(3);
        opacity: 0;
        filter: brightness(1.5);
    }
    50% {
        transform: scale(0.8);
        filter: brightness(1.2);
    }
    70% {
        transform: scale(1.1);
        filter: brightness(1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }
}

/* Wrong answer */
.option-box.wrong {
    animation: popWrong 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    background: var(--danger-gradient) !important;
    border-color: transparent !important;
    color: white !important;
    box-shadow: 
        0 10px 30px rgba(255, 8, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@keyframes popWrong {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
        background: #ffcccc;
    }
    30% {
        transform: scale(1.3);
        opacity: 0.8;
        background: #ff6666;
    }
    60% {
        transform: scale(0.9);
        opacity: 0.9;
        background: #ff3333;
    }
    80% {
        transform: scale(1.1);
        opacity: 1;
        background: var(--danger-gradient);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===========================================
   GAME FOOTER
   =========================================== */
.game-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 15px;
    background: linear-gradient(90deg, 
        rgba(255, 107, 107, 0.1) 0%,
        rgba(255, 217, 61, 0.1) 20%,
        rgba(107, 207, 127, 0.1) 40%,
        rgba(77, 150, 255, 0.1) 60%,
        rgba(157, 75, 255, 0.1) 80%,
        rgba(255, 107, 107, 0.1) 100%);
    color: #4F46E5;
    min-height: 50px;
    border-top: 3px solid #E5E7EB;
    border-image: repeating-linear-gradient(
            90deg,
            #FF6B6B 0px, #FF6B6B 20px,
            #FFD93D 20px, #FFD93D 40px,
            #6BCF7F 40px, #6BCF7F 60px,
            #4D96FF 40px, #4D96FF 80px,
            #9D4BFF 80px, #9D4BFF 100px
        ) 1;
    gap: 5px;
}

.footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px 12px;
    background: linear-gradient(135deg, #FF6B6B, #FFD93D, #6BCF7F, #4D96FF, #9D4BFF);
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    border: 2px solid #E5E7EB;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    max-width: 180px;
}

/* Middle button */
.footer-btn:nth-child(2) {
    flex: 1.2;
    margin: 0 5px;
}

.footer-btn:hover {
    background: #FFD93D;
    color: #4F46E5;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15);
}

.footer-btn i {
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ===========================================
   ERROR MESSAGES
   =========================================== */
.error-message {
    background: rgba(255, 107, 107, 0.1);
    border: 2px solid #ff6b6b;
    border-radius: 12px;
    padding: 20px;
    margin: 10px;
    text-align: center;
}

.error-message i {
    color: #ff6b6b;
    margin-bottom: 15px;
}

.error-message h3 {
    color: #ff6b6b;
    margin: 10px 0;
}

.error-message p {
    color: #666;
    margin: 8px 0;
}

.error-message button {
    background: linear-gradient(145deg, #4D96FF, #6BCBFF);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 15px;
}

.error-message button:hover {
    transform: translateY(-2px);
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */

/* Tablet */
@media (max-width: 768px) {
    .game-footer {
        padding: 8px 10px;
        gap: 4px;
        min-height: 45px;
    }
    
    .footer-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
        gap: 4px;
        border-radius: 6px;
    }
    
    .footer-btn i {
        font-size: 0.8rem;
    }
    
    .footer-btn:nth-child(2) {
        margin: 0 3px;
    }
    
    /* Counting rows - tablet */
    .question-box .level-1 .counting-display { font-size: 5vh; }
    .question-box .level-2 .counting-display { font-size: 5vh; }
    .question-box .level-3 .counting-display { font-size: 5vh; }
    .question-box .level-4 .counting-display { font-size: 5vh; }
    .question-box .level-5 .counting-display { font-size: 4vh; }
    
    .question {
        font-size: clamp(1.5rem, 3.5vw, 3rem);
        letter-spacing: 1px;
        padding: 0 8px;
    }
    .question-box .counting-row {
        gap: 0.15vw !important;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .game-footer {
        padding: 6px 8px;
        gap: 3px;
        min-height: auto;
    }
    
    .footer-btn {
        padding: 5px 6px;
        font-size: 0.75rem;
        gap: 3px;
        border-radius: 5px;
        max-width: none;
    }
    
    .footer-btn i {
        font-size: 0.75rem;
    }
    
    .footer-btn:nth-child(2) {
        margin: 0 2px;
        flex: 1;
    }
    
    /* Counting rows - mobile */
    .question-box .level-1 .counting-display { font-size: 5vh; }
    .question-box .level-2 .counting-display { font-size: 5vh; }
    .question-box .level-3 .counting-display { font-size: 5vh; }
    .question-box .level-4 .counting-display { font-size: 5vh; }
    .question-box .level-5 .counting-display { font-size: 4vh; }
    
    .question-box .counting-row {
        gap: 0.12vw !important;
        margin: 0.15vh 0 !important;
    }
    
    .question {
        font-size: clamp(1.3rem, 3vw, 2.5rem);
        padding: 0 5px;
        line-height: 1.1;
    }
    
    /* Hide button text on very small screens */
    @media (max-width: 360px) {
        .footer-btn span {
            display: none;
        }
        
        .footer-btn {
            padding: 8px;
            justify-content: center;
        }
        
        .footer-btn i {
            font-size: 0.9rem;
            margin: 0;
        }
    }
}

/* Small mobile */
@media (max-width: 400px) {
    .question {
        font-size: 2.5rem;
    }
    
    .question-mark {
        font-size: 3rem;
    }
    
    .option-box {
        font-size: 1.8rem;
        min-height: 75px;
    }
    
    .footer-btn {
        min-width: 90px;
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* Desktop */
@media (min-width: 1200px) {
    .game-footer {
        padding: 12px 20px;
        min-height: 60px;
        gap: 10px;
    }
    
    .footer-btn {
        padding: 10px 16px;
        font-size: 0.95rem;
        gap: 8px;
        border-radius: 10px;
        max-width: 200px;
    }
    
    .footer-btn i {
        font-size: 0.95rem;
    }
    
    .footer-btn:nth-child(2) {
        margin: 0 10px;
    }
    
    /* Counting rows - desktop */
    .question-box .level-1 .counting-display { font-size: 5vh; }
    .question-box .level-2 .counting-display { font-size: 5vh; }
    .question-box .level-3 .counting-display { font-size: 5vh; }
    .question-box .level-4 .counting-display { font-size: 5vh; }
    .question-box .level-5 .counting-display { font-size: 4vh; }
    
    .question-box .counting-row {
        gap: 0.25vw !important;
        margin: 0.25vh 0 !important;
    }
}

/* Height adjustments */
@media (max-height: 750px) {
    .game-header {
        min-height: 55px;
        padding: 18px 25px;
    }
    
    .game-header h2 {
        font-size: 1.5rem;
    }
    
    .game-info {
        min-height: 60px;
        padding: 15px 25px;
    }
    
    .info-value {
        font-size: 1.5rem;
    }
    
    .question {
        font-size: 3.2rem;
    }
    
    .option-box {
        font-size: 2.2rem;
        min-height: 90px;
    }
    
    .game-footer {
        min-height: 60px;
        padding: 15px 25px;
    }
}

/* ===========================================
   UTILITY CLASSES & ANIMATIONS
   =========================================== */

/* Gentle pulse animation */
@keyframes gentlePulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.9;
        transform: scale(1.05);
    }
}

/* Optional animation for icons */
.question-box .counting-icon.animated {
    animation: gentlePulse 2s ease-in-out infinite;
    animation-delay: calc(var(--icon-index, 0) * 0.1s);
}

/* Color change animation */
@keyframes colorChange {
    0% { color: #667eea; }
    50% { color: #fa709a; }
    100% { color: #43e97b; }
}
