/* ============================================
   SYNTHESIS — Institutional Design System
   ============================================ */

/* CSS Custom Properties */
[data-theme="dark"], :root {
    /* Colors - Modern Dark Glassmorphic */
    --bg-primary: #0f172a;
    --bg-secondary: #0b1121;
    --bg-tertiary: #1e293b;
    
    /* Apple Liquid Glass styling */
    --surface: rgba(15, 23, 42, 0.45);
    --surface-hover: rgba(30, 41, 59, 0.55);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.15), inset 0 -1px 1px rgba(0, 0, 0, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Using modern vibrant accents instead of flat gold */
    --gold: #8b5cf6; 
    --gold-muted: #7c3aed;
    --gold-pale: #a78bfa;
    --divider: rgba(255, 255, 255, 0.1);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --info: #0ea5e9;
    --info-bg: rgba(14, 165, 233, 0.15);

    /* Category Colors */
    --cat-tps: #8b5cf6;
    --cat-tps-bg: rgba(139, 92, 246, 0.15);
    --cat-tkd: #10b981;
    --cat-tkd-bg: rgba(16, 185, 129, 0.15);
    --cat-saintek: #0ea5e9;
    --cat-saintek-bg: rgba(14, 165, 233, 0.15);
    --cat-soshum: #f43f5e;
    --cat-soshum-bg: rgba(244, 63, 94, 0.15);
    --cat-adv: #8b5cf6;
    --cat-adv-bg: rgba(139, 92, 246, 0.15);
    --cat-adv-border: rgba(139, 92, 246, 0.3);

    /* Typography */
    --font-display: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-raleway: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-spacemono: 'JetBrains Mono', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Borders & Glass */
    --radius: 20px;
    --glass-blur: 40px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #cbd5e1;
    
    /* Apple Liquid Glass styling */
    --surface: rgba(255, 255, 255, 0.35);
    --surface-hover: rgba(255, 255, 255, 0.5);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.9), inset 0 -1px 1px rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --gold: #6366f1; 
    --gold-muted: #4f46e5;
    --gold-pale: #818cf8;
    --divider: rgba(0, 0, 0, 0.08);
    
    --success: #059669;
    --success-bg: rgba(16, 185, 129, 0.15);
    --error: #dc2626;
    --error-bg: rgba(239, 68, 68, 0.15);
    --warning: #d97706;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --info: #0284c7;
    --info-bg: rgba(14, 165, 233, 0.15);
    
    --cat-tps: #7c3aed;
    --cat-tps-bg: rgba(124, 58, 237, 0.1);
    --cat-tkd: #059669;
    --cat-tkd-bg: rgba(5, 150, 105, 0.1);
    --cat-saintek: #0284c7;
    --cat-saintek-bg: rgba(2, 132, 199, 0.1);
    --cat-soshum: #e11d48;
    --cat-soshum-bg: rgba(225, 29, 72, 0.1);
    --cat-adv: #6366f1;
    --cat-adv-bg: rgba(99, 102, 241, 0.1);
    --cat-adv-border: rgba(99, 102, 241, 0.25);
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    background-image: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 20%),
                      radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 20%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 15px;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Particle Canvas — hidden in redesign */
#particles {
    display: none;
}

/* View System */
.view {
    display: none;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes scoreReveal {
    from { stroke-dashoffset: 339.292; }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Theme Toggle Styles */
.theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0;
}
.theme-toggle svg { width: 22px; height: 22px; transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: none; }
.theme-toggle:hover { transform: translateY(-2px) scale(1.05); }

/* Panel — Apple Liquid Glass */
.glass-card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur)) saturate(200%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(200%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    transition: all var(--transition-normal);
    box-shadow: var(--glass-shadow), var(--glass-highlight);
}

.glass-card:hover {
    border-color: rgba(139, 92, 246, 0.35); /* Accent tint */
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px -8px rgba(0,0,0,0.25), var(--glass-shadow), var(--glass-highlight);
}

/* ========== BUTTONS ========== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 14px 32px;
    background: var(--gold);
    color: #ffffff; /* Always white for primary buttons with vibrant colors */
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    transition: all var(--transition-normal);
    letter-spacing: 0.02em;
}

