:root {
  color-scheme: dark;
  --night: #090f20;
  --ink: #edf8ff;
  --quiet: #96afc4;
  --mint: #64f7d4;
  --edge: #527994;
  --surface: rgb(18 32 51 / .91);
  --body-font: system-ui, sans-serif;
  --display-font: "DIN Condensed", "Aptos Narrow", "Arial Narrow", Impact, sans-serif;
  font-family: var(--body-font);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--night); color: var(--ink); }
button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--mint); outline-offset: 4px; }

.stage {
  --inset: clamp(10px, 1.25vw, 22px);
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--night) url("canyon.webp") center / cover no-repeat;
}
.stage:fullscreen { width: 100%; height: 100%; }
.stage:-webkit-full-screen { width: 100%; height: 100%; }
.stage:focus { outline: none; }
#track { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.neon-frame {
  --cut: 12px;
  --line: 2px;
  position: relative;
  isolation: isolate;
  border: 0;
  background: var(--surface);
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
}
.neon-frame::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background: var(--edge);
  clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, var(--line) var(--cut), var(--cut) var(--line), calc(100% - var(--cut)) var(--line), calc(100% - var(--line)) var(--cut), calc(100% - var(--line)) calc(100% - var(--cut)), calc(100% - var(--cut)) calc(100% - var(--line)), var(--cut) calc(100% - var(--line)), var(--line) calc(100% - var(--cut)), var(--line) var(--cut));
}
.neon-frame:focus-visible { --edge: var(--mint); outline: none; }

