/* =======================================
   ABC Adventure! — Exciting dark theme
   ======================================= */

:root {
    --bg1: #0b0620;
    --bg2: #1a0f3c;
    --bg3: #2d1b69;
    --surface: rgba(255,255,255,0.07);
    --surface-bright: rgba(255,255,255,0.12);
    --glow-purple: rgba(124,58,237,0.45);
    --glow-green: rgba(0,230,118,0.5);
    --glow-red: rgba(255,82,82,0.5);
    --correct: #00E676;
    --wrong: #FF5252;
    --text: #ffffff;
    --text-dim: rgba(255,255,255,0.55);
    --font-display: 'Fredoka', 'Trebuchet MS', cursive;
    --font-body: 'Nunito', 'Trebuchet MS', sans-serif;
    --fast: 0.2s cubic-bezier(.4,0,.2,1);
    --bounce: 0.5s cubic-bezier(.68,-.55,.265,1.55);
    --smooth: 0.35s cubic-bezier(.4,0,.2,1);
}

/* ===== RESET ===== */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { font-size:16px; overflow:hidden; height:100%; height:-webkit-fill-available; }
body {
    font-family: var(--font-body);
    color: var(--text);
    background: linear-gradient(160deg, var(--bg1), var(--bg2), var(--bg3));
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== BACKGROUND CANVAS ===== */
#bg-canvas {
    position: fixed; inset:0; width:100%; height:100%;
    pointer-events: none; z-index:0;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed; inset:0;
    display: flex; flex-direction: column;
    z-index:1;
    opacity:0; pointer-events:none;
    transform: scale(0.96);
    transition: opacity var(--smooth), transform var(--smooth);
}
.screen.active {
    opacity:1; pointer-events:auto; transform:scale(1);
}

/* ===== HOME SCREEN ===== */
.home-stars {
    position: absolute; top:16px; right:20px;
    font-family: var(--font-display);
    font-size:1.1rem; font-weight:700;
    background: var(--surface);
    padding: 6px 16px; border-radius:40px;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.home-center {
    flex:1;
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:16px; padding:24px;
}

.home-title {
    display:flex; gap:8px; margin-bottom:-4px;
}
.title-char {
    font-family: var(--font-display);
    font-size: clamp(4rem, 16vw, 7rem);
    font-weight:700;
    color: var(--c);
    text-shadow: 0 0 30px var(--c), 0 4px 0 rgba(0,0,0,0.3);
    display:inline-block;
    animation: char-pop 0.6s calc(var(--d) * 0.12s) both,
               char-float 3s calc(var(--d) * 0.4s) infinite ease-in-out;
}
@keyframes char-pop {
    0%  { opacity:0; transform:scale(0) rotate(-20deg); }
    60% { transform:scale(1.2) rotate(5deg); }
    100%{ opacity:1; transform:scale(1) rotate(0); }
}
@keyframes char-float {
    0%,100% { transform:translateY(0); }
    50%     { transform:translateY(-10px); }
}

.home-sub {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight:500;
    color: var(--text-dim);
    letter-spacing:1px;
    animation: fade-up 0.6s 0.4s both;
}

.home-mascot {
    font-size: clamp(3.5rem, 14vw, 5.5rem);
    cursor:pointer;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.15));
    animation: owl-bounce 2.5s infinite ease-in-out;
}
@keyframes owl-bounce {
    0%,100% { transform:translateY(0) rotate(0); }
    30%     { transform:translateY(-14px) rotate(-4deg); }
    70%     { transform:translateY(-8px) rotate(4deg); }
}

/* ===== PLAY BUTTON ===== */
.btn-play {
    font-family: var(--font-display);
    font-size:1.4rem; font-weight:700;
    color:#fff;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    padding: 18px 60px;
    border:none; border-radius:60px;
    cursor:pointer;
    box-shadow: 0 0 30px var(--glow-purple), 0 6px 20px rgba(0,0,0,0.3);
    display:flex; align-items:center; gap:10px;
    transition: transform var(--bounce), box-shadow var(--fast);
    animation: pulse-glow 2.5s infinite ease-in-out, fade-up 0.6s 0.6s both;
    -webkit-appearance:none;
}
.btn-play:hover { transform:translateY(-3px) scale(1.04); }
.btn-play:active { transform:scale(0.95) !important; }

