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

/* ========== THEME VARIABLES ========== */
:root {
    --bg-page: #1a1a2e;
    --bg-overlay: rgba(26,26,46,0.95);
    --bg-overlay-solid: rgba(26,26,46,0.98);
    --bg-card: #2a2a4e;
    --bg-card-hover: #3a3a5e;
    --bg-card-glass: rgba(42,42,78,0.9);
    --border-default: #444;
    --border-track: #333;
    --border-dot: #555;
    --text-body: #eee;
    --text-heading: #fff;
    --text-muted: #aaa;
    --text-dim: #888;
    --text-faint: #666;
    --divider: rgba(255,255,255,0.08);
    --divider-mid: rgba(255,255,255,0.1);
}

body[data-theme="light"] {
    --bg-page: #f4f4f8;
    --bg-overlay: rgba(244,244,248,0.95);
    --bg-overlay-solid: rgba(244,244,248,0.98);
    --bg-card: #ffffff;
    --bg-card-hover: #ebebf2;
    --bg-card-glass: rgba(255,255,255,0.9);
    --border-default: #ccc;
    --border-track: #ddd;
    --border-dot: #bbb;
    --text-body: #1a1a2e;
    --text-heading: #111;
    --text-muted: #555;
    --text-dim: #666;
    --text-faint: #888;
    --divider: rgba(0,0,0,0.08);
    --divider-mid: rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-page);
    color: var(--text-body);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* ========== BASE CLASSES ========== */

/* Overlay base — fullscreen modal backdrop */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.active {
    display: flex;
}

/* Button base */
.btn {
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: transform 0.1s, background 0.2s;
}

/* Primary CTA — large red action button */
.btn--primary {
    padding: 1rem 3rem;
    font-size: 1.3rem;
    border: none;
    background: #e94560;
    color: #fff;
}

.btn--primary:hover {
    background: #c73651;
    transform: scale(1.05);
}

.btn--primary:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* Secondary — ghost outline button */
.btn--secondary {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    border: 2px solid var(--border-default);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}

.btn--secondary:hover {
    border-color: var(--text-faint);
    color: var(--text-heading);
}

.btn--secondary:focus-visible {
    outline: 2px solid #16c79a;
    outline-offset: 2px;
}

/* ========== SCREEN CONTAINERS ========== */

#language-screen, #topic-screen, #game-screen, #end-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
    overflow-y: auto;
}

#language-screen {
    justify-content: flex-start;
    padding-top: 2rem;
}

#language-screen.active, #topic-screen.active, #game-screen.active, #end-screen.active {
    display: flex;
}

h1 { font-size: 2.5rem; margin-bottom: 1rem; }

.app-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 3.2rem;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, #e94560, #ff8a5c, #f0a500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 2px 4px rgba(233, 69, 96, 0.3));
}

.instructions {
    max-width: 500px;
    text-align: center;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.instructions strong { color: var(--text-heading); }

/* Waffle divider between sections */
.waffle-divider {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1.2rem 0;
    width: 100%;
    max-width: 320px;
}

.waffle-divider::before,
.waffle-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-default), transparent);
}

.waffle-divider-emoji {
    font-size: 0.9rem;
    opacity: 0.5;
}

/* #start-btn and #restart-btn use .btn.btn--primary */

.color-display {
    width: 200px;
    height: 200px;
    border-radius: 20px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-display.emoji-display {
    font-size: 6rem;
    background: transparent !important;
    box-shadow: none;
}

.color-display.emoji-display.plural-display {
    font-size: 4.5rem;
    letter-spacing: 0.2rem;
}

.reinforcement-label {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    min-height: 1.8rem;
    text-transform: capitalize;
    opacity: 0.85;
}

#timer-bar-container {
    width: 400px;
    max-width: 70vw;
    height: 8px;
    background: var(--border-track);
    border-radius: 4px;
    margin-bottom: 2rem;
    overflow: hidden;
}

#timer-bar {
    height: 100%;
    width: 100%;
    background: #0f3460;
    border-radius: 4px;
    transition: width linear, background linear;
}

#timer-bar.warning { background: #e94560; }

.buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    max-height: 40vh;
    overflow: hidden;
    flex-shrink: 1;
}

.buttons .answer-btn {
    flex: 0 1 calc(50% - 0.25rem);
    box-sizing: border-box;
}

.answer-btn {
    padding: 0.8rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-heading);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-transform: capitalize;
}

