/* LastTyper — Full Stylesheet
   Dark theme, electric cyan accent, JetBrains Mono */

/* ============================================
   FONTS
   ============================================ */
@font-face {
    font-family: "JetBrains Mono";
    src: url("https://cdn.lasttyper.com/fonts/jetbrains-mono-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("https://cdn.lasttyper.com/fonts/jetbrains-mono-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("https://cdn.lasttyper.com/fonts/jetbrains-mono-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("https://cdn.lasttyper.com/fonts/inter-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("https://cdn.lasttyper.com/fonts/inter-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("https://cdn.lasttyper.com/fonts/inter-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("https://cdn.lasttyper.com/fonts/inter-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("https://cdn.lasttyper.com/fonts/inter-800.woff2") format("woff2");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("https://cdn.lasttyper.com/fonts/inter-900.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --accent: #3cc8c0;
    --accent-dim: rgba(60, 200, 192, 0.15);
    --accent-glow: rgba(60, 200, 192, 0.4);
    --success: #3cc8c0;
    --error: #ff4444;
    --error-dim: rgba(255, 68, 68, 0.15);
    --warning: #ffaa00;
    --bg: #0a0a0a;
    --bg-raised: #111111;
    --bg-input: #0d0d0d;
    --text: #e0e0e0;
    --text-bright: #ffffff;
    --text-dim: #888888;
    --text-muted: #999999;
    --font-mono:
        "JetBrains Mono", "SF Mono", Monaco, "Cascadia Code", monospace;
    --font-ui:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
    --border: #222222;
    --bg-card: #111111;
}

/* Light theme */
[data-theme="light"] {
    --accent: #2b9a94;
    --accent-dim: rgba(43, 154, 148, 0.12);
    --accent-glow: rgba(43, 154, 148, 0.3);
    --success: #2b9a94;
    --error: #dc2626;
    --error-dim: rgba(220, 38, 38, 0.1);
    --warning: #d97706;
    --bg: #f5f5f5;
    --bg-raised: #ffffff;
    --bg-input: #f0f0f0;
    --text: #1a1a1a;
    --text-bright: #000000;
    --text-dim: #666666;
    --text-muted: #cccccc;
    --border: #dddddd;
    --bg-card: #ffffff;
}

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

::selection {
    background: var(--accent-dim);
    color: var(--text-bright);
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 24px 100px;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 8px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    height: 52px;
    text-decoration: none;
}

.logo img {
    height: 52px;
    width: auto;
}

.online-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.online-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
    animation: onlinePulse 3s ease-in-out infinite;
}

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

.header-xp {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.xp-bar-wrap {
    width: 100px;
    height: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.header-level {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.75rem;
}

.header-xp-text {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.karma-indicator {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.04em;
    animation: karmaGlow 2s ease-in-out infinite;
}

.karma-indicator.karma-high {
    color: #ff9900;
    animation: karmaGlowHigh 1.2s ease-in-out infinite;
}

@keyframes karmaGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes karmaGlowHigh {
    0%, 100% { opacity: 1; text-shadow: 0 0 6px rgba(255, 153, 0, 0.6); }
    50% { opacity: 0.7; text-shadow: 0 0 12px rgba(255, 153, 0, 0.9); }
}

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

#authArea {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.user-level {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.75rem;
}

.user-name {
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.user-name:hover {
    color: var(--accent);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

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

/* ============================================
   SMALL BUTTONS
   ============================================ */
.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: opacity 0.2s;
}

.btn-sm:hover {
    opacity: 0.85;
}

.btn-accent {
    background: var(--accent);
    color: #000;
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-ui);
    padding: 4px 8px;
}

.btn-link:hover {
    color: var(--text);
}

/* ============================================
   SOUND TOGGLE
   ============================================ */
.sound-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
    position: relative;
}

.sound-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70%;
    height: 1.5px;
    background: var(--error);
    transform: translate(-50%, -50%) rotate(-45deg);
    transition: opacity 0.2s;
    opacity: 1;
}

.sound-toggle:hover {
    color: var(--text-dim);
}
.sound-toggle.active {
    color: var(--accent);
}
.sound-toggle.active::after {
    opacity: 0;
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition:
        color 0.2s,
        transform 0.3s;
}

.theme-toggle:hover {
    color: var(--text-dim);
}

[data-theme="light"] .theme-toggle {
    color: var(--warning);
}

