/* ============================================================
   TEST-MAKER ENGINE — GODMODE CSS v4.2
   Palette fix: 10-col × 5-row grid, explicit btn height,
   zero scrollbar for 50 questions. Full godmode pass.
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   1. GOOGLE FONTS
───────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');


/* ─────────────────────────────────────────────────────────────
   2. DESIGN TOKENS
───────────────────────────────────────────────────────────── */
:root {
    --bg-void:      #07090f;
    --bg-base:      #0c1018;
    --bg-surface:   #111827;
    --bg-elevated:  #1a2333;
    --bg-overlay:   #1e2d42;
    --bg-glass:     rgba(17, 24, 39, 0.75);
    --bg-panel:     #1a2333;

    --text-heading:  #eef2f7;
    --text-display:  #eef2f7;
    --text-body:     #8b9ab3;
    --text-muted:    #4a5568;
    --text-faint:    #2d3748;

    --brand:            #f59e0b;
    --brand-primary:    #f59e0b;
    --brand-secondary:  #fbbf24;
    --brand-tertiary:   #fde68a;
    --brand-gradient:   linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --brand-glow:       0 0 40px -8px rgba(245, 158, 11, 0.35);
    --brand-glow-sm:    0 0 20px -5px rgba(245, 158, 11, 0.25);
    --glow-brand:       0 0 40px -8px rgba(245, 158, 11, 0.35);
    --brand-rgb:        245, 158, 11;
    --amber-hot:    #f59e0b;
    --amber-warm:   #d97706;

    --accent:          #06b6d4;
    --accent-surface:  rgba(6, 182, 212, 0.08);
    --accent-border:   rgba(6, 182, 212, 0.2);

    --success:         #10b981;
    --success-surface: rgba(16, 185, 129, 0.08);
    --success-border:  rgba(16, 185, 129, 0.25);
    --success-text:    #34d399;

    --error:           #ef4444;
    --error-surface:   rgba(239, 68, 68, 0.08);
    --error-border:    rgba(239, 68, 68, 0.25);
    --error-text:      #f87171;

    --border-faint:    rgba(255, 255, 255, 0.04);
    --border-subtle:   rgba(255, 255, 255, 0.07);
    --border-default:  rgba(255, 255, 255, 0.1);
    --border-strong:   rgba(255, 255, 255, 0.18);

    --shadow-xs:    0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md:    0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg:    0 20px 48px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
    --shadow-xl:    0 40px 80px rgba(0, 0, 0, 0.6);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.2);

    --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem;
    --sp-4: 1rem;    --sp-5: 1.25rem; --sp-6: 1.5rem;
    --sp-8: 2rem;    --sp-10: 2.5rem; --sp-12: 3rem;

    --r-xs: 0.25rem; --r-sm: 0.375rem; --r-md: 0.5rem;
    --r-lg: 0.75rem; --r-xl: 1rem;     --r-2xl: 1.5rem;
    --r-full: 9999px;

    --font-display: 'Syne', system-ui, sans-serif;
    --font-body:    'DM Sans', system-ui, sans-serif;
    --font-ui:      'DM Sans', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', monospace;

    --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-snappy: cubic-bezier(0.4, 0, 0.2, 1);
    --t-fast: 120ms; --t-normal: 220ms; --t-slow: 380ms;

    /*
      PALETTE MATH — zero-scrollbar for 50 questions:
        sidebar = 268px; padding = 14px L+R = 28px total
        grid width = 240px
        10 cols, gap 3px (9×3=27px): btn-width = (240-27)/10 = 21.3px
        btn-height = 22px FIXED (grid-auto-rows, not aspect-ratio)
        5 rows = 5×22 + 4×3 = 122px grid
        + compact header ~40px + progress ~28px + gaps ~22px = ~212px total
        → fits on any screen taller than 480px
    */
    --sidebar-w:   268px;
    --palette-btn: 22px;
    --palette-gap: 3px;
    --header-h:    60px;
}

.light-mode {
    --bg-void:      #f1f5f9;
    --bg-base:      #f8fafc;
    --bg-surface:   #ffffff;
    --bg-elevated:  #f1f5f9;
    --bg-overlay:   #e8edf4;
    --bg-glass:     rgba(255, 255, 255, 0.8);
    --bg-panel:     #f1f5f9;

    --text-heading:  #0f172a;
    --text-display:  #0f172a;
    --text-body:     #475569;
    --text-muted:    #94a3b8;
    --text-faint:    #cbd5e1;

    --brand:            #d97706;
    --brand-primary:    #d97706;
    --brand-secondary:  #f59e0b;
    --brand-gradient:   linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --brand-glow:       0 0 30px -8px rgba(217, 119, 6, 0.2);
    --brand-glow-sm:    0 0 15px -5px rgba(217, 119, 6, 0.15);
    --glow-brand:       0 0 30px -8px rgba(217, 119, 6, 0.2);
    --brand-rgb:        217, 119, 6;
    --amber-hot: #f59e0b; --amber-warm: #d97706;

    --accent:         #0891b2;
    --accent-surface: rgba(8, 145, 178, 0.06);
    --accent-border:  rgba(8, 145, 178, 0.15);

    --border-faint:   rgba(0, 0, 0, 0.03);
    --border-subtle:  rgba(0, 0, 0, 0.06);
    --border-default: rgba(0, 0, 0, 0.10);
    --border-strong:  rgba(0, 0, 0, 0.18);

    --shadow-xs: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 48px rgba(0,0,0,0.1), 0 8px 16px rgba(0,0,0,0.06);
    --shadow-xl: 0 40px 80px rgba(0,0,0,0.12);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.8), inset 0 -1px 0 rgba(0,0,0,0.05);

    --success-surface: rgba(16,185,129,0.06); --success-border: rgba(16,185,129,0.2);
    --success-text: #059669;
    --error-surface:   rgba(239,68,68,0.06);  --error-border:   rgba(239,68,68,0.2);
    --error-text: #dc2626;
}


/* ─────────────────────────────────────────────────────────────
   3. RESET & BASE
───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-void);
    color: var(--text-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 10%,  rgba(245,158,11,0.05) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 90%,  rgba(6,182,212,0.04)  0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 50% 50%,  rgba(245,158,11,0.02) 0%, transparent 70%),
        repeating-linear-gradient(0deg,  transparent, transparent 39px, rgba(255,255,255,0.012) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.012) 40px);
    z-index: -1; pointer-events: none;
}

body::after {
    content: '';
    position: fixed; inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.055) 1px, transparent 1px);
    background-size: 24px 24px;
    z-index: -1; pointer-events: none; opacity: 0.28;
}

.light-mode body::before {
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(245,158,11,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 90%, rgba(6,182,212,0.06)  0%, transparent 60%),
        repeating-linear-gradient(0deg,  transparent, transparent 39px, rgba(0,0,0,0.018) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(0,0,0,0.018) 40px);
}
.light-mode body::after { opacity: 0.1; background-image: radial-gradient(rgba(0,0,0,0.055) 1px, transparent 1px); }


/* ─────────────────────────────────────────────────────────────
   4. APP CONTAINER
───────────────────────────────────────────────────────────── */
.app-container {
    width: 100%; max-width: 1360px;
    height: 96vh; max-height: 930px;
    background: var(--bg-surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-xl), var(--brand-glow);
    border: 1px solid var(--border-subtle);
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
    animation: appMount 0.55s var(--ease-out) both;
}

