/* ==========================================================
   REACTION RUSH — Cinematic Esports Arena v3
   ========================================================== */

/* --- TOKENS --- */
:root {
    --bg: #03060e;
    --surface: rgba(8, 12, 24, .55);
    --glass: rgba(255, 255, 255, .035);
    --glass-b: rgba(255, 255, 255, .06);
    --txt: #eef1f8;
    --txt-m: #6a7a94;
    --txt-d: #2e3d55;

    --idle: #0c1222;
    --idle-h: #141f38;
    --wait: #ff2255;
    --go: #00e676;
    --pen: #ff8c00;
    --bonus: #c060ff;

    --cyan: #00e5ff;
    --pink: #ff2d78;
    --green: #00e676;
    --purple: #c060ff;
    --gold: #ffd740;

    --gl-idle: 0 0 60px rgba(0, 229, 255, .03);
    --gl-wait: 0 0 80px rgba(255, 34, 85, .55), 0 0 180px rgba(255, 34, 85, .12);
    --gl-go: 0 0 80px rgba(0, 230, 118, .6), 0 0 180px rgba(0, 230, 118, .14);
    --gl-pen: 0 0 70px rgba(255, 140, 0, .5), 0 0 140px rgba(255, 140, 0, .1);
    --gl-bonus: 0 0 80px rgba(192, 96, 255, .6), 0 0 180px rgba(192, 96, 255, .12);

    --ease: cubic-bezier(.22, 1, .36, 1);
    --ease-back: cubic-bezier(.34, 1.56, .64, 1);
    --ease-spring: cubic-bezier(.175, .885, .32, 1.275);
    --r: 2.5rem;

    /* Intensity scale (driven by JS) */
    --i-bright: 1;
    --i-glow: 1;
    --i-speed: 1;
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--txt);
    height: 100vh;
    overflow: hidden;
    user-select: none;
    position: relative;
    filter: brightness(var(--i-bright))
}

/* ==========================================================
   ATMOSPHERIC LAYERS
   ========================================================== */
.atmo {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden
}

/* 3-layer gradient mesh with parallax */
.mesh-layer {
    position: absolute;
    inset: -20%;
    border-radius: 50%;
    filter: blur(140px);
    will-change: transform
}

.mesh-far {
    width: 120%;
    height: 120%;
    background: radial-gradient(ellipse at 70% 20%, rgba(0, 229, 255, .07) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 80%, rgba(255, 45, 120, .06) 0%, transparent 55%);
    animation: mesh-drift1 28s ease-in-out infinite alternate;
}

.mesh-mid {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 40% 60%, rgba(192, 96, 255, .06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(0, 230, 118, .04) 0%, transparent 45%);
    animation: mesh-drift2 22s ease-in-out infinite alternate;
}

.mesh-near {
    width: 90%;
    height: 90%;
    left: 5%;
    top: 5%;
    background: radial-gradient(ellipse at 50% 50%, rgba(0, 229, 255, .04) 0%, transparent 40%);
    animation: mesh-drift3 16s ease-in-out infinite alternate;
}

@keyframes mesh-drift1 {
    0% {
        transform: translate(0, 0) scale(1)
    }

    100% {
        transform: translate(-40px, 30px) scale(1.05)
    }
}

@keyframes mesh-drift2 {
    0% {
        transform: translate(0, 0) scale(1)
    }

    100% {
        transform: translate(30px, -25px) scale(1.08)
    }
}

@keyframes mesh-drift3 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0)
    }

    100% {
        transform: translate(-20px, -15px) scale(1.1) rotate(2deg)
    }
}

/* Perspective grid */
.grid-plane {
    position: absolute;
    bottom: 0;
    left: -10%;
    width: 120%;
    height: 60%;
    background-image:
        linear-gradient(rgba(0, 229, 255, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 229, 255, .04) 1px, transparent 1px);
    background-size: 60px 60px;
    transform: perspective(500px) rotateX(55deg);
    transform-origin: center bottom;
    mask-image: linear-gradient(to top, rgba(0, 0, 0, .5) 0%, transparent 70%);
    -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, .5) 0%, transparent 70%);
    animation: grid-scroll 20s linear infinite;
    transition: transform .3s ease;
}

@keyframes grid-scroll {
    0% {
        background-position: 0 0
    }

    100% {
        background-position: 0 60px
    }
}

