/* ========================================
   Phrasal Verbs Lab - Story Choices
   Set 3: Travel & Navigation
   © Cool English 2026

   COLOR STATES:
   Empty blanks (unselected):  GRAY/SLATE    — waiting
   Active/selected blank:      BLUE/PURPLE   — "pick me!" glow
   Filled (correct first try): TEAL GREEN
   Filled (was wrong):         AMBER ORANGE  — still got it
   Word bank default:          SLATE borders
   Word bank used (correct):   TEAL strikethrough
   Hint button:                AMBER
   ======================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --slate-50:  #faf9f8;
    --slate-100: #f3f4f6;
    --slate-200: #e5e7eb;
    --slate-300: #d1d5db;
    --slate-400: #9ca3af;
    --slate-500: #6b7280;
    --slate-600: #4b5563;
    --slate-700: #374151;
    --slate-800: #1f2937;

    --teal-50:   #f0fdfa;
    --teal-100:  #ccfbf1;
    --teal-400:  #2dd4bf;
    --teal-500:  #14b8a6;
    --teal-600:  #0d9488;
    --teal-700:  #0f766e;

    --cyan-400:  #22d3ee;
    --cyan-500:  #06b6d4;
    --cyan-600:  #0891b2;

    --blue-100:   #dbeafe;
    --blue-200:   #bfdbfe;
    --blue-400:   #60a5fa;
    --blue-500:   #3b82f6;
    --blue-600:   #2563eb;

    --purple-100: #ede9fe;
    --purple-300: #c4b5fd;
    --purple-400: #a78bfa;
    --purple-500: #8b5cf6;
    --purple-600: #7c3aed;

    --amber-100:  #fef3c7;
    --amber-400:  #fbbf24;
    --amber-500:  #f59e0b;
    --amber-600:  #d97706;

    --red-100:    #fee2e2;
    --red-400:    #f87171;
    --red-500:    #ef4444;

    --shadow-sm:  0 1px 3px rgba(15,118,110,0.06);
    --shadow-md:  0 4px 6px -1px rgba(15,118,110,0.08), 0 2px 4px -2px rgba(15,118,110,0.06);
    --shadow-lg:  0 10px 15px -3px rgba(15,118,110,0.1), 0 4px 6px -4px rgba(15,118,110,0.08);
    --shadow-xl:  0 20px 25px -5px rgba(15,118,110,0.1), 0 8px 10px -6px rgba(15,118,110,0.08);
    --shadow-2xl: 0 25px 50px -12px rgba(15,118,110,0.2);
}

/* ── Base ── */
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(145deg, #d0f4ef 0%, #dceefb 50%, #e8edfb 100%);
    background-attachment: fixed;
    color: var(--slate-800);
}

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Background blobs */
.app::before, .app::after {
    content: ''; position: fixed; border-radius: 50%;
    z-index: 0; opacity: 0.18; pointer-events: none;
}
.app::before {
    width: 350px; height: 350px;
    background: linear-gradient(135deg, var(--teal-400), var(--cyan-500));
    top: -100px; right: -80px;
    animation: float 10s ease-in-out infinite;
}
.app::after {
    width: 280px; height: 280px;
    background: linear-gradient(135deg, var(--blue-400), var(--purple-400));
    bottom: -60px; left: -60px;
    animation: float 12s ease-in-out infinite reverse;
}
@keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    50%       { transform: translate(20px,-20px) scale(1.05); }
}


/* ========================================
   Header
   ======================================== */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 2rem;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
    border-bottom: 4px solid transparent;
    border-image: linear-gradient(90deg, #FF6B35, #F59E0B, #22C55E, #06B6D4, #8B5CF6, #EC4899) 1;
    box-shadow: 0 4px 20px rgba(15,118,110,0.08);
    position: sticky; top: 0; z-index: 10; flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 1rem; }