.app-container::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--brand-gradient); z-index: 200;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    box-shadow: 0 0 20px rgba(245,158,11,0.55);
}

@keyframes appMount {
    from { opacity: 0; transform: translateY(18px) scale(0.982); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}


/* ─────────────────────────────────────────────────────────────
   5. HEADER
───────────────────────────────────────────────────────────── */
.header {
    height: var(--header-h); min-height: var(--header-h);
    padding: 0 var(--sp-6);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex; justify-content: space-between; align-items: center;
    z-index: 100; position: relative; flex-shrink: 0;
}

.header::after {
    content: '';
    position: absolute; bottom: -1px; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(245,158,11,0.18) 30%, rgba(245,158,11,0.18) 70%, transparent 100%);
    pointer-events: none;
}

.title { display: flex; align-items: center; gap: var(--sp-4); }

.title h1 {
    font-family: var(--font-display); font-size: 1.15rem; font-weight: 800;
    color: var(--text-heading); letter-spacing: -0.03em;
    display: flex; align-items: center; gap: var(--sp-2); line-height: 1;
}

.title h1::before {
    content: '⚡'; font-size: 1rem;
    filter: drop-shadow(0 0 8px rgba(245,158,11,0.9));
    animation: boltPulse 3s ease-in-out infinite;
}

@keyframes boltPulse {
    0%,100% { filter: drop-shadow(0 0 6px rgba(245,158,11,0.8)); }
    50%     { filter: drop-shadow(0 0 16px rgba(245,158,11,1.0)); }
}

.title::after {
    content: ''; display: block; width: 1px; height: 20px;
    background: var(--border-default); border-radius: var(--r-full);
}

#subTitle {
    font-size: 0.66rem; font-weight: 500; color: var(--text-muted);
    letter-spacing: 0.03em; font-family: var(--font-mono);
    background: var(--bg-elevated); padding: 2px 8px;
    border-radius: var(--r-full); border: 1px solid var(--border-faint);
    white-space: nowrap;
}

.badge-panel { display: flex; align-items: center; gap: var(--sp-3); }

/* Timer */
.timer-box {
    display: flex; flex-direction: column; align-items: flex-end;
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-4);
    min-width: 82px; box-shadow: var(--shadow-inset), var(--shadow-xs);
    position: relative; overflow: hidden;
    transition: border-color var(--t-normal) ease, box-shadow var(--t-normal) ease;
}

.timer-box::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

.timer-box.urgent {
    border-color: rgba(239,68,68,0.4);
    animation: urgentPulse 1.5s ease-in-out infinite;
}

@keyframes urgentPulse {
    0%,100% { box-shadow: var(--shadow-inset), 0 0 10px -3px rgba(239,68,68,0.25); }
    50%     { box-shadow: var(--shadow-inset), 0 0 22px -3px rgba(239,68,68,0.5); }
}

.timer-label {
    font-family: var(--font-mono); font-size: 0.52rem; font-weight: 600;
    letter-spacing: 0.14em; color: var(--text-muted); text-transform: uppercase;
    line-height: 1; margin-bottom: 2px;
}

.timer {
    font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600;
    color: var(--brand-primary); line-height: 1.2; letter-spacing: 0.06em;
    text-shadow: 0 0 12px rgba(245,158,11,0.4);
    transition: color var(--t-normal) ease, text-shadow var(--t-normal) ease;
    font-variant-numeric: tabular-nums;
}

.timer-box.urgent .timer, .timer.warning {
    color: var(--error); text-shadow: 0 0 12px rgba(239,68,68,0.5);
}

/* Theme toggle */
.dark-toggle {
    position: relative; width: 36px; height: 36px;
    background: var(--bg-elevated); border: 1px solid var(--border-default);
    border-radius: var(--r-lg); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--t-fast) var(--ease-out);
    box-shadow: var(--shadow-inset); overflow: hidden;
}

.dark-toggle:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-inset), 0 0 0 1px rgba(245,158,11,0.2), 0 0 12px rgba(245,158,11,0.15);
    transform: scale(1.06);
}
.dark-toggle:active { transform: scale(0.94); }

.dark-toggle span {
    position: absolute; font-size: 1rem;
    transition: all 400ms var(--ease-spring); line-height: 1;
}

.dark-toggle .icon-sun  { opacity: 1;  transform: scale(1)   rotate(0deg); }
.dark-toggle .icon-moon { opacity: 0;  transform: scale(0.4) rotate(-90deg); }
.light-mode .dark-toggle .icon-sun  { opacity: 0;  transform: scale(0.4) rotate(90deg); }
.light-mode .dark-toggle .icon-moon { opacity: 1;  transform: scale(1)   rotate(0deg); }


/* ─────────────────────────────────────────────────────────────
   6. MAIN CARD
───────────────────────────────────────────────────────────── */
.main-card {
    flex: 1; display: flex; overflow: hidden; position: relative; min-height: 0;
}


/* ─────────────────────────────────────────────────────────────
   7. SIDEBAR — QUESTION PALETTE
   ═══════════════════════════════════════════════════════════
   ZERO-SCROLLBAR GUARANTEE FOR 50 QUESTIONS:
     Width 268px, padding 14px each side = 240px grid area
     grid-template-columns: repeat(10, 1fr)
     grid-auto-rows: 22px  ← FIXED, not aspect-ratio
     gap: 3px
     5 rows × 22px + 4 gaps × 3px = 122px grid height
     Header row (compact, horizontal): ~38px
     Progress box: ~28px
     Gap between sections: 10px × 3 = 30px
     Total: ~218px → no overflow on any screen ≥ 480px tall
   ═══════════════════════════════════════════════════════════ */
.question-palette {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-base);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 12px 14px 14px;
    gap: 10px;
    /* CRITICAL: clip content, no scrollbar */
    overflow: hidden;
    position: relative;
}

.question-palette::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--brand-primary), transparent 70%); opacity: 0.5;
}

.question-palette::after {
    content: ''; position: absolute; top: 0; bottom: 0; right: -1px; width: 1px;
    background: linear-gradient(180deg, rgba(245,158,11,0.18), transparent 65%);
    pointer-events: none;
}

/* Compact header: title left, legend right — all on one line */
.palette-header {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
    padding-bottom: 8px; border-bottom: 1px solid var(--border-faint);
}

.palette-title {
    font-family: var(--font-mono); font-size: 0.6rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.14em;
    line-height: 1; flex-shrink: 0;
}

.palette-legend { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }

.legend-item {
    font-size: 0.58rem; font-weight: 500; color: var(--text-muted);
    display: flex; align-items: center; gap: 4px; line-height: 1; white-space: nowrap;
}

