/* --- Base & Typography --- */
:root {
    --primary: #FF8C42; /* Soft Orange - can be overridden per game */
    --secondary: #4CAF50; /* Green */
    --bg: #E0F7FA; /* Light Blue */
    --text: #2c3e50;
    --wrong: #b0bec5; /* Grey for disabled */
}

body {
    font-family: 'Comic Sans MS', 'Varela Round', sans-serif;
    background-color: var(--bg);
    margin: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    user-select: none;
}

h1, h2, h3, p { margin: 0; text-align: center; color: var(--text); }

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: var(--bg);
    transition: opacity 0.3s;
}
.active { display: flex; }

/* --- Buttons --- */
.btn-large {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #E67E22;
    font-weight: bold;
    margin-top: 20px;
    transition: transform 0.1s;
}
.btn-large:active { transform: translateY(4px); box-shadow: 0 2px 0 #E67E22; }

/* --- Game Layout --- */
.game-header {
    position: absolute;
    top: 10px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    font-size: 1.2rem;
    font-weight: bold;
    color: #555;
    z-index: 10;
}

/* --- Modern HUD --- */
.game-hud {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-3);
    z-index: 10;
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    font-weight: 700;
    font-size: var(--font-size-lg);
    color: var(--color-gray-700);
}

.stat-score { color: var(--color-warning); }
.stat-streak { color: var(--color-error); }

/* --- The Question Card --- */
.main-card {
    background: white;
    padding: var(--space-6);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    text-align: center;
    max-width: 320px;
    margin-bottom: var(--space-6);
    border: 4px solid var(--primary);
    position: relative;
}

.main-image-container {
    width: 100%;
    height: 200px;
    background: var(--color-gray-100);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.game-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s;
    background-color: #fff;
}

.word-label {
    font-size: var(--font-size-3xl);
    text-transform: uppercase;
    color: var(--color-primary);
    letter-spacing: 2px;
    font-weight: 700;
}

/* --- The Answer Options --- */
.options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 500px;
}

.option-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    cursor: pointer;
    border: 3px solid var(--color-gray-200);
    box-shadow: var(--shadow-md);
    transition: all var(--duration-base) var(--ease-out);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.option-card:hover {
    transform: translateY(-6px) rotate(-2deg);
    border-color: var(--color-primary);
    box-shadow: 0 12px 20px rgba(59, 130, 246, 0.3);
}

.option-card:active {
    transform: scale(0.95);
}

.option-img-box {
    width: 100%;
    height: 140px;
    background: var(--color-gray-100);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.option-card:hover .option-img-box img {
    transform: scale(1.1);
}

.option-img-box img {
    transition: transform 0.3s;
}

.option-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-gray-700);
    text-transform: capitalize;
}

/* --- Text-Only Option Cards (for identify games like Vehicles) --- */
.option-card-text-only {
    padding: var(--space-6) var(--space-4);
    min-height: 120px;
    justify-content: center;
}

.option-card-text-only .option-text-large {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-gray-800);
    text-transform: capitalize;
    text-align: center;
    line-height: 1.3;
}

.option-card-text-only .option-audio-btn {
    margin-top: var(--space-3);
}

/* --- Audio Button for Options --- */
.option-audio-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: var(--space-2);
    box-shadow: 0 4px 0 var(--color-primary-darker), var(--shadow-md);
    transition: all var(--duration-fast) var(--ease-out);
}

.option-audio-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--color-primary-darker), var(--shadow-lg);
}

.option-audio-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--color-primary-darker), var(--shadow-sm);
}

.option-audio-btn.playing {
    animation: pulse-audio 0.6s ease-in-out infinite;
}

@keyframes pulse-audio {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* --- LET'S GO Button --- */
.next-btn-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-base) var(--ease-out);
}

.next-btn-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.next-btn {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: var(--font-size-2xl);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: var(--space-4) var(--space-10);
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(180deg, var(--color-success) 0%, var(--color-success-dark) 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 0 #047857, var(--shadow-xl);
    transition: all var(--duration-fast) var(--ease-out);
    animation: bounce-next 1s ease-in-out infinite;
}

.next-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #047857, var(--shadow-xl);
}

.next-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #047857, var(--shadow-sm);
    animation: none;
}

@keyframes bounce-next {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* --- Logic States --- */
.correct {
    border-color: var(--color-success) !important;
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    animation: bounce-in 0.5s var(--ease-bounce);
}

.wrong {
    border-color: var(--color-error) !important;
    animation: shake 0.5s var(--ease-out);
}

.disabled {
    opacity: 0.4;
    filter: grayscale(100%);
    border-color: var(--color-gray-300) !important;
    background: var(--color-gray-100);
    pointer-events: none;
    transform: scale(0.95);
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* --- Combo Text Animation --- */
.combo-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 3rem;
    color: #FFD700;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 100;
}
@keyframes comboPop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.5) rotate(10deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2) rotate(0deg); opacity: 0; }
}

