/* DUAL BRAIN: shared surfaces, components, then explicit viewport layouts. */
:root {
  color-scheme: light;
  --game-bg: #ffffff; --panel: #ffffff; --panel-raised: #f3f5f7;
  --field: #f1f3f4; --ink: #17212b; --blue: #1769d2; --red: #d14e4e;
  --bonus: #6c4a08; --shield: #176a60; --booster: #855009; --grid: #aeb7be;
  --soft-white: #17212b; --muted: #56616c; --line: #d8dde2;
  --player-glyph: #ffffff;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --safe-top: max(8px, env(safe-area-inset-top));
  --safe-right: max(8px, env(safe-area-inset-right));
  --safe-bottom: max(8px, env(safe-area-inset-bottom));
  --safe-left: max(8px, env(safe-area-inset-left));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--game-bg); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { margin: 0; color: var(--soft-white); background: #fff; line-height: 1.4; }
button, input, select { font: inherit; }
button, summary, a, select { -webkit-tap-highlight-color: transparent; }
button, a, select { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button, select, input, summary { min-height: 44px; }
button, select { min-width: 44px; }
input, select { font-size: 16px; }
button:disabled, input:disabled { color: #9ba8b9; background: #192330; border-color: var(--line); cursor: default; }
:is(button, a, input, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.visually-hidden, .leaderboard-runtime-title,
body[data-online-ranking="enabled"] .leaderboard-scope {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.game-shell {
  width: min(100%,1160px);
  min-height: 100dvh;
  margin: auto;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid;
  align-content: start;
  gap: 6px;
}
.game-shell > *, .brand, .scoreboard, .scoreboard p { min-width: 0; }

/* Time and the two playing fields lead; navigation stays quiet. */
.topbar {
  display: grid;
  grid-template-columns: minmax(0,1fr) 52px 44px;
  gap: 4px 8px;
  align-items: center;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  grid-template-rows: auto auto;
  border-bottom: 1px solid #d8dde2;
}
.brand {
  position: relative;
  padding-left: 25px;
  grid-column: 1;
  grid-row: 1;
  padding: 0;
}
.brand::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  translate: 0 -50%;
  width: 17px;
  height: 24px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--blue) 0 44%, transparent 44% 56%, var(--red) 56%);
  display: none;
}
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.topbar .eyebrow { display: none; }
h1 { margin: 0; font-size: 18px; line-height: 1.05; letter-spacing: -.045em; font-weight: 850; }
.scoreboard {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.scoreboard p { margin: 0; padding: 6px 9px; border-radius: 8px; background: #0e1721; border-left: 2px solid var(--blue); }
.scoreboard p:last-child { border-left-color: var(--red); }
.scoreboard p > span {
  display: block;
  color: #56616c;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .04em;
  line-height: 1.2;
}
.scoreboard strong { display: block; margin-top: 3px; color: var(--blue); font: 750 23px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.05em; white-space: nowrap; }
.scoreboard p:last-child strong { color: var(--soft-white); }
.topbar > .language-control {
  grid-column: 2;
  grid-row: 1;
}
.language-control { min-width: 0; }
.language-control select {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #17212b;
  font-size: 14px;
  border-color: #d8dde2;
}
.records-menu {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #17212b;
  background: #fff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  word-break: keep-all;
  border-color: #d8dde2;
}
.topbar > .records-menu {
  grid-column: 3;
  grid-row: 1;
  display: none;
}
.pause-control {
  grid-column: 3;
  grid-row: 1;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #d8dde2;
  border-radius: 8px;
  color: #17212b;
  background: #f3f5f7;
  font-size: 17px;
  font-weight: 850;
}
.pause-control[aria-pressed="true"] {
  background: #e8edf2;
}

.game-frame {
  position: relative;
  width: 100%;
  height: clamp(248px,calc(100dvh - 316px),560px);
  min-height: 248px;
  overflow: hidden;
  border: 1px solid #d8dde2;
  border-radius: 10px;
  background: #f1f3f4;
  box-shadow: none;
}
canvas { display: block; width: 100%; height: 100%; }
.status {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: max-content;
  max-width: calc(100% - 20px);
  max-height: calc(100% - 12px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 18px;
  display: grid;
  justify-items: center;
  gap: 7px;
  border: 1px solid #d8dde2;
  border-radius: 12px;
  color: #17212b;
  background: #fffffffa;
  box-shadow: 0 8px 28px #17212b1a;
  pointer-events: none;
  text-align: center;
}
.status.has-form, .status.has-support, .status.has-actions { pointer-events: auto; }
.status-heading { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 8px; min-width: 0; width: 100%; }
#status-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
#status-collision { color: var(--muted); font-size: 14px; }
.new-best-badge {
  padding: 2px 7px;
  border-radius: 5px;
  color: #fff;
  background: #6c4a08;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}
.status-result { width: 100%; }
.status-record { color: #17212b; font: 800 clamp(34px, 9vw, 48px)/1.05 var(--mono); letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
.status.is-new-best {
  border-color: #8a6111;
}
.status.is-new-best .status-record {
  color: #6c4a08;
}
.status.is-result { width: min(480px, calc(100% - 20px)); gap: 14px; padding: 18px 20px; border: 2px solid #58616d; border-radius: 16px; background: #fff; box-shadow: 0 8px 24px #17212b1a; }
.status.is-result.is-new-best { border-color: #8a6111; }
.status.is-result #status-title { color: var(--muted); font-size: 14px; font-weight: 650; letter-spacing: 0; }
#status-copy { color: var(--muted); font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.run-feedback { display: grid; justify-items: center; gap: 8px; width: 100%; }
.run-feedback p { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; }
.run-feedback-level-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
}
.run-feedback-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid #0e55b0;
  border-radius: 6px;
  color: #fff;
  background: #1769d2;
  font: 800 14px/1.1 var(--mono);
  letter-spacing: .02em;
  white-space: nowrap;
}
#run-feedback-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #1769d2;
  border-radius: 999px;
  color: #0e55b0;
  background: #eaf3ff;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.run-feedback .new-best-badge { justify-self: center; width: max-content; max-width: 100%; }
.result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 6px; margin-top: 2px; }
.result-actions button { min-width: 0; min-height: 44px; padding: 5px 7px; border: 1px solid #1769d2; border-radius: 8px; font-size: 14px; line-height: 1.15; font-weight: 750; overflow-wrap: normal; word-break: keep-all; }
.result-restart { color: #fff; background: #1769d2; }
.result-share { color: #17212b; background: #f3f5f7; }
.result-share-fallback { display: grid; gap: 4px; width: 100%; }
.result-share-fallback small { color: #56616c; font-size: 14px; line-height: 1.25; }
.result-share-fallback textarea { width: 100%; min-height: 72px; resize: vertical; padding: 7px; border: 1px solid #cbd2d9; border-radius: 7px; color: #17212b; background: #fff; font: 14px/1.3 var(--mono); overflow-wrap: anywhere; }
.result-share-status { margin: 0; color: #1769d2; font-size: 14px; line-height: 1.25; }
.result-share-fallback:not([hidden]) ~ .result-share-status {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.score-form { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(92px, .85fr); align-items: center; gap: 5px 6px; margin: 3px 0 0; }
.score-form label { grid-column: 1 / -1; color: var(--muted); font-size: 14px; text-align: left; }
.score-form input, .score-form button { min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 8px; }
.score-form input { width: 100%; padding: 6px 9px; background: #0b121b; color: var(--soft-white); font-size: 16px; }
.score-form button {
  min-width: 52px;
  padding: 4px 6px;
  border-color: #1769d2;
  color: #fff;
  background: #1769d2;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 750;
  white-space: nowrap;
}
.record-retry-ticket {
  width: 100%;
  min-height: 44px;
  margin-top: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--soft-white);
  background: var(--panel);
  font-size: 14px;
  font-weight: 700;
}
.support-cta { display: flex; justify-content: center; width: 100%; margin-top: 2px; padding-top: 8px; border-top: 1px solid #d8dde2; }
.support-cta a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  color: #56616c;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}
.support-cta a:hover { color: #17212b; background: #f3f5f7; }
.status.result-entering { animation: result-card-in 180ms ease-out both; }
@keyframes result-card-in { from { opacity: 0; } to { opacity: 1; } }
.status.best-effect .status-record { animation: best-result-spark 420ms ease-out; }
@keyframes best-result-spark { from { filter: brightness(1.6); } to { filter: brightness(1); } }

/* Controls are tactile; telemetry is deliberately less prominent. */
.game-console {
  display: grid;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  grid-template-columns: 1fr;
}
.telemetry-rail {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 4px 12px;
  min-width: 0;
}
.telemetry-chip, .powerup-state {
  min-width: 0;
  min-height: 26px;
  padding: 2px 0;
}
.telemetry-chip {
  display: grid;
  align-content: center;
  gap: 0;
}
.telemetry-chip span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}
.telemetry-chip small, .powerup-state b {
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .02em;
  font-weight: 700;
  color: #56616c;
}
.telemetry-chip small { color: var(--muted); }
.telemetry-chip strong, .powerup-state > strong {
  font: 650 17px/1.2 var(--mono);
  font-variant-numeric: tabular-nums;
  color: #17212b;
  font-size: 14px;
}
.telemetry-chip em, .powerup-state small { color: var(--muted); font-size: 12px; line-height: 1.25; font-style: normal; }
.speed-readout strong {
  color: #17212b;
  font: 650 14px/1.2 var(--mono);
}
.speed-readout.is-fast strong, .auto-status strong { color: var(--bonus); }
.powerup-state {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 3px;
  border-top: 1px solid var(--line);
  border: 0;
}
.powerup-state i { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 6px; font-size: 12px; font-style: normal; font-weight: 700; }
.powerup-state span { min-width: 0; display: grid; gap: 2px; }
.powerup-state b { color: var(--soft-white); }
.powerup-state small { display: none; }
#shield-guide { color: var(--shield); }
#boost-guide { color: var(--booster); }
.powerup-state.is-active {
  background: transparent;
  border-radius: 0;
}
.control-deck {
  display: grid;
  grid-template-columns: minmax(0,1fr) 104px minmax(0,1fr);
  grid-template-areas: "left speed right";
  gap: 8px;
  min-width: 0;
}
.move-pad {
  min-width: 44px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 6px;
  border: 1px solid #bfc9d2;
  border-radius: 10px;
  background: #f3f5f7;
  box-shadow: none;
  touch-action: none;
  user-select: none;
}
.move-left {
  grid-area: left;
  color: #1769d2;
}
.move-right {
  grid-area: right;
  color: #d14e4e;
  border-color: #d8bebe;
  background: #f8f3f3;
}
.move-pad span {
  font: 700 34px/1 system-ui, sans-serif;
  font-size: 30px;
}
.move-pad small {
  color: #17212b;
  font-size: 14px;
  line-height: 1.1;
  font-weight: 650;
}
.move-pad.is-active, .move-pad:active {
  border-color: currentColor;
  background: #e7edf3;
}
.speed-control {
  grid-area: speed;
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  grid-template-columns: 1fr;
}
.speed-control > small { color: var(--muted); text-align: center; font-size: 11px; font-weight: 700; line-height: 1.2; letter-spacing: .07em; }
.console-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(44px, 1fr));
  gap: 4px;
}
.console-buttons button {
  width: 100%;
  height: 44px;
  padding: 0;
  border: 1px solid #36485a;
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
  line-height: 1;
  touch-action: none;
  border-color: #d8dde2;
  color: #17212b;
}
.console-buttons button[data-control="faster"] {
  color: #1769d2;
  border-color: #b8cce4;
}
.console-buttons button.is-active, .console-buttons button:active {
  background: #e8edf2;
}
.game-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}
body[data-online-ranking="enabled"] .game-footer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.online-ranking-launcher, .demo-hub-link {
  min-width: 44px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  border-color: #d8dde2;
  color: #17212b;
}
.demo-hub-link {
  color: #1769d2;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.records-menu--footer { display: flex; justify-self: end; width: max-content; padding-inline: 0; border-color: transparent; color: #56616c; background: transparent; }
.leaderboard {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  border-top: 1px solid #d8dde2;
}
.leaderboard summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  cursor: pointer;
  list-style: none;
}
.leaderboard summary::-webkit-details-marker { display: none; }
.leaderboard summary::after {
  content: "+";
  margin-left: auto;
  color: #56616c;
  font-size: 20px;
  line-height: 1;
}
.leaderboard[open] summary::after { content: "\2212"; }
.leaderboard summary strong {
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
  color: #17212b;
}
.leaderboard-scope { margin-left: auto; color: var(--muted); font-size: 11px; }
.leaderboard ol { display: grid; gap: 0; padding: 0 10px 8px; margin: 0; list-style: none; }
.leaderboard li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 6px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  border-color: #e6e9ec;
}
.leaderboard li strong { min-width: 0; overflow-wrap: anywhere; }
.leaderboard li > span:last-child {
  color: #1769d2;
  font-variant-numeric: tabular-nums;
}
.leaderboard .empty { display: block; color: var(--muted); }

/* Public record form and its disclosure remain legible in a scrollable dialog. */
.online-ranking-dialog {
  width: min(540px, calc(100% - 20px));
  max-width: none;
  max-height: calc(100dvh - 20px);
  padding: 0;
  border: 1px solid #405363;
  border-radius: 12px;
  color: #17212b;
  background: #fff;
  box-shadow: 0 20px 60px #17212b33;
  overflow: hidden;
  border-color: #d8dde2;
}
.online-ranking-dialog::backdrop {
  background: #17212b80;
}
.online-ranking-panel { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.online-ranking-header, .online-ranking-toolbar, .online-ranking-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.online-ranking-header > div, .online-ranking-toolbar p { min-width: 0; }
.online-ranking-panel p { margin: 0; }
.online-ranking-kicker {
  color: #1769d2;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .06em;
}
.online-ranking-header h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -.04em; }
.online-ranking-close, .online-ranking-refresh, .online-ranking-retry, .online-ranking-submit {
  flex-shrink: 0;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid #3e5164;
  border-radius: 8px;
  background: #f3f5f7;
  font-size: 14px;
  font-weight: 650;
  border-color: #d8dde2;
  color: #17212b;
}
.online-ranking-note { padding-top: 10px; color: var(--muted); font-size: 14px; }
.online-ranking-toolbar { margin-top: 12px; }
.online-ranking-toolbar p, .online-ranking-total { color: var(--muted); font-size: 14px; }
.online-ranking-total { padding: 6px 0; min-height: 20px; }
.online-ranking-table-wrap { max-height: 240px; overflow: auto; border-block: 1px solid var(--line); }
.online-ranking-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.online-ranking-table th, .online-ranking-table td { padding: 10px 5px; border-bottom: 1px solid var(--line); text-align: left; }
.online-ranking-table thead th { color: var(--muted); font-weight: 600; }
.online-ranking-table th:first-child { width: 38px; text-align: center; }
.online-ranking-table th:last-child, .online-ranking-table td:last-child { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.online-ranking-table td:last-child { color: var(--blue); white-space: nowrap; font-weight: 750; }
.online-ranking-identity strong, .online-ranking-identity small { display: block; overflow-wrap: anywhere; font-size: 14px; }
.online-ranking-identity small { margin-top: 4px; color: var(--muted); }
.online-ranking-empty { padding: 28px 12px; color: var(--muted); text-align: center; }
.online-ranking-form {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: #fff;
  border-top: 1px solid #d8dde2;
}
.online-ranking-form h3 { margin: 0; font-size: 17px; }
.online-ranking-run, .online-ranking-disclosure { color: var(--muted); font-size: 14px; }
.online-ranking-form label { font-size: 14px; font-weight: 650; }
.online-ranking-form input { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #405166; border-radius: 8px; background: #0b121b; color: var(--soft-white); font-size: 16px; }
.online-ranking-form-message { min-height: 18px; font-size: 14px; overflow-wrap: anywhere; }
.online-ranking-form-message[data-state="success"] { color: var(--shield); }
.online-ranking-form-message[data-state="error"] { color: #ffaaa0; }
.online-ranking-actions { flex-wrap: wrap; }
.online-ranking-actions button { flex: 1 1 120px; }
.online-ranking-submit {
  color: #fff;
  background: #1769d2;
  border-color: #1769d2;
}

/* Onboarding uses the same two lanes, without repeating both languages. */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
  overflow-y: auto;
  background: #ffffffee;
  overscroll-behavior: contain;
}
.onboarding-card {
  width: min(100%, 460px);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px;
  display: grid;
  gap: 15px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 36px #17212b1a;
}
.onboarding-tools { display: flex; justify-content: flex-end; gap: 8px; }
.onboarding-tools .language-control { width: 112px; }
.onboarding-tools .records-menu { min-width: 96px; }
.onboarding-kicker { margin: 0; color: var(--blue); font-size: 11px; font-weight: 750; letter-spacing: .15em; }
.onboarding-card h2 {
  margin: 0;
  font-size: clamp(23px,6vw,30px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -.045em;
  word-break: keep-all;
  color: #17212b;
}
.onboarding-card h2 b { color: var(--blue); }
.onboarding-sub, .onboarding-steps span { display: none; }
.onboarding-figure { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; }
.onboarding-screen {
  position: relative;
  height: 110px;
  border: 2px solid var(--blue);
  border-radius: 6px;
  background: #f1f3f4;
  overflow: hidden;
  border-width: 1px;
}
.onboarding-screen--right { border-color: var(--red); }
.onboarding-block { position: absolute; width: 26%; height: 10px; background: var(--ink); border-radius: 1px; }
.onboarding-block[data-at="a"] { top: 16%; left: 10%; }
.onboarding-block[data-at="b"] { top: 46%; left: 58%; }
.onboarding-block[data-at="c"] { top: 22%; left: 56%; }
.onboarding-block[data-at="d"] { top: 52%; left: 12%; width: 38%; }
.onboarding-player { position: absolute; bottom: 9%; left: 50%; translate: -50% 0; width: 12px; height: 12px; border-radius: 3px; background: var(--blue); }
.onboarding-screen--right .onboarding-player { background: var(--red); }
.onboarding-input {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 0;
  color: #56616c;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .12em;
}
.onboarding-input b:first-child { color: var(--blue); }
.onboarding-input b:last-child { color: var(--red); }
.onboarding-steps {
  display: grid;
  gap: 8px;
  counter-reset: steps;
  list-style: none;
  padding: 0;
  margin: 0;
}
.onboarding-steps li { position: relative; padding-left: 30px; counter-increment: steps; }
.onboarding-steps li::before {
  content: counter(steps, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  color: #56616c;
  font: 650 12px/1.4 var(--mono);
}
.onboarding-steps b {
  display: block;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  word-break: keep-all;
}
.onboarding-start {
  min-height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #1769d2;
}
.onboarding-start b {
  font-size: 16px;
  font-weight: 800;
}
.onboarding-start span { font-size: 11px; letter-spacing: .12em; font-weight: 750; }
.records-menu--onboarding { width: 100%; background: transparent; }

@media (hover: hover) {
  .records-menu:hover, .online-ranking-launcher:hover, .support-cta a:hover, .leaderboard summary:hover { border-color: #6a8598; background: #e8f2f5; color: #17212b; }
  .move-pad:hover { border-color: currentColor; }
  .pause-control:hover, .onboarding-start:hover, .score-form button:hover { background: #85e4ee; color: #17212b; }
  .result-restart:hover { background: #0e55b0; color: #fff; }
  .result-share:hover { background: #e8f2f5; color: #17212b; }
}
/* Results use intrinsic height: localized disclosure and forms never get clipped.
   Canvas stays behind the card; active play keeps the explicit tested heights. */
.game-frame:has(.status.is-result:not([hidden])) { display: grid; height: auto; min-height: 350px; padding: 6px 0; }
.game-frame:has(.status.is-result:not([hidden])) canvas { position: absolute; inset: 0; }
.status.is-result { position: relative; top: auto; left: auto; translate: none; margin: auto; max-height: none; overflow: visible; }
@media (max-width: 350px) {
  .game-shell { gap: 6px; }
  .topbar { grid-template-columns: minmax(0, 1fr) 52px 64px 44px; padding: 6px; gap: 4px; }
  .brand { padding-left: 0; }
  .brand::before { display: none; }
  h1 { font-size: 17px; }
  .topbar .records-menu { padding-inline: 3px; }
  .scoreboard strong { font-size: 20px; }
  .game-console { padding: 6px; gap: 5px; }
  .telemetry-rail { column-gap: 8px; }
  .move-pad { min-height: 70px; }
  .status.is-result { max-width: calc(100% - 12px); width: calc(100% - 12px); padding: 16px; gap: 12px; }
  .run-feedback p { font-size: 14px; }
  .result-actions { gap: 4px; }
  .result-actions button { padding-inline: 4px; font-size: 14px; }
  .onboarding-card { padding: 16px; gap: 12px; }
  .onboarding-screen { height: 82px; }
  .onboarding-card h2 { font-size: 26px; }
}
@media (max-height: 720px) and (orientation: portrait) {
  .game-frame { height: clamp(248px, calc(100dvh - 322px), 390px); }
  .telemetry-chip, .powerup-state { min-height: 32px; }
  .telemetry-chip em { display: none; }
}
@media (max-width: 350px) and (max-height: 640px) and (orientation: portrait) {
  .game-shell { gap: 4px; }
  .move-pad { min-height: 48px; flex-direction: row; padding: 4px; gap: 4px; }
  .move-pad span { font-size: 24px; }
  .speed-control > small { display: none; }
}
@media (min-width: 620px) and (min-height: 560px) {
  .game-shell { width: min(calc(100% - 24px), 1100px); gap: 12px; padding-block: 16px; }
  .topbar { grid-template-columns: minmax(135px, 1fr) minmax(210px, 1.1fr) 64px 90px 44px; padding: 12px; gap: 12px; }
  .topbar .eyebrow { display: block; }
  .brand { padding-left: 30px; }
  .brand h1 { font-size: 23px; }
  .scoreboard { grid-column: 2; grid-row: 1; }
  .topbar > .language-control { grid-column: 3; }
  .topbar > .records-menu { grid-column: 4; }
  .pause-control { grid-column: 5; }
  .game-frame { height: min(calc(100dvh - 320px), 560px); min-height: 360px; }
  .telemetry-rail { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
  .powerup-state { border-top: 0; }
  .powerup-state small { display: block; }
  .control-deck { grid-template-columns: minmax(0, 1fr) 128px minmax(0, 1fr); }
  .leaderboard ol { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
}
@media (min-width: 960px) and (min-height: 700px) {
  .game-shell { align-content: center; }
  .game-frame { height: min(58dvh, 560px); }
  .game-console { grid-template-columns: minmax(300px, .9fr) minmax(440px, 1.3fr); gap: 20px; padding: 12px; }
  .telemetry-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
  .powerup-state { border-top: 1px solid var(--line); }
  .powerup-state small { display: none; }
}
/* Short landscape: chrome sits beside the full-height playing field. */
@media (orientation: landscape) and (max-height: 520px) {
  .game-shell { width: 100%; min-height: 100dvh; height: 100dvh; grid-template-columns: minmax(0, 1fr) 188px; grid-template-rows: 92px minmax(140px, 1fr) 44px; gap: 6px; align-content: stretch; }
  .game-frame { grid-column: 1; grid-row: 1 / 4; height: 100%; min-height: 0; border-radius: 12px; }
  .topbar { grid-column: 2; grid-row: 1; grid-template-columns: minmax(0, 1fr) 44px; grid-template-rows: 34px 44px; padding: 4px; gap: 4px; border-radius: 10px; }
  .topbar .brand, .topbar > .records-menu { display: none; }
  .scoreboard { grid-column: 1 / -1; grid-row: 1; gap: 4px; }
  .scoreboard p { padding: 2px 5px; }
  .scoreboard p > span { font-size: 10px; }
  .scoreboard strong { font-size: 16px; margin-top: 1px; }
  .topbar > .language-control { grid-column: 1; grid-row: 2; }
  .topbar .language-control select { padding-inline: 10px; }
  .pause-control { grid-column: 2; grid-row: 2; }
  .game-console { grid-column: 2; grid-row: 2; grid-template-rows: auto minmax(0, 1fr); min-height: 0; padding: 4px; gap: 4px; border-radius: 10px; }
  .telemetry-rail { gap: 2px 5px; }
  .telemetry-chip, .powerup-state { min-height: 23px; padding: 1px 0; }
  .telemetry-chip small, .powerup-state b { font-size: 10px; letter-spacing: 0; }
  .telemetry-chip strong, .powerup-state > strong { font-size: 14px; }
  .telemetry-chip em, .powerup-state small, .powerup-state i { display: none; }
  .powerup-state { grid-template-columns: minmax(0, 1fr) auto; gap: 2px; }
  .control-deck { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(44px, 1fr) 44px; grid-template-areas: "left right" "speed speed"; gap: 4px; }
  .move-pad { min-height: 44px; padding: 3px; gap: 1px; flex-direction: row; }
  .move-pad span { font-size: 22px; }
  .move-pad small { font-size: 14px; }
  .speed-control { padding: 0; grid-template-columns: minmax(0, 1fr) 94px; align-items: center; }
  .console-buttons { gap: 4px; }
  .game-footer, body[data-online-ranking="enabled"] .game-footer { grid-column: 2; grid-row: 3; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .game-footer .leaderboard { display: none; }
  .game-footer .records-menu--footer { display: flex; padding: 2px 4px; font-size: 14px; }
  .online-ranking-launcher { padding: 2px 3px; font-size: 14px; line-height: 1.15; }
  .game-shell:has(.status.is-result:not([hidden])) { height: auto; }
  .game-frame:has(.status.is-result:not([hidden])) { min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom)); }
  .status.is-result { width: calc(100% - 12px); max-width: 480px; padding: 16px 18px; gap: 12px; }
  .status-record { font-size: 34px; }
  .run-feedback { gap: 8px; }
  .run-feedback p { font-size: 14px; }
  .score-form { margin-top: 0; }
  .support-cta { margin-top: 0; padding-top: 6px; }
  .online-ranking-panel { padding: 12px; }
  .online-ranking-table-wrap { max-height: 130px; }
  .onboarding-card { width: min(100%, 760px); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 18px; padding: 14px 18px; }
  .onboarding-tools { grid-column: 2; grid-row: 1; }
  .onboarding-kicker { grid-column: 1; grid-row: 1; align-self: center; }
  .onboarding-card h2 { grid-column: 1; grid-row: 2; font-size: 25px; }
  .onboarding-figure { grid-column: 1; grid-row: 3 / 6; align-content: start; }
  .onboarding-screen { height: 90px; }
  .onboarding-steps { grid-column: 2; grid-row: 2 / 4; gap: 6px; }
  .onboarding-start { grid-column: 2; grid-row: 4; min-height: 44px; padding: 6px; }
  .records-menu--onboarding { grid-column: 2; grid-row: 5; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


/* Added selectors */
.brand h1 { font-size: 20px; letter-spacing: -.04em; }
.brand-tagline { margin: 3px 0 0; color: #56616c; font-size: 14px; line-height: 1.2; }
.scoreboard p, .scoreboard p:last-child { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.scoreboard strong, .scoreboard p:last-child strong { margin: 0; color: #17212b; font-size: 18px; letter-spacing: -.035em; }
#status-copy { color: #56616c; }
.score-form input, .online-ranking-form input { border-color: #cbd2d9; background: #fff; color: #17212b; }
.telemetry-chip em { display: none; }
.auto-status strong { color: #56616c; }
.powerup-state i, .powerup-state small { display: none; }
.powerup-state span, .powerup-state b { display: block; }
.powerup-state:not(.is-active) { visibility: hidden; }
.speed-readout { display: flex; align-items: baseline; justify-content: center; gap: 5px; }
.speed-readout small { color: #56616c; font-size: 12px; font-weight: 650; }
.speed-readout.is-fast strong { color: #6c4a08; }
.online-ranking-note, .online-ranking-toolbar p, .online-ranking-total, .online-ranking-run, .online-ranking-disclosure { color: #56616c; }

@media (max-width:350px) {
  .brand h1 { font-size:18px; }
  .scoreboard { gap:10px; }
  .scoreboard strong { font-size:17px; }
  .control-deck { grid-template-columns:minmax(0,1fr) 92px minmax(0,1fr); gap:5px; }
  .move-pad { min-height:56px; }
}
@media (min-width:620px) and (min-height:560px) {
  .game-shell { align-content:start; }
  .topbar { grid-template-columns:minmax(0,1fr) auto 52px 44px; grid-template-rows:auto; padding-block:8px; }
  .brand { grid-column:1; grid-row:1; }
  .scoreboard { grid-column:2; grid-row:1; min-width:220px; gap:14px; }
  .topbar > .language-control { grid-column:3; grid-row:1; }
  .pause-control { grid-column:4; grid-row:1; }
  .game-frame { height:min(calc(100dvh - 310px),560px); min-height:360px; }
  .game-console { grid-template-columns:1fr; gap:4px; align-items:stretch; }
  .telemetry-rail { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .control-deck { grid-template-columns:minmax(0,1fr) 108px minmax(0,1fr); width:100%; }
  .online-ranking-table thead th { background:#f7f8f9; }
}
@media (min-width:960px) and (min-height:700px) { .game-frame { height:min(58dvh,560px); } }
@media (orientation:landscape) and (max-height:520px) {
  .game-shell { grid-template-columns:minmax(0,1fr) 196px; grid-template-rows:78px minmax(118px,1fr) 92px; gap:6px; }
  .game-frame { grid-column:1; grid-row:1 / 4; height:100%; min-height:0; }
  .topbar { grid-column:2; grid-row:1; display:grid; grid-template-columns:minmax(0,1fr) 44px 44px; grid-template-rows:32px 44px; gap:2px 4px; padding-block:0; border-bottom:0; }
  .topbar .brand { display:none; }
  .scoreboard { grid-column:1 / -1; grid-row:1; min-width:0; gap:8px; }
  .scoreboard p, .scoreboard p:last-child { flex-direction:column; align-items:flex-start; justify-content:center; gap:0; }
  .scoreboard p > span { font-size:14px; line-height:1; }
  .scoreboard strong { font-size:15px; line-height:1; }
  .topbar > .language-control { display:flex; grid-column:2; grid-row:2; }
  .topbar > .language-control select { width:44px; height:44px; padding-inline:2px; font-size:14px; }
  .pause-control { display:block; grid-column:3; grid-row:2; width:44px; height:44px; }
  .game-console { grid-column:2; grid-row:2; grid-template-columns:1fr; gap:3px; padding:0; }
  .telemetry-rail { grid-template-columns:repeat(3,minmax(0,1fr)); gap:2px; }
  .telemetry-chip, .powerup-state { min-height:23px; padding:1px 0; }
  .telemetry-chip small, .powerup-state b { font-size:10px; }
  .telemetry-chip strong, .powerup-state > strong, .speed-readout small, .speed-readout strong { font-size:12px; }
  .control-deck { grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:minmax(44px,1fr) 44px; grid-template-areas:"left right" "speed speed"; gap:4px; }
  .move-pad { min-height:44px; flex-direction:row; gap:2px; padding:3px; }
  .move-pad span { font-size:22px; }
  .move-pad small { font-size:14px; }
  .speed-control { grid-template-columns:1fr 94px; align-items:center; }
  .game-footer, body[data-online-ranking="enabled"] .game-footer { grid-column:2; grid-row:3; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; }
  .game-footer .leaderboard { display:block; }
  .game-footer .records-menu--footer { display:flex; padding:2px 4px; font-size:14px; }
}
@media (orientation:landscape) and (max-height:520px) {
  .game-shell:has(.status.is-result:not([hidden])) { height:auto; min-height:100dvh; grid-template-rows:auto auto auto; align-content:start; }
  .game-frame:has(.status.is-result:not([hidden])) { grid-column:1; grid-row:1 / 4; height:auto; min-height:320px; overflow:visible; }
  .status.is-result { max-height:none; overflow:visible; }
}
