@font-face { font-family: 'Oxanium'; font-weight: 500; font-display: swap; src: url('fonts/oxanium-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Oxanium'; font-weight: 700; font-display: swap; src: url('fonts/oxanium-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Oxanium'; font-weight: 800; font-display: swap; src: url('fonts/oxanium-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 500; font-display: swap; src: url('fonts/barlow-semi-condensed-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 600; font-display: swap; src: url('fonts/barlow-semi-condensed-latin-600-normal.woff2') format('woff2'); }

:root {
  --bg: #070b10;
  --panel: rgba(9, 15, 21, 0.86);
  --line: rgba(127, 246, 255, 0.18);
  --text: #e3eef3;
  --muted: #8ea3ad;
  --nav: #3ff0ff;
  --nav-dim: rgba(63, 240, 255, 0.14);
  --danger: #ff6a1a;
  --alert: #ff3a46;
  --safe: #5dff8a;
  --gold: #ffc23d;
  --display: 'Oxanium', 'Barlow Semi Condensed', system-ui, sans-serif;
  --ui: 'Barlow Semi Condensed', system-ui, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--ui); font-size: 17px; }
[hidden] { display: none !important; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
kbd { font-family: var(--display); font-size: 0.72em; font-weight: 700; padding: 1px 6px; border: 1px solid rgba(255,255,255,0.28); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,0.06); color: var(--text); white-space: nowrap; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.lbl { font-family: var(--display); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.hud-score { position: absolute; left: 24px; top: 20px; min-width: 210px; }
.hud-score .big { font-size: 46px; font-weight: 800; line-height: 1; margin: 2px 0 8px; }
.hud-score .row { display: flex; justify-content: space-between; gap: 18px; font-size: 16px; font-weight: 600; }
.hud-score .row b { font-family: var(--display); font-weight: 700; }
.hud-score .safe b { color: var(--safe); }
.hud-score .risk b { color: var(--danger); }
.hud-score .risk.zero b { color: var(--muted); }
.hud-depth { position: absolute; right: 24px; top: 20px; text-align: right; min-width: 220px; }
.hud-depth .big { font-size: 40px; font-weight: 800; line-height: 1; margin: 2px 0 4px; }
.hud-depth .big small { font-size: 18px; color: var(--muted); }
.hud-depth .section { font-family: var(--display); font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--nav); }
.progress { position: relative; height: 6px; margin-top: 8px; background: rgba(255,255,255,0.1); border-radius: 3px; }
#h-prog { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--nav); border-radius: 3px; }
#h-rings i { position: absolute; top: -3px; width: 3px; height: 12px; background: var(--gold); border-radius: 1px; }
.mode { margin-top: 6px; font-size: 13px; color: var(--muted); }
.mode.offline { color: var(--danger); }
.hud-mult { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); text-align: center; transition: opacity .2s; }
#h-mult { font-size: 34px; font-weight: 800; color: var(--gold); }
.hud-mult .decay { width: 110px; height: 4px; margin: 4px auto 0; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; }
#h-decay { height: 100%; width: 100%; background: var(--gold); }
.hud-mult.idle { opacity: 0.25; }
.hud-mult.bump #h-mult { animation: bump .25s ease-out; }
@keyframes bump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.hud-ahead { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 6px; align-items: center; }
.ahead { font-weight: 600; font-size: 17px; padding: 5px 14px; border-radius: 6px; background: rgba(5,10,14,0.72); border: 1px solid var(--line); white-space: nowrap; }
.ahead.ok { border-color: rgba(93,255,138,0.6); color: var(--safe); }
.ahead.low { border-color: rgba(255,255,255,0.2); color: #b9c3c8; }
.ahead.salv { border-color: rgba(255,194,61,0.7); }
.ahead.salv .l { color: var(--gold); font-weight: 700; }
.ahead.salv .r { color: var(--nav); font-weight: 700; }
.hud-bottom { position: absolute; left: 24px; right: 24px; bottom: 20px; display: flex; gap: 28px; justify-content: center; align-items: flex-end; }
.meter { min-width: 210px; }
.meter .bar { position: relative; height: 10px; margin: 5px 0 3px; background: rgba(255,255,255,0.1); border-radius: 5px; overflow: visible; }
.meter .bar > div { height: 100%; width: 100%; border-radius: 5px; background: var(--nav); transform-origin: left; }
#h-charge { background: var(--safe); }
.meter .mark { position: absolute; top: -4px; width: 2px; height: 18px; background: #fff; }
.meter .sub { font-size: 14px; color: var(--muted); }
#m-brake.locked #h-brake { background: var(--alert); }
#m-brake.locked .sub { color: var(--alert); }
#m-brake.active #h-brake { background: #fff; }
#m-charge.ready .sub { color: var(--safe); font-weight: 600; }
#m-hook .state { margin-top: 5px; font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: 0.04em; color: var(--muted); }
#m-hook.ready .state { color: var(--nav); }
#m-hook.on .state { color: #fff; }
.pops { position: absolute; inset: 0; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; font-family: var(--display); font-weight: 800; font-size: 24px; white-space: nowrap; opacity: 0; will-change: transform, opacity; }
.pop.show { animation: pop 1.1s ease-out forwards; }
.pop.near { color: var(--gold); }
.pop.boost { color: var(--safe); }
.pop.info { color: var(--nav); font-size: 20px; }
.pop.warn { color: var(--danger); font-size: 20px; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } 12% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
.banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); text-align: center; padding: 18px 34px; background: rgba(6,10,14,0.78); border: 1px solid var(--line); border-radius: 10px; }
.banner .b-title { font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: 0.06em; }
.banner .b-sub { font-size: 18px; color: var(--muted); margin-top: 4px; }
.banner.crash { border-color: rgba(255,58,70,0.6); }
.banner.crash .b-title { color: var(--alert); }
.banner.section .b-title { color: var(--nav); }
.banner.section { background: rgba(6,10,14,0.5); animation: fadeout 2.4s forwards; }
@keyframes fadeout { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.help-card { position: absolute; right: 24px; bottom: 170px; max-width: 390px; padding: 14px 16px; background: rgba(6,10,14,0.82); border: 1px solid var(--line); border-radius: 10px; font-size: 16px; line-height: 1.65; }
.help-card .help-title { font-family: var(--display); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--nav); margin-bottom: 4px; }
.help-card .help-tip { margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 1.35; }
.help-card.fade { transition: opacity .8s; opacity: 0; }
.fps { position: absolute; left: 24px; bottom: 96px; font-family: var(--display); font-size: 13px; color: var(--muted); }
.flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
.flash.go { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: 0.6; } 100% { opacity: 0; } }

/* ---------- Panels ---------- */
.panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 26px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.panel.wide { width: min(720px, calc(100vw - 32px)); }
.panel h2 { font-family: var(--display); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 14px; font-size: 26px; }
.menu { left: 7vw; transform: translate(0, -50%); background: linear-gradient(180deg, rgba(8,13,18,0.88), rgba(8,13,18,0.72)); }
.logo { font-family: var(--display); font-weight: 800; font-size: 54px; letter-spacing: 0.08em; line-height: 0.95; margin: 0; }
.logo span { display: block; color: var(--nav); letter-spacing: 0.32em; font-size: 0.62em; margin-top: 6px; }
.tag { color: var(--muted); margin: 12px 0 20px; font-size: 17px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn { appearance: none; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 13px 16px; font: 600 19px var(--ui); color: var(--text); background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.14); border-radius: 9px; cursor: pointer; text-align: left; }
.btn .t { font-family: var(--display); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.btn small { font-size: 14px; color: var(--muted); font-weight: 500; text-align: right; }
.btn:hover, .btn:focus-visible { border-color: var(--nav); background: var(--nav-dim); outline: none; }
.btn.primary { border-color: rgba(63,240,255,0.55); background: rgba(63,240,255,0.12); }
.btn.primary .t { color: var(--nav); }
.status { min-height: 1.3em; color: var(--muted); font-size: 15px; margin: 14px 0 0; }
.status.warn { color: var(--danger); }
.status.good { color: var(--safe); }
.keys { color: var(--muted); font-size: 14px; line-height: 1.8; margin: 12px 0 0; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions .btn { justify-content: center; text-align: center; }
.small { font-size: 14px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tab { font: 600 16px var(--ui); color: var(--muted); background: transparent; border: 1px solid rgba(255,255,255,0.12); border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.tab.on { color: var(--nav); border-color: var(--nav); background: var(--nav-dim); }
.table-wrap { max-height: 52vh; overflow: auto; }
.board-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.board-table th { text-align: left; font-family: var(--display); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #0b1218; }
.board-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.board-table td.r, .board-table th.r { text-align: right; }
.board-table td.num { font-family: var(--display); }
.board-table tr.me td { color: var(--nav); font-weight: 700; }
.board-table td.name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
.settings label small { color: var(--muted); font-weight: 500; }
.settings label.check { flex-direction: row; align-items: center; gap: 10px; }
.settings input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--nav); }
.settings select, .settings input:not([type]), .nameform input { font: 500 17px var(--ui); color: var(--text); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.18); border-radius: 7px; padding: 8px 10px; }
.settings input[type=range] { accent-color: var(--nav); }
.settings output { color: var(--nav); }
.result { text-align: center; width: min(500px, calc(100vw - 32px)); }
.result .kicker { font-family: var(--display); font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.result h2 { font-size: 34px; margin: 4px 0 6px; }
.result.crash h2 { color: var(--alert); }
.result.salvage h2 { color: var(--gold); }
.result.core h2 { color: #fff0c0; }
.result .cause { color: var(--muted); margin: 0 0 14px; }
.r-score .huge { font-size: 64px; font-weight: 800; line-height: 1.05; color: var(--safe); }
.r-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 18px 0 8px; text-align: left; }
.r-stats div { padding: 8px 12px; background: rgba(255,255,255,0.04); border-radius: 8px; }
.r-stats dt { font-family: var(--display); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.r-stats dd { margin: 3px 0 0; font-family: var(--display); font-weight: 700; font-size: 20px; }
.r-breakdown { text-align: left; margin-top: 8px; font-size: 15px; color: var(--muted); }
.r-breakdown summary { cursor: pointer; }
.r-breakdown .line { display: flex; justify-content: space-between; padding: 2px 0; }
.r-breakdown .line b { font-family: var(--display); color: var(--text); }
.nameform { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; text-align: left; }
.nameform label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 15px; }
.nameform .btn { width: auto; }
.big-btn { font-size: 24px; padding: 16px; }
.big-btn small { margin-left: 8px; }
.result .actions .btn.primary { flex: 2; color: var(--nav); font-family: var(--display); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.result .actions .btn:not(.primary) { flex: 1; }
.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--display); letter-spacing: 0.2em; color: var(--nav); background: var(--bg); }
.device { z-index: 5; }

@media (max-width: 760px) {
  .menu { left: 50%; transform: translate(-50%, -50%); }
  .hud-score .big { font-size: 32px; }
  .hud-depth .big { font-size: 28px; }
  .hud-bottom { flex-wrap: wrap; gap: 10px; }
  .meter { min-width: 140px; }
  .help-card { display: none; }
}
