:root {
    --primary: #FF9F1C;
    --secondary: #2EC4B6;
    --accent: #FFBF69;
    --bg: #CBF3F0;
    --success: #06D6A0;
    --danger: #EF476F;
    --text: #2D3436;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Quicksand', sans-serif;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F7FA 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    color: var(--text);
}

/* Background Decorations */
.bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.sun {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: #FFD166;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(255, 209, 102, 0.6);
    animation: sunPulse 4s infinite alternate;
}

.cloud {
    position: absolute;
    background: white;
    border-radius: 100px;
    opacity: 0.8;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.05);
}

.cloud::after,
.cloud::before {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
}

.x1 {
    width: 120px;
    height: 50px;
    top: 100px;
    left: -150px;
    animation: moveClouds 25s linear infinite;
}

.x1::after {
    width: 50px;
    height: 50px;
    top: -30px;
    left: 15px;
}

.x1::before {
    width: 60px;
    height: 60px;
    top: -20px;
    right: 15px;
}

.x2 {
    width: 160px;
    height: 70px;
    top: 200px;
    left: -200px;
    animation: moveClouds 35s linear infinite;
    animation-delay: 5s;
    opacity: 0.6;
}

.x2::after {
    width: 70px;
    height: 70px;
    top: -40px;
    left: 20px;
}

.x2::before {
    width: 80px;
    height: 80px;
    top: -30px;
    right: 20px;
}

.x3 {
    width: 100px;
    height: 40px;
    top: 50px;
    left: -120px;
    animation: moveClouds 20s linear infinite;
    animation-delay: 10s;
}

.x3::after {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 10px;
}

.x4 {
    width: 140px;
    height: 60px;
    top: 150px;
    left: -160px;
    animation: moveClouds 30s linear infinite;
    animation-delay: 2s;
}

.x4::after {
    width: 60px;
    height: 60px;
    top: -35px;
    left: 20px;
}

@keyframes moveClouds {
    0% {
        left: -200px;
    }

    100% {
        left: 110%;
    }
}

@keyframes sunPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 40px rgba(255, 209, 102, 0.6);
    }

    100% {
        transform: scale(1.1);
        box-shadow: 0 0 60px rgba(255, 209, 102, 0.8);
    }
}

/* Floating Letters styles */
.floating-letter {
    position: absolute;
    font-family: 'Fredoka One', cursive;
    color: rgba(255, 255, 255, 0.6);
    user-select: none;
    z-index: -1;
    pointer-events: none;
    animation: floatLetter 10s infinite ease-in-out alternate;
}

.l1 {
    top: 10%;
    left: 10%;
    font-size: 8rem;
    color: rgba(255, 159, 28, 0.2);
    animation-duration: 8s;
}

.l2 {
    top: 20%;
    right: 15%;
    font-size: 6rem;
    color: rgba(46, 196, 182, 0.2);
    animation-duration: 12s;
}

.l3 {
    bottom: 15%;
    left: 20%;
    font-size: 10rem;
    color: rgba(239, 71, 111, 0.2);
    animation-duration: 15s;
}

.l4 {
    bottom: 30%;
    right: 10%;
    font-size: 5rem;
    color: rgba(67, 97, 238, 0.2);
    animation-duration: 9s;
    transform: rotate(15deg);
}

.l5 {
    top: 50%;
    left: 5%;
    font-size: 4rem;
    color: rgba(6, 214, 160, 0.2);
    animation-duration: 11s;
}

.l6 {
    top: 15%;
    right: 35%;
    font-size: 7rem;
    color: rgba(255, 209, 102, 0.3);
    animation-duration: 14s;
    transform: rotate(-10deg);
}

@keyframes floatLetter {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    100% {
        transform: translateY(-40px) rotate(10deg);
    }
}

.welcome-text {
    text-align: center;
    margin: 40px 0;
    color: #2D3436;
    /* Darker for contrast on bright sky */
    text-shadow: 2px 2px 0px white;
    padding: 20px;
    position: relative;
    z-index: 2;
}

.welcome-text h1 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--secondary);
    text-shadow: 4px 4px 0px #fff, 6px 6px 0px rgba(0, 0, 0, 0.1);
    letter-spacing: 2px;
}

.welcome-text p {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 700;
    color: #4A5568;
    background: rgba(255, 255, 255, 0.7);
    display: inline-block;
    padding: 5px 20px;
    border-radius: 20px;
    margin-top: 10px;
}

