/* CSS Variables */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 50, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);
    --border-color: rgba(255, 255, 255, 0.1);
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-error: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    background-image: 
        radial-gradient(ellipse at top left, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    margin-bottom: 2.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Chapter Grid */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chapter-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.chapter-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.chapter-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chapter-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.chapter-progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.chapter-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.btn-true {
    background: var(--gradient-success);
    color: white;
    flex: 1;
    padding: 1.25rem;
    font-size: 1.1rem;
}

.btn-false {
    background: var(--gradient-error);
    color: white;
    flex: 1;
    padding: 1.25rem;
    font-size: 1.1rem;
}

.btn-true:hover, .btn-false:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-true:disabled, .btn-false:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.btn-large {
    padding: 1.25rem 2rem;
    font-size: 1.1rem;
    width: 100%;
}

/* Quiz Page */
.quiz-container {
    max-width: 700px;
}

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

.back-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent-primary);
}

.quiz-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Progress */
.progress-section {
    margin-bottom: 2rem;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

/* Question Card */
.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

.question-number {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.25rem;
    line-height: 1.7;
    font-weight: 500;
}

/* Feedback Card */
.feedback-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    animation: slideIn 0.3s ease;
}

.feedback-card.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.feedback-card.incorrect {
    border-color: var(--error);
    background: var(--error-bg);
}

.feedback-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.feedback-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.explanation {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.quiz-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
    animation: scaleIn 0.3s ease;
}

.modal-content h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

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

.summary-percent {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.summary-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .stats-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .stat {
        flex: 1;
        min-width: 80px;
    }

    .chapter-grid {
        grid-template-columns: 1fr;
    }

    .question-card {
        padding: 1.5rem;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .button-group {
        flex-direction: column;
    }
}