/* Volumetric beams */
.vol-beams {
    position: absolute;
    inset: 0;
    overflow: hidden
}

.beam {
    position: absolute;
    top: -20%;
    left: 50%;
    transform-origin: 50% 0;
    opacity: .03;
    mix-blend-mode: screen;
    background: linear-gradient(180deg, rgba(255, 255, 255, .4) 0%, transparent 70%)
}

.beam-1 {
    width: 200px;
    height: 120%;
    transform: translateX(-50%) rotate(-12deg);
    animation: beam-pulse 6s ease-in-out infinite alternate
}

.beam-2 {
    width: 160px;
    height: 110%;
    transform: translateX(-30%) rotate(8deg);
    animation: beam-pulse 8s 1s ease-in-out infinite alternate
}

.beam-3 {
    width: 120px;
    height: 100%;
    transform: translateX(20%) rotate(-4deg);
    animation: beam-pulse 7s 2s ease-in-out infinite alternate
}

@keyframes beam-pulse {
    0% {
        opacity: .02
    }

    100% {
        opacity: .06
    }
}

/* Film grain */
.grain {
    position: absolute;
    inset: 0;
    opacity: .025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
    animation: grain-shift 0.3s steps(3) infinite;
}

@keyframes grain-shift {
    0% {
        transform: translate(0)
    }

    33% {
        transform: translate(-2px, 1px)
    }

    66% {
        transform: translate(1px, -1px)
    }

    100% {
        transform: translate(0)
    }
}

/* Vignette */
.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, .55) 100%);
}

/* Cursor glow */
.cursor-glow {
    position: fixed;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 229, 255, .04) 0%, transparent 65%);
    pointer-events: none;
    z-index: 1;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity .5s ease;
}

body:hover .cursor-glow {
    opacity: 1
}

/* Dust canvas */
.dust-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: .4
}

/* ==========================================================
   INTRO
   ========================================================== */
.intro {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity .9s var(--ease), transform 1.2s var(--ease), filter .9s var(--ease);
}

/* Letterbox bars */
.letterbox {
    position: absolute;
    left: 0;
    right: 0;
    height: 6vh;
    background: #000;
    z-index: 10;
    transition: height .8s var(--ease)
}

.letterbox-top {
    top: 0
}

.letterbox-bot {
    bottom: 0
}

.intro.exit .letterbox {
    height: 0
}

.intro.exit {
    opacity: 0;
    transform: scale(1.25);
    filter: blur(14px);
    pointer-events: none;
}

.intro-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.8rem;
    z-index: 5
}

/* Title */
.intro-title {
    display: flex;
    flex-direction: column;
    line-height: .92
}

.word {
    font-size: clamp(3.5rem, 12vw, 8.5rem);
    font-weight: 900;
    letter-spacing: -.03em;
    position: relative;
    opacity: 0;
}

/* REACTION — depth blur fade in */
.word-reaction {
    animation: word-depth 1.1s .3s var(--ease) forwards;
    color: var(--txt);
}

@keyframes word-depth {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(.94);
        filter: blur(12px)
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0)
    }
}

/* RUSH — chromatic snap */
.word-rush {
    animation: word-snap 0.6s .8s cubic-bezier(.16, 1, .3, 1) forwards;
    background: linear-gradient(135deg, var(--cyan), var(--pink), var(--purple));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.word-rush::before,
.word-rush::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    -webkit-text-fill-color: transparent;
    pointer-events: none;
}

.word-rush::before {
    background: linear-gradient(135deg, var(--cyan), transparent);
    -webkit-background-clip: text;
    background-clip: text;
    animation: chroma-r .6s .8s cubic-bezier(.16, 1, .3, 1) forwards;
    opacity: 0;
}