.back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 3rem; height: 3rem; border-radius: 0.875rem;
    background: linear-gradient(135deg, var(--slate-50), var(--slate-200));
    color: var(--slate-600); text-decoration: none;
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
    border: 2px solid var(--slate-200);
}
.back-btn:hover {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    border-color: var(--teal-500); color: white;
    transform: translateX(-5px); box-shadow: var(--shadow-lg);
}

.logo {
    width: 3rem; height: 3rem; border-radius: 0.875rem;
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    display: flex; align-items: center; justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(20,184,166,0.3);
}

.title-group { display: flex; align-items: center; gap: 1.25rem; }

.main-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem; font-weight: 800;
    letter-spacing: -0.02em; color: var(--slate-800);
}

.theme-badge {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    color: white; font-size: 1.125rem; font-weight: 700;
    padding: 0.625rem 1.25rem; border-radius: 2rem;
    box-shadow: var(--shadow-md);
}

.header-right { display: flex; align-items: center; gap: 1rem; }

/* Score */
.score-container {
    display: flex; align-items: baseline; gap: 0.25rem;
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    padding: 0.5rem 1.5rem; border-radius: 1rem;
    box-shadow: var(--shadow-lg), 0 0 15px rgba(20,184,166,0.2);
    min-width: 100px; justify-content: center;
}
.score-label {
    font-family: 'Poppins', sans-serif; font-size: 0.8rem; font-weight: 700;
    color: rgba(255,255,255,0.8); text-transform: uppercase;
    letter-spacing: 0.06em; margin-right: 0.3rem;
}
.score-value {
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem; font-weight: 900; color: white;
    transition: transform 0.2s ease;
}
.score-max {
    font-family: 'Poppins', sans-serif;
    font-size: 0.875rem; font-weight: 600; color: rgba(255,255,255,0.7);
}

/* Progress dots */
.progress-container {
    display: flex; align-items: center; gap: 1rem;
    background: white; padding: 0.875rem 1.5rem;
    border-radius: 1.25rem; border: 2px solid var(--slate-200);
    box-shadow: var(--shadow-md);
}
.progress-dots { display: flex; gap: 0.5rem; }
.progress-dot {
    width: 1.25rem; height: 1.25rem; border-radius: 50%;
    background: var(--slate-300);
    transition: all 0.3s ease;
}
.progress-dot.correct {
    background: linear-gradient(135deg, var(--teal-400), var(--teal-500));
    transform: scale(1.15);
}
.progress-dot.got-it {
    background: linear-gradient(135deg, var(--amber-400), var(--amber-500));
    transform: scale(1.15);
}
.progress-count {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem; font-weight: 800; color: var(--teal-600);
}


/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1; padding: 1rem 2rem;
    display: flex; flex-direction: column;
    position: relative; z-index: 5;
    min-height: 0; overflow: visible;
}

.story-container {
    flex: 1; display: flex; gap: 1.75rem;
    min-height: 0; overflow: visible;
}


/* ========================================
   Story Panel — Left
   ======================================== */
.story-panel {
    flex: 1.4; display: flex; flex-direction: column;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
    border-radius: 1.5rem; padding: 1.5rem 2rem;
    box-shadow: var(--shadow-xl);
    border: 3px solid var(--slate-200);
    min-height: 0; overflow-y: auto;
}

.story-header {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 1.25rem; flex-shrink: 0;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--slate-100);
}
.story-emoji { font-size: 2.75rem; }
.story-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.25rem; font-weight: 900;
    color: var(--teal-600);
    letter-spacing: -0.02em;
}

.story-body { flex: 1; }

.story-paragraph {
    font-family: 'Nunito', sans-serif;
    font-size: 1.75rem; font-weight: 600;
    color: var(--slate-700);
    line-height: 2.1;
    margin-bottom: 1.25rem;
}
.story-paragraph:last-child { margin-bottom: 0; }


/* ========================================
   Story Blanks — DISTINCT COLORS PER STATE
   ======================================== */
.story-blank {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.125rem 0.75rem;
    border-radius: 0.625rem;
    vertical-align: baseline;
    transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem;
    line-height: 1.6;
    cursor: pointer;
    border: 3px solid;
}

