:root {
    color-scheme: dark;
    --bg: #07070b;
    --surface: rgba(17, 17, 25, .78);
    --line: rgba(255, 255, 255, .09);
    --line-bright: rgba(255, 255, 255, .16);
    --text: #f6f4ff;
    --muted: #8c899a;
    --lime: #c8ff3d;
    --violet: #9d74ff;
    --cyan: #4de8ff;
    --danger: #ff5d7d;
    --shadow: 0 28px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }

body {
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 8%, rgba(157, 116, 255, .12), transparent 28rem),
        radial-gradient(circle at 88% 88%, rgba(77, 232, 255, .08), transparent 30rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .28;
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, black, transparent 82%);
}

body > h1,
body > #time,
body > #shape,
body > footer,
body > #restartBtn { display: none !important; }

button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(200, 255, 61, .48); outline-offset: 4px; }

.app {
    width: min(1480px, 100%);
    min-height: 100dvh;
    height: 100dvh;
    margin: 0 auto;
    padding: clamp(18px, 2.4vw, 34px);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: clamp(16px, 2vw, 24px);
}

.topbar, .brand, .top-actions, .status-pill, .arena-head, .arena-foot, .instruction {
    display: flex;
    align-items: center;
}

.topbar { justify-content: space-between; gap: 18px; }
.brand { gap: 12px; }

.brand-mark {
    width: 42px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px solid rgba(200, 255, 61, .28);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(200,255,61,.18), rgba(200,255,61,.035));
    box-shadow: inset 0 0 22px rgba(200,255,61,.06), 0 8px 30px rgba(0,0,0,.25);
}

.brand-mark::before {
    content: "";
    width: 12px;
    height: 21px;
    background: var(--lime);
    clip-path: polygon(48% 0, 100% 0, 67% 40%, 100% 40%, 29% 100%, 43% 55%, 0 55%);
    filter: drop-shadow(0 0 7px rgba(200,255,61,.75));
}

.brand-name {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-align: left;
    text-transform: uppercase;
}

.brand-subtitle {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-align: left;
    text-transform: uppercase;
}

.top-actions { gap: 10px; }

.status-pill, .icon-button {
    height: 42px;
    border: 1px solid var(--line);
    background: rgba(18, 18, 26, .72);
    backdrop-filter: blur(16px);
}

.status-pill {
    gap: 8px;
    padding: 0 15px;
    border-radius: 999px;
    color: #bbb8c8;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 0 4px rgba(140,137,154,.09);
    transition: .25s ease;
}

.status-pill[data-state="live"] .status-dot {
    background: var(--lime);
    box-shadow: 0 0 0 4px rgba(200,255,61,.1), 0 0 14px rgba(200,255,61,.7);
    animation: breathe 1.4s ease-in-out infinite;
}

