/* MathLeagues - Kid-Friendly UI Design */
/* Designed for middle school students (ages 11-14) */
/* Leonardo.ai-inspired redesign - Feb 2026 */

/* Fonts loaded via <link> in base.html for better performance */

:root {
    /* Vibrant Kid-Friendly Color Palette */
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --primary-glow: rgba(124, 58, 237, 0.3);

    /* Fun Accent Colors */
    --accent-pink: #ec4899;
    --accent-orange: #f97316;
    --accent-yellow: #fbbf24;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;

    /* Feedback Colors */
    --success: #22c55e;
    --success-light: #86efac;
    --success-bg: #dcfce7;
    --error: #ef4444;
    --error-light: #fca5a5;
    --error-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;

    /* Backgrounds - Soft & Inviting */
    --bg: #faf5ff;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f97316 100%);
    --bg-fun: linear-gradient(180deg, #faf5ff 0%, #ede9fe 100%);
    --card-bg: #ffffff;

    /* Text Colors */
    --text: #1e1b4b;
    --text-light: #6b7280;
    --text-muted: #9ca3af;

    /* Borders & Effects */
    --border: #e5e7eb;
    --border-fun: #ddd6fe;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --shadow: 0 4px 20px rgba(124, 58, 237, 0.1);
    --shadow-lg: 0 10px 40px rgba(124, 58, 237, 0.15);
    --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.2);

    /* Dark Theme Variables (default light theme values here for reference) */
    --dark-bg-base: #0d0d12;
    --dark-bg-surface: #141419;
    --dark-bg-elevated: #1a1a22;
    --dark-primary: #8b5cf6;
    --dark-primary-glow: rgba(139, 92, 246, 0.4);
    --dark-text: #f8fafc;
    --dark-text-secondary: #94a3b8;
    --dark-border: rgba(255, 255, 255, 0.08);
    --dark-glass-bg: rgba(255, 255, 255, 0.03);
    --dark-glass-border: rgba(255, 255, 255, 0.08);
}

/* ============================================
   THEME: Dark Mode (for public pages)
   ============================================ */
.theme-dark {
    --bg: var(--dark-bg-base);
    --bg-surface: var(--dark-bg-surface);
    --bg-elevated: var(--dark-bg-elevated);
    --bg-fun: var(--dark-bg-base);
    --card-bg: var(--dark-bg-surface);
    --primary: var(--dark-primary);
    --primary-glow: var(--dark-primary-glow);
    --text: var(--dark-text);
    --text-light: var(--dark-text-secondary);
    --text-muted: #64748b;
    --border: var(--dark-border);
    --border-fun: var(--dark-border);
    --glass-bg: var(--dark-glass-bg);
    --glass-border: var(--dark-glass-border);
}

.theme-dark body,
body.theme-dark {
    background: var(--dark-bg-base);
    color: var(--dark-text);
}

/* ============================================
   GLASSMORPHISM UTILITIES
   ============================================ */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
}

.glass-card-light {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
}

/* Glow effects */
.glow-primary {
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}

.glow-primary-hover:hover {
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
}

.glow-border {
    position: relative;
}

.glow-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.5), rgba(236, 72, 153, 0.5));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

/* ============================================
   NEW ANIMATIONS - Leonardo.ai Style
   ============================================ */
@keyframes gradient-shift {
    0% { transform: translate(0%, 0%) scale(1); opacity: 0.5; }
    50% { transform: translate(20%, -20%) scale(1.2); opacity: 0.8; }
    100% { transform: translate(0%, 0%) scale(1); opacity: 0.5; }
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.3),
                    0 0 40px rgba(139, 92, 246, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(139, 92, 246, 0.5),
                    0 0 60px rgba(139, 92, 246, 0.3);
    }
}

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

@keyframes border-glow {
    0%, 100% { border-color: rgba(139, 92, 246, 0.3); }
    50% { border-color: rgba(139, 92, 246, 0.6); }
}

@keyframes orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, -25px) scale(0.9); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-fun);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    position: relative;
}

/* ============================================
   ANIMATIONS - Fun & Engaging
   ============================================ */

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

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes bounce-in {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

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

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
    50% { box-shadow: 0 0 0 15px transparent; }
}

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

@keyframes star-twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

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

@keyframes points-float {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(1.2); opacity: 0; }
}

@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes sparkle {
    0%, 100% { transform: scale(0) rotate(0deg); opacity: 0; }
    50% { transform: scale(1) rotate(180deg); opacity: 1; }
}

/* ============================================
   BUTTONS - Playful & Touch-Friendly
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius);
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 52px;
    min-width: 52px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(124, 58, 237, 0.5);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 3px solid var(--border-fun);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: #faf5ff;
    transform: translateY(-2px);
}

.btn-small {
    padding: 10px 18px;
    font-size: 14px;
    min-height: 44px;
}

.btn-large {
    padding: 18px 36px;
    font-size: 18px;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
}

.btn-full {
    width: 100%;
}

.btn-hint {
    background: rgba(251, 191, 36, 0.15);
    border: 2px solid #fbbf24;
    color: #fbbf24;
    padding: 10px 18px;
    font-size: 14px;
    box-shadow: none;
}

.btn-hint:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.3);
}

.btn-hint:disabled {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.4);
    box-shadow: none;
    opacity: 0.6;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

/* ============================================
   LANDING PAGE - Dark Theme (Leonardo.ai Style)
   ============================================ */

.landing-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #0d0d12;
    position: relative;
    overflow: hidden;
}

/* Animated gradient orbs */
.landing-page .gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.landing-page .gradient-orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation: orb-float 15s ease-in-out infinite;
}

.landing-page .gradient-orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
    animation: orb-float 20s ease-in-out infinite reverse;
}

.landing-page .gradient-orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.25) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: orb-float 18s ease-in-out infinite;
    animation-delay: -5s;
}

/* Subtle grid pattern overlay */
.landing-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

/* Legacy support - keep existing ::after for shimmer effect */
.landing-page::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: radial-gradient(ellipse at center, transparent 0%, #0d0d12 70%);
    pointer-events: none;
}

.hero {
    text-align: center;
    color: #f8fafc;
    max-width: 650px;
    position: relative;
    z-index: 1;
    animation: card-enter 0.8s ease-out;
}

/* Mascot Container - Dark Theme with Glow */
.mascot-container {
    margin-bottom: 24px;
}

.mascot {
    width: 140px;
    height: 140px;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 40px rgba(139, 92, 246, 0.5))
            drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.mascot:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 60px rgba(139, 92, 246, 0.7))
            drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
}

/* Logo - Modern with Space Grotesk */
.logo {
    font-family: 'Space Grotesk', 'Nunito', sans-serif;
    font-size: 56px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #a78bfa 50%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: -1px;
}

/* Brand logo - reusable gradient text for "MathLeagues" across all pages */
.brand-logo {
    font-family: 'Nunito', 'Space Grotesk', sans-serif;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 50%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Light variant for dark/gradient backgrounds (dashboard header, etc.) */
.brand-logo-light {
    font-family: 'Nunito', 'Space Grotesk', sans-serif;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 20px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 36px;
    line-height: 1.6;
}

/* Features - Glassmorphic Cards */
.features {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 44px;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px 22px;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #f8fafc;
    min-width: 110px;
}

.feature:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 10px 40px rgba(139, 92, 246, 0.15);
}

.feature-icon {
    font-size: 36px;
    animation: bounce 2s ease-in-out infinite;
}

.feature:nth-child(2) .feature-icon {
    animation-delay: 0.3s;
}

.feature:nth-child(3) .feature-icon {
    animation-delay: 0.6s;
}

/* CTA Buttons - Glowing Dark Theme */
.cta-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.cta-buttons .btn {
    min-width: 180px;
    font-size: 16px;
    font-weight: 700;
    padding: 16px 28px;
    border-radius: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cta-buttons .btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    color: white;
    border: none;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
    animation: glow-pulse 3s ease-in-out infinite;
}

.cta-buttons .btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.6),
                0 10px 40px rgba(0, 0, 0, 0.3);
}

.cta-buttons .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.cta-buttons .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.2);
}

/* ============================================
   AUTH PAGES - Dark Theme Support
   ============================================ */

/* Base auth page - light theme default */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-fun);
    position: relative;
}

/* Dark theme auth page */
.auth-page.auth-dark {
    background: #0d0d12;
}

/* Colorful gradient auth page - matches homepage */
.auth-page.auth-colorful {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #ec4899 100%);
}

.auth-page.auth-colorful .auth-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-page.auth-colorful .auth-card::before {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.4),
        rgba(251, 191, 36, 0.6),
        rgba(255, 255, 255, 0.4));
}

.auth-page.auth-colorful .auth-card h1 {
    color: #fff;
}