/* Number badge */
.blank-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.75rem; height: 1.75rem;
    border-radius: 50%;
    font-size: 0.95rem; font-weight: 800;
    flex-shrink: 0;
}

/* ── EMPTY (unselected) — GRAY/SLATE ── */
.story-blank.empty {
    background: var(--slate-100);
    border-color: var(--slate-300);
    border-style: dashed;
    color: var(--slate-500);
    font-weight: 700;
}
.story-blank.empty .blank-number {
    background: var(--slate-400); color: white;
}
.story-blank.empty .blank-placeholder {
    color: var(--slate-300);
    letter-spacing: 0.15em;
}
.story-blank.empty:hover {
    background: var(--blue-100);
    border-color: var(--blue-400);
    border-style: dashed;
    color: var(--blue-500);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(59,130,246,0.15);
}
.story-blank.empty:hover .blank-number {
    background: var(--blue-500);
}

/* ── ACTIVE (selected) — BLUE/PURPLE glow ── */
.story-blank.active {
    background: linear-gradient(135deg, var(--blue-100), var(--purple-100));
    border-color: var(--purple-500);
    border-style: solid;
    color: var(--purple-600);
    box-shadow: 0 0 0 4px rgba(139,92,246,0.2), 0 4px 15px rgba(139,92,246,0.2);
    animation: blankPulse 1.5s ease-in-out infinite;
}
.story-blank.active .blank-number {
    background: linear-gradient(135deg, var(--blue-500), var(--purple-500)); color: white;
}
.story-blank.active .blank-placeholder {
    color: var(--purple-400);
}
@keyframes blankPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(139,92,246,0.15), 0 4px 15px rgba(139,92,246,0.15); }
    50%       { box-shadow: 0 0 0 8px rgba(139,92,246,0.08), 0 4px 20px rgba(139,92,246,0.25); }
}