.answer-btn:focus { outline: none; }
.answer-btn:focus-visible {
    outline: 2px solid #16c79a;
    outline-offset: 2px;
}

.answer-btn:hover {
    border-color: #e94560;
    background: var(--bg-card-hover);
}

/* Learning mode: buttons have colored backgrounds */
.answer-btn.learning-mode {
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.answer-btn.learning-mode:hover {
    filter: brightness(1.1);
}

/* Practice mode: neutral backgrounds, text only */
.answer-btn.practice-mode {
    background: var(--bg-card);
}

.answer-btn.practice-mode:hover {
    background: var(--bg-card-hover);
}

/* Verb/pronoun mode: 3-column grid, larger text, preserve original case */
.buttons.verb-mode .answer-btn {
    flex: 0 1 calc(33.333% - 0.35rem);
    font-size: 1.3rem;
    padding: 0.8rem 0.3rem;
    text-transform: none;
    overflow-wrap: break-word;
}

/* Balance the 7th button: when it's alone on the last row, make it wider */
.buttons.verb-mode .answer-btn:last-child:nth-child(3n + 1) {
    flex: 0 1 calc(50% - 0.25rem);
}

/* Pronoun Learning phase: single-column layout for clearer initial learning */
.buttons.pronoun-learning .answer-btn {
    flex: 0 1 100%;
}

/* Narrow screens: 2-column fallback for verb/pronoun buttons (long conjugations) */
@media (max-width: 420px) {
    .buttons.verb-mode .answer-btn {
        flex: 0 1 calc(50% - 0.25rem);
        font-size: 1.1rem;
    }
}

/* Learning phase highlight on the correct answer button */
.answer-btn.learning-highlight {
    border-color: #28a745;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

/* Reverse mode: emoji/colour swatch buttons — 3-column grid, large tap targets */
.buttons.reverse-mode {
    gap: 0.4rem;
}

.buttons.reverse-mode .answer-btn {
    flex: 0 1 calc(33.333% - 0.27rem);
    min-height: 72px;
    font-size: 2.2rem;
    line-height: 1;
    padding: 0.6rem 0.25rem;
}


#end-screen h1 {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.2rem;
    letter-spacing: 0.02em;
}

#final-score {
    font-size: 5rem;
    font-weight: 900;
    color: #e94560;
    margin: 1rem 0;
}

#end-message {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.prompt-label {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.language-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-items: center;
}

.language-selector .language-btn:last-child:nth-child(3n + 1) {
    grid-column: 2;
}

.language-selector .language-btn:nth-last-child(2):nth-child(3n + 1) {
    grid-column: 1;
}

.language-selector .language-btn:nth-last-child(2):nth-child(3n + 1) ~ .language-btn:last-child {
    grid-column: 3;
}

.language-btn {
    width: 100%;
    padding: 0.8rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--border-default);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.language-btn:hover {
    border-color: var(--text-faint);
    color: var(--text-heading);
    transform: translateY(-1px);
}

.language-btn.selected {
    border-color: #e94560;
    background: linear-gradient(135deg, #e94560, #c73651);
    color: #fff;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

.topic-header {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-heading);
    letter-spacing: 0.02em;
}

/* .back-btn uses .btn.btn--secondary */
.back-btn {
    margin-top: 1rem;
}

.setting-label {
    color: var(--text-faint);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Flat category selector (verb tenses) */
.category-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

/* Category kanban board */
.category-kanban {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 0.2rem;
}
.kanban-column {
    min-height: 3rem;
}
.kanban-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    margin-bottom: 0.4rem;
    text-align: center;
}
#kanban-to-learn .kanban-heading { color: var(--text-faint); }
#kanban-to-learn .kanban-heading::before { content: '📋 '; }
#kanban-learning .kanban-heading { color: #f0a500; }
#kanban-learning .kanban-heading::before { content: '🧇 '; }
#kanban-mastered .kanban-heading { color: #16c79a; }
#kanban-mastered .kanban-heading::before { content: '⭐ '; }
.kanban-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
}

.category-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--border-default);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    text-align: center;
}

.category-btn:hover,
.category-btn:focus-visible {
    border-color: var(--text-faint);
    color: var(--text-heading);
}

.category-btn.selected {
    border-color: #16c79a;
    background: #16c79a;
    color: #fff;
}

