/* ========================================
   DEUTSCH MEISTER - Modern Educational Game
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500&display=swap');

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0b0e1a;
    --bg-secondary: #111427;
    --bg-card: rgba(22, 27, 51, 0.85);
    --bg-card-hover: rgba(30, 36, 66, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #f0f2f8;
    --text-secondary: #9ba3bf;
    --text-muted: #636b87;

    --accent-blue: #4f6ef7;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-cyan: #06b6d4;
    --accent-orange: #f97316;

    --gradient-primary: linear-gradient(135deg, #4f6ef7, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-danger: linear-gradient(135deg, #ef4444, #ec4899);
    --gradient-warm: linear-gradient(135deg, #f97316, #f59e0b);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-card: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(79, 110, 247, 0.5);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 30px rgba(79, 110, 247, 0.15);
    --shadow-glow-green: 0 0 30px rgba(16, 185, 129, 0.15);
    --shadow-glow-red: 0 0 30px rgba(239, 68, 68, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Grade accent colors */
    --grade-1: #ff6b6b;
    --grade-2: #ff8e53;
    --grade-3: #ffc857;
    --grade-4: #a8e06c;
    --grade-5: #56cfe1;
    --grade-6: #4ea8de;
    --grade-7: #7b68ee;
    --grade-8: #9d4edd;
    --grade-9: #c77dff;
    --grade-10: #e0aaff;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated background mesh */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(79, 110, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 60%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 90%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    z-index: 0;
    pointer-events: none;
}

/* ---- Top Navigation ---- */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(11, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-back {
    display: none;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    background: none;
    border: none;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.nav-back:hover {
    color: var(--text-primary);
    background: var(--bg-glass-hover);
}

.nav-back.visible {
    display: flex;
}

.nav-logo {
    font-size: 1.15rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-card);
}

.nav-xp {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-yellow);
}

.nav-xp .xp-icon { font-size: 1rem; }

/* ---- Screens ---- */
.screen {
    display: none;
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 80px 1.5rem 2rem;
    min-height: calc(100vh - 60px);
    animation: screenFadeIn 0.35s ease;
}

.screen.active {
    display: block;
}

@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- HOME SCREEN ---- */
.home-hero {
    text-align: center;
    padding: 2.5rem 0 2rem;
}

.home-hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 0.75rem;
}

.home-hero h1 .gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-hero .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 520px;
    margin: 0 auto;
}

/* Stats Cards */
.stats-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 2rem 0 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    min-width: 130px;
    text-align: center;
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(79, 110, 247, 0.2);
    box-shadow: var(--shadow-glow-blue);
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-blue);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Grade Grid */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    padding-bottom: 2rem;
}

.grade-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    overflow: hidden;
}

.grade-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--grade-color, var(--accent-blue));
    opacity: 0.7;
    transition: var(--transition-normal);
}

.grade-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-lg);
}

.grade-card:hover::before {
    height: 4px;
    opacity: 1;
}

.grade-card .grade-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--grade-color, var(--accent-blue));
    margin-bottom: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.grade-card .grade-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.grade-card .grade-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.grade-card .grade-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.grade-card .grade-topics {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.grade-card .grade-progress-ring {
    width: 32px;
    height: 32px;
}

.grade-card .grade-progress-ring circle {
    fill: none;
    stroke-width: 3;
}

.grade-card .grade-progress-ring .ring-bg {
    stroke: rgba(255, 255, 255, 0.06);
}

.grade-card .grade-progress-ring .ring-fill {
    stroke: var(--grade-color, var(--accent-blue));
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
    transform: rotate(-90deg);
    transform-origin: center;
}

/* ---- TOPIC SCREEN ---- */
.topics-header {
    padding: 1.5rem 0;
}

.topics-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
}

.topics-header .grade-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.topic-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.topic-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-md);
}

.topic-card .topic-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}

.topic-card .topic-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.topic-card .topic-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 1rem;
}

.topic-card .topic-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topic-card .topic-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.topic-card .topic-stars {
    display: flex;
    gap: 3px;
}

.topic-card .topic-stars .star {
    font-size: 0.9rem;
    opacity: 0.2;
}

.topic-card .topic-stars .star.earned {
    opacity: 1;
}