.auth-page.auth-colorful .subtitle {
    color: rgba(255, 255, 255, 0.8);
}

.auth-page.auth-colorful .form-group label {
    color: rgba(255, 255, 255, 0.9);
}

.auth-page.auth-colorful .form-group input,
.auth-page.auth-colorful .form-group select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.auth-page.auth-colorful .form-group input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.auth-page.auth-colorful .form-group input:focus,
.auth-page.auth-colorful .form-group select:focus {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15),
                0 0 20px rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

.auth-page.auth-colorful .form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23ffffff' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    -webkit-appearance: none;
    appearance: none;
    padding-right: 40px;
}

.auth-page.auth-colorful .form-group select option {
    background: #764ba2;
    color: #fff;
}

.auth-page.auth-colorful .btn-primary {
    background: white;
    color: #7c3aed;
    font-weight: 800;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.auth-page.auth-colorful .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.auth-page.auth-colorful .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.auth-page.auth-colorful .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.auth-page.auth-colorful .back-link {
    color: rgba(255, 255, 255, 0.7);
}

.auth-page.auth-colorful .back-link:hover {
    color: #fff;
}

.auth-page.auth-colorful .auth-footer {
    color: rgba(255, 255, 255, 0.6);
}

.auth-page.auth-colorful .auth-footer a {
    color: rgba(255, 255, 255, 0.9);
}

.auth-page.auth-colorful .auth-footer a:hover {
    color: #fff;
}

.auth-page.auth-colorful .error-message {
    background: rgba(239, 68, 68, 0.2);
    border-left-color: #fca5a5;
    color: #fecaca;
}

.auth-page.auth-colorful .success-message {
    background: rgba(34, 197, 94, 0.2);
    border-left-color: #86efac;
    color: #bbf7d0;
}

/* Animated orbs for dark auth pages */
.auth-page.auth-dark .gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.auth-page.auth-dark .gradient-orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    animation: orb-float 15s ease-in-out infinite;
}

.auth-page.auth-dark .gradient-orb-2 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.25) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation: orb-float 20s ease-in-out infinite reverse;
}

/* Grid pattern for dark auth */
.auth-page.auth-dark::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

/* Auth card - light theme default */
.auth-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: card-enter 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), var(--accent-pink), var(--accent-orange));
}

/* Dark theme auth card - glassmorphic */
.auth-page.auth-dark .auth-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-page.auth-dark .auth-card::before {
    background: linear-gradient(90deg,
        rgba(139, 92, 246, 0.8),
        rgba(236, 72, 153, 0.8),
        rgba(6, 182, 212, 0.8));
}

.back-link {
    color: var(--text-light);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    transition: color 0.2s;
}

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

/* Dark theme back link */
.auth-page.auth-dark .back-link {
    color: #94a3b8;
}

.auth-page.auth-dark .back-link:hover {
    color: #a78bfa;
}

.auth-card h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text);
}

/* Dark theme heading */
.auth-page.auth-dark .auth-card h1 {
    color: #f8fafc;
}

.subtitle {
    color: var(--text-light);
    margin-bottom: 28px;
    font-size: 16px;
}

.auth-page.auth-dark .subtitle {
    color: #94a3b8;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}

.auth-page.auth-dark .form-group label {
    color: #cbd5e1;
}

.form-group input,
.form-group select {
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: 'Nunito', sans-serif;
    transition: all 0.3s;
    min-height: 52px;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Dark theme form inputs */
.auth-page.auth-dark .form-group input,
.auth-page.auth-dark .form-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

.auth-page.auth-dark .form-group input::placeholder {
    color: #64748b;
}

.auth-page.auth-dark .form-group input:focus,
.auth-page.auth-dark .form-group select:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3),
                0 0 20px rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.auth-page.auth-dark .form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    -webkit-appearance: none;
    appearance: none;
    padding-right: 40px;
}

.auth-page.auth-dark .form-group select option {
    background: #1a1a22;
    color: #f8fafc;
}

/* Dark theme button in forms */
.auth-page.auth-dark .btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}

.auth-page.auth-dark .btn-primary:hover {
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}

.auth-page.auth-dark .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

.auth-page.auth-dark .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(139, 92, 246, 0.5);
}

.error-message {
    background: var(--error-bg);
    color: var(--error);
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border-left: 4px solid var(--error);
    animation: shake 0.5s ease;
}

.success-message {
    background: var(--success-bg);
    color: #15803d;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border-left: 4px solid var(--success);
}

/* ============================================
   MODAL SYSTEM - Unified Popup/Dialog Styles
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    position: relative;
    max-width: 400px;
    width: 100%;
    animation: modal-slide-in 0.3s ease-out;
}

/* Compact modal variant for simple menus */
.modal-content.modal-compact {
    max-width: 320px;
    padding: 24px;
}

.modal-content.modal-compact h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

@keyframes modal-slide-in {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--text);
    background: var(--border);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* Settings Menu Options */
.settings-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--text);
    font-size: 15px;
    font-family: 'Nunito', sans-serif;
}

.settings-option:hover {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.settings-option-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.settings-option-text {
    flex: 1;
    font-weight: 600;
}

.settings-option-arrow {
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 700;
}

/* User Card Component */
.user-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.user-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: white;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.user-grade {
    font-size: 14px;
    color: var(--text-light);
}

/* Info Box Component */
.info-box {
    background: rgba(99, 102, 241, 0.1);
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.info-box-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.info-box-content {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

/* Loading & Empty States */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h2,
.empty-state h3 {
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 28px;
    color: var(--text-light);
    font-size: 15px;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: var(--accent-pink);
}

/* Dark theme auth footer */
.auth-page.auth-dark .auth-footer {
    color: #64748b;
}

.auth-page.auth-dark .auth-footer a {
    color: #a78bfa;
}

.auth-page.auth-dark .auth-footer a:hover {
    color: #c4b5fd;
}

/* Dark theme error/success messages */
.auth-page.auth-dark .error-message {
    background: rgba(239, 68, 68, 0.15);
    border-left-color: #ef4444;
    color: #fca5a5;
}

.auth-page.auth-dark .success-message {
    background: rgba(34, 197, 94, 0.15);
    border-left-color: #22c55e;
    color: #86efac;
}

/* ============================================
   DASHBOARD - Modern & Engaging (Light Theme)
   ============================================ */

.dashboard-page {
    min-height: 100vh;
    padding-bottom: 100px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #ec4899 100%);
}

/* Override text colors for gradient background */
.dashboard-page .section-header h2 {
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.dashboard-page .stat-label {
    color: rgba(255, 255, 255, 0.85);
}

.dashboard-page .section-header .section-icon {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Text overrides for gradient background pages */
.dashboard-page .loading,
.practice-page .loading,
.admin-page .loading {
    color: rgba(255, 255, 255, 0.7);
}

.dashboard-page .empty-state,
.practice-page .empty-state,
.admin-page .empty-state {
    color: rgba(255, 255, 255, 0.7);
}

.dashboard-page .empty-state h2,
.dashboard-page .empty-state h3,
.practice-page .empty-state h2,
.practice-page .empty-state h3,
.admin-page .empty-state h2,
.admin-page .empty-state h3 {
    color: #fff;
}

.dashboard-page .empty-state p,
.practice-page .empty-state p,
.admin-page .empty-state p {
    color: rgba(255, 255, 255, 0.75);
}

/* Override white backgrounds for gradient pages */
.dashboard-page .empty-state,
.practice-page .empty-state,
.admin-page .empty-state {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.dashboard-page .no-data,
.practice-page .no-data,
.admin-page .no-data {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    color: rgba(255, 255, 255, 0.75);
}

/* Admin page - matches dashboard gradient */
.admin-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #ec4899 100%);
}

.dashboard-header {
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.dashboard-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.dashboard-header h1 {
    font-size: 26px;
    font-weight: 800;
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.user-greeting {
    font-weight: 600;
    font-size: 15px;
}

.user-info .btn {
    background: rgba(255,255,255,0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.dashboard-content {
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
}

/* Stats Cards - Gamified Look */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 36px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: white;
    text-align: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.08);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.18);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card:nth-child(1)::before {
    background: linear-gradient(90deg, var(--primary), var(--accent-pink));
}

.stat-card:nth-child(2)::before {
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-yellow));
}

.stat-card:nth-child(3)::before {
    background: linear-gradient(90deg, var(--accent-cyan), var(--success));
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.stat-value {
    font-size: 42px;
    font-weight: 900;
    color: #fff;
    display: block;
    line-height: 1.1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.stat-card:nth-child(2) .stat-value {
    color: #fff;
}

.stat-card:nth-child(3) .stat-value {
    color: #fff;
}

.stat-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Topics Section */
.topics-section {
    margin-bottom: 36px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

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

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.topic-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.06);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.topic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent-pink));
    opacity: 0;
    transition: opacity 0.3s;
}

.topic-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.18);
}

.topic-card:hover::before {
    opacity: 1;
}

.topic-card h3 {
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 10px;
    color: #fff;
}

.topic-level {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    margin-bottom: 14px;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent-cyan));
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: rainbow-shift 2s linear infinite;
    background-size: 200% 100%;
}