/* Subtle column tints */
#kanban-learning .category-btn { border-color: rgba(240, 165, 0, 0.3); }
#kanban-mastered .category-btn { border-color: rgba(22, 199, 154, 0.3); }

@media (max-width: 480px) {
    .category-kanban {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
    #kanban-mastered {
        grid-column: 1 / -1;
    }
    .kanban-items {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .category-btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
        width: auto;
    }
}

@media (max-width: 360px) {
    .category-kanban { gap: 0.3rem; }
    .category-btn { font-size: 0.65rem; padding: 0.25rem 0.4rem; }
}

/* Mode selector (Words / Verbs toggle) */
.mode-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.mode-btn {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--border-default);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: var(--text-faint);
    color: var(--text-heading);
}

.mode-btn.selected {
    border-color: #0f3460;
    background: #0f3460;
    color: #fff;
}

.mode-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Verb display: large text instead of emoji/colour */
.verb-display {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-heading);
    text-align: center;
    line-height: 1.3;
    max-width: 90vw;
    word-break: break-word;
}

.verb-context {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Pronoun display: stack emoji above English label */
.color-display.pronoun-display {
    flex-direction: column;
}

.pronoun-emoji {
    font-size: 6rem;
    line-height: 1;
}

.pronoun-english-label {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-heading);
    text-transform: none;
    margin-top: 0.25rem;
    line-height: 1.3;
}

/* Emoji display (replaces colour square for emoji categories) */
.emoji-display {
    font-size: 5rem;
    line-height: 1;
    text-align: center;
    margin: 1rem 0;
}

/* Audio toggle switch */
.audio-toggle-container {
    margin-bottom: 1.5rem;
}

.audio-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.audio-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.audio-toggle input:focus-visible + .audio-toggle-slider {
    outline: 2px solid #16c79a;
    outline-offset: 2px;
}

.audio-toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--border-default);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.audio-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.audio-toggle input:checked + .audio-toggle-slider {
    background: #16c79a;
}

.audio-toggle input:checked + .audio-toggle-slider::before {
    transform: translateX(20px);
}

.audio-toggle-icon {
    font-size: 1.2rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.audio-toggle input:checked ~ .audio-toggle-icon {
    opacity: 1;
}

.audio-toggle-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.score-display {
    position: absolute;
    top: 3.5rem;
    right: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #e94560;
}

.game-language-flag {
    font-size: 1.4rem;
    margin-right: 0.3rem;
    vertical-align: middle;
}

#game-screen {
    position: relative;
    scrollbar-gutter: stable;
}

.stats-row {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: #0f3460;
}

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

/* Level system styles */
.level-display {
    position: absolute;
    top: 1rem;
    left: 1rem;
    text-align: left;
}

.level-info {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.3rem;
}

.phase-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.phase-badge.learning {
    background: #28a745;
    color: #fff;
}

.phase-badge.practice {
    background: #fd7e14;
    color: #fff;
}

.phase-badge.typing {
    background: #6f42c1;
    color: #fff;
}

.phase-badge.speech {
    background: #e83e8c;
    color: #fff;
}

.phase-desc {
    font-size: 0.7rem;
    color: var(--text-faint);
    margin-bottom: 0.3rem;
}

/* Typing mode UI */
.typing-ui {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 400px;
}

.typing-ui.active {
    display: flex;
}

.typing-input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1.3rem;
    font-family: inherit;
    font-weight: 600;
    text-align: center;
    border: 2px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-heading);
    outline: none;
    text-transform: capitalize;
}

.typing-input:focus {
    border-color: #6f42c1;
    box-shadow: 0 0 8px rgba(111, 66, 193, 0.4);
}

.typing-input.shake {
    animation: shake 0.4s ease;
    border-color: #e94560;
}

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

.typing-feedback {
    font-size: 1rem;
    color: var(--text-muted);
    min-height: 1.5em;
}

.typing-hint {
    font-size: 0.75rem;
    color: var(--text-faint);
    font-style: italic;
}

.accent-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    justify-content: center;
    margin-bottom: 0.25rem;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 2px; /* prevent scrollbar clipping button shadows */
}

.accent-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-default);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-heading);
    font-size: 1.1rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}

.accent-btn:hover {
    border-color: #6f42c1;
    background: var(--bg-card-hover);
}

.accent-btn:active {
    transform: scale(0.92);
}