/* ── FILLED CORRECT (first try) — TEAL ── */
.story-blank.correct {
    background: linear-gradient(135deg, var(--teal-50), var(--teal-100));
    border-color: var(--teal-500);
    border-style: solid;
    color: var(--teal-600);
    cursor: default;
    animation: fillPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.story-blank.correct .blank-number { background: var(--teal-500); color: white; }
.story-blank.correct .blank-word  { font-weight: 900; color: var(--teal-600); }

/* ── INCORRECT (showing wrong word briefly) — RED ── */
.story-blank.incorrect {
    background: var(--red-100);
    border-color: var(--red-400);
    border-style: solid;
    color: var(--red-500);
    cursor: default;
}
.story-blank.incorrect .blank-number { background: var(--red-400); color: white; }

/* ── CORRECTED (was wrong, now shows correct) — AMBER ── */
.story-blank.corrected {
    background: linear-gradient(135deg, var(--amber-100), #fffbeb);
    border-color: var(--amber-500);
    border-style: solid;
    color: var(--amber-600);
    cursor: default;
    animation: fillPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.story-blank.corrected .blank-number { background: var(--amber-500); color: white; }
.story-blank.corrected .blank-word  { font-weight: 900; color: var(--amber-600); }

@keyframes fillPop {
    0%   { transform: scale(0.8); opacity: 0.5; }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Shake on wrong */
.story-blank.shake {
    animation: blankShake 0.45s ease !important;
}
@keyframes blankShake {
    0%, 100% { transform: translateX(0); }
    15%, 55%  { transform: translateX(-6px); }
    35%, 75%  { transform: translateX(6px); }
}


/* ========================================
   Word Bank — Right Sidebar
   ======================================== */
.wordbank-panel {
    flex: 0 0 280px; display: flex; flex-direction: column;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
    border-radius: 1.5rem; padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    border: 3px solid var(--slate-200);
    min-height: 0;
}

.wordbank-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem; font-weight: 900;
    color: var(--purple-600);
    text-align: center; margin-bottom: 0.5rem;
}

.wordbank-hint {
    font-family: 'Nunito', sans-serif;
    font-size: 1.05rem; font-weight: 600;
    color: var(--slate-400);
    text-align: center; margin-bottom: 1rem;
    line-height: 1.4;
    transition: all 0.3s ease;
}
.wordbank-hint.pulse {
    animation: hintPulse 0.6s ease;
}
@keyframes hintPulse {
    0%, 100% { transform: scale(1); color: var(--slate-400); }
    50%       { transform: scale(1.05); color: var(--purple-500); }
}

.hint-blank {
    background: var(--purple-100); color: var(--purple-600);
    padding: 0.1rem 0.5rem; border-radius: 0.375rem;
    font-weight: 700;
}

.wordbank-grid {
    flex: 1; display: flex; flex-direction: column;
    gap: 0.625rem;
    overflow-y: auto;
}

/* ── Default word bank button ── */
.word-chip {
    display: flex; align-items: center; justify-content: center;
    gap: 0.375rem;
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem; font-weight: 800;
    color: var(--slate-700);
    background: white;
    border: 3px solid var(--slate-200);
    border-radius: 0.875rem;
    cursor: pointer;
    padding: 0.625rem 1rem;
    transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    opacity: 0;
    animation: fadeInUp 0.3s ease forwards;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.word-chip:hover:not(.used):not(:disabled) {
    border-color: var(--purple-400);
    background: var(--purple-100);
    transform: scale(1.06);
    box-shadow: var(--shadow-lg), 0 0 15px rgba(139,92,246,0.15);
    color: var(--purple-600);
}
.word-chip:active:not(.used) { transform: scale(0.97); }

/* ── Selected ── */
.word-chip.selected {
    background: linear-gradient(135deg, var(--blue-100), var(--purple-100));
    border-color: var(--purple-500);
    color: var(--purple-700);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.2), var(--shadow-lg);
}

/* ── Used (placed) — TEAL strikethrough ── */
.word-chip.used {
    background: linear-gradient(135deg, var(--teal-50), var(--teal-100));
    border-color: var(--teal-400);
    color: var(--teal-500);
    opacity: 0.55;
    cursor: default;
    text-decoration: line-through;
    pointer-events: none;
}

.word-chip .checkmark-icon {
    width: 1.1em; height: 1.1em;
    flex-shrink: 0; margin-left: 0.25rem;
}

/* Wobble on wrong */
.word-chip.wobble {
    animation: wobbleSquish 0.55s ease !important;
}
@keyframes wobbleSquish {
    0%   { transform: scale(1) rotate(0deg); }
    15%  { transform: scale(1.1,0.85) rotate(-4deg); }
    30%  { transform: scale(0.85,1.1) rotate(3deg); }
    45%  { transform: scale(1.05,0.92) rotate(-2deg); }
    60%  { transform: scale(0.95,1.03) rotate(1deg); }
    75%  { transform: scale(1.02,0.98) rotate(-0.5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Word bank footer */
.wordbank-footer {
    display: flex; gap: 0.625rem; margin-top: 0.875rem; flex-shrink: 0;
}

.hint-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 0.5rem; width: 100%;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem; font-weight: 700;
    padding: 0.875rem 0.75rem;
    border-radius: 0.875rem; border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--amber-400), var(--amber-500));
    color: white;
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: var(--shadow-md);
}
.hint-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); }

.see-results-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 1rem 0.75rem;
    border-radius: 0.875rem;
    border: 3px solid rgba(255,255,255,0.4);
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(37,99,235,0.45), 0 0 0 4px rgba(37,99,235,0.2);
    animation: pulse-results-btn 2s ease-in-out infinite;
}
.see-results-btn:hover { transform: scale(1.04); box-shadow: 0 6px 24px rgba(37,99,235,0.55), 0 0 0 6px rgba(37,99,235,0.1); }

@keyframes pulse-results-btn {
    0%, 100% { box-shadow: 0 4px 16px rgba(37,99,235,0.45), 0 0 0 4px rgba(37,99,235,0.2); }
    50%       { box-shadow: 0 4px 20px rgba(37,99,235,0.6),  0 0 0 8px rgba(37,99,235,0.0); }
}