.legend-item::before {
    content: ''; width: 7px; height: 7px; border-radius: 2px;
    border: 1px solid var(--border-default); background: var(--bg-elevated); flex-shrink: 0;
}

.legend-item.answered::before {
    background: var(--success); border-color: var(--success);
    box-shadow: 0 0 5px rgba(16,185,129,0.5);
}

/* Compact progress box */
.palette-progress {
    flex-shrink: 0;
    background: var(--bg-elevated); border: 1px solid var(--border-faint);
    border-radius: var(--r-md); padding: 6px 10px;
    display: flex; justify-content: space-between; align-items: center;
    position: relative; overflow: hidden;
}

.palette-progress-label {
    font-size: 0.58rem; color: var(--text-muted); font-family: var(--font-mono);
    letter-spacing: 0.04em; position: relative; z-index: 1;
}

.palette-progress-count {
    font-size: 0.68rem; font-weight: 700; font-family: var(--font-mono);
    color: var(--success); position: relative; z-index: 1;
    font-variant-numeric: tabular-nums;
}

/* Standalone #paletteFill — thin progress bar */
#paletteFill {
    height: 2px; flex-shrink: 0;
    background: linear-gradient(90deg, var(--success), var(--brand-primary));
    border-radius: var(--r-full);
    transition: width 400ms var(--ease-out);
    box-shadow: 0 0 6px rgba(16,185,129,0.35);
}

/* If paletteFill is inside a track wrapper */
.palette-fill-track {
    height: 2px; background: var(--bg-overlay); border-radius: var(--r-full); overflow: hidden; flex-shrink: 0;
}
.palette-fill-track .palette-fill, .palette-fill-track #paletteFill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--brand-primary));
    border-radius: var(--r-full); transition: width 400ms var(--ease-out);
    box-shadow: 0 0 6px rgba(16,185,129,0.35);
}

/* ─────────────────────────────────────────────────────────────
   QUESTION BUTTON GRID
   10 cols × 5 rows = 50 questions, exactly 122px tall, no scroll
───────────────────────────────────────────────────────────── */
.grid-buttons {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-auto-rows: var(--palette-btn);   /* ← FIXED 22px rows, key fix */
    gap: var(--palette-gap);
    flex-shrink: 0;
    overflow: hidden;                      /* belt + suspenders */
}

.q-btn {
    /* Height locked to grid-auto-rows — DO NOT use aspect-ratio */
    width: 100%;
    height: var(--palette-btn);
    min-height: var(--palette-btn);
    max-height: var(--palette-btn);
    border-radius: 4px;
    border: 1px solid var(--border-faint);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.56rem; font-weight: 600;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease-out);
    position: relative;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-inset);
    user-select: none; -webkit-user-select: none;
    font-variant-numeric: tabular-nums;
    padding: 0; overflow: hidden;
}

.q-btn:hover {
    border-color: rgba(245,158,11,0.6); color: var(--brand-primary);
    background: rgba(245,158,11,0.09);
    transform: translateY(-1px) scale(1.08);
    box-shadow: var(--shadow-xs), 0 0 0 1px rgba(245,158,11,0.15);
    z-index: 2;
}
.q-btn:active { transform: scale(0.93); }

.q-btn.answered {
    background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: var(--success);
}

.q-btn.answered::after {
    content: ''; position: absolute; bottom: 2px; right: 2px;
    width: 3px; height: 3px; border-radius: 50%;
    background: var(--success); opacity: 0.9;
}

.q-btn.current {
    background: var(--brand-primary); color: var(--bg-void);
    border-color: transparent;
    box-shadow: 0 0 0 1.5px var(--bg-base), 0 0 0 3px var(--brand-primary), var(--brand-glow-sm);
    transform: scale(1.12); z-index: 3; font-weight: 800;
}

.q-btn.answered.current { background: var(--brand-primary); color: var(--bg-void); border-color: transparent; }

.q-btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }


/* ─────────────────────────────────────────────────────────────
   8. CONTENT PANE
───────────────────────────────────────────────────────────── */
.content-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }


/* ─────────────────────────────────────────────────────────────
   9. PROGRESS AREA
───────────────────────────────────────────────────────────── */
.progress-area {
    display: flex; align-items: center; gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-8);
    border-bottom: 1px solid var(--border-faint);
    background: var(--bg-surface); flex-shrink: 0;
}

.question-counter {
    font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
    color: var(--text-heading); background: var(--bg-elevated);
    padding: 3px var(--sp-3); border-radius: var(--r-md);
    border: 1px solid var(--border-subtle); letter-spacing: 0.04em;
    white-space: nowrap; box-shadow: var(--shadow-inset);
    font-variant-numeric: tabular-nums;
}

.progress-bar-container {
    flex: 1; height: 4px; background: var(--bg-elevated);
    border-radius: var(--r-full); overflow: hidden; position: relative;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.progress-fill {
    height: 100%; background: var(--brand-gradient);
    border-radius: var(--r-full); transition: width 400ms var(--ease-out);
    position: relative; box-shadow: 0 0 10px rgba(245,158,11,0.5);
}

.progress-fill::after {
    content: ''; position: absolute; top: 0; left: -40px; width: 40px; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: progressShimmer 2.4s ease-in-out infinite;
}

@keyframes progressShimmer {
    0%       { transform: translateX(0);    opacity: 0; }
    20%,80%  { opacity: 1; }
    100%     { transform: translateX(600px); opacity: 0; }
}

.progress-pct {
    font-family: var(--font-mono); font-size: 0.62rem; font-weight: 600;
    color: var(--brand-primary); white-space: nowrap; min-width: 34px;
    text-align: right; font-variant-numeric: tabular-nums;
}


/* ─────────────────────────────────────────────────────────────
   10. QUESTION BOX
───────────────────────────────────────────────────────────── */
.question-box {
    flex: 1; display: flex; align-items: flex-start; justify-content: center;
    padding: var(--sp-8) var(--sp-8) var(--sp-6);
    overflow-y: auto; overflow-x: hidden; min-height: 0;
}

.question-content-wrapper {
    width: 100%; max-width: 680px; display: flex; flex-direction: column;
    margin: auto; min-height: min-content;
    animation: qFadeIn 0.28s var(--ease-out) both;
}

@keyframes qFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

#questionLabel {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    font-family: var(--font-mono); font-size: 0.63rem; font-weight: 600;
    letter-spacing: 0.12em; color: var(--brand-primary);
    text-transform: uppercase; margin-bottom: var(--sp-3); flex-shrink: 0;
}

#questionLabel::before {
    content: ''; width: 3px; height: 13px; background: var(--brand-gradient);
    border-radius: var(--r-full); box-shadow: 0 0 6px rgba(245,158,11,0.5); flex-shrink: 0;
}

