/* ============================================
   Precision Slice — Premium Minimal UI
   ============================================ */

/* ─── CSS Theme Variables ───────────────────── */
:root {
    --bg: #0A0A0F;
    --bg-overlay: rgba(10, 10, 15, 0.85);
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-modal: rgba(14, 14, 24, 0.98);
    --bg-input: rgba(255, 255, 255, 0.06);
    --bg-btn-primary: rgba(110, 68, 255, 0.15);
    --bg-btn-primary-hover: rgba(110, 68, 255, 0.3);
    --bg-btn-secondary: rgba(255, 255, 255, 0.04);
    --bg-btn-secondary-hover: rgba(255, 255, 255, 0.08);
    --bg-accent: rgba(110, 68, 255, 0.06);
    --bg-dropdown-hover: rgba(110, 68, 255, 0.15);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.75);
    --text-muted: rgba(255, 255, 255, 0.6);
    --text-faint: rgba(255, 255, 255, 0.35);
    --text-placeholder: rgba(255, 255, 255, 0.15);
    --border-default: rgba(255, 255, 255, 0.08);
    --border-card: rgba(255, 255, 255, 0.07);
    --border-input: rgba(255, 255, 255, 0.12);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-muted: rgba(255, 255, 255, 0.1);
    --border-muted-hover: rgba(255, 255, 255, 0.22);
    --border-strong: rgba(255, 255, 255, 0.2);
    --border-strong-hover: rgba(255, 255, 255, 0.4);
    --shadow: rgba(0, 0, 0, 0.5);
    --gradient-start: #FFFFFF;
}

[data-theme="light"] {
    --bg: #F0EEFF;
    --bg-overlay: rgba(240, 238, 255, 0.92);
    --bg-card: rgba(110, 68, 255, 0.04);
    --bg-card-hover: rgba(110, 68, 255, 0.08);
    --bg-modal: rgba(248, 246, 255, 0.98);
    --bg-input: rgba(110, 68, 255, 0.06);
    --bg-btn-primary: rgba(110, 68, 255, 0.12);
    --bg-btn-primary-hover: rgba(110, 68, 255, 0.25);
    --bg-btn-secondary: rgba(110, 68, 255, 0.04);
    --bg-btn-secondary-hover: rgba(110, 68, 255, 0.1);
    --bg-accent: rgba(110, 68, 255, 0.06);
    --bg-dropdown-hover: rgba(110, 68, 255, 0.1);
    --text-primary: #1A0A3C;
    --text-secondary: rgba(26, 10, 60, 0.75);
    --text-muted: rgba(26, 10, 60, 0.6);
    --text-faint: rgba(26, 10, 60, 0.35);
    --text-placeholder: rgba(26, 10, 60, 0.2);
    --border-default: rgba(110, 68, 255, 0.15);
    --border-card: rgba(110, 68, 255, 0.12);
    --border-input: rgba(110, 68, 255, 0.25);
    --border-subtle: rgba(110, 68, 255, 0.08);
    --border-muted: rgba(110, 68, 255, 0.2);
    --border-muted-hover: rgba(110, 68, 255, 0.4);
    --border-strong: rgba(110, 68, 255, 0.2);
    --border-strong-hover: rgba(110, 68, 255, 0.45);
    --shadow: rgba(110, 68, 255, 0.12);
    --gradient-start: #2D1266;
}

/* ─── Reset ─────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── App Container ─────────────────────────── */
#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ─── Canvas ────────────────────────────────── */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* ─── Header Bar ────────────────────────────── */
.header-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 16px 24px;
    z-index: 200;
    pointer-events: none;
    border-bottom: 1px solid var(--border-default);
}

.header-bar.hidden {
    display: none;
}

.header-title {
    font-size: 22px;
    font-weight: 200;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--gradient-start) 0%, #A78BFA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.3s ease;
    user-select: none;
}

.header-title:hover {
    opacity: 0.8;
}

.header-streak {
    margin-left: auto;
    margin-right: 0;
}