.topic-stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
}

/* Action Section */
.action-section {
    text-align: center;
}

.action-section .btn-large {
    animation: pulse-glow 2s infinite;
}

.recommendation {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 15px;
    font-weight: 600;
}

.recommendation strong {
    color: #fff;
}

/* ============================================
   PRACTICE PAGE - Modern & Focused
   ============================================ */

.practice-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #ec4899 100%);
}

.practice-header {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-wrap: wrap;
    gap: 12px;
    color: white;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topic-name {
    font-weight: 800;
    font-size: 16px;
    color: #fff;
}

.level-badge {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
    color: white;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

.session-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
}

.session-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.streak-badge {
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-yellow));
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    animation: bounce 1s ease-in-out infinite;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* Topic Selection */
.topic-selection-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.topics-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 450px;
}

.topic-btn {
    padding: 20px 28px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    font-size: 17px;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    color: #fff;
}

.topic-btn::before {
    content: '📚';
    font-size: 24px;
}

.topic-btn:nth-child(2)::before { content: '🔢'; }
.topic-btn:nth-child(3)::before { content: '📐'; }
.topic-btn:nth-child(4)::before { content: '📊'; }
.topic-btn:nth-child(5)::before { content: '🧮'; }
.topic-btn:nth-child(6)::before { content: '📈'; }

.topic-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(8px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* Level Selection Screen */
.level-selection-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.level-selection-topic {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    font-weight: 600;
}

.level-selection-topic span {
    color: #fff;
    font-weight: 800;
}

.level-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 24px;
}

/* Adaptive option - make it stand out */
.level-btn[data-level="adaptive"] {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
}

.level-btn[data-level="adaptive"]:hover {
    background: rgba(34, 197, 94, 0.3);
}

.level-btn[data-level="adaptive"].selected {
    background: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.level-btn[data-level="adaptive"] .level-name {
    color: #86efac;
}

.level-btn[data-level="adaptive"] .level-desc {
    color: rgba(134, 239, 172, 0.8);
}

.level-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    min-height: 60px;
    position: relative;
    color: #fff;
}

.level-btn:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.level-btn.selected {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.level-btn.selected .level-name {
    color: #fff;
}

.level-icon {
    font-size: 18px;
    min-width: 70px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 4px;
    border-radius: 10px;
    letter-spacing: -2px;
}

.level-btn[data-level="adaptive"] .level-icon {
    background: rgba(34, 197, 94, 0.15);
    letter-spacing: 0;
}

.level-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.level-name {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
}

.level-desc {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

/* Current level info display */
.current-level-info {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

/* Mark user's current level button */
.level-btn.current-level {
    border-color: var(--success);
    position: relative;
}

.level-btn.current-level::after {
    content: 'Your level';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: white;
    background: var(--success);
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-weight: 700;
}

/* Question Screen */
.question-container {
    width: 100%;
    max-width: 650px;
    text-align: center;
    animation: slide-up 0.5s ease-out;
}

.question-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 13px;
}

.source-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-gsm8k {
    background: #dbeafe;
    color: #1e40af;
}

.source-deepmind {
    background: #fce7f3;
    color: #9d174d;
}

.source-manual {
    background: #d1fae5;
    color: #065f46;
}

.source-template {
    background: #fef3c7;
    color: #92400e;
}

.subtopic-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 600;
}

.question-text {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.7;
    margin-bottom: 32px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.question-text::before {
    content: '🤔';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    animation: bounce 2s ease-in-out infinite;
}

/* Multiple Choice Options */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 28px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    min-height: 64px;
    color: #fff;
}

@media (hover: hover) {
    .option-btn:hover {
        border-color: rgba(255, 255, 255, 0.4);
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.02);
    }
}

.option-btn:active {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
}

.option-btn.selected {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.option-btn.correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.25);
    color: #fff;
    animation: bounce-in 0.5s ease;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.3);
}

.option-btn.incorrect {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.25);
    color: #fff;
    animation: shake 0.5s ease;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
}

.option-letter {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    font-weight: 800;
    font-size: 18px;
    flex-shrink: 0;
    transition: all 0.3s;
    color: #fff;
}

.option-btn.selected .option-letter {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
    color: white;
    transform: scale(1.1);
}

.option-text {
    flex: 1;
}

/* Numeric Input */
.numeric-input {
    margin-bottom: 28px;
}

.numeric-input input {
    width: 100%;
    max-width: 320px;
    padding: 20px;
    font-size: 28px;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    text-align: center;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-lg);
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
}

.numeric-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.numeric-input input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.15);
}

/* Hints */
.hint-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.hint-penalty {
    font-size: 14px;
    font-weight: 700;
    color: var(--warning);
    background: var(--warning-bg);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.hint-penalty:empty {
    display: none;
}

.hint-display {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid var(--warning);
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    text-align: left;
    font-weight: 600;
    font-size: 15px;
    animation: slide-up 0.3s ease-out;
}

.hint-display::before {
    content: '💡 ';
    font-size: 18px;
}

/* ============================================
   RESULT SCREEN - Celebratory!
   ============================================ */

.result-container {
    text-align: center;
    max-width: 500px;
    animation: bounce-in 0.5s ease-out;
}

.result-icon {
    font-size: 80px;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto 28px;
    position: relative;
}

.result-icon.correct {
    background: linear-gradient(135deg, var(--success-light) 0%, var(--success-bg) 100%);
    color: var(--success);
    animation: bounce 0.6s ease;
}

.result-icon.incorrect {
    background: linear-gradient(135deg, var(--error-light) 0%, var(--error-bg) 100%);
    color: var(--error);
}

/* Sparkles around correct answer */
.result-icon.correct::before,
.result-icon.correct::after {
    content: '✨';
    position: absolute;
    font-size: 30px;
    animation: sparkle 1s ease infinite;
}

.result-icon.correct::before {
    top: -10px;
    left: -10px;
    animation-delay: 0.2s;
}

.result-icon.correct::after {
    bottom: -10px;
    right: -10px;
    animation-delay: 0.5s;
}

.result-container h2 {
    font-size: 36px;
    font-weight: 900;
    margin-bottom: 12px;
}

.result-container h2.correct-text {
    color: var(--success);
}

.result-container h2.incorrect-text {
    color: var(--error);
}

.encouragement {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 24px;
}

.result-details {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    text-align: left;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    color: #fff;
}

.result-details p {
    margin-bottom: 10px;
    font-size: 15px;
}

.result-details p:empty {
    display: none;
}

#userAnswer:not(:empty),
#guest-user-answer:not(:empty) {
    background: rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--error);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #fca5a5;
}

#userAnswer:not(:empty)::before,
#guest-user-answer:not(:empty)::before {
    content: '✗ ';
    font-weight: 700;
}

#correctAnswer:not(:empty),
#guest-correct-answer:not(:empty) {
    background: rgba(34, 197, 94, 0.15);
    border-left: 4px solid var(--success);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #86efac;
}

#correctAnswer:not(:empty)::before,
#guest-correct-answer:not(:empty)::before {
    content: '✓ ';
    font-weight: 700;
}

#explanation:not(:empty),
#guest-explanation:not(:empty) {
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-left: 4px solid var(--primary);
    padding: 16px 20px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
    margin-top: 16px;
}

#explanation:not(:empty)::before,
#guest-explanation:not(:empty)::before {
    content: '💡 Explanation: ';
    font-weight: 700;
    color: var(--accent-cyan);
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
}

.result-details strong {
    color: var(--primary);
}

.points-earned {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
    color: white;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    animation: bounce 0.6s ease;
}

.points-earned::before {
    content: '⭐';
    font-size: 28px;
}

.level-change {
    padding: 14px 28px;
    border-radius: var(--radius-lg);
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 28px;
    display: inline-block;
}

.level-change.up {
    background: linear-gradient(135deg, var(--success-bg) 0%, #bbf7d0 100%);
    color: var(--success);
    animation: bounce-in 0.5s ease;
}

.level-change.up::before {
    content: '🚀 ';
}

.level-change.down {
    background: var(--error-bg);
    color: var(--error);
}

.level-change.down::before {
    content: '📚 ';
}

/* ============================================
   SUMMARY SCREEN - Achievement Unlocked Feel
   ============================================ */

.summary-container {
    text-align: center;
    max-width: 500px;
    animation: slide-up 0.5s ease-out;
}

.summary-container h2 {
    font-size: 36px;
    font-weight: 900;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-pink) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.summary-container h2::before {
    content: '🎉 ';
    -webkit-text-fill-color: initial;
}

.summary-container h2::after {
    content: ' 🎉';
    -webkit-text-fill-color: initial;
}

.summary-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    margin-bottom: 32px;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 36px;
}

