@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

/* ══════════════════════════════════════════════════
   CUSTOM TOOLTIP SYSTEM
   Works on desktop (hover) and mobile (tap)
   Usage: data-tooltip="text" on any element
   ══════════════════════════════════════════════════ */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.88);
    background: rgba(18, 18, 38, 0.97);
    color: #eeeaf8;
    font-family: 'Outfit', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 7px;
    border: 1px solid rgba(139, 92, 246, 0.35);
    box-shadow: 0 4px 18px rgba(0,0,0,0.55), 0 0 0 1px rgba(139,92,246,0.12);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.34,1.4,.64,1);
    z-index: 999;
    max-width: 200px;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
}
/* Arrow */
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(18, 18, 38, 0.97);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
    z-index: 999;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip].tooltip-visible::after,
[data-tooltip].tooltip-visible::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
/* Tooltip that opens downward (for top-bar items near top edge) */
[data-tooltip-down]::after {
    bottom: auto;
    top: calc(100% + 8px);
}
[data-tooltip-down]::before {
    bottom: auto;
    top: calc(100% + 3px);
    border-top-color: transparent;
    border-bottom-color: rgba(18, 18, 38, 0.97);
}



/* ══════════════════════════════════════════════════
   TOKENS
══════════════════════════════════════════════════ */
:root {
    color-scheme: dark;

    /* Base */
    --bg:          #04040e;
    --surface:     rgba(10, 10, 24, 0.88);
    --surface-md:  rgba(14, 14, 30, 0.92);
    --surface-hi:  rgba(18, 18, 38, 0.96);
    --line:        rgba(255, 255, 255, 0.08);
    --line-accent: rgba(139, 92, 246, 0.28);
    --text:        #eeeaf8;
    --muted:       #8882aa;
    --dim:         #4e4a6a;

    /* Brand */
    --violet:        #8b5cf6;
    --violet-lt:     #a78bfa;
    --violet-glow:   rgba(139, 92, 246, 0.4);
    --violet-soft:   rgba(139, 92, 246, 0.1);

    /* Phase colours */
    --c-idle:     #eeeaf8;
    --c-approach: #fbbf24;
    --c-warm:     #f97316;
    --c-hot:      #06d6f5;
    --c-critical: #34d399;
    --c-miss:     #f87171;

    --glow-idle:     rgba(139, 92, 246, 0.25);
    --glow-approach: rgba(251, 191, 36, 0.35);
    --glow-warm:     rgba(249, 115, 22, 0.35);
    --glow-hot:      rgba(6, 214, 245, 0.4);
    --glow-critical: rgba(52, 211, 153, 0.45);

    /* UI */
    --gold:  #fbbf24;
    --green: #34d399;
    --red:   #f87171;
    --pink:  #f472b6;

    --radius:    16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow:    0 24px 80px rgba(0,0,0,0.75), 0 0 0 1px var(--line);
}

/* ══════════════════════════════════════════════════
   RESET
══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }
html, body { 
    height: 100%; 
    min-height: 100%; 
    max-height: 100%;
}
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; cursor: pointer; }

/* ══════════════════════════════════════════════════
   BODY & BACKGROUND
══════════════════════════════════════════════════ */
body.pi-page {
    overflow-x: hidden;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(139,92,246,0.13) 0%, transparent 55%),
        radial-gradient(ellipse 70% 55% at 85% 85%, rgba(6,214,245,0.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(52,211,153,0.04) 0%, transparent 60%);
    color: var(--text);
    font-family: 'Outfit', ui-sans-serif, system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background-image 600ms ease;
}

/* Phase background pulse */
body.pi-page[data-phase="hot"] {
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(6,214,245,0.1) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 20% 80%, rgba(139,92,246,0.07) 0%, transparent 50%);
}
body.pi-page[data-phase="critical"] {
    background-image:
        radial-gradient(ellipse 90% 70% at 50% 40%, rgba(52,211,153,0.13) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 20%, rgba(6,214,245,0.06) 0%, transparent 50%);
}

/* ══════════════════════════════════════════════════
   FLOATING π SYMBOLS
══════════════════════════════════════════════════ */
.pi-bg {
    position: fixed; inset: 0;
    pointer-events: none; z-index: 0; overflow: hidden;
}
.pi-bg span {
    position: absolute;
    font-family: 'Space Mono', monospace; font-weight: 700;
    color: rgba(139, 92, 246, 0.065);
    user-select: none;
    animation: floatPi linear infinite;
}
@keyframes floatPi {
    0%   { transform: translateY(110vh) rotate(-15deg); opacity: 0; }
    8%   { opacity: 1; }
    92%  { opacity: 1; }
    100% { transform: translateY(-15vh) rotate(20deg); opacity: 0; }
}

/* ══════════════════════════════════════════════════
   CANVAS (particles)
══════════════════════════════════════════════════ */
.fx-canvas {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
}

/* ══════════════════════════════════════════════════
   SHELL LAYOUT
══════════════════════════════════════════════════ */
.game-shell {
    position: relative; z-index: 1;
    width: min(1240px, calc(100% - 28px));
    min-height: 100svh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 370px;
    gap: 18px;
    align-items: center;
    padding: 22px 0;
}

/* ══════════════════════════════════════════════════
   GLASS PANEL BASE
══════════════════════════════════════════════════ */
.game-stage,
.leaderboard-panel,
.win-modal .modal-content,
.welcome-modal .modal-content,
.history-modal .modal-content {
    border: 1px solid var(--line);
    background: linear-gradient(175deg, rgba(14,14,28,0.9) 0%, rgba(6,6,18,0.95) 100%);
    box-shadow: var(--shadow);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
}