/* Light mode subtle adjustments */
[data-theme="light"] .toast {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .modal-box {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .stat-box {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .ch.incorrect {
    background: rgba(220, 38, 38, 0.08);
}

/* ============================================
   LANGUAGE SELECTOR (Dropdown)
   ============================================ */
.lang-selector {
    position: relative;
}

.lang-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    font-family: var(--font-ui);
    transition: all 0.2s;
}

.lang-dropdown-toggle:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

img.lang-flag {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.lang-dropdown-toggle .lang-flag {
    width: 20px;
    height: 20px;
}

.lang-dropdown-toggle .lang-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.lang-selector.open .lang-dropdown-toggle {
    border-color: var(--accent);
    color: var(--accent);
}

.lang-selector.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-raised);
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    padding: 4px;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
    z-index: 100;
}

[data-theme="light"] .lang-dropdown {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.lang-selector.open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
    font-family: var(--font-ui);
    text-align: left;
    transition: all 0.15s;
}

.lang-option:hover {
    background: var(--accent-dim);
    color: var(--text);
}

.lang-option.active {
    color: var(--accent);
    font-weight: 600;
}

.lang-option .lang-flag {
    width: 22px;
    height: 22px;
    max-width: 22px;
    max-height: 22px;
}

/* ============================================
   NAV TABS (Game / Daily / Leaderboard)
   ============================================ */
.nav-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.nav-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all 0.2s;
}

.nav-tab:hover {
    color: var(--text);
}

.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ============================================
   GAME SECTION — STATUS BAR
   ============================================ */
.status-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.85rem;
}

.status-label {
    color: var(--text-dim);
}

.status-value {
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.status-value.streak {
    color: var(--accent);
}

.status-value.streak.on-fire {
    animation: fireGlow 1.5s ease-in-out infinite;
}

@keyframes fireGlow {
    0%,
    100% {
        text-shadow: 0 0 4px rgba(60, 200, 192, 0.3);
    }
    50% {
        text-shadow:
            0 0 12px rgba(60, 200, 192, 0.6),
            0 0 20px rgba(46, 234, 223, 0.3);
    }
}

/* ============================================
   DIFFICULTY SELECTOR
   ============================================ */
.difficulty-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.diff-btn {
    padding: 5px 14px;
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all 0.15s;
}

.diff-btn:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

.diff-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* ============================================
   LIVE STATS ROW
   ============================================ */
.live-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 12px;
    font-family: var(--font-mono);
}

.live-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.live-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-bright);
    transition: color 0.15s;
    font-variant-numeric: tabular-nums;
    min-width: 3ch;
}

.live-stat-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   TEXT DISPLAY — THE MAIN EVENT
   ============================================ */
.text-area {
    position: relative;
    margin-bottom: 16px;
}

.text-display {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    line-height: 2;
    color: var(--text-muted);
    min-height: 180px;
    max-height: 240px;
    overflow: hidden;
    position: relative;
    outline: none;
    user-select: none;
    cursor: text;
    padding: 4px 0 4px 12px;
    border-left: 2px solid transparent;
    transition:
        border-color 0.3s ease,
        max-height 0.3s;
}

.text-display.typing-active {
    border-left-color: var(--accent);
}

.text-display.diff-hard {
    max-height: 360px;
    min-height: 220px;
}

.text-display.diff-expert,
.text-display.timed-long {
    max-height: 440px;
    min-height: 260px;
}

.text-display.empty {
    color: var(--text-dim);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Text fade-in on new text load */
.text-display.text-fade-in {
    animation: textFadeIn 0.3s ease;
}

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

/* Word wrapper — keeps whole words together on line breaks */
.word {
    display: inline-block;
    white-space: nowrap;
}

/* Character states */
.ch {
    position: relative;
    transition: color 0.05s;
}

.ch.correct {
    color: var(--success);
}

.ch.incorrect {
    color: var(--error);
    background: var(--error-dim);
    border-radius: 2px;
}

.ch.current {
    color: var(--text);
}

/* Blinking cursor — thin vertical bar before current character */
.ch.cursor::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--accent);
    border-radius: 1px;
    animation: cursorBlink 1s step-end infinite;
}

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

/* Current word highlight */
.ch.current-word {
    color: var(--text-dim);
}

/* Progress bar */
.progress-bar {
    height: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

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

/* ============================================
   COMBO DISPLAY
   ============================================ */
.combo-display {
    position: fixed;
    top: 50%;
    right: 32px;
    transform: translateY(-50%);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 50;
}

.combo-display.visible {
    opacity: 1;
}

.combo-count {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    transition:
        transform 0.15s,
        font-size 0.3s,
        color 0.3s;
}

.combo-count.pulse {
    animation: comboPulse 0.25s ease;
}

@keyframes comboPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* Combo escalation */
.combo-display.tier-2 .combo-count {
    font-size: 3rem;
    color: var(--warning);
}
.combo-display.tier-3 .combo-count {
    font-size: 3.5rem;
    color: #2eeadf;
    text-shadow: 0 0 20px rgba(46, 234, 223, 0.5);
}
.combo-display.tier-4 .combo-count {
    font-size: 4rem;
    color: #ffffff;
    text-shadow: 0 0 30px rgba(60, 200, 192, 0.7);
}

.combo-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-dim);
    margin-top: 2px;
}

.combo-multiplier {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 2px;
}

/* ============================================
   COMBO BREAK FLASH
   ============================================ */
.combo-break-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    box-shadow: inset 0 0 80px rgba(255, 68, 68, 0.4);
    opacity: 0;
    transition: opacity 0.05s;
}

.combo-break-flash.active {
    opacity: 1;
}