[data-theme="light"] .btn-primary {
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

/* Kill glow animation */
.btn-glow {
    animation: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter var(--transition-fast), background var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(201, 168, 76, 0.08);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(192, 57, 43, 0.3);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition-fast);
}

.btn-danger:hover {
    filter: brightness(1.15);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--ivory-dim);
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-back:hover {
    color: var(--gold);
}

.btn-back-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    color: var(--ivory-dim);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.btn-back-sm:hover {
    color: var(--gold);
    border-color: var(--gold-muted);
}

/* ========== LANDING PAGE — PRESTIGE HERO ========== */

#landing.view.active {
    display: flex;
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    background: transparent;
    border-radius: 0;
}

/* Accent bar — full-height left border */
.hero-accent-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, var(--gold) 0%, var(--info) 100%);
    flex-shrink: 0;
    z-index: 2;
}

/* Hero content — left-aligned, vertically centred */
.hero-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding: 64px 72px 64px 88px;
    max-width: 860px;
    width: 100%;
}

/* ── Top badge row ── */
.hero-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 36px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
}

.hero-badge-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    flex-shrink: 0;
    box-shadow: 0 0 8px var(--gold);
}

.hero-badge-text {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    text-transform: uppercase;
}

.hero-badge-right {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    background: var(--surface);
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--divider);
}

/* ── Eyebrow ── */
.hero-eyebrow {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--gold);
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* ── Hero Title ── */
.hero-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(48px, 8vw, 96px);
    line-height: 1.1;
    height: 1.1em;
    display: block;
    white-space: nowrap;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Scrambling letter spans */
.hero-title .letter {
    display: inline-block;
    vertical-align: top;
    transition: none;
}

.hero-title .letter.scrambling {
    font-family: var(--font-mono);
    color: var(--gold);
    -webkit-text-fill-color: var(--gold);
}

/* ── Subtitle ── */
.hero-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    max-width: 600px;
    line-height: 1.6;
}

/* ── Divider ── */
.hero-divider {
    display: none;
}

/* ── Stats Box ── */
.hero-stats-box {
    display: flex;
    width: 100%;
    max-width: 580px;
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    margin-bottom: 48px;
    overflow: hidden;
    box-shadow: 0 8px 32px -8px rgba(0,0,0,0.1);
}

.stats-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 24px;
    border-right: 1px solid var(--divider);
}

.stats-cell:last-child {
    border-right: none;
}

.stats-cell-num {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 8px;
}