/* QUESTION TEXT — explicit visibility, min-height, no clip */
#questionText, .question-text {
    display: block;
    visibility: visible !important;
    font-family: var(--font-display); font-size: 1.18rem; font-weight: 700;
    line-height: 1.62; color: var(--text-heading); margin-bottom: var(--sp-6);
    letter-spacing: -0.01em; min-height: 2rem; overflow: visible;
    position: relative; z-index: 1; opacity: 1; transform: none;
    transition: opacity 140ms ease, transform 140ms ease;
    will-change: opacity, transform; word-break: break-word;
}

.question-text-wrap {
    overflow: visible; position: relative; padding: 2px 0 4px;
    flex-shrink: 0; min-height: 2rem;
}

/* Options */
.options-grid { display: flex; flex-direction: column; gap: var(--sp-3); }

#optionsContainer .option-item:nth-child(1) { animation-delay:   0ms; }
#optionsContainer .option-item:nth-child(2) { animation-delay:  35ms; }
#optionsContainer .option-item:nth-child(3) { animation-delay:  70ms; }
#optionsContainer .option-item:nth-child(4) { animation-delay: 105ms; }
#optionsContainer .option-item:nth-child(5) { animation-delay: 140ms; }

.option-item {
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--r-xl); padding: var(--sp-4) var(--sp-5);
    display: flex; align-items: center; gap: var(--sp-4);
    cursor: pointer; font-size: 0.92rem; font-weight: 400; color: var(--text-body);
    transition:
        border-color var(--t-normal) var(--ease-out),
        background   var(--t-normal) var(--ease-out),
        color        var(--t-normal) var(--ease-out),
        transform    var(--t-normal) var(--ease-out),
        box-shadow   var(--t-normal) var(--ease-out);
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-inset), var(--shadow-xs);
    user-select: none; -webkit-user-select: none;
    animation: optionIn 0.3s var(--ease-out) both;
}

@keyframes optionIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.option-item::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.025) 50%, transparent 60%);
    transform: translateX(-100%); transition: transform 450ms var(--ease-out); pointer-events: none;
}
.option-item:hover::before { transform: translateX(100%); }

.option-item::after {
    content: ''; position: absolute; left: 0; top: 12%; bottom: 12%; width: 0;
    background: var(--brand-gradient); border-radius: 0 2px 2px 0;
    transition: width var(--t-normal) var(--ease-out);
}
.option-item:hover::after, .option-item.selected::after { width: 3px; }

.option-item:hover {
    border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.06);
    color: var(--text-heading); transform: translateX(6px);
    box-shadow: var(--shadow-sm), -3px 0 0 0 var(--brand-primary);
}
.option-item:active { transform: translateX(4px) scale(0.996); }

.option-item.selected {
    background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.6);
    color: var(--text-heading);
    box-shadow: var(--shadow-sm), -4px 0 0 0 var(--brand-primary), var(--brand-glow-sm);
    transform: translateX(6px);
}

.option-prefix {
    width: 28px; height: 28px; background: var(--bg-surface);
    border: 1px solid var(--border-default); border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 0.68rem; color: var(--text-muted);
    transition: all var(--t-normal) var(--ease-out); flex-shrink: 0; box-shadow: var(--shadow-inset);
}
.option-item:hover .option-prefix, .option-item.selected .option-prefix {
    background: var(--brand-primary); border-color: transparent; color: var(--bg-void);
    box-shadow: 0 0 14px rgba(245,158,11,0.4), var(--shadow-xs); transform: scale(1.06);
}

.option-text { flex: 1; line-height: 1.5; word-break: break-word; }
.option-item:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }


/* ─────────────────────────────────────────────────────────────
   11. ACTION BAR
───────────────────────────────────────────────────────────── */
.action-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--sp-4) var(--sp-8);
    border-top: 1px solid var(--border-faint);
    background: var(--bg-surface); flex-shrink: 0; gap: var(--sp-3); position: relative;
}

.nav-buttons, .action-group-right { display: flex; align-items: center; gap: var(--sp-2); }


/* ─────────────────────────────────────────────────────────────
   12. BUTTON SYSTEM
───────────────────────────────────────────────────────────── */
button {
    font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
    padding: var(--sp-2) var(--sp-5); border: 1px solid transparent;
    border-radius: var(--r-lg); cursor: pointer;
    transition: all var(--t-fast) var(--ease-out); white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--sp-2); letter-spacing: 0.01em;
    position: relative; overflow: hidden; outline: none;
}
button:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

button::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 60%);
    border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity var(--t-fast);
}
button:hover::after { opacity: 1; }

.btn-nav {
    background: var(--bg-elevated); color: var(--text-heading);
    border-color: var(--border-default);
    box-shadow: var(--shadow-inset), var(--shadow-xs); padding: var(--sp-2) var(--sp-4);
}
.btn-nav:hover:not(:disabled) {
    background: var(--bg-overlay); border-color: var(--border-strong);
    transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.btn-nav:active:not(:disabled) { transform: translateY(1px); box-shadow: var(--shadow-inset); }
.btn-nav:disabled { opacity: 0.28; cursor: not-allowed; transform: none !important; box-shadow: none; }

.btn-text {
    background: transparent; color: var(--text-muted);
    border-color: transparent; padding: var(--sp-2) var(--sp-3);
}
.btn-text:hover { color: var(--error); background: var(--error-surface); border-color: var(--error-border); }

.btn-primary {
    background: var(--brand-gradient); color: var(--bg-void); font-weight: 700;
    border-color: transparent; padding: var(--sp-2) var(--sp-6);
    box-shadow: var(--shadow-sm), 0 4px 18px rgba(245,158,11,0.28); letter-spacing: 0.02em;
}
.btn-primary:hover {
    transform: translateY(-2px); box-shadow: var(--shadow-md), 0 8px 28px rgba(245,158,11,0.4);
    filter: brightness(1.06);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-xs), 0 2px 8px rgba(245,158,11,0.2); }

.btn-secondary {
    background: transparent; color: var(--text-muted); border-color: var(--border-default); box-shadow: var(--shadow-inset);
}
.btn-secondary:hover {
    color: var(--brand-primary); border-color: var(--brand-primary);
    background: rgba(245,158,11,0.05); box-shadow: var(--shadow-inset), 0 0 0 1px rgba(245,158,11,0.12);
}

.secondary-actions {
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-3) var(--sp-8) var(--sp-4);
    border-top: 1px dashed var(--border-faint); flex-shrink: 0; gap: var(--sp-3);
}


/* ─────────────────────────────────────────────────────────────
   13. RESULTS VIEW
───────────────────────────────────────────────────────────── */
#resultView { flex-direction: column; overflow-y: auto; }
#resultView.main-card:not(.hidden) { display: flex; }

.results-header {
    text-align: center; padding: var(--sp-8) var(--sp-8) var(--sp-5);
    flex-shrink: 0; position: relative;
}
.results-header::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 260px; height: 260px;
    background: radial-gradient(ellipse, rgba(245,158,11,0.07) 0%, transparent 70%);
    pointer-events: none; z-index: 0;
}
.results-header > * { position: relative; z-index: 1; }

