/* Ruby Grid: one stylesheet for the site and the game. */

@font-face {
    font-family: "Chakra Petch";
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    src: url("../fonts/chakra-petch-600.woff2") format("woff2");
}
@font-face {
    font-family: "Chakra Petch";
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    src: url("../fonts/chakra-petch-700.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
    src: url("../fonts/inter-var.woff2") format("woff2");
}

:root {
    --bg: #080a10;
    --bg-2: #0d1119;
    --panel: #111722;
    --panel-2: #172033;
    --line: #222d44;
    --line-2: #31405f;
    --text: #e9eef8;
    --muted: #98a4c0;
    --faint: #69758f;
    --ruby: #ff3b5c;
    --ruby-hi: #ff7088;
    --ruby-lo: #a8153a;
    --cyan: #35e0ff;
    --gold: #ffc43d;
    --green: #34e39a;
    --danger: #ff6b6b;
    --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
    --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --cut: 12px;
    --maxw: 1160px;
    --gutter: clamp(16px, 4vw, 32px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    color-scheme: dark;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--body);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 480px at 78% -8%, rgba(255, 59, 92, 0.16), transparent 70%),
        radial-gradient(700px 420px at 4% 12%, rgba(53, 224, 255, 0.08), transparent 70%),
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: auto, auto, 44px 44px, 44px 44px;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
a { color: var(--cyan); text-underline-offset: 3px; }
a:hover { color: #8aeeff; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

h1, h2, h3, h4 {
    font-family: var(--display);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: 0.01em;
    margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.5rem, 6.4vw, 4.6rem); }
h2 { font-size: clamp(1.75rem, 3.6vw, 2.5rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--ruby);
    color: #fff;
    font-weight: 600;
    border-radius: 4px;
}
.skip-link:focus { top: 12px; color: #fff; }

.wrap {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

/* ── Navigation ───────────────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(8, 10, 16, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.nav-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 64px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { color: #fff; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { color: var(--ruby); font-weight: 700; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 0 auto;
    padding: 0;
    list-style: none;
}
.nav-links a:not(.btn) {
    display: block;
    padding: 8px 14px;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 4px;
}
.nav-links a:not(.btn):hover, .nav-links a[aria-current="page"] { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-links .btn { margin-left: 8px; }
.nav-toggle {
    display: none;
    margin-left: auto;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line-2);
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
    display: block;
    width: 20px;
    height: 2px;
    margin-inline: auto;
    background: currentColor;
    content: "";
    position: relative;
}
.nav-toggle span::before { top: -6px; position: absolute; left: 0; }
.nav-toggle span::after { top: 6px; position: absolute; left: 0; }

@media (max-width: 760px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        flex-direction: column;
        align-items: stretch;
        margin: 0;
        padding: 12px var(--gutter) 20px;
        background: rgba(8, 10, 16, 0.97);
        border-bottom: 1px solid var(--line);
    }
    .nav-links.open { display: flex; }
    .nav-links a:not(.btn) { padding: 12px 8px; }
    .nav-links .btn { margin: 8px 0 0; text-align: center; }
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    --c: var(--cut);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 28px;
    border: 0;
    font-family: var(--display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff;
    cursor: pointer;
    clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
    transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.12); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.btn-primary { background: linear-gradient(135deg, var(--ruby-hi), var(--ruby) 45%, var(--ruby-lo)); }
.btn-ghost { background: var(--line-2); color: var(--text); }
.btn-ghost:hover { background: #3a4a6d; color: #fff; }
.btn-sm { min-height: 40px; padding: 0 18px; font-size: 0.9rem; }

/* ── Panels and labels ────────────────────────────────────────────────── */
.panel {
    position: relative;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 22px;
}
.panel::before, .panel::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ruby);
    pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.kicker {
    display: inline-block;
    margin: 0 0 14px;
    font-family: var(--display);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--cyan);
}
.kicker::before { content: "// "; color: var(--ruby); }
.label {
    margin: 0 0 10px;
    font-family: var(--display);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--faint);
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.section { padding-block: clamp(56px, 9vw, 104px); }
.section-head { max-width: 720px; margin-bottom: 40px; }
.section-head p { color: var(--muted); font-size: 1.08rem; }
.band { background: rgba(13, 17, 25, 0.72); border-block: 1px solid var(--line); }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero { padding-block: clamp(40px, 7vw, 88px) clamp(48px, 7vw, 80px); }
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: clamp(32px, 5vw, 72px);
    align-items: center;
}
.hero h1 span { color: var(--ruby); }
.hero-sub { max-width: 34em; font-size: 1.15rem; color: var(--muted); margin-bottom: 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 14px; }
.hero-copy { animation: rise 0.7s ease both; }
.demo { animation: rise 0.7s 0.12s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.demo-hud {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.demo-foot { display: flex; justify-content: space-between; gap: 12px; margin: 14px 0 0; font-size: 0.88rem; color: var(--muted); }

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
}

/* ── Board frame (shared by demo and game) ────────────────────────────── */
.board-frame {
    position: relative;
    width: 100%;
    max-width: 620px;
    aspect-ratio: 1 / 1;
    margin-inline: auto;
    background: #0a0e16;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    box-shadow: 0 0 0 4px rgba(255, 59, 92, 0.06), 0 18px 60px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(53, 224, 255, 0.04);
    overflow: hidden;
}
.board-frame canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; outline-offset: -3px; }
.toast {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    margin: 0;
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.4;
    background: rgba(8, 10, 16, 0.92);
    border: 1px solid var(--line-2);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
}
.board-cover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    text-align: center;
    background: rgba(8, 10, 16, 0.86);
    backdrop-filter: blur(3px);
}
.board-cover strong { font-family: var(--display); font-size: 1.8rem; }
.board-cover p { margin: 0 0 14px; color: var(--muted); }
.cover-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ── HUD tiles ────────────────────────────────────────────────────────── */
.hud-tile {
    padding: 10px 16px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ruby);
    border-radius: 3px;
}
.hud-tile .label { margin: 0; font-size: 0.7rem; }
.hud-tile output {
    display: block;
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.9rem;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.hud-tile.cyan { border-left-color: var(--cyan); }
.hud-tile.gold { border-left-color: var(--gold); }
.hud-tile.low output { color: var(--ruby-hi); }
.bump { animation: bump 0.25s ease; }
@keyframes bump { 50% { transform: scale(1.08); } }

/* ── Stat strip ───────────────────────────────────────────────────────── */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.stat-strip li {
    padding: 18px 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--ruby);
    border-radius: 3px;
}
.stat-strip b {
    display: block;
    font-family: var(--display);
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    line-height: 1.1;
    color: var(--text);
}
.stat-strip span { color: var(--muted); font-size: 0.92rem; }
@media (max-width: 700px) { .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Steps, gems, ranks ───────────────────────────────────────────────── */
.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}
.steps li { counter-increment: step; }
.steps li::before {
    content: "0" counter(step);
    display: block;
    margin-bottom: 8px;
    font-family: var(--display);
    font-weight: 700;
    font-size: 2.6rem;
    line-height: 1;
    color: var(--ruby);
}
.steps h3 { margin-bottom: 8px; }
.steps p { margin: 0; color: var(--muted); }
@media (max-width: 860px) { .steps { grid-template-columns: 1fr; } }