.word-rush::after {
    background: linear-gradient(135deg, transparent, var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    animation: chroma-l .6s .8s cubic-bezier(.16, 1, .3, 1) forwards;
    opacity: 0;
}

@keyframes word-snap {
    0% {
        opacity: 0;
        transform: translateY(-10px) scaleY(1.15);
        filter: blur(4px)
    }

    50% {
        opacity: 1;
        transform: translateY(2px) scaleY(.97);
        filter: blur(0)
    }

    100% {
        opacity: 1;
        transform: translateY(0) scaleY(1);
        filter: blur(0)
    }
}

@keyframes chroma-r {
    0% {
        opacity: .7;
        transform: translate(5px, -2px)
    }

    100% {
        opacity: 0;
        transform: translate(0)
    }
}

@keyframes chroma-l {
    0% {
        opacity: .7;
        transform: translate(-5px, 2px)
    }

    100% {
        opacity: 0;
        transform: translate(0)
    }
}

/* Gradient flow on RUSH after settle */
.word-rush {
    animation: word-snap .6s .8s cubic-bezier(.16, 1, .3, 1) forwards, grad-flow 6s 1.4s ease-in-out infinite
}

@keyframes grad-flow {

    0%,
    100% {
        background-position: 0% 50%
    }

    50% {
        background-position: 100% 50%
    }
}

/* Glitch hover */
.word:hover::after {
    animation: glitch .3s steps(2) forwards
}

@keyframes glitch {
    0% {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
        transform: translate(0)
    }

    25% {
        opacity: .6;
        clip-path: inset(20% 0 30% 0);
        transform: translate(-3px, 1px)
    }

    50% {
        opacity: 0;
        clip-path: inset(60% 0 10% 0);
        transform: translate(3px, -1px)
    }

    75% {
        opacity: .4;
        clip-path: inset(30% 0 40% 0);
        transform: translate(-2px)
    }

    100% {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
        transform: translate(0)
    }
}

/* Tagline */
.intro-tagline {
    font-size: clamp(.9rem, 2.2vw, 1.2rem);
    color: var(--txt-m);
    font-weight: 300;
    letter-spacing: .08em;
    opacity: 0;
    animation: fade-up .8s .9s var(--ease) forwards;
}

@keyframes fade-up {
    0% {
        opacity: 0;
        transform: translateY(12px)
    }

    100% {
        opacity: 1;
        transform: translateY(0)
    }
}

/* CTA — Premium Button */
.cta {
    position: relative;
    padding: 1.1rem 3.2rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--bg);
    background: linear-gradient(135deg, var(--cyan), var(--green));
    border: none;
    border-radius: 100px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 229, 255, .2), 0 12px 40px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .15);
    opacity: 0;
    animation: fade-up .8s 1.1s var(--ease) forwards;
    transition: transform .5s var(--ease-back), box-shadow .5s ease;
    transform-style: preserve-3d;
    perspective: 800px;
}

.cta:hover {
    transform: scale(1.06) translateY(-3px);
    box-shadow: 0 6px 30px rgba(0, 229, 255, .35), 0 16px 50px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.cta:active {
    transform: scale(.96) translateY(1px);
    box-shadow: 0 2px 10px rgba(0, 229, 255, .15), 0 4px 16px rgba(0, 0, 0, .3);
    transition-duration: .12s;
}

/* Shine sweep */
.cta-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent);
    transform: skewX(-20deg);
    pointer-events: none;
}

.cta:hover .cta-shine {
    animation: shine .8s ease forwards
}

@keyframes shine {
    0% {
        left: -100%
    }

    100% {
        left: 200%
    }
}

/* Glow layer */
.cta-glow {
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    background: inherit;
    filter: blur(16px);
    opacity: 0;
    z-index: -1;
    transition: opacity .4s ease;
}

.cta:hover .cta-glow {
    opacity: .5
}

.cta-text {
    position: relative;
    z-index: 2
}

/* Hint */
.intro-hint {
    font-size: .7rem;
    color: var(--txt-d);
    opacity: 0;
    animation: fade-up .6s 1.3s var(--ease) forwards;
}

.intro-hint kbd {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 5px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--glass-b);
    font-family: 'JetBrains Mono', monospace;
    font-size: .6rem;
    color: var(--txt-m);
}

/* ==========================================================
   GAME
   ========================================================== */
.game {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: opacity .7s var(--ease), transform .9s var(--ease);
}

.hidden-game {
    opacity: 0;
    transform: scale(.92);
    pointer-events: none
}

.visible-game {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto
}

/* --- HUD --- */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.6rem;
    z-index: 10
}

.hud-left,
.hud-right {
    display: flex;
    align-items: center;
    gap: .8rem
}

.hud-chip {
    display: flex;
    align-items: baseline;
    gap: .25rem;
    padding: .35rem .8rem;
    border-radius: 100px;
    background: var(--glass);
    border: 1px solid var(--glass-b);
    backdrop-filter: blur(10px);
    transition: transform .35s var(--ease), border-color .3s ease, box-shadow .3s ease;
}