/* ══════════════════════════════════════════════════
   GAME STAGE
══════════════════════════════════════════════════ */
.game-stage {
    border-radius: var(--radius);
    min-height: min(860px, calc(100svh - 44px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color 500ms ease, box-shadow 500ms ease;
}

/* Phase border glow */
body[data-phase="approach"] .game-stage { border-color: rgba(251,191,36,0.22); }
body[data-phase="warm"]     .game-stage { border-color: rgba(249,115,22,0.28); }
body[data-phase="hot"]      .game-stage { border-color: rgba(6,214,245,0.32); box-shadow: 0 0 60px rgba(6,214,245,0.08), var(--shadow); }
body[data-phase="critical"] .game-stage {
    border-color: rgba(52,211,153,0.45);
    box-shadow: 0 0 80px rgba(52,211,153,0.14), var(--shadow);
    animation: stageBorderPulse 0.4s ease-in-out infinite alternate;
}
@keyframes stageBorderPulse {
    from { box-shadow: 0 0 50px rgba(52,211,153,0.1), var(--shadow); }
    to   { box-shadow: 0 0 100px rgba(52,211,153,0.22), var(--shadow); }
}

/* ── STATS BAR ───────────────────────────────── */
.stats-bar {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    background: rgba(139, 92, 246, 0.04);
    flex-shrink: 0;
}
.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 9px 6px;
    border-right: 1px solid var(--line);
    min-width: 0;
    transition: background 200ms;
}
.stat-item:last-child { border-right: none; }
.stat-item:hover { background: rgba(139, 92, 246, 0.07); }
.stat-label {
    color: var(--dim);
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    white-space: nowrap;
}
.stat-value {
    color: var(--text);
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.stat-value.is-gold  { color: var(--gold); }
.stat-value.is-green { color: var(--green); }

/* ── BRAND ROW ───────────────────────────────── */
.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.brand-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.lang-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}
.lang-selector-wrapper:hover {
    background: rgba(255, 255, 255, 0.15);
}
.lang-dropdown {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.home-link {
    text-decoration: none;
    font-weight: 900;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #a78bfa, #06d6f5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}
.brand-actions { display: flex; align-items: center; gap: 8px; }
.target-pill {
    color: var(--gold);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 999px;
    padding: 4px 11px;
    background: rgba(251, 191, 36, 0.07);
    white-space: nowrap;
}
.quick-share-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    height: 32px;
    font-size: 0.76rem;
    font-weight: 800;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid var(--line-accent);
    color: var(--violet-lt);
    transition: background 150ms, transform 150ms;
    white-space: nowrap;
}
.quick-share-btn:hover { background: rgba(139, 92, 246, 0.2); transform: translateY(-1px); }

.sound-toggle-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text); font-size: 1rem; transition: background 150ms;
}
.sound-toggle-btn:hover { background: rgba(255, 255, 255, 0.15); }
.sound-toggle-btn.muted { opacity: 0.5; filter: grayscale(1); }

/* ══════════════════════════════════════════════════
   THE ARENA — Counter Hero
══════════════════════════════════════════════════ */
.arena {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: clamp(16px, 3vh, 36px) clamp(16px, 4vw, 36px);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Soft ambient light behind counter — reacts to phase */
.arena::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 55% at 50% 45%, var(--glow-idle) 0%, transparent 70%);
    opacity: 0.5;
    pointer-events: none;
    transition: background 600ms ease;
}
body[data-phase="approach"] .arena::before { background: radial-gradient(ellipse 70% 55% at 50% 45%, var(--glow-approach) 0%, transparent 70%); }
body[data-phase="warm"]     .arena::before { background: radial-gradient(ellipse 70% 55% at 50% 45%, var(--glow-warm) 0%, transparent 70%); }
body[data-phase="hot"]      .arena::before { background: radial-gradient(ellipse 80% 60% at 50% 45%, var(--glow-hot) 0%, transparent 65%); }
body[data-phase="critical"] .arena::before {
    background: radial-gradient(ellipse 90% 70% at 50% 45%, var(--glow-critical) 0%, transparent 60%);
    animation: arenaBreath 0.35s ease-in-out infinite alternate;
}
@keyframes arenaBreath {
    from { opacity: 0.4; }
    to   { opacity: 0.75; }
}

/* ── PHASE MESSAGE ───────────────────────────── */
.phase-msg {
    position: relative;
    z-index: 1;
    min-height: 28px;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 6px;
    transition: color 400ms ease;
}
body[data-phase="approach"] .phase-msg { color: var(--c-approach); }
body[data-phase="warm"]     .phase-msg { color: var(--c-warm); }
body[data-phase="hot"]      .phase-msg { color: var(--c-hot); }
body[data-phase="critical"] .phase-msg {
    color: var(--c-critical);
    animation: msgBlink 0.35s ease-in-out infinite alternate;
}
@keyframes msgBlink {
    from { opacity: 0.85; }
    to   { opacity: 1; }
}
.phase-msg.animate-in {
    animation: msgSlideIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── COUNTER STAGE ───────────────────────────── */
.counter-stage {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
}

.counter {
    font-family: 'Space Mono', monospace;
    font-size: clamp(4rem, 10vw, 8rem);
    font-weight: 700;
    line-height: 0.88;
    width: auto;
    min-width: 7.5ch;
    display: inline-block;
    text-align: center;
    padding-right: 0.1em; /* Fix Safari bounding box clipping */
    white-space: nowrap;
    color: var(--c-idle);
    text-shadow:
        0 0 40px rgba(139, 92, 246, 0.2),
        0 2px 0 rgba(0,0,0,0.5);
    /* Removed text-shadow transition which causes Safari to freeze the text rendering */
    transition: color 500ms ease;
    user-select: none;
}

/* Optimize counter rendering during active countdown */
body.ticking .counter {
    text-shadow: 0 2px 0 rgba(0,0,0,0.6) !important;
    will-change: auto !important;
    transform: none !important;
    animation: none !important;
}

/* Phase counter colours */
body[data-phase="approach"] .counter {
    color: var(--c-approach);
    text-shadow: 0 0 50px rgba(251,191,36,0.45), 0 2px 0 rgba(0,0,0,0.5);
}
body[data-phase="warm"] .counter {
    color: var(--c-warm);
    text-shadow: 0 0 55px rgba(249,115,22,0.45), 0 2px 0 rgba(0,0,0,0.5);
}
body[data-phase="hot"] .counter {
    color: var(--c-hot);
    text-shadow: 0 0 60px rgba(6,214,245,0.55), 0 0 20px rgba(6,214,245,0.3), 0 2px 0 rgba(0,0,0,0.5);
    animation: counterHot 0.5s ease-in-out infinite;
}
body[data-phase="critical"] .counter {
    color: var(--c-critical);
    text-shadow: 0 0 70px rgba(52,211,153,0.65), 0 0 30px rgba(52,211,153,0.4), 0 2px 0 rgba(0,0,0,0.5);
    animation: counterCritical 0.28s ease-in-out infinite;
}
.pi-page.victory .counter {
    color: var(--c-critical);
    text-shadow: 0 0 80px rgba(52,211,153,0.7), 0 0 160px rgba(52,211,153,0.3);
    animation: victoryScale 0.5s cubic-bezier(0.34,1.56,0.64,1);
    will-change: transform;
}

@keyframes counterHot {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.012); }
}
@keyframes counterCritical {
    0%, 100% { transform: scale(1) rotate(-0.3deg); }
    50%       { transform: scale(1.018) rotate(0.3deg); }
}
@keyframes victoryScale {
    0%   { transform: scale(0.9); }
    60%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* ── TARGET REFERENCE ────────────────────────── */
.target-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 5px 16px;
    border-radius: 999px;
    background: rgba(52, 211, 153, 0.07);
    border: 1px solid rgba(52, 211, 153, 0.18);
    transition: background 400ms ease, border-color 400ms ease, transform 300ms ease;
}
.target-display-label {
    color: var(--dim);
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.target-display-value {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    color: var(--green);
    letter-spacing: -0.02em;
}
body[data-phase="critical"] .target-display {
    background: rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.45);
    transform: scale(1.05);
}