/* ============================================
   RESTART HINT
   ============================================ */
.restart-hint {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 12px;
    font-family: var(--font-mono);
    opacity: 0;
    animation: hintFadeIn 0.4s ease 1.5s forwards;
}

@keyframes hintFadeIn {
    to {
        opacity: 1;
    }
}

.restart-hint kbd {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.65rem;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    background: var(--bg-raised);
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ============================================
   RESULTS SCREEN
   ============================================ */
.results-screen {
    display: none;
    text-align: center;
    padding: 20px 0 12px;
    animation: fadeInUp 0.3s ease;
}

.results-screen.visible {
    display: block;
}

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

.result-wpm {
    font-family: var(--font-mono);
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
    margin-bottom: 2px;
}

.result-wpm-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.result-delta {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.result-delta.positive {
    color: var(--accent);
}

.result-delta.negative {
    color: var(--text-dim);
}

.result-grade {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 700;
    margin-bottom: 12px;
    animation: gradeIn 0.4s ease;
}

@keyframes gradeIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.grade-splus {
    color: var(--gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}
.grade-s {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}
.grade-a {
    color: var(--accent);
}
.grade-b {
    color: #68d8d0;
}
.grade-c {
    color: var(--text);
}
.grade-d {
    color: var(--text-dim);
}
.grade-f {
    color: var(--error);
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

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

.result-stat-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.result-stat-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* New best indicator */
.new-best {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 3px;
    margin-bottom: 8px;
    animation: bestPulse 1s ease infinite;
}

@keyframes bestPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.result-rank {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.result-heatmap {
    margin-bottom: 12px;
}

.heatmap-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.heatmap-keys {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.heatmap-key {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border);
    position: relative;
}

.heatmap-key .heatmap-ms {
    position: absolute;
    bottom: -14px;
    font-size: 0.55rem;
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
}

.result-xp {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
    animation: xpPop 0.5s ease;
}

.result-xp.karma-xp {
    color: var(--gold);
}

@keyframes xpPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    60% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

.btn-next-test {
    animation: nextTestGlow 2s ease 1s infinite;
}

@keyframes nextTestGlow {
    0%,
    100% {
        box-shadow: none;
    }
    50% {
        box-shadow: 0 0 16px var(--accent-glow);
    }
}

.result-restart-hint {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 16px;
    font-family: var(--font-mono);
}

.result-restart-hint kbd {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.6rem;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    background: var(--bg-raised);
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0);
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-accent {
    background: var(--accent);
    color: #000;
}
.btn-dim {
    background: var(--bg-raised);
    color: var(--text-dim);
    border: 1px solid var(--text-muted);
}
.btn-dim:hover {
    color: var(--text);
    border-color: var(--text-dim);
}
.btn-full {
    width: 100%;
    justify-content: center;
}

/* ============================================
   RANKINGS
   ============================================ */
.game-section,
.leaderboard-section {
    display: none;
}

.game-section.visible,
.leaderboard-section.visible {
    display: block;
}

/* User rank card */
.rank-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.rank-card-position {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    min-width: 70px;
    text-align: center;
}

.rank-card-hash {
    font-size: 1.2rem;
    opacity: 0.5;
    vertical-align: super;
}

.rank-card-info {
    flex: 1;
    min-width: 0;
}

.rank-card-name {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 4px;
}

.rank-card-stats {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.rank-card-stats strong {
    color: var(--text);
    font-family: var(--font-mono);
}

.rank-card-total {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Rankings filters */
.rankings-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

/* Rankings list */
.rankings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rankings-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 6px;
    transition: background 0.15s;
}

.ranking-row:hover {
    background: var(--surface);
}

.ranking-row.is-self {
    background: rgba(60, 200, 192, 0.05);
    border: 1px solid rgba(60, 200, 192, 0.15);
}

.ranking-pos {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    width: 36px;
    text-align: center;
    color: var(--text-muted);
}

.ranking-pos.gold {
    color: var(--gold);
}
.ranking-pos.silver {
    color: var(--silver);
}
.ranking-pos.bronze {
    color: var(--bronze);
}

.ranking-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-level {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 6px;
}

.user-stars {
    color: var(--accent);
    font-size: 0.7em;
    letter-spacing: -1px;
    margin-left: 4px;
}

.user-stars .stars-empty {
    color: rgba(255, 255, 255, 0.15);
}

.ranking-row .user-stars,
.lb-table .user-stars {
    font-size: 0.85em;
}

.ranking-wpm {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    width: 70px;
    text-align: right;
}

.ranking-wpm-label {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 3px;
}

.ranking-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 140px;
    justify-content: flex-end;
}

.rankings-acc-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 16px;
    padding: 10px 16px;
    border: 1px solid var(--text-muted);
    border-radius: 8px;
}

.rankings-acc-hint a {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.lb-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--text-muted);
    font-weight: 600;
}

.lb-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(51, 51, 51, 0.5);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    text-align: left;
}

.lb-table tr:hover td {
    color: var(--text);
}

.lb-table .rank-1 td {
    color: var(--gold);
}
.lb-table .rank-2 td {
    color: var(--silver);
}
.lb-table .rank-3 td {
    color: var(--bronze);
}
.lb-table .current-user td {
    color: var(--accent);
}

.lb-table .rank-col {
    width: 50px;
    text-align: center;
}
.lb-table .wpm-col {
    font-weight: 700;
    font-family: var(--font-mono);
}

.lb-username {
    cursor: pointer;
    transition: color 0.2s;
}

.lb-username:hover {
    color: var(--accent);
}

.lb-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================
   DAILY CHALLENGE CARD (inside game section)
   ============================================ */
.daily-card {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--accent-dim);
    border-radius: 10px;
    padding: 12px 18px;
    margin: 10px 0;
}

.daily-card-info {
    flex: 1;
    min-width: 140px;
}

.daily-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

.daily-card-countdown {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-dim);
}