/* All topics button */
.topic-card.all-topics {
    border: 1px dashed rgba(79, 110, 247, 0.3);
    background: rgba(79, 110, 247, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 180px;
}

.topic-card.all-topics:hover {
    border-color: rgba(79, 110, 247, 0.5);
    background: rgba(79, 110, 247, 0.08);
}

.topic-card.all-topics .topic-icon {
    font-size: 2.5rem;
}

/* ---- QUIZ SCREEN ---- */
.quiz-container {
    max-width: 720px;
    margin: 0 auto;
}

/* Quiz Header */
.quiz-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.quiz-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.quiz-counter {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.quiz-difficulty {
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.quiz-difficulty.leicht {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.quiz-difficulty.mittel {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.quiz-difficulty.schwer {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.quiz-points {
    color: var(--accent-green);
}

.quiz-streak {
    display: none;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    background: rgba(249, 115, 22, 0.12);
    border: 1px solid rgba(249, 115, 22, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-orange);
    font-size: 0.82rem;
    animation: streakBounce 0.5s ease;
}

.quiz-streak.visible {
    display: flex;
}

@keyframes streakBounce {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Progress Bar */
.quiz-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    margin-bottom: 2rem;
    overflow: hidden;
}

.quiz-progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.quiz-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    border-radius: var(--radius-full);
}

/* Question Card */
.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
    animation: questionSlideIn 0.4s ease;
}

@keyframes questionSlideIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.question-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
}

/* Answer Options */
.answers-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.answer-btn {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.answer-btn .answer-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.answer-btn:hover {
    background: rgba(79, 110, 247, 0.08);
    border-color: rgba(79, 110, 247, 0.25);
    transform: translateX(4px);
}

.answer-btn:hover .answer-letter {
    background: rgba(79, 110, 247, 0.15);
    color: var(--accent-blue);
}

.answer-btn.correct {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: var(--shadow-glow-green);
    animation: correctPulse 0.4s ease;
}

.answer-btn.correct .answer-letter {
    background: var(--accent-green);
    color: white;
}

.answer-btn.wrong {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: var(--shadow-glow-red);
    animation: wrongShake 0.4s ease;
}

.answer-btn.wrong .answer-letter {
    background: var(--accent-red);
    color: white;
}

.answer-btn.disabled {
    pointer-events: none;
    opacity: 0.5;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Text Input Answer */
.answer-input-wrap {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.answer-input {
    flex: 1;
    min-width: 200px;
    padding: 0.85rem 1.1rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition-normal);
}

.answer-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}

.answer-input::placeholder {
    color: var(--text-muted);
}

.answer-input.correct {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.answer-input.wrong {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.submit-btn {
    padding: 0.85rem 1.5rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    white-space: nowrap;
}

.submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* True/False Buttons */
.tf-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.tf-btn {
    padding: 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-card);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tf-btn:first-child:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.tf-btn:last-child:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.tf-btn.correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.5);
}

.tf-btn.wrong {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Feedback */
.feedback-panel {
    display: none;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: feedbackSlide 0.35s ease;
}

.feedback-panel.visible {
    display: block;
}

.feedback-panel.correct {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.feedback-panel.wrong {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

@keyframes feedbackSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.feedback-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.feedback-panel.correct .feedback-title { color: var(--accent-green); }
.feedback-panel.wrong .feedback-title { color: var(--accent-red); }

.feedback-explanation {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 0.75rem;
}

.feedback-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--accent-yellow);
    line-height: 1.5;
}

.feedback-tip .tip-icon { flex-shrink: 0; }

.feedback-correct-answer {
    margin-top: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--accent-green);
    font-weight: 600;
}

/* Continue Button */
.continue-btn {
    display: none;
    width: 100%;
    padding: 1rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    margin-bottom: 2rem;
}

.continue-btn.visible {
    display: block;
}

.continue-btn:hover {
    opacity: 0.92;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 110, 247, 0.25);
}

/* ---- RESULTS SCREEN ---- */
.results-container {
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
}

.results-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: resultsEmojiBounce 0.6s ease;
}

@keyframes resultsEmojiBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.results-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.results-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Results Score Ring */
.results-score-ring {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 2rem;
}

.results-score-ring svg {
    transform: rotate(-90deg);
}

.results-score-ring .ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 10;
}

.results-score-ring .ring-fill {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.results-score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.4rem;
    font-weight: 800;
}

.results-score-label {
    position: absolute;
    top: 62%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Results Stats Grid */
.results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.results-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 1.1rem 0.75rem;
}

.results-stat .rs-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-blue);
}

.results-stat .rs-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

/* XP Earned */
.results-xp {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-yellow);
    margin-bottom: 2rem;
    animation: xpPop 0.5s ease 0.5s both;
}

@keyframes xpPop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Results Buttons */
.results-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.results-actions .btn {
    padding: 0.85rem 1.75rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 110, 247, 0.25);
}

.btn-secondary {
    background: var(--bg-glass);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255, 255, 255, 0.12);
}

/* ---- Achievements Badge Row ---- */
.achievements-section {
    margin: 2rem 0;
}

.achievements-grid {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.ach-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    font-size: 1.4rem;
    opacity: 0.3;
    transition: var(--transition-normal);
    cursor: default;
    position: relative;
}

.ach-badge.unlocked {
    opacity: 1;
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.08);
    animation: achUnlock 0.5s ease;
}

@keyframes achUnlock {
    0% { transform: scale(0.5) rotate(-10deg); }
    60% { transform: scale(1.15) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.ach-badge .ach-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.7rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.ach-badge:hover .ach-tooltip {
    opacity: 1;
}

/* ---- Notification Toast ---- */
.toast {
    position: fixed;
    top: 76px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: all 0.35s ease;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Confetti ---- */
.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    z-index: 9998;
    animation: confettiDrop 2.5s linear forwards;
    pointer-events: none;
}

@keyframes confettiDrop {
    0% { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .screen {
        padding: 72px 1rem 1.5rem;
    }

    .home-hero {
        padding: 1.5rem 0 1rem;
    }

    .home-hero h1 {
        font-size: 1.75rem;
    }

    .stats-row {
        gap: 0.5rem;
    }

    .stat-card {
        min-width: 100px;
        padding: 0.75rem 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .grade-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .grade-card {
        padding: 1.15rem;
    }

    .topic-grid {
        grid-template-columns: 1fr;
    }

    .question-card {
        padding: 1.5rem;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .answer-btn {
        padding: 0.85rem 1rem;
        font-size: 0.92rem;
    }

    .results-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        justify-content: center;
    }

    .nav-xp {
        font-size: 0.78rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .grade-grid {
        grid-template-columns: 1fr 1fr;
    }

    .grade-card .grade-desc {
        display: none;
    }

    .tf-buttons {
        grid-template-columns: 1fr;
    }

    .answer-input-wrap {
        flex-direction: column;
    }

    .results-score-ring {
        width: 130px;
        height: 130px;
    }
}

/* ---- Utility ---- */
.hidden { display: none !important; }
.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;
}