.play-arrow { font-size:1.1rem; }

@keyframes pulse-glow {
    0%,100% { box-shadow: 0 0 25px var(--glow-purple), 0 6px 20px rgba(0,0,0,0.3); }
    50%     { box-shadow: 0 0 45px var(--glow-purple), 0 6px 30px rgba(0,0,0,0.4); }
}

/* Practice button */
.btn-practice {
    font-family: var(--font-body);
    font-size:1rem; font-weight:800;
    color: var(--text-dim);
    background: var(--surface);
    border:2px solid rgba(255,255,255,0.1);
    padding:12px 28px; border-radius:40px;
    cursor:pointer;
    transition: transform var(--fast), background var(--fast);
    animation: fade-up 0.6s 0.8s both;
    -webkit-appearance:none;
}
.btn-practice:hover { background: var(--surface-bright); }
.btn-practice:active { transform:scale(0.95); }
.btn-practice.hidden { display:none; }

.practice-count {
    background: var(--wrong);
    color:#fff;
    font-size:0.75rem;
    font-weight:900;
    padding:2px 8px; border-radius:20px;
    margin-left:4px;
}
.practice-count:empty { display:none; }

.btn-secondary {
    font-family: var(--font-body);
    font-size:1.1rem; font-weight:800;
    color: var(--text);
    background: var(--surface);
    border:2px solid rgba(255,255,255,0.15);
    padding:14px 32px; border-radius:50px;
    cursor:pointer;
    transition: transform var(--fast), background var(--fast);
    -webkit-appearance:none;
}
.btn-secondary:hover { background:var(--surface-bright); }
.btn-secondary:active { transform:scale(0.95); }

/* ===== GAME HUD ===== */
.game-hud {
    display:flex; justify-content:space-between; align-items:center;
    padding:14px 18px;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom:1px solid rgba(255,255,255,0.06);
    flex-shrink:0;
}
.hud-item {
    font-family: var(--font-display);
    font-size:1rem; font-weight:600;
}
.hud-streak {
    display:flex; align-items:center; gap:4px;
    opacity:0; transform:scale(0.7);
    transition: opacity var(--smooth), transform var(--bounce);
}
.hud-streak.visible { opacity:1; transform:scale(1); }
.fire { font-size:1.2rem; }

/* ===== SPEAKER ===== */
.game-body {
    flex:1;
    display:flex; flex-direction:column;
    align-items:center; justify-content:center;
    gap: clamp(20px, 4vh, 36px);
    padding:16px 20px;
    min-height:0;
}

.speaker-wrap {
    display:flex; flex-direction:column; align-items:center; gap:8px;
}

