/* CSS Reset & Variables */
:root {
    --bg-dark: #0b0f17;
    --card-bg: #151b26;
    --card-border: #283245;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gold-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #fbbf24 100%);
    --accent-orange: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-blue: #3b82f6;
    
    --shadow-glow: 0 10px 30px -10px rgba(139, 92, 246, 0.4);
    --shadow-gold: 0 8px 24px rgba(245, 158, 11, 0.3);
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.4);
    
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --font-main: 'Poppins', sans-serif;
    --font-hindi: 'Tiro Devanagari Hindi', 'Poppins', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    user-select: none;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.14) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(217, 70, 239, 0.14) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
}

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

/* App Container */
.app-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 20px 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: rgba(21, 27, 38, 0.85);
    backdrop-filter: blur(14px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    flex-wrap: wrap;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(139, 92, 246, 0.5));
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.2;
}

.logo h1 span {
    color: #fbbf24;
    font-size: 0.85rem;
    font-weight: 600;
}

.logo .subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

/* XP Level Bar */
.xp-level-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(33, 41, 56, 0.8);
    border: 1px solid var(--card-border);
    padding: 6px 14px;
    border-radius: var(--radius-md);
}

.xp-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 6px;
}

.xp-bar-outer {
    width: 90px;
    height: 8px;
    background: #1a2230;
    border-radius: 10px;
    overflow: hidden;
}

.xp-bar-inner {
    height: 100%;
    background: var(--gold-gradient);
    border-radius: 10px;
    transition: width 0.4s ease;
}

.xp-num {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    background: #1c2433;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 3px;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.icon-btn {
    background: #1c2433;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.icon-btn:hover {
    transform: scale(1.08);
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 126, 95, 0.15);
    border: 1px solid rgba(255, 126, 95, 0.4);
    color: #ff7e5f;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
}

.streak-icon {
    font-size: 1.1rem;
    animation: flamePulse 1.5s infinite alternate;
}