/* ========================================
   Feedback Toast (correct / wrong)
   ======================================== */
.feedback-toast {
    position: fixed; bottom: 5.5rem; left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex; align-items: center; gap: 0.875rem;
    padding: 1rem 2rem; border-radius: 1.25rem;
    font-family: 'Nunito', sans-serif;
    box-shadow: var(--shadow-2xl);
    z-index: 150; opacity: 0;
    transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: none;
}
.feedback-toast.visible {
    opacity: 1; transform: translateX(-50%) translateY(0);
}
.feedback-toast.correct {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
}
.feedback-toast.incorrect {
    background: linear-gradient(135deg, var(--red-400), var(--red-500));
}
.toast-icon {
    width: 2.25rem; height: 2.25rem;
    background: rgba(255,255,255,0.2); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
}
.toast-message {
    font-size: 1.375rem; font-weight: 800; color: white;
}
.toast-points {
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem; font-weight: 900; color: rgba(255,255,255,0.9);
}


/* ========================================
   Floating Wrong Emoji
   ======================================== */
.wrong-emoji {
    position: fixed; font-size: 3rem;
    pointer-events: none; z-index: 200;
    transform: translate(-50%, 0);
    animation: emojiFloat 0.9s ease-out forwards;
}
@keyframes emojiFloat {
    0%   { opacity: 1; transform: translate(-50%, 0) scale(0.5) rotate(0deg); }
    20%  { opacity: 1; transform: translate(-50%, -30px) scale(1.3) rotate(-10deg); }
    100% { opacity: 0; transform: translate(-50%, -120px) scale(0.6) rotate(15deg); }
}


/* ========================================
   Hint Toast
   ======================================== */
.hint-toast {
    position: fixed; bottom: 5rem; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white; padding: 1rem 2rem;
    border-radius: 1rem;
    font-family: 'Nunito', sans-serif;
    font-size: 1.375rem; font-weight: 700;
    display: flex; align-items: center; gap: 0.75rem;
    box-shadow: var(--shadow-2xl);
    z-index: 150; opacity: 0;
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.hint-toast.visible {
    opacity: 1; transform: translateX(-50%) translateY(0);
}
.hint-toast-icon { font-size: 1.5rem; }


/* ========================================
   Completion Overlay
   ======================================== */
.completion-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center;
    z-index: 100; opacity: 0; transition: opacity 0.3s ease;
}
.completion-overlay.visible { display: flex; opacity: 1; }

.completion-content {
    background: white; border-radius: 2rem; padding: 3rem 4rem;
    text-align: center; box-shadow: var(--shadow-2xl); max-width: 90%;
    animation: bounceIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes bounceIn {
    0%   { transform: scale(0.6); opacity: 0; }
    50%  { transform: scale(1.04); }
    100% { transform: scale(1); opacity: 1; }
}

.comp-emoji  { font-size: 5rem; margin-bottom: 1rem; }
.comp-title  {
    font-family: 'Poppins', sans-serif; font-size: 2.5rem;
    font-weight: 900; color: var(--slate-800); margin-bottom: 1rem;
}
.comp-score  {
    font-family: 'Poppins', sans-serif; font-size: 4rem;
    font-weight: 900; color: var(--teal-500); margin-bottom: 0.5rem;
}
.comp-pct    {
    font-family: 'Poppins', sans-serif; font-size: 2rem;
    font-weight: 700; color: var(--slate-500); margin-bottom: 0.75rem;
}
.comp-stats  {
    display: flex; gap: 2rem; justify-content: center; margin-bottom: 1.25rem;
}
.comp-stat   { display: flex; flex-direction: column; align-items: center; }
.comp-stat-value {
    font-family: 'Poppins', sans-serif; font-size: 2rem; font-weight: 900;
}
.comp-stat-value.correct  { color: var(--teal-500); }
.comp-stat-value.mistakes { color: var(--red-400); }
.comp-stat-label {
    font-family: 'Nunito', sans-serif; font-size: 1.125rem; font-weight: 700;
    color: var(--slate-500);
}
.comp-msg    {
    font-family: 'Nunito', sans-serif; font-size: 1.5rem;
    font-weight: 600; color: var(--slate-600); margin-bottom: 2rem;
}
.comp-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.comp-retry, .comp-home {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 1rem 2rem; border-radius: 1rem;
    font-family: 'Poppins', sans-serif; font-size: 1.25rem;
    font-weight: 700; cursor: pointer; transition: all 0.3s ease;
    text-decoration: none;
}
.comp-retry {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    color: white; border: none; box-shadow: var(--shadow-lg);
}
.comp-retry:hover { transform: scale(1.05); box-shadow: var(--shadow-xl); }
.comp-home  { background: white; color: var(--slate-700); border: 3px solid var(--slate-300); }
.comp-home:hover { border-color: var(--teal-400); color: var(--teal-600); transform: scale(1.05); }


/* ========================================
   Footer
   ======================================== */
.footer {
    padding: 0.5rem; background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px); border-top: 2px solid var(--slate-200);
    text-align: center; z-index: 10; flex-shrink: 0;
}
.footer p { font-family: 'Nunito', sans-serif; font-size: 1rem; color: var(--slate-400); font-weight: 600; }