.summary-stat {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 28px 20px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.summary-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.summary-stat:nth-child(1)::before {
    background: linear-gradient(90deg, var(--success), var(--accent-cyan));
}

.summary-stat:nth-child(2)::before {
    background: linear-gradient(90deg, var(--primary), var(--accent-pink));
}

.summary-stat:nth-child(3)::before {
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-yellow));
}

.summary-stat-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.summary-value {
    font-size: 48px;
    font-weight: 900;
    display: block;
    line-height: 1.1;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.summary-stat:nth-child(1) .summary-value {
    color: #86efac;
}

.summary-stat:nth-child(2) .summary-value {
    color: #fff;
}

.summary-stat:nth-child(3) .summary-value {
    color: #fbbf24;
}

.summary-label {
    font-size: 14px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ============================================
   CONFETTI ANIMATION
   ============================================ */

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    animation: confetti-fall 3s linear forwards;
}

.confetti:nth-child(odd) {
    background: var(--primary);
    border-radius: 50%;
}

.confetti:nth-child(even) {
    background: var(--accent-pink);
    border-radius: 2px;
}

.confetti:nth-child(3n) {
    background: var(--accent-yellow);
}

.confetti:nth-child(4n) {
    background: var(--accent-cyan);
}

.confetti:nth-child(5n) {
    background: var(--success);
}

/* ============================================
   UTILITIES
   ============================================ */

.loading {
    color: var(--text-light);
    text-align: center;
    padding: 40px;
    font-weight: 600;
}

.loading::before {
    content: '⏳ ';
    animation: bounce 1s infinite;
    display: inline-block;
}

.no-data {
    color: var(--text-light);
    text-align: center;
    padding: 40px;
    font-weight: 600;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.no-data::before {
    content: '📝 ';
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
}

.error {
    color: var(--error);
    text-align: center;
    padding: 24px;
    background: var(--error-bg);
    border-radius: var(--radius-lg);
    font-weight: 600;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

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

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

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

    .logo {
        font-size: 36px;
    }

    .features {
        gap: 16px;
    }

    .feature {
        padding: 16px 20px;
    }

    .cta-buttons {
        flex-direction: column;
    }

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

    .question-text {
        font-size: 17px;
        padding: 18px;
        line-height: 1.5;
        margin-bottom: 20px;
    }

    .question-text::before {
        font-size: 28px;
        top: -14px;
    }

    .stat-value {
        font-size: 36px;
    }

    .summary-value {
        font-size: 40px;
    }

    .result-icon {
        width: 120px;
        height: 120px;
        font-size: 64px;
    }

    .practice-header {
        padding: 12px 16px;
    }

    .session-stats {
        gap: 12px;
        font-size: 13px;
    }

    /* Screen container mobile */
    .screen {
        padding: 16px;
        justify-content: flex-start;
        padding-top: 24px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Result screen mobile */
    .result-container {
        padding: 0 12px;
    }

    .result-container h2 {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .encouragement {
        font-size: 15px;
        margin-bottom: 16px;
    }

    .result-details {
        padding: 14px;
        margin-bottom: 16px;
        border-radius: 16px;
    }

    #userAnswer:not(:empty),
    #correctAnswer:not(:empty),
    #guest-user-answer:not(:empty),
    #guest-correct-answer:not(:empty) {
        padding: 10px 12px;
        font-size: 14px;
        margin-bottom: 10px;
        border-radius: 6px;
    }

    #explanation:not(:empty),
    #guest-explanation:not(:empty) {
        padding: 12px 14px;
        font-size: 13px;
        line-height: 1.6;
        margin-top: 12px;
        border-radius: 6px;
    }

    #explanation:not(:empty)::before,
    #guest-explanation:not(:empty)::before {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .points-earned {
        font-size: 22px;
        padding: 8px 18px;
        margin-bottom: 16px;
    }

    .points-earned::before {
        font-size: 20px;
    }

    .level-change {
        font-size: 14px;
        padding: 10px 20px;
        margin-bottom: 16px;
    }

    #nextBtn {
        width: 100%;
        padding: 14px 24px;
        font-size: 16px;
    }

    /* Landing page mobile */
    .landing-page .hero {
        padding: 20px;
    }

    .logo {
        font-size: 42px;
    }

    .tagline {
        font-size: 16px;
        padding: 0 10px;
    }

    .mascot {
        width: 100px;
        height: 100px;
    }

    .hero-footer {
        font-size: 13px;
    }

    /* Auth pages mobile */
    .auth-page {
        padding: 16px;
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .auth-card h1 {
        font-size: 26px;
    }

    .subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .auth-form {
        gap: 16px;
    }

    .form-group input,
    .form-group select {
        padding: 12px 14px;
        font-size: 16px;
        min-height: 48px;
    }

    .form-group label {
        font-size: 13px;
    }

    .auth-footer {
        font-size: 14px;
        margin-top: 20px;
    }

    .back-link {
        font-size: 14px;
        margin-bottom: 16px;
    }

    /* Modal mobile */
    .modal-overlay {
        padding: 16px;
    }

    .modal-content.modal-compact {
        padding: 20px;
        max-width: 100%;
    }

    .modal-content.modal-compact h2 {
        font-size: 18px;
        padding-right: 32px;
    }

    .settings-option {
        padding: 12px 14px;
        font-size: 14px;
    }

    .settings-option-icon {
        font-size: 18px;
        width: 24px;
    }

    .modal-close {
        top: 12px;
        right: 12px;
    }

    /* Dashboard mobile */
    .dashboard-header {
        padding: 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .dashboard-header h1 {
        font-size: 24px;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .user-greeting {
        font-size: 14px;
    }

    .dashboard-content {
        padding: 16px;
    }

    .stats-overview {
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        border-radius: 16px;
    }

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

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

    /* Topics grid mobile */
    .topics-grid {
        gap: 12px;
    }

    .topic-card {
        padding: 16px;
        border-radius: 16px;
    }

    .topic-card h3 {
        font-size: 15px;
    }

    .topic-level {
        font-size: 13px;
    }

    .topic-stats {
        font-size: 12px;
        gap: 12px;
    }

    .section-header h2 {
        font-size: 20px;
    }

    .action-section {
        padding: 20px 0;
    }

    .recommendation {
        font-size: 14px;
    }

    /* Level selection mobile */
    .level-selection-title {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .level-selection-topic {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .current-level-info {
        font-size: 13px;
        padding: 6px 12px;
        margin-bottom: 12px;
    }

    .level-options {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 20px;
        width: 100%;
        padding: 0 4px;
    }

    .level-btn {
        display: flex;
        flex-direction: row;
        align-items: center;
        width: 100%;
        padding: 12px 14px;
        border-radius: 14px;
        min-height: 54px;
        gap: 12px;
        box-sizing: border-box;
    }

    .level-icon {
        font-size: 14px;
        min-width: 55px;
        max-width: 55px;
        padding: 6px 2px;
        border-radius: 8px;
        letter-spacing: -3px;
        flex-shrink: 0;
    }

    .level-btn[data-level="adaptive"] .level-icon {
        letter-spacing: 0;
    }

    .level-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .level-name {
        font-size: 14px;
    }

    .level-desc {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #startWithLevelBtn {
        width: 100%;
        margin-top: 12px;
        padding: 14px 20px;
    }

    /* Topic selection mobile */
    .topic-selection-title {
        font-size: 22px;
    }

    .topic-btn {
        padding: 14px 18px;
        font-size: 15px;
    }

    /* Question screen mobile */
    .hint-section {
        flex-direction: column;
        gap: 10px;
    }

    .btn-hint {
        width: 100%;
    }

    .hint-penalty {
        text-align: center;
    }

    .hint-display {
        font-size: 14px;
        padding: 14px;
        margin-bottom: 16px;
    }

    #submitBtn {
        width: 100%;
        position: sticky;
        bottom: 0;
        z-index: 10;
        box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.2);
    }

    .option-btn {
        padding: 14px 16px;
    }

    .option-letter {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .option-text {
        font-size: 15px;
    }

    /* Summary screen mobile */
    .summary-container {
        padding: 20px;
    }

    .summary-container h2 {
        font-size: 26px;
    }

    .summary-subtitle {
        font-size: 15px;
    }

    .summary-stats {
        gap: 16px;
    }

    .summary-stat {
        padding: 16px;
    }

    .summary-stat-icon {
        font-size: 28px;
    }

    .summary-label {
        font-size: 12px;
    }

    .summary-actions {
        flex-direction: column;
        gap: 12px;
    }

    .summary-actions .btn {
        width: 100%;
    }

    /* Achievement popup mobile */
    .achievement-popup {
        top: 10px;
        right: 10px;
        left: 10px;
        padding: 14px 16px;
    }

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

    .achievement-popup h3 {
        font-size: 14px;
    }

    .achievement-popup p {
        font-size: 12px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .dashboard-content {
        padding: 32px;
    }

    .question-text {
        font-size: 26px;
    }
}

/* ============================================
   RACE MODE - Space Theme
   ============================================ */

/* Race Section Container */
.race-section {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 36px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(124, 58, 237, 0.2);
}

.race-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, white, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 400px 60px, white, transparent),
        radial-gradient(2px 2px at 500px 100px, rgba(255,255,255,0.8), transparent);
    background-size: 550px 200px;
    animation: twinkle 4s ease-in-out infinite;
    pointer-events: none;
}

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

.race-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.race-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-size: 22px;
    font-weight: 800;
}

.race-section-title .rocket-icon {
    font-size: 28px;
    animation: float 3s ease-in-out infinite;
}

/* Race Connection Status Banner */
.race-connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(249, 115, 22, 0.95));
    border-radius: var(--radius);
    color: white;
    font-size: 13px;
    font-weight: 600;
    position: relative;
    z-index: 2;
}

