/* ============================================
   EduQuest - Design System & Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Colors */
    --bg-primary: #06060f;
    --bg-secondary: #0d0d1f;
    --bg-tertiary: #141428;
    --bg-card: rgba(20, 20, 45, 0.7);
    --bg-card-hover: rgba(30, 30, 65, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #606080;
    --text-accent: #8b5cf6;

    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.3);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.3);
    --accent-orange: #f59e0b;
    --accent-orange-glow: rgba(245, 158, 11, 0.3);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.3);
    --accent-pink: #ec4899;
    --accent-pink-glow: rgba(236, 72, 153, 0.3);
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.3);
    --accent-teal: #14b8a6;

    /* Subject Colors */
    --color-coding: #8b5cf6;
    --color-coding-glow: rgba(139, 92, 246, 0.25);
    --color-history: #f59e0b;
    --color-history-glow: rgba(245, 158, 11, 0.25);
    --color-languages: #ec4899;
    --color-languages-glow: rgba(236, 72, 153, 0.25);
    --color-sciences: #10b981;
    --color-sciences-glow: rgba(16, 185, 129, 0.25);
    --color-english: #3b82f6;
    --color-english-glow: rgba(59, 130, 246, 0.25);

    /* Difficulty Colors */
    --diff-easy: #10b981;
    --diff-medium: #f59e0b;
    --diff-hard: #ef4444;
    --diff-extreme: #8b5cf6;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(139, 92, 246, 0.3);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- Particle Background --- */
#particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

/* --- Header --- */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(6, 6, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.header-left {
    flex: 0 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition-base);
}

.logo:hover {
    transform: scale(1.03);
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.5));
}

.logo-text {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-accent {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

#breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

#breadcrumb .crumb {
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

#breadcrumb .crumb:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

#breadcrumb .crumb.active {
    color: var(--accent-purple);
    font-weight: 600;
}

#breadcrumb .separator {
    color: var(--text-muted);
    font-size: 11px;
}

.header-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.stats-bar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-icon {
    font-size: 15px;
}

.xp-bar-container {
    width: 180px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.xp-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Main Content --- */
#app-content {
    position: relative;
    z-index: 1;
    padding-top: 80px;
    min-height: 100vh;
}

/* --- Screen Animations --- */
.screen-enter {
    animation: screenFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* --- Home Screen --- */
.home-screen {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

.hero-section {
    text-align: center;
    margin-bottom: var(--space-3xl);
    padding: var(--space-3xl) var(--space-lg);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-purple);
    margin-bottom: var(--space-lg);
    animation: floatBadge 3s ease-in-out infinite;
}

@keyframes floatBadge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(36px, 5vw, 64px);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: var(--space-lg);
    letter-spacing: -1.5px;
}

.hero-title .gradient-text {
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 50%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* --- Subject Cards Grid --- */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-3xl);
}

.subject-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-slow);
    overflow: hidden;
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-color);
    opacity: 0.8;
    transition: height var(--transition-slow);
}

.subject-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 0%, var(--card-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-slow);
    pointer-events: none;
}

.subject-card:hover {
    transform: translateY(-6px);
    border-color: var(--card-color);
    box-shadow: 0 12px 40px var(--card-glow);
}

.subject-card:hover::before {
    height: 4px;
}

.subject-card:hover::after {
    opacity: 1;
}

.subject-card:active {
    transform: translateY(-2px) scale(0.98);
}

.card-icon {
    font-size: 42px;
    margin-bottom: var(--space-md);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
    display: block;
}

.card-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-md);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.card-tag {
    padding: 3px 10px;
    background: var(--bg-glass);
    border-radius: 50px;
    font-weight: 500;
}

/* --- Progress Summary --- */
.progress-section {
    margin-bottom: var(--space-3xl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-md);
}

.progress-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
    transition: var(--transition-base);
}

.progress-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.progress-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- Grade Selection Screen --- */
.grade-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

.screen-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.screen-icon {
    font-size: 52px;
    display: block;
    margin-bottom: var(--space-md);
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.3));
}

.screen-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.5px;
}

.screen-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.grade-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-slow);
    text-align: center;
    position: relative;
    overflow: hidden;
}

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

.grade-card:active {
    transform: translateY(-1px) scale(0.98);
}

.grade-emoji {
    font-size: 40px;
    margin-bottom: var(--space-md);
    display: block;
}

.grade-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.grade-ages {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.grade-progress {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.grade-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

/* --- Term Selection --- */
.term-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
}

.term-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-slow);
    text-align: center;
    position: relative;
}

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

.term-card:active {
    transform: translateY(-1px) scale(0.98);
}

.term-number {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
}

.term-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.term-topics {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Sub-subject Selection (for Sciences) --- */
.sub-subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.sub-subject-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-slow);
    text-align: center;
}

.sub-subject-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-green);
    box-shadow: 0 12px 40px var(--accent-green-glow);
    background: var(--bg-card-hover);
}