.stats-cell-lbl {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ── CTA Button ── */
.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 18px;
    padding: 16px 36px;
    background: var(--gold);
    color: #ffffff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

[data-theme="light"] .hero-cta {
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
    filter: brightness(1.1);
}

.hero-cta:active {
    transform: translateY(0);
}

/* Custom manual arrow inside CTA */
.cta-arrow {
    display: inline-flex;
    align-items: center;
    gap: 0;
    position: relative;
    width: 28px;
    height: 12px;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.hero-cta:hover .cta-arrow {
    transform: translateX(4px);
}

.cta-arrow-line {
    display: block;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.cta-arrow-tip {
    display: block;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    border-radius: 1px;
}

/* ── Decorative geometry — top right ── */
.hero-deco-squares {
    position: absolute;
    top: 10%;
    right: 5%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

.deco-square {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}

.deco-sq-outer {
    width: 300px;
    height: 300px;
    top: -100px;
    right: -50px;
    background: rgba(139, 92, 246, 0.2); /* Deep purple/indigo glow */
    border: none;
}

.deco-sq-inner {
    width: 250px;
    height: 250px;
    top: 150px;
    right: 150px;
    background: rgba(14, 165, 233, 0.2); /* Cyan glow */
    border: none;
}

/* ── Decorative geometry — bottom right (crosshair) ── */
.hero-deco-crosshair {
    display: none;
}

/* ── Legacy stat-card classes (used by subject selection count system) ── */
.landing-container { display: none; }
.ugm-emblem, .emblem-ring, .emblem-inner, .emblem-text, .emblem-year { display: none; }
.hero-stats, .stat-card { display: none; }

/* Keep stat-number/stat-label accessible to JS count updater */
.stat-number { display: none; }
.stat-label { display: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .hero-content {
        padding: 48px 32px 48px 44px;
    }
    .hero-title {
        font-size: clamp(48px, 12vw, 72px);
    }
    .hero-stats-box {
        max-width: 100%;
    }
    .stats-cell {
        padding: 14px 16px;
    }
    .stats-cell-num {
        font-size: 22px;
    }
    .hero-divider {
        max-width: 100%;
    }
    .hero-deco-squares {
        opacity: 0.5;
        right: 20px;
        top: 20px;
    }
    .hero-deco-crosshair {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-content {
        padding: 36px 20px 36px 32px;
    }
    .hero-top-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .hero-title {
        font-size: clamp(40px, 14vw, 60px);
        white-space: normal;
    }
    .hero-stats-box {
        flex-direction: column;
    }
    .stats-cell {
        border-right: none;
        border-bottom: 1px solid rgba(201,168,76,0.2);
    }
    .stats-cell:last-child {
        border-bottom: none;
    }
}


/* ========== SUBJECT SELECTION ========== */
.select-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

.select-header {
    margin-bottom: var(--space-xl);
}

.select-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
    color: var(--ivory);
}

.select-subtitle {
    color: var(--ivory-dim);
    font-size: 15px;
}

.mode-toggle {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-xl);
    padding: 3px;
    background: var(--navy);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    width: fit-content;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 24px;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--ivory-dim);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn.active {
    background: var(--gold);
    color: var(--navy);
    box-shadow: none;
}

.mode-btn:hover:not(.active) {
    color: var(--gold);
}

/* Full Exam Card */
.full-exam-card {
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--divider);
}

.full-exam-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gold-muted);
}

.full-exam-card:hover {
    border-color: rgba(201, 168, 76, 0.45);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.full-exam-badge {
    display: inline-block;
    padding: 3px 10px;
    background: transparent;
    color: var(--gold-muted);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: var(--space-md);
}

.full-exam-card h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--ivory);
}

.full-exam-card p {
    color: var(--ivory-dim);
    font-size: 14px;
    margin-bottom: var(--space-md);
}

.full-exam-meta {
    display: flex;
    gap: var(--space-lg);
    color: var(--ivory-dim);
    font-size: 13px;
}

.full-exam-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.category-card {
    padding: var(--space-lg);
    overflow: hidden;
    position: relative;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    border-radius: 0;
}

.category-card[data-category="tps"]::before { background: var(--cat-tps); }
.category-card[data-category="tkd"]::before { background: var(--cat-tkd); }
.category-card[data-category="saintek"]::before { background: var(--cat-saintek); }
.category-card[data-category="soshum"]::before { background: var(--cat-soshum); }

.cat-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.cat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 18px;
}

.cat-icon-tps { background: var(--cat-tps-bg); color: var(--cat-tps); }
.cat-icon-tkd { background: var(--cat-tkd-bg); color: var(--cat-tkd); }
.cat-icon-saintek { background: var(--cat-saintek-bg); color: var(--cat-saintek); }
.cat-icon-soshum { background: var(--cat-soshum-bg); color: var(--cat-soshum); }

.cat-info {
    flex: 1;
}

.cat-info h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--ivory);
}

.cat-desc {
    font-size: 12px;
    color: var(--ivory-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.cat-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.cat-subjects {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.subject-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.subject-btn:hover {
    background: var(--navy-light);
    border-color: var(--divider);
}

.subj-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius);
}

/* ========== ADVANCED CHALLENGE CARD ========== */
:root {
    --cat-adv: #C9A84C;
    --cat-adv-bg: rgba(201, 168, 76, 0.08);
    --cat-adv-border: rgba(201, 168, 76, 0.25);
}

.advanced-challenge-card {
    padding: var(--space-lg);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--cat-adv-border);
    background: var(--navy-mid);
}