.hud {
  position: absolute;
  inset: max(var(--inset), env(safe-area-inset-top)) max(var(--inset), env(safe-area-inset-right)) auto max(var(--inset), env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
}
.distance {
  --edge: #365b78;
  --cut: clamp(8px, .9vw, 14px);
  margin: 0;
  min-width: clamp(92px, 12.5vw, 202px);
  padding: clamp(8px, .75vw, 14px) clamp(12px, 1.65vw, 28px) clamp(7px, .65vw, 12px);
  font-family: var(--display-font);
  font-weight: 750;
  line-height: 1;
}
.distance dt {
  margin-bottom: 1px;
  font-size: clamp(14px, 1.52vw, 24px);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.distance dd {
  margin: 0;
  font-size: clamp(26px, 2.72vw, 45px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.distance .unit { font-size: .87em; }
.actions { display: flex; align-items: flex-start; gap: clamp(6px, 1.3vw, 22px); pointer-events: auto; }
.action {
  --cut: 9px;
  --edge: #466e8a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 1.2vw, 20px);
  min-height: clamp(44px, 3.4vw, 55px);
  padding: 6px clamp(9px, 1.08vw, 19px);
  font-family: var(--display-font);
  font-size: clamp(17px, 1.54vw, 25px);
  font-weight: 750;
  letter-spacing: .02em;
  white-space: nowrap;
}
.action:hover { --edge: #8ab7cb; --surface: rgb(25 44 64 / .96); }
#arrow-toggle { min-width: clamp(102px, 13.1vw, 208px); }
#fullscreen { min-width: clamp(94px, 12.4vw, 198px); }
.action svg { width: clamp(17px, 1.8vw, 28px); flex: none; }
.action svg, .arrow-overlay svg, .steer-hint svg, .touch-controls svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.contract, #fullscreen[aria-pressed="true"] .expand { display: none; }
#fullscreen[aria-pressed="true"] .contract { display: block; }

.switch-track {
  --thumb: clamp(13px, 1.24vw, 20px);
  display: flex;
  align-items: center;
  width: clamp(28px, 3.26vw, 53px);
  min-height: calc(var(--thumb) + 6px);
  padding: 3px;
  border-radius: 99px;
  background: #32485c;
}
.switch-track > span { width: var(--thumb); height: var(--thumb); border-radius: 50%; background: var(--ink); }
#arrow-toggle[aria-checked="true"] .switch-track { justify-content: flex-end; background: var(--mint); }
.fullscreen-feedback {
  position: absolute;
  right: 0;
  top: calc(clamp(44px, 3.4vw, 55px) + 8px);
  margin: 0;
  border-radius: 6px;
  background: #152134;
  color: var(--ink);
  font-size: .82rem;
}
.fullscreen-feedback:not(:empty) { border: 1px solid var(--edge); padding: 8px 10px; }

.run-panel {
  --cut: clamp(12px, 1.2vw, 19px);
  position: absolute;
  z-index: 2;
  top: clamp(66px, 9.9vh, 114px);
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 28px, max(470px, 40.5vw));
  max-width: 720px;
  padding: clamp(20px, 2.6vw, 43px) clamp(16px, 2.7vw, 45px) clamp(14px, 1.25vw, 23px);
  text-align: center;
}
.run-panel h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--display-font);
  font-size: clamp(33px, 3.74vw, 63px);
  font-weight: 850;
  line-height: .98;
  letter-spacing: .008em;
  text-transform: uppercase;
  text-wrap: balance;
}
.run-panel p { margin: 5px 0 0; color: var(--quiet); font-weight: 550; }
#panel-copy { font-size: clamp(15px, 1.68vw, 28px); }
#finish-detail { font-size: clamp(13px, 1.25vw, 19px); font-variant-numeric: tabular-nums; }
.start {
  --cut: 12px;
  min-width: 60%;
  min-height: clamp(44px, 4vw, 67px);
  margin-top: clamp(15px, 1.96vw, 32px);
  padding: 6px 20px 3px;
  border: 0;
  background: var(--mint);
  color: #0a1a27;
  font-family: var(--display-font);
  font-size: clamp(24px, 2.64vw, 43px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: .025em;
  text-transform: uppercase;
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
}
.start:hover { background: #9dffe8; }
.start:focus-visible { background: #c9fff2; box-shadow: inset 0 0 0 4px #238777; outline: none; }
.run-panel .steer-hint { margin-top: clamp(7px, .75vw, 13px); font-size: clamp(14px, 1.42vw, 25px); }
.steer-hint span { display: inline-flex; gap: .24em; align-items: center; vertical-align: -.12em; }
.steer-hint svg { width: .86em; height: .86em; }

.arrow-overlay {
  --cut: clamp(7px, .85vw, 14px);
  --edge: #365b78;
  --surface: rgb(15 28 44 / .89);
  --key: clamp(32px, 3.5vw, 56px);
  position: absolute;
  right: max(var(--inset), env(safe-area-inset-right));
  bottom: max(6.8vh, env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, var(--key));
  gap: clamp(4px, .55vw, 9px);
  padding: clamp(8px, .98vw, 16px) clamp(8px, 1.22vw, 21px);
  pointer-events: none;
}
.arrow-overlay kbd {
  display: grid;
  place-items: center;
  width: var(--key);
  height: var(--key);
  border: 2px solid var(--ink);
  border-radius: clamp(5px, .65vw, 11px);
  background: #152134;
  color: var(--ink);
}
.arrow-overlay kbd.up { grid-column: 2; }
.arrow-overlay kbd.left { grid-column: 1; grid-row: 2; }
.arrow-overlay kbd.down { grid-column: 2; grid-row: 2; }
.arrow-overlay kbd.right { grid-column: 3; grid-row: 2; }
.arrow-overlay svg { width: 63%; }
.arrow-overlay kbd[data-active="true"], .touch-controls button[data-active="true"] {
  border-color: var(--mint);
  background: var(--mint);
  color: #0a1a27;
}
.left > svg, svg.left { transform: rotate(-90deg); }
.down > svg { transform: rotate(180deg); }
.right > svg, svg.right { transform: rotate(90deg); }

.touch-controls {
  display: none;
  position: absolute;
  left: max(var(--inset), env(safe-area-inset-left));
  bottom: max(var(--inset), env(safe-area-inset-bottom));
  z-index: 2;
  gap: 10px;
}
.touch-controls button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 10px;
  border: 2px solid var(--edge);
  border-radius: 9px;
  background: var(--surface);
  touch-action: none;
  user-select: none;
}
.touch-controls svg { width: 100%; }
@media (any-pointer: coarse) {
  .stage[data-mode="running"] .touch-controls { display: flex; }
}
@media (min-width: 730px) {
  .run-panel h1 { transform: scaleX(1.16); }
}

@media (max-width: 480px) {
  .actions { gap: 5px; }
  .action { gap: 5px; min-height: 44px; padding-inline: 8px; font-size: 16px; }
  .action svg { width: 15px; }
  .distance { min-width: 70px; padding-inline: 10px; }
  .distance dt { font-size: 12px; }
  .distance dd { font-size: 22px; }
  #fullscreen[aria-pressed="true"] #fullscreen-label { max-width: 6em; white-space: normal; text-align: center; line-height: 1.02; }
  .arrow-overlay { bottom: max(var(--inset), env(safe-area-inset-bottom)); }
}
@media (max-height: 440px) {
  .run-panel { padding-block: 13px; }
  .run-panel h1 { font-size: clamp(29px, 3.15vw, 46px); }
  .start { margin-top: 10px; }
  .arrow-overlay { --key: clamp(28px, 3.4vw, 44px); bottom: max(var(--inset), env(safe-area-inset-bottom)); }
}
.svg-defs, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.no-script { position: absolute; inset: auto 20px 20px; z-index: 5; color: var(--ink); }
