:root {
    --primary-color: #962927;
    --primary-hover: #7a2120;
    --success-color: #10b981;
    --success-bg: #d1fae5;
    --error-color: #ef4444;
    --error-bg: #fee2e2;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background-color: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.logo {
    height: 60px;
    object-fit: contain;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.lesson-nav {
    display: flex;
    gap: 1rem;
    max-width: 1000px;
    margin: 1.5rem auto 0;
    align-items: center;
}

.lesson-select {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-main);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.lesson-select:focus {
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

.secondary-btn {
    background-color: var(--text-main);
    color: white;
}

.secondary-btn:hover {
    background-color: #334155;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
}

.screen {
    display: none;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.3s ease-out;
}

.screen.active {
    display: block;
}

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

/* Welcome Screen */
#welcome-screen {
    text-align: center;
}

#welcome-screen h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#welcome-screen p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.stats-overview {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat-card {
    background: var(--bg-color);
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border-color);
}

.history-container {
    margin-top: 2rem;
    text-align: left;
    display: none;
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.history-container h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.history-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-score {
    font-weight: 600;
    color: var(--text-main);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
}

/* Loading Screen */
#loading-screen {
    text-align: center;
    padding: 4rem 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Quiz Screen */
.quiz-header {
    margin-bottom: 2rem;
}

.progress-container {
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.quiz-stats {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
}

.question-container h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.option-btn {
    padding: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: transparent;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.option-btn.correct {
    border-color: var(--success-color);
    background-color: var(--success-bg);
}

.option-btn.wrong {
    border-color: var(--error-color);
    background-color: var(--error-bg);
}

.explanation {
    font-size: 0.9rem;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.7);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    border-left: 4px solid var(--success-color);
    animation: fadeIn 0.3s ease-out;
}

.quiz-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
}

/* Results Screen */
#results-screen {
    text-align: center;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 2rem auto;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
}

/* Responsive */
@media (max-width: 600px) {
    .header-container {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .logo {
        height: 50px;
    }

    .lesson-nav {
        flex-direction: column;
        width: 100%;
    }

    .lesson-select, .btn {
        width: 100%;
    }

    .screen {
        padding: 1.5rem;
    }
    
    .stats-overview {
        flex-direction: column;
        gap: 1rem;
    }
}
