        /* --- 1. CSS Variables & Theming --- */
        :root {
            /* Light Mode Palette */
            --primary: #4f46e5;
            --primary-hover: #4338ca;
            --primary-light: #eef2ff;
            --bg-body: #f9fafb;
            --bg-card: #ffffff;
            --text-main: #111827;
            --text-muted: #6b7280;
            --border: #e5e7eb;
            --input-bg: #ffffff;
            --success: #16a34a;
            --success-bg: #dcfce7;
            --error: #dc2626;
            --error-bg: #fee2e2;
            --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            --radius: 0.75rem;
        }

        /* Dark Mode Palette */
        html.dark {
            --primary: #818cf8;
            --primary-hover: #6366f1;
            --primary-light: rgba(79, 70, 229, 0.2);
            --bg-body: #111827;
            --bg-card: #1f2937;
            --text-main: #f3f4f6;
            --text-muted: #9ca3af;
            --border: #374151;
            --input-bg: #374151;
            --success: #4ade80;
            --success-bg: rgba(22, 163, 74, 0.2);
            --error: #f87171;
            --error-bg: rgba(220, 38, 38, 0.2);
            --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
        }

        /* --- 2. Reset & Base Styles --- */
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bg-body);
            color: var(--text-main);
            transition: background-color 0.3s ease, color 0.3s ease;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* --- 3. Layout Utilities --- */
        .container { max-width: 800px; margin: 0 auto; padding: 2rem 1rem; width: 100%; flex-grow: 1; }
        .header { 
            background-color: var(--bg-card); 
            border-bottom: 1px solid var(--border); 
            padding: 1rem;
            position: sticky;
            top: 0;
            z-index: 10;
        }
        .header-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
        .logo { font-size: 1.25rem; font-weight: 800; color: var(--primary); }
        .logo span { color: var(--text-main); }
        
        .hidden { display: none !important; }
        .flex { display: flex; }
        .flex-col { flex-direction: column; }
        .items-center { align-items: center; }
        .justify-between { justify-content: space-between; }
        .justify-center { justify-content: center; }
        .gap-2 { gap: 0.5rem; }
        .gap-4 { gap: 1rem; }
        .mt-4 { margin-top: 1rem; }
        .mb-4 { margin-bottom: 1rem; }
        .text-center { text-align: center; }
        .w-full { width: 100%; }

        /* --- 4. Components --- */
        
        /* Cards */
        .card {
            background-color: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 1.5rem;
            box-shadow: var(--shadow);
            margin-bottom: 1.5rem;
            transition: all 0.3s ease;
        }

        /* Inputs & Selects */
        label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); }
        select, input[type="text"], input[type="number"] {
            width: 100%;
            padding: 0.75rem;
            border-radius: 0.5rem;
            border: 1px solid var(--border);
            background-color: var(--input-bg);
            color: var(--text-main);
            font-size: 1rem;
            margin-bottom: 1rem;
        }
        input:focus, select:focus { outline: 2px solid var(--primary); border-color: transparent; }

        /* Buttons */
        .btn {
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            border: none;
            font-size: 0.9rem;
        }
        .btn-primary { background-color: var(--primary); color: white; width: 100%; }
        .btn-primary:hover { background-color: var(--primary-hover); }
        .btn-secondary { background-color: var(--bg-body); color: var(--text-main); border: 1px solid var(--border); }
        .btn-secondary:hover { background-color: var(--border); }
        .btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.5rem; }
        .btn-icon:hover { color: var(--text-main); background-color: var(--border); border-radius: 50%; }

        /* Tabs */
        .tabs { display: flex; background: var(--border); padding: 4px; border-radius: 0.5rem; margin-bottom: 1.5rem; }
        .tab-btn {
            flex: 1;
            padding: 0.5rem;
            text-align: center;
            border-radius: 0.3rem;
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: 500;
            color: var(--text-muted);
            background: transparent;
            border: none;
        }
        .tab-btn.active { background-color: var(--bg-card); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

        /* Checkboxes */
        .checkbox-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 0.5rem;
            max-height: 200px;
            overflow-y: auto;
            padding: 0.5rem;
            border: 1px solid var(--border);
            border-radius: 0.5rem;
            background: var(--bg-body);
        }
        .checkbox-item { display: flex; align-items: center; font-size: 0.85rem; }
        .checkbox-item input { margin-right: 0.5rem; }

        /* Quiz specific */
        .stats-bar {
            display: flex;
            justify-content: space-between;
            background: var(--bg-card);
            padding: 1rem;
            border-radius: var(--radius);
            border: 1px solid var(--border);
            margin-bottom: 1rem;
            position: sticky;
            top: 80px;
            z-index: 5;
        }
        .stat-label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; display: block; }
        .stat-value { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
        .timer-value { font-family: monospace; }

        /* Options & Questions */
        .question-text { font-size: 1.15rem; margin-bottom: 1.5rem; line-height: 1.6; white-space: pre-wrap; }

        /* MCQ Buttons */
        .option-btn {
            width: 100%;
            text-align: left;
            padding: 1rem;
            margin-bottom: 0.75rem;
            border: 1px solid var(--border);
            border-radius: 0.5rem;
            background: var(--bg-card);
            color: var(--text-main);
            cursor: pointer;
            display: flex;
            align-items: center;
            transition: all 0.2s;
        }
        .option-btn:hover:not(:disabled) { background-color: var(--bg-body); }
        .option-btn.selected { border-color: var(--primary); background-color: var(--primary-light); box-shadow: 0 0 0 1px var(--primary); }
        .option-btn.correct { border-color: var(--success); background-color: var(--success-bg); color: var(--success); }
        .option-btn.incorrect { border-color: var(--error); background-color: var(--error-bg); color: var(--error); }
        .option-letter { font-weight: 800; margin-right: 1rem; color: var(--text-muted); min-width: 1.5rem; }
        
        /* MSQ Grid Styles */
        .msq-container { display: flex; flex-direction: column; gap: 1rem; }
        .msq-row { background: var(--bg-body); padding: 1rem; border-radius: 0.5rem; border: 1px solid var(--border); }
        .msq-statement { font-weight: 500; margin-bottom: 0.75rem; }
        .msq-options { display: flex; gap: 0.5rem; flex-wrap: wrap; }
        .msq-options .option-btn { width: auto; flex: 1; margin-bottom: 0; min-width: 100px; justify-content: center; }

        /* Cloze Styles */
        .cloze-input {
            display: inline-block;
            width: 120px;
            padding: 0.25rem 0.5rem;
            margin: 0 0.25rem;
            border: none;
            border-bottom: 2px solid var(--text-muted);
            background: transparent;
            color: var(--text-main);
            text-align: center;
            font-weight: 600;
        }
        .cloze-input:focus { outline: none; border-bottom-color: var(--primary); }
        .cloze-input.correct { border-bottom-color: var(--success); color: var(--success); }
        .cloze-input.incorrect { border-bottom-color: var(--error); color: var(--error); }

        /* Result Specifics */
        span.correct { color: var(--success); font-weight: bold; }
        span.incorrect { color: var(--error); font-weight: bold; }

        /* Navigation Grid */
        .nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 0.5rem; }
        .nav-cell {
            height: 40px;
            border-radius: 0.3rem;
            border: 1px solid var(--border);
            background: var(--bg-body);
            color: var(--text-muted);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 0.85rem;
        }
        .nav-cell.active { border-color: var(--primary); border-width: 2px; }
        .nav-cell.answered { background-color: var(--primary-light); color: var(--primary); border-color: var(--primary); }
        .nav-cell.answered-correct { background-color: var(--success-bg); color: var(--success); border-color: var(--success); }
        .nav-cell.answered-incorrect { background-color: var(--error-bg); color: var(--error); border-color: var(--error); }

        /* Results */
        .result-card { border-left: 4px solid; padding: 1.5rem; background: var(--bg-card); margin-bottom: 1rem; border-radius: 0.5rem; box-shadow: var(--shadow); }
        .result-correct { border-left-color: var(--success); }
        .result-incorrect { border-left-color: var(--error); }
        .explanation-box { background: var(--bg-body); padding: 1rem; margin-top: 1rem; border-radius: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }
        .user-answer { margin: 0.5rem 0; font-size: 0.95rem; }
        .sub-result { margin-top: 0.5rem; padding: 0.5rem; background: var(--bg-body); border-radius: 0.25rem; }
        
        /* Modals */
        .modal {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5);
            display: flex; align-items: center; justify-content: center;
            opacity: 0; pointer-events: none; transition: opacity 0.3s;
            z-index: 100;
            backdrop-filter: blur(2px);
        }
        .modal.active { opacity: 1; pointer-events: all; }
        .modal-content {
            background: var(--bg-card);
            padding: 2rem;
            border-radius: 1rem;
            max-width: 500px;
            width: 90%;
            position: relative;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
            max-height: 90vh;
            overflow-y: auto;
        }
        .modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
        
        /* Footer */
        footer { text-align: center; padding: 2rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.85rem; margin-top: auto; }

        /* Loading Spinner */
        .spinner { width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 1rem; }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* Badge */
        .badge { font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 0.25rem; font-family: monospace; background: var(--bg-body); color: var(--text-muted); }
        
        /* Donation Image */
        .donation-image { max-width: 150px; height: auto; margin-bottom: 1rem; border-radius: var(--radius); }

        /* --- Statistic & Podium --- */
        .leaderboard-table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; font-size: 0.9rem; }
        .leaderboard-table th, .leaderboard-table td { padding: 0.75rem; border: 1px solid var(--border); text-align: left; color: var(--text-main); }
        .leaderboard-table th { background-color: var(--bg-body); font-weight: 600; color: var(--primary); }
        .leaderboard-table tbody tr:nth-child(even) { background-color: var(--bg-body); }
        .leaderboard-table tbody tr:hover { background-color: var(--primary-light); transform: translateY(-2px); transition: transform 0.2s; }

        .podium-container { display: flex; justify-content: center; align-items: flex-end; gap: 1rem; margin: 2rem 0 3rem; min-height: 200px; }
        .podium-spot {
            background-color: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
            padding: 0.5rem; text-align: center; display: flex; flex-direction: column;
            justify-content: flex-end; align-items: center; box-shadow: var(--shadow);
            position: relative; transition: transform 0.3s; width: 30%; max-width: 120px;
        }
        .podium-spot:hover { transform: translateY(-5px); }
        /* Podium Colors - using hardcoded colors for medals as they are specific */
        .podium-spot.first { height: 180px; order: 2; background: #FFC000; border-color: #B8A000; color: #1f2937; }
        .podium-spot.second { height: 150px; order: 1; background: #C0C0C0; border-color: #969696; color: #1f2937; }
        .podium-spot.third { height: 120px; order: 3; background: #CD7F32; border-color: #a66629; color: #1f2937; }
        
        .podium-spot h4 { font-size: 0.85rem; font-weight: 800; margin: 0.5rem 0 0; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
        .rank-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background-color: var(--primary); color: white; font-weight: 800; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; box-shadow: var(--shadow); z-index: 2; }
        .profile-picture { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; border: 3px solid white; background: #e0e0e0; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 4px; }
        .podium-spot.empty { background: var(--bg-body); border-style: dashed; opacity: 0.6; border-color: var(--text-muted); color: var(--text-muted); }
        
        .loading-row { text-align: center; padding: 2rem; color: var(--text-muted); }

        /* Login & Name List */
        .name-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; padding: 0.5rem; }
        .name-list-item { background-color: var(--bg-body); border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.75rem 1rem; cursor: pointer; transition: background-color 0.2s ease; text-align: center; color: var(--text-main); }
        .name-list-item:hover { background-color: var(--primary-light); color: var(--primary); border-color: var(--primary); }
        .user-info { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
        .user-badge { background: var(--primary); color: white; padding: 0.25rem 0.75rem; border-radius: 999px; font-weight: 600; font-size: 0.8rem; }