/* ========================================
   Scrollbars
   ======================================== */
.story-panel::-webkit-scrollbar,
.wordbank-grid::-webkit-scrollbar { width: 6px; }
.story-panel::-webkit-scrollbar-track,
.wordbank-grid::-webkit-scrollbar-track { background: transparent; }
.story-panel::-webkit-scrollbar-thumb,
.wordbank-grid::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 3px; }
.story-panel::-webkit-scrollbar-thumb:hover,
.wordbank-grid::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }


/* ========================================
   Responsive — Desktop Height
   ======================================== */
@media (max-height: 900px) {
    .main-content { padding: 0.75rem 2rem; }
    .story-container { gap: 1.25rem; }
    .story-paragraph { font-size: 1.625rem; }
    .story-title { font-size: 2rem; }
}

@media (max-height: 800px) {
    .main-content { padding: 0.5rem 1.5rem; }
    .story-container { gap: 1rem; }
    .story-paragraph { font-size: 1.5rem; }
    .story-title { font-size: 1.75rem; }
    .word-chip { font-size: 1.375rem; }
    .story-emoji { font-size: 2rem; }
}

@media (max-height: 700px) {
    .story-paragraph { font-size: 1.375rem; }
    .story-title { font-size: 1.625rem; }
    .word-chip { font-size: 1.25rem; }
}


/* ========================================
   Responsive — Desktop Width
   ======================================== */
@media (max-width: 1400px) {
    .story-paragraph { font-size: 1.5rem; }
    .story-blank { font-size: 1.5rem; }
    .blank-number { width: 1.5rem; height: 1.5rem; font-size: 0.85rem; }
    .word-chip { font-size: 1.5rem; }
}

@media (max-width: 1200px) {
    .main-content { padding: 1rem 1.5rem; }
    .story-container { gap: 1.25rem; }
    .story-panel { padding: 1.25rem 1.5rem; }
    .story-title { font-size: 1.875rem; }
    .story-paragraph { font-size: 1.375rem; }
    .story-blank { font-size: 1.375rem; }
    .wordbank-panel { flex: 0 0 240px; padding: 1.25rem; }
    .word-chip { font-size: 1.375rem; padding: 0.5rem 0.875rem; }
    .wordbank-title { font-size: 1.5rem; }
}

