:root {
  --bg: #0a0e16;
  --panel: #101625;
  --line: #1f2740;
  --dot: #1a2032;
  --text: #eef2fb;
  --muted: #5f6b85;
  --cyan: #5ee7ff;
  --amber: #ffce73;
  --red: #ff7c8c;
  --green: #7ee787;
  --track: #1f2740;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f4fa;
    --panel: #ffffff;
    --line: #d7dcee;
    --dot: #e4e8f5;
    --text: #10162a;
    --muted: #5b6478;
    --cyan: #0a7fa8;
    --amber: #a86500;
    --red: #c0344a;
    --green: #1c7a3f;
    --track: #dfe4f2;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--mono); min-height: 100vh; }
p { margin: 0; }
h1 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: 0.1em; }
.muted { color: var(--muted); }
.cyan { color: var(--cyan); }
.green { color: var(--green); }
.amber { color: var(--amber); }
.strong { font-weight: 700; }
.small { font-size: 0.8rem; }
.mono { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.frame { max-width: 1000px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.top { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.state { color: var(--cyan); font-weight: 600; }
.state.over { color: var(--red); }
.state.idle { color: var(--muted); }
.banner { padding: 10px 14px; border: 1px solid var(--amber); color: var(--text); border-radius: 8px; }
.banner strong { color: var(--amber); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 760px) { .grid { grid-template-columns: minmax(0, 1fr); gap: 20px; } }
.left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.title-row { display: flex; gap: 24px; align-items: baseline; }
.board-wrap { position: relative; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); aspect-ratio: 1 / 2; max-width: 320px; }
canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-card { max-width: 340px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; font-family: system-ui, sans-serif; }
.overlay-title { font-weight: 650; font-size: 1.05rem; }
select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
progress { width: 100%; height: 6px; border: 0; border-radius: 99px; overflow: hidden; background: var(--track); appearance: none; }
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--cyan); }
progress::-moz-progress-bar { background: var(--cyan); }

.scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 320px; }
.scores div { display: flex; flex-direction: column; }
.label { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.06em; }
.big { font-size: clamp(1.3rem, 4vw, 1.9rem); font-weight: 700; letter-spacing: 0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }

.right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.exec { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.shield { color: var(--amber); font-weight: 700; }
.meter { display: flex; flex-direction: column; gap: 4px; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .track { height: 4px; flex: 1; border-radius: 99px; background: var(--track); overflow: hidden; }
.meter-row .fill { height: 100%; width: 0; background: var(--amber); transition: width 0.12s linear; }
.meter-row .fill.green { background: var(--green); }
.meter-row .fill.red { background: var(--red); }
.meter-row span { width: 3rem; text-align: right; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 18px; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.btn { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.btn.primary { background: var(--cyan); color: #04222b; border-color: var(--cyan); font-weight: 700; justify-content: center; font-family: system-ui, sans-serif; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
kbd { font: inherit; font-size: 0.75rem; color: var(--muted); }
.ctl { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.ctl input[type="range"] { width: 120px; accent-color: var(--cyan); }
.ctl input[type="checkbox"] { accent-color: var(--cyan); }
.hint { margin-left: auto; }
@media (max-width: 700px) { .hint { display: none; } }
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