.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th {
    font-family: var(--display);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--faint);
}
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
caption { text-align: left; padding: 0 0 12px; }

.special-list { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.special-list li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.special-list b { color: var(--text); font-weight: 600; }
.sp-icon { flex: none; width: 34px; height: 34px; }

.gem-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.gem-grid li {
    padding: 18px 10px 14px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
}
.gem-grid svg { width: 52px; height: 52px; display: block; margin: 0 auto 8px; }
.gem-grid b { display: block; font-family: var(--display); font-size: 1rem; }
.gem-grid span { font-size: 0.82rem; color: var(--faint); }
@media (max-width: 900px) { .gem-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .gem-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.ladder { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.ladder li {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-2);
    border-radius: 3px;
}
.ladder li:nth-child(1) { border-left-color: var(--gold); }
.ladder li:nth-child(2) { border-left-color: var(--ruby); }
.ladder li:nth-child(3) { border-left-color: var(--cyan); }
.ladder b { font-family: var(--display); font-size: 1.1rem; }
.ladder span { font-family: var(--display); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Leaderboard ──────────────────────────────────────────────────────── */
.lb-table td:first-child, .lb-table th:first-child { width: 64px; }
.lb-rank { font-family: var(--display); font-weight: 700; color: var(--faint); }
.lb-table tr:nth-child(1) .lb-rank { color: var(--gold); }
.lb-table tr:nth-child(2) .lb-rank { color: #cfd8ea; }
.lb-table tr:nth-child(3) .lb-rank { color: #e0955a; }
.lb-title { color: var(--faint); font-size: 0.88rem; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 4px; font-family: var(--display); font-size: 1.25rem; color: var(--text); }

/* ── About and notes ──────────────────────────────────────────────────── */
.about { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.about p { color: var(--muted); }
.notes { display: grid; gap: 16px; }
.note { padding: 18px 20px; }
.note h3 { font-size: 1.05rem; margin-bottom: 6px; }
.note p { margin: 0; font-size: 0.95rem; }
@media (max-width: 860px) { .about { grid-template-columns: 1fr; } }

.cta {
    text-align: center;
    padding-block: clamp(56px, 8vw, 88px);
}
.cta h2 { max-width: 14em; margin-inline: auto; }
.cta p { color: var(--muted); max-width: 30em; margin-inline: auto; margin-bottom: 26px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); background: rgba(8, 10, 16, 0.9); padding-block: 48px 28px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: 32px; }
.footer p { color: var(--muted); font-size: 0.93rem; max-width: 26em; margin-top: 12px; }
.footer h2 { font-size: 0.78rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 12px; }
.footer ul { margin: 0; padding: 0; list-style: none; }
.footer li { margin-bottom: 8px; }
.footer a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.footer a:hover { color: var(--text); text-decoration: underline; }
.footer-bottom { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.86rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* ── Legal and plain pages ────────────────────────────────────────────── */
.page { padding-block: clamp(40px, 7vw, 80px) clamp(56px, 9vw, 104px); }
.legal { max-width: 760px; }
.legal h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); }
.legal h2 { font-size: 1.4rem; margin-top: 2em; }
.legal-date { color: var(--faint); font-size: 0.92rem; margin-bottom: 2em; }
.legal p, .legal li { color: #c3cce0; }
.legal ul { padding-left: 1.2em; }
.legal li { margin-bottom: 0.4em; }

/* ── Contact form ─────────────────────────────────────────────────────── */
.contact-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }
.form { display: grid; gap: 18px; }
.form label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.93rem; }
.form input[type="text"], .form input[type="email"], .form textarea, .field {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: #0a0e16;
    border: 1px solid var(--line-2);
    border-radius: 4px;
}
.form textarea { min-height: 160px; resize: vertical; }
.form input:focus, .form textarea:focus, .field:focus { outline: 2px solid var(--cyan); outline-offset: 1px; border-color: var(--cyan); }
.field-hint { margin: 6px 0 0; font-size: 0.86rem; color: var(--faint); }
.field-error { margin: 6px 0 0; font-size: 0.9rem; color: var(--danger); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.alert { padding: 14px 16px; border-radius: 4px; border: 1px solid var(--line-2); border-left-width: 3px; background: var(--panel); }
.alert.ok { border-left-color: var(--green); }
.alert.bad { border-left-color: var(--danger); }
.alert p { margin: 0; }

/* ── 404 ──────────────────────────────────────────────────────────────── */
.lost { text-align: center; padding-block: clamp(64px, 12vw, 140px); }
.lost .code { font-family: var(--display); font-weight: 700; font-size: clamp(5rem, 20vw, 11rem); line-height: 1; color: var(--ruby); text-shadow: 0 0 40px rgba(255, 59, 92, 0.35); }

/* ═════════════════════════════ GAME PAGE ═════════════════════════════ */
.game-body { background-attachment: scroll; }
.game-top {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px var(--gutter);
    background: rgba(8, 10, 16, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.game-links { display: flex; gap: 4px; margin-left: auto; }
.game-links a { padding: 8px 12px; color: var(--muted); text-decoration: none; font-size: 0.93rem; border-radius: 4px; }
.game-links a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
@media (max-width: 560px) { .game-links { display: none; } .player-chip { margin-left: auto; } }

.player-chip { position: relative; }
.player-chip > button {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 220px;
    min-height: 42px;
    padding: 4px 14px 4px 4px;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    cursor: pointer;
}
.player-chip > button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    font-family: var(--display);
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    border-radius: 50%;
    background: var(--ruby-lo);
}
.menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    min-width: 200px;
    padding: 6px;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.menu button, .menu a {
    display: block;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
}
.menu button:hover, .menu a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: clamp(20px, 3vw, 40px);
    width: 100%;
    max-width: 1180px;
    margin-inline: auto;
    padding: clamp(16px, 3vw, 36px) var(--gutter) 56px;
    align-items: start;
}
@media (max-width: 960px) { .game-layout { grid-template-columns: minmax(0, 1fr); } }

.board-col { min-width: 0; }
.hud { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; max-width: 620px; margin: 0 auto 10px; }
@media (max-width: 420px) { .hud-tile output { font-size: 1.45rem; } .hud-tile { padding: 8px 10px 10px; } }
.pips { display: flex; gap: 3px; max-width: 620px; margin: 0 auto 14px; }
.pips i { flex: 1; height: 6px; background: var(--line); border-radius: 1px; transition: background 0.2s; }
.pips i.on { background: var(--cyan); }
.pips.low i.on { background: var(--ruby); }
.board-hint { max-width: 620px; margin: 14px auto 0; font-size: 0.88rem; color: var(--faint); text-align: center; }

.side-col { display: grid; gap: 18px; min-width: 0; }
.rank-name { margin: 0 0 12px; font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1.1; }
.meter { height: 8px; background: var(--line); border-radius: 1px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ruby), var(--gold)); transition: width 0.5s ease; }
.rank-next { margin: 10px 0 0; font-size: 0.88rem; color: var(--muted); }

.lb-list { margin: 0; padding: 0; list-style: none; }
.lb-list li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 9px 8px;
    border-bottom: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}
.lb-list li:last-child { border-bottom: 0; }
.lb-list li.you { background: rgba(53, 224, 255, 0.08); box-shadow: inset 3px 0 0 var(--cyan); }
.lb-list .pos { font-family: var(--display); font-weight: 700; color: var(--faint); }
.lb-list li:nth-child(1) .pos { color: var(--gold); }
.lb-list li:nth-child(2) .pos { color: #cfd8ea; }
.lb-list li:nth-child(3) .pos { color: #e0955a; }
.lb-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list .pts { font-family: var(--display); font-weight: 600; }
.lb-empty { margin: 0; color: var(--muted); font-size: 0.95rem; }

.legend { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; font-size: 0.92rem; color: var(--muted); }
.legend li { display: flex; gap: 12px; align-items: flex-start; }
.legend b { color: var(--text); font-weight: 600; }

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow-y: auto;
    background: rgba(5, 7, 12, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal { width: 100%; max-width: 460px; padding: 30px 28px 26px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); }
.modal h1, .modal h2 { font-size: clamp(2rem, 6vw, 2.7rem); margin-bottom: 8px; }
.modal h1 span { color: var(--ruby); }
.modal > p { color: var(--muted); }
.modal .btn { width: 100%; margin-top: 6px; }
.modal-actions { display: grid; gap: 10px; margin-top: 18px; }
.how { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 0.93rem; color: var(--muted); }
.how summary { cursor: pointer; font-family: var(--display); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.82rem; color: var(--text); }
.how ul { margin: 12px 0 0; padding-left: 1.1em; }
.how li { margin-bottom: 6px; }
.fine { margin: 16px 0 0; font-size: 0.84rem; color: var(--faint); }

.final-score { font-family: var(--display); font-weight: 700; font-size: clamp(3.2rem, 14vw, 4.6rem); line-height: 1; margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.badge { padding: 4px 12px; font-family: var(--display); font-weight: 700; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: #1a1200; background: var(--gold); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.badge.cyan { background: var(--cyan); color: #00222a; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 6px; }
.stat-grid div { padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; text-align: center; }
.stat-grid b { display: block; font-family: var(--display); font-size: 1.35rem; line-height: 1.2; }
.stat-grid span { font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.save-note { min-height: 1.4em; margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }
.save-note.bad { color: var(--danger); }

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