.results-header h2 {
    font-family: var(--font-mono); font-size: 0.65rem; text-transform: uppercase;
    letter-spacing: 0.16em; color: var(--text-muted); margin-bottom: var(--sp-3);
}

.score-big {
    font-family: var(--font-display); font-size: 5rem; font-weight: 800;
    background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; line-height: 1; margin-bottom: var(--sp-2);
    letter-spacing: -0.04em; filter: drop-shadow(0 2px 12px rgba(245,158,11,0.25));
    animation: scoreReveal 0.5s var(--ease-out) both; animation-delay: 80ms;
}

@keyframes scoreReveal {
    from { opacity: 0; transform: scale(0.88) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.score-message {
    font-size: 0.85rem; color: var(--text-body); max-width: 380px; margin: 0 auto;
    line-height: 1.6; animation: scoreReveal 0.4s var(--ease-out) both; animation-delay: 200ms;
}

.stats-row {
    display: flex; justify-content: center; gap: var(--sp-4);
    padding: 0 var(--sp-8) var(--sp-5); flex-shrink: 0;
}

.stat-pill {
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--r-xl); padding: var(--sp-3) var(--sp-5);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    min-width: 88px; box-shadow: var(--shadow-inset), var(--shadow-xs);
    transition: all var(--t-fast) var(--ease-out);
    animation: staggerIn 0.4s var(--ease-out) both;
}
.stat-pill:nth-child(1) { animation-delay:  80ms; }
.stat-pill:nth-child(2) { animation-delay: 150ms; }
.stat-pill:nth-child(3) { animation-delay: 220ms; }
.stat-pill:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: var(--border-default); }

.stat-val {
    font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700;
    color: var(--text-heading); line-height: 1; font-variant-numeric: tabular-nums;
}
.stat-val.correct { color: var(--success); text-shadow: 0 0 12px rgba(16,185,129,0.3); }
.stat-val.wrong   { color: var(--error);   text-shadow: 0 0 12px rgba(239,68,68,0.3); }
.stat-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--text-muted); }

.result-filters {
    display: flex; gap: var(--sp-2); padding: 0 var(--sp-6) var(--sp-3);
    flex-shrink: 0; flex-wrap: wrap;
}

.filter-btn {
    background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text-muted);
    padding: 4px var(--sp-4); border-radius: var(--r-full); font-size: 0.7rem; font-weight: 600;
    box-shadow: var(--shadow-inset); cursor: pointer;
    transition: all var(--t-fast) var(--ease-out); letter-spacing: 0.02em;
}
.filter-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); background: rgba(245,158,11,0.05); }
.filter-btn.active {
    background: var(--brand-primary); color: var(--bg-void); border-color: transparent;
    box-shadow: 0 2px 12px rgba(245,158,11,0.35); transform: translateY(-1px);
}

.results-list {
    flex: 1; overflow-y: auto; padding: 0 var(--sp-6) var(--sp-6);
    display: flex; flex-direction: column; gap: var(--sp-2);
}

.result-item {
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
    border-left: 3px solid var(--border-default);
    transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease, border-color var(--t-fast) ease;
    animation: resultSlideIn 0.3s var(--ease-out) both;
    box-shadow: var(--shadow-inset), var(--shadow-xs);
}

.result-item:nth-child(1)   { animation-delay:   0ms; }
.result-item:nth-child(2)   { animation-delay:  22ms; }
.result-item:nth-child(3)   { animation-delay:  44ms; }
.result-item:nth-child(4)   { animation-delay:  66ms; }
.result-item:nth-child(5)   { animation-delay:  88ms; }
.result-item:nth-child(6)   { animation-delay: 110ms; }
.result-item:nth-child(7)   { animation-delay: 132ms; }
.result-item:nth-child(8)   { animation-delay: 154ms; }
.result-item:nth-child(n+9) { animation-delay: 175ms; }

.result-item:hover { transform: translateX(4px); box-shadow: var(--shadow-sm); border-color: var(--border-default); }

@keyframes resultSlideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.result-item.correct { border-left-color: var(--success); background: var(--success-surface); border-color: var(--success-border); }
.result-item.wrong   { border-left-color: var(--error);   background: var(--error-surface);   border-color: var(--error-border); }
.result-item.skipped { border-left-color: var(--text-muted); opacity: 0.65; }

.result-meta { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--sp-2); }
.result-qnum { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.06em; }
.result-status { font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; padding: 2px var(--sp-2); border-radius: var(--r-full); }
.result-item.correct .result-status { color: var(--success); background: rgba(16,185,129,0.12); }
.result-item.wrong   .result-status { color: var(--error);   background: rgba(239,68,68,0.12); }

/* Compatible with runtime CSS display:flex on .result-question */
.result-question {
    font-family: var(--font-display); font-size: 0.88rem; font-weight: 700;
    color: var(--text-heading); margin-bottom: var(--sp-2); line-height: 1.48; letter-spacing: -0.01em;
}

.result-answer {
    display: flex; gap: var(--sp-4); font-size: 0.78rem; color: var(--text-muted);
    flex-wrap: wrap; margin-top: var(--sp-1);
}
.result-answer span         { display: flex; align-items: center; gap: var(--sp-1); }
.result-answer .your-ans    { color: var(--error); }
.result-answer .wrong-ans   { color: var(--error); }
.result-answer .correct-ans { color: var(--success); }

.result-actions {
    display: flex; justify-content: center; padding: var(--sp-5) var(--sp-6);
    flex-shrink: 0; border-top: 1px solid var(--border-faint); gap: var(--sp-3);
}


/* ─────────────────────────────────────────────────────────────
   14. FOOTER
───────────────────────────────────────────────────────────── */
footer {
    padding: var(--sp-2) var(--sp-6); background: var(--bg-base);
    border-top: 1px solid var(--border-faint); color: var(--text-muted);
    font-family: var(--font-mono); font-size: 0.58rem; text-align: center;
    font-weight: 500; letter-spacing: 0.08em; flex-shrink: 0; opacity: 0.65;
}


/* ─────────────────────────────────────────────────────────────
   15. SCROLLBARS
───────────────────────────────────────────────────────────── */
::-webkit-scrollbar           { width: 4px; height: 4px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: var(--border-default); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--brand-primary); }
::-webkit-scrollbar-corner    { background: transparent; }