.advanced-challenge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--gold);
}

.adv-accent-bar {
    display: none;
}

.advanced-challenge-card:hover {
    border-color: rgba(201, 168, 76, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.cat-icon-adv {
    background: var(--cat-adv-bg);
    color: var(--gold);
}

.cat-icon-adv svg {
    stroke: var(--gold);
}

.advanced-challenge-card .cat-info h3 {
    color: var(--gold);
}

.adv-count-badge {
    color: var(--gold) !important;
    background: var(--cat-adv-bg) !important;
    border: 1px solid var(--cat-adv-border);
}

.adv-subject-btn:hover {
    border-color: var(--cat-adv-border) !important;
    background: rgba(201, 168, 76, 0.06) !important;
}

.adv-difficulty-tag {
    margin-top: var(--space-md);
    padding: 0;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    border-top: 1px solid var(--divider);
    padding-top: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* KaTeX overrides for dark theme */
.katex {
    font-size: 1.05em !important;
    color: var(--text-primary) !important;
}

.katex .mord,
.katex .mop,
.katex .mbin,
.katex .mrel,
.katex .mopen,
.katex .mclose,
.katex .mpunct,
.katex .minner {
    color: inherit !important;
}

.question-text .katex-display {
    margin: 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.option-text .katex {
    font-size: 1em !important;
}

/* ========== QUIZ VIEW ========== */
.quiz-layout {
    max-width: 1300px;
    margin: 0 auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.quiz-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.quiz-subject-info {
    display: flex;
    flex-direction: column;
}

.quiz-category-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-muted);
}

.quiz-subject-label {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--ivory);
}

.quiz-header-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    max-width: 400px;
    margin: 0 var(--space-lg);
}

.quiz-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--info), var(--gold));
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.quiz-progress-text {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

/* Timer */
.quiz-timer {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    color: var(--ivory);
}

.quiz-timer.warning {
    border-color: rgba(201, 168, 76, 0.5);
    color: var(--gold);
}

.quiz-timer.danger {
    border-color: rgba(192, 57, 43, 0.5);
    color: var(--error);
    animation: pulse 1s ease infinite;
}

#timerDisplay {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
}

/* Quiz Body */
.quiz-body {
    display: flex;
    gap: var(--space-md);
    flex: 1;
}

.quiz-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.question-card {
    padding: var(--space-xl);
    flex: 1;
}

.question-number-badge {
    display: inline-block;
    padding: 3px 12px;
    background: transparent;
    color: var(--gold-muted);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-lg);
    text-transform: uppercase;
}

.question-text {
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: var(--space-xl);
    color: var(--text-primary);
    white-space: pre-wrap;
}

.question-text .code-block {
    background: rgba(0, 0, 0, 0.25);
    padding: var(--space-md);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 13px;
    margin: var(--space-md) 0;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Answer Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--divider);
    border-left: 4px solid transparent;
    border-radius: calc(var(--radius) - 4px);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    width: 100%;
}

.option-btn:hover:not(.disabled) {
    background: var(--surface-hover);
    border-left-color: var(--gold-muted);
    transform: translateX(4px);
}

.option-btn.selected {
    background: var(--cat-tps-bg);
    border-left-color: var(--gold);
    border-color: var(--gold-muted);
    border-left: 4px solid var(--gold);
}

.option-btn.correct {
    background: var(--success-bg);
    border-left-color: var(--success);
    border-color: var(--success);
    border-left: 4px solid var(--success);
}

.option-btn.wrong {
    background: var(--error-bg);
    border-left-color: var(--error);
    border-color: var(--error);
    border-left: 4px solid var(--error);
}

.option-btn.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.option-btn.disabled.correct {
    opacity: 1;
}

.option-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    font-weight: 700;
    font-size: 13px;
    margin-top: 0;
    transition: all var(--transition-normal);
}

.option-btn.selected .option-label {
    background: var(--gold);
    color: var(--navy);
}

.option-btn.correct .option-label {
    background: var(--success);
    color: var(--navy);
}

.option-btn.wrong .option-label {
    background: var(--error);
    color: white;
}