.hud-chip:hover {
    transform: translateY(-1px) scale(1.03);
    border-color: rgba(255, 255, 255, .1)
}

.hud-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--txt);
    transition: transform .2s var(--ease-spring);
}

.hud-val.bump {
    animation: bump .35s var(--ease-spring)
}

@keyframes bump {
    0% {
        transform: scale(1)
    }

    40% {
        transform: scale(1.3)
    }

    100% {
        transform: scale(1)
    }
}

/* Score light pulse */
.hud-chip.pulse-glow {
    box-shadow: 0 0 25px rgba(0, 230, 118, .3);
    transition: box-shadow .15s ease
}

.hud-lbl {
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--txt-d);
    text-transform: uppercase
}

.streak-fire {
    font-size: .9rem;
    transition: transform .3s var(--ease-spring), filter .3s ease;
    filter: saturate(.5) brightness(.7);
}

.streak-fire.lit {
    filter: saturate(1.3) brightness(1.3);
    animation: fire-bounce .5s var(--ease-spring)
}

@keyframes fire-bounce {
    0% {
        transform: scale(1) rotate(0)
    }

    30% {
        transform: scale(1.5) rotate(-12deg)
    }

    60% {
        transform: scale(.85) rotate(5deg)
    }

    100% {
        transform: scale(1) rotate(0)
    }
}

.streak-chip.hot {
    border-color: rgba(255, 140, 0, .3);
    box-shadow: 0 0 20px rgba(255, 140, 0, .15)
}

.hud-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-b);
    color: var(--txt-m);
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all .35s var(--ease);
    text-decoration: none;
    font-size: 1.1rem;
}

.hud-btn:hover {
    color: var(--txt);
    background: rgba(255, 255, 255, .07);
    transform: scale(1.12);
    border-color: rgba(255, 255, 255, .14)
}

.hud-btn:active {
    transform: scale(.9);
    transition-duration: .1s
}

.hud-select {
    background: var(--glass);
    color: var(--txt-m);
    border: 1px solid var(--glass-b);
    border-radius: 100px;
    padding: .3rem .8rem;
    font-family: 'Outfit', sans-serif;
    font-size: .7rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    backdrop-filter: blur(8px);
    -webkit-appearance: none;
    transition: all .35s ease;
}

.hud-select:hover {
    color: var(--txt);
    border-color: rgba(255, 255, 255, .14)
}

.hud-select option {
    background: var(--bg);
    color: var(--txt)
}

/* Round pill */
.round-pill {
    position: fixed;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .35rem 1rem;
    border-radius: 100px;
    background: var(--glass);
    border: 1px solid var(--glass-b);
    backdrop-filter: blur(12px);
    font-size: .6rem;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--txt-d);
    text-transform: uppercase;
    z-index: 60;
    opacity: 0;
    animation: fade-up .5s .3s var(--ease) forwards;
}

.round-pill strong {
    font-family: 'JetBrains Mono', monospace;
    font-size: .85rem;
    color: var(--cyan);
    font-weight: 700
}

/* ==========================================================
   ARENA STAGE
   ========================================================== */
.stage {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 2rem;
    perspective: 1200px
}

/* Spotlight behind arena */
.arena-spotlight {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 229, 255, .06) 0%, transparent 65%);
    transition: background .6s ease, transform .6s ease;
    filter: blur(40px);
    z-index: 0;
}

/* Arena */
.arena {
    width: 100%;
    max-width: 380px;
    aspect-ratio: 1;
    border-radius: var(--r);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    z-index: 2;
    border: 1px solid var(--glass-b);
    transform: rotateX(1deg) rotateY(0);
    transition: background .4s var(--ease), box-shadow .5s var(--ease), transform .4s var(--ease-spring), border-color .4s ease;
}

/* Rotating edge light */
.arena-edge-light {
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from 0deg, transparent 0%, rgba(0, 229, 255, .12) 25%, transparent 50%, rgba(192, 96, 255, .08) 75%, transparent 100%);
    animation: edge-rotate 8s linear infinite;
    opacity: .5;
    pointer-events: none;
    mask-image: radial-gradient(ellipse, transparent 65%, black 100%);
    -webkit-mask-image: radial-gradient(ellipse, transparent 65%, black 100%);
}

@keyframes edge-rotate {
    0% {
        transform: rotate(0)
    }

    100% {
        transform: rotate(360deg)
    }
}

.arena-inner {
    text-align: center;
    pointer-events: none;
    z-index: 3;
    position: relative
}