.daily-card-action .btn-sm {
    padding: 6px 18px;
    font-size: 0.82rem;
}

.daily-card-done {
    display: flex;
    align-items: center;
    gap: 12px;
}

.daily-card-score {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

.daily-card-expand {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-family: var(--font-ui);
    transition: all 0.15s;
}
.daily-card-expand:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.daily-card-lb {
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 4px;
}

/* ============================================
   PROFILE / STATS
   ============================================ */
.profile-section {
    display: none;
}

.profile-section.visible {
    display: block;
}

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

.profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-bright);
}

.profile-level {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.profile-title {
    font-size: 0.8rem;
    color: var(--text-dim);
}

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

.stat-box {
    padding: 16px;
    background: var(--bg-raised);
    border-radius: 6px;
    text-align: center;
}

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

.stat-box-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* ============================================
   ACHIEVEMENTS
   ============================================ */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.achievement-card {
    padding: 12px;
    background: var(--bg-raised);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.achievement-card.unlocked {
    opacity: 1;
}

.achievement-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    filter: grayscale(1);
    transition: filter 0.3s;
}

.achievement-card.unlocked .achievement-icon {
    filter: none;
}

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

.achievement-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.achievement-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* ============================================
   CHALLENGE (FRIEND) SECTION
   ============================================ */
.challenge-vs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    margin: 24px 0;
    flex-wrap: wrap;
}

.challenge-player {
    text-align: center;
    min-width: 140px;
}

.challenge-player-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.challenge-player-wpm {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
}

.challenge-player.winner .challenge-player-wpm {
    color: var(--accent);
}

.challenge-player.loser .challenge-player-wpm {
    color: var(--text-dim);
}

.challenge-vs-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.closing {
    animation: modalOut 0.2s ease forwards;
}

@keyframes modalIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.modal-box {
    background: var(--bg-raised);
    border: 1px solid var(--text-muted);
    border-radius: 8px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    position: relative;
    animation: modalBoxIn 0.2s ease;
}

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

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

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

.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--text-muted);
}

.modal-tab {
    flex: 1;
    padding: 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-ui);
    text-align: center;
    transition: all 0.2s;
}

.modal-tab:hover {
    color: var(--text);
}
.modal-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ============================================
   FORMS
   ============================================ */
.auth-form {
    display: none;
}

.form-group {
    margin-bottom: 12px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color 0.2s;
}

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

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

.form-error {
    color: var(--error);
    font-size: 0.8rem;
    margin-bottom: 12px;
    min-height: 1.2em;
}

.form-forgot {
    margin-top: 12px;
    font-size: 0.8rem;
}

.form-forgot a {
    color: var(--text-dim);
    text-decoration: none;
}

.form-forgot a:hover {
    color: var(--accent);
}

/* ============================================
   SOLO PRACTICE FEATURES
   ============================================ */
.practice-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--text-muted);
    background: none;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.toggle-btn:hover {
    color: var(--text);
    border-color: var(--text);
}

.toggle-btn.active {
    border-color: var(--error);
    color: var(--error);
    background: rgba(255, 80, 80, 0.08);
}

.toggle-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.toggle-check input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.ghost-input-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ghost-label {
    font-size: 0.85rem;
}

.ghost-wpm-input {
    width: 60px;
    padding: 3px 6px;
    background: var(--bg-raised);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-align: center;
}

.ghost-wpm-input:focus {
    outline: none;
    border-color: var(--accent);
}

.ghost-wpm-input::-webkit-inner-spin-button,
.ghost-wpm-input::-webkit-outer-spin-button {
    opacity: 1;
    background: var(--bg-raised);
    border-left: 1px solid var(--border);
    cursor: pointer;
    filter: invert(1) brightness(0.6) sepia(1) hue-rotate(130deg) saturate(4);
}

/* Ghost cursor span */
.ch.ghost-cursor::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 170, 0, 0.75);
    border-radius: 1px;
}

.ch.ghost-cursor {
    position: relative;
}

.text-display.ghost-ahead {
    border-left: 2px solid var(--success);
}

.text-display.ghost-behind {
    border-left: 2px solid var(--error);
}

