/* =========================================================
   Flappy Horror · The Reaper's Flight — NX Gaming
   ========================================================= */

/* ---------- Fonts (self-hosted latin subsets from Google Fonts, SIL OFL 1.1; see fonts/) ---------- */
@font-face {
    font-family: 'Rubik Wet Paint';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/rubik-wet-paint-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 400 700; /* variable font: one file for 400, 500 and 700 */
    font-display: swap;
    src: url(fonts/space-grotesk-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500 700; /* variable font: one file for 500 and 700 */
    font-display: swap;
    src: url(fonts/jetbrains-mono-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --void: #05080a;
    --crypt: #0b1215;
    --crypt-2: #111b1f;
    --line: rgba(160, 220, 230, 0.12);
    --line-2: rgba(160, 220, 230, 0.22);
    --bone: #e8f1f2;
    --mist: #9fb4b9;
    --dim: #5f7479;
    --blood: #e3263a;
    --blood-deep: #8f0f1e;
    --ecto: #5ff5d1;
    --pumpkin: #ff8a1f;
    --gold: #f6c453;

    --font-display: 'Rubik Wet Paint', 'Creepster', system-ui, cursive;
    --font-ui: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

    /* Height budget for the top bar in the stage-size maths below. Left at its original
       value (the NX Gaming bar itself is 52px / 48px) so the canvas size doesn't change. */
    --header-h: 64px;
    --footer-h: 56px;
    --radius: 18px;
}

*,
*::before,
*::after { box-sizing: border-box; }

/* The cabinet's rotating glow pokes past the screen edge on phones. Clip sideways
   overflow at the viewport (no scroll container, so the glow itself isn't cut). */
html { height: 100%; overflow-x: clip; }

body {
    margin: 0;
    min-height: 100%;
    background-color: var(--void);
    background-image:
        radial-gradient(120% 80% at 50% 0%, rgba(5, 8, 10, 0.2), rgba(5, 8, 10, 0.92) 70%),
        linear-gradient(180deg, rgba(5, 8, 10, 0.55), rgba(5, 8, 10, 0.95)),
        url(./bg2.jpg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--bone);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* fallback for browsers without clip */
    overflow-x: clip;
}

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

/* ---------- Atmosphere ---------- */
.atmos { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.atmos__fog {
    position: absolute; left: -50%; width: 200%; height: 60%;
    background:
        radial-gradient(40% 50% at 20% 60%, rgba(150, 210, 220, 0.10), transparent 70%),
        radial-gradient(30% 40% at 60% 50%, rgba(150, 210, 220, 0.08), transparent 70%),
        radial-gradient(35% 45% at 85% 70%, rgba(150, 210, 220, 0.09), transparent 70%);
    filter: blur(20px);
}
.atmos__fog--a { bottom: -10%; animation: fogDrift 60s linear infinite; }
.atmos__fog--b { bottom: 10%; opacity: 0.6; animation: fogDrift 90s linear infinite reverse; }
.atmos__flash {
    position: absolute; inset: 0; background: rgba(200, 230, 255, 0.9);
    opacity: 0; mix-blend-mode: overlay;
}
.atmos__flash.is-on { animation: flash 0.9s ease-out; }

@keyframes fogDrift { from { transform: translateX(0); } to { transform: translateX(25%); } }
@keyframes flash {
    0% { opacity: 0; } 6% { opacity: 0.7; } 12% { opacity: 0.1; }
    18% { opacity: 0.5; } 100% { opacity: 0; }
}

/* ---------- NX Gaming bar ----------
   Shared by the hub (nesturex.com/nx-gaming) and every game page: keep the copies
   identical. Always dark, whatever the page theme, because the logo's white letters
   vanish on light backgrounds. */
.nxg-bar {
    box-sizing: content-box;
    height: 52px;
    padding: env(safe-area-inset-top, 0px) clamp(16px, 3vw, 40px) 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: rgba(11, 16, 32, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #fff;
    color-scheme: dark;
}
.nxg-bar__logo {
    display: inline-flex; align-items: center;
    min-height: 44px;
    border-radius: 8px;
}
.nxg-bar__logo img { display: block; width: auto; height: 28px; }
.nxg-bar__all {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #fff;
    font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}
.nxg-bar__all:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.24); }
.nxg-bar__all svg { flex: none; width: 16px; height: 16px; }
.nxg-bar__logo:focus-visible,
.nxg-bar__all:focus-visible { outline: 2px solid #5b9cf0; outline-offset: 2px; }
@media (max-width: 760px) {
    .nxg-bar { height: 48px; }
    .nxg-bar__logo img { height: 24px; }
}
/* Very narrow phones: icon-only button (the link keeps its aria-label). */
@media (max-width: 359px) {
    .nxg-bar__all { padding: 0 13px; }
    .nxg-bar__all span { display: none; }
}
/* ---------- /NX Gaming bar ---------- */

/* ---------- Top bar (the NX Gaming bar, plus the sound button) ---------- */
.topbar { position: relative; z-index: 2; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 42px; height: 42px; display: grid; place-items: center;
    border-radius: 12px; border: 1px solid var(--line-2);
    background: rgba(11, 18, 21, 0.6); backdrop-filter: blur(8px);
    color: var(--bone); cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.icon-btn:hover { border-color: var(--ecto); background: rgba(95, 245, 209, 0.08); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--ecto); outline-offset: 2px; }
.ico { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ico--off { display: none; }
.icon-btn[aria-pressed="true"] .ico--on { display: none; }
.icon-btn[aria-pressed="true"] .ico--off { display: block; color: var(--blood); }

/* ---------- Layout ---------- */
.layout {
    position: relative; z-index: 1;
    display: grid;
    grid-template-columns: minmax(240px, 320px) auto minmax(240px, 320px);
    justify-content: center;
    align-items: center;
    gap: clamp(24px, 4vw, 64px);
    padding: 8px clamp(16px, 3vw, 40px) 16px;
    min-height: calc(100dvh - var(--header-h) - var(--footer-h));
}

/* ---------- Side panels ---------- */
.panel { max-width: 320px; }
.eyebrow {
    margin: 0 0 12px; font-family: var(--font-mono); font-size: 11px;
    letter-spacing: 0.22em; text-transform: uppercase; color: var(--pumpkin);
}
.title {
    margin: 0; font-family: var(--font-display); font-weight: 400;
    font-size: clamp(52px, 5.5vw, 84px); line-height: 0.88; letter-spacing: 0.01em;
    color: var(--bone);
    text-shadow: 0 0 30px rgba(159, 180, 185, 0.25);
}
.title span { color: var(--blood); text-shadow: 0 0 28px rgba(227, 38, 58, 0.45); }
.subtitle {
    margin: 10px 0 0; font-family: var(--font-mono); font-size: 13px;
    letter-spacing: 0.3em; text-transform: uppercase; color: var(--mist);
}
.lore { margin: 22px 0 0; color: var(--mist); line-height: 1.65; font-size: 15px; }
.lore em { color: var(--ecto); font-style: normal; }

.panel__h {
    margin: 32px 0 14px; font-family: var(--font-mono); font-weight: 700;
    font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--dim);
    display: flex; align-items: center; gap: 12px;
}
.panel__h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.panel--records .panel__h:first-child { margin-top: 0; }

.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.keys li { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--mist); }
.keys__k { display: flex; gap: 6px; flex-wrap: wrap; }
kbd {
    font-family: var(--font-mono); font-size: 11px; font-weight: 700;
    min-width: 28px; padding: 5px 8px; text-align: center;
    color: var(--bone); background: var(--crypt-2);
    border: 1px solid var(--line-2); border-bottom-width: 3px; border-radius: 7px;
}

.records { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.records__item {
    margin: 0; padding: 14px 16px; border-radius: 14px;
    background: rgba(11, 18, 21, 0.72); border: 1px solid var(--line);
    backdrop-filter: blur(10px);
}
.records__item--hero { grid-column: 1 / -1; }
.records dt {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--dim);
}
.records dd {
    margin: 6px 0 0; font-family: var(--font-mono); font-weight: 700; font-size: 22px;
    font-variant-numeric: tabular-nums; color: var(--bone);
}
.records__item--hero dd {
    font-family: var(--font-display); font-weight: 400; font-size: 54px; line-height: 1;
    color: var(--blood); text-shadow: 0 0 24px rgba(227, 38, 58, 0.4);
}

.medals { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.medals li {
    display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 12px;
    border: 1px dashed var(--line-2); color: var(--dim);
    transition: all 0.4s ease;
}
.medals__ico { font-size: 18px; filter: grayscale(1) brightness(0.5); transition: filter 0.4s; }
.medals__name { font-weight: 500; font-size: 14px; }
.medals__req { font-family: var(--font-mono); font-size: 12px; }
.medals li.is-earned {
    border-style: solid; color: var(--bone);
    background: linear-gradient(90deg, rgba(255, 138, 31, 0.10), transparent);
    border-color: rgba(255, 138, 31, 0.35);
}
.medals li.is-earned .medals__ico { filter: none; }
.medals li.is-earned[data-tier="moon"] {
    background: linear-gradient(90deg, rgba(227, 38, 58, 0.18), transparent);
    border-color: rgba(227, 38, 58, 0.5);
}

.omen {
    margin-top: 24px; padding: 16px 18px; border-radius: 14px;
    background: linear-gradient(135deg, rgba(143, 15, 30, 0.22), rgba(11, 18, 21, 0.6));
    border: 1px solid rgba(227, 38, 58, 0.25);
    font-size: 13.5px; line-height: 1.6; color: var(--mist);
}
.omen p { margin: 0; }
.omen__h {
    margin-bottom: 6px !important; font-family: var(--font-mono); font-size: 10px;
    letter-spacing: 0.22em; text-transform: uppercase; color: var(--blood);
}
.omen strong { color: var(--bone); font-weight: 700; }

/* ---------- Cabinet / stage ---------- */
.cabinet { display: grid; place-items: center; }
.cabinet__frame {
    position: relative; padding: 10px; border-radius: calc(var(--radius) + 10px);
    background: linear-gradient(160deg, rgba(40, 60, 66, 0.55), rgba(8, 12, 14, 0.9) 40%, rgba(60, 10, 18, 0.55));
    box-shadow:
        0 0 0 1px var(--line-2),
        0 30px 80px -20px rgba(0, 0, 0, 0.9),
        0 0 120px -30px rgba(95, 245, 209, 0.25);
}
.cabinet__frame::before {
    /* breathing ecto glow */
    content: ""; position: absolute; inset: -2px; border-radius: inherit; z-index: -1;
    background: conic-gradient(from 0deg, transparent, rgba(95, 245, 209, 0.5), transparent 30%, rgba(227, 38, 58, 0.5), transparent 60%);
    filter: blur(14px); opacity: 0.45;
    animation: spin 14s linear infinite;
}
body.blood-moon .cabinet__frame::before {
    background: conic-gradient(from 0deg, transparent, rgba(227, 38, 58, 0.8), transparent 30%, rgba(255, 138, 31, 0.6), transparent 60%);
    opacity: 0.7;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage {
    --h: min(calc(100dvh - var(--header-h) - var(--footer-h) - 48px), 860px);
    position: relative;
    height: var(--h);
    aspect-ratio: 9 / 16;
    max-width: calc(100vw - 52px);
    border-radius: var(--radius);
    overflow: hidden;
    background: #071012;
    container-type: size;
    touch-action: manipulation;
    user-select: none; -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}
.stage.is-shaking { animation: shake 0.45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
    10%, 90% { transform: translate(-2px, 1px); }
    20%, 80% { transform: translate(4px, -2px); }
    30%, 50%, 70% { transform: translate(-6px, 3px); }
    40%, 60% { transform: translate(6px, -2px); }
}
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Overlays ---------- */
.overlay {
    position: absolute; inset: 0; z-index: 3;
    display: grid; place-items: center; padding: 8cqw;
    background: radial-gradient(100% 70% at 50% 45%, rgba(5, 8, 10, 0.55), rgba(5, 8, 10, 0.88));
    opacity: 0; visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s;
    text-align: center;
}
.overlay.is-active { opacity: 1; visibility: visible; }
.overlay--ghostly { background: transparent; pointer-events: none; }
.overlay__inner { display: flex; flex-direction: column; align-items: center; width: 100%; }
.overlay.is-active .overlay__inner { animation: rise 0.6s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6cqh) scale(0.96); } to { opacity: 1; transform: none; } }

.ov-eyebrow {
    margin: 0 0 3cqh; font-family: var(--font-mono); font-size: 3cqw;
    letter-spacing: 0.4em; color: var(--pumpkin); text-transform: uppercase;
}
.ov-title {
    margin: 0; font-family: var(--font-display); font-weight: 400;
    font-size: 17cqw; line-height: 0.86; color: var(--bone);
    text-shadow: 0 0 6cqw rgba(159, 180, 185, 0.35);
}
.ov-title span { color: var(--blood); text-shadow: 0 0 6cqw rgba(227, 38, 58, 0.6); }
.ov-title--sm { font-size: 12cqw; }
.ov-title--blood { color: var(--blood); text-shadow: 0 0 6cqw rgba(227, 38, 58, 0.6); }
.ov-sub {
    margin: 2.5cqh 0 0; font-family: var(--font-mono); font-size: 3.4cqw;
    letter-spacing: 0.3em; text-transform: uppercase; color: var(--mist);
}
.ov-hint {
    margin: 2.5cqh 0 0; font-family: var(--font-mono); font-size: 2.8cqw;
    letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim);
}

/* Buttons */
.btn {
    position: relative; margin-top: 6cqh;
    padding: 3.6cqw 8cqw; border-radius: 999px;
    font-family: var(--font-ui); font-weight: 700; font-size: 4.2cqw;
    letter-spacing: 0.08em; text-transform: uppercase;
    cursor: pointer; border: 0; color: var(--bone);
    transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.25s;
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 2px solid var(--ecto); outline-offset: 3px; }
.btn--blood {
    background: linear-gradient(180deg, #ff3b4e, var(--blood) 45%, var(--blood-deep));
    box-shadow: 0 0 0 1px rgba(255, 120, 130, 0.4) inset, 0 10px 30px -8px rgba(227, 38, 58, 0.8);
    animation: pulse 2.4s ease-in-out infinite;
}
.btn--blood:hover { box-shadow: 0 0 0 1px rgba(255, 160, 170, 0.6) inset, 0 12px 40px -6px rgba(227, 38, 58, 1); }
.btn--ghost {
    background: rgba(232, 241, 242, 0.06);
    box-shadow: 0 0 0 1px var(--line-2) inset;
}
.btn--ghost:hover { background: rgba(95, 245, 209, 0.12); box-shadow: 0 0 0 1px var(--ecto) inset; }
/* "More games" link: smaller, and well below the play controls so a flap tap can't land on it */
.btn--more {
    display: inline-block; margin-top: 7cqh;
    padding: 2.4cqw 5.5cqw; font-size: 3.1cqw;
    text-decoration: none; color: var(--mist);
}
.btn--more:hover { color: var(--bone); }
.btn--more[aria-disabled="true"] { pointer-events: none; }
.btn-row { display: flex; gap: 3cqw; margin-top: 5cqh; }
.btn-row .btn { margin-top: 0; padding: 3.4cqw 6cqw; }
@keyframes pulse { 50% { box-shadow: 0 0 0 1px rgba(255, 120, 130, 0.4) inset, 0 10px 46px -4px rgba(227, 38, 58, 0.95); } }

/* Get ready */
.overlay__inner--ready { justify-content: flex-start; height: 100%; padding-top: 16cqh; }
.overlay__inner--ready .ready__tap { margin-top: 26cqh; }
.ready__word {
    margin: 0; font-family: var(--font-display); font-size: 13cqw; color: var(--ecto);
    text-shadow: 0 0 6cqw rgba(95, 245, 209, 0.6);
    animation: flicker 3s infinite;
}
.ready__tap {
    display: flex; flex-direction: column; align-items: center; gap: 2cqh;
    font-family: var(--font-mono); font-size: 3.2cqw; letter-spacing: 0.25em;
    text-transform: uppercase; color: var(--bone);
}
.ready__ring {
    width: 12cqw; height: 12cqw; border-radius: 50%;
    border: 2px solid var(--bone); position: relative;
}
.ready__ring::after {
    content: ""; position: absolute; inset: -2px; border-radius: 50%;
    border: 2px solid var(--ecto); animation: ping 1.4s ease-out infinite;
}
@keyframes ping { from { transform: scale(1); opacity: 1; } to { transform: scale(2); opacity: 0; } }
.ready__tip {
    margin: 4cqh 0 0; max-width: 80%; font-size: 3.3cqw; line-height: 1.5; color: var(--mist);
    padding: 2.4cqw 4cqw; border-radius: 3cqw;
    background: rgba(5, 8, 10, 0.6); border: 1px solid var(--line);
}
@keyframes flicker {
    0%, 19%, 21%, 23%, 54%, 56%, 100% { opacity: 1; }
    20%, 22%, 55% { opacity: 0.35; }
}

/* Game over tombstone */
.tomb {
    position: relative; margin-top: 5cqh; width: 82%;
    padding: 6cqw 5cqw 5cqw;
    border-radius: 40cqw 40cqw 4cqw 4cqw;
    background:
        linear-gradient(180deg, rgba(60, 76, 80, 0.9), rgba(24, 32, 35, 0.95)),
        var(--crypt);
    box-shadow: 0 0 0 1px rgba(200, 230, 235, 0.15) inset, 0 3cqh 6cqh -2cqh rgba(0, 0, 0, 0.9);
}
.tomb__medal { display: flex; flex-direction: column; align-items: center; gap: 1cqh; }
.tomb__medal-ico {
    width: 16cqw; height: 16cqw; display: grid; place-items: center; border-radius: 50%;
    font-size: 8cqw; background: rgba(5, 8, 10, 0.5);
    box-shadow: 0 0 0 1px var(--line-2) inset;
    color: var(--dim);
}
.tomb__medal-name {
    font-family: var(--font-mono); font-size: 2.8cqw; letter-spacing: 0.2em; text-transform: uppercase; color: var(--mist);
}
.tomb__medal[data-tier="bone"] .tomb__medal-ico { box-shadow: 0 0 0 2px #d9cfb8 inset, 0 0 5cqw rgba(217, 207, 184, 0.35); }
.tomb__medal[data-tier="skull"] .tomb__medal-ico { box-shadow: 0 0 0 2px #cfd8dc inset, 0 0 5cqw rgba(207, 216, 220, 0.45); }
.tomb__medal[data-tier="pumpkin"] .tomb__medal-ico { box-shadow: 0 0 0 2px var(--gold) inset, 0 0 6cqw rgba(246, 196, 83, 0.6); }
.tomb__medal[data-tier="moon"] .tomb__medal-ico { box-shadow: 0 0 0 2px var(--blood) inset, 0 0 7cqw rgba(227, 38, 58, 0.8); }
.tomb__medal:not([data-tier="none"]) .tomb__medal-ico { animation: medalIn 0.8s 0.3s cubic-bezier(.2,.9,.3,1.5) both; }
@keyframes medalIn { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }

.tomb__stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 3cqh 0 0; }
.tomb__stats div { margin: 0; }
.tomb__stats div + div { border-left: 1px solid rgba(200, 230, 235, 0.12); }
.tomb__stats dt {
    font-family: var(--font-mono); font-size: 2.5cqw; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim);
}
.tomb__stats dd {
    margin: 0.6cqh 0 0; font-family: var(--font-display); font-size: 9cqw; line-height: 1;
    color: var(--bone); font-variant-numeric: tabular-nums;
}
#overScore { color: var(--blood); }
#overSouls { color: var(--ecto); }
.tomb__new {
    position: absolute; top: -2.5cqw; right: -2cqw; margin: 0;
    padding: 1.4cqw 3cqw; border-radius: 99px; transform: rotate(8deg);
    background: var(--pumpkin); color: var(--void);
    font-family: var(--font-mono); font-weight: 700; font-size: 2.6cqw; letter-spacing: 0.15em; text-transform: uppercase;
    box-shadow: 0 0 5cqw rgba(255, 138, 31, 0.6);
    animation: medalIn 0.6s 0.6s cubic-bezier(.2,.9,.3,1.5) both;
}
.epitaph {
    margin: 3cqh 0 0; min-height: 2.5em; max-width: 86%;
    font-style: italic; font-size: 3.3cqw; line-height: 1.5; color: var(--mist);
}

/* In-game buttons */
.phase-btn, .pause-btn {
    position: absolute; z-index: 2; cursor: pointer; border: 0;
    -webkit-tap-highlight-color: transparent;
}
.pause-btn {
    top: 3cqw; right: 3cqw; width: 10cqw; height: 10cqw;
    border-radius: 3cqw; display: grid; place-items: center;
    background: rgba(5, 8, 10, 0.45); color: var(--bone);
    box-shadow: 0 0 0 1px var(--line-2) inset;
}
.pause-btn svg { width: 55%; height: 55%; fill: currentColor; }
.phase-btn {
    right: 4cqw; bottom: 1.2cqh; width: 16cqw; height: 16cqw; border-radius: 50%;
    font-family: var(--font-mono); font-weight: 700; font-size: 2.8cqw; letter-spacing: 0.12em;
    color: var(--void);
    background: radial-gradient(circle at 35% 30%, #c8fff1, var(--ecto) 45%, #129b80);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4) inset, 0 0 8cqw rgba(95, 245, 209, 0.8);
    animation: phaseReady 1.1s ease-in-out infinite;
}
.phase-btn[hidden], .pause-btn[hidden] { display: none; }
@keyframes phaseReady { 50% { transform: scale(1.08); box-shadow: 0 0 0 2px rgba(255,255,255,0.6) inset, 0 0 14cqw rgba(95, 245, 209, 1); } }

/* ---------- How to play ---------- */
.howto {
    position: relative; z-index: 1;
    max-width: 1040px; margin: 8px auto 0;
    padding: 0 clamp(16px, 3vw, 40px);
}
.howto__title {
    margin: 0 0 16px; font-family: var(--font-mono); font-weight: 700;
    font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--mist);
    display: flex; align-items: center; gap: 12px;
}
.howto__title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.howto__grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.howto__block {
    padding: 18px 20px; border-radius: 14px;
    background: rgba(11, 18, 21, 0.72); border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    font-size: 15px; line-height: 1.65; color: var(--mist);
}
.howto__block p { margin: 0; }
.howto__block p + p { margin-top: 12px; }
.howto__h {
    margin: 0 0 10px; font-family: var(--font-mono); font-weight: 700;
    font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--pumpkin);
}
.howto__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.howto__list strong { color: var(--bone); font-weight: 700; }
.howto__link {
    display: inline-block; margin-top: 16px;
    color: var(--ecto); font-weight: 700; text-decoration: none;
    border-bottom: 1px solid rgba(95, 245, 209, 0.35);
}
.howto__link:hover { border-bottom-color: var(--ecto); }
.howto__link:focus-visible { outline: 2px solid var(--ecto); outline-offset: 3px; border-radius: 2px; }

/* ---------- Footer ---------- */
.footer {
    position: relative; z-index: 1;
    min-height: var(--footer-h);
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 18px;
    padding: 12px 16px 18px;
    font-family: var(--font-mono); font-size: 12px; color: var(--dim);
    text-align: center;
}
.footer p { margin: 0; }
.footer strong { color: var(--bone); letter-spacing: 0.08em; }
.footer__small { color: #46585c; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .layout { grid-template-columns: auto minmax(240px, 300px); }
    .panel--lore { display: none; }
}

@media (max-width: 760px) {
    :root { --header-h: 54px; }
    .layout {
        grid-template-columns: 1fr;
        padding: 0 12px 24px; gap: 28px;
    }
    .stage {
        --h: min(calc(100dvh - var(--header-h) - 30px), calc((100vw - 44px) * 16 / 9));
        max-width: none;
    }
    .panel--lore { display: block; }
    .panel { max-width: 520px; width: 100%; margin: 0 auto; }
    .panel--lore { order: 2; }
    .panel--records { order: 3; }
    .howto { max-width: 544px; padding: 0 12px; margin-top: 0; }
    .howto__grid { grid-template-columns: 1fr; }
}

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