.arena-title {
    font-size: clamp(1.6rem, 4.5vw, 2.6rem);
    font-weight: 800;
    margin-bottom: .35rem;
    text-shadow: 0 2px 30px rgba(0, 0, 0, .4);
    transition: all .3s var(--ease);
}

.arena-sub {
    font-size: clamp(.8rem, 1.8vw, 1rem);
    color: rgba(255, 255, 255, .55);
    font-weight: 400;
    letter-spacing: .04em;
    transition: all .3s var(--ease);
}

/* === ARENA STATES === */

/* IDLE */
.arena.idle {
    background: var(--idle);
    box-shadow: var(--gl-idle);
    animation: breathe 5s ease-in-out infinite alternate
}

@keyframes breathe {
    0% {
        box-shadow: var(--gl-idle);
        transform: rotateX(1deg) scale(1)
    }

    100% {
        box-shadow: 0 0 90px rgba(0, 229, 255, .05);
        transform: rotateX(1deg) scale(1.005)
    }
}

.arena.idle:hover {
    background: var(--idle-h);
    transform: rotateX(1deg) scale(1.02);
    border-color: rgba(255, 255, 255, .1);
    animation: none
}

/* WAITING */
.arena.waiting {
    background: var(--wait);
    box-shadow: var(--gl-wait);
    border-color: rgba(255, 34, 85, .3);
    animation: tension 1s ease-in-out infinite alternate
}

.arena.waiting~.arena-spotlight {
    background: radial-gradient(circle, rgba(255, 34, 85, .1) 0%, transparent 65%)
}

@keyframes tension {
    0% {
        transform: rotateX(1deg) scale(1);
        box-shadow: var(--gl-wait)
    }

    100% {
        transform: rotateX(1deg) scale(1.01);
        box-shadow: 0 0 100px rgba(255, 34, 85, .6), 0 0 200px rgba(255, 34, 85, .16)
    }
}

/* ACTIVE */
.arena.active {
    background: var(--go);
    box-shadow: var(--gl-go);
    border-color: rgba(0, 230, 118, .35);
    animation: arena-pop .45s var(--ease-spring) both
}

@keyframes arena-pop {
    0% {
        transform: rotateX(1deg) scale(1)
    }

    35% {
        transform: rotateX(0) scale(1.09)
    }

    55% {
        transform: rotateX(.5deg) scale(1.03)
    }

    75% {
        transform: rotateX(1deg) scale(1.065)
    }

    100% {
        transform: rotateX(1deg) scale(1.055)
    }
}

/* BONUS */
.arena.bonus {
    background: var(--bonus);
    box-shadow: var(--gl-bonus);
    border-color: rgba(192, 96, 255, .35);
    animation: arena-pop .45s var(--ease-spring) both
}

.arena.bonus::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent 30%, rgba(255, 215, 64, .08) 50%, transparent 70%);
    background-size: 200% 200%;
    animation: shimmer-sweep 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer-sweep {
    0% {
        background-position: 200% 200%
    }

    100% {
        background-position: -200% -200%
    }
}

/* PENALTY */
.arena.penalty {
    background: var(--pen);
    box-shadow: var(--gl-pen);
    border-color: rgba(255, 140, 0, .35);
    animation: hard-shake .45s cubic-bezier(.36, .07, .19, .97) both
}

@keyframes hard-shake {

    0%,
    100% {
        transform: translate(0) rotate(0)
    }

    12% {
        transform: translate(-8px, -5px) rotate(-2deg)
    }

    24% {
        transform: translate(8px, 5px) rotate(2deg)
    }

    36% {
        transform: translate(-6px, 3px) rotate(-1.2deg)
    }

    48% {
        transform: translate(6px, -3px) rotate(1.2deg)
    }

    60% {
        transform: translate(-3px, -2px) rotate(-.5deg)
    }

    72% {
        transform: translate(3px, 2px) rotate(.5deg)
    }

    84% {
        transform: translate(-1px, 0) rotate(0)
    }
}

/* Level modifiers */
.arena.level-2 {
    filter: brightness(1.04)
}

.arena.level-3 {
    filter: brightness(1.08)
}

.arena.level-4 {
    filter: brightness(1.12);
    border-color: rgba(255, 255, 255, .2)
}

.arena.level-5 {
    filter: brightness(1.18);
    border-color: rgba(255, 255, 255, .35);
    animation: throb .5s ease-in-out infinite alternate
}