/* Typing mode: smaller display and reordered timer */
#game-screen.typing-active .color-display {
    width: 120px;
    height: 120px;
    margin-bottom: 0.5rem;
}

#game-screen.typing-active .color-display.emoji-display {
    font-size: 3.5rem;
}

#game-screen.typing-active .reinforcement-label {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

#game-screen.typing-active #timer-bar-container {
    order: 1;
    margin-bottom: 0.75rem;
}

#game-screen.typing-active .typing-ui {
    order: 2;
}

/* Speech mode UI */
.speech-ui {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.speech-ui.active {
    display: flex;
}

.mic-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: rgba(232, 62, 140, 0.2);
    border: 2px solid #e83e8c;
    border-radius: 12px;
    color: #e83e8c;
    font-size: 1.1rem;
    font-weight: 600;
}

.mic-icon {
    width: 24px;
    height: 24px;
    position: relative;
}

.mic-icon::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 16px;
    background: currentColor;
    border-radius: 6px;
    left: 6px;
    top: 0;
}

.mic-icon::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 10px;
    border: 2px solid currentColor;
    border-top: none;
    border-radius: 0 0 9px 9px;
    left: 3px;
    top: 12px;
}

.mic-icon.listening {
    animation: pulse 1s ease-in-out infinite;
}

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

.speech-prompt {
    font-size: 1.2rem;
    color: var(--text-heading);
    text-align: center;
}

.voice-feedback {
    font-size: 1rem;
    color: var(--text-muted);
    min-height: 1.5em;
}

.speech-attempts {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    max-height: 5rem;
    overflow-y: auto;
    width: 100%;
    padding: 0 0.5rem;
}

.speech-attempt {
    font-size: 0.85rem;
    color: #e94560;
    opacity: 0.7;
}

.speech-attempt::before {
    content: '\2717 ';
}

.speech-warning {
    display: none;
    background: rgba(255, 152, 0, 0.2);
    border: 2px solid #ff9800;
    border-radius: 8px;
    padding: 1rem;
    color: #ff9800;
    text-align: center;
    max-width: 400px;
    margin-bottom: 1rem;
}

.speech-warning.visible {
    display: block;
}