.race-connection-status.hidden {
    display: none;
}

.race-connection-icon {
    font-size: 16px;
}

.race-connection-text {
    flex: 1;
}

/* Race Entry State */
.race-entry {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.race-entry .btn {
    min-width: 160px;
}

.race-join-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.race-join-input input {
    width: 120px;
    padding: 14px 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    font-family: 'Nunito', sans-serif;
    letter-spacing: 2px;
}

.race-join-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0;
    text-transform: none;
}

.race-join-input input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.15);
}

/* Race Setup Modal */
.race-setup {
    position: relative;
    z-index: 1;
    text-align: center;
}

.race-setup-title {
    color: white;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.race-setup-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 500px;
    margin: 0 auto;
}

.race-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.race-field-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
}

.race-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.race-chip {
    padding: 10px 18px;
    min-height: 44px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.race-chip:hover {
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.18);
    transform: scale(1.05);
}

.race-chip.selected {
    background: rgba(124, 58, 237, 0.3);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.race-pill-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.race-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    min-height: 44px;
    padding: 8px 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: white;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 2px;
}

.race-pill span {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.race-pill:hover {
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.18);
    transform: scale(1.05);
}

.race-pill.selected {
    background: rgba(124, 58, 237, 0.3);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.race-setup-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Race Lobby State */
.race-lobby {
    position: relative;
    z-index: 1;
}

.race-room-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.race-room-code {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 4px;
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
}

.race-room-topic {
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.race-room-topic-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.race-room-topic-label {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}

.race-topic-chip {
    background: rgba(124, 58, 237, 0.25);
    border: 1px solid rgba(124, 58, 237, 0.5);
    color: #f3e8ff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.race-room-level {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #bbf7d0;
    font-size: 13px;
    font-weight: 700;
}

.race-participants-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    justify-content: center;
}

.race-participant {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 16px;
    border-radius: var(--radius-full);
    color: white;
    font-weight: 600;
}

.race-participant-rocket {
    font-size: 20px;
}

.race-participant.is-me {
    background: rgba(124, 58, 237, 0.4);
    border: 2px solid var(--primary);
}

.race-lobby-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.race-next-countdown {
    color: var(--accent-yellow);
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    animation: pulse-glow 1s infinite;
}

/* Race Countdown Overlay */
.race-countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 2000;
}

.race-countdown-number {
    font-size: 180px;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 60px var(--accent-cyan), 0 0 120px var(--primary);
    animation: countdown-pulse 1s ease-in-out;
}

.race-countdown-text {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-yellow);
    margin-top: 20px;
}

@keyframes countdown-pulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Race Active State - Track */
.race-active {
    position: relative;
    z-index: 1;
}

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.race-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid var(--error);
    padding: 8px 20px;
    border-radius: var(--radius-full);
    color: white;
    font-size: 24px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.race-timer.warning {
    animation: pulse-glow 0.5s infinite;
    background: rgba(239, 68, 68, 0.4);
}

.race-my-score {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    color: white;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-size: 20px;
    font-weight: 800;
}

/* Race Track */
.race-track {
    background: linear-gradient(180deg, #0a0a1a 0%, #1a1a3a 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.race-track-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 700;
}

.race-track-start {
    display: flex;
    align-items: center;
    gap: 6px;
}

.race-track-finish {
    display: flex;
    align-items: center;
    gap: 6px;
}

.race-lanes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.race-lane {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.race-lane-name {
    width: 80px;
    color: white;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.race-lane-track {
    flex: 1;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
    position: relative;
    overflow: hidden;
}

.race-lane-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.1) 0px,
        rgba(255, 255, 255, 0.1) 10px,
        transparent 10px,
        transparent 20px
    );
    transform: translateY(-50%);
}

.race-rocket {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 10px currentColor);
    z-index: 1;
}

.race-rocket.boosting {
    animation: rocket-boost 0.3s ease;
}

@keyframes rocket-boost {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.3); }
    100% { transform: translateY(-50%) scale(1); }
}

.race-lane-score {
    width: 60px;
    text-align: right;
    color: var(--accent-yellow);
    font-size: 16px;
    font-weight: 800;
}

.race-rank-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 16px;
}

/* Race Question Area */
.race-question-area {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.race-question-number {
    color: var(--accent-cyan);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.race-question-text {
    color: white;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.6;
}

.race-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.race-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.12);
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
}

@media (hover: hover) {
    .race-option-btn:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: var(--accent-cyan);
        box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
        transform: translateY(-1px);
    }
}

.race-option-btn:active {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
    transform: translateY(-1px);
}

.race-option-btn.selected {
    background: rgba(124, 58, 237, 0.32);
    border-color: #a78bfa;
    box-shadow: 0 0 22px rgba(124, 58, 237, 0.45);
}

.race-option-btn.correct {
    background: rgba(34, 197, 94, 0.28);
    border-color: #4ade80;
    box-shadow: 0 0 22px rgba(34, 197, 94, 0.45);
    animation: correct-flash 0.5s ease;
}

.race-option-btn.incorrect {
    background: rgba(239, 68, 68, 0.28);
    border-color: #f87171;
    box-shadow: 0 0 22px rgba(239, 68, 68, 0.45);
    animation: shake 0.5s ease;
}

@keyframes correct-flash {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 30px var(--success); }
}

.race-option-letter {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-weight: 800;
    flex-shrink: 0;
}

.race-numeric-input {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.race-numeric-input input {
    width: 200px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius);
    color: white;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    font-family: 'Nunito', sans-serif;
}

.race-numeric-input input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* Race Action Bar - Unified Button Layout */
.race-action-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

/* Base unified button style */
.race-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1.5px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.35);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.15);
    min-width: 100px;
    justify-content: center;
}

.race-action-btn .btn-icon {
    font-size: 16px;
}

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

/* Hint buttons - Yellow */
.race-action-btn.hint {
    background: rgba(251, 191, 36, 0.18);
    border-color: #fbbf24;
    color: #fde68a;
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
}

.race-action-btn.hint:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.28);
}

/* Skip button - Orange/Brown */
.race-action-btn.skip {
    background: rgba(249, 115, 22, 0.18);
    border-color: #b4783c;
    color: #fdba74;
    box-shadow: 0 0 18px rgba(249, 115, 22, 0.35);
}

.race-action-btn.skip:hover:not(:disabled) {
    background: rgba(249, 115, 22, 0.28);
}

.race-action-btn.skip:disabled {
    opacity: 0.4;
}

/* Skipped button - Purple */
.race-action-btn.skipped {
    background: rgba(139, 92, 246, 0.22);
    border-color: #8b5cf6;
    color: #ddd6fe;
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.4);
}

.race-action-btn.skipped:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.3);
}

/* Resume button - Green */
.race-action-btn.resume {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
    color: #4ade80;
}

.race-action-btn.resume:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.35);
}

.race-hint-penalty {
    display: block;
    text-align: center;
    color: var(--accent-orange);
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
}

/* Legacy hint section - keep for compatibility */
.race-hint-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.race-hint-btn {
    background: rgba(251, 191, 36, 0.2);
    border: 2px solid var(--accent-yellow);
    color: var(--accent-yellow);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.race-hint-btn:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.3);
}

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

.race-hint-display {
    background: rgba(251, 191, 36, 0.15);
    border: 2px solid var(--accent-yellow);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    color: white;
    font-size: 15px;
    line-height: 1.6;
}