@keyframes throb {
    0% {
        transform: rotateX(1deg) scale(1.04)
    }

    100% {
        transform: rotateX(1deg) scale(1.07)
    }
}

/* ==========================================================
   FEEDBACK
   ========================================================== */
.feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    text-align: center;
    pointer-events: none;
    z-index: 20;
    background: rgba(6, 10, 22, .65);
    padding: 1.8rem 3rem;
    border-radius: 1.5rem;
    border: 1px solid var(--glass-b);
    backdrop-filter: blur(24px);
    transition: opacity .5s var(--ease), transform .5s var(--ease);
}

.feedback:not(.hidden) {
    animation: fb-in .4s var(--ease-back) both
}

@keyframes fb-in {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(.55) translateY(8px)
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0)
    }
}

.feedback.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.9);
    pointer-events: none
}

#feedback-text {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 900;
    margin-bottom: .2rem;
    background: linear-gradient(135deg, #fff, var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#feedback-subtext {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    color: var(--green);
    font-weight: 700
}

.feedback.negative #feedback-subtext {
    color: var(--pen)
}

/* ==========================================================
   FLOATING SCORE
   ========================================================== */
.floating-score {
    position: fixed;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--green);
    pointer-events: none;
    z-index: 200;
    text-shadow: 0 0 18px rgba(0, 230, 118, .5);
    animation: float-up 1.3s var(--ease) forwards;
}

.floating-score.bonus-score {
    color: var(--gold);
    font-size: 1.5rem;
    text-shadow: 0 0 22px rgba(255, 215, 64, .6)
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1.2)
    }

    30% {
        transform: translateY(-25px) scale(1)
    }

    100% {
        opacity: 0;
        transform: translateY(-90px) scale(.6)
    }
}

/* ==========================================================
   SHOCKWAVE
   ========================================================== */
.shockwave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    border: 2px solid rgba(0, 230, 118, .4);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 15;
    opacity: 0;
}

.shockwave.active {
    animation: shockwave-expand .6s ease-out forwards
}

@keyframes shockwave-expand {
    0% {
        width: 0;
        height: 0;
        opacity: .8;
        border-width: 3px
    }

    100% {
        width: 600px;
        height: 600px;
        opacity: 0;
        border-width: 1px
    }
}

/* ==========================================================
   VIGNETTE PULSE
   ========================================================== */
.vignette-pulse {
    position: fixed;
    inset: 0;
    z-index: 800;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0, 0, 0, .6) 100%);
    transition: opacity .15s ease;
}

.vignette-pulse.flash {
    animation: vig-flash .4s ease-out forwards
}

@keyframes vig-flash {
    0% {
        opacity: .7
    }

    100% {
        opacity: 0
    }
}

/* ==========================================================
   GODLIKE
   ========================================================== */
body.godlike-impact {
    animation: g-shake .4s cubic-bezier(.36, .07, .19, .97) both
}

body.godlike-impact::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 999;
    background: radial-gradient(circle at 50% 50%, rgba(0, 230, 118, .3) 0%, transparent 55%);
    animation: g-flash .5s ease-out both;
    pointer-events: none;
}

@keyframes g-shake {

    0%,
    100% {
        transform: translate(0) rotate(0)
    }

    15% {
        transform: translate(-8px, -6px) rotate(-2deg)
    }

    30% {
        transform: translate(8px, 6px) rotate(2deg)
    }

    45% {
        transform: translate(-5px, 3px) rotate(-1deg)
    }

    60% {
        transform: translate(5px, -3px) rotate(1deg)
    }

    75% {
        transform: translate(-2px, -1px) rotate(0)
    }
}

@keyframes g-flash {
    0% {
        opacity: 1
    }

    100% {
        opacity: 0
    }
}

/* Camera micro-shake */
body.micro-shake {
    animation: m-shake .2s ease both
}

@keyframes m-shake {

    0%,
    100% {
        transform: translate(0)
    }

    25% {
        transform: translate(-2px, -1px)
    }

    50% {
        transform: translate(2px, 1px)
    }

    75% {
        transform: translate(-1px, 0)
    }
}