/* Browser compatibility banner */
.browser-banner {
    position: relative;
    background: #ff9800;
    border: 2px solid #e68a00;
    border-radius: 8px;
    padding: 0.75rem 2.2rem 0.75rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #1a1a1a;
    line-height: 1.4;
    font-weight: 500;
}
.browser-banner p { margin: 0; }
.browser-banner strong { color: #000; font-weight: 700; }
.browser-banner-dismiss {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: #4a3000;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
}
.browser-banner-dismiss:hover,
.browser-banner-dismiss:focus-visible { color: #000; }

@media (prefers-reduced-motion: reduce) {
    .mic-icon.listening {
        animation: none;
    }
}

/* Vertical level progress bar */
.vertical-progress-container {
    position: fixed;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 200px;
    background: var(--border-track);
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border: 2px solid var(--border-default);
}

.vertical-progress-bar {
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #16c79a, #0f3460);
    border-radius: 0 0 13px 13px;
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.vertical-progress-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sfx-mute-btn {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    opacity: 0.7;
}

.sfx-mute-btn:hover {
    opacity: 1;
}

.sfx-mute-btn.muted {
    opacity: 0.4;
}

.time-display {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* Game controls (pause/quit) */
.game-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.game-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg-card-glass);
    border: none;
    color: var(--text-heading);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.game-control-btn:hover {
    background: var(--bg-card-hover);
}

.game-control-btn:focus-visible {
    outline: 2px solid #16c79a;
    outline-offset: 2px;
}

/* Pause overlay — uses .overlay base */

.pause-title {
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-heading);
    margin-bottom: 2rem;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

/* #resume-btn uses .btn.btn--primary */

/* .pause-quit-btn uses .btn.btn--secondary */

/* Level-up overlay — uses .overlay base */

.level-up-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    color: #e94560;
    margin-bottom: 1rem;
    animation: levelUpPulse 0.5s ease-out;
}

@keyframes levelUpPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.level-up-message {
    font-size: 1.3rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.level-up-phase {
    font-size: 1.1rem;
    color: #f0a500;
    margin-bottom: 0.5rem;
}

.level-up-streak {
    font-size: 1.1rem;
    color: #16c79a;
    margin-bottom: 0.5rem;
}

.level-up-info {
    font-size: 0.95rem;
    color: #16c79a;
    margin-bottom: 0.5rem;
}

.level-up-time {
    font-size: 1rem;
    color: #e94560;
    margin-bottom: 2rem;
}

.level-up-countdown {
    font-size: 4rem;
    font-weight: 900;
    color: #e94560;
}

/* Overlay navigation buttons (level-up & cycle-complete) */
.overlay-nav {
    margin-top: 1rem;
}

/* .overlay-nav-btn uses .btn.btn--secondary */

/* Start screen progress display */
.progress-display {
    background: rgba(15, 52, 96, 0.3);
    border: 2px solid #0f3460;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
    min-width: 250px;
    box-shadow: 0 2px 12px rgba(15, 52, 96, 0.2);
}

.progress-title {
    font-size: 0.8rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.journey-tracker {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.journey-phase {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
    border-radius: 8px;
    padding: 4px 6px;
    margin: -4px -6px;
    transition: background 0.15s;
}

.journey-phase.active,
.journey-phase.completed {
    pointer-events: auto;
    cursor: pointer;
}

.journey-phase:hover {
    background: var(--divider);
}

.journey-phase:focus-visible {
    outline: 2px solid #6f42c1;
    outline-offset: 2px;
}

.journey-phase.active {
    opacity: 1;
}

.journey-phase.completed {
    opacity: 0.7;
}

.journey-dot {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-dot);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    margin-top: 2px;
}

.journey-phase.active .journey-dot {
    background: #fd7e14;
    border-color: #fd7e14;
    box-shadow: 0 0 8px rgba(253, 126, 20, 0.4);
}

.journey-phase.active[data-phase="0"] .journey-dot {
    background: #28a745;
    border-color: #28a745;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.4);
}

.journey-phase.active[data-phase="2"] .journey-dot {
    background: #6f42c1;
    border-color: #6f42c1;
    box-shadow: 0 0 8px rgba(111, 66, 193, 0.4);
}

.journey-phase.active[data-phase="3"] .journey-dot {
    background: #e83e8c;
    border-color: #e83e8c;
    box-shadow: 0 0 8px rgba(232, 62, 140, 0.4);
}

.journey-phase.completed .journey-dot {
    background: #28a745;
    border-color: #28a745;
}

.journey-phase.completed .journey-dot::after {
    content: '\2713';
    color: #fff;
    font-weight: 700;
}

.journey-phase.active .journey-dot::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
}

.journey-connector {
    width: 2px;
    height: 16px;
    background: var(--border-track);
    margin-left: 11px;
}

.journey-phase.completed + .journey-connector {
    background: #28a745;
}

.journey-phase-info {
    flex: 1;
    min-width: 0;
}

.journey-phase-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
}

.journey-phase-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.journey-phase-progress {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.journey-stats {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--divider-mid);
    font-size: 0.8rem;
    color: var(--text-dim);
}

.journey-stats-sep {
    color: var(--border-dot);
}

/* Cycle complete overlay — uses .overlay base */

.cycle-complete-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    color: #28a745;
    margin-bottom: 1rem;
    animation: levelUpPulse 0.5s ease-out;
}

.cycle-complete-message {
    font-size: 1.3rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.cycle-complete-colors {
    font-size: 1.1rem;
    color: #e83e8c;
    margin-bottom: 0.5rem;
}

.new-color-badges {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.color-badge {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    text-transform: capitalize;
}

.cycle-complete-info {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

#level-up-overlay .phase-badge {
    font-size: 1rem;
    padding: 0.4rem 1rem;
    margin-bottom: 0.5rem;
}

.cycle-complete-countdown {
    font-size: 4rem;
    font-weight: 900;
    color: #28a745;
}

/* Statistics styles */
.start-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

#stats-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border: 2px solid var(--divider-mid);
    border-radius: 8px;
    background: transparent;
    color: var(--text-heading);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

#stats-btn:hover {
    border-color: var(--border-default);
    background: var(--divider);
}

/* Auth section */
.auth-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--divider);
    text-align: center;
}

.auth-prompt {
    margin: 0 0 0.9rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    max-width: 240px;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    border: none;
}

.auth-btn:hover { opacity: 0.88; transform: scale(1.02); }
.auth-btn:active { transform: scale(0.98); }

.auth-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.auth-btn--google {
    background: #fff;
    color: #3c4043;
}

