/* ============================================
   Math Quest Portal - Styles
   A distinctive, modern math practice platform
   ============================================ */

:root {
    /* Color Palette - Deep ocean meets sunset warmth */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #232b45;
    
    --accent-primary: #f59e0b;
    --accent-secondary: #fbbf24;
    --accent-glow: rgba(245, 158, 11, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);
    
    --gradient-hero: linear-gradient(135deg, #0a0e1a 0%, #1a1f35 50%, #0f172a 100%);
    --gradient-accent: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-card: linear-gradient(145deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(245, 158, 11, 0.3);
    
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(245, 158, 11, 0.2);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --font-display: 'Crimson Pro', Georgia, serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    /* iOS safe area support */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    /* Prevent iOS rubber-banding */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

.app-container {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    position: relative;
    /* Safe area padding for notched devices */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* iOS standalone mode adjustments */
@media all and (display-mode: standalone) {
    .app-container {
        padding-top: max(env(safe-area-inset-top), 20px);
    }
}

/* Touch optimizations for Apple devices */
@supports (-webkit-touch-callout: none) {
    button, .option-btn, .grade-card {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* Page Transitions */
.page {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.page.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.5s ease;
}

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

/* ============================================
   Landing Page
   ============================================ */

#landing-page {
    min-height: 100vh;
    background: var(--gradient-hero);
    position: relative;
}

.hero-background {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Floating Math Symbols */
.floating-shapes {
    position: absolute;
    inset: 0;
}

.shape {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 3rem;
    color: rgba(245, 158, 11, 0.1);
    animation: float 20s infinite ease-in-out;
}

.shape-1 { top: 10%; left: 5%; animation-delay: 0s; font-size: 4rem; }
.shape-2 { top: 20%; right: 10%; animation-delay: -3s; font-size: 5rem; color: rgba(251, 191, 36, 0.08); }
.shape-3 { top: 60%; left: 8%; animation-delay: -6s; font-size: 3.5rem; }
.shape-4 { top: 40%; right: 5%; animation-delay: -9s; font-size: 4.5rem; color: rgba(245, 158, 11, 0.12); }
.shape-5 { bottom: 20%; left: 15%; animation-delay: -12s; font-size: 3rem; }
.shape-6 { bottom: 30%; right: 15%; animation-delay: -15s; font-size: 4rem; }
.shape-7 { top: 75%; left: 60%; animation-delay: -7s; font-size: 3.5rem; }
.shape-8 { top: 15%; left: 40%; animation-delay: -4s; font-size: 2.5rem; color: rgba(251, 191, 36, 0.06); }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-20px) rotate(5deg); }
    50% { transform: translateY(-10px) rotate(-3deg); }
    75% { transform: translateY(-25px) rotate(3deg); }
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    position: relative;
    z-index: 10;
}

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

.logo-icon {
    font-size: 1.75rem;
    color: var(--accent-primary);
    animation: pulse 3s infinite ease-in-out;
}

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

.logo-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Hero Content */
.hero-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 3rem 4rem;
    position: relative;
    z-index: 10;
}

.hero-text {
    text-align: center;
    margin-bottom: 4rem;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.gradient-text {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.source-badge a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

.source-badge a:hover {
    text-decoration: underline;
}

.feature-tags {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.feature-tag {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.15) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    color: var(--accent-secondary);
    font-weight: 500;
}

/* Grade Selection */
.grade-selection {
    margin-top: 2rem;
}

.section-title {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    max-width: 1000px;
    margin: 0 auto;
}

.grade-card {
    background: var(--gradient-card);
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.grade-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(245, 158, 11, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

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

.grade-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.1);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.grade-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.grade-level {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

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

.grade-meta {
    font-size: 0.8rem;
    color: var(--accent-primary);
    font-family: var(--font-mono);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: relative;
    z-index: 10;
}

.main-footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.main-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   Exam Page
   ============================================ */

#exam-page {
    min-height: 100vh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

.back-icon {
    font-size: 1.2rem;
}

.exam-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.exam-grade {
    font-weight: 600;
    color: var(--accent-primary);
}

.exam-separator {
    color: var(--text-muted);
}

.exam-progress {
    color: var(--text-secondary);
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    color: var(--accent-secondary);
}

.timer-icon {
    font-size: 1.1rem;
}

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

.progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

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

.progress-markers {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
}

/* Question Container */
.question-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
}

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

.question-number {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.question-points {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-primary);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
}

.question-text {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.question-image-container {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

.question-image-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
}

/* Options */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
}

.option-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(245, 158, 11, 0.05);
}

.option-btn.selected {
    border-color: var(--accent-primary);
    background: rgba(245, 158, 11, 0.1);
}

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

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

.option-letter {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 50%;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.option-btn.selected .option-letter {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.option-btn.correct .option-letter {
    background: var(--success);
    color: white;
}

.option-btn.incorrect .option-letter {
    background: var(--error);
    color: white;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

/* Exam Navigation */
.exam-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

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

.next-btn {
    background: var(--gradient-accent);
    color: var(--bg-primary);
}

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

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

.submit-btn:hover {
    background: #0d9668;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

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

.question-dots {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.question-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.3s ease;
}

.question-dot.current {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.2);
}

.question-dot.answered {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

/* ============================================
   Results Page
   ============================================ */

#results-page {
    min-height: 100vh;
    background: var(--gradient-hero);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.results-container {
    max-width: 700px;
    width: 100%;
}

.results-header {
    text-align: center;
    margin-bottom: 2rem;
}

.results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease infinite;
}

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

.results-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

/* Score Card */
.score-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
}

.score-circle {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 2rem;
}

.score-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-bg {
    fill: none;
    stroke: var(--bg-secondary);
    stroke-width: 8;
}

.score-fill {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1.5s ease;
}

.score-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

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

.score-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.score-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

.score-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Results Actions */
.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.review-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.review-btn:hover {
    border-color: var(--accent-primary);
}

.retry-btn {
    background: var(--gradient-accent);
    color: var(--bg-primary);
}

.retry-btn:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

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

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

/* Review Section */
.review-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.review-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.review-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border-left: 4px solid var(--border-subtle);
}

.review-item.correct {
    border-left-color: var(--success);
}

.review-item.incorrect {
    border-left-color: var(--error);
}

.review-question {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.review-answers {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
}

.review-answer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.review-answer.user {
    color: var(--text-secondary);
}

.review-answer.correct-answer {
    color: var(--success);
    font-weight: 500;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--bg-card-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .main-header {
        padding: 1rem 1.5rem;
    }
    
    .hero-content {
        padding: 1.5rem;
    }
    
    .grade-grid {
        grid-template-columns: 1fr;
    }
    
    .exam-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .exam-content {
        padding: 1rem;
    }
    
    .question-container {
        padding: 1.25rem;
    }
    
    .score-details {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   Authentication Styles
   ============================================ */

/* ============================================
   User Area (Header - Subtle)
   ============================================ */

.user-area {
    position: relative;
}

.user-icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-icon-btn:hover {
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.user-icon {
    font-size: 1.25rem;
}

.user-dropdown {
    position: relative;
}

.user-avatar-btn {
    background: var(--gradient-accent);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-avatar-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.avatar-letter {
    color: var(--bg-primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.dropdown-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.dropdown-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
}

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

.dropdown-item.logout:hover {
    color: var(--error);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    position: relative;
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

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

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.auth-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

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

.form-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    min-height: 1.25rem;
}

.auth-submit-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--gradient-accent);
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* ============================================
   Compact Results Page
   ============================================ */

.results-container.compact {
    max-width: 800px;
    padding: 1rem 2rem;
}

.results-top {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.results-header-compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
}

.results-header-compact .results-icon {
    font-size: 2.5rem;
    margin: 0;
    animation: none;
}

.results-header-compact .results-title {
    font-size: 1.5rem;
    margin: 0;
}

.results-header-compact .results-subtitle {
    margin: 0;
    font-size: 0.95rem;
}

.score-card.compact {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
    flex-wrap: wrap;
}

.score-circle.compact {
    width: 120px;
    height: 120px;
    margin: 0;
}

.score-circle.compact .score-value {
    font-size: 2rem;
}

.score-details.compact {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    border: none;
    padding: 0;
    min-width: 200px;
}

.score-details.compact .score-stat {
    min-width: 60px;
}

.save-status {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.save-status.saved {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.save-status.not-saved {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-secondary);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.save-status a {
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.results-actions.compact {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-start;
    margin: 0;
}

.results-actions.compact .action-btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
}

/* ============================================
   History Page
   ============================================ */

#history-page {
    min-height: 100vh;
    background: var(--gradient-hero);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.history-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
}

.history-user {
    color: var(--text-secondary);
}

.history-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-icon {
    font-size: 1.75rem;
}

.stat-number {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.history-section-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    gap: 1rem;
    flex-wrap: wrap;
}

.history-grade {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.grade-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}

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

.history-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.history-score {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
}

.history-score.good {
    color: var(--success);
}

.history-score.ok {
    color: var(--accent-primary);
}

.history-score.poor {
    color: var(--error);
}

.history-details {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.empty-history {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.empty-history p {
    margin-bottom: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .main-header {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .auth-section {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .score-card.compact {
        flex-direction: column;
        text-align: center;
    }
    
    .results-header-compact {
        flex-direction: column;
        text-align: center;
    }
    
    .results-actions.compact {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .history-stats {
        width: 100%;
        justify-content: space-between;
    }
}

/* SVG Gradient Definition (added via JS) */