@keyframes flamePulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 2px #ff7e5f); }
    100% { transform: scale(1.2); filter: drop-shadow(0 0 10px #ff1100); }
}

/* Screens Setup */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* HERO CARD */
.hero-card {
    background: rgba(21, 27, 38, 0.85);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.hero-badge {
    display: inline-block;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.hero-card h2 {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 12px;
}

.hero-card h2 .highlight {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 680px;
    margin: 0 auto 20px auto;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.h-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1c2433;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    color: #e6edf3;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.h-stat i {
    color: #fbbf24;
}

/* SECTION TITLES */
.section-title {
    margin-bottom: 16px;
}

.section-title h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title h3 i {
    color: #a78bfa;
}

/* MODES GRID */
.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.mode-card {
    background: rgba(21, 27, 38, 0.75);
    border: 2px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.mode-card:hover {
    transform: translateY(-4px);
    border-color: #fbbf24;
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.2);
}

.mode-card.selected {
    border-color: #fbbf24;
    background: rgba(245, 158, 11, 0.1);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.mode-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 12px;
}

.bg-gold { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-orange { background: linear-gradient(135deg, #ff7e5f, #feb47b); }
.bg-purple { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.bg-blue { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.bg-green { background: linear-gradient(135deg, #10b981, #059669); }

.mode-card h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.mode-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.4;
    flex-grow: 1;
}

.mode-pill {
    font-size: 0.75rem;
    font-weight: 600;
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.gold-pill {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.15);
}

/* SUBJECT SELECTOR */
.subject-selector-wrapper {
    background: rgba(21, 27, 38, 0.75);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 24px;
}

.subject-selector-wrapper.hidden {
    display: none;
}

.subject-selector-wrapper h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.subject-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sub-chip {
    background: #1c2433;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sub-chip:hover {
    border-color: #8b5cf6;
    color: #c084fc;
}

.sub-chip.active {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

/* ACTION BAR */
.action-bar {
    text-align: center;
    margin-top: 10px;
}

.primary-btn {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    padding: 14px 38px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.25s ease;
}

.primary-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 36px -8px rgba(139, 92, 246, 0.6);
}

.primary-btn.pulse {
    animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.btn-secondary {
    background: #1c2433;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: #283245;
    transform: translateY(-1px);
}

/* QUIZ ARENA SCREEN */
.quiz-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.status-item {
    display: flex;
    flex-direction: column;
}

.status-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.text-right {
    text-align: right;
}

.timer-box {
    background: #1c2433;
    border: 1px solid var(--card-border);
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #e6edf3;
}

.timer-box.urgent {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
    animation: shakeUrgent 0.5s infinite;
}

@keyframes shakeUrgent {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.combo-box {
    background: linear-gradient(135deg, #ff7e5f, #d946ef);
    padding: 4px 12px;
    border-radius: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 800;
    animation: popCombo 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popCombo {
    0% { transform: scale(0.5); }
    100% { transform: scale(1); }
}

.combo-box.hidden {
    display: none;
}

/* PROGRESS BAR */
.progress-container {
    height: 8px;
    background: #1c2433;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

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

/* MASCOT BANNER */
.mascot-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mascot-avatar {
    font-size: 2.2rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    animation: mascotBounce 3s ease-in-out infinite;
}

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

.mascot-bubble {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #c084fc;
    padding: 10px 16px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    font-size: 0.88rem;
    font-weight: 500;
    flex: 1;
}

/* QUESTION CARD */
.question-card {
    background: rgba(21, 27, 38, 0.88);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    position: relative;
}

.q-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.q-tag {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pyq-badge {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 700;
}

.pyq-badge.hidden {
    display: none;
}

.diff-tag {
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 600;
}

.diff-tag.easy { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.diff-tag.medium { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.diff-tag.hard { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.question-text {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 20px;
    color: #f0f6fc;
}

/* Options Grid */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    background: #1c2433;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.option-btn:hover:not(.disabled) {
    background: #283245;
    border-color: #8b5cf6;
    transform: translateX(4px);
}

.opt-prefix {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #a78bfa;
    flex-shrink: 0;
}

.opt-text {
    flex-grow: 1;
    line-height: 1.4;
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: var(--accent-green) !important;
    color: #a7f3d0 !important;
    animation: correctPulse 0.4s ease;
}

.option-btn.correct .opt-prefix {
    background: var(--accent-green);
    color: #fff;
}

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

.option-btn.incorrect {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: var(--accent-red) !important;
    color: #fecaca !important;
    animation: shakeWrong 0.4s ease;
}

.option-btn.incorrect .opt-prefix {
    background: var(--accent-red);
    color: #fff;
}

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

.option-btn.disabled {
    cursor: default;
    opacity: 0.7;
}

/* EXPLANATION BOX */
.explanation-box {
    margin-top: 18px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-md);
    padding: 16px;
    animation: fadeIn 0.3s ease;
}

.explanation-box.hidden {
    display: none;
}

.exp-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #c084fc;
    margin-bottom: 6px;
}

#explanation-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* QUIZ CONTROLS */
.quiz-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quiz-controls .hidden {
    display: none !important;
}

/* RESULT SCREEN */
.result-card {
    background: rgba(21, 27, 38, 0.88);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.result-avatar {
    font-size: 3.5rem;
    margin-bottom: 12px;
}

.result-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.result-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.score-box {
    background: #1c2433;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.score-number {
    font-size: 1.4rem;
    font-weight: 800;
}

.highlight-text {
    color: #c084fc;
}

.xp-green {
    color: #34d399;
}

.badge-reward-card {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(217, 70, 239, 0.2));
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    margin-bottom: 24px;
}

.badge-icon {
    font-size: 2.2rem;
    color: #fbbf24;
}

.badge-reward-card h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #f0f6fc;
}

.badge-reward-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* REVIEW SECTION */
.review-section {
    background: rgba(21, 27, 38, 0.88);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.review-section.hidden {
    display: none;
}

.review-section h3 {
    font-size: 1.2rem;
    margin-bottom: 18px;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.review-item {
    background: #1c2433;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

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

.review-item.is-wrong {
    border-left: 4px solid var(--accent-red);
}

.rev-q-num {
    font-size: 0.8rem;
    font-weight: 700;
    color: #a78bfa;
    margin-bottom: 6px;
}

.rev-q-text {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.rev-ans {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.rev-ans.user-ans { color: #f87171; }
.rev-ans.correct-ans { color: #34d399; font-weight: 600; }

.rev-exp {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px rgba(255,255,255,0.05) solid;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 650px) {
    .navbar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .xp-level-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .nav-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .hero-card h2 {
        font-size: 1.4rem;
    }
    
    .modes-grid {
        grid-template-columns: 1fr;
    }
}