.header-streak:not(:empty) {
    margin-right: 14px;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.header-username {
    margin-left: 0;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    pointer-events: auto;
    user-select: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.header-username:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
    border-radius: 2px;
}

.header-username:hover {
    color: var(--text-muted);
}

/* ─── HUD ───────────────────────────────────── */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 80px;
    padding-bottom: 24px;
    padding-left: 24px;
    padding-right: 24px;
    pointer-events: none;
    z-index: 10;
}

#timer {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    text-shadow: 0 0 20px rgba(110, 68, 255, 0.3);
}

/* ─── Overlays ──────────────────────────────── */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    z-index: 100;
    transition: opacity 0.4s ease-out;
}

.overlay.hidden {
    display: none;
    opacity: 0;
}

/* ─── Menu Screen ───────────────────────────── */
.menu-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
    padding-bottom: 56px; /* clear fixed footer */
}

/* Soft drifting halo sits behind the wordmark to invite the eye in */
.menu-content::before {
    content: "";
    position: absolute;
    width: 520px; height: 520px;
    left: 50%; top: -180px;
    transform: translateX(-50%);
    background: radial-gradient(circle at center,
        rgba(167, 139, 250, 0.22) 0%,
        rgba(110, 68, 255, 0.10) 30%,
        transparent 60%);
    z-index: -1;
    animation: menuHalo 5.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes menuHalo {
    0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
    50%      { opacity: 1.0; transform: translateX(-50%) scale(1.08); }
}

/* ─── Persistent Footer ─────────────────────── */
.menu-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 32px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-default);
    background: var(--bg);
    z-index: 150;
    pointer-events: none;
}

.footer-link {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    pointer-events: auto;
    padding: 10px 4px;
}

.footer-link:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
    border-radius: 2px;
}

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

.title {
    font-size: 56px;
    font-weight: 200;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, #A78BFA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 40px rgba(167, 139, 250, 0.25));
}

.subtitle {
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.6;
}

/* ─── Score Screen ──────────────────────────── */
.score-content {
    text-align: center;
}

.score-category {
    font-size: 28px;
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #A78BFA;
    margin-bottom: 12px;
    text-shadow: 0 0 30px rgba(167, 139, 250, 0.5);
    min-height: 38px;
    opacity: 0;
}