/* ── PRECISION BAR ───────────────────────────── */
.precision-bar {
    position: relative;
    z-index: 1;
    width: min(460px, 100%);
    height: 36px;
    margin-top: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: linear-gradient(90deg,
        rgba(248,113,113,0.9)  0%,
        rgba(251,191,36,0.9)   25%,
        rgba(52,211,153,0.95)  50%,
        rgba(251,191,36,0.9)   75%,
        rgba(248,113,113,0.9)  100%
    );
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 4px 20px rgba(0,0,0,0.4);
    transition: box-shadow 400ms ease;
}
body[data-phase="critical"] .precision-bar {
    box-shadow: 0 0 0 2px rgba(52,211,153,0.5), 0 0 24px rgba(52,211,153,0.3), 0 4px 20px rgba(0,0,0,0.4);
}

/* Zone labels */
.precision-bar em, .precision-bar strong {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    z-index: 2;
    color: rgba(0,0,0,0.6);
    font-size: 0.62rem;
    font-style: normal;
    font-weight: 900;
    pointer-events: none;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.precision-bar em:first-child { left: 10px; }
.precision-bar strong {
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    color: rgba(0,0,0,0.7);
}
.precision-bar em:last-child { right: 10px; }

/* Needle */
.precision-bar > span {
    position: absolute;
    top: -2px; left: 0;
    width: 100%; height: 40px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    pointer-events: none;
    transform: translateX(50%);
    will-change: transform;
    z-index: 3;
}
.precision-bar > span::after {
    content: '';
    position: absolute;
    top: 0; left: -2px;
    width: 4px; height: 100%;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 0 14px rgba(255,255,255,0.95), 0 0 28px rgba(255,255,255,0.6);
}

/* ══════════════════════════════════════════════════
   CONTROLS AREA
══════════════════════════════════════════════════ */
.controls-area {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 22px 14px;
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,0.015);
    flex-shrink: 0;
}

/* ── PLAYER FORM ─────────────────────────────── */
.player-form { display: grid; gap: 5px; }
.player-form label {
    color: var(--dim);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.field-row { display: flex; align-items: center; gap: 10px; }

input {
    min-width: 0; width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    background: rgba(139, 92, 246, 0.05);
    color: var(--text);
    outline: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: border-color 200ms, box-shadow 200ms, background 200ms;
}
input::placeholder { color: var(--dim); }
input:focus {
    border-color: var(--violet);
    background: rgba(139, 92, 246, 0.09);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.secondary-btn {
    height: 44px;
    padding: 0 16px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid var(--line-accent);
    border-radius: var(--radius-sm);
    color: var(--violet-lt);
    font-weight: 800;
    font-size: 0.88rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 150ms, transform 100ms;
}
.secondary-btn:hover { background: rgba(139, 92, 246, 0.18); }

/* ── ACTIONS ─────────────────────────────────── */
.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.start-btn, .hit-btn {
    min-height: 58px;
    font-size: 1rem;
    font-weight: 900;
    border-radius: 12px;
    border: 0;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
    transition: filter 150ms, transform 100ms, box-shadow 200ms;
}
.start-btn::after, .hit-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, transparent 55%);
    pointer-events: none;
}

.start-btn {
    background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
    color: #1a0d00;
    box-shadow: 0 4px 24px rgba(251,191,36,0.28), 0 1px 0 rgba(255,255,255,0.12) inset;
}
.start-btn:hover:not(:disabled) {
    filter: brightness(1.08);
    box-shadow: 0 6px 32px rgba(251,191,36,0.42);
    transform: translateY(-1px);
}
.start-btn:active { transform: translateY(1px); }