@media (max-width: 1024px) {
    .story-container { flex-direction: column; }
    .story-panel { flex: none; max-height: 55vh; }
    .wordbank-panel { flex: none; }
    .wordbank-grid { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .word-chip { flex: 0 0 auto; padding: 0.5rem 1.25rem; }
}


/* ========================================
   Responsive — Mobile (< 768px)
   Unlock scroll, word bank moves to TOP
   ======================================== */
@media (max-width: 768px) {
    /* Unlock viewport — story can be long */
    html, body { height: auto; overflow-y: auto; overflow-x: hidden; }
    .app { height: auto; min-height: 100vh; overflow: visible; }
    .main-content { flex: none; padding: 0.5rem; overflow: visible; }
    .story-container { flex: none; flex-direction: column; gap: 0.75rem; overflow: visible; }

    /* Word bank moves to top so choices are visible before reading */
    .wordbank-panel { order: -1; flex: none; }
    .story-panel { flex: none; max-height: none; padding: 1rem 1.25rem; border-radius: 1.25rem; border-width: 2px; }

    /* Word bank horizontal on mobile */
    .wordbank-grid { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .word-chip { flex: 0 0 auto; font-size: 1.25rem; padding: 0.5rem 1rem; border-width: 2px; }
    .wordbank-panel { padding: 1rem; border-radius: 1.25rem; border-width: 2px; }
    .wordbank-title { font-size: 1.375rem; margin-bottom: 0.375rem; }
    .wordbank-hint { font-size: 0.95rem; margin-bottom: 0.5rem; }
    .hint-btn { font-size: 1rem; padding: 0.75rem; }

    /* Header */
    .header { flex-wrap: nowrap; gap: 0.5rem; padding: 0.5rem 0.75rem; }
    .header-left { flex: 1; min-width: 0; gap: 0.5rem; }
    .header-right { flex-shrink: 0; gap: 0.5rem; }
    .back-btn { width: 2.5rem; height: 2.5rem; border-radius: 0.625rem; }
    .back-btn svg { width: 20px; height: 20px; }
    .logo { display: none; }
    .main-title { font-size: 1.25rem; }
    .theme-badge { display: none; }
    .score-container { padding: 0.375rem 1rem; min-width: auto; }
    .score-label { font-size: 0.7rem; }
    .score-value { font-size: 1.375rem; }
    .score-max { font-size: 0.75rem; }
    .progress-dots { display: none; }
    .progress-container { padding: 0.5rem 1rem; border-radius: 1.5rem; }
    .progress-count { font-size: 1.25rem; }

    /* Story text */
    .story-header { margin-bottom: 0.75rem; gap: 0.75rem; padding-bottom: 0.75rem; }
    .story-emoji { font-size: 2rem; }
    .story-title { font-size: 1.5rem; }
    .story-paragraph { font-size: 1.25rem; line-height: 1.9; margin-bottom: 1rem; }
    .story-blank { font-size: 1.25rem; padding: 0.1rem 0.5rem; border-width: 2px; }
    .blank-number { width: 1.375rem; height: 1.375rem; font-size: 0.8rem; }

    /* Toasts */
    .hint-toast { font-size: 1.125rem; padding: 0.875rem 1.5rem; bottom: 4rem; }
    .feedback-toast { bottom: 4.5rem; padding: 0.75rem 1.5rem; }
    .toast-message { font-size: 1.125rem; }
    .toast-points { font-size: 1.375rem; }

    .footer p { font-size: 0.875rem; }
    .app::before, .app::after { display: none; }
}

@media (max-width: 480px) {
    .header { padding: 0.5rem; gap: 0.375rem; }
    .back-btn { width: 2.25rem; height: 2.25rem; }
    .main-title { font-size: 1.125rem; }
    .score-container { padding: 0.25rem 0.75rem; }
    .score-label { font-size: 0.65rem; }
    .score-value { font-size: 1.125rem; }
    .main-content { padding: 0.375rem; }
    .story-panel { padding: 0.875rem 1rem; }
    .story-emoji { font-size: 1.75rem; }
    .story-title { font-size: 1.25rem; }
    .story-paragraph { font-size: 1.125rem; line-height: 1.85; }
    .story-blank { font-size: 1.125rem; }
    .blank-number { width: 1.25rem; height: 1.25rem; font-size: 0.75rem; }
    .wordbank-panel { padding: 0.75rem; }
    .wordbank-title { font-size: 1.125rem; }
    .word-chip { font-size: 1.05rem; padding: 0.375rem 0.75rem; }
    .hint-btn { font-size: 0.9rem; padding: 0.625rem; }
    .hint-btn svg { width: 18px; height: 18px; }
    .hint-toast { font-size: 1rem; padding: 0.75rem 1.25rem; }
    .completion-content { padding: 2rem 1.5rem; }
    .comp-title { font-size: 2rem; }
    .comp-score { font-size: 3rem; }
}


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

/* ========================================
   V4 RESPONSIVE CLIP/SCROLL SAFETY PATCH
   Same principle as Definitions V4:
   shrink first, then scroll the real content area instead of clipping.
   This patch is intentionally last so it wins the cascade.
   ======================================== */
@media (min-width: 900px) {
    html,
    body,
    .app {
        height: 100dvh;
        overflow: hidden;
    }

    .main-content {
        min-height: 0;
        overflow: hidden;
    }

    .story-container {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-gutter: stable;
        overscroll-behavior: contain;
    }

    .story-panel,
    .wordbank-panel {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-gutter: stable;
    }

    .wordbank-grid {
        min-height: 0;
        overflow-y: auto;
    }

    .story-header,
    .footer,
    .header {
        flex-shrink: 0;
    }
}

/* Medium teacher-laptop/projector heights, including responsive test panes around 1058px tall. */
@media (min-width: 900px) and (max-height: 1100px) {
    .header {
        padding-top: clamp(0.45rem, 0.8vh, 0.75rem);
        padding-bottom: clamp(0.45rem, 0.8vh, 0.75rem);
    }

    .main-content {
        padding-top: clamp(0.5rem, 0.9vh, 0.85rem);
        padding-bottom: clamp(0.5rem, 0.9vh, 0.85rem);
    }

    .story-container {
        gap: clamp(0.8rem, 1.4vw, 1.35rem);
    }

    .story-panel {
        padding: clamp(1rem, 1.7vh, 1.35rem) clamp(1.25rem, 2vw, 1.75rem);
    }

    .story-header {
        margin-bottom: clamp(0.65rem, 1vh, 1rem);
        padding-bottom: clamp(0.55rem, 0.9vh, 0.85rem);
    }

    .story-title {
        font-size: clamp(1.65rem, 3vh, 2.1rem);
        line-height: 1.1;
    }

    .story-emoji {
        font-size: clamp(1.9rem, 3.3vh, 2.5rem);
    }

    .story-paragraph {
        font-size: clamp(1.25rem, 2.5vh, 1.6rem);
        line-height: 1.65;
        margin-bottom: clamp(0.75rem, 1.2vh, 1rem);
    }

    .story-blank {
        font-size: clamp(1.2rem, 2.4vh, 1.55rem);
    }

    .wordbank-panel {
        flex-basis: clamp(230px, 20vw, 280px);
        padding: clamp(1rem, 1.6vh, 1.35rem);
    }

    .wordbank-title {
        font-size: clamp(1.35rem, 2.5vh, 1.65rem);
    }

    .word-chip {
        font-size: clamp(1.15rem, 2.25vh, 1.45rem);
        padding-top: clamp(0.4rem, 0.7vh, 0.55rem);
        padding-bottom: clamp(0.4rem, 0.7vh, 0.55rem);
    }

    .footer {
        padding-top: clamp(0.25rem, 0.6vh, 0.45rem);
        padding-bottom: clamp(0.25rem, 0.6vh, 0.45rem);
    }
}

@media (min-width: 900px) and (max-height: 820px) {
    .story-paragraph {
        font-size: 1.2rem;
        line-height: 1.55;
    }

    .word-chip {
        font-size: 1.1rem;
    }

    .wordbank-grid {
        gap: 0.45rem;
    }
}

@media (min-width: 900px) and (max-height: 720px) {
    .story-paragraph {
        font-size: 1.05rem;
        line-height: 1.45;
    }

    .story-title {
        font-size: 1.45rem;
    }

    .word-chip {
        font-size: 0.95rem;
        padding: 0.3rem 0.65rem;
    }
}
