       :root {
            --primary-color: #2563eb;
            --primary-hover: #1d4ed8;
            --success-color: #10b981;
            --warning-color: #f59e0b;
            --danger-color: #ef4444;
            --bg-color: #ffffff;
            --text-color: #1f2937;
            --border-color: #e5e7eb;
            --card-bg: #ffffff;
            --header-bg: #f8fafc;
            --answered-color: #10b981;
            --marked-color: #f59e0b;
            --unanswered-color: #ef4444;
            --unvisited-color: #6b7280;
        }

        [data-theme="dark"] {
            --bg-color: #111827;
            --text-color: #f9fafb;
            --border-color: #374151;
            --card-bg: #1f2937;
            --header-bg: #1f2937;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            line-height: 1.6;
            transition: all 0.3s ease;
        }

        /* Header Styles */
        .header {
            background: var(--header-bg);
            border-bottom: 2px solid var(--border-color);
            padding: 1rem 2rem;
            position: sticky;
            top: 0;
            z-index: 100;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 1rem;
        }

        .test-title {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--primary-color);
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 2rem;
            flex-wrap: wrap;
        }

        .timer {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-weight: 600;
            font-size: 1.1rem;
        }

        .timer.warning {
            color: var(--danger-color);
            animation: pulse 1s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .theme-toggle {
            background: none;
            border: 2px solid var(--border-color);
            color: var(--text-color);
            padding: 0.5rem;
            border-radius: 0.5rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .theme-toggle:hover {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }

        /* Main Content */
        .main-container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 0 1rem;
            display: grid;
            grid-template-columns: 1fr 300px;
            gap: 2rem;
        }

        .question-area {
            background: var(--card-bg);
            border-radius: 0.75rem;
            padding: 2rem;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            border: 1px solid var(--border-color);
        }

        .progress-section {
            margin-bottom: 2rem;
        }

        .progress-bar {
            width: 100%;
            height: 8px;
            background: var(--border-color);
            border-radius: 4px;
            overflow: hidden;
            margin-bottom: 0.5rem;
        }

        .progress-fill {
            height: 100%;
            background: var(--primary-color);
            transition: width 0.3s ease;
        }

        .progress-text {
            font-size: 0.9rem;
            color: var(--text-color);
            opacity: 0.8;
        }

        .question-container {
            margin-bottom: 2rem;
        }

        .question-number {
            color: var(--primary-color);
            font-weight: 600;
            margin-bottom: 1rem;
        }

        .question-text {
            font-size: 1.1rem;
            margin-bottom: 1.5rem;
            line-height: 1.7;
            white-space: pre-line;  /* Break lines at \n inside explanation text */;   
        }

        .options-container {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .option {
            position: relative;
            cursor: pointer;
            padding: 1rem;
            border: 2px solid var(--border-color);
            border-radius: 0.5rem;
            transition: all 0.3s ease;
            background: var(--card-bg);
        }

        .option:hover {
            border-color: var(--primary-color);
            background: rgba(37, 99, 235, 0.05);
        }

        .option.selected {
            border-color: var(--primary-color);
            background: rgba(37, 99, 235, 0.1);
        }

        .option input[type="radio"] {
            position: absolute;
            opacity: 0;
            width: 0;
            height: 0;
        }

        .option-text {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .option-letter {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 2rem;
            height: 2rem;
            border-radius: 50%;
            background: var(--border-color);
            color: var(--text-color);
            font-weight: 600;
            flex-shrink: 0;
        }

        .option.selected .option-letter {
            background: var(--primary-color);
            color: white;
        }

        /* Navigation Buttons */
        .navigation {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 2rem;
            flex-wrap: wrap;
            gap: 1rem;
        }

        .nav-button {
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1rem;
        }

        .btn-primary {
            background: var(--primary-color);
            color: white;
        }

        .btn-primary:hover:not(:disabled) {
            background: var(--primary-hover);
        }

        .btn-secondary {
            background: var(--border-color);
            color: var(--text-color);
        }

        .btn-secondary:hover:not(:disabled) {
            background: var(--text-color);
            color: var(--bg-color);
        }

        .btn-warning {
            background: var(--warning-color);
            color: white;
        }

        .btn-warning:hover:not(:disabled) {
            background: #d97706;
        }

        .nav-button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Question Palette */
        .question-palette {
            background: var(--card-bg);
            border-radius: 0.75rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            border: 1px solid var(--border-color);
            position: sticky;
            top: 120px;
            max-height: calc(100vh - 140px);
            overflow-y: auto;
        }

        .palette-title {
            font-weight: 600;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid var(--border-color);
        }

        .palette-legend {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.5rem;
            margin-bottom: 1rem;
            font-size: 0.8rem;
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .legend-color {
            width: 12px;
            height: 12px;
            border-radius: 2px;
        }

        .palette-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 0.5rem;
        }

        .palette-item {
            width: 40px;
            height: 40px;
            border: 2px solid var(--border-color);
            border-radius: 0.25rem;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-weight: 600;
            font-size: 0.9rem;
            transition: all 0.3s ease;
            background: var(--card-bg);
        }

        .palette-item:hover {
            border-color: var(--primary-color);
        }

        .palette-item.current {
            border-color: var(--primary-color);
            background: var(--primary-color);
            color: white;
        }

        .palette-item.answered {
            background: var(--answered-color);
            color: white;
            border-color: var(--answered-color);
        }

        .palette-item.marked {
            background: var(--marked-color);
            color: white;
            border-color: var(--marked-color);
        }

        .palette-item.unanswered {
            background: var(--unanswered-color);
            color: white;
            border-color: var(--unanswered-color);
        }

        .palette-item.unvisited {
            background: var(--unvisited-color);
            color: white;
            border-color: var(--unvisited-color);
        }

        /* Modal Styles */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }

        .modal.show {
            display: flex;
        }

        .modal-content {
            background: var(--card-bg);
            padding: 2rem;
            border-radius: 0.75rem;
            max-width: 500px;
            width: 90%;
            text-align: center;
        }

        .modal-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 1rem;
        }

        .modal-buttons {
            display: flex;
            gap: 1rem;
            justify-content: center;
            margin-top: 1.5rem;
        }

        /* Results Page */
        .results-container {
            display: none;
            max-width: 1000px;
            margin: 2rem auto;
            padding: 0 1rem;
        }

        .results-header {
            background: var(--card-bg);
            padding: 2rem;
            border-radius: 0.75rem;
            margin-bottom: 2rem;
            text-align: center;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            border: 1px solid var(--border-color);
        }

        .score-display {
            font-size: 3rem;
            font-weight: bold;
            color: var(--primary-color);
            margin-bottom: 1rem;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1rem;
            margin: 2rem 0;
        }

        .stat-item {
            text-align: center;
            padding: 1rem;
            border-radius: 0.5rem;
            border: 1px solid var(--border-color);
        }

        .stat-number {
            font-size: 2rem;
            font-weight: bold;
            margin-bottom: 0.5rem;
        }

        .stat-correct .stat-number { color: var(--success-color); }
        .stat-incorrect .stat-number { color: var(--danger-color); }
        .stat-unanswered .stat-number { color: var(--unvisited-color); }

        .review-section {
            background: var(--card-bg);
            padding: 2rem;
            border-radius: 0.75rem;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            border: 1px solid var(--border-color);
        }

        .review-question {
            margin-bottom: 2rem;
            padding: 1.5rem;
            border: 1px solid var(--border-color);
            border-radius: 0.5rem;
           
        }

        .review-question.correct {
            border-left: 4px solid var(--success-color);
        }

        .review-question.incorrect {
            border-left: 4px solid var(--danger-color);
        }

        .review-question.unanswered {
            border-left: 4px solid var(--unvisited-color);
        }

        .review-options {
            margin: 1rem 0;
        }

        .review-option {
            padding: 0.75rem;
            margin: 0.5rem 0;
            border-radius: 0.25rem;
        }

        .review-option.correct {
            background: rgba(16, 185, 129, 0.1);
            border: 1px solid var(--success-color);
        }

        .review-option.user-selected {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid var(--danger-color);
        }

        .explanation {
            background: rgba(37, 99, 235, 0.1);
            padding: 1rem;
            border-radius: 0.5rem;
            margin-top: 1rem;
            border-left: 4px solid var(--primary-color);
            white-space: pre-line;  /* Break lines at \n inside explanation text */;       
            word-wrap: break-word;     /* Break long words */
            overflow-wrap: break-word; /* Modern replacement */
            text-align: justify;       /* Neat alignment for long paragraphs */
        }

        .explanation ul {
            margin: 0.25rem 0 0;
            padding-left: 1.25rem;
            list-style: disc;
            line-height: 0.75;    /* keeps it readable */
        }

        .explanation li {
            margin: 0.2rem 0;   /* smaller gap */
            line-height: 1.4;    /* keeps it readable */
        }

        .explanation li b {
            font-weight: bold;   /* keep bold */
            color: inherit;      /* use the same color as parent text */
            line-height: 0.8;
        }

        /* Footer */
        .footer {
            background: var(--header-bg);
            border-top: 1px solid var(--border-color);
            padding: 2rem;
            text-align: center;
            margin-top: 4rem;
        }

        .footer-content {
            max-width: 1200px;
            margin: 0 auto;
        }

        .instructions {
            background: var(--card-bg);
            padding: 1.5rem;
            border-radius: 0.5rem;
            border: 1px solid var(--border-color);
            margin-bottom: 1rem;
        }

        .instructions h3 {
            margin-bottom: 1rem;
            color: var(--primary-color);
        }

        .instructions ul {
            text-align: left;
            max-width: 600px;
            margin: 0 auto;
        }

        .instructions li {
            margin-bottom: 0.5rem;
        }

        .match-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 1rem;
        }
        .match-table th, .match-table td {
            padding: 8px;
            border: 1px solid var(--border-color);
        }
        .match-table th {
            background: var(--header-bg);
        }

        /* Responsive Design */
        @media (max-width: 768px) {
            .main-container {
                grid-template-columns: 1fr;
                gap: 1rem;
            }

            .question-palette {
                position: static;
                max-height: none;
                order: -1;
            }

            .palette-grid {
                grid-template-columns: repeat(10, 1fr);
            }

            .palette-item {
                width: 32px;
                height: 32px;
                font-size: 0.8rem;
            }

            .header-content {
                flex-direction: column;
                align-items: stretch;
                text-align: center;
            }

            .header-right {
                justify-content: center;
            }

            .navigation {
                flex-direction: column;
            }

            .stats-grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 480px) {
            .question-area,
            .question-palette {
                padding: 1rem;
            }

            .score-display {
                font-size: 2rem;
            }

            .stats-grid {
                grid-template-columns: 1fr;
            }
        }

        /* Accessibility */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }

        /* Focus styles for accessibility */
        button:focus,
        .option:focus,
        .palette-item:focus {
            outline: 2px solid var(--primary-color);
            outline-offset: 2px;
        }

        /* High contrast mode support */
        @media (prefers-contrast: high) {
            :root {
                --border-color: #000000;
                --text-color: #000000;
            }
            
            [data-theme="dark"] {
                --border-color: #ffffff;
                --text-color: #ffffff;
            }
        }
        .start-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;              /* full viewport height */
    background: var(--bg-color);
    color: var(--text-color);
    text-align: center;
    padding: 2rem;
}

.start-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
}

.start-box h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.start-box ul {
    text-align: left;
    margin-bottom: 2rem;
    line-height: 1.6;
}