/* Custom text panel */
.custom-text-panel {
    margin-bottom: 12px;
    background: var(--bg-raised);
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    padding: 12px;
}

.custom-text-area {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 8px 10px;
    resize: vertical;
    display: block;
}

.custom-text-area:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-text-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ============================================
   GUIDE SECTION
   ============================================ */
.guide-section {
    display: none;
    padding: 32px 0 48px;
    max-width: 960px;
    margin: 0 auto;
}

.guide-section.visible {
    display: block;
}

.guide-header {
    text-align: center;
    margin-bottom: 36px;
}

.guide-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 2px;
    margin: 0 0 8px;
}

.guide-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

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

.guide-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s;
}

.guide-card:hover {
    border-color: var(--accent);
}

.guide-card--highlight {
    border-color: rgba(255, 215, 0, 0.35);
    background: linear-gradient(135deg, var(--bg-card) 80%, rgba(255, 215, 0, 0.04));
}

.guide-card--highlight:hover {
    border-color: rgba(255, 215, 0, 0.7);
}

.guide-card-icon {
    font-size: 28px;
    line-height: 1;
}

.guide-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.5px;
}

.guide-card-body {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   PROFILE — CLASSROOM SECTION
   ============================================ */
.profile-class-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.profile-class-desc {
    color: var(--text-dim);
    font-size: 0.88rem;
    margin-bottom: 14px;
    line-height: 1.5;
}

.profile-join-row {
    display: flex;
    gap: 8px;
    align-items: center;
    max-width: 320px;
}

.profile-join-row input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.95rem;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text);
    outline: none;
    text-transform: uppercase;
    transition: border-color 0.2s;
}

.profile-join-row input:focus {
    border-color: var(--accent);
}

.profile-class-error {
    color: var(--error);
    font-size: 0.82rem;
    margin-top: 8px;
}

.profile-class-teacher-cta {
    margin-top: 14px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* ============================================
   SUDDEN DEATH POPUP
   ============================================ */
.sd-popup {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
    background: rgba(10, 10, 10, 0.88);
    backdrop-filter: blur(6px);
    animation: fadeIn 0.15s ease;
}

.sd-popup.hidden {
    display: none;
}

.sd-popup-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 56px;
    background: var(--bg-card);
    border: 1px solid #ff3333;
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(255, 51, 51, 0.25);
    animation: sdPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
}

@keyframes sdPop {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sd-popup-icon {
    font-size: 52px;
    line-height: 1;
    animation: sdShake 0.4s ease 0.1s;
}

@keyframes sdShake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-12deg); }
    40% { transform: rotate(12deg); }
    60% { transform: rotate(-8deg); }
    80% { transform: rotate(6deg); }
}

.sd-popup-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 4px;
    color: #ff3333;
    text-shadow: 0 0 20px rgba(255, 51, 51, 0.5);
}

.sd-popup-sub {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.sd-popup-btn {
    margin-top: 8px;
    padding: 10px 32px;
    background: transparent;
    border: 1px solid #ff3333;
    border-radius: 6px;
    color: #ff3333;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sd-popup-btn:hover {
    background: #ff3333;
    color: #000;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-raised);
    border-left: 3px solid var(--accent);
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text);
    animation:
        toastIn 0.2s ease,
        toastOut 0.2s ease forwards;
    animation-delay: 0s, var(--toast-duration, 3s);
    pointer-events: auto;
    max-width: 320px;
}

.toast.info {
    border-left-color: var(--accent);
}
.toast.success {
    border-left-color: var(--success);
}
.toast.error {
    border-left-color: var(--error);
}
.toast.warning {
    border-left-color: var(--warning);
}
.toast.achievement {
    border-left-color: var(--gold);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================
   ACHIEVEMENT NOTIFICATION (console-style)
   ============================================ */
.achievement-toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.achievement-toast {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-raised);
    border: 1px solid var(--gold);
    border-top: 3px solid var(--gold);
    border-radius: 6px;
    padding: 12px 20px 12px 16px;
    min-width: 280px;
    max-width: 380px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 215, 0, 0.12);
    animation:
        achSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        achFadeOut 0.4s ease forwards;
    animation-delay: 0s, var(--ach-duration, 5s);
    pointer-events: auto;
}

.achievement-toast-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}

.achievement-toast-body {
    min-width: 0;
}

.achievement-toast-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 2px;
}

.achievement-toast-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.achievement-toast-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 1px;
}

.achievement-toast.levelup {
    border-color: var(--accent);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 255, 204, 0.15);
}

.achievement-toast.levelup .achievement-toast-label {
    color: var(--accent);
}

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

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

/* ============================================
   CONFETTI (CSS-only)
   ============================================ */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    top: -10px;
    animation: confettiFall var(--fall-duration, 2.5s) ease-in forwards;
    animation-delay: var(--fall-delay, 0s);
}

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

/* ============================================
   FOOTER
   ============================================ */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 24px;
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    pointer-events: none;
    z-index: 10;
}

.footer-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
}