/* ==========================================================
   MODAL
   ========================================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity .35s var(--ease)
}

.modal.hidden {
    opacity: 0;
    pointer-events: none
}

.modal.hidden .modal-panel {
    transform: translateY(25px) scale(.95)
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(16px)
}

.modal-panel {
    position: relative;
    background: rgba(8, 12, 26, .9);
    border: 1px solid rgba(0, 229, 255, .08);
    backdrop-filter: blur(36px);
    padding: 1.8rem 2rem;
    border-radius: 1.5rem;
    width: 90%;
    max-width: 420px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 80px rgba(0, 0, 0, .5), 0 0 40px rgba(0, 229, 255, .03), inset 0 1px 0 rgba(255, 255, 255, .04);
    transition: transform .45s var(--ease-back);
    display: flex;
    flex-direction: column;
}

.modal-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 229, 255, .03) 0%, transparent 40%, transparent 80%, rgba(192, 96, 255, .02) 100%);
}

.modal-panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 10%, rgba(0, 229, 255, .2) 50%, transparent 90%);
    pointer-events: none;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.3rem
}

.modal-head h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--txt)
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-b);
    color: var(--txt-m);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all .3s var(--ease);
}

.modal-close:hover {
    color: var(--txt);
    background: rgba(255, 255, 255, .08);
    transform: rotate(90deg) scale(1.1)
}

.modal-close:active {
    transform: rotate(90deg) scale(.9);
    transition-duration: .1s
}

.modal-body {
    overflow: hidden;
    flex: 1;
    min-height: 0
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .65rem;
    margin-bottom: 1.3rem
}

.stat-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .8rem .4rem;
    border-radius: .9rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, .035) 0%, rgba(255, 255, 255, .015) 100%);
    border: 1px solid var(--glass-b);
    transition: border-color .3s ease, transform .3s var(--ease), box-shadow .3s ease;
    position: relative;
}

.stat-tile:hover {
    border-color: rgba(255, 255, 255, .12);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2)
}


.stat-icon {
    font-size: 1.2rem
}

.stat-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--txt)
}

.stat-lbl {
    font-size: .5rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--txt-d);
    font-weight: 600
}

.lb-section {
    overflow-y: auto;
    flex: 1;
    min-height: 0
}

.lb-title {
    font-size: .7rem;
    font-weight: 700;
    color: var(--txt-m);
    margin-bottom: .5rem;
    letter-spacing: .05em
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem
}

#leaderboard-list li {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .7rem;
    border-radius: .6rem;
    background: rgba(255, 255, 255, .02);
    border: 1px solid var(--glass-b);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: .8rem;
    transition: all .3s var(--ease);
}

#leaderboard-list li:hover {
    border-color: rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .04)
}

#leaderboard-list li:first-child {
    border-color: rgba(255, 215, 64, .15);
    box-shadow: 0 0 15px rgba(255, 215, 64, .04);
    animation: gold-edge 3s ease-in-out infinite alternate
}

@keyframes gold-edge {
    0% {
        border-color: rgba(255, 215, 64, .1)
    }

    100% {
        border-color: rgba(255, 215, 64, .25)
    }
}

.rank-icon {
    font-size: .9rem;
    flex-shrink: 0
}

.rank-number {
    color: var(--txt-m);
    font-size: .65rem;
    min-width: 20px;
    flex-shrink: 0
}

.rank-score {
    flex: 1;
    text-align: right;
    color: var(--txt);
    white-space: nowrap
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media(max-width:768px) {
    .hud {
        padding: .6rem .8rem
    }

    .hud-val {
        font-size: 1rem
    }

    .hud-btn {
        width: 30px;
        height: 30px
    }

    .hud-select {
        display: none
    }

    .arena {
        max-width: 340px
    }

    .arena-title {
        font-size: 1.6rem !important
    }

    .word {
        font-size: clamp(2.6rem, 10vw, 4.5rem)
    }

    .intro-tagline {
        font-size: .85rem
    }

    .cta {
        padding: .9rem 2.2rem;
        font-size: .95rem
    }

    .round-pill {
        bottom: .7rem
    }

    .feedback {
        padding: 1rem 1.8rem
    }

    #feedback-text {
        font-size: clamp(1.2rem, 4vw, 1.8rem)
    }

    .modal-panel {
        width: 92%;
        max-width: 360px;
        padding: 1.3rem 1rem
    }

    .cursor-glow {
        display: none
    }

    .letterbox {
        height: 4vh
    }

    .grid-plane {
        opacity: .5
    }
}

@media(max-width:480px) {
    .hud {
        padding: .4rem .5rem
    }

    .hud-left,
    .hud-right {
        gap: .4rem
    }

    .hud-val {
        font-size: .85rem
    }

    .hud-btn {
        width: 26px;
        height: 26px
    }

    .hud-btn svg {
        width: 13px;
        height: 13px
    }

    .stage {
        padding: .8rem
    }

    .arena {
        max-width: 250px;
        border-radius: 1.5rem
    }

    .arena-title {
        font-size: 1.3rem !important
    }

    .word {
        font-size: clamp(2rem, 14vw, 3.2rem)
    }

    .intro-content {
        gap: 1rem
    }

    .cta {
        padding: .7rem 1.8rem;
        font-size: .85rem
    }

    .round-pill {
        font-size: .5rem;
        padding: .25rem .7rem;
        bottom: .4rem
    }

    .round-pill strong {
        font-size: .7rem
    }

    .feedback {
        padding: .8rem 1.2rem;
        border-radius: .8rem
    }

    #feedback-text {
        font-size: 1.1rem
    }

    #feedback-subtext {
        font-size: .75rem
    }

    .modal-panel {
        width: 95%;
        padding: 1rem .8rem;
        border-radius: .9rem
    }

    .stats-grid {
        gap: .35rem
    }

    .stat-tile {
        padding: .5rem .2rem;
        border-radius: .6rem
    }

    .stat-icon {
        font-size: .9rem
    }

    .stat-num {
        font-size: .8rem
    }

    #leaderboard-list li {
        padding: .4rem .5rem;
        font-size: .7rem;
        gap: .35rem
    }

    .letterbox {
        height: 3vh
    }
}

/* ==========================================================
   THEMES
   ========================================================== */