/* ─────────────────────────────────────────────────────────────
   16. UTILITIES
───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.stagger-children > * { animation: staggerIn 0.4s var(--ease-out) both; }
.stagger-children > *:nth-child(1) { animation-delay:   0ms; }
.stagger-children > *:nth-child(2) { animation-delay:  60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }

@keyframes staggerIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.toast {
    position: fixed; bottom: var(--sp-6); left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-overlay); color: var(--text-heading);
    border: 1px solid var(--border-default); border-radius: var(--r-xl);
    padding: var(--sp-3) var(--sp-5); font-size: 0.82rem; font-weight: 500;
    box-shadow: var(--shadow-lg); z-index: 9999; opacity: 0;
    transition: all 0.4s var(--ease-spring); white-space: nowrap;
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }


/* ─────────────────────────────────────────────────────────────
   17. RESPONSIVE — TABLET (≤ 900px)
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-container { height: 100dvh; max-height: none; border-radius: 0; border: none; box-shadow: none; }
    .main-card { flex-direction: column; }

    .question-palette {
        width: 100%; border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        padding: 10px 12px; overflow: visible; gap: 8px;
    }

    .grid-buttons { grid-template-columns: repeat(10, 1fr); grid-auto-rows: 20px; gap: 3px; }
    .palette-header { flex-direction: row; }

    .question-box { padding: var(--sp-5) var(--sp-6); align-items: flex-start; justify-content: flex-start; }
    .question-content-wrapper { max-width: 100%; margin: 0; }
    .progress-area { padding: var(--sp-3) var(--sp-5); }
    .action-bar    { padding: var(--sp-3) var(--sp-5); }
    .secondary-actions { padding: var(--sp-2) var(--sp-5) var(--sp-3); }
    .stats-row { gap: var(--sp-2); }
}


/* ─────────────────────────────────────────────────────────────
   18. RESPONSIVE — MOBILE (≤ 640px)
───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    :root { --header-h: 54px; --palette-btn: 20px; --palette-gap: 2px; }

    .header { padding: 0 var(--sp-4); }
    .title h1 { font-size: 1rem; }
    #subTitle { display: none; }
    .title::after { display: none; }
    .timer-box { padding: var(--sp-1) var(--sp-3); min-width: 68px; }
    .timer { font-size: 0.9rem; }

    .question-palette { padding: 8px 10px; gap: 6px; }
    .grid-buttons { grid-template-columns: repeat(10, 1fr); grid-auto-rows: var(--palette-btn); gap: var(--palette-gap); }
    .q-btn { font-size: 0.5rem; }
    .palette-progress { display: none; }

    .progress-area { padding: var(--sp-2) var(--sp-4); }
    .question-box { padding: var(--sp-4); align-items: flex-start; }
    .question-content-wrapper { margin: 0; }
    #questionText, .question-text { font-size: 1.05rem; }
    .option-item { padding: var(--sp-3) var(--sp-4); font-size: 0.87rem; }
    .option-prefix { width: 24px; height: 24px; font-size: 0.62rem; }

    .action-bar { flex-direction: column; padding: var(--sp-3) var(--sp-4); gap: var(--sp-2); }
    .nav-buttons, .action-group-right { width: 100%; }
    .nav-buttons { order: 2; }
    .action-group-right { order: 1; }
    .btn-nav { flex: 1; text-align: center; }
    .btn-primary { width: 100%; justify-content: center; padding: var(--sp-3); }
    .secondary-actions { padding: var(--sp-2) var(--sp-4) var(--sp-3); }

    .score-big { font-size: 3.2rem; }
    .stats-row { flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-4); }
    .results-list { padding: 0 var(--sp-4) var(--sp-4); }
    .result-actions { padding: var(--sp-4); }
    footer { font-size: 0.52rem; }
}


/* ─────────────────────────────────────────────────────────────
   19. REDUCED MOTION
───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        animation-delay: 0ms !important;
    }

    .progress-fill::after { display: none; }

    .title h1::before { animation: none; filter: drop-shadow(0 0 6px rgba(245,158,11,0.6)); }

    .timer-box.urgent {
        animation: none; border-color: rgba(239,68,68,0.5);
        box-shadow: var(--shadow-inset), 0 0 0 1px rgba(239,68,68,0.3);
    }

    .option-item, .result-item { animation: none !important; opacity: 1 !important; transform: none !important; }
}


/* ═══════════════════════════════════════════════════════════
   SECTION 20 — WELCOME SCREEN  (GODMODE v4.2)
   ═══════════════════════════════════════════════════════════
   #welcomeView is position:absolute inset:0 z-index:50 inside
   .app-container — it overlays the pre-rendered test with no
   layout disruption. Session resume bypasses it entirely.
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   20-A. CONTAINER
───────────────────────────────────────────────────────────── */
#welcomeView {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: var(--bg-void);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    /* Inherits appMount entrance from .app-container */
}

/* Dismiss: slides up + fades; JS adds .hidden on animationend */
#welcomeView.wv-leaving {
    animation: wvLeave 440ms var(--ease-out) both;
    pointer-events: none;
}

@keyframes wvLeave {
    0%   { opacity: 1; transform: translateY(0)    scale(1);     }
    100% { opacity: 0; transform: translateY(-24px) scale(0.99); }
}


/* ─────────────────────────────────────────────────────────────
   20-B. AMBIENT BACKGROUND
───────────────────────────────────────────────────────────── */
.wv-blob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}
.wv-blob-1 {
    width: 720px; height: 720px;
    background: radial-gradient(circle, rgba(245,158,11,0.072) 0%, transparent 65%);
    top: -220px; left: -160px;
}
.wv-blob-2 {
    width: 540px; height: 540px;
    background: radial-gradient(circle, rgba(6,182,212,0.05) 0%, transparent 65%);
    bottom: -100px; right: -80px;
}
.wv-blob-3 {
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(245,158,11,0.038) 0%, transparent 65%);
    top: 38%; right: 6%;
}

.wv-dots {
    position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.048) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    opacity: 0.85;
}


/* ─────────────────────────────────────────────────────────────
   20-C. FRAME CHROME
───────────────────────────────────────────────────────────── */

/* Amber glow bar — top edge */
.wv-top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--brand-gradient);
    box-shadow: 0 0 24px rgba(245,158,11,0.55);
    z-index: 2;
    pointer-events: none;
}

/* Corner crosshair marks */
.wv-corner {
    position: absolute;
    width: 20px; height: 20px;
    pointer-events: none;
    z-index: 2;
}
.wv-corner::before,
.wv-corner::after {
    content: '';
    position: absolute;
    background: rgba(245,158,11,0.4);
}
.wv-corner::before { width: 100%;  height: 1.5px; top: 0; left: 0; }
.wv-corner::after  { width: 1.5px; height: 100%;  top: 0; left: 0; }

.wv-corner--tl { top: 26px;    left: 26px; }
.wv-corner--tr { top: 26px;    right: 26px;  transform: scaleX(-1); }
.wv-corner--bl { bottom: 26px; left: 26px;   transform: scaleY(-1); }
.wv-corner--br { bottom: 26px; right: 26px;  transform: scale(-1,-1); }


/* ─────────────────────────────────────────────────────────────
   20-D. SCROLLING TICKER
───────────────────────────────────────────────────────────── */
.wv-ticker {
    position: absolute;
    top: 2px; left: 0; right: 0; /* sits just below the amber bar */
    height: 26px;
    overflow: hidden;
    z-index: 3;
    display: flex;
    align-items: center;
    /* Fade edges */
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 8%, black 92%, transparent 100%);
    mask-image:         linear-gradient(90deg, transparent 0%, black 8%, black 92%, transparent 100%);
}