/* --- Loading Spinner --- */
.loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--primary);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Progress Bar --- */
.progress-track {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    height: 8px;
    background: #ddd;
}
.progress-fill {
    height: 100%;
    background: var(--secondary);
    width: 0%;
    transition: width 0.5s;
}

/* --- Speech Speed Control --- */
.speed-control {
    position: absolute;
    top: 50px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
}
.speed-control label {
    font-size: 0.8rem;
    color: #666;
    font-weight: bold;
}
.speed-slider {
    width: 80px;
    accent-color: var(--primary);
}
.speed-value {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: bold;
    min-width: 35px;
}
.tts-badge {
    position: fixed;
    bottom: 15px;
    left: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 10;
}

/* --- Cute Replay Button --- */
.replay-btn {
    background: linear-gradient(135deg, #FFD93D 0%, #FF6B6B 100%);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    box-shadow: 0 4px 0 #E55A5A, 0 6px 10px rgba(0,0,0,0.15);
    transition: all 0.15s ease;
    animation: pulse-glow 2s ease-in-out infinite;
}
.replay-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 0 #E55A5A, 0 8px 15px rgba(255,107,107,0.4);
}
.replay-btn:active {
    transform: translateY(3px) scale(0.95);
    box-shadow: 0 1px 0 #E55A5A;
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 4px 0 #E55A5A, 0 6px 10px rgba(0,0,0,0.15); }
    50% { box-shadow: 0 4px 0 #E55A5A, 0 6px 20px rgba(255,217,61,0.5); }
}

/* --- Preload Progress Bar --- */
.preload-progress-container {
    width: 280px;
    height: 20px;
    background: #ddd;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.preload-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    transition: width 0.3s ease-out;
}

/* --- Fun Loading Animals --- */
.loading-animals {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 320px;
}
.animal {
    font-size: 2.8rem;
    display: inline-block;
    animation: bounce 0.6s ease-in-out infinite;
    cursor: pointer;
    transition: transform 0.2s;
}
.animal:hover {
    animation: none;
    transform: scale(1.5) rotate(20deg);
}
.animal:active {
    transform: scale(2) rotate(-20deg);
}
.bounce-1 { animation-delay: 0s; }
.bounce-2 { animation-delay: 0.1s; }
.bounce-3 { animation-delay: 0.2s; }
.bounce-4 { animation-delay: 0.3s; }
.bounce-5 { animation-delay: 0.4s; }
.bounce-6 { animation-delay: 0.5s; }
.bounce-7 { animation-delay: 0.6s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}
@keyframes superJump {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-80px) scale(1.5) rotate(20deg); }
    50% { transform: translateY(-100px) scale(1.8) rotate(-10deg); }
    70% { transform: translateY(-60px) scale(1.3) rotate(15deg); }
    100% { transform: translateY(0) scale(1) rotate(0deg); }
}

/* --- Home Button --- */
.home-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
    z-index: 1000;
}
.home-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}
.home-btn:active {
    transform: scale(0.95);
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    /* Adjust HUD for smaller screens */
    .game-hud {
        top: 10px;
        gap: var(--space-2);
    }

    .hud-stat {
        padding: var(--space-1) var(--space-3);
        font-size: var(--font-size-base);
    }

    /* TTS badge at bottom */
    .tts-badge {
        bottom: 10px;
        left: 10px;
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    /* Adjust speed control */
    .speed-control {
        top: 70px;
        right: 10px;
        padding: 6px 10px;
        gap: 6px;
    }

    .speed-slider {
        width: 60px;
    }

    /* Smaller home button on mobile */
    .home-btn {
        width: 44px;
        height: 44px;
        top: 12px;
        left: 12px;
    }

    /* Reduce card sizes */
    .main-card {
        max-width: 280px;
        padding: var(--space-4);
    }

    .main-image-container {
        height: 160px;
    }

    .word-label {
        font-size: var(--font-size-2xl);
    }

    .options-container {
        gap: 12px;
        max-width: 100%;
    }

    .option-card {
        padding: var(--space-3);
    }

    .option-img-box {
        height: 100px;
    }

    .option-text {
        font-size: var(--font-size-base);
    }
}

@media (max-width: 480px) {
    /* Stack HUD vertically on very small screens */
    .game-hud {
        flex-direction: column;
        gap: var(--space-1);
        top: 8px;
    }

    .hud-stat {
        padding: var(--space-1) var(--space-2);
        font-size: var(--font-size-sm);
    }

    /* Further adjust badges */
    .tts-badge {
        bottom: 8px;
        left: 8px;
        font-size: 0.6rem;
    }

    .speed-control {
        top: 100px;
        padding: 5px 8px;
    }

    .speed-control label {
        font-size: 0.7rem;
    }

    .speed-slider {
        width: 50px;
    }

    /* Even smaller cards */
    .main-card {
        max-width: 240px;
        padding: var(--space-3);
    }

    .main-image-container {
        height: 120px;
    }

    .word-label {
        font-size: var(--font-size-xl);
        letter-spacing: 1px;
    }

    .option-img-box {
        height: 80px;
    }

    .option-text {
        font-size: var(--font-size-sm);
    }
}
