:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #f8fafc;
    --secondary-hover: #f1f5f9;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --bg-color: #f1f5f9;
    --surface-color: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    
    --answered-color: #10b981;
    --unanswered-color: #cbd5e1;
    --current-color: #3b82f6;
    --locked-bg: #f8fafc;
    --locked-text: #94a3b8;
    
    /* Subject Colors */
    --physics-color: #06b6d4;
    --chemistry-color: #6366f1;
    --biology-color: #10b981;
    --mock-color: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
}

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Typography */
h1 { font-size: 2rem; font-weight: 700; color: var(--text-primary); margin-bottom: 1rem; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { line-height: 1.6; color: var(--text-secondary); }

/* Buttons */
button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover { background-color: var(--primary-hover); }

.secondary-btn {
    background-color: var(--secondary-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover { background-color: var(--secondary-hover); }

.danger-btn {
    background-color: var(--danger-color);
    color: white;
}

.danger-btn:hover { background-color: var(--danger-hover); }

/* Start & Result Screens */
#start-screen, #result-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.start-box, .result-box {
    background-color: var(--surface-color);
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.instructions {
    text-align: left;
    margin: 2rem 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.instructions li { margin-bottom: 0.5rem; }

/* Result specifics */
.score-card {
    background-color: var(--secondary-color);
    padding: 2rem;
    border-radius: 0.75rem;
    margin: 2rem 0;
}

.score-display {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.percentage {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.insight-msg {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Exam Screen Layout */
.exam-header {
    background-color: var(--surface-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.exam-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.timer-container {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    background-color: var(--secondary-color);
    padding: 0.5rem 1.5rem;
    border-radius: 9999px;
}

.exam-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Main Question Section */
.question-section {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.question-header {
    margin-bottom: 1.5rem;
}

.question-content {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    line-height: 1.7;
}

/* Options */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-item {
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
}

.option-item:hover {
    border-color: var(--primary-hover);
    background-color: var(--secondary-color);
}

.option-item.selected {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.option-label {
    font-weight: 600;
    margin-right: 1rem;
    color: var(--primary-color);
}

/* Actions */
.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--surface-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.box {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

.box.answered { background-color: var(--answered-color); border-color: var(--answered-color); }
.box.unanswered { background-color: var(--unanswered-color); }
.box.current { background-color: var(--current-color); border-color: var(--current-color); }

/* Question Grid */
.question-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}

.grid-btn {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: all 0.2s;
}

.grid-btn:hover {
    border-color: var(--primary-color);
}

.grid-btn.answered {
    background-color: var(--answered-color);
    color: white;
    border-color: var(--answered-color);
}

.grid-btn.current {
    background-color: var(--current-color);
    color: white;
    border-color: var(--current-color);
}

/* Toast */
#toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--danger-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transition: opacity 0.3s ease;
}

/* Solutions Screen */
.solutions-body {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.solution-card {
    background-color: var(--surface-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
}

.solution-card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.solution-card .user-ans, .solution-card .correct-ans {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.solution-card .correct-ans {
    color: var(--success-color);
}

.solution-card .user-ans.wrong {
    color: var(--danger-color);
}

.solution-explanation {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Dashboard Styles */
.dashboard-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1.25rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.dashboard-title {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    backdrop-filter: blur(4px);
}

.dashboard-main {
    padding: 3rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Hero Section */
.dashboard-hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, #312e81 100%);
    background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px), linear-gradient(135deg, var(--primary-color) 0%, #312e81 100%);
    background-size: 20px 20px, 100% 100%;
    border-radius: 1.5rem;
    padding: 3.5rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.25), 0 10px 10px -5px rgba(79, 70, 229, 0.15);
    position: relative;
    overflow: hidden;
}

.dashboard-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}

.hero-text {
    flex: 1;
    text-align: left;
}

.hero-text h1 {
    font-size: 2.75rem;
    font-weight: 800;
    color: white;
    margin-bottom: 1rem;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.hero-text p {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.6;
}

.stats-container {
    display: flex;
    gap: 1.5rem;
    flex-shrink: 0;
}

.stat-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1.25rem;
    padding: 1.5rem 2rem;
    min-width: 150px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-num {
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    display: block;
    line-height: 1;
    margin-bottom: 0.35rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Tabs Container */
.tab-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.75rem;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
    color: var(--primary-color);
    background-color: var(--secondary-color);
}

.tab-btn.active {
    color: var(--accent);
    background-color: var(--accent-light);
    border-bottom: 3px solid var(--accent);
    border-radius: 0.75rem 0.75rem 0 0;
}

.tab-btn span {
    font-size: 1.25rem;
}

/* Subject Sections & Hierarchy */
.subject-section {
    margin-bottom: 3.5rem;
    animation: fadeIn 0.4s ease-out;
}

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

.subject-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--sub-color-light);
    color: var(--sub-color);
}

.subject-section-header span {
    font-size: 2rem;
}

.subject-section-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0;
    letter-spacing: -0.02em;
}

.subject-section-header span.badge {
    background-color: var(--sub-color-light);
    color: var(--sub-color);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Dynamic Subject Themes */
.subject-physics {
    --sub-color: var(--physics-color);
    --sub-color-light: rgba(6, 182, 212, 0.08);
    --sub-color-glow: rgba(6, 182, 212, 0.2);
}

.subject-chemistry {
    --sub-color: var(--chemistry-color);
    --sub-color-light: rgba(99, 102, 241, 0.08);
    --sub-color-glow: rgba(99, 102, 241, 0.2);
}

.subject-biology {
    --sub-color: var(--biology-color);
    --sub-color-light: rgba(16, 185, 129, 0.08);
    --sub-color-glow: rgba(16, 185, 129, 0.2);
}

.subject-mock {
    --sub-color: var(--mock-color);
    --sub-color-light: rgba(245, 158, 11, 0.08);
    --sub-color-glow: rgba(245, 158, 11, 0.2);
}

/* Modules Grid Nested */
.module-grid-nested {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.75rem;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.75rem;
}

.module-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.75rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.module-card.unlocked {
    cursor: pointer;
    border-left: 5px solid var(--sub-color);
}

.module-card.unlocked:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 25px -5px var(--sub-color-glow), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--sub-color);
}

.module-card.locked {
    background-color: var(--locked-bg);
    cursor: not-allowed;
    opacity: 0.8;
}

.card-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--sub-color-light);
    color: var(--sub-color);
    transition: transform 0.2s;
}

.module-card.unlocked:hover .card-icon {
    transform: scale(1.1);
}

.module-card.locked .card-icon {
    background-color: #f1f5f9;
    color: var(--locked-text);
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
    line-height: 1.4;
    font-weight: 600;
}

.module-card.locked .card-content h3 {
    color: var(--locked-text);
}

.module-type {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    background-color: var(--secondary-color);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
}

.module-card.locked .module-type {
    background-color: #f1f5f9;
    color: var(--locked-text);
}

.card-status {
    color: var(--sub-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.module-card.unlocked .card-status span {
    font-size: 1.75rem;
    animation: pulse 2s infinite;
}

.module-card.locked .card-status {
    color: var(--locked-text);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.12); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Success Button (green submit) */
.success-btn {
    background-color: var(--success-color);
    color: white;
}
.success-btn:hover {
    background-color: #059669;
}

/* MathJax Normalization */
mjx-container {
    font-size: 100% !important;
    color: inherit !important;
    display: inline-block;
    vertical-align: middle;
}
mjx-container[display="true"] {
    display: block !important;
    margin: 1em 0 !important;
    text-align: center;
}

/* Option badge styles */
.option-item {
    gap: 0.75rem;
}
.option-label {
    background-color: var(--secondary-color);
    color: var(--text-primary);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}
.option-item.selected .option-label {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Action button changes & header styling */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 50%;
    aspect-ratio: 1;
    cursor: pointer;
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}
.icon-btn:hover {
    background-color: var(--secondary-hover);
}
.mobile-only {
    display: none !important;
}

/* Exam Screen Responsive Updates */
@media (max-width: 1024px) {
    .exam-body {
        flex-direction: column;
    }
    .sidebar {
        position: fixed;
        top: 0;
        right: -340px;
        width: 320px;
        height: 100vh;
        max-height: 100vh;
        background-color: var(--surface-color);
        z-index: 1000;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -10px 0 30px rgba(15, 23, 42, 0.15);
        border-left: 1px solid var(--border-color);
        border-top: none;
        display: flex;
        flex-direction: column;
    }
    .sidebar.open {
        right: 0;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        z-index: 999;
    }
    .sidebar-overlay.visible {
        display: block;
    }
    .mobile-only {
        display: flex !important;
    }
    .dashboard-header, .dashboard-main {
        padding: 1.5rem;
    }
    .dashboard-hero {
        flex-direction: column;
        text-align: center;
        padding: 2.5rem 1.5rem;
    }
    .hero-text {
        text-align: center;
    }
    .hero-text h1 {
        font-size: 2.2rem;
    }
    .stats-container {
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
    }
    .stat-card {
        flex: 1;
        min-width: 120px;
    }
}