.stage {
    position: relative;
    width: 100%;
    min-height: 50vh;
    flex: 1;
    background: url('https://img.freepik.com/free-vector/laboratory-room-with-scientific-tools_1308-41076.jpg?w=1380&t=st=1706400000~exp=1706400600~hmac=...') no-repeat center center;
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.stage::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.header {
    position: absolute;
    top: 20px;
    width: 90%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.nav-home {
    background: white;
    padding: 10px 20px;
    border-radius: 50px;
    min-width: 80px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: none;
    transition: all 0.2s;
}

.nav-home:hover {
    transform: scale(1.05);
    background: var(--bg);
}

.score-board {
    background: white;
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
}

.header-options {
    display: flex;
    gap: 10px;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
}

.header-options.show {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}

.menu-toggle {
    background: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: none;
    transition: all 0.3s;
    z-index: 101;
}

.menu-toggle:hover {
    transform: rotate(45deg) scale(1.1);
}

.menu-toggle.active {
    background: var(--primary);
    color: white;
}

/* Mobile Menu Logic */
@media (max-width: 768px) {
    .header-options {
        position: fixed;
        top: 80px;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 20px;
        border-radius: 20px 0 0 20px;
        flex-direction: column;
        width: auto;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
        z-index: 100;
        transform: translateX(100%);
        /* Start off-screen on mobile */
    }

    .header-options.show {
        transform: translateX(0);
        opacity: 1;
        pointer-events: all;
    }

    .header {
        position: relative;
        top: 0;
        padding: 10px;
        background: white;
        width: 100%;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }
}

.voice-control,
.level-badge {
    background: white;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    padding: 5px 15px;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 3px solid transparent;
}

.voice-control:hover,
.level-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.voice-control select,
.level-badge select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    padding: 10px 30px 10px 10px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--secondary);
    cursor: pointer;
    outline: none;
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%234361EE' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 10px) center;
}

.level-badge {
    background: var(--secondary);
    color: white;
}

.level-badge select {
    color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
}

.level-badge select option {
    color: #333;
    background: white;
}

.word-builder-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
}

.word-box {
    background: white;
    border-radius: 30px;
    padding: 15px 40px;
    width: 90%;
    max-width: 600px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.5rem, 10vw, 5rem);
    color: var(--secondary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), inset 0 -8px 0 rgba(0, 0, 0, 0.1);
    letter-spacing: clamp(4px, 2vw, 12px);
    position: relative;
    gap: 10px;
}

#puzzle-image {
    max-width: 90%;
    max-height: 200px;
    height: auto;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    display: none;
    /* Hidden by default until loaded */
    object-fit: contain;
}

#puzzle-image.show {
    display: block;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.keyboard-wrapper {
    width: 100%;
    min-height: 35vh;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.keyboard {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    overflow-y: auto;
}

.key {
    background: white;
    border: none;
    border-radius: 18px;
    padding: 15px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 0 #cbd5e1;
}

.key:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #cbd5e1;
}

.key.vowel {
    background: #fff5eb;
    color: var(--primary);
    box-shadow: 0 6px 0 #ffd1b3;
}

.key span.phoneme {
    font-size: 0.7rem;
    font-family: 'Quicksand', sans-serif;
    margin-top: 5px;
    color: #666;
    text-transform: lowercase;
}

.keyboard-tabs {
    display: flex;
    background: #e2e8f0;
    padding: 5px 10px;
    gap: 5px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.keyboard-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 10px 15px;
    border: none;
    background: none;
    font-family: 'Fredoka One', cursive;
    font-size: 0.9rem;
    color: #64748b;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn.active {
    background: #f8fafc;
    color: var(--secondary);
}

.key:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.mascot {
    position: absolute;
    bottom: 20px;
    right: 40px;
    width: 120px;
    z-index: 6;
    animation: float 3s infinite ease-in-out;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom center;
}

.mascot svg path {
    transition: d 0.1s ease-in-out, stroke 0.2s;
}

.mascot:hover {
    transform: scale(1.1) rotate(5deg);
}

.mascot:active {
    transform: scale(0.9) translateY(10px);
}

.mascot.surprise {
    animation: surprise 0.5s ease-out;
}