.sub-subject-card:active {
    transform: translateY(-1px) scale(0.98);
}

.sub-icon {
    font-size: 40px;
    margin-bottom: var(--space-md);
    display: block;
}

.sub-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.sub-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- Difficulty Selection --- */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.difficulty-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-slow);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.difficulty-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--diff-color);
    transition: height var(--transition-slow);
}

.difficulty-card:hover {
    transform: translateY(-4px);
    border-color: var(--diff-color);
    box-shadow: 0 12px 40px var(--diff-glow);
    background: var(--bg-card-hover);
}

.difficulty-card:hover::before {
    height: 4px;
}

.difficulty-card:active {
    transform: translateY(-1px) scale(0.98);
}

.diff-icon {
    font-size: 36px;
    margin-bottom: var(--space-md);
    display: block;
}

.diff-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--diff-color);
}

.diff-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.diff-stars {
    font-size: 16px;
    letter-spacing: 2px;
}

/* --- Quiz Screen --- */
.quiz-screen {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.quiz-info {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.quiz-counter {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.quiz-counter span {
    color: var(--accent-purple);
    font-size: 18px;
}

.quiz-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 6px 14px;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.quiz-timer.warning {
    color: var(--accent-orange);
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.1);
    animation: timerPulse 1s ease infinite;
}

.quiz-timer.danger {
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
    animation: timerPulse 0.5s ease infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-green);
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    margin-bottom: var(--space-2xl);
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.quiz-question-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    margin-bottom: var(--space-lg);
    animation: questionSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes questionSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.quiz-difficulty-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-md);
}

.quiz-difficulty-badge.easy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--diff-easy);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.quiz-difficulty-badge.medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--diff-medium);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.quiz-difficulty-badge.hard {
    background: rgba(239, 68, 68, 0.15);
    color: var(--diff-hard);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.quiz-difficulty-badge.extreme {
    background: rgba(139, 92, 246, 0.15);
    color: var(--diff-extreme);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.quiz-question-text {
    font-family: var(--font-display);
    font-size: clamp(18px, 2.5vw, 24px);
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: var(--space-xl);
    color: var(--text-primary);
}

.quiz-options {
    display: grid;
    gap: var(--space-md);
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-glass);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 15px;
    color: var(--text-primary);
    position: relative;
}

.quiz-option:hover:not(.disabled) {
    background: var(--bg-glass-hover);
    border-color: var(--accent-purple);
    transform: translateX(4px);
}

.quiz-option:active:not(.disabled) {
    transform: translateX(2px) scale(0.99);
}

.quiz-option .option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.quiz-option:hover:not(.disabled) .option-letter {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-purple);
}

.quiz-option.correct {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
    animation: correctPulse 0.5s ease;
}

.quiz-option.correct .option-letter {
    background: var(--accent-green);
    color: white;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.quiz-option.incorrect {
    border-color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    animation: incorrectShake 0.4s ease;
}

.quiz-option.incorrect .option-letter {
    background: var(--accent-red);
    color: white;
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.quiz-option.disabled {
    cursor: default;
    opacity: 0.5;
}

.quiz-option.disabled.correct,
.quiz-option.disabled.incorrect {
    opacity: 1;
}

/* Explanation */
.quiz-explanation {
    margin-top: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: rgba(139, 92, 246, 0.08);
    border-left: 3px solid var(--accent-purple);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

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

.quiz-explanation strong {
    color: var(--accent-purple);
}

.quiz-nav {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white;
    box-shadow: 0 4px 16px var(--accent-purple-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-purple-glow);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

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

.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.btn-lg {
    padding: 16px 36px;
    font-size: 16px;
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: 8px 18px;
    font-size: 13px;
}

/* --- Results Screen --- */
.results-screen {
    max-width: 700px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.results-icon {
    font-size: 72px;
    margin-bottom: var(--space-lg);
    display: block;
    animation: resultsBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes resultsBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.results-title {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 900;
    margin-bottom: var(--space-sm);
}

.results-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: var(--space-2xl);
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
}

.result-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

.result-stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
}

.result-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.result-stat-value.green { color: var(--accent-green); }
.result-stat-value.red { color: var(--accent-red); }
.result-stat-value.blue { color: var(--accent-blue); }
.result-stat-value.purple { color: var(--accent-purple); }
.result-stat-value.orange { color: var(--accent-orange); }

.results-xp-earned {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-purple);
    margin-bottom: var(--space-2xl);
    animation: xpPop 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

@keyframes xpPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.results-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Review Section --- */
.review-section {
    margin-top: var(--space-2xl);
    text-align: left;
}

.review-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-lg);
    text-align: center;
}

.review-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}

.review-item.correct-review {
    border-left: 3px solid var(--accent-green);
}

.review-item.incorrect-review {
    border-left: 3px solid var(--accent-red);
}

.review-question {
    font-weight: 600;
    margin-bottom: var(--space-sm);
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
}

.review-answer {
    font-size: 13px;
    color: var(--text-secondary);
    padding-left: var(--space-lg);
}

.review-answer .correct-text {
    color: var(--accent-green);
    font-weight: 600;
}

.review-answer .wrong-text {
    color: var(--accent-red);
    text-decoration: line-through;
}

/* --- Notification --- */
.notification {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transform: translateX(0);
    transition: all var(--transition-slow);
}

.notification.hidden {
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

.notification.success {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
}

.notification.error {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
}

.notification.xp {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.1);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 480px;
    width: 90%;
    text-align: center;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    display: block;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    margin-bottom: var(--space-sm);
}

.modal-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

/* --- Back Button --- */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    background: none;
    border: none;
    margin-bottom: var(--space-lg);
    border-radius: var(--radius-sm);
}

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