.icon-button {
    width: 42px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #d9d6e5;
    cursor: pointer;
    transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.icon-button:hover { transform: translateY(-2px); border-color: var(--line-bright); background: #1a1a24; }
.sound-icon { position: relative; width: 18px; height: 18px; }

.sound-icon::before {
    content: "";
    position: absolute;
    left: 1px;
    top: 6px;
    width: 6px;
    height: 7px;
    border-radius: 2px 0 0 2px;
    background: currentColor;
    box-shadow: 4px 0 0 -1px currentColor;
}

.sound-icon::after {
    content: "";
    position: absolute;
    right: 1px;
    top: 4px;
    width: 7px;
    height: 10px;
    border: 2px solid currentColor;
    border-left-color: transparent;
    border-top-color: transparent;
    border-bottom-color: transparent;
    border-radius: 50%;
}

.icon-button[aria-pressed="false"] .sound-icon { opacity: .42; }
.icon-button[aria-pressed="false"] .sound-icon::after {
    width: 17px; height: 2px; right: 0; top: 8px; border: 0; border-radius: 2px;
    background: var(--danger); transform: rotate(-42deg);
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.stat {
    min-width: 0;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(150deg, rgba(25,25,35,.84), rgba(14,14,20,.7));
    box-shadow: inset 0 1px rgba(255,255,255,.025);
    backdrop-filter: blur(18px);
}

.stat-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.stat-label::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #3c3947; }
.stat:first-child .stat-label::after { background: var(--lime); box-shadow: 0 0 10px rgba(200,255,61,.5); }

.stat-value {
    margin-top: 7px;
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: clamp(1.35rem, 2.2vw, 2rem);
    font-weight: 780;
    letter-spacing: -.045em;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-value small { margin-left: 4px; color: var(--muted); font-size: .7rem; font-weight: 650; letter-spacing: 0; }

.game-shell {
    position: relative;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(330px, 1fr) auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 28px;
    background:
        radial-gradient(circle at 50% 52%, rgba(157,116,255,.06), transparent 28rem),
        rgba(11, 11, 16, .78);
    box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.035);
    isolation: isolate;
}

.game-shell::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    opacity: .33;
    background-image: radial-gradient(rgba(255,255,255,.16) .7px, transparent .7px);
    background-size: 19px 19px;
    mask-image: radial-gradient(circle at center, black, transparent 70%);
}

.arena-head, .arena-foot {
    z-index: 5;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(12,12,17,.72);
    backdrop-filter: blur(16px);
}

.arena-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.round-copy { min-width: 0; }

.eyebrow {
    margin: 0 0 3px;
    color: var(--lime);
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-align: left;
    text-transform: uppercase;
}

.round-title {
    margin: 0;
    display: block;
    overflow: hidden;
    color: #dcd9e7;
    font-size: .88rem;
    font-weight: 680;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mode-switch {
    display: flex;
    padding: 4px;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(5,5,8,.62);
}

.mode-button {
    min-width: 72px;
    border: 0;
    border-radius: 9px;
    padding: 8px 11px;
    color: var(--muted);
    background: transparent;
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .04em;
    cursor: pointer;
    transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}

.mode-button:hover:not(:disabled) { color: var(--text); }
.mode-button.active { color: #111408; background: var(--lime); box-shadow: 0 4px 18px rgba(200,255,61,.15); }
.mode-button:disabled { cursor: not-allowed; opacity: .5; }

.arena {
    position: relative;
    min-height: 0;
    overflow: hidden;
    touch-action: manipulation;
}

.arena::before, .arena::after {
    content: "";
    position: absolute;
    width: 1px;
    height: 48px;
    top: 50%;
    left: 50%;
    background: linear-gradient(transparent, rgba(255,255,255,.1), transparent);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.arena::after { width: 48px; height: 1px; }

.target {
    --hue: 82;
    position: absolute;
    z-index: 4;
    left: 50%;
    top: 50%;
    width: clamp(78px, 8.2vw, 106px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px solid hsla(var(--hue), 95%, 72%, .48);
    border-radius: 31%;
    color: white;
    background:
        radial-gradient(circle at 36% 28%, hsla(var(--hue), 100%, 76%, .38), transparent 24%),
        linear-gradient(145deg, hsla(var(--hue), 80%, 55%, .26), hsla(var(--hue), 80%, 34%, .12)),
        #171820;
    box-shadow:
        0 0 0 7px hsla(var(--hue), 90%, 60%, .035),
        0 18px 40px rgba(0,0,0,.38),
        0 0 34px hsla(var(--hue), 90%, 55%, .16),
        inset 0 1px rgba(255,255,255,.16);
    opacity: 0;
    transform: translate(-50%, -50%) scale(.6) rotate(-7deg);
    cursor: pointer;
    transition: opacity .15s ease, transform .24s cubic-bezier(.2, .8, .2, 1), box-shadow .2s ease;
    will-change: left, top, transform;
}

.target.visible { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
.target:hover {
    box-shadow: 0 0 0 9px hsla(var(--hue),90%,60%,.055), 0 20px 46px rgba(0,0,0,.42),
        0 0 46px hsla(var(--hue),90%,55%,.25), inset 0 1px rgba(255,255,255,.2);
}
.target.round { border-radius: 50%; }
.target.squircle { border-radius: 42% 22% 39% 25%; }

.target-key {
    font-size: clamp(2.05rem, 4.2vw, 3.5rem);
    font-weight: 830;
    letter-spacing: -.06em;
    line-height: 1;
    text-shadow: 0 3px 18px rgba(0,0,0,.5);
}

.target-hint {
    position: absolute;
    left: 50%;
    bottom: 12px;
    color: hsla(var(--hue), 95%, 88%, .7);
    font-size: .5rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    transform: translateX(-50%);
}

.target.miss { animation: shake .26s ease; border-color: var(--danger); }

.game-overlay {
    position: absolute;
    z-index: 8;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 22px;
    background: radial-gradient(circle at 50% 45%, rgba(13,13,20,.68), rgba(8,8,12,.9));
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
}

.game-overlay.visible { opacity: 1; pointer-events: auto; }
.overlay-content { width: min(540px, 100%); text-align: center; }

.mini-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    color: #bab6c7;
    font-size: .7rem;
    font-weight: 780;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.mini-label::before { content: ""; width: 24px; height: 1px; background: var(--lime); box-shadow: 0 0 10px rgba(200,255,61,.7); }

.overlay-title {
    margin: 0;
    color: var(--text);
    font-size: clamp(2.35rem, 6.2vw, 5rem);
    font-weight: 820;
    letter-spacing: -.07em;
    line-height: .95;
    text-decoration: none;
}

.overlay-title .accent { color: var(--lime); }
.overlay-description {
    max-width: 430px;
    margin: 18px auto 26px;
    color: #9692a2;
    font-size: clamp(.9rem, 1.5vw, 1.02rem);
    line-height: 1.65;
}

.primary-button {
    min-width: 192px;
    border: 1px solid #d9ff79;
    border-radius: 16px;
    padding: 15px 22px;
    color: #101308;
    background: var(--lime);
    box-shadow: 0 12px 34px rgba(200,255,61,.13), inset 0 1px rgba(255,255,255,.55);
    font-size: .82rem;
    font-weight: 830;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.primary-button:hover { transform: translateY(-3px); box-shadow: 0 18px 42px rgba(200,255,61,.2), inset 0 1px rgba(255,255,255,.55); }
.key-tip { margin-top: 15px; color: #686573; font-size: .72rem; }

kbd {
    display: inline-grid;
    min-width: 26px;
    height: 22px;
    place-items: center;
    margin: 0 4px;
    padding: 0 6px;
    border: 1px solid rgba(255,255,255,.16);
    border-bottom-width: 2px;
    border-radius: 6px;
    color: #aaa6b5;
    background: #191820;
    font-family: inherit;
    font-size: .62rem;
    font-weight: 700;
}

.countdown {
    color: var(--text);
    font-size: clamp(6rem, 18vw, 13rem);
    font-weight: 850;
    letter-spacing: -.09em;
    line-height: .8;
    text-shadow: 0 0 60px rgba(200,255,61,.14);
    animation: count-in .58s cubic-bezier(.2,.8,.2,1);
}

.results-title {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.result-score {
    margin: 0;
    color: var(--lime);
    font-size: clamp(3.2rem, 8vw, 6rem);
    font-weight: 840;
    letter-spacing: -.07em;
    line-height: 1;
    text-shadow: 0 0 40px rgba(200,255,61,.12);
}

.result-score small { color: var(--muted); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.result-verdict { margin: 9px 0 22px; color: #d7d3df; font-size: 1.05rem; font-weight: 680; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 auto 22px; }

.result-item { padding: 12px 8px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.result-item strong { display: block; font-size: 1.08rem; }
.result-item span { display: block; margin-top: 3px; color: var(--muted); font-size: .6rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }

.arena-foot {
    position: relative;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 620;
}

.progress-track { position: absolute; top: -1px; left: 0; right: 0; height: 2px; background: rgba(255,255,255,.03); }
.progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--violet), var(--cyan), var(--lime));
    box-shadow: 0 0 12px rgba(77,232,255,.34);
    transform-origin: left;
    transition: transform .1s linear;
}

.instruction { gap: 9px; }
.instruction::before { content: ""; width: 7px; height: 7px; border: 1px solid #575361; border-radius: 50%; }
.reaction-readout { color: #aaa6b5; font-variant-numeric: tabular-nums; }
.reaction-readout strong { color: var(--text); font-size: .8rem; }

.float-score {
    position: absolute;
    z-index: 6;
    color: var(--lime);
    font-size: .8rem;
    font-weight: 850;
    pointer-events: none;
    text-shadow: 0 0 12px rgba(200,255,61,.5);
    animation: score-up .6s ease forwards;
}

.flash {
    position: absolute;
    z-index: 3;
    width: 88px;
    aspect-ratio: 1;
    border: 1px solid var(--lime);
    border-radius: 50%;
    pointer-events: none;
    animation: flash-out .52s ease-out forwards;
}

.screen-reader-only {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@keyframes breathe { 50% { opacity: .5; transform: scale(.82); } }
@keyframes count-in {
    from { opacity: 0; transform: scale(1.4); filter: blur(8px); }
    to { opacity: 1; transform: scale(1); filter: blur(0); }
}
@keyframes shake {
    25% { transform: translate(-55%, -50%) rotate(-5deg); }
    55% { transform: translate(-45%, -50%) rotate(5deg); }
    80% { transform: translate(-53%, -50%) rotate(-2deg); }
}
@keyframes score-up {
    from { opacity: 0; transform: translate(-50%, 8px) scale(.8); }
    20% { opacity: 1; }
    to { opacity: 0; transform: translate(-50%, -38px) scale(1.08); }
}
@keyframes flash-out {
    from { opacity: .7; transform: translate(-50%, -50%) scale(.35); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
}

@media (min-width: 721px) and (max-height: 900px) {
    .app {
        padding: 18px 24px;
        gap: 14px;
    }

    .brand-mark {
        width: 38px;
        border-radius: 12px;
    }

    .stat {
        padding: 12px 16px;
        border-radius: 16px;
    }

    .stat-value {
        margin-top: 5px;
        font-size: 1.55rem;
    }

    .arena-head,
    .arena-foot {
        padding: 12px 18px;
    }

    .overlay-title {
        font-size: clamp(2.8rem, 5.2vw, 4.2rem);
    }

    .mini-label {
        margin-bottom: 12px;
    }

    .overlay-description {
        margin: 12px auto 18px;
        line-height: 1.5;
    }

    .primary-button {
        padding: 13px 20px;
    }
}

@media (max-width: 720px) {
    .app {
        min-height: 100dvh;
        height: auto;
        padding: 14px;
        grid-template-rows: auto auto minmax(500px, calc(100dvh - 174px));
        gap: 12px;
    }
    .brand-subtitle, .status-pill span, .key-tip, .reaction-readout span { display: none; }
    .status-pill { width: 42px; justify-content: center; padding: 0; }
    .stats { gap: 7px; }
    .stat { padding: 11px 10px; border-radius: 14px; }
    .stat-label { font-size: .56rem; letter-spacing: .08em; }
    .stat-value { font-size: 1.25rem; }
    .game-shell { border-radius: 22px; }
    .arena-head { align-items: flex-start; flex-direction: column; padding: 13px 14px; }
    .mode-switch { width: 100%; }
    .mode-button { flex: 1; min-width: 0; padding: 7px 5px; }
    .arena { min-height: 350px; }
    .target { width: 84px; }
    .arena-foot { padding: 14px; }
    .overlay-title { font-size: clamp(2.7rem, 15vw, 4.8rem); }
    .overlay-description { margin: 14px auto 21px; line-height: 1.5; }
}

@media (max-width: 390px) {
    .app { padding: 10px; }
    .brand-mark, .icon-button, .status-pill { width: 38px; height: 38px; }
    .brand-name { font-size: .9rem; }
    .stat:nth-child(4) small { display: none; }
    .result-grid { gap: 5px; }
}

@media (hover: none) { .desktop-only { display: none; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