/* Wrong Answer Penalty Warning */
.penalty-warning {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(239, 68, 68, 0.15);
    border: 2px solid #ef4444;
    border-radius: var(--radius);
    padding: 10px 16px;
    color: #ef4444;
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
}

#wrongCount {
    font-weight: 900;
}

#penaltyPoints {
    color: #ff6b6b;
    font-weight: 900;
    font-size: 16px;
}

/* Race Results */
.race-results {
    position: relative;
    z-index: 1;
    text-align: center;
}

.race-results-title {
    color: white;
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 24px;
    text-shadow: 0 0 30px var(--accent-cyan);
}

.race-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
}

.race-podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius-lg);
    min-width: 100px;
}

.race-podium-place.first {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    order: 2;
    padding-bottom: 40px;
}

.race-podium-place.second {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    order: 1;
    padding-bottom: 24px;
}

.race-podium-place.third {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    order: 3;
    padding-bottom: 16px;
}

.race-podium-medal {
    font-size: 40px;
    margin-bottom: 8px;
}

.race-podium-name {
    color: white;
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 4px;
}

.race-podium-score {
    color: rgba(255, 255, 255, 0.9);
    font-size: 20px;
    font-weight: 900;
}

.race-full-results {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.race-result-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    color: white;
}

.race-result-row:last-child {
    margin-bottom: 0;
}

.race-result-row.is-me {
    background: rgba(124, 58, 237, 0.3);
    border: 2px solid var(--primary);
}

.race-result-rank {
    width: 40px;
    font-size: 18px;
    font-weight: 900;
}

.race-result-name {
    flex: 1;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.race-result-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.race-result-score {
    font-weight: 900;
    color: var(--accent-yellow);
    font-size: 18px;
}

.race-next-race-info {
    color: var(--accent-cyan);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Race Primary Buttons */
.race-page .btn {
    border-radius: 999px;
    border: 1.5px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.35);
    color: #f8fafc;
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.18);
}

.race-page .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
}

.race-page .btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
    border: 1.5px solid rgba(236, 72, 153, 0.6);
    box-shadow: 0 0 24px rgba(124, 58, 237, 0.45);
}

.race-page .btn-primary:hover {
    box-shadow: 0 0 32px rgba(124, 58, 237, 0.65);
}

/* Race Leave Button */
.race-leave-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1.5px solid #ef4444;
    color: #fecaca;
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.35);
}

.race-leave-btn:hover {
    background: rgba(239, 68, 68, 0.28);
    box-shadow: 0 0 22px rgba(239, 68, 68, 0.5);
}

/* Floating Points Animation */
.floating-points {
    position: fixed;
    font-size: 32px;
    font-weight: 900;
    color: var(--success);
    text-shadow: 0 0 20px var(--success);
    pointer-events: none;
    z-index: 3000;
    animation: points-float 1s ease-out forwards;
}

.floating-points.negative {
    color: #ef4444;
    text-shadow: 0 0 20px #ef4444;
}

/* Star Burst Effect */
.star-burst {
    position: fixed;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 2999;
}

.star-burst::before {
    content: '⭐';
    position: absolute;
    font-size: 24px;
    animation: star-burst 0.6s ease-out forwards;
}

@keyframes star-burst {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    100% { transform: scale(2) rotate(180deg); opacity: 0; }
}

/* Race Toast Notification (for practice page) */
.race-toast-notification {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(124, 58, 237, 0.3);
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 360px;
}

.race-toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.race-toast-content {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.race-toast-icon {
    font-size: 32px;
    animation: float 2s ease-in-out infinite;
}

.race-toast-text {
    flex: 1;
    min-width: 150px;
    color: white;
    font-size: 15px;
    font-weight: 600;
}

.race-toast-text strong {
    color: var(--accent-cyan);
}

.race-toast-topic {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.race-toast-actions {
    display: flex;
    gap: 8px;
}

.race-toast-join {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.race-toast-join:hover {
    transform: scale(1.05);
}

.race-toast-dismiss {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.race-toast-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Race Mode Mobile Responsiveness */
@media (max-width: 600px) {
    .race-section {
        padding: 16px;
        margin-bottom: 24px;
    }

    .race-section-title {
        font-size: 18px;
    }

    .race-entry {
        flex-direction: column;
        align-items: center;
    }

    .race-entry .btn {
        width: 100%;
    }

    .race-join-input {
        width: 100%;
        flex-direction: column;
    }

    .race-join-input input {
        width: 100%;
    }

    .race-room-code {
        font-size: 20px;
        padding: 10px 18px;
    }

    .race-track {
        padding: 12px;
    }

    .race-lane-name {
        width: 60px;
        font-size: 12px;
    }

    .race-rocket {
        font-size: 22px;
    }

    .race-lane-score {
        width: 50px;
        font-size: 14px;
    }

    .race-options {
        grid-template-columns: 1fr;
    }

    .race-option-btn {
        padding: 14px 16px;
        font-size: 15px;
    }

    .race-timer {
        font-size: 20px;
        padding: 6px 14px;
    }

    .race-question-text {
        font-size: 17px;
    }

    .race-podium {
        flex-direction: column;
        align-items: center;
    }

    .race-podium-place {
        width: 100%;
        max-width: 200px;
        order: unset !important;
    }

    .race-podium-place.first {
        padding-bottom: 16px;
    }

    .race-result-stats {
        gap: 12px;
        font-size: 12px;
    }

    .race-toast-notification {
        left: 10px;
        right: 10px;
        bottom: 90px;
        max-width: none;
    }

    .race-countdown-number {
        font-size: 120px;
    }

    .race-countdown-text {
        font-size: 24px;
    }
}

/* ============================================
   RACE MODE UI/UX ENHANCEMENTS
   ============================================ */

/* Wobble animation (gentler than shake for wrong answers) */
@keyframes wobble {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.race-option-btn.incorrect {
    animation: wobble 0.4s ease;
}

/* Rocket trail effect */
.race-rocket::after {
    content: '✨';
    position: absolute;
    left: -20px;
    opacity: 0;
    animation: trail-fade 0.3s ease-out;
}

.race-rocket.moving::after {
    opacity: 0.7;
}

@keyframes trail-fade {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-10px); }
}

/* Rocket initial (accessibility - player initials on rockets) */
.rocket-initial {
    position: absolute;
    left: -18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 900;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Distance markers on race track */
.race-lane-track::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 25%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 25% 0 0 rgba(255, 255, 255, 0.1), 50% 0 0 rgba(255, 255, 255, 0.1);
}

/* Race Entry - Clean Two Button Design */
.race-entry-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.race-entry-buttons .btn {
    min-width: 150px;
}

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

/* Active Race Banner */
.race-active-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(124, 58, 237, 0.2));
    border: 2px solid var(--accent-cyan);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    animation: banner-glow 2s ease-in-out infinite;
}

@keyframes banner-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(6, 182, 212, 0.2); }
    50% { box-shadow: 0 0 30px rgba(6, 182, 212, 0.4); }
}

.race-active-icon {
    font-size: 32px;
    animation: float 2s ease-in-out infinite;
}

.race-active-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.race-active-who {
    color: white;
    font-size: 16px;
    font-weight: 800;
}

.race-active-details {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 600;
}

.race-no-active {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    padding: 12px;
}

/* Touch target size fixes */
.race-hint-btn {
    padding: 12px 20px;
    min-height: 48px;
}

.race-toast-dismiss {
    width: 44px;
    height: 44px;
}

.race-join-input input {
    height: 56px;
}

/* Emotional Feedback Styles */
.race-praise-message {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    font-weight: 900;
    color: var(--accent-yellow);
    text-shadow: 0 0 20px var(--accent-yellow), 0 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 3001;
    animation: praise-pop 1.2s ease-out forwards;
}

@keyframes praise-pop {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    20% { transform: translateX(-50%) scale(1.3); opacity: 1; }
    40% { transform: translateX(-50%) scale(1); }
    100% { transform: translateX(-50%) scale(1); opacity: 0; }
}

.race-streak-indicator {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-yellow));
    color: white;
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-size: 20px;
    font-weight: 900;
    pointer-events: none;
    z-index: 3002;
    animation: streak-pulse 2s ease-out forwards;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.5);
}

@keyframes streak-pulse {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    20% { transform: translateX(-50%) scale(1.2); opacity: 1; }
    30% { transform: translateX(-50%) scale(1); }
    80% { transform: translateX(-50%) scale(1); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 0; }
}

.race-encourage-message {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px 28px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 700;
    pointer-events: none;
    z-index: 3000;
    animation: encourage-fade 2.5s ease-out forwards;
    max-width: 90%;
    text-align: center;
    border: 2px solid var(--accent-cyan);
}