/* --- Stagger Animations --- */
.stagger-item {
    opacity: 0;
    transform: translateY(15px);
    animation: staggerIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }

@keyframes staggerIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Achievement Pop --- */
.achievement-popup {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 250;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.2);
    animation: achievementIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards,
               achievementOut 0.4s ease 3s forwards;
}

@keyframes achievementIn {
    to { transform: translateX(-50%) translateY(0); }
}

@keyframes achievementOut {
    to { transform: translateX(-50%) translateY(100px); opacity: 0; }
}

.achievement-icon {
    font-size: 28px;
}

.achievement-text {
    font-size: 14px;
    font-weight: 600;
}

.achievement-name {
    color: var(--accent-purple);
    font-family: var(--font-display);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    display: block;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
}

/* --- Quiz Start Preview --- */
.quiz-start-screen {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.quiz-start-info {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    margin-bottom: var(--space-xl);
}

.quiz-start-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    text-align: left;
}

.quiz-detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.quiz-detail-item strong {
    color: var(--text-primary);
}

.question-count-selector {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.count-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.count-options {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    flex-wrap: wrap;
}

.count-btn {
    padding: 8px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
}

.count-btn:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.count-btn.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* --- Confetti --- */
.confetti-piece {
    position: fixed;
    z-index: 400;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    pointer-events: none;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #app-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 16px;
    }

    .header-center {
        order: 3;
        flex-basis: 100%;
        justify-content: flex-start;
        overflow-x: auto;
    }

    .stats-bar {
        gap: 10px;
    }

    .stat-item {
        font-size: 12px;
    }

    .xp-bar-container {
        width: 120px;
    }

    .home-screen,
    .grade-screen,
    .quiz-screen,
    .results-screen {
        padding: var(--space-lg) var(--space-md);
    }

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

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

    .hero-title {
        font-size: 28px;
    }

    .quiz-header {
        flex-wrap: wrap;
        gap: 8px;
    }

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

    .results-actions {
        flex-direction: column;
        align-items: center;
    }

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

@media (max-width: 480px) {
    .subjects-grid {
        grid-template-columns: 1fr;
    }

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

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.3);
}

/* --- Selection --- */
::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

/* --- Interactive Coding Lab Styles --- */
.coding-mode-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    margin-top: var(--space-2xl);
}

.mode-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    cursor: pointer;
    transition: all var(--transition-slow);
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 320px;
}

.mode-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent-purple);
    box-shadow: 0 12px 40px var(--accent-purple-glow);
    background: var(--bg-card-hover);
}

.mode-icon {
    font-size: 56px;
    margin-bottom: var(--space-md);
    filter: drop-shadow(0 4px 16px rgba(139, 92, 246, 0.3));
}

.mode-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    margin-bottom: var(--space-sm);
}

.mode-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-lg);
    flex-grow: 1;
}

.coding-lab-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: var(--space-lg);
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    height: calc(100vh - 120px);
}

.lab-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    overflow-y: auto;
}

.lab-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
}

.lab-challenge-item {
    padding: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-base);
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lab-challenge-item:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-light);
}

.lab-challenge-item.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-purple);
}

.lab-challenge-status {
    font-size: 14px;
}

.lab-main {
    display: grid;
    grid-template-rows: 1fr 200px;
    gap: var(--space-lg);
    height: 100%;
}

.lab-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    height: 100%;
}

.lab-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.lab-panel-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lab-description {
    flex: 1;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.lab-description code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--accent-pink);
}

.editor-wrapper {
    flex: 1;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.editor-textarea {
    width: 100%;
    height: 100%;
    background: #090915;
    color: #a9b7c6;
    border: none;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    resize: none;
    outline: none;
    line-height: 1.5;
}

.lab-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.lab-output {
    background: #090915;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #a9b7c6;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.console-log-line {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 2px;
}

.console-log-line.error {
    color: var(--accent-red);
}

.console-log-line.success {
    color: var(--accent-green);
}

.preview-iframe {
    width: 100%;
    height: 100%;
    background: white;
    border: none;
    border-radius: var(--radius-md);
}