.auth-btn--apple {
    background: #000;
    color: #fff;
}

#auth-signed-in {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.auth-user-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.auth-signout-btn {
    padding: 0.3rem 0.8rem;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.auth-signout-btn:hover {
    border-color: var(--text-dim);
    color: var(--text-heading);
}

/* Auth error message */
.auth-error {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: rgba(233, 69, 96, 0.15);
    border: 1px solid rgba(233, 69, 96, 0.4);
    color: #e94560;
    font-size: 0.8rem;
    text-align: center;
    max-width: 240px;
}

/* Daily streak badge on topic screen */
.streak-badge {
    font-size: 0.85rem;
    color: var(--text-faint);
    margin-bottom: 1rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--border-track);
    text-align: center;
}

.streak-badge.active {
    color: #fd7e14;
    border-color: rgba(253, 126, 20, 0.4);
    background: rgba(253, 126, 20, 0.1);
}


/* Stats overlay — uses .overlay base, overrides bg opacity */
#stats-overlay {
    background: var(--bg-overlay-solid);
    padding: 2rem;
    overflow-y: auto;
}

.stats-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.2rem;
    font-weight: 900;
    color: #e94560;
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
}

.stats-card {
    background: rgba(15, 52, 96, 0.3);
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stats-card.wide {
    grid-column: span 2;
}

.stats-card-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-heading);
}

.stats-card-label {
    font-size: 0.8rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.3rem;
}

.language-stats {
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
}

.language-stats-title {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.language-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-track);
}

.language-stat-name {
    color: var(--text-heading);
    font-weight: 600;
}

.language-stat-data {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stats-buttons {
    display: flex;
    gap: 1rem;
}

#close-stats-btn {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: #0f3460;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

#close-stats-btn:hover {
    background: #1a4a7a;
}

#reset-stats-btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
    border: 2px solid #e94560;
    border-radius: 8px;
    background: transparent;
    color: #e94560;
    cursor: pointer;
    transition: all 0.2s;
}

#reset-stats-btn:hover {
    background: #e94560;
    color: #fff;
}

#reset-progress-btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
    border: 2px solid #ff9800;
    border-radius: 8px;
    background: transparent;
    color: #ff9800;
    cursor: pointer;
    transition: all 0.2s;
}

#reset-progress-btn:hover {
    background: #ff9800;
    color: #fff;
}

/* Speed mercy overlay — uses .overlay base */

.speed-mercy-title {
    font-size: 3rem;
    font-weight: 900;
    color: #fd7e14;
    margin-bottom: 1rem;
    animation: levelUpPulse 0.5s ease-out;
}

.speed-mercy-message {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: center;
}

.speed-mercy-streak {
    font-size: 1.1rem;
    color: #16c79a;
    margin-bottom: 1rem;
}

.speed-mercy-hint {
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.speed-mercy-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

/* #speed-mercy-retry uses .btn.btn--primary */

#speed-mercy-add-time {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    border: 2px solid #fd7e14;
    border-radius: 8px;
    background: transparent;
    color: #fd7e14;
    cursor: pointer;
    transition: all 0.2s;
}

#speed-mercy-add-time:hover {
    background: #fd7e14;
    color: #fff;
}

/* .speed-mercy-end-btn uses .btn.btn--secondary */

/* Personal best indicator on end screen */
.personal-best {
    display: none;
    color: #28a745;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.personal-best.visible {
    display: block;
}

.best-streak-display {
    font-size: 0.85rem;
    color: var(--text-faint);
    margin-top: 0.5rem;
}

/* Mobile: compact buttons to prevent overflow */
@media (max-height: 700px) {
    #language-screen, #topic-screen, #game-screen, #end-screen {
        padding: 1rem;
    }
    #game-screen {
        justify-content: flex-start;
        padding-top: 0.5rem;
    }
    .answer-btn {
        padding: 0.5rem 0.4rem;
        font-size: 0.95rem;
    }
    .buttons {
        gap: 0.35rem;
        max-height: 35vh;
    }
    .buttons .answer-btn {
        flex: 0 1 calc(50% - 0.175rem);
    }
}

/* Very small screens: even more compact */
@media (max-height: 500px) {
    .color-display {
        width: 80px;
        height: 80px;
    }
    .color-display.emoji-display {
        font-size: 3rem;
    }
    .buttons {
        max-height: 30vh;
    }
}