.footer .online-indicator {
    font-size: 0.7rem;
}

.footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.footer a {
    color: var(--text-dim);
    transition: color 0.2s;
}

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

/* ============================================
   PROFILE SECTION
   ============================================ */
.profile-section {
    display: none;
    padding: 24px 0;
}

.profile-section.visible {
    display: block;
}

.profile-logged-out {
    text-align: center;
    padding: 60px 0;
    color: var(--text-dim);
}

.profile-header {
    margin-bottom: 32px;
}

.profile-username {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    color: var(--text);
    margin: 0 0 4px;
}

.profile-level {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

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

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.profile-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.profile-stat-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.profile-stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-section-title {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 0 16px;
}

.profile-chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 32px;
    position: relative;
    height: 220px;
}

.profile-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    margin-bottom: 32px;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: opacity 0.2s;
}

.achievement-card.locked {
    opacity: 0.35;
}

.achievement-card.unlocked {
    border-color: var(--accent);
}

.achievement-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

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

.achievement-name {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text);
}

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

/* ============================================
   MODE SELECTOR
   ============================================ */
.mode-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.mode-btn {
    padding: 5px 14px;
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all 0.15s;
}

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

.mode-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* ============================================
   COUNTDOWN TIMER
   ============================================ */
.countdown-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-family: var(--font-mono);
}

.countdown-value {
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    transition:
        color 0.5s,
        text-shadow 0.5s;
    text-shadow: 0 0 12px var(--accent-glow);
    min-width: 2.5ch;
    text-align: center;
}

.countdown-value.warning {
    color: #f0a030;
    text-shadow: 0 0 16px rgba(240, 160, 48, 0.4);
}

.countdown-value.urgent {
    color: var(--error);
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
    animation: countdownPulse 0.5s ease infinite;
}

.countdown-value.tick {
    animation: countdownTick 0.3s ease;
}

@keyframes countdownPulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

@keyframes countdownTick {
    0% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

.countdown-label {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-left: 2px;
}

/* ============================================
   RESULT MODE TAG
   ============================================ */
.result-mode-tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 3px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
    letter-spacing: 1px;
}

/* ============================================
   SCREEN SHAKE (typing error)
   ============================================ */
.text-area.shake {
    animation: screenShake 0.15s ease;
}

@keyframes screenShake {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-3px);
    }
    50% {
        transform: translateX(3px);
    }
    75% {
        transform: translateX(-2px);
    }
    100% {
        transform: translateX(0);
    }
}

/* ============================================
   COMBO FLASH TEXT
   ============================================ */
.combo-flash {
    position: fixed;
    top: 50%;
    left: 32px;
    transform: translateY(-50%) scale(0);
    transform-origin: left center;
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 900;
    pointer-events: none;
    z-index: 150;
    text-transform: uppercase;
    letter-spacing: 4px;
    opacity: 0;
    animation: comboFlashIn 0.8s ease forwards;
}

.combo-flash.tier-fire {
    color: var(--warning);
    text-shadow: 0 0 30px rgba(255, 170, 0, 0.6);
}

.combo-flash.tier-unstoppable {
    color: #2eeadf;
    text-shadow: 0 0 40px rgba(46, 234, 223, 0.6);
}

.combo-flash.tier-godlike {
    color: #ffffff;
    text-shadow:
        0 0 40px rgba(255, 215, 0, 0.8),
        0 0 80px rgba(60, 200, 192, 0.4);
}

@keyframes comboFlashIn {
    0% {
        transform: translateY(-50%) scale(0);
        opacity: 0;
    }
    20% {
        transform: translateY(-50%) scale(1.3);
        opacity: 1;
    }
    60% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-60%) scale(0.8);
        opacity: 0;
    }
}

/* ============================================
   SPEED LINES (high combo)
   ============================================ */
.text-area {
    position: relative;
}

.text-area.speed-lines::before,
.text-area.speed-lines::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    animation: speedLineFade 0.3s ease forwards;
}

.text-area.speed-lines::before {
    left: -20px;
    background: linear-gradient(
        to right,
        rgba(60, 200, 192, 0.15),
        transparent
    );
}

.text-area.speed-lines::after {
    right: -20px;
    background: linear-gradient(to left, rgba(60, 200, 192, 0.15), transparent);
}

.text-area.speed-lines-intense::before,
.text-area.speed-lines-intense::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    animation: speedLineFade 0.3s ease forwards;
}

.text-area.speed-lines-intense::before {
    left: -20px;
    background: linear-gradient(to right, rgba(60, 200, 192, 0.3), transparent);
}

.text-area.speed-lines-intense::after {
    right: -20px;
    background: linear-gradient(to left, rgba(60, 200, 192, 0.3), transparent);
}

@keyframes speedLineFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   BACKGROUND PULSE (combo intensity)
   ============================================ */
body.combo-pulse {
    transition: background-color 0.5s ease;
}

body.combo-tier-2 {
    background-color: #0c0e0e;
}

body.combo-tier-3 {
    background-color: #0a1212;
}

