:root {
  color-scheme: dark;
  --bg: #0c1014;
  --surface: #151b21;
  --line: #30383f;
  --strong: #f1f4ec;
  --soft: #b0b9ba;
  --acid: #dcfc63;
  --head: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Chivo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; color: var(--strong); font: 400 .9rem/1.5 var(--body); background: var(--bg); }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }
.topbar { min-height: 66px; padding: 0 max(5vw, calc((100vw - 1250px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #ffffff16; background: #0c1014; }
.wordmark { font-weight: 700; white-space: nowrap; }
.wordmark i { display: inline-block; width: 14px; height: 14px; margin-right: 5px; vertical-align: -1px; background: repeating-linear-gradient(135deg,var(--acid) 0 3px,transparent 3px 6px); }
.top-actions, .hero-actions, .launch, .finish-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.small-button { border: 1px solid var(--line); background: transparent; min-height: 36px; border-radius: 4px; padding: 5px 12px; font-size: .78rem; color: var(--soft); }
.small-button:hover, .secondary:hover { border-color: var(--acid); color: var(--acid); }
.hero {
  position: relative; min-height: clamp(425px, 40vw, 660px); display: grid; align-items: end;
  background: linear-gradient(90deg,#081015 0%,#081015b0 24%,transparent 64%), linear-gradient(0deg,#0c1014 0%,transparent 39%), #0a171f url("./art/cover.webp") center 45%/cover;
  border-bottom: 1px solid #ffffff13;
}
.hero-content { width: min(1250px, 90%); margin: 0 auto; padding: 70px 0 46px; isolation: isolate; }
.kicker { margin: 0 0 10px; color: #dce3d2; text-transform: uppercase; font-size: clamp(.62rem,1.2vw,.75rem); letter-spacing: .12em; font-weight: 700; }
.kicker span { background: var(--acid); display: inline-block; height: 7px; width: 24px; margin: 0 7px 1px 0; transform: skewX(-22deg); }
h1, h2 { font-family: var(--head); font-style: italic; font-weight: 900; text-transform: uppercase; }
h1 { font-size: clamp(4.2rem, 8vw, 8.7rem); line-height: .78; letter-spacing: -.025em; margin: 0 0 25px; text-shadow: 0 3px 28px #0009; }
h1 em { color: var(--acid); font-style: inherit; }
.hero-copy { max-width: 370px; color: #d2d9d8; font-size: clamp(.9rem, 1.4vw, 1.07rem); margin: 0 0 21px; }
.primary, .secondary { display: inline-flex; justify-content: center; align-items: center; gap: 10px; min-height: 45px; padding: 9px 16px; border: 1px solid transparent; border-radius: 4px; font-weight: 700; text-align: center; line-height: 1.2; }
.primary { color: #111701; background: var(--acid); border-color: var(--acid); }
.primary:hover { background: #edffa5; }
.primary:disabled { opacity: .5; cursor: default; }
.secondary { background: #11181cdd; border-color: #4a555c; color: var(--strong); }
.shell { max-width: 1250px; width: 90%; margin: 0 auto; padding: 31px 0 0; }
.garage-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr); gap: 24px; }
.selection { border: 1px solid var(--line); background: #11161b; padding: 19px; min-width: 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; margin: 0 0 12px; }
.section-heading h2, .dialog-top h2 { font-size: clamp(2rem, 4vw, 2.8rem); line-height: .95; margin: 0; }
.section-heading span { color: var(--soft); font-size: .73rem; letter-spacing: .06em; }
.racer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.racer-card, .course-card, .modes button { min-width: 0; padding: 8px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.racer-card:hover, .course-card:hover, .modes button:hover { border-color: #87938c; }
.racer-card[aria-pressed=true], .course-card[aria-pressed=true], .modes button[aria-pressed=true], .cube-size button[aria-pressed=true] { border-color: var(--acid); background: #273124; }
.racer-card { display: flex; align-items: center; gap: 5px; font-weight: 600; text-align: left; font-size: .78rem; min-height: 62px; }
.racer-card img { object-fit: contain; width: 43px; height: 45px; filter: drop-shadow(0 3px 2px #0007); }
.racer-card[data-id=blade] img { transform: rotate(30deg); }
.racer-spec { min-height: 106px; display: grid; grid-template-columns: 1fr minmax(104px, .45fr); gap: 12px; align-items: center; padding: 12px 0 0; }
.racer-spec strong { font-size: 1.05rem; }
.racer-spec p { color: var(--soft); font-size: .8rem; line-height: 1.35; margin: .15em 0 0; }
.spec-meters div { display: grid; grid-template-columns: 42px 1fr; gap: 4px; align-items: center; font-size: .63rem; color: var(--soft); }
.spec-meters meter { width: 100%; height: 8px; }
.course-grid, .modes { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.course-card { display: grid; grid-template-columns: 52px 1fr; align-items: center; min-height: 65px; gap: 5px; padding: 5px 8px; text-align: left; line-height: 1.2; }
.course-card strong { display: block; font-size: .8rem; }
.course-card small, .modes small { display: block; margin-top: 4px; font-size: .68rem; color: var(--soft); }
.course-card canvas { width: 52px; height: 43px; }
#course-notes { color: var(--soft); margin: 9px 0; font-size: .8rem; min-height: 2.45em; }
.modes button { font-weight: 700; min-height: 48px; line-height: 1.2; }
.modes small { font-weight: 400; }
.launch { margin-top: 12px; }
.launch .primary { flex: 1; }
.pit-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px; color: var(--soft); border-top: 1px solid var(--line); margin: 24px 0 0; padding: 14px 0 22px; font-size: .8rem; }
.pit-footer button { background: none; border: 0; padding: 0; color: inherit; }
.pit-footer label { display: inline-flex; align-items: center; gap: 4px; }
input { accent-color: var(--acid); }

#race { position: fixed; inset: 0; overflow: hidden; background: #192226; touch-action: none; user-select: none; }
#track { position: absolute; width: 100%; height: 100%; display: block; }
.race-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px,env(safe-area-inset-right)); display: flex; align-items: stretch; gap: 5px; pointer-events: none; }
.telemetry, .driver, .race-side, .meters { background: #080d13e8; border: 1px solid #ffffff29; border-radius: 5px; }
.telemetry { min-width: 78px; padding: 4px 10px 6px; text-align: center; }
.telemetry strong, .driver strong { font: italic 900 clamp(1.55rem, 3vw, 2.7rem)/1 var(--head); font-variant-numeric: tabular-nums; display: block; }
.telemetry span, .driver span { display: block; color: #c9d2d2; font-size: .63rem; text-transform: uppercase; letter-spacing: .09em; }
.telemetry.score strong { color: var(--acid); }
.hud-actions { margin-left: auto; display: flex; gap: 5px; pointer-events: auto; }
.hud-actions button { border: 1px solid #ffffff39; background: #080d13e8; min-width: 42px; border-radius: 5px; padding: 0 7px; font-size: 1.2rem; }
.race-side { position: absolute; bottom: max(20px,env(safe-area-inset-bottom)); right: max(18px,env(safe-area-inset-right)); padding: 3px 7px 8px; text-align: center; font-size: .67rem; pointer-events: none; }
#minimap { display: block; width: 120px; height: 101px; }
#race-sound { font-size: .75rem; font-weight: 700; }
#race-sound[aria-pressed=false] { color: var(--soft); text-decoration: line-through; }
#pause span { display: block; margin: auto; width: 11px; height: 14px; border-inline: 3px solid currentColor; }
#race-message { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); text-align: center; width: 93%; font: italic 900 clamp(2rem, 7vw, 5.2rem)/1 var(--head); text-shadow: 0 3px 3px #000, 0 1px 20px #000; color: var(--acid); text-transform: uppercase; pointer-events: none; }
#race-message.notice { top: 22%; font-size: clamp(1.5rem, 4vw, 3rem); }
.drive-bottom { position: absolute; bottom: max(20px,env(safe-area-inset-bottom)); left: max(18px,env(safe-area-inset-left)); display: flex; align-items: stretch; gap: 5px; pointer-events: none; }
.driver { text-align: center; padding: 6px 10px 4px; display: flex; flex-direction: column; justify-content: center; }
.meters { padding: 5px 8px; width: 210px; }
.meters > div { display: grid; grid-template-columns: minmax(72px, .9fr) 1fr; align-items: center; min-height: 17px; gap: 4px; }
.meters label { color: #d8ded7; font-size: .64rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meters meter { width: 100%; height: 9px; }
meter { accent-color: var(--acid); }
meter::-webkit-meter-bar { background: #3b4448; border: 0; border-radius: 3px; }
meter::-webkit-meter-optimum-value { background: var(--meter, var(--acid)); border-radius: 3px; }
meter::-moz-meter-bar { background: var(--meter, var(--acid)); }
#health { --meter: #76efa6; }
#health.low { --meter: #ff7f68; }
#charge { --meter: #e5a0ff; }
#special-meter.ready label { color: #e5a0ff; }
.touch { display: none; position: absolute; bottom: max(11px,env(safe-area-inset-bottom)); left: max(10px,env(safe-area-inset-left)); right: max(10px,env(safe-area-inset-right)); justify-content: space-between; gap: 6px; pointer-events: none; }
.touch > div { display: grid; grid-template-columns: repeat(2, minmax(54px,1fr)); gap: 5px; }
.touch button { pointer-events: auto; touch-action: none; border: 1px solid #99a4a9; border-radius: 8px; min-height: 47px; background: #121923e8; font-size: .71rem; font-weight: 700; padding: 3px 8px; }
.touch button[data-input=left], .touch button[data-input=right] { font-size: 1.25rem; }
.touch button[data-input=drift] { grid-column: 1 / -1; }
.touch button[data-input=boost] { color: var(--acid); }
.touch button.ready { border-color: #e5a0ff; color: #e5a0ff; }
.touch button.held { background: var(--acid); color: #0b1115; border-color: var(--acid); }

dialog { width: min(535px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; padding: 20px; color: var(--strong); border: 1px solid #4a5359; border-top: 3px solid var(--acid); border-radius: 5px; background: #141b22; box-shadow: 0 12px 60px #000b; }
dialog::backdrop { background: #071017b8; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 15px; }
.dialog-top h2 { font-size: 2.4rem; }
.close { width: 38px; height: 38px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); font-size: 1.4rem; line-height: 1; }
#how p { color: var(--soft); }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.controls dd, .results dd { margin: 0; }
kbd { padding: 1px 5px; border: 1px solid #657173; border-radius: 3px; color: var(--acid); white-space: nowrap; }
.board-choose { display: flex; gap: 10px; flex-wrap: wrap; }
.board-choose label, #submit-score label { display: grid; gap: 3px; color: var(--soft); font-size: .75rem; }
select { background: #0c1319; border: 1px solid #657173; color: var(--strong); border-radius: 4px; padding: 7px; }
#board-list { list-style: none; padding: 0; margin: 0; }
#board-list li { display: grid; grid-template-columns: 30px minmax(98px,1.4fr) minmax(52px,.65fr) minmax(55px,.7fr); align-items: center; gap: 5px; border-top: 1px solid var(--line); padding: 6px 0; }
#board-list li > strong { color: var(--acid); text-align: right; font-variant-numeric: tabular-nums; }
#board-list small { display: block; color: var(--soft); font-size: .68rem; }
#paused button { display: flex; width: 100%; margin: 8px 0; }
.results-place { display: flex; align-items: center; gap: 15px; }
.results-place strong { color: var(--acid); font: italic 900 4.5rem/.9 var(--head); }
#finish-run { font-weight: 700; }
#finish-run small { display: block; color: var(--soft); font-weight: 400; }
.results { display: grid; grid-template-columns: 1fr auto; gap: 5px; border-block: 1px solid var(--line); padding: 8px 0; }
.results dd { text-align: right; font-variant-numeric: tabular-nums; }
#submit-score { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
#finish-status, #board-status { min-height: 1.5em; font-size: .8rem; color: var(--soft); }
.cube-size, .cube-turns { display: flex; flex-wrap: wrap; gap: 6px; }
.cube-turns button, .cube-size button { min-height: 34px; }
.cube-net { display: grid; grid-template-columns: repeat(4, minmax(42px,72px)); grid-template-rows: repeat(3, minmax(42px,72px)); gap: 4px; justify-content: center; margin: 12px auto; }
.cube-face { display: grid; gap: 2px; background: #090f15; padding: 3px; aspect-ratio: 1; }
.cube-face span { border: 1px solid #ffffff41; border-radius: 2px; }
.cube-turns { justify-content: center; }
#cube-status { color: var(--acid); min-height: 1.5em; }

@media (max-width: 860px) {
  .garage-grid { grid-template-columns: 1fr; gap: 12px; }
  .selection { padding: 14px; }
}
@media (max-width: 560px) {
  .topbar { min-height: 57px; padding-inline: 4vw; }
  .top-actions { gap: 5px; }
  .small-button { padding: 5px 7px; font-size: .69rem; }
  .hero { min-height: 530px; background: linear-gradient(0deg,#0c1014 0%,#0c1014dc 22%,transparent 72%), #0a171f url("./art/cover.webp") 64% top/auto 390px no-repeat; }
  .hero-content { padding: 195px 0 22px; }
  h1 { font-size: clamp(3.45rem, 13vw, 5rem); margin-bottom: 17px; }
  .hero-copy { margin-bottom: 14px; }
  .racer-card { flex-direction: column; text-align: center; gap: 3px; font-size: .71rem; }
  .racer-card img { width: 42px; height: 44px; }
  .racer-spec { grid-template-columns: 1fr minmax(85px,.42fr); }
  .course-card { grid-template-columns: 40px 1fr; }
  .course-card canvas { width: 40px; }
  .telemetry { min-width: 0; padding: 4px 6px 5px; }
  .telemetry span { font-size: .52rem; letter-spacing: 0; }
  .hud-actions button { min-width: 32px; }
  .race-top { gap: 3px; }
}
@media (any-pointer: coarse) {
  .touch { display: flex; }
  .drive-bottom, .race-side { bottom: max(115px,calc(env(safe-area-inset-bottom) + 105px)); }
}
@media (any-pointer: coarse) and (max-height: 530px) {
  .drive-bottom, .race-side { bottom: max(8px,env(safe-area-inset-bottom)); }
  .drive-bottom { left: 50%; transform: translateX(-50%); }
  .race-side { top: 62px; bottom: auto; }
  #minimap { width: 86px; height: 75px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Vehicle selection and race feedback */
.racer-grid { grid-template-columns: repeat(5,minmax(0,1fr)); }
.racer-card {
  flex-direction: column; justify-content: end; gap: 5px; min-height: 92px; padding: 7px 3px 8px;
  text-align: center; line-height: 1.15; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 38%,#ffffff10,transparent 74%), var(--surface);
  transition: border-color .16s, background-color .16s;
}
.racer-card[aria-pressed=true] {
  border-color: var(--racer-color);
  background: radial-gradient(ellipse at 50% 38%,color-mix(in srgb,var(--racer-color),transparent 64%),transparent 76%),#1a2126;
}
.racer-card img {
  width: 60px; height: 57px; max-width: 95%; transition: translate .18s;
  filter: drop-shadow(0 4px 4px #000b);
}
.racer-card:hover img { translate: 0 -3px; }
.racer-card[data-id=knuckles] span { color: #ffab9c; }
.racer-card[data-id=knuckles]::before {
  content: ""; position: absolute; top: 0; right: 0; width: 15px; height: 15px;
  background: linear-gradient(45deg,transparent 50%,#f36556 50%);
}
.racer-spec {
  grid-template-columns: minmax(56px,100px) 1fr minmax(104px,.55fr); margin: 12px 0 0; padding: 7px 9px 7px 6px;
  border: 1px solid color-mix(in srgb,var(--racer-color),transparent 74%);
  border-radius: 5px;
  background: radial-gradient(ellipse at 3% 53%,color-mix(in srgb,var(--racer-color),transparent 78%),transparent 65%), #10171d;
}
.fighter-preview { width: 100%; height: 81px; object-fit: contain; filter: drop-shadow(1px 5px 6px #05070b); }
.racer-spec strong { font: italic 900 1.5rem/1.05 var(--head); text-transform: uppercase; }
.course-card[aria-pressed=true] { box-shadow: inset 3px 0 0 var(--acid); }
#race .race-top .telemetry { border-top: 2px solid color-mix(in srgb,var(--course-color),transparent 43%); }
#race .telemetry.score { border-top-color: var(--acid); }
#race .race-side { border-bottom: 2px solid var(--course-color); }
#race-message.countdown {
  font-size: clamp(4.6rem,13vw,11rem); letter-spacing: -.035em;
  filter: drop-shadow(0 7px 24px #090a04d8);
}
#race-message.impact {
  color: #fff0aa; text-shadow: 0 3px 0 #a42b15, 0 5px 19px #000, 0 0 22px #f78139c0;
}
.smash-chain {
  position: absolute; right: max(16px,env(safe-area-inset-right)); top: max(86px,calc(env(safe-area-inset-top) + 76px));
  color: #1a1208; background: #ffc760; border-left: 4px solid #fff4b2;
  box-shadow: 0 6px 22px #07040586; padding: 3px 10px; transform: skewX(-8deg); pointer-events: none;
}
.smash-chain strong { font: italic 900 clamp(1.25rem,3vw,2.55rem)/1 var(--head); margin-right: .24em; }
.smash-chain span { font-size: .66rem; font-weight: 700; text-transform: uppercase; }

@media (max-width: 560px) {
  .racer-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .racer-card { min-height: 76px; }
  .racer-card img { height: 44px; width: 49px; }
  .racer-spec { grid-template-columns: 66px 1fr; gap: 5px 8px; }
  .racer-spec .spec-meters { grid-column: 2; }
  .fighter-preview { grid-row: span 2; height: 77px; }
  .smash-chain { top: max(64px,calc(env(safe-area-inset-top) + 58px)); }
}
@media (any-pointer: coarse) and (max-height: 530px) {
  .smash-chain { right: max(110px,calc(env(safe-area-inset-right) + 108px)); }
}
@media (prefers-reduced-motion: reduce) {
  .racer-card, .racer-card img { transition: none; }
  .racer-card:hover img { translate: none; }
}
