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

:root {
    --primary: #1a1a1a;
    --secondary: #f0f0f0;
    --accent: #6366f1;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-light: #6b7280;
    --bg-main: #ffffff;
    --bg-secondary: #f9fafb;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --primary: #ffffff;
    --secondary: #1f2937;
    --accent: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-light: #9ca3af;
    --bg-main: #1f2937;
    --bg-secondary: #111827;
    --border: #374151;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.15);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.35);
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

#app {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 560px;
    padding: 20px;
}

/* Start Screen Styles */
#startScreen {
    background: var(--bg-secondary);
}

#startScreen h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

#startScreen h1::after {
    content: '.';
    color: var(--accent);
}

.header-controls {
    position: absolute;
    top: 20px;
    right: 20px;
}

.theme-toggle {
    background: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.theme-toggle:hover {
    border-color: var(--accent);
    background: var(--accent);
}

.theme-toggle:hover .theme-icon {
    filter: grayscale(1) brightness(2);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 18px;
    margin-bottom: 20px;
}

.exam-info-banner {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 32px;
    text-align: center;
}

.exam-info-banner p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.exam-info-banner span {
    color: var(--accent);
    font-weight: 600;
}

.settings-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow-md);
}

.settings-card h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-card h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--accent);
    margin-right: 8px;
    border-radius: 2px;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
    background: var(--bg-secondary);
}

.setting-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-main);
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-light);
}

/* Button Styles */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
    margin-top: 24px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--accent);
    transition: left 0.3s;
    z-index: 0;
}

.btn-primary:hover::before {
    left: 0;
}

.btn-primary span {
    position: relative;
    z-index: 1;
}

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

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

.btn-submit {
    background: var(--success);
    color: white;
    padding: 12px 24px;
    font-size: 14px;
}

.btn-submit:hover {
    background: #008f68;
    transform: translateY(-1px);
}

/* Exam Screen Styles */
#examScreen {
    flex-direction: column;
    background: var(--bg-secondary);
}

.exam-header {
    width: 100%;
    background: var(--bg-main);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.exam-info {
    display: flex;
    align-items: center;
}

.question-indicator {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.question-indicator #currentQuestionNum {
    font-size: 24px;
    color: var(--accent);
    margin: 0 4px;
}

.timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.timer::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 3px;
    background: var(--border);
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 100px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100px); }
    100% { transform: translateX(100px); }
}

.exam-container {
    display: flex;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    flex: 1;
}

/* Question Navigation Sidebar */
.question-nav {
    width: 240px;
    background: var(--bg-main);
    padding: 24px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - 83px);
}

.question-nav h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.question-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.question-btn {
    aspect-ratio: 1;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    position: relative;
}

.question-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-main);
}

.question-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.question-btn.answered:not(.active) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.question-btn.answered:not(.active)::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

/* Main Question Area */
.question-area {
    flex: 1;
    background: var(--bg-main);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: calc(100vh - 83px);
}

#questionContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

#questionText {
    color: var(--text-primary);
    margin-bottom: 48px;
    line-height: 1.8;
    font-size: 22px;
    font-weight: 400;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    position: relative;
}

.answer-option:hover {
    border-color: var(--accent);
    background: var(--bg-main);
    transform: translateX(8px);
}

.answer-option.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.answer-option.selected .option-label {
    background: white;
    color: var(--primary);
}

.option-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-main);
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
    margin-right: 16px;
    flex-shrink: 0;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.answer-option:hover .option-label {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.option-text {
    flex: 1;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.navigation-buttons .btn {
    min-width: 140px;
}

.navigation-buttons .btn-secondary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--border);
    color: var(--text-light);
}

/* Results Screen */
#resultsScreen {
    background: var(--bg-secondary);
}

#resultsScreen h1 {
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 32px;
    text-align: center;
}

.results-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.score-display {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.score-display h2 {
    font-size: 72px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--danger));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-display p {
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.results-details p {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.results-details span {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.results-summary {
    margin-top: 32px;
}

.results-summary h3 {
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.question-review {
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.review-item {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--border);
}

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

.review-item.incorrect {
    border-left-color: var(--danger);
}

.review-item-header {
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.review-item-status {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.review-item-status.correct {
    background: var(--success);
    color: white;
}

.review-item-status.incorrect {
    background: var(--danger);
    color: white;
}

.review-item p {
    margin-bottom: 8px;
    line-height: 1.6;
}

.review-item p strong {
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .exam-container {
        flex-direction: column;
    }

    .question-nav {
        width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .question-buttons {
        grid-template-columns: repeat(10, 1fr);
    }
}

@media (max-width: 768px) {
    #startScreen h1 {
        font-size: 36px;
    }

    .exam-header {
        flex-wrap: wrap;
        gap: 16px;
    }

    .question-area {
        padding: 24px;
    }

    #questionText {
        font-size: 18px;
    }

    .results-details {
        grid-template-columns: 1fr;
    }

    .navigation-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .navigation-buttons .btn {
        width: 100%;
    }
}