@keyframes encourage-fade {
    0% { transform: translateX(-50%) translateY(20px); opacity: 0; }
    15% { transform: translateX(-50%) translateY(0); opacity: 1; }
    80% { transform: translateX(-50%) translateY(0); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-10px); opacity: 0; }
}

/* First-Time Tutorial Overlay */
.race-tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.race-tutorial-modal {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(124, 58, 237, 0.3);
    position: relative;
    overflow: hidden;
}

.race-tutorial-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent);
    background-size: 200px 150px;
    opacity: 0.3;
    pointer-events: none;
}

.race-tutorial-slide {
    display: none;
    animation: slide-up 0.4s ease;
}

.race-tutorial-slide.active {
    display: block;
}

.race-tutorial-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.race-tutorial-modal h3 {
    color: white;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
}

.race-tutorial-modal p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    line-height: 1.6;
}

.race-tutorial-nav {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.race-tutorial-dots {
    display: flex;
    gap: 10px;
}

.race-tutorial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.race-tutorial-dot.active {
    background: var(--accent-cyan);
    transform: scale(1.3);
}

.race-tutorial-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

.race-tutorial-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: var(--radius-full);
    font-size: 16px;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: transform 0.2s;
    min-width: 150px;
}

.race-tutorial-btn:hover {
    transform: scale(1.05);
}

/* "Don't show again" checkbox label for tutorial popups */
.dont-show-again-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.dont-show-again-label:hover {
    opacity: 1;
}

.dont-show-again-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

/* Dark theme variant (for race tutorial) */
.race-tutorial-nav .dont-show-again-label {
    color: rgba(255, 255, 255, 0.7);
}

.race-tutorial-nav .dont-show-again-label:hover {
    color: rgba(255, 255, 255, 0.95);
}

/* Light theme variant (for dashboard onboarding - now also dark gradient) */
.onboarding-nav .dont-show-again-label {
    color: rgba(255, 255, 255, 0.7);
}

.onboarding-nav .dont-show-again-label:hover {
    color: rgba(255, 255, 255, 0.95);
}

/* Race Track Visual Enhancements */
.race-track {
    position: relative;
}

/* Animated star field background */
.race-track::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 50% 30%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 70% 70%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.6), transparent);
    animation: stars-move 20s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes stars-move {
    from { background-position: 0 0; }
    to { background-position: -100px 0; }
}

/* Distance markers */
.race-track-markers {
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 80px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* Enhanced rocket glow for leader */
.race-lane:first-child .race-rocket {
    filter: drop-shadow(0 0 15px gold) drop-shadow(0 0 30px gold);
}

/* Rocket tilt animation when moving */
@keyframes rocket-tilt {
    0% { transform: translateY(-50%) rotate(0deg); }
    50% { transform: translateY(-50%) rotate(15deg); }
    100% { transform: translateY(-50%) rotate(0deg); }
}

.race-rocket.boosting {
    animation: rocket-tilt 0.3s ease, rocket-boost 0.3s ease;
}

/* Mobile responsive for new elements */
@media (max-width: 600px) {
    .race-entry-buttons {
        flex-direction: column;
    }

    .race-entry-buttons .btn {
        width: 100%;
    }

    .race-active-banner {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .race-active-text {
        align-items: center;
    }

    .race-tutorial-modal {
        padding: 28px;
    }

    .race-tutorial-icon {
        font-size: 48px;
    }

    .race-tutorial-modal h3 {
        font-size: 20px;
    }

    .race-tutorial-modal p {
        font-size: 14px;
    }

    .race-praise-message {
        font-size: 22px;
    }

    .race-streak-indicator {
        font-size: 16px;
        padding: 8px 18px;
    }

    .race-encourage-message {
        font-size: 14px;
        padding: 12px 20px;
    }
}

/* ============================================
   ACCESSIBILITY - Visually Hidden (Screen Reader Only)
   ============================================ */

.visually-hidden,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   ACCESSIBILITY - Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   ACCESSIBILITY - Enhanced Focus Indicators
   ============================================ */

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    box-shadow: none;
}

/* High contrast focus for dark backgrounds (race mode) */
.race-section :focus-visible,
.race-page :focus-visible {
    outline-color: var(--accent-cyan);
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 10000;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 0 0 var(--radius) 0;
    font-weight: 700;
}

.skip-link:focus {
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
}

/* ============================================
   ACCESSIBILITY - Status Indicators with Icons
   ============================================ */

/* Error states - include icon alongside color */
.error-message::before,
.error::before {
    content: '\2716 '; /* ✖ symbol */
    font-weight: bold;
}

/* Success states - include icon alongside color */
.success-message::before {
    content: '\2714 '; /* ✔ symbol */
    font-weight: bold;
}

/* ============================================
   SKELETON LOADING SCREENS
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 70%;
}

.skeleton-text.full {
    width: 100%;
}

.skeleton-card {
    height: 150px;
    border-radius: var(--radius-lg);
}

.skeleton-stat {
    height: 100px;
    border-radius: var(--radius-lg);
}

.skeleton-question {
    height: 180px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.skeleton-button {
    height: 52px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
}

/* Dark skeleton for race mode */
.race-section .skeleton,
.race-page .skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.empty-state h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 24px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state .btn {
    margin-top: 8px;
}

/* ============================================
   LEVEL-UP PROGRESS INDICATOR
   ============================================ */

.level-progress {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.level-progress-text {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    display: block;
}

.level-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-pink));
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RETRY BUTTON STYLES
   ============================================ */

.retry-container {
    text-align: center;
    padding: 24px;
}

.retry-message {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 16px;
}

.btn-retry {
    background: var(--border);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-retry:hover {
    background: var(--text-muted);
    color: white;
}

.btn-retry::before {
    content: '\21BB '; /* ↻ symbol */
}

/* ============================================
   FIRST-TIME ONBOARDING MODAL
   ============================================ */

.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fade-in 0.3s ease;
    padding: 20px;
}

.onboarding-modal {
    background: linear-gradient(135deg, #1a1040 0%, #2d1b69 40%, #4a1d6b 70%, #6b2150 100%);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(124, 58, 237, 0.3);
    position: relative;
    overflow: hidden;
}

.onboarding-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 40px 60px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 120px 30px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 280px 100px, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 200px 150px, rgba(255,255,255,0.5), transparent);
    background-size: 320px 200px;
    opacity: 0.3;
    pointer-events: none;
}

.onboarding-slide {
    display: none;
    animation: slide-up 0.4s ease;
}

.onboarding-slide.active {
    display: block;
}

.onboarding-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.onboarding-modal h3 {
    color: white;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
}

.onboarding-modal p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 0;
}

.onboarding-nav {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.onboarding-dots {
    display: flex;
    gap: 10px;
}

.onboarding-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.onboarding-dot.active {
    background: var(--accent-cyan);
    transform: scale(1.3);
}

.onboarding-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

.onboarding-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: var(--radius-full);
    font-size: 16px;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: transform 0.2s;
    min-width: 150px;
}

.onboarding-btn:hover {
    transform: scale(1.05);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .onboarding-modal {
        padding: 28px;
    }

    .onboarding-icon {
        font-size: 48px;
    }

    .onboarding-modal h3 {
        font-size: 20px;
    }

    .onboarding-modal p {
        font-size: 14px;
    }
}

/* ============================================
   HAPTIC FEEDBACK VISUAL INDICATOR
   ============================================ */

.haptic-tap {
    animation: haptic-flash 0.1s ease;
}

@keyframes haptic-flash {
    0% { transform: scale(1); }
    50% { transform: scale(0.97); }
    100% { transform: scale(1); }
}

/* ============================================
   INPUT MICRO-INTERACTIONS
   ============================================ */

.form-group input:not(:placeholder-shown),
.form-group select:not([value=""]) {
    border-color: var(--primary-light);
}

.numeric-input input:focus {
    transform: scale(1.02);
}

/* ============================================
   DARK MODE SUPPORT (Future)
   ============================================ */

@media (prefers-color-scheme: dark) {
    /* Can be enabled later for dark mode support */
}

/* ============================================
   GLOBAL CHAT WIDGET
   Floating chat for all users on all pages
   ============================================ */

/* Chat Widget - Bubble Style (Less Intrusive) */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: block;
}

/* Chat Bubble - Small circular button */
.chat-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(124, 58, 237, 0.5);
    cursor: grab;
}

.chat-bubble:active {
    cursor: grabbing;
}

.chat-bubble-icon {
    font-size: 24px;
}

.chat-bubble-pulse {
    animation: bubble-pulse 0.6s ease;
}

@keyframes bubble-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Unread badge on bubble */
.chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error);
    color: white;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid var(--bg-dark);
}

/* Message preview popup */
.chat-preview {
    position: absolute;
    bottom: 65px;
    right: 0;
    background: rgba(15, 12, 41, 0.95);
    border-radius: 12px;
    padding: 10px 14px;
    max-width: 250px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(124, 58, 237, 0.3);
    backdrop-filter: blur(10px);
    animation: preview-slide-in 0.3s ease;
    cursor: pointer;
}