.wv-ticker-track {
    display: flex;
    gap: 24px;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(245,158,11,0.42);
    animation: wvTick 32s linear infinite;
}

.wv-sep { opacity: 0.35; }

@keyframes wvTick {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}


/* ─────────────────────────────────────────────────────────────
   20-E. STAGGERED ENTRANCE ANIMATION
   JS adds .wv-in to trigger; each element has --d (delay) inline
───────────────────────────────────────────────────────────── */
.wv-anim {
    opacity: 0;
    transform: translateY(16px);
    transition:
        opacity   480ms var(--ease-out),
        transform 480ms var(--ease-out);
    transition-delay: var(--d, 0ms);
}
.wv-anim.wv-in {
    opacity: 1;
    transform: translateY(0);
}


/* ─────────────────────────────────────────────────────────────
   20-F. MAIN CONTENT
───────────────────────────────────────────────────────────── */
.wv-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 40px 24px;
    gap: 0;
    position: relative;
    z-index: 4;
    text-align: center;
    overflow: hidden;
    min-height: 0;
}


/* ─────────────────────────────────────────────────────────────
   20-G. EYEBROW BADGE
───────────────────────────────────────────────────────────── */
.wv-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(245,158,11,0.72);
    margin-bottom: 26px;
    padding: 5px 14px;
    border: 1px solid rgba(245,158,11,0.18);
    border-radius: var(--r-full);
    background: rgba(245,158,11,0.05);
}

.wv-pulse-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--brand-primary);
    box-shadow: 0 0 7px var(--brand-primary);
    animation: wvDot 2.2s ease-in-out infinite;
}

@keyframes wvDot {
    0%,100% { transform: scale(1);   opacity: 1; }
    50%     { transform: scale(0.6); opacity: 0.45; }
}


/* ─────────────────────────────────────────────────────────────
   20-H. BRAND WORDMARK
───────────────────────────────────────────────────────────── */
.wv-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 26px;
}

.wv-bolt {
    font-size: clamp(2.4rem, 4.5vw, 3.2rem);
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 0 18px rgba(245,158,11,0.8));
    animation: wvBolt 3.2s ease-in-out infinite;
}

@keyframes wvBolt {
    0%,100% { filter: drop-shadow(0 0 12px rgba(245,158,11,0.7)); }
    50%     { filter: drop-shadow(0 0 28px rgba(245,158,11,1));   }
}

.wv-name {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 0.88;
    gap: 1px;
}

.wv-n1,
.wv-n2,
.wv-n3 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.4rem, 5.5vw, 4.2rem);
    letter-spacing: -0.04em;
    color: var(--text-heading);
    display: block;
    line-height: 0.92;
}

/* "Maker" gets the amber gradient */
.wv-n2 {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 42%, #d97706 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 12px rgba(245,158,11,0.22));
}


/* ─────────────────────────────────────────────────────────────
   20-I. TAGLINE
───────────────────────────────────────────────────────────── */
.wv-tagline {
    font-family: var(--font-body);
    font-size: clamp(0.88rem, 1.5vw, 1.05rem);
    font-weight: 400;
    line-height: 1.68;
    color: var(--text-body);
    max-width: 420px;
    margin-bottom: 26px;
    letter-spacing: 0.005em;
}


/* ─────────────────────────────────────────────────────────────
   20-J. FEATURE PILLS
───────────────────────────────────────────────────────────── */
.wv-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 32px;
}

.wv-pill {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 5px 13px;
    border-radius: var(--r-full);
    border: 1px solid;
    transition: transform var(--t-fast) var(--ease-out);
}
.wv-pill:hover { transform: translateY(-2px); }

.wv-amber { color: #f59e0b; border-color: rgba(245,158,11,0.28); background: rgba(245,158,11,0.07); }
.wv-cyan  { color: #06b6d4; border-color: rgba(6,182,212,0.24);  background: rgba(6,182,212,0.06);  }
.wv-green { color: #10b981; border-color: rgba(16,185,129,0.22); background: rgba(16,185,129,0.06); }
.wv-ghost { color: var(--text-muted); border-color: var(--border-subtle); background: var(--bg-elevated); }


/* ─────────────────────────────────────────────────────────────
   20-K. JSON CODE BLOCK
───────────────────────────────────────────────────────────── */
.wv-code {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-xl);
    overflow: hidden;
    margin: 0 0 36px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-md);
    text-align: left;
}

.wv-code-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-faint);
}

.wv-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.wv-dot-r { background: #ef4444; opacity: 0.75; }
.wv-dot-y { background: #f59e0b; opacity: 0.75; }
.wv-dot-g { background: #10b981; opacity: 0.75; }

.wv-code-name {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    margin-left: 4px;
}

.wv-code-pre {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    line-height: 1.72;
    padding: 14px 18px;
    overflow-x: auto;
    white-space: pre;
    scrollbar-width: none;
}
.wv-code-pre::-webkit-scrollbar { display: none; }

/* Caption strip below code */
.wv-code-caption {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-top: 1px solid var(--border-faint);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.wv-code-caption strong { color: var(--success); }

.wv-code-caption-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    flex-shrink: 0;
    animation: wvDot 2.2s ease-in-out infinite;
}

/* Syntax colours */
.s-bracket { color: rgba(139,154,179,0.55); }
.s-key     { color: #06b6d4; }
.s-str     { color: rgba(238,242,247,0.52); }
.s-ok      { color: #f59e0b; font-weight: 700; } /* the correct answer */
.s-num     { color: #a78bfa; }
.s-dim     { color: rgba(139,154,179,0.38); }


/* ─────────────────────────────────────────────────────────────
   20-L. CTA — BEGIN BUTTON
───────────────────────────────────────────────────────────── */
.wv-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 13px;
}

.wv-begin-btn {
    /* Override global button styles */
    font-family:     var(--font-display) !important;
    font-weight:     800 !important;
    font-size:       1.05rem !important;
    letter-spacing:  -0.01em !important;
    padding:         15px 50px !important;
    border-radius:   var(--r-xl) !important;
    border:          none !important;
    background:      var(--brand-gradient) !important;
    color:           #0c1018 !important;
    display:         inline-flex !important;
    align-items:     center !important;
    gap:             12px !important;
    cursor:          pointer;
    position:        relative;
    overflow:        hidden;
    box-shadow:
        0 0 0 1px rgba(245,158,11,0.28),
        0 8px 32px rgba(245,158,11,0.32),
        0 2px 8px  rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.22);
    transition: all 200ms var(--ease-out) !important;
}

/* Shimmer sweep on hover */
.wv-begin-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 550ms var(--ease-out);
    pointer-events: none;
}
.wv-begin-btn:hover::before { transform: translateX(120%); }

.wv-begin-btn:hover {
    transform:  translateY(-3px) scale(1.025) !important;
    box-shadow:
        0 0 0 1.5px rgba(245,158,11,0.45),
        0 14px 40px rgba(245,158,11,0.48),
        0 4px 12px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.28) !important;
    filter: brightness(1.06);
}

.wv-begin-btn:active {
    transform:  translateY(0) scale(0.988) !important;
    box-shadow:
        0 0 0 1px rgba(245,158,11,0.25),
        0 4px 14px rgba(245,158,11,0.28) !important;
}

.wv-begin-btn:focus-visible {
    outline:        3px solid var(--brand-primary) !important;
    outline-offset: 3px !important;
}

.wv-btn-bolt  { font-size: 1rem;  line-height: 1; }
.wv-btn-label { line-height: 1; }
.wv-btn-arrow {
    font-size:  1.15rem;
    line-height: 1;
    transition: transform 200ms var(--ease-out);
}
.wv-begin-btn:hover .wv-btn-arrow { transform: translateX(5px); }

/* Keyboard hint */
.wv-hint {
    font-family: var(--font-mono);
    font-size:   0.58rem;
    font-weight: 500;
    color:       var(--text-muted);
    letter-spacing: 0.05em;
}

.wv-hint kbd {
    font-family:   var(--font-mono);
    font-size:     0.56rem;
    font-weight:   600;
    color:         var(--text-body);
    background:    var(--bg-elevated);
    border:        1px solid var(--border-default);
    border-bottom: 2px solid var(--border-strong);
    border-radius: 3px;
    padding:       1px 5px;
}


/* ─────────────────────────────────────────────────────────────
   20-M. FOOTER
───────────────────────────────────────────────────────────── */
.wv-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px 18px;
    font-family:    var(--font-mono);
    font-size:      0.57rem;
    font-weight:    500;
    color:          var(--text-muted);
    letter-spacing: 0.08em;
    position: relative;
    z-index: 4;
    flex-shrink: 0;
}

.wv-mid-dot { opacity: 0.35; }

.wv-ver  { color: var(--brand-primary); opacity: 0.7; }
.wv-free { color: var(--success);       opacity: 0.7; }

.wv-link {
    color: var(--text-body);
    text-decoration: none;
    border-bottom: 1px solid var(--border-subtle);
    transition: color var(--t-fast) ease, border-color var(--t-fast) ease;
}
.wv-link:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}