/* ========== LEGAL LINKS (language screen footer) ========== */

.legal-links {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legal-link {
    background: none;
    border: none;
    color: var(--text-muted);
    opacity: 0.5;
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s, opacity 0.15s;
}

.legal-link:hover {
    opacity: 0.8;
}

.legal-separator {
    color: var(--text-muted);
    opacity: 0.4;
    font-size: 0.75rem;
}

/* ========== LEGAL OVERLAYS (Privacy Policy / Terms) ========== */

#privacy-overlay,
#terms-overlay {
    background: var(--bg-overlay-solid);
    padding: 2rem;
    overflow-y: auto;
    align-items: center;
    justify-content: flex-start;
}

.legal-overlay-content {
    position: relative;
    max-width: 600px;
    width: 100%;
    padding: 1rem 0;
}

.legal-title {
    font-size: 1.8rem;
    font-weight: 900;
    color: #e94560;
    margin-bottom: 1.5rem;
    padding-right: 2.5rem;
}

.legal-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    transition: color 0.15s;
}

.legal-close-btn:hover {
    color: var(--text-heading);
}

.legal-close-btn:focus-visible {
    outline: 2px solid #16c79a;
    outline-offset: 2px;
}

.legal-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

.legal-text h3 {
    color: var(--text-heading);
    font-size: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.legal-text p {
    margin-bottom: 0.75rem;
}

.legal-text ul {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.legal-text li {
    margin-bottom: 0.3rem;
}

.legal-inline-link {
    background: none;
    border: none;
    color: #16c79a;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.legal-inline-link:hover {
    color: #1ae0af;
}

/* ========== DATA MANAGEMENT BUTTONS (stats overlay) ========== */

.stats-buttons--data {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--divider-mid);
}

#export-data-btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 600;
    border: 2px solid #0f3460;
    border-radius: 8px;
    background: transparent;
    color: #0f3460;
    cursor: pointer;
    transition: all 0.2s;
}

#export-data-btn:hover {
    background: #0f3460;
    color: #fff;
}

#delete-account-btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 600;
    border: 2px solid #dc3545;
    border-radius: 8px;
    background: transparent;
    color: #dc3545;
    cursor: pointer;
    transition: all 0.2s;
}

#delete-account-btn:hover {
    background: #dc3545;
    color: #fff;
}

/* ========== DAILY CHALLENGE SYSTEM ========== */

/* Toast notification — slides in from top */
.challenge-toast {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 200;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(40, 167, 69, 0.4);
    white-space: nowrap;
}

.challenge-toast.visible {
    top: 1rem;
}

.challenge-toast-emoji {
    font-size: 1.3rem;
}

/* Daily challenge card on topic screen */
.daily-challenge-card {
    background: rgba(15, 52, 96, 0.2);
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    text-align: center;
    min-width: 250px;
    max-width: 400px;
    width: 100%;
}

.daily-challenge-card.completed {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.daily-challenge-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.daily-challenge-emoji {
    font-size: 1.2rem;
}

.daily-challenge-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.daily-challenge-desc {
    font-size: 0.9rem;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.daily-challenge-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-track);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}

.daily-challenge-progress-fill {
    height: 100%;
    width: 0%;
    background: #e94560;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.daily-challenge-card.completed .daily-challenge-progress-fill {
    background: #28a745;
}

.daily-challenge-status {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.daily-challenge-card.completed .daily-challenge-status {
    color: #28a745;
    font-weight: 600;
}

/* End screen — daily challenge indicator */
.daily-challenge-end {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(15, 52, 96, 0.2);
    border: 1px solid #0f3460;
    margin-top: 0.5rem;
}

.daily-challenge-end.completed {
    color: #28a745;
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
    font-weight: 600;
}

.daily-challenge-end-emoji {
    font-size: 1rem;
}

.end-screen-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    margin-top: 2rem;
}