body.combo-tier-4 {
    background-color: #0a1414;
    animation: bgPulseIntense 1.5s ease-in-out infinite;
}

@keyframes bgPulseIntense {
    0%,
    100% {
        background-color: #0a1414;
    }
    50% {
        background-color: #0c1818;
    }
}

/* Light theme: subtler bg pulse */
[data-theme="light"] body.combo-tier-2 {
    background-color: #f0f5f5;
}
[data-theme="light"] body.combo-tier-3 {
    background-color: #eaf2f2;
}
[data-theme="light"] body.combo-tier-4 {
    background-color: #e5f0f0;
}

/* ============================================
   LESSONS
   ============================================ */
.lessons-section {
    display: none;
}

.lessons-section.visible {
    display: block;
}

.lessons-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.lessons-title {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: var(--text);
}

.lessons-progress-summary {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.lesson-card {
    padding: 16px;
    background: var(--bg-raised);
    border: 1px solid var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.lesson-card:hover {
    border-color: var(--text-dim);
    transform: translateY(-1px);
}

.lesson-card.completed {
    border-color: var(--accent);
}

.lesson-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.lesson-card.locked:hover {
    transform: none;
    border-color: var(--text-muted);
}

.lesson-card.current {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-dim);
}

.lesson-card-number {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.lesson-card-name {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.lesson-card-keys {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.lesson-card-status {
    font-size: 0.7rem;
    font-weight: 600;
}

.lesson-card.completed .lesson-card-status {
    color: var(--accent);
}

.lesson-card.locked .lesson-card-status {
    color: var(--text-muted);
}

.lesson-card.current .lesson-card-status {
    color: var(--warning);
}

/* Active lesson */
.lesson-active {
    animation: fadeInUp 0.3s ease;
}

.lesson-info {
    text-align: center;
    margin-bottom: 24px;
}

.lesson-info-name {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.lesson-info-keys {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: var(--accent);
    letter-spacing: 6px;
    margin-bottom: 8px;
}

.lesson-info-goal {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.lesson-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
}

.lesson-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

/* ============================================
   RACE HISTORY
   ============================================ */
.race-history {
    margin-bottom: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.race-history-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 32px 0;
}

.race-history-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    font-size: 0.85rem;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(51, 51, 51, 0.4);
}

.race-history-row:last-child {
    border-bottom: none;
}

.race-history-row:hover {
    background: rgba(60, 200, 192, 0.03);
}

.race-history-result {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    width: 44px;
    text-align: center;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.race-history-result.win {
    color: var(--accent);
    background: var(--accent-dim);
}

.race-history-result.loss {
    color: #ff6b6b;
    background: var(--error-dim);
}

.race-history-result.tie {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
}

.race-history-opponent {
    flex: 1;
    color: var(--text);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.race-history-wpm {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text);
    min-width: 80px;
    text-align: right;
}

.race-history-wpm span {
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.race-history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 60px;
    text-align: right;
    flex-shrink: 0;
}

/* ============================================
   RANK BADGES
   ============================================ */
.rank-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
    vertical-align: middle;
    font-family: var(--font-ui);
}

.rank-bronze {
    color: #cd7f32;
    background: rgba(205, 127, 50, 0.12);
}

.rank-silver {
    color: #c0c0c0;
    background: rgba(192, 192, 192, 0.12);
}

.rank-gold {
    color: var(--gold);
    background: rgba(255, 215, 0, 0.12);
}

.rank-diamond {
    color: #b9f2ff;
    background: rgba(185, 242, 255, 0.12);
}

.rank-master {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.12);
}

/* ============================================
   RACE BAR
   ============================================ */
.race-bar {
    margin-bottom: 12px;
}

/* ============================================
   RACE LOBBY
   ============================================ */
.race-lobby {
    text-align: center;
    padding: 48px 0 32px;
    animation: fadeInUp 0.3s ease;
}

.race-lobby-title {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 32px;
}

.race-lobby-players {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    margin-bottom: 32px;
}

.race-lobby-player {
    min-width: 140px;
    text-align: center;
}

.race-lobby-name {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.race-lobby-ready {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    animation: readyPulse 1s ease infinite;
}

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

.race-lobby-vs {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
}

.race-lobby-link {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.race-lobby-link input {
    width: 320px;
    max-width: 60vw;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    outline: none;
}

.race-lobby-link input:focus {
    border-color: var(--accent);
}

.race-lobby .btn {
    margin: 0 6px;
}

/* ============================================
   RACE HUD (opponent progress during race)
   ============================================ */
.race-hud {
    margin-bottom: 16px;
    animation: fadeInUp 0.2s ease;
}

.race-hud-opponent {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.race-hud-opponent-name {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-dim);
}

.race-hud-opponent-wpm {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-muted);
}

.race-hud-opponent-status {
    font-size: 0.75rem;
    color: var(--error);
    font-weight: 600;
}

.race-progress-opponent {
    height: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    overflow: hidden;
}

.race-progress-opponent-fill {
    height: 100%;
    background: var(--text-dim);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ============================================
   RACE COUNTDOWN OVERLAY
   ============================================ */
.race-countdown-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    background: rgba(10, 10, 10, 0.85);
    pointer-events: none;
}

.race-countdown-number {
    font-family: var(--font-mono);
    font-size: 8rem;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 60px var(--accent-glow);
    will-change: transform, opacity;
}

.race-countdown-number.pop {
    animation: raceCountPop 0.8s ease;
}

@keyframes raceCountPop {
    0% {
        transform: scale(2);
        opacity: 0;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
    80% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

/* ============================================
   MATCHMAKING OVERLAY
   ============================================ */
.matchmaking-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 500;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.matchmaking-spinner {
    width: 64px;
    height: 64px;
    border: 3px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mmSpin 1s linear infinite;
    box-shadow: 0 0 20px var(--accent-glow);
}

@keyframes mmSpin {
    to {
        transform: rotate(360deg);
    }
}

.matchmaking-text {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    animation: mmPulse 2s ease-in-out infinite;
}

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

.matchmaking-actions {
    margin-top: 8px;
}

.matchmaking-ghost {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    animation: fadeInUp 0.3s ease;
}

.matchmaking-ghost-text {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--text-dim);
}

/* ============================================
   RACE RESULTS (VS screen)
   ============================================ */
.race-results {
    text-align: center;
    padding: 40px 0 20px;
    animation: fadeInUp 0.3s ease;
}

.race-results-title {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 32px;
}

.race-results-vs {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    margin-bottom: 32px;
}

.race-results-player {
    text-align: center;
    min-width: 160px;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--text-muted);
    background: var(--bg-raised);
}

.race-results-player.winner {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-dim);
}

.race-results-player-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.race-results-player-name {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.race-results-player-wpm {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
}

.race-results-player.winner .race-results-player-wpm {
    color: var(--accent);
}

.race-results-player.loser .race-results-player-wpm {
    color: var(--text-dim);
}

.race-results-player-wpm-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.race-results-player-stats {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.race-results-player-stats span {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text);
}

.race-results-divider {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-muted);
    align-self: center;
    padding-top: 40px;
}

.race-results-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* ============================================
   RACE NOTIFICATION BAR
   ============================================ */
.race-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg-raised);
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 4px 20px rgba(60, 200, 192, 0.2);
    animation: raceNotifSlide 0.3s ease;
}

@keyframes raceNotifSlide {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.race-notification-text {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--text);
}

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

.race-notification-btn {
    animation: raceNotifPulse 1.5s ease infinite;
}

@keyframes raceNotifPulse {
    0%,
    100% {
        box-shadow: none;
    }
    50% {
        box-shadow: 0 0 12px var(--accent-glow);
    }
}

/* ============================================
   HIDDEN UTILITY
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */
.mobile-overlay {
    display: none;
}

@media (max-width: 768px) {
    .mobile-overlay {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: rgba(10, 10, 10, 0.92);
        backdrop-filter: blur(8px);
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 24px;
    }

    .mobile-overlay-content {
        max-width: 320px;
    }

    .mobile-overlay-icon {
        font-size: 3rem;
        margin-bottom: 16px;
    }

    .mobile-overlay-content h2 {
        font-family: "JetBrains Mono", monospace;
        font-size: 1.4rem;
        color: var(--accent);
        margin: 0 0 12px;
    }

    .mobile-overlay-content p {
        color: var(--text-dim);
        font-size: 0.9rem;
        line-height: 1.6;
        margin: 0;
    }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 12px 16px 100px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .text-display {
        font-size: 1.1rem;
        line-height: 1.8;
        min-height: 140px;
        max-height: 200px;
    }

    .live-stats {
        gap: 20px;
    }

    .live-stat-value {
        font-size: 1.4rem;
    }

    .result-wpm {
        font-size: 3.5rem;
    }

    .result-stats {
        gap: 20px;
    }

    .combo-display {
        right: 12px;
        top: auto;
        bottom: 120px;
        transform: none;
    }

    .combo-count {
        font-size: 2rem;
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .profile-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .challenge-vs {
        flex-direction: column;
        gap: 16px;
    }

    .modal-box {
        margin: 16px;
        padding: 24px;
    }

    .nav-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .difficulty-bar {
        flex-wrap: wrap;
    }

    .mode-bar {
        flex-wrap: wrap;
    }

    .countdown-value {
        font-size: 2.2rem;
    }

    .combo-flash {
        font-size: 1.8rem;
    }

    .race-lobby-players {
        flex-direction: column;
        gap: 16px;
    }

    .race-results-vs {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }

    .race-results-divider {
        padding-top: 0;
    }

    .race-countdown-number {
        font-size: 5rem;
    }

    .lb-table {
        font-size: 0.75rem;
    }

    .lb-table th,
    .lb-table td {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .live-stats {
        gap: 12px;
    }

    .live-stat-value {
        font-size: 1.2rem;
    }

    .text-display {
        font-size: 1rem;
    }

    .result-wpm {
        font-size: 3rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