.option-text {
    flex: 1;
    padding-top: 2px;
}

/* Hint Panel */
.hint-panel {
    padding: 0;
    overflow: hidden;
}

.hint-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 12px 18px;
    background: none;
    border: none;
    color: var(--gold-muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition-fast);
    letter-spacing: 0.02em;
}

.hint-toggle:hover {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.04);
}

.hint-content {
    display: none;
    padding: 0 18px 16px 46px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    border-top: 1px solid var(--divider);
    padding-top: var(--space-md);
}

.hint-content.show {
    display: block;
}

/* Explanation Panel */
.explanation-panel {
    padding: var(--space-lg);
}

.explanation-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.explanation-icon {
    font-size: 20px;
}

.explanation-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
}

.explanation-title.correct {
    color: var(--success);
}

.explanation-title.wrong {
    color: var(--error);
}

.explanation-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
}

/* Navigation Buttons */
.quiz-nav-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.btn-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    color: var(--ivory-dim);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.btn-flag:hover {
    color: var(--gold);
    border-color: var(--gold-muted);
}

.btn-flag.flagged {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(226, 185, 59, 0.4);
}

.quiz-nav-buttons .btn-primary,
.quiz-nav-buttons .btn-secondary {
    flex: 1;
}

/* Quiz Sidebar — Navigator */
.quiz-sidebar {
    width: 260px;
    min-width: 260px;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    height: fit-content;
    position: sticky;
    top: var(--space-md);
}

.sidebar-title {
    font-size: 10px;
    font-weight: 600;
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gold-muted);
}

.sidebar-legend {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 10px;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-dot.answered { background: var(--gold); }
.legend-dot.flagged { background: var(--warning); }
.legend-dot.unanswered { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255,255,255,0.1); }

/* Question Navigator Grid — squares */
.question-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: var(--space-lg);
    max-height: 350px;
    overflow-y: auto;
    padding-right: var(--space-xs);
}

.question-grid::-webkit-scrollbar {
    width: 3px;
}

.question-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.q-grid-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--divider);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.q-grid-btn:hover {
    border-color: rgba(201, 168, 76, 0.4);
}

.q-grid-btn.current {
    border: 2px solid var(--gold);
    color: var(--gold);
}

.q-grid-btn.answered {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

.q-grid-btn.flagged {
    background: var(--navy-light);
    border-color: var(--gold);
    color: var(--gold);
}

.q-grid-btn.answered.flagged {
    background: var(--gold-muted);
    border-color: var(--gold);
    color: var(--navy);
}

.sidebar-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: var(--space-lg);
}

.sidebar-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.04);
}

.sidebar-stat-val {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}

.sidebar-stat-lbl {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: var(--gold);
    color: var(--navy);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: filter var(--transition-fast);
    letter-spacing: 0.02em;
}

.btn-submit:hover {
    filter: brightness(1.1);
}

/* ========== RESULTS VIEW ========== */
.results-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

.results-header {
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
    margin-bottom: var(--space-2xl);
    padding: var(--space-2xl);
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px -8px rgba(0,0,0,0.1);
}

.results-score-ring {
    position: relative;
    width: 140px;
    height: 140px;
    min-width: 140px;
}

.score-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 8;
}

.score-fill {
    fill: none;
    stroke: url(#scoreGrad);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 700;
    color: var(--gold);
    animation: countUp 0.6s ease 0.5s both;
}

.score-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.results-summary {
    flex: 1;
}

.results-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--ivory);
}

.results-subject {
    color: var(--ivory-dim);
    font-size: 14px;
    margin-bottom: var(--space-lg);
}

.results-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.result-meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm) 0;
}

.meta-val {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
}

.result-meta-item:nth-child(1) .meta-val { color: var(--success); }
.result-meta-item:nth-child(2) .meta-val { color: var(--error); }
.result-meta-item:nth-child(3) .meta-val { color: var(--warning); }
.result-meta-item:nth-child(4) .meta-val { color: var(--info); }

.meta-lbl {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.results-actions {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
    flex-wrap: wrap;
}

/* Review Section */
.review-section {}

.review-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--ivory);
}