.hit-btn {
    background: linear-gradient(135deg, #34d399 0%, #06d6f5 100%);
    color: #001810;
    box-shadow: 0 4px 24px rgba(52,211,153,0.25), 0 1px 0 rgba(255,255,255,0.12) inset;
}
.hit-btn:hover:not(:disabled) {
    filter: brightness(1.08);
    box-shadow: 0 6px 32px rgba(52,211,153,0.42);
    transform: translateY(-1px);
}
.hit-btn:active { transform: translateY(1px); }
.hit-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* Hit button urgency states */
.pi-page:not(.victory) .hit-btn:not(:disabled) {
    animation: readyPulse 1.4s ease-in-out infinite;
}
body[data-phase="hot"] .hit-btn:not(:disabled) {
    animation: hotBtnPulse 0.5s ease-in-out infinite !important;
    box-shadow: 0 0 0 3px rgba(6,214,245,0.3), 0 4px 24px rgba(52,211,153,0.25) !important;
}
body[data-phase="critical"] .hit-btn:not(:disabled) {
    animation: criticalBtnPulse 0.28s ease-in-out infinite !important;
    box-shadow: 0 0 0 4px rgba(52,211,153,0.45), 0 0 40px rgba(52,211,153,0.35) !important;
    filter: brightness(1.1);
}

@keyframes readyPulse {
    0%, 100% { box-shadow: 0 4px 24px rgba(52,211,153,0.2), 0 1px 0 rgba(255,255,255,0.12) inset; }
    50%       { box-shadow: 0 4px 40px rgba(52,211,153,0.45), 0 0 0 3px rgba(52,211,153,0.12), 0 1px 0 rgba(255,255,255,0.12) inset; }
}
@keyframes hotBtnPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(6,214,245,0.25), 0 4px 24px rgba(52,211,153,0.2); transform: scale(1); }
    50%       { box-shadow: 0 0 0 5px rgba(6,214,245,0.4), 0 4px 40px rgba(6,214,245,0.35); transform: scale(1.02); }
}
@keyframes criticalBtnPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(52,211,153,0.35), 0 0 30px rgba(52,211,153,0.3); transform: scale(1); }
    50%       { box-shadow: 0 0 0 7px rgba(52,211,153,0.55), 0 0 60px rgba(52,211,153,0.45); transform: scale(1.025); }
}

/* ══════════════════════════════════════════════════
   RESULT STRIP
══════════════════════════════════════════════════ */
.result-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 52px;
    padding: 10px 22px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
    background: rgba(255,255,255,0.018);
}
.result-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dim);
    flex-shrink: 0;
    white-space: nowrap;
}
.result-value {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    flex-shrink: 0;
    transition: color 400ms ease;
}
.result-diff {
    flex: 1;
    font-size: 0.82rem;
    color: var(--muted);
    min-width: 0;
}
.result-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.streak-badge {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(249,115,22,0.15));
    border: 1px solid rgba(251,191,36,0.3);
    font-size: 0.72rem;
    font-weight: 900;
    color: var(--gold);
    white-space: nowrap;
    flex-shrink: 0;
}
.streak-badge.visible { display: flex; }

.rank-pill {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 900;
    white-space: nowrap;
    flex-shrink: 0;
}
.rank-pill.visible { display: flex; }
.rank-pill.rank-master { background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.3); color: var(--green); }
.rank-pill.rank-sniper { background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3); color: var(--violet-lt); }
.rank-pill.rank-hunter { background: rgba(6,214,245,0.1);   border: 1px solid rgba(6,214,245,0.28); color: #06d6f5; }
.rank-pill.rank-rookie  { background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--muted); }

button.icon-btn {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    font-size: 1rem;
    transition: background 150ms, border-color 150ms, transform 100ms;
    flex-shrink: 0;
    color: var(--text);
}
button.icon-btn:hover { background: rgba(139, 92, 246, 0.14); border-color: var(--line-accent); transform: translateY(-1px); }