/* Stats overlay — daily challenge section */
.daily-challenge-stats {
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
    background: rgba(15, 52, 96, 0.2);
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.daily-challenge-stats.completed {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.daily-challenge-stats-title {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.daily-challenge-stats-desc {
    font-size: 0.9rem;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.daily-challenge-stats-status {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.daily-challenge-stats.completed .daily-challenge-stats-status {
    color: #28a745;
    font-weight: 600;
}

/* ========== ACHIEVEMENT SYSTEM ========== */

/* Achievement toast — gold/amber, slides in from top */
.achievement-toast {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: #f0a500;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 200;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(240, 165, 0, 0.4);
    white-space: nowrap;
}

.achievement-toast.visible {
    top: 1rem;
}

.achievement-toast-emoji {
    font-size: 1.3rem;
}

/* Achievements section in stats overlay */
.achievements-section {
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
}

.achievements-title {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.achievements-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.achievement-card {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem;
    border-radius: 8px;
    border: 2px solid #f0a500;
    background: rgba(240, 165, 0, 0.1);
}

.achievement-card.locked {
    border-color: var(--border-default);
    background: transparent;
    opacity: 0.4;
}

.achievement-emoji {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.achievement-info {
    min-width: 0;
}

.achievement-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}

.achievement-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.3;
    margin-top: 0.15rem;
}

.achievement-date {
    font-size: 0.65rem;
    color: #f0a500;
    margin-top: 0.2rem;
}

@media (max-width: 420px) {
    .achievements-list {
        grid-template-columns: 1fr;
    }
}

/* ========== XP AND LEVELLING SYSTEM ========== */

/* XP section in stats overlay */
.xp-section {
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
    background: rgba(15, 52, 96, 0.2);
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 1rem;
}

.xp-level-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.xp-level-num-label {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text-heading);
}

.xp-level-title {
    font-size: 1rem;
    font-weight: 700;
}

.xp-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-track);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.xp-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #16c79a, #0f3460);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.xp-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.xp-total {
    font-weight: 600;
    color: var(--text-muted);
}

/* XP earned on end screen */
.xp-earned {
    font-size: 1.1rem;
    font-weight: 700;
    color: #16c79a;
    margin-top: 0.5rem;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    background: rgba(22, 199, 154, 0.1);
    border: 1px solid rgba(22, 199, 154, 0.3);
}

/* XP toast — brief flash, slides in from top */
.xp-toast {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #16c79a;
    color: #fff;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    z-index: 200;
    transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(22, 199, 154, 0.4);
    white-space: nowrap;
}

.xp-toast.visible {
    top: 1rem;
}

/* Level-up toast — more prominent, slides in from top */
.level-up-xp-toast {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #6f42c1, #e94560);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 200;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(111, 66, 193, 0.4);
    white-space: nowrap;
}

.level-up-xp-toast.visible {
    top: 1rem;
}

.level-toast-level {
    font-size: 1.2rem;
}

.level-toast-title {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ========== BUY ME A COFFEE NUDGE ========== */

.coffee-nudge {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    margin-top: 1.5rem;
    opacity: 0.6;
    max-width: 320px;
    line-height: 1.5;
}

.coffee-nudge a {
    color: #f0a500;
    text-decoration: underline;
    transition: color 0.15s;
}

.coffee-nudge a:hover {
    color: #ffbf33;
}

.coffee-nudge--overlay {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--divider);
}

/* ========== WEAKNESS REPORT ========== */

.weakness-report {
    max-width: 400px;
    width: 100%;
    margin-bottom: 1.5rem;
}

.weakness-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.75rem 0;
    background: none;
    border: none;
    border-top: 1px solid var(--divider);
    border-bottom: 1px solid var(--divider);
    color: var(--text-muted);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: color 0.2s;
}

.weakness-section-header:hover {
    color: var(--text-heading);
}

.weakness-chevron {
    transition: transform 0.2s;
}

.weakness-section-header[aria-expanded="true"] .weakness-chevron {
    transform: rotate(90deg);
}

.weakness-content {
    padding-top: 1rem;
}

.weakness-no-data {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
    padding: 1rem 0;
}

.weakness-overall {
    text-align: center;
    margin-bottom: 1rem;
}

.weakness-overall-pct {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-heading);
}

.weakness-overall-label {
    font-size: 0.8rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.2rem;
}

.weakness-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.weakness-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.weakness-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    background: rgba(15, 52, 96, 0.2);
    border-radius: 6px;
    font-size: 0.85rem;
}

.weakness-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-body);
}

.weakness-item-stats {
    flex-shrink: 0;
    color: var(--text-dim);
    font-size: 0.75rem;
}

.accuracy-bar-bg {
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.accuracy-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.accuracy-bar-fill--red { background: #e74c3c; }
.accuracy-bar-fill--amber { background: #f0a500; }
.accuracy-bar-fill--green { background: #27ae60; }