.review-filter {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 18px;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    color: var(--ivory-dim);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: #ffffff;
}

.filter-btn:hover:not(.active) {
    border-color: var(--gold-muted);
    color: var(--text-primary);
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.review-item {
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    border-left: 4px solid;
}

.review-item.correct {
    border-left-color: var(--success);
}

.review-item.wrong {
    border-left-color: var(--error);
}

.review-item.skipped {
    border-left-color: var(--warning);
}

.review-question {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: var(--space-md);
    white-space: pre-wrap;
}

.review-answer-grid {
    margin-bottom: var(--space-md);
}

.review-option {
    padding: 8px 14px;
    margin-bottom: 4px;
    border-radius: var(--radius);
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.review-option.is-correct {
    background: var(--success-bg);
    color: var(--success);
}

.review-option.is-selected.is-wrong {
    background: var(--error-bg);
    color: var(--error);
}

.review-option .review-opt-label {
    font-weight: 700;
    min-width: 22px;
}

.review-explanation {
    padding: var(--space-md);
    background: rgba(126, 173, 212, 0.05);
    border: 1px solid rgba(126, 173, 212, 0.1);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.review-explanation strong {
    color: var(--info);
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-card {
    max-width: 420px;
    width: 90%;
    padding: var(--space-2xl);
    text-align: center;
    background: var(--navy-mid);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
}

.modal-icon {
    font-size: 40px;
    margin-bottom: var(--space-md);
}

.modal-card h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--ivory);
}

.modal-card p {
    color: var(--ivory-dim);
    font-size: 14px;
    margin-bottom: var(--space-xl);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

/* ========== RESPONSIVE — MOBILE OPTIMISATION ========== */

/* Prevent horizontal overflow globally */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* ── Tablet / small desktop (≤900px) ── */
@media (max-width: 900px) {
    /* Quiz: sidebar moves below question panel */
    .quiz-body {
        flex-direction: column-reverse;
    }

    .quiz-sidebar {
        width: 100%;
        min-width: auto;
        position: static;
    }

    .question-grid {
        grid-template-columns: repeat(10, 1fr);
        max-height: 150px;
    }

    /* Category cards: single column */
    .category-grid {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        text-align: center;
    }

    .results-meta {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Large mobile (≤768px) ── */
@media (max-width: 768px) {
    /* Subject selection container */
    .select-container {
        padding: var(--space-lg) var(--space-md);
    }

    /* Category grid: force single column with safe min */
    .category-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    /* Advanced challenge card */
    .advanced-challenge-card {
        margin-top: var(--space-md);
    }

    /* Stats dashboard subject table: hide accuracy col on mobile */
    .stats-subject-row {
        grid-template-columns: 1fr 60px 60px 60px;
    }

    .stats-subject-row .stats-subject-cell:last-child {
        display: none;
    }

    .stats-subject-row-header span:last-child {
        display: none;
    }

    /* Results */
    .results-container {
        padding: var(--space-lg) var(--space-md);
    }
}

/* ── Standard mobile (≤600px) ── */
@media (max-width: 600px) {
    /* Kill old hero-stats (legacy) */
    .hero-stats {
        flex-direction: column;
        gap: 0;
    }

    .stat-card {
        flex-direction: row;
        justify-content: center;
        gap: var(--space-md);
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--divider);
        padding: var(--space-sm) var(--space-md);
    }

    .stat-card:last-child {
        border-bottom: none;
    }

    /* Quiz header: wrap and re-order for small screens */
    .quiz-header {
        flex-wrap: wrap;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
    }

    .quiz-header-left {
        gap: var(--space-sm);
    }

    .quiz-subject-label {
        font-size: 14px;
    }

    .quiz-header-center {
        order: 3;
        max-width: 100%;
        margin: 0;
        width: 100%;
        flex-basis: 100%;
    }

    /* Nav buttons: prev/next fill width */
    .quiz-nav-buttons {
        flex-wrap: wrap;
    }

    .quiz-nav-buttons .btn-primary,
    .quiz-nav-buttons .btn-secondary {
        flex: 1;
        min-width: 0;
        padding: 12px 10px;
        font-size: 13px;
    }

    /* Question navigator: 7 columns */
    .question-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    /* Mode toggle: full width */
    .mode-toggle {
        width: 100%;
    }

    .mode-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    .results-meta {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Subject buttons: better touch target */
    .subject-btn {
        padding: 14px 16px;
        min-height: 48px;
    }

    /* Stats time card */
    .stats-time-card {
        flex-wrap: wrap;
        gap: var(--space-md);
        padding: var(--space-md);
    }
}

/* ── Small mobile (≤480px) ── */
@media (max-width: 480px) {
    /* Select container: tighter padding */
    .select-container {
        padding: var(--space-md);
    }

    /* Category card: tighter */
    .category-card {
        padding: var(--space-md);
    }

    .advanced-challenge-card {
        padding: var(--space-md);
    }

    /* Option buttons: readable touch-size */
    .option-btn {
        padding: 12px 14px;
        font-size: 14px;
    }

    /* Question card padding */
    .question-card {
        padding: var(--space-lg) var(--space-md);
    }

    /* Quiz nav bottom bar */
    .quiz-nav-buttons {
        gap: var(--space-sm);
    }

    /* Results */
    .results-header {
        gap: var(--space-lg);
    }

    .results-score-ring {
        width: 120px;
        height: 120px;
    }

    .results-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .results-actions button {
        width: 100%;
        justify-content: center;
    }

    /* Stats dashboard */
    .stats-summary-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-summary-row .stats-summary-card:first-child {
        grid-column: 1 / -1;
    }

    .stats-subject-row {
        grid-template-columns: 1fr 50px 50px;
        font-size: 12px;
    }

    /* Hide last two cols on very small screen */
    .stats-subject-row .stats-subject-cell:nth-child(4),
    .stats-subject-row .stats-subject-cell:nth-child(5),
    .stats-subject-row-header span:nth-child(4),
    .stats-subject-row-header span:nth-child(5) {
        display: none;
    }

    /* Modal */
    .modal-card {
        padding: var(--space-lg);
    }

    /* Mode toggle text: shorten if needed */
    .mode-btn {
        font-size: 12px;
        gap: 5px;
        padding: 9px 8px;
    }

    /* Sidebar question grid: 5 col on smallest */
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
        max-height: 200px;
    }
}

/* ── Extra small (≤375px) ── */
@media (max-width: 375px) {
    /* Hero: ensure SYNTHESIS doesn't overflow */
    .hero-title {
        font-size: clamp(36px, 13vw, 52px) !important;
        white-space: normal !important;
        word-break: break-word;
    }

    .hero-content {
        padding: 28px 16px 28px 26px !important;
    }

    .hero-stats-box {
        flex-direction: column;
    }

    .stats-cell {
        border-right: none;
        border-bottom: 1px solid rgba(201,168,76,0.2);
        padding: 12px 16px;
    }

    .stats-cell:last-child {
        border-bottom: none;
    }

    .hero-cta {
        font-size: 12px;
        padding: 13px 20px;
    }

    /* Select: minimal padding */
    .select-container {
        padding: 12px;
    }

    .cat-header {
        gap: var(--space-sm);
    }

    .quiz-subject-label {
        font-size: 13px;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Subject button: one line */
    .subject-btn {
        font-size: 13px;
    }

    .subj-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 160px;
    }
}


/* Scrollbar — minimal */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.15);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.3);
}

/* Selection */
::selection {
    background: rgba(201, 168, 76, 0.25);
    color: var(--ivory);
}

/* ============================================
   STATISTICS & ANALYTICS DASHBOARD
   ============================================ */

.stats-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    padding-bottom: var(--space-3xl);
}