/* ══════════════════════════════════════════════════
   TOAST NOTIFICATION
══════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: rgba(12, 12, 28, 0.97);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 999px;
    padding: 11px 26px;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    z-index: 200;
    opacity: 0;
    transition: opacity 280ms ease, transform 280ms cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(139,92,246,0.2);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.near-miss {
    border-color: rgba(251, 191, 36, 0.5);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 24px rgba(251,191,36,0.2);
}
.toast.so-close {
    border-color: rgba(249, 115, 22, 0.6);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 30px rgba(249,115,22,0.25);
}
.toast.perfect {
    border-color: rgba(52, 211, 153, 0.6);
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 40px rgba(52,211,153,0.3);
}

/* ══════════════════════════════════════════════════
   LEADERBOARD PANEL
══════════════════════════════════════════════════ */
.leaderboard-panel {
    border-radius: var(--radius);
    max-height: min(860px, calc(100svh - 44px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(139, 92, 246, 0.04);
    flex-shrink: 0;
}
.eyebrow {
    color: var(--violet-lt);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.panel-head h1 {
    margin: 3px 0 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.panel-head-actions { display: flex; gap: 6px; }

.leaderboard {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 8px;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--line-accent) transparent;
}
.leaderboard::-webkit-scrollbar { width: 4px; }
.leaderboard::-webkit-scrollbar-thumb { background: var(--line-accent); border-radius: 4px; }

.leaderboard li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-height: 52px;
    padding: 6px 10px;
    border-radius: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 150ms;
}
.leaderboard li:last-child { border-bottom: none; }
.leaderboard li:hover { background: rgba(139,92,246,0.07); }
.leaderboard li.is-me {
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.22) !important;
}
.leaderboard li.is-me .player-name { color: var(--violet-lt); }

.rank { color: var(--dim); font-weight: 900; font-size: 0.8rem; text-align: center; }
.player-name {
    color: var(--text); font-weight: 700; font-size: 0.88rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-meta {
    display: block; margin-top: 1px;
    color: var(--dim); font-size: 0.7rem; font-weight: 600;
}
.score-meta .won-badge { color: var(--green); font-weight: 800; }
.score-hit {
    font-family: 'Space Mono', monospace;
    font-weight: 700; font-size: 0.86rem; color: var(--text);
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════
   MODALS — BASE
══════════════════════════════════════════════════ */
dialog {
    border: 0; padding: 0;
    background: transparent; color: var(--text);
}
dialog::backdrop {
    background: rgba(4, 4, 14, 0.7);
    backdrop-filter: blur(14px);
    animation: backdropIn 300ms ease forwards;
}
@keyframes backdropIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
.modal-content {
    position: relative;
    border-radius: 20px;
    padding: 32px 28px;
}
@keyframes modalIn {
    0%   { transform: scale(0.86) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-content { animation: modalIn 340ms cubic-bezier(0.34,1.56,0.64,1); }

.close-btn {
    position: absolute; top: 14px; right: 14px;
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    background: rgba(255,255,255,0.08);
    font-size: 1.25rem; line-height: 1;
    display: grid; place-items: center;
    color: var(--muted);
    transition: background 150ms, color 150ms;
}
.close-btn:hover { background: rgba(255,255,255,0.14); color: var(--text); }

/* ── WELCOME MODAL ───────────────────────────── */
.welcome-modal { width: min(430px, calc(100% - 24px)); }
.welcome-modal .modal-content { text-align: center; }

.welcome-pi-logo {
    width: 76px; height: 76px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(6,214,245,0.15));
    border: 1px solid var(--line-accent);
    display: grid; place-items: center;
    font-family: 'Space Mono', monospace;
    font-size: 2rem; font-weight: 700;
    color: var(--violet-lt);
    box-shadow: 0 0 40px rgba(139,92,246,0.2);
}
.welcome-modal h2 {
    font-size: 1.65rem; font-weight: 900;
    letter-spacing: -0.02em; margin-bottom: 8px;
}
.welcome-modal p {
    color: var(--muted); font-size: 0.9rem;
    line-height: 1.6; margin-bottom: 26px;
}
.welcome-modal p strong { color: var(--green); font-family: 'Space Mono', monospace; }
.welcome-nick-wrap {
    display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px;
}
.welcome-nick-wrap label {
    text-align: left; color: var(--dim);
    font-size: 0.68rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.08em;
}
.welcome-nick-wrap input { 
    height: 52px; font-size: 1.05rem; text-align: center; border-radius: 12px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.3);
    transition: all 0.2s ease;
}
.welcome-nick-wrap input:focus {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.8);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
}
.play-btn {
    width: 100%; height: 56px;
    border: 0; border-radius: 14px;
    font-size: 1.05rem; font-weight: 900;
    background: linear-gradient(135deg, #8b5cf6, #06d6f5);
    color: #fff;
    box-shadow: 0 6px 28px rgba(139,92,246,0.35);
    transition: filter 150ms, transform 150ms, box-shadow 150ms;
    position: relative; overflow: hidden;
}
.play-btn::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 55%);
    pointer-events: none;
}
.play-btn:hover { filter: brightness(1.1); box-shadow: 0 8px 36px rgba(139,92,246,0.48); transform: translateY(-2px); }

/* ── WIN MODAL ───────────────────────────────── */
.win-modal { width: min(470px, calc(100% - 24px)); }
.win-modal .modal-content { text-align: center; }
.modal-mark {
    display: inline-grid; place-items: center;
    min-width: 110px; min-height: 44px;
    border-radius: 10px;
    background: rgba(52,211,153,0.1);
    border: 1px solid rgba(52,211,153,0.3);
    color: var(--green);
    font-family: 'Space Mono', monospace;
    font-weight: 700; font-size: 1.15rem;
    text-shadow: 0 0 20px rgba(52,211,153,0.5);
    margin-bottom: 16px;
}
.win-modal h2 {
    font-size: 1.7rem; font-weight: 900;
    letter-spacing: -0.02em; margin-bottom: 8px;
}
.win-modal p { color: var(--muted); font-size: 0.88rem; line-height: 1.6; margin-bottom: 22px; }

.share-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.share-grid button, .share-grid a {
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    min-height: 52px; min-width: 0;
    padding: 0 14px;
    font-weight: 700; font-size: 0.92rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    text-decoration: none; color: var(--text);
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    position: relative;
    overflow: hidden;
}
.share-grid button::before, .share-grid a::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(255,255,255,0.06), transparent);
    opacity: 0; transition: opacity 0.2s;
    pointer-events: none;
}
.share-grid button:hover, .share-grid a:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.share-grid button:hover::before, .share-grid a:hover::before { opacity: 1; }

#whatsappShare, #challengeWhatsapp { 
    background: linear-gradient(135deg, rgba(37,211,102,0.15), rgba(37,211,102,0.03)); 
    border-color: rgba(37,211,102,0.3); color: #25d366; 
}
#whatsappShare:hover, #challengeWhatsapp:hover { 
    border-color: rgba(37,211,102,0.6); box-shadow: 0 8px 24px rgba(37,211,102,0.25);
}

#telegramShare, #challengeTelegram { 
    background: linear-gradient(135deg, rgba(40,167,230,0.15), rgba(40,167,230,0.03)); 
    border-color: rgba(40,167,230,0.3); color: #28a7e6; 
}
#telegramShare:hover, #challengeTelegram:hover { 
    border-color: rgba(40,167,230,0.6); box-shadow: 0 8px 24px rgba(40,167,230,0.25);
}

#xShare { 
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02)); 
    border-color: rgba(255,255,255,0.2); color: #fff; 
}
#xShare:hover { 
    border-color: rgba(255,255,255,0.4); box-shadow: 0 8px 24px rgba(255,255,255,0.15);
}

#nativeShare, #challengeNative {
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(139,92,246,0.03));
    border-color: rgba(139,92,246,0.3); color: var(--violet-lt);
}
#nativeShare:hover, #challengeNative:hover {
    border-color: rgba(139,92,246,0.6); box-shadow: 0 8px 24px rgba(139,92,246,0.25);
}

#copyShare, #challengeCopyLink {
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    border-color: rgba(255,255,255,0.15); color: var(--text);
}
#copyShare:hover, #challengeCopyLink:hover {
    border-color: rgba(255,255,255,0.3); box-shadow: 0 8px 24px rgba(255,255,255,0.1);
}

/* ── HISTORY MODAL ───────────────────────────── */
.history-modal { width: min(560px, calc(100% - 24px)); }
.history-modal .modal-content {
    text-align: left;
    display: flex; flex-direction: column;
    max-height: 88vh;
}
.history-modal h2 { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.02em; margin-bottom: 4px; }
.history-sub { color: var(--muted); font-size: 0.8rem; margin-bottom: 16px; }
.history-list {
    overflow-y: auto; flex: 1;
    list-style: none; max-height: 58vh;
    display: flex; flex-direction: column; gap: 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-accent) transparent;
}
.history-list li {
    display: grid;
    grid-template-columns: 26px minmax(0,1fr) auto auto;
    align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.05);
    transition: background 150ms;
}
.history-list li:hover { background: rgba(139,92,246,0.07); }
.history-list li.best-entry { background: rgba(52,211,153,0.07); border-color: rgba(52,211,153,0.18); }
.history-num { color: var(--dim); font-size: 0.76rem; font-weight: 700; text-align: center; }
.history-hit { font-family: 'Space Mono', monospace; font-weight: 700; font-size: 0.9rem; color: var(--text); }
.history-diff { font-family: 'Space Mono', monospace; font-size: 0.76rem; color: var(--muted); }
.history-date { font-size: 0.68rem; color: var(--dim); white-space: nowrap; }
.history-won { color: var(--green); font-weight: 800; font-size: 0.7rem; }