[data-theme="cyberpunk"] {
    --bg: #020208;
    --glass: rgba(0, 240, 255, .04);
    --glass-b: rgba(0, 240, 255, .1);
    --txt: #fcee0a;
    --txt-m: #00f0ff;
    --txt-d: #2a4560;
    --idle: #08041a;
    --idle-h: #110830;
    --wait: #ff003c;
    --go: #00f0ff;
    --pen: #ffea00;
    --bonus: #ff00a0;
    --cyan: #00f0ff;
    --pink: #ff003c;
    --green: #00f0ff;
    --purple: #ff00a0;
    --gold: #ffea00;
    font-family: 'JetBrains Mono', monospace;
}

[data-theme="cyberpunk"] .word-rush {
    background: linear-gradient(135deg, #fcee0a, #ff003c, #00f0ff);
    -webkit-background-clip: text;
    background-clip: text
}

[data-theme="minimal"] {
    --bg: #f8f9fb;
    --glass: rgba(0, 0, 0, .03);
    --glass-b: rgba(0, 0, 0, .07);
    --txt: #111827;
    --txt-m: #6b7280;
    --txt-d: #9ca3af;
    --idle: #f0f1f5;
    --idle-h: #e4e6ec;
    --wait: #ef4444;
    --go: #10b981;
    --pen: #f59e0b;
    --bonus: #8b5cf6;
    --cyan: #0ea5e9;
    --pink: #ec4899;
    --green: #10b981;
    --purple: #8b5cf6;
    --gold: #f59e0b;
}

[data-theme="minimal"] .mesh-layer {
    opacity: .03
}

[data-theme="minimal"] .grain {
    opacity: .008
}

[data-theme="minimal"] .vignette {
    background: radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(0, 0, 0, .12) 100%)
}

[data-theme="minimal"] .grid-plane {
    opacity: .3
}

[data-theme="minimal"] .beam {
    opacity: .01
}

[data-theme="minimal"] .cursor-glow {
    background: radial-gradient(circle, rgba(0, 0, 0, .02) 0%, transparent 65%)
}

[data-theme="minimal"] .word {
    color: var(--txt);
    text-shadow: none
}

[data-theme="minimal"] .word-rush {
    background: linear-gradient(135deg, #111827, #6366f1, #ec4899);
    -webkit-background-clip: text;
    background-clip: text
}

[data-theme="minimal"] .cta {
    background: linear-gradient(135deg, #111827, #374151);
    color: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .12)
}

[data-theme="minimal"] #feedback-text {
    background: linear-gradient(135deg, #111827, #6366f1);
    -webkit-background-clip: text;
    background-clip: text
}

[data-theme="minimal"] .arena-edge-light {
    opacity: .15
}