.stats-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.stats-top-right {
    display: flex;
    gap: var(--space-sm);
}

.btn-reset-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid rgba(192, 57, 43, 0.3);
    color: var(--text-muted);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    letter-spacing: 0.02em;
}

.btn-reset-stats:hover {
    border-color: var(--error);
    color: var(--error);
    background: var(--error-bg);
}

.stats-page-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--ivory);
    margin-bottom: 4px;
}

.stats-page-subtitle {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
}

/* Summary Cards Row */
.stats-summary-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stats-summary-card {
    background: var(--navy-mid);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: var(--space-lg) var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.stats-summary-card:hover {
    border-color: rgba(201, 168, 76, 0.35);
}

.stats-card-icon {
    margin-bottom: 4px;
    opacity: 0.85;
}

.stats-card-number {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--ivory);
    line-height: 1;
}

.stats-card-label {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

/* Accuracy Ring */
.stats-ring-wrap {
    position: relative;
    width: 80px;
    height: 80px;
}

.stats-ring-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.stats-ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.06);
    stroke-width: 6;
}

.stats-ring-fill {
    fill: none;
    stroke: var(--gold);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 263.894;
    stroke-dashoffset: 263.894;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-ring-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: baseline;
    gap: 1px;
}

.stats-ring-value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
}