/* ══════════════════════════════════════════════════
   NEAR-MISS FLASH OVERLAY
══════════════════════════════════════════════════ */
.near-miss-flash {
    position: fixed; inset: 0;
    pointer-events: none; z-index: 50;
    opacity: 0;
    background: radial-gradient(ellipse at center, rgba(251,191,36,0.12) 0%, transparent 70%);
    transition: opacity 150ms ease;
}
.near-miss-flash.fire { opacity: 1; }

/* ══════════════════════════════════════════════════
   HOVER (pointer devices)
══════════════════════════════════════════════════ */
@media (hover: hover) {
    .start-btn:hover:not(:disabled),
    .hit-btn:hover:not(:disabled) { filter: brightness(1.08); }
}

/* ══════════════════════════════════════════════════
   RESPONSIVE — TABLET
══════════════════════════════════════════════════ */
@media (max-width: 980px) {
    .game-shell {
        grid-template-columns: 1fr;
        align-items: start;
        padding: 12px 0;
        gap: 14px;
    }
    .game-stage {
        min-height: auto;
        max-height: none;
    }
    .leaderboard-panel {
        max-height: 480px;
        margin-bottom: 12px;
        background: linear-gradient(175deg, rgba(14,14,28,0.95) 0%, rgba(6,6,18,0.98) 100%);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
        border: 1px solid var(--line);
    }
}

/* ══════════════════════════════════════════════════
   RESPONSIVE — MOBILE
══════════════════════════════════════════════════ */
@media (max-width: 560px) {
    .game-shell { width: calc(100% - 14px); gap: 10px; padding: 7px 0; }

    .stats-bar { overflow-x: auto; }
    .stat-item { min-width: 72px; }
    .stat-value { font-size: 0.72rem; }

    .brand-row { padding: 10px 14px; }

    .counter { font-size: clamp(3.2rem, 18vw, 5.5rem); }

    .arena { padding: 14px 14px; gap: 0; }
    .precision-bar { height: 30px; }
    .precision-bar > span { height: 34px; }

    .controls-area { padding: 12px 14px; gap: 12px; }
    .actions { gap: 10px; }
    .start-btn, .hit-btn { min-height: 54px; font-size: 0.95rem; }

    .result-strip { padding: 9px 14px; gap: 8px; }
    .field-row { flex-direction: column; }
    .secondary-btn { width: 100%; }

    .share-grid { grid-template-columns: 1fr; }
    .toast { font-size: 0.9rem; padding: 10px 20px; max-width: calc(100vw - 32px); white-space: normal; text-align: center; }

    .leaderboard-panel {
        position: relative;
        max-height: 400px;
        border-radius: 20px;
        margin-top: 10px;
    }
}

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

/* ══════════════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-accent); border-radius: 5px; }

/* ══════════════════════════════════════════════════
   NEAR-MISS DOPAMINE EFFECTS — TikTok style
══════════════════════════════════════════════════ */

/* Fixed layer, covers entire viewport */
.effect-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 90;
    overflow: hidden;
}

/* ── Screen shake ─────────────────────────────── */
body.shake-heavy  { animation: shakeH  0.55s ease; }
body.shake-medium { animation: shakeM  0.4s  ease; }
body.shake-light  { animation: shakeL  0.28s ease; }

@keyframes shakeH {
    0%,100% { transform: translate3d(0,0,0) rotate(0deg); }
    11%     { transform: translate3d(-9px,-6px,0) rotate(-.7deg); }
    22%     { transform: translate3d(9px,6px,0)  rotate(.7deg);  }
    33%     { transform: translate3d(-7px,5px,0) rotate(-.4deg); }
    44%     { transform: translate3d(7px,-5px,0) rotate(.4deg);  }
    55%     { transform: translate3d(-5px,7px,0) rotate(-.2deg); }
    66%     { transform: translate3d(5px,-7px,0) rotate(.2deg);  }
    77%     { transform: translate3d(-5px,2px,0); }
    88%     { transform: translate3d(5px,-2px,0); }
}
@keyframes shakeM {
    0%,100% { transform: translate3d(0,0,0); }
    16%     { transform: translate3d(-5px,-3px,0); }
    33%     { transform: translate3d(5px,3px,0);  }
    50%     { transform: translate3d(-3px,4px,0); }
    66%     { transform: translate3d(3px,-4px,0); }
    83%     { transform: translate3d(-2px,2px,0); }
}
@keyframes shakeL {
    0%,100% { transform: translate3d(0,0,0); }
    25%     { transform: translate3d(-3px,-2px,0); }
    50%     { transform: translate3d(3px,2px,0);  }
    75%     { transform: translate3d(-2px,2px,0); }
}

/* ── Edge color glow ──────────────────────────── */
.edge-glow {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 80ms;
}
.edge-glow.go { animation: edgePulse 1.6s ease forwards; }
@keyframes edgePulse {
    0%   { opacity: 0; }
    18%  { opacity: 1; }
    60%  { opacity: 0.65; }
    100% { opacity: 0; }
}

/* ── Shockwave rings ──────────────────────────── */
.rings-container { position: absolute; inset: 0; }
.shock-ring {
    position: absolute;
    left: 50%; top: 40%;
    width: 100px; height: 100px;
    margin: -50px 0 0 -50px;
    border-radius: 50%;
    border-width: 3px;
    border-style: solid;
    opacity: 0;
    animation: ringBoom 2s cubic-bezier(.08,.9,.2,1) var(--delay,0ms) forwards;
    width: 120px; height: 120px;
    margin: -60px 0 0 -60px;
    border-width: 4px;
}
@keyframes ringBoom {
    0%   { transform: scale(.04); opacity: 1;  filter: blur(0); }
    15%  { opacity: .9; }
    50%  { opacity: .5; filter: blur(1px); }
    100% { transform: scale(32); opacity: 0;  filter: blur(3px); }
}