.mascot.dance {
    animation: dance 0.8s ease-in-out;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0);
    }

    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

@keyframes surprise {
    0% {
        transform: scale(1) translateY(0);
    }

    20% {
        transform: scale(1.2, 0.8) translateY(10px);
    }

    40% {
        transform: scale(0.8, 1.2) translateY(-20px);
    }

    100% {
        transform: scale(1) translateY(0);
    }
}

@keyframes dance {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    15% {
        transform: translate(0, -30px) scale(1.1);
    }

    /* Up */
    30% {
        transform: translate(0, 30px) scale(0.9);
    }

    /* Down */
    45% {
        transform: translate(-30px, 0) rotate(-10deg);
    }

    /* Left */
    60% {
        transform: translate(30px, 0) rotate(10deg);
    }

    /* Right */
    75% {
        transform: translate(0, -15px) scale(1.1);
    }
}

/* Hub Container & Card Styles */
.hub-container {
    max-width: 900px;
    width: 90%;
    margin: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    padding: 50px 20px;
}

.hub-card {
    background: white;
    border-radius: 40px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy */
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.05);
    border: 5px solid transparent;
    position: relative;
    top: 0;
}

.hub-card:hover {
    transform: translateY(-15px) rotate(2deg);
    box-shadow: 0 20px 0 rgba(0, 0, 0, 0.05);
    z-index: 2;
}

.hub-card:active {
    transform: translateY(5px);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.05);
}

.hub-card.lab {
    border-color: #FF9F1C;
    color: #FF9F1C;
}

.hub-card.game {
    border-color: #06D6A0;
    color: #06D6A0;
}

.hub-card.grammar {
    border-color: #EF476F;
    color: #EF476F;
}

.hub-card.detective {
    border-color: #118AB2;
    color: #118AB2;
}

.hub-card.builder {
    border-color: #06D6A0;
    color: #06D6A0;
}

.hub-card.mechanics {
    border-color: #FF9F1C;
    color: #FF9F1C;
}

.hub-card.speaking {
    border-color: #9D4EDD;
    color: #9D4EDD;
}

.hub-card.writing {
    border-color: #118AB2;
    color: #118AB2;
}

.hub-card.lab:hover {
    background: #FFF4E5;
}

.hub-card.game:hover {
    background: #E6FFFA;
}

.hub-card.grammar:hover {
    background: #FFF0F3;
}

.hub-card.detective:hover {
    background: #E0FAFF;
}

.hub-card.builder:hover {
    background: #E6FFFA;
}

.hub-card.mechanics:hover {
    background: #FFF4E5;
}

.hub-card.speaking:hover {
    background: #F3E8FF;
}

.hub-card.writing:hover {
    background: #E0FAFF;
}

.hub-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    display: block;
}

.hub-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: #333;
    margin-bottom: 15px;
}

.hub-desc {
    color: #64748b;
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Missing Success Modal & Sparkle Styles in style.css */
#word-reveal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    padding: 40px 80px;
    border-radius: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    text-align: center;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90%;
    max-width: 500px;
}

#word-reveal.show {
    transform: translate(-50%, -50%) scale(1);
}

#word-reveal h2 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.5rem, 8vw, 5rem);
    color: var(--secondary);
    margin-bottom: 20px;
}