.stats-ring-unit {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--gold-muted);
}

/* Performance Chart Card */
.stats-chart-card {
    margin-bottom: var(--space-lg);
    padding: var(--space-lg);
}

.stats-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.stats-chart-header h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--ivory);
}

.stats-chart-legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-body);
}

.legend-dot-inline {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.stats-chart-wrap {
    position: relative;
    width: 100%;
    min-height: 200px;
}

.stats-chart-wrap canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
}

.stats-chart-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
}

/* Time Spent Card */
.stats-time-card {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    padding: var(--space-lg) var(--space-xl);
    margin-bottom: var(--space-lg);
}

.stats-time-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(201, 168, 76, 0.08);
    border-radius: var(--radius);
}

.stats-time-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stats-time-value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 600;
    color: var(--ivory);
}

.stats-time-label {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Category Breakdown */
.stats-breakdown-card {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.stats-section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--ivory);
    margin-bottom: var(--space-md);
}

.stats-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.stats-breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stats-breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-breakdown-name {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--ivory);
}

.stats-breakdown-counts {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.stats-breakdown-counts .correct-count { color: var(--success); }
.stats-breakdown-counts .wrong-count { color: var(--error); }

.stats-bar-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
    display: flex;
}

.stats-bar-correct {
    height: 100%;
    background: var(--success);
    border-radius: 3px 0 0 3px;
    transition: width 0.6s ease;
}

.stats-bar-wrong {
    height: 100%;
    background: var(--error);
    transition: width 0.6s ease;
}

.stats-bar-skipped {
    height: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 0 3px 3px 0;
    transition: width 0.6s ease;
}

/* Subject Detail List */
.stats-subject-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stats-subject-row {
    display: grid;
    grid-template-columns: 1fr 70px 70px 70px 70px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
}

.stats-subject-row:last-child { border-bottom: none; }

.stats-subject-row-header {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--divider);
}

.stats-subject-name {
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--ivory);
    font-size: 13px;
}

.stats-subject-cell {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 13px;
}

.stats-subject-cell.correct-val { color: var(--success); }
.stats-subject-cell.wrong-val { color: var(--error); }
.stats-subject-cell.total-val { color: var(--text-muted); }
.stats-subject-cell.accuracy-val { color: var(--gold); font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
    .stats-summary-row {
        grid-template-columns: repeat(3, 1fr);
    }
    .stats-summary-row .stats-summary-card:first-child {
        grid-column: 1 / -1;
    }
    .stats-time-card {
        flex-wrap: wrap;
        gap: var(--space-md);
    }
    .stats-subject-row {
        grid-template-columns: 1fr 55px 55px 55px 55px;
        font-size: 12px;
    }
    .stats-container {
        padding: var(--space-lg) var(--space-md);
    }
}

@media (max-width: 480px) {
    .stats-summary-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-summary-row .stats-summary-card:first-child {
        grid-column: 1 / -1;
    }
    .stats-subject-row {
        grid-template-columns: 1fr 45px 45px 45px 45px;
        font-size: 11px;
    }
    .stats-page-title {
        font-size: 22px;
    }
}