.speaker-btn {
    position:relative;
    width: clamp(90px, 22vw, 120px);
    height: clamp(90px, 22vw, 120px);
    border-radius:50%;
    background: radial-gradient(circle at 38% 35%, #7c3aed, #4c1d95);
    border:3px solid rgba(255,255,255,0.15);
    box-shadow: 0 0 35px var(--glow-purple);
    cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    transition: transform var(--fast), box-shadow var(--fast);
    -webkit-appearance:none;
}
.speaker-btn:active { transform:scale(0.92); }
.speaker-icon { font-size: clamp(2rem, 6vw, 2.8rem); position:relative; z-index:2; }

/* Animated sound waves */
.wave {
    position:absolute; inset:-12px;
    border:2px solid rgba(124,58,237,0.35);
    border-radius:50%;
    pointer-events:none;
    opacity:0;
}
.speaker-btn.speaking .wave { animation: wave-ring 1.6s infinite ease-out; }
.w1 { animation-delay:0s !important; }
.w2 { animation-delay:0.35s !important; }
.w3 { animation-delay:0.7s !important; }
@keyframes wave-ring {
    0%   { transform:scale(1); opacity:0.6; }
    100% { transform:scale(1.8); opacity:0; }
}

.speaker-hint {
    font-size:0.8rem;
    font-weight:700;
    color: var(--text-dim);
    letter-spacing:0.5px;
}

/* ===== OPTION CARDS ===== */
.options {
    display:flex; flex-direction:column;
    gap:12px;
    width:100%;
    max-width:420px;
}

.opt-card {
    display:flex; align-items:center; justify-content:center; gap:14px;
    padding: clamp(16px, 3.5vh, 24px) 20px;
    border-radius:20px;
    border:3px solid rgba(255,255,255,0.12);
    cursor:pointer;
    position:relative;
    overflow:hidden;
    transition: transform var(--fast), border-color var(--fast), box-shadow var(--fast);
    -webkit-appearance:none;
    animation: card-in 0.35s calc(var(--ci) * 70ms) both;
}
.opt-card::before {
    content:'';
    position:absolute; inset:0;
    background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.15), transparent 65%);
    pointer-events:none;
}
.opt-card:hover { transform:translateY(-3px) scale(1.03); }
.opt-card:active { transform:scale(0.96) !important; }

.opt-upper {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 7vw, 3.2rem);
    font-weight:700;
    color:#fff;
    text-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.opt-lower {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4.5vw, 2rem);
    font-weight:500;
    color: rgba(255,255,255,0.55);
}

@keyframes card-in {
    0%   { opacity:0; transform:translateY(30px) scale(0.85); }
    60%  { transform:translateY(-4px) scale(1.02); }
    100% { opacity:1; transform:translateY(0) scale(1); }
}

/* Card answer states */
.opt-card.correct {
    border-color: var(--correct) !important;
    box-shadow: 0 0 30px var(--glow-green), inset 0 0 20px rgba(0,230,118,0.15) !important;
    animation: card-correct 0.5s ease forwards !important;
}
.opt-card.wrong {
    border-color: var(--wrong) !important;
    box-shadow: 0 0 25px var(--glow-red) !important;
    animation: card-shake 0.45s ease !important;
}
.opt-card.dimmed {
    opacity:0.25;
    pointer-events:none;
    filter: grayscale(0.5);
}

@keyframes card-correct {
    0%   { transform:scale(1); }
    35%  { transform:scale(1.08); }
    65%  { transform:scale(0.97); }
    100% { transform:scale(1.03); }
}
@keyframes card-shake {
    0%,100% { transform:translateX(0); }
    15%  { transform:translateX(-10px) rotate(-1deg); }
    30%  { transform:translateX(10px) rotate(1deg); }
    45%  { transform:translateX(-7px); }
    60%  { transform:translateX(7px); }
    75%  { transform:translateX(-3px); }
}

/* ===== FEEDBACK POP ===== */
.feedback-pop {
    position:fixed;
    top:50%; left:50%;
    transform:translate(-50%,-50%) scale(0);
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    font-weight:700;
    text-align:center;
    white-space:nowrap;
    pointer-events:none;
    z-index:20;
    opacity:0;
    transition: none;
}
.feedback-pop.show {
    animation: feedback-in 0.5s cubic-bezier(.34,1.56,.64,1) forwards;
}
.feedback-pop.correct { color: var(--correct); text-shadow: 0 0 25px var(--glow-green); }
.feedback-pop.wrong   { color: var(--wrong);   text-shadow: 0 0 20px var(--glow-red); }

@keyframes feedback-in {
    0%   { opacity:0; transform:translate(-50%,-50%) scale(0.3); }
    50%  { opacity:1; transform:translate(-50%,-50%) scale(1.15); }
    100% { opacity:1; transform:translate(-50%,-50%) scale(1); }
}