.btn-next {
    background: linear-gradient(135deg, #FF9F1C, #FF8C00);
    color: white;
    border: none;
    padding: 18px 50px;
    border-radius: 50px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 10px 0 #E67E22;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-top: 20px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-next:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 15px 0 #E67E22;
    filter: brightness(1.1);
}

.btn-next:active {
    transform: translateY(6px);
    box-shadow: 0 4px 0 #E67E22;
}

.sparkle {
    position: absolute;
    pointer-events: none;
    animation: sparkle 0.6s ease-out forwards;
    z-index: 100;
}

@keyframes sparkle {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

#game-instruction {
    background: var(--accent);
    color: #333;
    padding: 8px 25px;
    border-radius: 20px;
    font-weight: 700;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.controls-row {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.control-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 15px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.btn-clear {
    background: #ff4d4d;
    color: white;
}

.btn-sound {
    background: var(--secondary);
    color: white;
}

.word-box span.blank {
    display: inline-block;
    min-width: 60px;
    border-bottom: 6px dashed var(--primary);
    color: transparent;
    margin: 0 5px;
}

.word-box span.filled {
    color: var(--secondary);
    border-bottom: 6px solid var(--success);
}

/* Topic Selector Styles */
.topic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(46, 196, 182, 0.2);
    backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.topic-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.topic-container {
    background: white;
    padding: 40px 30px;
    border-radius: 40px;
    max-width: 700px;
    width: 92%;
    text-align: center;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.3);
    border: 10px solid #f7d002;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: none;
}

.topic-container::-webkit-scrollbar {
    display: none;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 30px;
}

.topic-item {
    padding: 20px 10px;
    border-radius: 25px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 4px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1/1;
}

.topic-item:hover {
    transform: scale(1.05) rotate(2deg);
    background: white;
    border-color: #9b5de5;
    box-shadow: 0 15px 30px rgba(155, 93, 229, 0.2);
}

.topic-item:active {
    transform: scale(0.95);
}

.topic-item span {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    display: block;
    margin-bottom: 5px;
}

.topic-item h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 0.9rem;
    color: #475569;
    margin: 0;
}

/* --- SPEAKING GAME STYLES --- */
.mic-btn {
    font-size: 3rem;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    cursor: pointer;
    box-shadow: 0 5px 0 #cbd5e1;
    transition: all 0.2s;
}

.mic-btn:active,
.mic-btn.active {
    background: #EF476F;
    color: white;
    transform: scale(0.95);
    box-shadow: 0 2px 0 #b91c1c;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 71, 111, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(239, 71, 111, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 71, 111, 0);
    }
}

/* --- WORD DETECTIVE STYLES --- */
.detective-card {
    background: white;
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    max-width: 800px;
    text-align: center;
    border-top: 10px solid #118AB2;
    position: relative;
}

.mission-badge {
    background: #118AB2;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-family: 'Fredoka One';
    font-size: 1.2rem;
    display: inline-block;
    margin-bottom: 20px;
    transform: rotate(-2deg);
    box-shadow: 0 5px 15px rgba(17, 138, 178, 0.3);
}

.sentence-display {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-family: 'Quicksand', sans-serif;
    margin: 30px 0;
    line-height: 1.6;
}

.word-token {
    display: inline-block;
    padding: 12px 18px;
    margin: 6px 4px;
    border-radius: 18px;
    background: #f8fafc;
    border: 3px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 800;
    color: #475569;
}

.word-token:hover {
    background: white;
    border-color: #118AB2;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 20px rgba(17, 138, 178, 0.1);
}

.word-token.correct {
    background: #06D6A0 !important;
    color: white !important;
    border-color: #06D6A0 !important;
    transform: scale(1.1);
    box-shadow: 0 10px 25px rgba(6, 214, 160, 0.4);
    pointer-events: none;
}

.word-token.wrong {
    background: #EF476F !important;
    color: white !important;
    border-color: #EF476F !important;
    animation: shake 0.5s;
}

/* --- SENTENCE BUILDER STYLES --- */
.builder-card {
    background: white;
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    max-width: 900px;
    text-align: center;
    border-top: 10px solid #06D6A0;
    min-height: 300px;
}

.slot-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 40px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 20px;
    min-height: 100px;
    align-items: center;
}

.word-slot {
    width: 120px;
    /* Approx word width */
    height: 60px;
    background: #e2e8f0;
    border: 2px dashed #cbd5e1;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.word-slot:empty::before {
    content: '?';
    color: #94a3b8;
    font-size: 1.5rem;
    font-weight: bold;
}

.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 20px;
    border-top: 2px solid #f1f5f9;
}

.draggable-word {
    background: white;
    padding: 15px 25px;
    border-radius: 15px;
    font-family: 'Quicksand', sans-serif;
    font-weight: bold;
    font-size: 1.2rem;
    color: #475569;
    background: #fff;
    box-shadow: 0 4px 0 #cbd5e1;
    border: 1px solid #e2e8f0;
    cursor: grab;
    transition: all 0.1s;
    user-select: none;
}

.draggable-word:active {
    cursor: grabbing;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #cbd5e1;
}

.word-slot .draggable-word {
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 1.5rem;
    color: #06D6A0;
}

.topic-item h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    color: #333;
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 20px;
    display: inline-flex;
}