.chat-preview::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(15, 12, 41, 0.95);
}

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

.chat-preview-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-right: 6px;
}

.chat-preview-text {
    font-size: 13px;
    color: white;
    word-break: break-word;
}

/* Chat Panel - Full chat window */
.chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 320px;
    height: 400px;
    min-width: 280px;
    min-height: 300px;
    max-width: 500px;
    max-height: 600px;
    background: rgba(15, 12, 41, 0.95);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(124, 58, 237, 0.2);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(124, 58, 237, 0.3);
    overflow: visible;
    transition: opacity 0.2s, transform 0.2s;
}

/* Resize handle - top-left corner */
.chat-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 20;
    border-top-left-radius: var(--radius-lg);
}

.chat-resize-handle::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    border-top-left-radius: 2px;
    transition: border-color 0.2s;
}

.chat-resize-handle:hover::before {
    border-left-color: rgba(255, 255, 255, 0.6);
    border-top-color: rgba(255, 255, 255, 0.6);
}

.chat-panel.resizing {
    transition: none;
    user-select: none;
}

/* Collapsed state - hide panel, show only bubble */
.chat-widget.chat-collapsed .chat-panel {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
}

.chat-widget.chat-collapsed .chat-bubble {
    display: flex;
}

/* Expanded state - show panel */
.chat-widget:not(.chat-collapsed) .chat-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(236, 72, 153, 0.2));
    min-height: 48px;
    cursor: grab;
    user-select: none;
}

.chat-header:active {
    cursor: grabbing;
}

.chat-title {
    font-weight: 700;
    color: white;
    font-size: 15px;
}

.chat-online-count {
    margin-left: auto;
    margin-right: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(34, 197, 94, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-online-count:hover {
    background: rgba(34, 197, 94, 0.4);
}

/* Online users popup */
.chat-online-popup {
    position: absolute;
    top: 48px;
    left: 10px;
    right: 10px;
    background: rgba(30, 27, 75, 0.98);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10;
    max-height: 200px;
    display: flex;
    flex-direction: column;
}

.chat-online-popup-header {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-online-popup-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-online-user {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    gap: 8px;
}

.chat-online-user:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-online-user-me {
    background: rgba(124, 58, 237, 0.15);
}

.chat-online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-online-name {
    font-size: 13px;
    color: white;
}

.chat-online-you {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-left: auto;
}

.chat-online-empty {
    padding: 12px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.chat-btn-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Custom scrollbar for chat */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Message wrapper - contains bubble + time */
.chat-message-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 85%;
    animation: chat-message-in 0.2s ease-out;
}

.chat-message-wrapper-mine {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message {
    position: relative;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

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

.chat-message-mine {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
}

.chat-message-system {
    align-self: center;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    font-style: italic;
    padding: 4px 8px;
}

.chat-message-username {
    display: inline;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-right: 6px;
}

.chat-message-username::after {
    content: ":";
}

.chat-message-mine .chat-message-username {
    color: rgba(255, 255, 255, 0.8);
}

.chat-message-text {
    display: inline;
    color: white;
    font-size: 13px;
    word-wrap: break-word;
    line-height: 1.4;
}

.chat-message-time {
    display: block;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.35);
    text-align: right;
    margin-top: 2px;
    margin-right: 4px;
}

/* Delete button for own messages */
.chat-message-delete {
    background: none;
    border: none;
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    margin-left: 6px;
    transition: opacity 0.2s;
}

.chat-message-delete:hover {
    opacity: 0.7;
}

/* Message deletion animation */
.chat-message-deleted {
    animation: message-delete 0.3s ease forwards;
}

@keyframes message-delete {
    to {
        opacity: 0;
        transform: translateX(20px);
        height: 0;
        padding: 0;
        margin: 0;
    }
}

.chat-input-area {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 14px;
    font-family: 'Nunito', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--primary);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

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

.chat-send-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    border: none;
    border-radius: 20px;
    padding: 10px 18px;
    color: white;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

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

.chat-warning-banner {
    padding: 10px 16px;
    text-align: center;
}

.chat-warning-banner.warning-type {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.9), rgba(249, 115, 22, 0.9));
}

.chat-warning-banner.blocked-type {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
}

.chat-warning-text {
    color: white;
    font-size: 13px;
    font-weight: 600;
}

/* Connection status indicator */
.chat-connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(249, 115, 22, 0.95));
    color: white;
    font-size: 12px;
    font-weight: 500;
}

.chat-connection-status.hidden {
    display: none;
}

.chat-connection-icon {
    font-size: 14px;
}

.chat-connection-text {
    flex: 1;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .chat-widget {
        bottom: 80px !important;
        right: 15px !important;
    }

    .chat-bubble {
        width: 50px;
        height: 50px;
    }

    .chat-bubble-icon {
        font-size: 20px;
    }

    .chat-panel {
        width: calc(100vw - 30px) !important;
        height: 320px !important;
        right: -5px;
        min-width: unset;
        max-width: unset;
    }

    .chat-resize-handle {
        display: none;
    }

    .chat-header {
        cursor: default;
    }

    .chat-preview {
        bottom: 60px;
        right: 0;
        max-width: 200px;
    }
}

/* Print - hide chat */
@media print {
    .chat-widget {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════
   SCRATCHPAD WIDGET
   ═══════════════════════════════════════════════════════════ */

.scratchpad-widget {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 9998;
    font-family: 'Nunito', sans-serif;
}

/* Bubble */
.scratchpad-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

.scratchpad-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
}

.scratchpad-bubble-icon {
    font-size: 26px;
    color: #fff;
    line-height: 1;
}

/* Collapsed: hide panel, show bubble */
.scratchpad-collapsed .scratchpad-panel {
    display: none;
}

.scratchpad-widget:not(.scratchpad-collapsed) .scratchpad-bubble {
    display: none;
}

/* Panel */
.scratchpad-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 380px;
    height: 450px;
    min-width: 300px;
    min-height: 350px;
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.scratchpad-panel.resizing {
    transition: none !important;
    user-select: none;
}

/* Resize handle (top-right corner) */
.scratchpad-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: ne-resize;
    z-index: 2;
}

.scratchpad-resize-handle::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    border-right: 2px solid rgba(255, 255, 255, 0.3);
}

/* Header */
.scratchpad-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(124, 58, 237, 0.15);
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.scratchpad-title {
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.scratchpad-tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.scratchpad-tab {
    padding: 3px 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.scratchpad-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.scratchpad-tab-active {
    background: rgba(124, 58, 237, 0.4);
    border-color: rgba(124, 58, 237, 0.6);
    color: #e2e8f0;
}

.scratchpad-btn-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 4px;
    line-height: 1;
}

.scratchpad-btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

/* Toolbar */
.scratchpad-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.scratchpad-tool,
.scratchpad-action {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.scratchpad-tool:hover,
.scratchpad-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

.scratchpad-tool-active {
    background: rgba(124, 58, 237, 0.4);
    border-color: rgba(124, 58, 237, 0.6);
    color: #e2e8f0;
}

.scratchpad-color {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.scratchpad-color:hover {
    transform: scale(1.15);
}

.scratchpad-color-active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.scratchpad-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 4px;
}

/* Body */
.scratchpad-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Canvas */
.scratchpad-canvas-wrapper {
    flex: 1;
    background: #ffffff;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
    min-height: 0;
}

.scratchpad-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Text mode */
.scratchpad-textarea {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 12px;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1e293b;
    background: #ffffff;
    border-radius: 0 0 16px 16px;
    box-sizing: border-box;
}

.scratchpad-textarea::placeholder {
    color: #94a3b8;
}

/* Hidden utility */
.scratchpad-widget .hidden {
    display: none !important;
}

/* ─── Scratchpad Mobile ──────────────────────────────────── */

@media (max-width: 600px) {
    .scratchpad-widget {
        left: 10px;
        bottom: 10px;
    }

    .scratchpad-bubble {
        width: 48px;
        height: 48px;
    }

    .scratchpad-bubble-icon {
        font-size: 22px;
    }

    .scratchpad-panel {
        width: calc(100vw - 20px) !important;
        height: 380px !important;
        left: -5px;
        min-width: unset;
        max-width: unset;
    }

    .scratchpad-resize-handle {
        display: none;
    }

    .scratchpad-header {
        cursor: default;
    }

    .scratchpad-tool,
    .scratchpad-action {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .scratchpad-color {
        width: 34px;
        height: 34px;
    }
}

/* Print - hide scratchpad */
@media print {
    .scratchpad-widget {
        display: none;
    }
}

/* Confetti Animation */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall linear forwards;
}

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