/* =====================================================
           CSS VARIABLES – Dark Mode Support
           ===================================================== */
        :root {
            --primary-gradient: linear-gradient(135deg, #4648d4 0%, #6063ee 100%);
            --bg-color: #fcf8ff;
            --card-bg: #ffffff;
            --text-color: #1b1b23;
            --border-color: #c7c4d7;
            --hover-bg: rgba(70,72,212,0.08);
            --muted-color: #767586;
            --danger: #dc3545;
            --danger-bg: rgba(220,53,69,0.1);
        }
        [data-theme="dark"] {
            --bg-color: #12121c;
            --card-bg: #1e1e2e;
            --text-color: #e4e1ed;
            --border-color: #3a3a52;
            --hover-bg: rgba(70,72,212,0.18);
            --muted-color: #9d9ab0;
        }

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

        body {
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: var(--bg-color);
            min-height: 100vh;
            padding: 10px;
            color: var(--text-color);
            transition: background 0.3s, color 0.3s;
        }

        h1, h2, h3, .font-headline { font-family: 'Manrope', 'Segoe UI', sans-serif; }

        .material-symbols-outlined {
            font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
        }

        .container {
            max-width: 1000px;
            margin: 0 auto;
            background: var(--card-bg);
            border-radius: 24px;
            box-shadow: 0 20px 50px rgba(70,72,212,0.12), 0 4px 16px rgba(0,0,0,0.08);
            overflow: hidden;
            transition: background 0.3s;
        }

        /* Header */
        .header {
            background: var(--primary-gradient);
            color: white;
            padding: 24px 20px 20px;
            text-align: center;
            position: relative;
        }
        .header h1 { font-size: 1.8rem; margin-bottom: 5px; font-family: 'Manrope', sans-serif; font-weight: 800; letter-spacing: -0.02em; }
        .header p { opacity: 0.88; font-size: 0.9rem; font-weight: 500; }
        .header-controls {
            position: absolute;
            top: 20px; right: 20px;
            display: flex; gap: 10px; flex-wrap: wrap;
        }
        .icon-btn {
            background: rgba(255,255,255,0.18);
            border: 1px solid rgba(255,255,255,0.25); color: white;
            width: 40px; height: 40px;
            border-radius: 50%; cursor: pointer;
            font-size: 18px; display: flex;
            align-items: center; justify-content: center;
            transition: all 0.2s;
            backdrop-filter: blur(8px);
        }
        .icon-btn:hover { background: rgba(255,255,255,0.32); transform: scale(1.08); }
        .icon-btn:focus-visible { outline: 2px solid white; outline-offset: 2px; }

        .timer-info {
            display: flex; justify-content: space-around;
            margin-top: 15px; flex-wrap: wrap;
        }
        .timer-box {
            background: rgba(255,255,255,0.2);
            padding: 8px 16px; border-radius: 30px; margin: 5px;
        }
        .timer-box span { font-size: 1.2rem; font-weight: bold; margin-left: 6px; }

        /* Tabs */
        .tabs {
            display: flex; background: var(--card-bg);
            border-bottom: 2px solid var(--border-color);
            overflow-x: auto;
            gap: 0.25rem;
            padding: 0 0.5rem;
        }
        .tab {
            padding: 14px 20px; cursor: pointer;
            border: none; background: none;
            font-size: 0.9rem; color: var(--text-color);
            white-space: nowrap; transition: all 0.2s;
            font-family: 'Inter', sans-serif;
            font-weight: 500;
            border-bottom: 3px solid transparent;
            margin-bottom: -2px;
        }
        /* FIX: aria-current handled in JS; visual style for active */
        .tab.active, .tab[aria-current="page"] { color: #4648d4; border-bottom: 3px solid #4648d4; font-weight: 600; }
        .tab:hover:not(:disabled) { background: var(--hover-bg); color: #4648d4; }
        .tab:disabled { opacity: 0.5; cursor: not-allowed; }
        .tab:focus-visible { outline: 2px solid #4648d4; outline-offset: -2px; }

        .content { padding: 20px; }
        .screen { display: none; animation: fadeIn 0.3s ease; }
        .screen.active { display: block; }
        @keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

        /* Cards & Components */
        .mode-selector {
            display: flex; flex-wrap: wrap; gap: 1.5rem;
            justify-content: center; margin: 2rem 0;
        }

        /* ── Subject grid — scalable grouped layout ── */
        /* Groups subjects by name; each group gets a compact paper-list inside */
        .subject-grid {
            display: flex;
            flex-direction: column;
            gap: 1rem;
            margin: 1rem 0;
        }
        /* One row per subject-group (e.g. "Political Science") */
        .subject-group {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 1.25rem;
            overflow: hidden;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .subject-group:hover { border-color: #4648d4; box-shadow: 0 4px 16px rgba(70,72,212,0.1); }
        .subject-group-header {
            display: flex;
            align-items: center;
            gap: 0.8rem;
            padding: 0.75rem 1.1rem;
            background: rgba(70,72,212,0.06);
            border-bottom: 1px solid var(--border-color);
        }
        .subject-group-icon { font-size: 1.6rem; line-height: 1; }
        .subject-group-name {
            font-size: 1rem;
            font-weight: 700;
            color: #4648d4;
            flex: 1;
        }
        .subject-group-count {
            font-size: 0.75rem;
            color: var(--muted-color);
        }
        /* Paper chips inside each group */
        .subject-papers {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            padding: 0.7rem 1rem;
        }
        .subject-card {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            padding: 0.45rem 1rem;
            border: 2px solid var(--border-color);
            border-radius: 2rem;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 0.88rem;
            font-weight: 500;
            background: var(--card-bg);
            color: var(--text-color);
            position: relative;
        }
        .subject-card:hover {
            border-color: #4648d4;
            background: var(--hover-bg);
            color: #4648d4;
        }
        .subject-card.selected {
            border-color: #4648d4;
            background: #4648d4;
            color: white;
        }
        .subject-card .subject-badge {
            display: none; /* badge no longer needed — selection is visual */
        }
        /* Pill dot to show selected state */
        .subject-card::after {
            content: '';
            width: 6px; height: 6px;
            border-radius: 50%;
            background: currentColor;
            opacity: 0;
            transition: opacity 0.2s;
        }
        .subject-card.selected::after { opacity: 1; }

        /* Question/duration meta shown inline */
        .subject-card-meta {
            font-size: 0.75rem;
            opacity: 0.75;
        }

        /* ── Mode cards — same as before, kept smaller ── */
        .mode-card {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 1.25rem;
            padding: 1.5rem;
            cursor: pointer;
            transition: all 0.25s;
            flex: 1;
            min-width: 180px;
            max-width: 230px;
            text-align: center;
        }
        .mode-card:hover {
            border-color: #4648d4;
            transform: translateY(-4px);
            box-shadow: 0 12px 30px rgba(70,72,212,0.18);
        }
        .mode-card.selected {
            border-color: #4648d4;
            background: var(--hover-bg);
            box-shadow: 0 4px 16px rgba(70,72,212,0.15);
        }

        .subject-icon { display: none; } /* icon now lives in group header only */
        .subject-card h3 { display: none; } /* name in group header */
        .subject-card .subject-meta { display: none; } /* topics in group header */

        .stats-dashboard {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
            gap: 1rem;
            margin: 1.5rem 0;
        }
        .stat-card {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 1rem;
            padding: 1rem;
            text-align: center;
            transition: box-shadow 0.2s, border-color 0.2s;
        }
        .stat-card:hover { border-color: #4648d4; box-shadow: 0 4px 14px rgba(70,72,212,0.1); }
        .stat-value { font-size: 1.8rem; font-weight: 800; color: #4648d4; font-family: 'Manrope', sans-serif; }

        .custom-options {
            max-width: 600px;
            margin: 1rem auto;
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 1.25rem;
            padding: 1.5rem;
            display: none;
        }
        .custom-options.active { display: block; }
        .form-group { margin: 1rem 0; }
        .form-group label { display: block; margin-bottom: 0.4rem; font-weight: 500; }
        .form-group input, .form-group select {
            width: 100%;
            padding: 0.6rem;
            border: 2px solid var(--border-color);
            border-radius: 0.5rem;
            background: var(--card-bg);
            color: var(--text-color);
        }
        .topic-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
        .topic-tag {
            padding: 0.3rem 1rem;
            border: 1px solid var(--border-color);
            border-radius: 2rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .topic-tag.selected {
            background: #4648d4;
            color: white;
            border-color: #4648d4;
        }

        .instructions {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 1.25rem;
            padding: 1.25rem;
            margin: 1.5rem auto;
            max-width: 700px;
            text-align: left;
        }
        .instructions h3 { color: #4648d4; margin-bottom: 0.5rem; font-family: 'Manrope', sans-serif; }
        .instructions ul { padding-left: 1.5rem; line-height: 1.8; }

        .btn {
            padding: 0.7rem 1.5rem;
            border-radius: 2rem;
            font-weight: 600;
            border: none;
            cursor: pointer;
            transition: all 0.25s;
            font-size: 0.9rem;
            margin: 0.25rem;
            font-family: 'Inter', sans-serif;
            letter-spacing: 0.01em;
        }
        .btn-primary {
            background: var(--primary-gradient);
            color: white;
            box-shadow: 0 4px 14px rgba(70,72,212,0.3);
        }
        .btn-primary:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(70,72,212,0.42);
        }
        .btn-primary:active:not(:disabled) { transform: scale(0.97); }
        .btn-secondary {
            background: var(--card-bg);
            color: var(--text-color);
            border: 2px solid var(--border-color);
        }
        .btn-secondary:hover:not(:disabled) { border-color: #4648d4; color: #4648d4; background: rgba(70,72,212,0.05); }
        /* FIX: .btn-danger now defined */
        .btn-danger {
            background: var(--danger);
            color: white;
        }
        .btn-danger:hover:not(:disabled) {
            background: #c82333;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(220,53,69,0.4);
        }
        .btn:focus-visible { outline: 2px solid #4648d4; outline-offset: 2px; }

        /* Question container */
        .question-container {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 1.25rem;
            padding: 1.5rem;
            margin-bottom: 1rem;
        }
        .question-header {
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }
        .question-number { font-size: 1.1rem; font-weight: 800; color: #4648d4; font-family: 'Manrope', sans-serif; }
        .progress-bar {
            width: 100%;
            height: 6px;
            background: var(--border-color);
            border-radius: 3px;
            overflow: hidden;
            margin: 0.8rem 0;
        }
        .progress-fill {
            height: 100%;
            background: var(--primary-gradient);
            width: 0;
            transition: width 0.3s;
        }
        .question-text { font-size: 1rem; line-height: 1.5; margin-bottom: 1rem; }
        .question-text-hi { font-size: 0.9rem; color: var(--muted-color); margin-top: 0.3rem; }

        /* ── Vertical parts: (i)(ii) and Statement A/B ── */
        .question-parts {
            display: flex; flex-direction: column;
            gap: 0.5rem; margin-top: 0.6rem;
        }
        .question-part {
            display: flex; gap: 0.6rem;
            line-height: 1.6; align-items: flex-start;
        }
        .question-part-label {
            font-weight: 700; color: #4648d4;
            min-width: 3.5rem; flex-shrink: 0;
        }

        /* ── Assertion items: (A)(B)(C)(D) vertical list ── */
        .question-assertions {
            display: flex; flex-direction: column;
            gap: 0.45rem; margin-top: 0.6rem;
            padding: 0.7rem 0.9rem;
            background: rgba(70,72,212,0.05);
            border-left: 3px solid rgba(70,72,212,0.35);
            border-radius: 0 0.5rem 0.5rem 0;
        }
        .question-assertion-item {
            display: flex; gap: 0.6rem;
            line-height: 1.6; align-items: flex-start;
            font-size: 0.95rem;
        }
        .question-assertion-label {
            font-weight: 700; color: #4648d4;
            min-width: 2rem; flex-shrink: 0;
        }

        /* ── Two-column list (Match List-I / List-II) ── */
        .question-lists {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.8rem;
            margin-top: 0.8rem;
        }
        /* Stack single-column on narrow screens */
        @media (max-width: 540px) { .question-lists { grid-template-columns: 1fr; } }
        .question-list-col {
            border: 1.5px solid var(--border-color);
            border-radius: 0.7rem;
            overflow: hidden;
        }
        .question-list-header {
            background: rgba(70,72,212,0.12);
            color: #4648d4;
            font-weight: 700;
            font-size: 0.85rem;
            padding: 0.4rem 0.8rem;
            border-bottom: 1.5px solid var(--border-color);
            text-align: center;
        }
        .question-list-items {
            padding: 0.5rem 0.8rem;
            display: flex;
            flex-direction: column;
            gap: 0.3rem;
        }
        .question-list-item {
            display: flex;
            gap: 0.5rem;
            font-size: 0.92rem;
            line-height: 1.5;
            align-items: flex-start;
            padding: 0.15rem 0;
        }
        .question-list-item-label {
            font-weight: 700;
            color: #4648d4;
            min-width: 2rem;
            flex-shrink: 0;
            font-size: 0.85rem;
        }
        /* Right-column labels are numbers — different colour */
        .question-list-col:last-child .question-list-item-label {
            color: #c0392b;
        }
        /* Instruction line below the two columns */
        .question-list-instruction {
            margin-top: 0.5rem;
            font-style: italic;
            font-size: 0.88rem;
            color: var(--muted-color);
        }

        /* ── Paired options (match-the-pair 8-opt) ── */
        .option-pair { display: flex; flex-direction: column; gap: 0.15rem; }
        .option-pair-item:first-child { font-weight: 500; color: var(--text-color); }
        .option-pair-item:last-child  { font-size: 0.88rem; color: var(--muted-color); }

        /* FIX: .option-text-hi JS-injected class now styled */
        .option-text-hi {
            font-size: 0.82rem;
            color: var(--muted-color);
            margin-top: 0.25rem;
            line-height: 1.4;
        }

        .options-container { display: flex; flex-direction: column; gap: 0.7rem; }
        .option {
            padding: 0.8rem 1rem;
            border: 2px solid var(--border-color);
            border-radius: 0.875rem;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 0.8rem;
        }
        .option:hover { border-color: #4648d4; background: var(--hover-bg); }
        .option.selected { border-color: #4648d4; background: rgba(70,72,212,0.12); }
        .option-label {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: var(--border-color);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            flex-shrink: 0;
        }
        .option.selected .option-label { background: #4648d4; color: white; }
        .option.practice-correct {
            border-color: #28a745 !important;
            background: rgba(40,167,69,0.1) !important;
        }
        .option.practice-wrong {
            border-color: #dc3545 !important;
            background: rgba(220,53,69,0.1) !important;
        }
        /* FIX: .not-attempted-opt now styled */
        .not-attempted-opt {
            border-style: dashed;
            opacity: 0.85;
        }
        .options-locked { pointer-events: none; }

        .question-context {
            margin-top: 1rem;
            padding: 1rem;
            background: rgba(70,72,212,0.08);
            border-left: 4px solid #4648d4;
            border-radius: 0.5rem;
            display: none;
        }
        .question-context.show { display: block; }
        /* FIX: .question-context-title now styled */
        .question-context-title {
            font-weight: 700;
            color: #4648d4;
            margin-bottom: 0.5rem;
            font-size: 0.95rem;
        }

        /* FIX: .meta-badge and .topic-badge now styled */
        .meta-badge {
            display: inline-block;
            padding: 0.2rem 0.7rem;
            border-radius: 1rem;
            font-size: 0.78rem;
            font-weight: 600;
            border: 1px solid transparent;
        }
        .topic-badge {
            background: rgba(70,72,212,0.12);
            color: #4648d4;
            border-color: rgba(70,72,212,0.3);
        }

        /* FIX: .recommendation now styled */
        .recommendation {
            padding: 0.8rem 1rem;
            border-radius: 0.6rem;
            border-left: 4px solid #4648d4;
            background: rgba(70,72,212,0.07);
            margin-top: 0.5rem;
            font-size: 0.95rem;
            line-height: 1.5;
        }

        /* Palette */
        .palette-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
            gap: 0.7rem;
            margin: 1.5rem 0;
        }
        .palette-item {
            aspect-ratio: 1;
            border: 2px solid var(--border-color);
            border-radius: 0.7rem;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: 0.2s;
        }
        .palette-item.current { background: #4648d4; border-color: #4648d4; color: white; box-shadow: 0 2px 10px rgba(70,72,212,0.4); }
        .palette-item.answered { background: rgba(40,167,69,0.2); border-color: #28a745; }
        .palette-item.marked { background: rgba(255,193,7,0.2); border-color: #ffc107; }
        .palette-item.not-attempted-pal { background: rgba(108,117,125,0.15); border-color: #6c757d; }
        .palette-item.blank-risk { background: rgba(220,53,69,0.15); border-color: #dc3545; color: #dc3545; }

        /* FIX: Palette legend swatches all have dimensions */
        .palette-legend-swatch {
            display: inline-block;
            width: 20px;
            height: 20px;
            border-radius: 4px;
            vertical-align: middle;
            margin-right: 4px;
        }

        /* Results */
        .score-card {
            background: var(--primary-gradient);
            border-radius: 1.5rem;
            padding: 2rem 1.5rem;
            text-align: center;
            color: white;
            margin-bottom: 1.5rem;
            box-shadow: 0 8px 32px rgba(70,72,212,0.3);
        }
        .score-value { font-size: 3rem; font-weight: 800; margin: 1rem 0; font-family: 'Manrope', sans-serif; letter-spacing: -0.02em; }
        .score-details {
            display: flex;
            justify-content: center;
            gap: 2rem;
            flex-wrap: wrap;
        }
        .score-detail-value { font-size: 1.8rem; font-weight: bold; }

        .performance-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px,1fr));
            gap: 1rem;
            margin-bottom: 1rem;
        }
        .performance-card {
            background: var(--card-bg);
            border: 2px solid var(--border-color);
            border-radius: 1.25rem;
            padding: 1.25rem;
            transition: box-shadow 0.2s;
        }
        .performance-card:hover { box-shadow: 0 4px 14px rgba(70,72,212,0.1); }

        /* FIX: .history-item and .history-date now styled */
        .history-item {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 0.875rem;
            padding: 0.8rem 1rem;
            margin-bottom: 0.7rem;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .history-item:hover { border-color: #4648d4; box-shadow: 0 2px 10px rgba(70,72,212,0.1); }
        .history-date {
            font-size: 0.78rem;
            color: var(--muted-color);
            margin-bottom: 0.3rem;
        }
        .history-subject-label {
            display: inline-block;
            padding: 0.15rem 0.6rem;
            background: rgba(70,72,212,0.12);
            color: #4648d4;
            border-radius: 1rem;
            font-size: 0.75rem;
            font-weight: 600;
            margin-bottom: 0.3rem;
        }

        /* Modals */
        .modal {
            display: none;
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background: rgba(0,0,0,0.6);
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }
        .modal-content {
            background: var(--card-bg);
            max-width: 500px;
            width: 90%;
            border-radius: 1.5rem;
            padding: 1.75rem;
            animation: slideUp 0.2s;
            box-shadow: 0 24px 60px rgba(0,0,0,0.25);
        }
        @keyframes slideUp { from { transform: translateY(30px); opacity:0; } to { transform: translateY(0); opacity:1; } }
        .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
        .close-btn { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-color); }
        .close-btn:focus-visible { outline: 2px solid #4648d4; border-radius: 4px; }

        .time-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 20px;
            font-size: 0.7rem;
            background: #e3f2fd;
            color: #1565c0;
            margin-left: 8px;
        }
        .time-badge.slow { background: #fce4ec; color: #b71c1c; }

        .shortcut-grid {
            display: grid;
            grid-template-columns: 1fr 2fr;
            gap: 0.7rem;
        }
        .shortcut-key {
            background: var(--border-color);
            padding: 0.3rem;
            border-radius: 0.3rem;
            text-align: center;
            font-family: monospace;
            font-weight: bold;
        }
        .practice-banner {
            background: linear-gradient(135deg,#84fab0,#8fd3f4);
            color: #333;
            padding: 0.5rem;
            border-radius: 2rem;
            text-align: center;
            margin-bottom: 1rem;
        }
        .loading-overlay {
            position: fixed;
            top:0;left:0;width:100%;height:100%;
            background: rgba(0,0,0,0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10000;
        }
        .spinner {
            border: 4px solid rgba(255,255,255,0.3);
            border-top: 4px solid white;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            animation: spin 1s linear infinite;
            margin: 0 auto 1rem;
        }
        @keyframes spin { 100% { transform: rotate(360deg); } }

        /* Toast notification (replaces alert() for timer warning) */
        .toast {
            position: fixed;
            bottom: 24px; left: 50%;
            transform: translateX(-50%) translateY(60px);
            background: #333;
            color: #fff;
            padding: 0.75rem 1.5rem;
            border-radius: 2rem;
            font-size: 0.95rem;
            z-index: 9999;
            opacity: 0;
            transition: all 0.4s ease;
            pointer-events: none;
            white-space: nowrap;
        }
        .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
        .toast.warning { background: #dc3545; }

        /* Language toggle */
        .lang-toggle-wrap {
            display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0;
            font-size: 0.9rem;
        }
        .toggle-switch {
            position: relative; display: inline-block;
            width: 44px; height: 24px;
        }
        .toggle-switch input { opacity: 0; width:0; height:0; }
        .toggle-slider {
            position: absolute; cursor: pointer;
            top:0; left:0; right:0; bottom:0;
            background: var(--border-color);
            border-radius: 24px; transition: 0.3s;
        }
        .toggle-slider:before {
            position: absolute; content: "";
            height: 18px; width: 18px; left: 3px; bottom: 3px;
            background: white; border-radius: 50%; transition: 0.3s;
        }
        input:checked + .toggle-slider { background: #4648d4; }
        input:checked + .toggle-slider:before { transform: translateX(20px); }

        /* Supabase status */
        .db-status {
            display: inline-flex; align-items: center; gap: 6px;
            font-size: 0.78rem; padding: 3px 10px; border-radius: 1rem;
            background: rgba(255,255,255,0.15); color: white;
        }
        .db-dot {
            width: 8px; height: 8px; border-radius: 50%;
            background: #ffc107;
        }
        .db-dot.connected { background: #28a745; }
        .db-dot.error { background: #dc3545; }

        /* Print */
        @media print {
            .no-print { display: none !important; }
            .container { box-shadow: none; border-radius: 0; }
            body { background: white; padding: 0; }
            .screen { display: block !important; }
            #testScreen, #paletteScreen, #startScreen { display: none !important; }
            /* UX-3 FIX: result and review screens always visible when printing */
            #resultScreen, #reviewScreen { display: block !important; }
        }

        @media (max-width: 768px) {
            .header h1 { font-size: 1.3rem; }
            .header-controls { position: static; justify-content: center; margin-top: 12px; }
            .subject-card, .mode-card { min-width: 160px; }
            .score-value { font-size: 2rem; }
        }

        /* Difficulty badge */
        .difficulty-badge {
            display: inline-block;
            padding: 0.15rem 0.6rem;
            border-radius: 1rem;
            font-size: 0.72rem;
            font-weight: 600;
            margin-left: 4px;
        }
        .difficulty-easy { background: #d4edda; color: #155724; }
        .difficulty-medium { background: #fff3cd; color: #856404; }
        .difficulty-hard { background: #f8d7da; color: #721c24; }

        /* Promoted from inline styles */
        .btn-start-large {
            padding: 0.9rem 2.5rem;
            font-size: 1.05rem;
            letter-spacing: 0.02em;
            font-family: 'Manrope', sans-serif;
            font-weight: 700;
        }
        .nav-buttons {
            display: flex;
            justify-content: space-between;
            gap: 1rem;
            flex-wrap: wrap;
        }

        /* Focus trap: ensure modal backdrop captures focus */
        .modal[style*="flex"] { display: flex !important; }
        .modal-content:focus-visible { outline: none; }