.diff-btn {
    padding: 12px 25px;
    border: none;
    background: transparent;
    border-radius: 15px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn.active {
    background: white;
    color: var(--secondary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.diff-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
    color: var(--primary);
}

/* --- RESPONSIVE QUERIES --- */

/* Tablet and Smaller Desktop */
@media (max-width: 1024px) {
    .hub-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 20px;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .header {
        position: relative;
        top: 0;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 10px;
        justify-content: space-between;
        align-items: center;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .header-options {
        position: fixed;
        top: 70px;
        /* Below the header */
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(15px);
        padding: 20px;
        border-radius: 20px 0 0 20px;
        display: flex;
        flex-direction: column;
        gap: 15px;
        width: auto;
        min-width: 200px;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
        transform: translateX(120%);
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        z-index: 99;
    }

    .header-options.show {
        transform: translateX(0);
        pointer-events: all;
    }

    .nav-home,
    .menu-toggle {
        width: 45px;
        height: 45px;
        min-width: 45px;
        /* Prevent crushing */
        padding: 0;
        font-size: 1.2rem;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 !important;
        /* Override inline styles */
    }

    .nav-text {
        display: none;
    }

    /* Ensure the score board is visible in the row */
    .score-board {
        order: 2;
        padding: 5px 15px;
        font-size: 1rem;
        height: 45px;
    }

    .menu-toggle {
        order: 3;
    }

    .stage {
        padding: 10px;
        min-height: 35vh;
    }

    .word-box {
        font-size: clamp(2rem, 10vw, 3rem);
        min-height: 80px;
        padding: 10px;
        width: 100%;
        margin-top: 10px;
    }

    #puzzle-image {
        max-height: 150px;
        margin-bottom: 10px;
    }

    .word-box span.blank {
        min-width: 40px;
        border-bottom-width: 4px;
        margin: 0 2px;
    }

    .keyboard {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 6px;
        padding: 10px;
    }

    .key {
        font-size: 1.2rem;
        padding: 8px;
        border-radius: 10px;
    }

    .key span.phoneme {
        font-size: 0.6rem;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .mascot {
        width: 70px;
        right: 10px;
        bottom: 15px;
    }

    /* Topic Selector Mobile */
    .topic-container {
        padding: 30px 10px;
        width: 96%;
        border-width: 6px;
    }

    .topic-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-top: 15px;
    }

    .topic-item {
        padding: 10px 5px;
        border-radius: 18px;
    }

    .topic-item span {
        font-size: 2rem;
    }

    .topic-item h3 {
        font-size: 0.75rem;
    }

    #word-reveal {
        padding: 30px 15px;
        width: 94%;
    }

    #word-reveal h2 {
        font-size: 2.2rem;
    }
}

/* Very Small Screens */
@media (max-width: 480px) {
    .keyboard {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }

    .key {
        font-size: 1.1rem;
        padding: 6px;
    }

    .welcome-text h1 {
        font-size: 2rem;
    }

    .topic-grid {
        grid-template-columns: 1fr;
        /* Single column for very small screens if needed, or keep 2 */
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mascot Blinking Animation */
#mascot-eyes {
    transform-origin: center;
    transform-box: fill-box;
    animation: blink 4s infinite;
}

#pupil-left,
#pupil-right {
    transition: transform 0.1s ease-out;
}

@keyframes blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(0.1);
    }
}

/* --- TENSE GAME STYLES --- */
.grammar-stage {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    padding: 20px;
}