/* ── Tier colours ── */
.score-category[data-tier="poor"]       { color: #6B7280; text-shadow: 0 0 12px rgba(107, 114, 128, 0.3); }
.score-category[data-tier="okay"]       { color: #FBBF24; text-shadow: 0 0 20px rgba(251, 191, 36, 0.4); }
.score-category[data-tier="good"]       { color: #34D399; text-shadow: 0 0 24px rgba(52, 211, 153, 0.5); }
.score-category[data-tier="great"]      { color: #60A5FA; text-shadow: 0 0 28px rgba(96, 165, 250, 0.55); }
.score-category[data-tier="incredible"] { color: #C4B5FD; text-shadow: 0 0 34px rgba(196, 181, 253, 0.65); }
.score-category[data-tier="perfect"]    { color: #FCD34D; text-shadow: 0 0 40px rgba(252, 211, 77, 0.8), 0 0 80px rgba(252, 211, 77, 0.4); }

/* ── Tier animations ── */
.score-category[data-tier="poor"].reveal       { animation: poorPunch      0.50s ease-out            forwards; }
.score-category[data-tier="okay"].reveal       { animation: okayPunch      0.45s ease-out            forwards; }
.score-category[data-tier="good"].reveal       { animation: goodPunch      0.50s ease-out            forwards; }
.score-category[data-tier="great"].reveal      { animation: greatPunch     0.55s ease-out            forwards; }
.score-category[data-tier="incredible"].reveal { animation: incrediblePunch 0.60s ease-out           forwards; }
.score-category[data-tier="perfect"].reveal    { animation: perfectPunch   0.70s ease-out            forwards; }

/* fallback if tier not set */
.score-category:not([data-tier]).reveal,
.score-category[data-tier=""].reveal {
    animation: okayPunch 0.45s ease-out forwards;
}

/* POOR — weak thud, barely shakes */
@keyframes poorPunch {
    0%   { opacity: 0; transform: scale(1.5); }
    40%  { opacity: 1; transform: scale(0.96); }
    60%  { transform: scale(1.02) translateX(-3px); }
    78%  { transform: scale(1)    translateX(3px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}

/* OKAY — light punch, one small shake */
@keyframes okayPunch {
    0%   { opacity: 0; transform: scale(2); }
    28%  { opacity: 1; transform: scale(0.92); }
    42%  { transform: scale(1.04) translateX(-5px); }
    57%  { transform: scale(1)    translateX(5px); }
    72%  { transform:             translateX(-3px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}

/* GOOD — medium punch, two shakes */
@keyframes goodPunch {
    0%   { opacity: 0; transform: scale(2.2); }
    22%  { opacity: 1; transform: scale(0.88); }
    35%  { transform: scale(1.06) translateX(-7px); }
    48%  { transform:             translateX(7px); }
    61%  { transform:             translateX(-4px); }
    75%  { transform:             translateX(4px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}

/* GREAT — strong punch, three shakes */
@keyframes greatPunch {
    0%   { opacity: 0; transform: scale(2.5); }
    18%  { opacity: 1; transform: scale(0.85); }
    30%  { transform: scale(1.08) translateX(-9px); }
    42%  { transform:             translateX(9px); }
    53%  { transform:             translateX(-5px); }
    64%  { transform:             translateX(5px); }
    76%  { transform:             translateX(-2px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}

/* INCREDIBLE — heavy punch, four shakes + lingering glow */
@keyframes incrediblePunch {
    0%   { opacity: 0; transform: scale(3); }
    15%  { opacity: 1; transform: scale(0.82); }
    26%  { transform: scale(1.10) translateX(-12px); }
    37%  { transform:             translateX(12px); }
    48%  { transform:             translateX(-7px); }
    58%  { transform:             translateX(7px); }
    68%  { transform:             translateX(-3px); }
    78%  { transform:             translateX(3px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}

/* PERFECT CUT — maximum drama */
@keyframes perfectPunch {
    0%   { opacity: 0; transform: scale(3.5); }
    12%  { opacity: 1; transform: scale(0.78); }
    22%  { transform: scale(1.15) translateX(-16px); }
    33%  { transform:             translateX(16px); }
    43%  { transform:             translateX(-10px); }
    53%  { transform:             translateX(10px); }
    62%  { transform:             translateX(-6px); }
    71%  { transform:             translateX(6px); }
    80%  { transform:             translateX(-2px); }
    89%  { transform:             translateX(2px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}

.score-value {
    font-size: 72px;
    font-weight: 100;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-shadow: 0 0 40px rgba(110, 68, 255, 0.3);
}

.score-split {
    font-size: 13px;
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 24px;
    min-height: 18px;
    font-variant-numeric: tabular-nums;
}

/* ─── Buttons ───────────────────────────────── */
.btn-primary {
    padding: 14px 48px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-primary);
    background: var(--bg-btn-primary);
    border: 1px solid rgba(110, 68, 255, 0.4);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
}

.btn-primary:hover {
    background: var(--bg-btn-primary-hover);
    border-color: rgba(110, 68, 255, 0.8);
    box-shadow: 0 0 30px rgba(110, 68, 255, 0.2);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(110, 68, 255, 0.05);
    border-color: rgba(110, 68, 255, 0.15);
}

/* ─── Hero CTA — menu Start button ─────────────── */
.btn-hero {
    padding: 18px 80px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: #FFFFFF;
    background: rgba(110, 68, 255, 0.32);
    border: 1px solid rgba(167, 139, 250, 0.8);
    border-radius: 6px;
    cursor: pointer;
    box-shadow:
        0 0 32px rgba(110, 68, 255, 0.35),
        0 0 80px rgba(110, 68, 255, 0.20),
        inset 0 0 24px rgba(167, 139, 250, 0.18);
    animation: heroPulse 2.4s ease-in-out infinite;
    position: relative;
    transition: transform 0.15s ease, background 0.2s ease;
}

.btn-hero:hover {
    background: rgba(110, 68, 255, 0.45);
    border-color: rgba(196, 181, 253, 1);
    animation-play-state: paused;
    box-shadow:
        0 0 48px rgba(167, 139, 250, 0.55),
        0 0 100px rgba(110, 68, 255, 0.30),
        inset 0 0 32px rgba(196, 181, 253, 0.30);
}

.btn-hero:active { transform: scale(0.97); }

.btn-hero:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
}

@keyframes heroPulse {
    0%, 100% {
        box-shadow:
            0 0 32px rgba(110, 68, 255, 0.35),
            0 0 80px rgba(110, 68, 255, 0.20),
            inset 0 0 24px rgba(167, 139, 250, 0.18);
    }
    50% {
        box-shadow:
            0 0 44px rgba(167, 139, 250, 0.55),
            0 0 110px rgba(110, 68, 255, 0.35),
            inset 0 0 32px rgba(196, 181, 253, 0.28);
    }
}

/* ─── Stats Panel + Action Container ─────────── */
.stats-and-action {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    width: fit-content;
    min-width: 240px;
}

.stats-and-action .stats-panel {
    display: block;
    width: 100%;
}

.stats-and-action .btn-hero {
    text-align: center;
}

/* ─── Stats Panel (Menu) ────────────────────── */
.stats-panel {
    display: inline-block;
    padding: 16px 32px;
    background: var(--bg-accent);
    border: 1px solid rgba(110, 68, 255, 0.15);
    border-radius: 6px;
    min-width: 240px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.stat-row + .stat-row {
    border-top: 1px solid var(--border-subtle);
}

.stat-label {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.today-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(167, 139, 250, 0.7);
    padding-bottom: 6px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(110, 68, 255, 0.15);
}

.stat-divider {
    margin: 8px 0;
    border-top: 1px solid rgba(110, 68, 255, 0.25);
}

/* ─── Score Details + Action Container ──────── */
.score-and-action {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    width: fit-content;
    min-width: 240px;
}

.score-and-action .stats-panel {
    display: block;
    width: 100%;
}

.score-and-action .btn-hero {
    text-align: center;
}

.score-and-action .btn-share {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

/* ─── PERFECT CUT Flash Overlay ─────────────── */
.perfect-flash {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center,
        rgba(255, 215, 0, 0.25) 0%,
        rgba(255, 215, 0, 0.08) 40%,
        transparent 70%);
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.perfect-flash.active {
    opacity: 1;
}

.perfect-flash.hidden {
    display: none;
}

/* ─── PERFECT CUT Text Overlay ──────────────── */
.perfect-cut-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 60;
    pointer-events: none;
}

.perfect-cut-overlay.hidden {
    display: none;
}

.perfect-cut-text {
    font-size: 42px;
    font-weight: 200;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: #FFD700;
    text-shadow:
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 60px rgba(255, 215, 0, 0.4),
        0 0 100px rgba(255, 215, 0, 0.2);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.perfect-cut-text.reveal {
    opacity: 1;
    transform: scale(1);
}

.perfect-cut-text.fade-out {
    opacity: 0;
    transform: scale(1.1);
    transition: opacity 0.5s ease-in, transform 0.5s ease-in;
}

/* ─── Utilities ─────────────────────────────── */
.hidden {
    display: none !important;
}

/* ─── Leaderboard Button (Menu) ─────────────── */
.btn-secondary {
    padding: 14px 48px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-btn-secondary);
    border: 1px solid var(--border-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
}

.btn-secondary:hover {
    background: var(--bg-btn-secondary-hover);
    border-color: var(--border-muted-hover);
    color: var(--text-secondary);
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* ─── View Leaderboard Link (Score Screen) ───── */
.view-leaderboard-link {
    font-size: 11px;
    color: #A78BFA;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 12px;
    transition: color 0.2s ease;
    background: none;
    border: none;
    font-family: inherit;
}

.view-leaderboard-link:hover {
    color: #c4b5fd;
}

.view-leaderboard-link:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ─── Leaderboard Screen ─────────────────────── */
.lb-content {
    text-align: center;
    width: 100%;
    max-width: 380px;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.lb-header {
    font-size: 13px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.lb-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
}

.lb-tab {
    flex: 1;
    padding: 8px;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lb-tab:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 2px;
}

.lb-tab.active {
    background: rgba(110, 68, 255, 0.2);
    border-color: rgba(110, 68, 255, 0.4);
    color: var(--text-primary);
}

.lb-tab:hover:not(.active) {
    background: var(--bg-card-hover);
    color: var(--text-muted);
}

.lb-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(110, 68, 255, 0.3) transparent;
}

.lb-entries::-webkit-scrollbar {
    width: 4px;
}

.lb-entries::-webkit-scrollbar-track {
    background: transparent;
}

.lb-entries::-webkit-scrollbar-thumb {
    background: rgba(110, 68, 255, 0.3);
    border-radius: 2px;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 10px;
    text-align: left;
}

.lb-entry.player-row {
    background: rgba(110, 68, 255, 0.08);
    border: 1px solid rgba(110, 68, 255, 0.25);
}

.lb-entry.player-row .lb-name,
.lb-entry.player-row .lb-score {
    color: #c4b5fd;
}

.lb-medal {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.lb-rank {
    font-size: 13px;
    color: var(--text-muted);
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.lb-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-rounds {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 8px;
    flex-shrink: 0;
    min-width: 24px;
    text-align: right;
}

.lb-score {
    font-size: 14px;
    font-weight: 300;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.lb-message {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 40px 0;
    margin: 0;
}

.lb-retry-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.2s ease;
}

.lb-retry-btn:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 2px;
}

.lb-retry-btn:hover {
    border-color: var(--border-strong-hover);
    color: var(--text-secondary);
}

/* ─── Name Prompt Modal ──────────────────────── */
.name-prompt-modal {
    width: 300px;
    background: rgba(14, 12, 30, 0.90);
    border: 1px solid var(--border-muted);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    backdrop-filter: blur(20px);
}

.name-prompt-icon {
    font-size: 22px;
    margin-bottom: 10px;
    color: rgba(167, 139, 250, 0.9);
}

.name-prompt-headline {
    font-size: 16px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.name-prompt-subline {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 22px;
    line-height: 1.5;
}

.name-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    outline: none;
    margin-bottom: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.name-input::placeholder {
    color: var(--text-faint);
}

.name-input:focus,
.name-input:focus-visible {
    border-color: rgba(167, 139, 250, 0.8);
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.25);
}

.name-input.shake {
    animation: inputShake 0.4s ease;
}

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

.btn-skip {
    display: block;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    margin: 10px auto 0;
    letter-spacing: 0.05em;
    transition: color 0.2s ease;
}

.btn-skip:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
    border-radius: 2px;
}

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

/* ─── Share Replay Button ───────────────────── */
.btn-share {
    display: block;
    background: none;
    border: 1px solid var(--border-muted);
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.btn-share:hover {
    border-color: var(--border-muted-hover);
    color: var(--text-secondary);
}

.btn-share:active {
    transform: scale(0.98);
}

.btn-share:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
}

/* ─── Toast Notification ────────────────────── */
.toast {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(110, 68, 255, 0.92);
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 13px;
    letter-spacing: 0.06em;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.toast.visible {
    opacity: 1;
}

/* ─── Replay End Screen ─────────────────────── */
.replay-end-label {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.name-prompt-footer {
    font-size: 10px;
    color: var(--text-placeholder);
    margin-top: 14px;
}

/* Name prompt uses full-width primary button */
.name-prompt-modal .btn-primary {
    width: 100%;
    padding: 11px;
    display: block;
    margin-bottom: 8px;
}

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

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

/* ─── Username Dropdown ─────────────────────── */
.username-dropdown {
    position: absolute;
    top: 52px;
    right: 24px;
    min-width: 160px;
    background: var(--bg-modal);
    border: 1px solid var(--border-muted);
    border-radius: 10px;
    padding: 6px;
    z-index: 300;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px var(--shadow);
    animation: dropdownIn 0.15s ease-out;
}

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

.username-dropdown.hidden {
    display: none;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

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

.dropdown-item:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: -2px;
    border-radius: 6px;
}

/* ─── Profile Screen ────────────────────────── */
/* ─── Profile Screen Fullscreen ─────────────── */
.profile-screen-fullscreen {
    align-items: flex-start;
    justify-content: flex-start;
    overflow-y: auto;
    top: 57px;   /* below fixed header bar */
    bottom: 60px; /* above fixed footer bar */
    padding: 0;
}

.profile-content {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ─── Profile Top Bar ───────────────────────── */
.profile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 0 8px;
    border-bottom: 1px solid rgba(110, 68, 255, 0.12);
}

.profile-back-btn {
    background: rgba(110, 68, 255, 0.12);
    border: 1px solid rgba(110, 68, 255, 0.3);
    border-radius: 6px;
    color: rgba(167, 139, 250, 0.9);
    font-family: inherit;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    padding: 6px 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.profile-back-btn:hover {
    background: rgba(110, 68, 255, 0.25);
    border-color: rgba(110, 68, 255, 0.6);
    color: #c4b5fd;
}

.profile-back-btn:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 2px;
}

.profile-avatar {
    font-size: 28px;
    color: rgba(167, 139, 250, 0.9);
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(110, 68, 255, 0.1);
    border-radius: 50%;
    border: 1px solid rgba(110, 68, 255, 0.2);
}

.profile-identity {
    flex: 1;
    min-width: 0;
}

.profile-username {
    font-size: 16px;
    font-weight: 300;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-anon-id {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-edit-btn {
    background: rgba(110, 68, 255, 0.12);
    border: 1px solid rgba(110, 68, 255, 0.3);
    border-radius: 6px;
    color: rgba(167, 139, 250, 0.9);
    font-family: inherit;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 6px 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.profile-edit-btn:hover {
    background: rgba(110, 68, 255, 0.25);
    border-color: rgba(110, 68, 255, 0.6);
    color: #c4b5fd;
}

.profile-edit-btn:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 2px;
}

/* ─── Profile Stats Grid ────────────────────── */
.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
}

.profile-stat-card {
    background: rgba(110, 68, 255, 0.06);
    border: 1px solid rgba(110, 68, 255, 0.20);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    transition: border-color 0.2s ease;
    box-shadow: 0 0 16px rgba(110, 68, 255, 0.06) inset;
}

.profile-stat-card:hover {
    border-color: rgba(110, 68, 255, 0.35);
}

.profile-stat-value {
    font-size: 22px;
    font-weight: 200;
    margin-bottom: 5px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, #A78BFA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.40));
}

.profile-stat-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ─── Profile Meta ──────────────────────────── */
.profile-meta {
    width: 100%;
    text-align: center;
}

.profile-meta span {
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

/* ─── Profile Section Title ─────────────────── */
.profile-section-title {
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 10px;
}

/* ─── Profile Chart ─────────────────────────── */
.profile-chart-section {
    width: 100%;
}

.profile-chart-container {
    position: relative;
    width: 100%;
    height: 180px;
    background: rgba(110, 68, 255, 0.04);
    border: 1px solid rgba(110, 68, 255, 0.15);
    border-radius: 10px;
    padding: 12px;
    box-sizing: border-box;
}

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

.profile-chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    pointer-events: none;
}

/* ─── Profile History ───────────────────────── */
.profile-history-section {
    width: 100%;
}

.profile-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.profile-history-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    padding: 9px 12px;
    transition: border-color 0.2s ease;
}

.profile-history-entry:hover {
    border-color: rgba(110, 68, 255, 0.25);
}

.profile-history-score {
    font-size: 15px;
    font-weight: 200;
    background: linear-gradient(135deg, var(--gradient-start) 0%, #A78BFA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 52px;
}

.profile-history-category {
    flex: 1;
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.profile-history-accuracy {
    font-size: 11px;
    font-weight: 300;
    color: var(--text-faint);
    letter-spacing: 0.05em;
    min-width: 38px;
    text-align: right;
}

.profile-history-copy-btn {
    background: rgba(110, 68, 255, 0.12);
    border: 1px solid rgba(110, 68, 255, 0.3);
    border-radius: 5px;
    color: rgba(167, 139, 250, 0.9);
    font-family: inherit;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.profile-history-copy-btn:hover {
    background: rgba(110, 68, 255, 0.25);
    border-color: rgba(110, 68, 255, 0.6);
    color: #c4b5fd;
}

.profile-history-copy-btn:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 2px;
}

.profile-history-empty {
    font-size: 11px;
    color: var(--text-faint);
    text-align: center;
    padding: 14px 0;
    letter-spacing: 0.06em;
}

/* ─── Theme Toggle ──────────────────────────── */
.theme-toggle {
    position: absolute;
    right: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
    line-height: 0;
    pointer-events: auto;
}

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

.theme-toggle:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.9);
    outline-offset: 3px;
    border-radius: 2px;
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
}

/* ─── Touch device cursor reset ─────────────── */
@media (pointer: coarse) {
    #game-canvas {
        cursor: default;
    }
}

/* ─── Tablet Breakpoint ──────────────────────── */
@media (max-width: 768px) {
    .title {
        font-size: 44px;
    }

    .lb-content {
        max-width: 480px;
        padding: 0 20px;
    }

    .profile-content {
        max-width: 480px;
        padding: 0 20px 40px;
    }

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

    .lb-tab {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ─── Mobile Responsive Breakpoint ──────────── */
@media (max-width: 480px) {
    .header-bar {
        padding: 10px 16px;
    }

    .menu-footer {
        gap: 16px;
    }

    .title {
        font-size: 36px;
    }

    .btn-hero {
        padding: 16px 48px;
    }

    .btn-primary {
        padding: 14px 32px;
        min-height: 44px;
    }

    .lb-tab {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .lb-content {
        max-width: 100%;
        padding: 0 12px;
    }

    .name-prompt-modal {
        width: min(300px, 90vw);
    }

    .profile-content {
        max-width: 100%;
        padding: 0 12px 40px;
    }

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

/* ─── Profile Protect Section ───────────────── */
.profile-protect-section {
    width: 100%;
    padding: 16px 0 4px;
    border-top: 1px solid rgba(110, 68, 255, 0.1);
}

.protect-hint {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 0.04em;
    margin: 0 0 10px;
}

.protect-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.protect-email-input {
    flex: 1;
    background: rgba(110, 68, 255, 0.06);
    border: 1px solid rgba(110, 68, 255, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.protect-email-input::placeholder {
    color: var(--text-faint);
}

.protect-email-input:focus {
    border-color: rgba(110, 68, 255, 0.5);
}

.protect-status {
    font-size: 12px;
    letter-spacing: 0.03em;
    line-height: 1.5;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 6px;
}

.protect-status-ok {
    color: rgba(167, 139, 250, 1);
    background: rgba(110, 68, 255, 0.12);
    border: 1px solid rgba(110, 68, 255, 0.25);
}

.protect-status-error {
    color: rgba(255, 120, 120, 1);
    background: rgba(255, 80, 80, 0.08);
    border: 1px solid rgba(255, 80, 80, 0.2);
}

.protect-linked-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.protect-linked-email {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.protect-badge {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(167, 139, 250, 0.9);
    background: rgba(110, 68, 255, 0.12);
    border: 1px solid rgba(110, 68, 255, 0.25);
    border-radius: 4px;
    padding: 3px 7px;
}

.protect-divider {
    border: none;
    border-top: 1px solid rgba(110, 68, 255, 0.1);
    margin: 14px 0;
}