/* ─────────────────────────────────────────────────────────────
   20-N. RESPONSIVE
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    /* On tablet the welcome overlays the vertical stack layout */
    #welcomeView {
        position: fixed; /* cover the full viewport stacked layout */
    }
}

@media (max-width: 640px) {
    .wv-main { padding: 36px 22px 20px; }

    .wv-brand { gap: 12px; }
    .wv-bolt  { font-size: 2.2rem; }
    .wv-n1, .wv-n2, .wv-n3 { font-size: 2.4rem; }

    .wv-tagline { font-size: 0.86rem; }

    .wv-code { max-width: 100%; }
    .wv-code-pre { font-size: 0.64rem; padding: 11px 13px; }

    .wv-begin-btn { padding: 13px 36px !important; font-size: 0.96rem !important; }

    .wv-ticker { display: none; }
    .wv-eyebrow { font-size: 0.56rem; }

    .wv-corner { width: 15px; height: 15px; }
    .wv-corner--tl { top: 16px; left: 16px; }
    .wv-corner--tr { top: 16px; right: 16px; }
    .wv-corner--bl { bottom: 16px; left: 16px; }
    .wv-corner--br { bottom: 16px; right: 16px; }
}

@media (max-width: 400px) {
    .wv-pills { gap: 6px; }
    .wv-pill  { font-size: 0.56rem; padding: 4px 10px; }
}


/* ─────────────────────────────────────────────────────────────
   20-O. LIGHT MODE
───────────────────────────────────────────────────────────── */
.light-mode #welcomeView  { background: var(--bg-void); }
.light-mode .wv-dots      { background-image: radial-gradient(rgba(0,0,0,0.04) 1px, transparent 1px); }
.light-mode .wv-code      { background: var(--bg-elevated); border-color: var(--border-default); }
.light-mode .wv-code-bar  { background: var(--bg-surface); }


/* ─────────────────────────────────────────────────────────────
   20-P. REDUCED MOTION
───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .wv-anim {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    #welcomeView.wv-leaving {
        animation: none !important;
        opacity: 0;
    }
    .wv-ticker-track { animation: none; }
    .wv-bolt         { animation: none; }
    .wv-pulse-dot    { animation: none; }
    .wv-code-caption-dot { animation: none; }
}



/* ============================================================
   GODMODE PATCH v4.3 — Micro-Interactions & Polish
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   1. BRAND AWARE SELECTION (Global Polish)
───────────────────────────────────────────────────────────── */
::selection {
    background: rgba(245, 158, 11, 0.25);  /* Amber tint */
    color: var(--text-heading);
    text-shadow: none;
}

/* Light mode adjustment for selection contrast */
.light-mode ::selection {
    background: rgba(245, 158, 11, 0.4);
    color: var(--bg-void);
}

/* ─────────────────────────────────────────────────────────────
   2. GODMODE FOCUS STATES (The "Neon Ring")
   Replaces default outline with a glowing double-ring.
   Works for buttons, inputs, and interactive grid items.
───────────────────────────────────────────────────────────── */
button:focus-visible,
.q-btn:focus-visible,
.option-item:focus-visible,
.dark-toggle:focus-visible,
.filter-btn:focus-visible {
    outline: none !important; /* Remove default browser outline */
    
    /* 
       Ring 1: Gap to background (bg-void) 
       Ring 2: The Brand Color
       Ring 3: Outer Glow
    */
    box-shadow: 
        0 0 0 2px var(--bg-void), 
        0 0 0 4px var(--brand-primary),
        0 0 16px rgba(245, 158, 11, 0.4);
        
    z-index: 10; /* Ensure focus ring sits above siblings */
}

/* Light mode focus glow adjustment */
.light-mode button:focus-visible,
.light-mode .q-btn:focus-visible,
.light-mode .option-item:focus-visible {
    box-shadow: 
        0 0 0 2px var(--bg-surface), 
        0 0 0 4px var(--brand-primary),
        0 0 12px rgba(245, 158, 11, 0.3);
}

/* ─────────────────────────────────────────────────────────────
   3. TOUCH OPTIMIZATION (Mobile Performance)
   Removes 300ms tap delay on mobile devices.
───────────────────────────────────────────────────────────── */
button,
.q-btn,
.option-item,
.dark-toggle,
.filter-btn {
    touch-action: manipulation; 
}

/* ─────────────────────────────────────────────────────────────
   4. PREMIUM SCROLL SNAPPING (Results List)
   Makes questions magnetically snap into view when scrolling.
───────────────────────────────────────────────────────────── */
.results-list {
    scroll-snap-type: y mandatory;
}

.result-item {
    scroll-snap-align: start; /* Snap the top of the item to the top of viewport */
    scroll-margin-top: var(--sp-4); /* Add a little breathing room at the top */
}

/* Optional: Make the question content snap too for a "slide" feel */
.question-box {
    scroll-snap-type: y proximity;
}