.tense-card {
    background: white;
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.tense-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(90deg, #FF9F1C, #FFBF69);
}

.sentence-box {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    color: #2D3436;
    margin-bottom: 40px;
    line-height: 1.4;
}

.blank-spot {
    border-bottom: 3px solid #EF476F;
    color: #EF476F;
    padding: 0 10px;
    display: inline-block;
    min-width: 100px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.option-btn {
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    padding: 20px;
    border-radius: 20px;
    font-size: 1.5rem;
    font-family: 'Fredoka One', cursive;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    transform: translateY(-5px);
    background: white;
    border-color: #EF476F;
    color: #EF476F;
    box-shadow: 0 10px 20px rgba(239, 71, 111, 0.2);
}

.option-btn.correct {
    background: #06D6A0;
    color: white;
    border-color: #06D6A0;
}

.option-btn.wrong {
    background: #EF476F;
    color: white;
    border-color: #EF476F;
    animation: shake 0.5s;
}

.feedback {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #06D6A0;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
}

.feedback.show {
    opacity: 1;
}

.time-badge {
    background: #FFD166;
    color: #333;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 10px;
}

/* --- ECHO CHAMBER (SPEAKING GAME) IMPROVEMENTS --- */
.speaking-title {
    color: #EF476F !important;
}

.speaking-card {
    border-top-color: #EF476F !important;
    padding: 40px !important;
}

.listen-btn {
    width: auto !important;
    padding: 12px 35px !important;
    border-radius: 50px !important;
    font-family: 'Fredoka One', cursive !important;
    font-size: 1.2rem !important;
    margin-bottom: 20px;
}

.phrase-text {
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(1.8rem, 6vw, 3rem);
    color: #2d3436;
    margin: 40px 0 !important;
    font-weight: 800;
    line-height: 1.2;
}

.mic-wrapper {
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mic-status {
    color: #718096;
    margin-top: 20px;
    font-weight: 700;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

/* @media Overrides for Speaking Game Optimization */
@media (max-width: 600px) {
    .speaking-card {
        padding: 35px 15px !important;
        width: 98% !important;
        border-radius: 25px !important;
    }
    
    .phrase-text {
        font-size: 2rem;
        margin: 30px 0 !important;
    }

    .mic-btn {
        width: 110px;
        height: 110px;
        font-size: 3.5rem;
    }

    .mic-wrapper {
        margin: 30px auto;
    }

    .listen-btn {
        width: 100% !important;
        max-width: 250px;
    }
}

/* --- DICTATION STATION IMPROVEMENTS --- */
.game-title {
    font-family: 'Fredoka One', cursive;
    color: #118AB2;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 5px;
    position: relative;
    z-index: 2;
}

.game-instructions {
    color: #4A5568;
    margin-bottom: 15px;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    background: rgba(255, 255, 255, 0.6);
    display: inline-block;
    padding: 2px 12px;
    border-radius: 10px;
}

.dictation-card {
    border-top-color: #118AB2 !important;
    padding: 40px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.speaker-btn {
    background: var(--secondary);
    color: white;
    font-size: 2rem;
    border-radius: 50%;
    width: 100px;
    height: 100px;
    border: none;
    box-shadow: 0 8px 0 rgba(46, 196, 182, 0.4);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

.speaker-btn:hover {
    transform: scale(1.05);
}

.speaker-btn:active {
    transform: translateY(4px) scale(0.95);
    box-shadow: 0 4px 0 rgba(46, 196, 182, 0.4);
}

.click-hint {
    margin: 15px 0 10px 0;
    color: #718096;
    font-weight: 700;
    font-size: 0.9rem;
}

.sentence-text {
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    margin: 30px 0 !important;
    color: #2d3436;
    line-height: 1.4;
    font-weight: 800;
}

#user-input {
    font-size: clamp(1.1rem, 4vw, 1.8rem);
    padding: 15px 20px !important;
    border-radius: 20px !important;
    border: 3px solid #e2e8f0 !important;
    text-align: center;
    width: 100% !important;
    max-width: 450px !important;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    margin-bottom: 10px;
}

#user-input:focus {
    border-color: var(--secondary) !important;
    box-shadow: 0 0 20px rgba(46, 196, 182, 0.2);
}

/* Specific Media Overrides for Mobile View Optimization */
@media (max-width: 600px) {
    .stage {
        padding: 15px 10px;
        min-height: 40vh;
    }
    
    .grammar-stage {
        padding: 0 !important;
        width: 100%;
    }

    .dictation-card {
        padding: 30px 20px !important;
        margin: 10px auto !important;
        width: 98% !important;
        border-radius: 25px !important;
        min-height: auto !important;
    }

    .speaker-btn {
        width: 85px;
        height: 85px;
        font-size: 1.8rem;
    }

    .game-title {
        font-size: 1.8rem;
    }

    .game-instructions {
        font-size: 0.85rem;
    }

    .sentence-text {
        font-size: 1.5rem;
        margin: 20px 0 !important;
    }

    .control-btn {
        font-size: 1.2rem;
        padding: 15px 30px;
        width: 100%;
        max-width: 300px;
        margin: 15px auto 0 auto;
        display: block;
    }
}

#phrase-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    object-fit: contain;
    border: 5px solid #fff;
    display: none;
    background: #f8fafc;
}

#phrase-image.show {
    display: block;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}