/* ── Slam text ────────────────────────────────── */
.slam-text {
    position: absolute;
    top: 38%; left: 50%;
    transform: translateX(-50%) translateY(-50%);
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 8vw, 5.8rem);
    letter-spacing: -.03em;
    text-align: center;
    white-space: nowrap;
    z-index: 5; opacity: 0;
}
.slam-text.go {
    animation: slamDrop 3.8s cubic-bezier(.22,1.3,.5,1) forwards;
}
@keyframes slamDrop {
    0%   { opacity:0; transform:translateX(-50%) translateY(-280%) scale(3.2); filter:blur(16px); }
    7%   { opacity:1; transform:translateX(-50%) translateY(-50%)  scale(.86); filter:blur(0);   }
    11%  {            transform:translateX(-50%) translateY(-60%)  scale(1.18); }
    14%  {            transform:translateX(-50%) translateY(-50%)  scale(.96); }
    17%  {            transform:translateX(-50%) translateY(-54%)  scale(1.06); }
    20%  {            transform:translateX(-50%) translateY(-50%)  scale(1);   }
    65%  { opacity:1; }
    100% { opacity:0; transform:translateX(-50%) translateY(-72%) scale(.82); filter:blur(5px); }
}

/* ── Slam subtitle ────────────────────────────── */
.slam-sub {
    position: absolute;
    top: 52%; left: 50%;
    transform: translateX(-50%);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(.76rem, 2.2vw, 1.15rem);
    text-align: center; white-space: nowrap;
    color: rgba(255,255,255,.6);
    z-index: 5; opacity: 0;
}
.slam-sub.go {
    animation: subAppear 3.6s ease forwards;
    animation-delay: 180ms;
}
@keyframes subAppear {
    0%   { opacity:0; transform:translateX(-50%) scale(.84); }
    22%  { opacity:1; transform:translateX(-50%) scale(1);   }
    72%  { opacity:1; }
    100% { opacity:0; }
}

/* ── Accuracy meter ───────────────────────────── */
.accuracy-meter {
    position: absolute;
    bottom: 12%; left: 50%;
    transform: translateX(-50%);
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    z-index: 5; opacity: 0;
    min-width: 180px;
}
.accuracy-meter.go {
    animation: accReveal 3.6s ease forwards;
    animation-delay: 300ms;
}
@keyframes accReveal {
    0%   { opacity:0; transform:translateX(-50%) translateY(20px) scale(.84); }
    22%  { opacity:1; transform:translateX(-50%) translateY(0)    scale(1.05); }
    28%  {            transform:translateX(-50%) scale(1); }
    75%  { opacity:1; }
    100% { opacity:0; transform:translateX(-50%) translateY(-14px); }
}
.acc-label {
    font-size: .58rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .14em;
    color: rgba(255,255,255,.4);
}
.acc-value {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(2.2rem, 6.5vw, 4rem);
    line-height: 1; letter-spacing: -.04em;
}
.acc-grade {
    font-size: .7rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .08em;
    color: rgba(255,255,255,.45);
}
.acc-bar {
    width: clamp(130px, 28vw, 220px);
    height: 5px; border-radius: 999px;
    background: rgba(255,255,255,.1); overflow: hidden;
}
.acc-bar-fill {
    height: 100%; border-radius: 999px;
    width: 0;
    transition: width 1.9s cubic-bezier(.22,1,.36,1);
}

.floating-texts {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 95;
    pointer-events: none;
    overflow: hidden;
}

/* ══════════════════════════════════════════
   TIKTOK LIVE FLOATING ITEM
   Rises from bottom, sways sideways, fades at top
   Just like TikTok Live reaction bubbles
   ══════════════════════════════════════════ */
.tiktok-float-wrapper {
    position: absolute;
    bottom: 6%;
    pointer-events: none;
    will-change: transform;
    animation: tiktokSway var(--dur, 3s) var(--delay, 0ms) ease-in-out forwards;
}