/* ===== RESULTS SCREEN ===== */
.results-wrap {
    flex:1;
    display:flex; flex-direction:column;
    align-items:center; justify-content:center;
    gap:18px; padding:24px; text-align:center;
}
.results-emoji {
    font-size: clamp(3.5rem, 14vw, 5rem);
    animation: bounce-in 0.6s 0.2s both;
}
.results-heading {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    font-weight:700;
    animation: fade-up 0.5s 0.3s both;
}
.results-stars-big {
    display:flex; align-items:center; gap:10px;
    animation: fade-up 0.5s 0.45s both;
}
.big-star { font-size:2.8rem; animation: spin-star 3s infinite ease-in-out; }
.big-num { font-family:var(--font-display); font-size:3rem; font-weight:700; }

.results-row {
    display:flex; gap:14px;
    animation: fade-up 0.5s 0.6s both;
}
.r-stat {
    background: var(--surface);
    border-radius:16px;
    padding:14px 18px;
    min-width:75px;
}
.r-val { font-family:var(--font-display); font-size:1.6rem; font-weight:700; }
.r-label { font-size:0.7rem; font-weight:700; color:var(--text-dim); text-transform:uppercase; letter-spacing:0.5px; }

.results-trouble {
    animation: fade-up 0.5s 0.75s both;
}
.results-trouble:empty { display:none; }
.trouble-heading {
    font-family: var(--font-display);
    font-size:0.95rem; font-weight:600;
    color: var(--text-dim);
    margin-bottom:8px;
}
.trouble-chips {
    display:flex; gap:8px; flex-wrap:wrap; justify-content:center;
}
.trouble-chip {
    background: rgba(255,82,82,0.15);
    border:2px solid var(--wrong);
    color: var(--wrong);
    font-family: var(--font-display);
    font-size:1rem; font-weight:700;
    padding:4px 14px; border-radius:30px;
}

.results-btns {
    display:flex; gap:12px; flex-wrap:wrap; justify-content:center;
    animation: fade-up 0.5s 0.9s both;
}

/* ===== CONFETTI ===== */
#confetti-canvas {
    position:fixed; inset:0; width:100%; height:100%;
    pointer-events:none; z-index:100;
}

/* ===== MUTE TOGGLE ===== */
.mute-toggle {
    position:fixed; bottom:14px; right:14px; z-index:50;
    width:44px; height:44px; border-radius:50%;
    background: var(--surface);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border:2px solid rgba(255,255,255,0.08);
    font-size:1.2rem;
    cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    transition: transform var(--fast);
    -webkit-appearance:none;
}
.mute-toggle:active { transform:scale(0.9); }
.mute-toggle.muted { opacity:0.4; }

/* ===== STAR BURSTS ===== */
.star-pop {
    position:fixed; pointer-events:none; z-index:90;
    font-size:1.8rem;
    animation: star-fly 0.7s ease-out forwards;
}
@keyframes star-fly {
    0%   { opacity:1; transform:scale(0) translateY(0); }
    40%  { opacity:1; transform:scale(1.4) translateY(-25px); }
    100% { opacity:0; transform:scale(0.6) translateY(-70px); }
}

/* ===== UTILITY KEYFRAMES ===== */
@keyframes fade-up {
    0%   { opacity:0; transform:translateY(18px); }
    100% { opacity:1; transform:translateY(0); }
}
@keyframes bounce-in {
    0%   { transform:scale(0); }
    50%  { transform:scale(1.2); }
    70%  { transform:scale(0.93); }
    100% { transform:scale(1); }
}
@keyframes spin-star {
    0%,100% { transform:rotate(0deg) scale(1); }
    25%     { transform:rotate(12deg) scale(1.1); }
    75%     { transform:rotate(-12deg) scale(1.05); }
}

/* ===== RESPONSIVE ===== */
@media (min-width:500px) {
    .options { max-width:460px; }
}
@media (min-width:768px) {
    .options { max-width:520px; gap:16px; }
    .opt-card { padding:26px 24px; }
}
@media (min-height:800px) {
    .game-body { gap:40px; }
}

/* Accessibility */
@media (prefers-reduced-motion:reduce) {
    *,*::before,*::after {
        animation-duration:0.01ms!important;
        animation-iteration-count:1!important;
        transition-duration:0.01ms!important;
    }
}