.tiktok-float {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    white-space: nowrap;
    opacity: 0;
    will-change: transform, opacity;
    user-select: none;
    animation: tiktokRise var(--dur, 3s) var(--delay, 0ms) cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Vertical rise with pop-in bounce */
@keyframes tiktokRise {
    0%   { opacity: 0;   transform: translateY(0px)    scale(0.2); }
    7%   { opacity: 1;   transform: translateY(-25px)  scale(1.35); }
    13%  {               transform: translateY(-50px)  scale(0.9); }
    18%  {               transform: translateY(-72px)  scale(1.1); }
    24%  {               transform: translateY(-95px)  scale(1); }
    78%  { opacity: 1;   transform: translateY(-300px) scale(1); }
    100% { opacity: 0;   transform: translateY(-400px) scale(0.75); }
}

/* Horizontal sway — the key to looking like TikTok */
@keyframes tiktokSway {
    0%   { transform: translateX(0px); }
    25%  { transform: translateX(calc(var(--drift-x, 24px) * 0.4)); }
    50%  { transform: translateX(calc(var(--drift-x, 24px) * 0.75)); }
    75%  { transform: translateX(calc(var(--drift-x, 24px) * 0.95)); }
    100% { transform: translateX(var(--drift-x, 24px)); }
}

/* ── Streak / Combo pop ──────────────────────────────── */
.combo-pop {
    position: absolute;
    top: 18%; left: 50%;
    transform: translateX(-50%);
    font-family: 'Outfit', sans-serif;
    font-weight: 900; font-size: clamp(1.2rem,4vw,2.2rem);
    white-space: nowrap; text-align: center;
    letter-spacing: .02em;
    z-index: 6; opacity: 0;
}
.combo-pop.go { animation: comboPop 3.2s ease forwards; }
@keyframes comboPop {
    0%   { opacity:0; transform:translateX(-50%) scale(.35) rotate(-10deg); }
    11%  { opacity:1; transform:translateX(-50%) scale(1.32) rotate(4deg); }
    16%  {            transform:translateX(-50%) scale(.92) rotate(-2deg); }
    20%  {            transform:translateX(-50%) scale(1.08) rotate(0deg); }
    25%  {            transform:translateX(-50%) scale(1); }
    68%  { opacity:1; }
    100% { opacity:0; transform:translateX(-50%) translateY(-32px) scale(.8); }
}

/* ── Responsive adjustments ───────────────────── */
@media (max-width: 560px) {
    .slam-text  { font-size: clamp(1.6rem, 10vw, 3rem); }
    .acc-value  { font-size: clamp(1.8rem, 9vw, 3rem);  }
    .shock-ring { top: 45%; }
}

/* ══════════════════════════════════════════════════
   CHALLENGE BANNER (reto activo desde URL)
══════════════════════════════════════════════════ */
.challenge-banner {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    width: min(94vw, 560px);
    background: linear-gradient(135deg,rgba(139,92,246,.22) 0%,rgba(6,214,245,.18) 100%);
    border: 1px solid rgba(139,92,246,.5);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: .9rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 8px 40px rgba(139,92,246,.3),0 0 0 1px rgba(255,255,255,.05);
    transition: top .5s cubic-bezier(.34,1.56,.64,1), opacity .4s;
    pointer-events: none;
    opacity: 0;
}
.challenge-banner.visible { top: 72px; pointer-events: all; opacity: 1; }
.banner-inner { display:flex; align-items:center; gap:.7rem; flex:1; flex-wrap:wrap; min-width:0; }
.banner-icon  { font-size:1.5rem; flex-shrink:0; }
.banner-text  { font-size:.92rem; color:var(--text); line-height:1.4; }
.banner-text strong { color:var(--violet-lt); }
.banner-score { display:inline-flex; align-items:center; gap:.4rem; margin-left:.4rem;
    font-family:'Space Mono',monospace; font-size:.85rem; color:#06d6f5; }
.banner-diff  { font-size:.75rem; color:var(--muted); background:rgba(255,255,255,.06); padding:.1rem .4rem; border-radius:6px; }
.banner-cta   { font-size:.8rem; color:var(--violet-lt); font-weight:600; white-space:nowrap; }
.banner-close { background:none; border:none; color:var(--muted); font-size:1.3rem; cursor:pointer;
    padding:.2rem .4rem; border-radius:6px; transition:color .2s,background .2s; flex-shrink:0; }
.banner-close:hover { color:var(--text); background:rgba(255,255,255,.06); }

/* ══════════════════════════════════════════════════
   PIN / RECOVER MODAL
══════════════════════════════════════════════════ */
.pin-modal { border:none; background:transparent; padding:0; }
.pin-modal::backdrop { background:rgba(4,4,14,.75); backdrop-filter:blur(8px); }
.pin-content { max-width:380px !important; text-align:center; }
.pin-form { display:flex; flex-direction:column; gap:1rem; margin-top:1.2rem; }
.pin-inputs { display:flex; gap:.6rem; justify-content:center; }
.pin-digit {
    width:100%; max-width:220px; padding:.9rem 1rem; font-size:1.6rem;
    text-align:center; font-family:'Space Mono',monospace; letter-spacing:.3em;
    background:rgba(255,255,255,.06); border:1.5px solid var(--line-accent);
    border-radius:12px; color:var(--text); outline:none;
    transition:border-color .2s,box-shadow .2s;
    -moz-appearance:textfield;
    /* iOS PIN Modal Focus Bug Fix */
    user-select:text !important; -webkit-user-select:text !important;
    pointer-events:auto !important;
    touch-action: manipulation !important;
    transform: translateZ(0); /* Forces a new stacking context making it focusable in Safari modals */
}
.pin-digit::-webkit-inner-spin-button,
.pin-digit::-webkit-outer-spin-button { -webkit-appearance:none; }
.pin-digit:focus { border-color:var(--violet); box-shadow:0 0 0 3px var(--violet-glow); }
.pin-actions { display:flex; gap:.7rem; flex-direction:column; }
.btn-primary {
    padding:.85rem 1.5rem; background:linear-gradient(135deg,var(--violet),#06d6f5);
    color:#fff; border:none; border-radius:12px; font-size:1rem; font-weight:700;
    cursor:pointer; transition:opacity .2s,transform .15s;
}
.btn-primary:hover { opacity:.9; transform:translateY(-1px); }
.btn-ghost {
    padding:.75rem 1.5rem; background:transparent; color:var(--muted);
    border:1px solid var(--line); border-radius:12px; font-size:.92rem;
    cursor:pointer; transition:color .2s,border-color .2s;
}
.btn-ghost:hover { color:var(--text); border-color:var(--line-accent); }

/* ══════════════════════════════════════════════════
   XP DISPLAY PILL / SESSION COUNTER / PIN BADGE
══════════════════════════════════════════════════ */
.xp-display {
    display:none; align-items:center; gap:.4rem; padding:.3rem .75rem;
    background:rgba(139,92,246,.12); border:1px solid rgba(139,92,246,.3);
    border-radius:20px; font-size:.78rem; font-weight:600; color:var(--violet-lt);
}
.xp-display.visible { display:inline-flex; }
.xp-value { font-family:'Space Mono',monospace; font-size:.72rem; color:var(--muted); }
.session-counter {
    display:none; align-items:center; gap:.35rem; font-size:.78rem; color:var(--muted);
    padding:.25rem .65rem; background:rgba(255,255,255,.04); border:1px solid var(--line); border-radius:20px;
}
.session-counter.visible { display:inline-flex; }
.session-counter strong { color:var(--violet-lt); font-variant-numeric:tabular-nums; }
#pinBadge {
    display:none; align-items:center; gap:.3rem; font-size:.72rem; font-weight:600;
    color:#34d399; background:rgba(52,211,153,.1); border:1px solid rgba(52,211,153,.3);
    border-radius:20px; padding:.2rem .55rem;
}
.recover-link {
    display:inline-block; margin-top:.6rem; font-size:.82rem; color:var(--muted);
    text-decoration:underline; cursor:pointer; transition:color .2s;
}
.recover-link:hover { color:var(--violet-lt); }

@media (max-width: 480px) {
    .challenge-banner { padding:.7rem .9rem; gap:.6rem; }
    .banner-cta       { display:none; }
    .pin-digit        { font-size:1.3rem; }
}
