:root {
  --ink: #1B1420;
  --bone: #F3E6C8;
  --bone-deep: #E3CEA4;
  --saffron: #F2A93B;
  --magenta: #E0457B;
  --mint: #3FB8A5;
  --violet: #5B2A86;
  --cobalt: #2A5DB0;
  --paper: #F3E6C8;
  --display: 'Ultra', Georgia, serif;
  --text: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --num: 'Dela Gothic One', 'Barlow Condensed', sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #1B1420;
  color: var(--ink);
  font-family: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.print-grain {
  display: none;
}

button { font-family: inherit; }

/* ---------------------------------------------------------------- */
/* loading */
/* ---------------------------------------------------------------- */

.loading {
  position: absolute;
  inset: 0;
  z-index: 90;
  overflow: hidden;
  background: #1B1420;
  transition: opacity 0.6s ease;
}
.loading.gone { opacity: 0; pointer-events: none; }

.loading-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 58% 50%;
  filter: saturate(1.05);
}

.loading-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(27,20,32,0.86) 0%, rgba(27,20,32,0.35) 40%, rgba(27,20,32,0.05) 70%),
    linear-gradient(0deg, rgba(27,20,32,0.9) 0%, rgba(27,20,32,0.1) 45%);
}

.loading-content {
  position: absolute;
  left: clamp(20px, 6vw, 90px);
  bottom: clamp(34px, 9vh, 110px);
  width: min(520px, 82vw);
  color: var(--bone);
}

.load-eyebrow, .kicker {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  font-size: clamp(9px, 1.2vw, 12px);
  margin: 0 0 10px;
  color: var(--saffron);
}

.load-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(46px, 8vw, 100px);
  line-height: 0.82;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--bone);
  text-shadow: 6px 6px 0 var(--violet), 10px 10px 0 rgba(27,20,32,0.55);
  transform: rotate(-2deg);
  transform-origin: left bottom;
}

.load-sub {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--magenta);
  margin: 4px 0 26px;
  font-size: clamp(11px, 1.4vw, 16px);
}

.load-bar {
  width: min(360px, 70vw);
  height: 14px;
  border: 3px solid var(--ink);
  background: rgba(243, 230, 200, 0.2);
  box-shadow: 4px 4px 0 rgba(27,20,32,0.5);
  position: relative;
  overflow: hidden;
}
.load-bar span {
  display: block;
  height: 100%;
  width: 4%;
  background: repeating-linear-gradient(115deg, var(--saffron) 0 8px, var(--magenta) 8px 16px);
  transition: width 0.35s ease;
}
.load-note {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.3em;
  font-size: 11px;
  margin: 12px 0 0;
  color: rgba(243,230,200,0.8);
}

/* ---------------------------------------------------------------- */
/* menu */
/* ---------------------------------------------------------------- */

.menu {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.menu.hidden, [hidden] { display: none !important; }

.title-art {
  position: absolute;
  left: calc(2.4vw + var(--safe-l));
  top: calc(1.4vh + var(--safe-t));
  width: min(38vw, 660px);
  height: auto;
  transform: rotate(-3.4deg);
  transform-origin: left top;
  filter: drop-shadow(0 18px 30px rgba(27, 20, 32, 0.22));
  pointer-events: none;
  user-select: none;
}

.ticket-stack {
  position: absolute;
  left: calc(3.6vw + var(--safe-l));
  top: 42.5vh;
  width: min(15.5vw, 240px);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1.1vh, 14px);
  pointer-events: auto;
  transform-origin: left top;
}

.ticket {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform-origin: left center;
  transition: transform 0.18s cubic-bezier(.2,.9,.25,1.2), filter 0.18s ease;
  will-change: transform;
}
.ticket:nth-child(1) { transform: rotate(-1.6deg); }
.ticket:nth-child(2) { transform: rotate(1.1deg); }
.ticket:nth-child(3) { transform: rotate(-0.8deg); }
.ticket:nth-child(4) { transform: rotate(1.6deg); }

.ticket img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(27,20,32,0.22));
}

.ticket .go-mark {
  position: absolute;
  right: -0.65em;
  top: 50%;
  transform: translate(-40%, -50%) scale(0.5) rotate(-12deg);
  font-family: var(--num);
  font-size: clamp(16px, 2vw, 28px);
  color: var(--magenta);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--bone);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.18s cubic-bezier(.2,.9,.25,1.4);
  pointer-events: none;
}
.ticket:hover, .ticket:focus-visible {
  transform: rotate(0deg) scale(1.045);
  filter: drop-shadow(0 10px 0 rgba(27,20,32,0.16));
  outline: none;
}
.ticket:hover .go-mark, .ticket:focus-visible .go-mark {
  opacity: 1;
  transform: translate(0, -50%) scale(1) rotate(-6deg);
}
.ticket:active { transform: rotate(0deg) scale(0.985); }

.menu-corner {
  position: absolute;
  right: calc(1.8vw + var(--safe-r));
  top: calc(1.6vh + var(--safe-t));
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.sound-btn {
  width: 44px;
  height: 44px;
  border: 3px solid var(--ink);
  background: var(--bone);
  box-shadow: 4px 4px 0 rgba(27,20,32,0.35);
  clip-path: polygon(8% 0, 92% 0, 100% 12%, 100% 88%, 92% 100%, 8% 100%, 0 88%, 0 12%);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.sound-btn svg { fill: var(--ink); stroke: var(--ink); stroke-width: 1.6; fill-rule: evenodd; }
.sound-btn svg .wave { fill: none; stroke-linecap: round; }
.sound-btn svg .cross { display: none; fill: none; stroke: var(--magenta); stroke-width: 2.4; stroke-linecap: round; }
.sound-btn[aria-pressed="false"] svg .wave { display: none; }
.sound-btn[aria-pressed="false"] svg .cross { display: block; }
.sound-btn:hover { background: var(--saffron); }

.cash-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 6px;
  background: var(--bone);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(27,20,32,0.35);
  clip-path: polygon(6% 0, 100% 0, 100% 100%, 0 100%, 0 16%);
}
.cash-chip img { width: 27px; height: 27px; object-fit: contain; }
.cash-chip span {
  font-family: var(--num);
  font-size: 14px;
  color: var(--violet);
  letter-spacing: 0.02em;
}

.menu-foot {
  position: absolute;
  left: calc(3.6vw + var(--safe-l));
  bottom: calc(2.4vh + var(--safe-b));
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 30px);
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.26em;
  font-size: clamp(8px, 1vw, 11px);
  pointer-events: none;
}
.menu-foot .tag { color: var(--ink); text-shadow: 0 1px 0 rgba(243,230,200,0.5); }
.menu-foot .dim { color: rgba(27,20,32,0.62); }
.menu-foot .press { color: var(--violet); }
.menu-credit {
  position: absolute;
  right: calc(1.9vw + var(--safe-r));
  bottom: calc(2.4vh + var(--safe-b));
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.24em;
  font-size: 9px;
  color: rgba(243,230,200,0.85);
  text-shadow: 0 1px 2px rgba(27,20,32,0.7);
  pointer-events: none;
}

/* ---------------------------------------------------------------- */
/* paper panel */
/* ---------------------------------------------------------------- */

.panel-wrap {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-t)) calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l));
  background: rgba(27, 20, 32, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.panel {
  width: min(820px, 94vw);
  max-height: 88vh;
  background: var(--ink);
  padding: 6px;
  clip-path: polygon(0 2.2%, 1.6% 0, 98.6% 0, 100% 2.4%, 99.4% 9%, 100% 16%, 99.2% 24%, 100% 33%, 99.4% 42%, 100% 52%, 99.2% 61%, 100% 70%, 99.4% 79%, 100% 88%, 98.6% 100%, 1.4% 100%, 0 97.6%);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  animation: panelIn 0.32s cubic-bezier(.2,.9,.25,1.05);
}
.panel-inner {
  background: var(--bone);
  max-height: calc(88vh - 12px);
  overflow: auto;
  padding: clamp(18px, 3.2vw, 38px) clamp(18px, 4vw, 46px) clamp(20px, 3vw, 36px);
  clip-path: polygon(0 2.2%, 1.7% 0, 98.5% 0, 100% 2.4%, 99.4% 9%, 100% 16%, 99.2% 24%, 100% 33%, 99.4% 42%, 100% 52%, 99.2% 61%, 100% 70%, 99.4% 79%, 100% 88%, 98.5% 100%, 1.4% 100%, 0 97.6%);
  background-image: radial-gradient(rgba(27,20,32,0.3) 0.6px, transparent 0.7px);
  background-size: 4px 4px;
  background-position: 0 0;
  scrollbar-width: thin;
  scrollbar-color: var(--violet) transparent;
}

.panel-head { position: relative; padding-right: 80px; border-bottom: 3px solid var(--ink); padding-bottom: 14px; margin-bottom: 20px; }
.panel-kicker { margin-bottom: 4px; color: var(--violet); letter-spacing: 0.34em; }
.panel-head h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(28px, 4.4vw, 52px);
  line-height: 0.95;
  margin: 0;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(224,69,123,0.35);
  transform: rotate(-1deg);
}
.panel-close {
  position: absolute;
  right: 0;
  top: 4px;
  border: 3px solid var(--ink);
  background: var(--magenta);
  color: var(--bone);
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 11px;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.panel-close:hover { background: var(--violet); }

.panel-body {
  font-family: var(--text);
  font-weight: 500;
  letter-spacing: 0.06em;
  font-size: 15px;
  line-height: 1.45;
  color: #2A1E30;
}
.panel-body h3 {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--violet);
  margin: 26px 0 10px;
  text-transform: uppercase;
}
.panel-body h3:first-child { margin-top: 0; }
.panel-body p { margin: 0 0 12px; max-width: 66ch; }
.panel-body .lead {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.panel-body .small { font-size: 12px; letter-spacing: 0.12em; color: rgba(42,30,48,0.7); }
.panel-body b { font-weight: 700; }

.rule { height: 3px; background: var(--ink); margin: 22px 0; opacity: 0.85; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 6px; }
.swatch {
  position: relative;
  width: 54px;
  height: 54px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  box-shadow: 3px 3px 0 rgba(27,20,32,0.25);
  transition: transform 0.12s ease;
}
.swatch:hover { transform: translateY(-2px) rotate(-3deg); }
.swatch.on { outline: 4px solid var(--saffron); outline-offset: 2px; }
.swatch.on::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: rgba(27,20,32,0.82);
}
.swatch-row.small .swatch { width: 42px; height: 42px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(18px, 4vw, 40px); }
@media (max-width: 620px) { .two-col { grid-template-columns: 1fr; } }

.stat-row { display: grid; grid-template-columns: 88px 1fr 38px; align-items: center; gap: 8px; margin: 8px 0; }
.stat-row span { font-weight: 700; letter-spacing: 0.16em; font-size: 10px; text-transform: uppercase; }
.stat-row b { font-family: var(--num); font-weight: 400; font-size: 11px; text-align: right; }
.stat-rail { height: 10px; border: 2px solid var(--ink); background: rgba(27,20,32,0.09); }
.stat-rail i { display: block; height: 100%; background: repeating-linear-gradient(115deg, var(--magenta) 0 6px, var(--saffron) 6px 12px); }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 2px dashed rgba(27,20,32,0.25); }
.setting-row:last-child { border-bottom: 0; }
.setting-row label { font-weight: 700; letter-spacing: 0.16em; font-size: 11px; text-transform: uppercase; }
.setting-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: min(240px, 44vw);
  height: 10px;
  background: rgba(27,20,32,0.14);
  border: 2px solid var(--ink);
  outline: none;
}
.setting-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 22px;
  background: var(--magenta);
  border: 3px solid var(--ink);
  cursor: pointer;
  border-radius: 0;
  box-shadow: 2px 2px 0 rgba(27,20,32,0.28);
}
.setting-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 22px; background: var(--magenta); border: 3px solid var(--ink); border-radius: 0; cursor: pointer;
}
.toggle {
  border: 3px solid var(--ink);
  background: var(--bone-deep);
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 11px;
  padding: 6px 14px;
  cursor: pointer;
  min-width: 74px;
  box-shadow: 3px 3px 0 rgba(27,20,32,0.25);
}
.toggle.on { background: var(--mint); }
.toggle:hover { filter: brightness(1.05); }

.credits-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; }
.credit-card { border: 3px solid var(--ink); padding: 14px 16px; background: rgba(243,230,200,0.6); }
.credit-card h4 {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.2em;
  font-size: 10px;
  margin: 0 0 8px;
  color: var(--violet);
  text-transform: uppercase;
}
.credit-card p { margin: 0; font-size: 13px; line-height: 1.4; }
.big-credit {
  font-family: var(--display);
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1;
  color: var(--violet);
  margin: 0 0 4px;
  text-shadow: 2px 2px 0 var(--magenta);
}

/* ---------------------------------------------------------------- */
/* wipe */
/* ---------------------------------------------------------------- */

.wipe {
  position: absolute;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  transform: translateX(-108%);
  transition: transform 0.44s cubic-bezier(.68,0,.28,1);
}
.wipe span {
  position: absolute;
  inset: -4%;
  display: block;
  background: var(--ink);
  clip-path: polygon(0 0, 92% 0, 96% 8%, 93% 17%, 97% 27%, 94% 38%, 98% 49%, 95% 60%, 97% 71%, 93% 82%, 96% 91%, 94% 100%, 0 100%);
}
.wipe::after {
  content: "";
  position: absolute;
  inset: -4%;
  background: var(--magenta);
  clip-path: polygon(92% 0, 95% 0, 99% 8%, 96% 17%, 100% 27%, 97% 38%, 101% 49%, 98% 60%, 100% 71%, 96% 82%, 99% 91%, 97% 100%, 92% 100%);
}
.wipe.in { transform: translateX(0); }
.wipe.out { transform: translateX(108%); }

/* ---------------------------------------------------------------- */
/* HUD */
/* ---------------------------------------------------------------- */

.race { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.race .hud { transition: opacity 0.28s ease; }
.race.finishing .hud, .race.finishing .control-line { opacity: 0; }
.race .race-actions button, .race .touch-controls button, .race .pause-panel, .race .results, .race .help-card, .race .pause-btn { pointer-events: auto; }
.hud { position: absolute; inset: 0; pointer-events: none; }

.pos-frame {
  position: absolute;
  left: calc(1.3vw + var(--safe-l));
  top: calc(1.2vh + var(--safe-t));
  width: clamp(190px, 22vw, 310px);
  aspect-ratio: 1024 / 480;
  background-image: url("../assets/img/telegraph_frame.webp");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 10px 14px rgba(27,20,32,0.25));
}
.pos-inner {
  position: absolute;
  inset: 9% 9% 10% 8%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pos-kicker {
  margin: 0;
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(6px, 0.72vw, 9px);
  letter-spacing: 0.22em;
  color: var(--violet);
  white-space: nowrap;
}
.pos-num {
  margin: 0;
  font-family: var(--num);
  font-weight: 400;
  line-height: 0.9;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.08em;
}
.pos-num span { font-size: clamp(34px, 4.6vw, 66px); }
.pos-num small { font-family: var(--num); font-size: clamp(12px, 1.4vw, 20px); color: var(--violet); }
.pos-num .pos-slash { font-family: var(--text); font-weight: 700; font-size: clamp(15px, 1.7vw, 24px); color: var(--ink); padding: 0 2px 0 1px; }
.pos-clock {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 0;
  font-family: var(--num);
  font-size: clamp(11px, 1.2vw, 17px);
  color: var(--ink);
}
.pos-clock img { width: clamp(13px, 1.3vw, 18px); height: auto; opacity: 0.9; }

.progress-strip {
  position: absolute;
  right: calc(1.4vw + var(--safe-r));
  top: calc(1.3vh + var(--safe-t));
  width: clamp(230px, 30vw, 430px);
}
.strip-track {
  position: relative;
  height: clamp(38px, 5.4vh, 54px);
  background: var(--bone);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(27,20,32,0.3);
  clip-path: polygon(0 12%, 3% 0, 97% 0, 100% 12%, 100% 88%, 97% 100%, 3% 100%, 0 88%);
}
.strip-line { position: absolute; left: 4%; top: 18%; width: 92%; height: 40%; opacity: 0.75; }
.strip-chips { position: absolute; inset: 0; }
.strip-chips .chip {
  position: absolute;
  bottom: 2px;
  width: clamp(18px, 2.1vw, 28px);
  height: clamp(18px, 2.1vw, 28px);
  border: 2px solid var(--ink);
  border-radius: 50%;
  overflow: hidden;
  transform: translateX(-50%);
  background: var(--bone);
  transition: bottom 0.18s ease;
  z-index: 3;
}
.strip-chips .chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-chips .chip.me { border-color: var(--saffron); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--saffron); z-index: 5; }
.strip-flags .flag {
  position: absolute;
  top: -10px;
  transform: translateX(-50%);
  width: clamp(14px, 1.6vw, 22px);
  height: auto;
  filter: drop-shadow(0 2px 0 rgba(27,20,32,0.25));
}
.strip-start {
  position: absolute;
  left: 3%;
  bottom: 1px;
  width: 4px;
  height: calc(100% - 2px);
  background: var(--ink);
}
.strip-finish {
  position: absolute;
  right: 0.5%;
  top: -13%;
  height: 126%;
  aspect-ratio: 347 / 283;
  z-index: 2;
}
.strip-finish img { width: 100%; height: 100%; object-fit: contain; }
.strip-label {
  display: flex;
  justify-content: space-between;
  margin: 4px 2px 0;
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(6px, 0.62vw, 8px);
  letter-spacing: 0.16em;
  color: var(--bone);
  text-shadow: 0 1px 2px rgba(27,20,32,0.8);
}

.standings {
  position: absolute;
  right: calc(1.4vw + var(--safe-r));
  top: clamp(78px, 12.6vh, 122px);
  width: clamp(180px, 15.5vw, 240px);
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}
.stand-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: clamp(30px, 3.7vh, 40px);
  padding: 0 8px 0 4px;
  background: rgba(243, 230, 200, 0.94);
  border: 2px solid var(--ink);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 5% 100%, 0 84%);
  box-shadow: 3px 3px 0 rgba(27,20,32,0.24);
  transition: transform 0.2s ease;
}
.stand-row .tab { width: 4px; align-self: stretch; margin: 4px 0; background: var(--violet); }
.stand-row .pic {
  width: clamp(20px, 2.2vw, 28px);
  height: clamp(20px, 2.2vw, 28px);
  border: 2px solid var(--ink);
  border-radius: 50%;
  overflow: hidden;
  flex: none;
}
.stand-row .pic img { width: 100%; height: 100%; object-fit: cover; }
.stand-row .who {
  flex: 1;
  min-width: 0;
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(8px, 0.78vw, 10px);
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stand-row .who small { display: block; font-size: 7px; letter-spacing: 0.16em; color: rgba(42,30,48,0.55); }
.stand-row .gap { font-family: var(--num); font-size: clamp(8px, 0.8vw, 11px); color: var(--violet); }
.stand-row .place {
  font-family: var(--num);
  font-size: clamp(11px, 1vw, 14px);
  color: var(--ink);
  width: 18px;
  text-align: right;
}
.stand-row.me { background: var(--saffron); border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 3px 3px 0 rgba(27,20,32,0.3); }

.gauge {
  position: absolute;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%);
  width: clamp(150px, 15vw, 230px);
  aspect-ratio: 1 / 0.92;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 8px 12px rgba(27,20,32,0.3));
}
.gauge-shoe {
  position: absolute;
  left: 50%;
  top: 47%;
  transform: translate(-50%, -50%);
  width: 58%;
  height: auto;
  opacity: 0.98;
}
.gauge-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gauge-svg .arc-bg {
  fill: none;
  stroke: rgba(27,20,32,0.35);
  stroke-width: 7;
  stroke-linecap: round;
}
.gauge-svg .arc-fg {
  fill: none;
  stroke: var(--magenta);
  stroke-width: 5.4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
  filter: drop-shadow(0 0 2px rgba(243,230,200,0.5));
}
.gauge-speed {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--bone);
  line-height: 0.9;
}
.gauge-speed span {
  font-family: var(--num);
  font-size: clamp(18px, 2vw, 30px);
  display: block;
  text-shadow: 2px 2px 0 var(--ink);
}
.gauge-speed small { font-family: var(--text); font-weight: 700; font-size: 7px; letter-spacing: 0.24em; }
.stamina {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  width: 74%;
  height: clamp(12px, 1.4vw, 18px);
  border: 2px solid var(--ink);
  background: rgba(27,20,32,0.32);
  display: flex;
  align-items: center;
  overflow: hidden;
}
.stamina img {
  position: absolute;
  left: -10%;
  top: 50%;
  transform: translateY(-50%);
  width: 38%;
  height: 190%;
  object-fit: contain;
  opacity: 0.9;
  z-index: 2;
}
.stamina-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: repeating-linear-gradient(115deg, var(--bone) 0 5px, var(--magenta) 5px 10px);
  transition: width 0.12s linear;
}
.stamina-fray {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: var(--ink);
  clip-path: polygon(0 0, 60% 10%, 20% 28%, 80% 42%, 30% 60%, 90% 76%, 40% 100%, 0 100%);
  opacity: 0;
}
.gauge.low .stamina-fill { animation: frayFlash 0.34s steps(2) infinite; }
.gauge.low .stamina-fray { opacity: 1; animation: frayFlash 0.24s steps(2) infinite; }
.gauge-label {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(6px, 0.7vw, 9px);
  letter-spacing: 0.34em;
  color: var(--bone);
  text-shadow: 0 1px 2px rgba(27,20,32,0.85);
}

.race-actions {
  position: absolute;
  top: calc(1.5vh + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.round-btn {
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--num);
  font-size: 13px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 3px 3px 0 rgba(27,20,32,0.28);
}
.round-btn:hover { background: var(--saffron); }

/* ---------------------------------------------------------------- */
/* race overlays */
/* ---------------------------------------------------------------- */

.marks {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  overflow: hidden;
}
.marks img {
  position: absolute;
  animation: markSlam 0.72s cubic-bezier(.2,.9,.2,1) forwards;
  filter: drop-shadow(6px 6px 0 rgba(27,20,32,0.45));
}
.marks img.spur { right: 5%; bottom: 26%; width: clamp(180px, 27vw, 360px); }
.marks img.overtake { left: 50%; top: 40%; width: clamp(180px, 22vw, 320px); animation: markGo 0.72s cubic-bezier(.2,.9,.2,1) forwards; }
.marks img.go { left: 50%; top: 40%; transform: translate(-50%, -50%); width: clamp(240px, 34vw, 480px); animation: goBurst 1.1s cubic-bezier(.2,.9,.2,1) forwards; }

.speedlines {
  position: absolute;
  inset: -20%;
  z-index: 21;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: repeating-conic-gradient(from 0deg at 50% 44%, transparent 0deg 5.4deg, rgba(27,20,32,0.7) 5.4deg 5.8deg, transparent 5.8deg 11deg);
  -webkit-mask-image: radial-gradient(ellipse at 50% 44%, transparent 24%, black 62%);
  mask-image: radial-gradient(ellipse at 50% 44%, transparent 24%, black 62%);
}
.speedlines.on { opacity: 0.75; animation: speedSpin 0.6s linear infinite; }

.countdown {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  pointer-events: none;
  text-align: center;
}
.countdown .count-num {
  font-family: var(--display);
  font-size: clamp(100px, 24vw, 280px);
  line-height: 0.8;
  color: var(--bone);
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  text-shadow: 12px 14px 0 var(--violet), 18px 20px 0 rgba(27,20,32,0.35);
  animation: countSlam 0.92s cubic-bezier(.16,.9,.2,1) both;
  transform: translateY(-4vh) rotate(-4deg);
}
.countdown .count-sub {
  position: absolute;
  left: 50%;
  top: 66%;
  transform: translateX(-50%);
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(9px, 1.1vw, 13px);
  letter-spacing: 0.3em;
  color: var(--bone);
  text-shadow: 0 2px 6px rgba(27,20,32,0.8);
  white-space: nowrap;
}

.touch-controls {
  position: absolute;
  left: calc(14px + var(--safe-l));
  right: calc(14px + var(--safe-r));
  bottom: calc(16px + var(--safe-b));
  z-index: 25;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.steer-group, .act-group { display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
.steer-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: rgba(243,230,200,0.92);
  color: var(--ink);
  font-family: var(--display);
  font-size: 34px;
  line-height: 0;
  padding-bottom: 6px;
  box-shadow: 4px 4px 0 rgba(27,20,32,0.35);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
.steer-btn:active, .steer-btn.held { background: var(--saffron); transform: translateY(2px); box-shadow: 2px 2px 0 rgba(27,20,32,0.35); }
.act-btn {
  border: 3px solid var(--ink);
  background: rgba(243,230,200,0.92);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.14em;
  box-shadow: 4px 4px 0 rgba(27,20,32,0.35);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.act-btn.small { width: 58px; height: 58px; border-radius: 50%; font-size: 10px; }
.act-btn.spur {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--magenta);
  color: var(--bone);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  position: relative;
  overflow: hidden;
}
.act-btn.spur img { width: 42px; height: auto; filter: drop-shadow(1px 1px 0 rgba(27,20,32,0.4)); }
.act-btn.spur span { font-size: 11px; letter-spacing: 0.22em; }
.act-btn.spur:active, .act-btn.spur.held { background: var(--violet); transform: translateY(2px); box-shadow: 2px 2px 0 rgba(27,20,32,0.35); }

.control-line {
  position: absolute;
  left: 50%;
  bottom: calc(3px + var(--safe-b));
  transform: translateX(-50%);
  margin: 0;
  z-index: 24;
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(6px, 0.7vw, 9px);
  letter-spacing: 0.18em;
  color: rgba(243,230,200,0.9);
  text-shadow: 0 1px 3px rgba(27,20,32,0.9);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------------------------------------------------------------- */
/* pause + help */
/* ---------------------------------------------------------------- */

.pause-panel {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(27,20,32,0.72);
  backdrop-filter: blur(3px);
}
.pause-card {
  width: min(420px, 88vw);
  background: var(--bone);
  border: 6px solid var(--ink);
  padding: clamp(20px, 4vw, 36px);
  text-align: center;
  clip-path: polygon(0 2%, 2% 0, 98% 0, 100% 2%, 100% 98%, 98% 100%, 2% 100%, 0 98%);
  box-shadow: 10px 10px 0 rgba(27,20,32,0.4);
  animation: panelIn 0.3s cubic-bezier(.2,.9,.25,1.05);
}
.pause-card h2 {
  font-family: var(--display);
  font-size: clamp(38px, 7vw, 64px);
  margin: 0 0 20px;
  color: var(--ink);
  text-shadow: 4px 4px 0 var(--magenta);
  transform: rotate(-2deg);
}
.pause-card .kicker { color: var(--violet); }
.pause-actions { display: flex; flex-direction: column; gap: 10px; }
.pause-actions button, .stamp-btn {
  border: 3px solid var(--ink);
  background: var(--bone-deep);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.24em;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
}
.pause-actions button:hover, .stamp-btn:hover { background: var(--saffron); transform: translateY(-1px); }
.pause-actions button:active, .stamp-btn:active { transform: translateY(2px); box-shadow: 2px 2px 0 var(--ink); }
.stamp-btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.stamp-btn.ghost:hover { background: rgba(27,20,32,0.08); }

.help-card {
  position: absolute;
  left: calc(14px + var(--safe-l));
  bottom: calc(110px + var(--safe-b));
  z-index: 26;
  width: min(330px, 76vw);
  background: var(--bone);
  border: 4px solid var(--ink);
  padding: 18px 20px 16px;
  clip-path: polygon(0 3%, 3% 0, 97% 0, 100% 3%, 99.4% 22%, 100% 44%, 99.4% 66%, 100% 86%, 97% 100%, 2% 100%, 0 96%);
  box-shadow: 6px 6px 0 rgba(27,20,32,0.35);
  pointer-events: auto;
  animation: panelIn 0.24s ease;
}
.help-card h3 { font-family: var(--text); font-weight: 700; font-size: 15px; letter-spacing: 0.16em; margin: 0 0 10px; color: var(--violet); }
.help-card ul { margin: 0; padding: 0 0 0 16px; font-size: 12.5px; line-height: 1.5; letter-spacing: 0.03em; }
.help-card li { margin-bottom: 5px; }
.help-card .kicker { color: var(--violet); margin-bottom: 4px; }
.help-close {
  position: absolute;
  right: 8px;
  top: 8px;
  border: 0;
  background: none;
  font-family: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}

/* ---------------------------------------------------------------- */
/* finish freeze + results */
/* ---------------------------------------------------------------- */

.freeze {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 14px var(--ink), inset 0 0 0 20px var(--bone), inset 0 0 0 26px var(--ink);
  background: rgba(243,230,200,0.02);
}
.freeze.finish { background: rgba(27,20,32,0.18); }
.freeze-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rank-badge {
  display: flex;
  align-items: baseline;
  gap: 14px;
  color: var(--violet);
  transform: rotate(-7deg);
  filter: drop-shadow(6px 6px 0 rgba(27,20,32,0.35));
  animation: rankStamp 0.5s cubic-bezier(.16,.9,.2,1) both;
}
.rank-badge #rankStamp {
  font-family: var(--num);
  font-size: clamp(150px, 30vw, 360px);
  line-height: 0.75;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 10px 12px 0 var(--magenta);
}
.rank-badge small {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.24em;
  font-size: clamp(12px, 1.6vw, 20px);
  color: var(--bone);
  text-shadow: 2px 2px 0 var(--ink);
}
.freeze-caption {
  font-family: var(--display);
  font-size: clamp(18px, 3vw, 34px);
  color: var(--bone);
  text-shadow: 4px 4px 0 var(--violet), 2px 2px 0 var(--ink);
  letter-spacing: 0.02em;
  transform: rotate(-2deg);
  margin: 0;
}

.results {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
  background: rgba(27,20,32,0.45);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.35s ease;
}
.results-paper {
  width: min(1050px, 96vw);
  height: min(94vh, 880px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bone);
  border: 6px solid var(--ink);
  padding: clamp(16px, 2.6vw, 32px);
  clip-path: polygon(0 1.6%, 1% 0, 99% 0, 100% 1.8%, 99.4% 8%, 100% 14%, 99.3% 21%, 100% 28%, 99.4% 36%, 100% 44%, 99.3% 52%, 100% 61%, 99.4% 70%, 100% 78%, 99.3% 86%, 100% 94%, 99% 100%, 1% 100%, 0 98.4%);
  box-shadow: 14px 14px 0 rgba(0,0,0,0.3);
  scrollbar-width: thin;
  scrollbar-color: var(--violet) transparent;
  animation: resultsIn 0.5s cubic-bezier(.2,.9,.25,1.02);
}
.results-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  border-bottom: 4px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 16px;
}
.results-title { text-align: center; }
.results-title h2 {
  font-family: var(--display);
  font-size: clamp(30px, 4.4vw, 58px);
  margin: 0;
  line-height: 0.95;
  color: var(--ink);
  text-shadow: 4px 4px 0 var(--magenta);
  transform: rotate(-1deg);
}
.results-title .kicker { color: var(--violet); margin-bottom: 2px; }
.results-title .qual {
  font-family: var(--text);
  font-weight: 700;
  letter-spacing: 0.2em;
  font-size: clamp(8px, 1vw, 11px);
  color: var(--violet);
  margin: 6px 0 0;
}
.results-cash { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.results-cash img { width: clamp(26px, 3vw, 36px); height: auto; }
.results-cash span { font-family: var(--num); font-size: clamp(20px, 2.6vw, 32px); color: var(--violet); line-height: 1; }
.results-cash small, .results-place small { font-family: var(--text); font-weight: 700; letter-spacing: 0.2em; font-size: 8px; color: rgba(42,30,48,0.7); }
.results-place { text-align: right; justify-self: end; }
.results-place > span {
  font-family: var(--num);
  font-size: clamp(46px, 6vw, 82px);
  line-height: 0.8;
  color: var(--violet);
  display: block;
  text-shadow: 3px 3px 0 var(--magenta);
}
.results-place small { display: block; }

.results-cols { display: grid; grid-template-columns: 1.6fr 0.9fr; gap: clamp(14px, 2.4vw, 30px); flex: 1; min-height: 0; }
.results-table { overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--violet) transparent; }
.results-side { display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 720px) { .results-cols { grid-template-columns: 1fr; } }

.results-table { border-top: 2px solid var(--ink); }
.result-row {
  display: grid;
  grid-template-columns: 34px 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  border-bottom: 1px solid rgba(27,20,32,0.2);
  font-family: var(--text);
  font-weight: 500;
  font-size: clamp(10px, 1.05vw, 13px);
  letter-spacing: 0.06em;
}
.result-row.me { background: var(--saffron); border: 2px solid var(--ink); }
.result-row .rp { font-family: var(--num); font-size: clamp(12px, 1.2vw, 16px); color: var(--ink); text-align: right; }
.result-row .pic { width: 28px; height: 28px; border: 2px solid var(--ink); border-radius: 50%; overflow: hidden; }
.result-row .pic img { width: 100%; height: 100%; object-fit: cover; }
.result-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
.result-row .nm small { display: block; font-size: 7px; letter-spacing: 0.16em; color: rgba(42,30,48,0.55); }
.result-row .rt { font-family: var(--num); font-size: clamp(9px, 1vw, 12px); color: var(--violet); }

.results-side h3 { font-family: var(--text); font-weight: 700; font-size: 11px; letter-spacing: 0.24em; color: var(--violet); margin: 0 0 8px; }
.best-times { border-top: 2px solid var(--ink); padding-top: 6px; min-height: 70px; }
.best-row { display: flex; justify-content: space-between; gap: 8px; font-family: var(--text); font-weight: 500; font-size: 11px; letter-spacing: 0.06em; padding: 3px 0; border-bottom: 1px solid rgba(27,20,32,0.14); text-transform: uppercase; }
.best-row b { font-family: var(--num); font-weight: 400; color: var(--violet); font-size: 10px; }
.best-times .dim { font-size: 10px; letter-spacing: 0.16em; color: rgba(42,30,48,0.55); }
.results-stats { margin-top: 18px; border-top: 3px solid var(--ink); padding-top: 10px; }
.results-stats > div { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; font-family: var(--text); font-weight: 700; font-size: 10px; letter-spacing: 0.18em; }
.results-stats b { font-family: var(--num); font-weight: 400; font-size: 13px; color: var(--ink); }

.results-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; flex: none; }
.results-actions .stamp-btn { flex: 1; min-width: 150px; }
.results-note {
  flex: none;
  font-family: var(--text);
  font-weight: 700;
  font-size: 8px;
  letter-spacing: 0.2em;
  color: rgba(42,30,48,0.55);
  margin: 14px 0 0;
  text-align: center;
}

/* ---------------------------------------------------------------- */
/* toast */
/* ---------------------------------------------------------------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(26px + var(--safe-b));
  transform: translate(-50%, 30px);
  z-index: 60;
  background: var(--bone);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 rgba(27,20,32,0.4);
  padding: 10px 18px;
  font-family: var(--text);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--violet);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(.2,.9,.25,1.1);
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- */
/* animations */
/* ---------------------------------------------------------------- */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes resultsIn { from { opacity: 0; transform: translateY(26px) rotate(0.6deg); } to { opacity: 1; transform: rotate(-0.35deg); } }
@keyframes countSlam {
  0% { opacity: 0; transform: translateY(-4vh) scale(2.1) rotate(-9deg); }
  28% { opacity: 1; transform: translateY(-4vh) scale(1) rotate(-4deg); }
  78% { opacity: 1; transform: translateY(-4vh) scale(1) rotate(-4deg); }
  100% { opacity: 0; transform: translateY(-4vh) scale(0.94) rotate(-3deg); }
}
@keyframes goBurst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.5) rotate(-6deg); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.02) rotate(-2deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1.06) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.14) rotate(-1deg); }
}
@keyframes markSlam {
  0% { opacity: 0; transform: translate(30px, -60px) scale(2) rotate(10deg); }
  18% { opacity: 1; transform: translate(0, 0) scale(1) rotate(-3deg); }
  66% { opacity: 1; transform: translate(0, 0) scale(1.02) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-10px, -10px) scale(0.92) rotate(-5deg); }
}
@keyframes markGo {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(1.8); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  74% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
  100% { opacity: 0; transform: translate(-50%, -54%) scale(0.9); }
}
@keyframes speedSpin { from { transform: rotate(0deg); } to { transform: rotate(2.5deg); } }
@keyframes rankStamp {
  0% { opacity: 0; transform: rotate(-16deg) scale(2.6); }
  60% { opacity: 1; transform: rotate(-7deg) scale(0.96); }
  100% { opacity: 1; transform: rotate(-7deg) scale(1); }
}
@keyframes frayFlash {
  0% { background: var(--magenta); }
  100% { background: var(--saffron); }
}
@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--saffron); }
  50% { box-shadow: 0 0 0 2px var(--ink), 0 0 0 7px var(--magenta); }
}

/* ---------------------------------------------------------------- */
/* responsive */
/* ---------------------------------------------------------------- */

@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .control-line { bottom: calc(2px + var(--safe-b)); font-size: 7px; letter-spacing: 0.12em; }
}

@media (max-width: 900px) {
  .menu-foot .dim { display: none; }
  .menu-credit { display: none; }
  .standings { width: clamp(140px, 30vw, 200px); }
}

@media (max-width: 760px) {
  .title-art {
    left: calc(3vw + var(--safe-l));
    top: calc(1.4vh + var(--safe-t));
    width: min(88vw, 620px);
  }
  .ticket-stack {
    left: calc(4.4vw + var(--safe-l));
    top: 29.5vh;
    width: min(61vw, 290px);
    gap: clamp(3px, 0.9vh, 10px);
  }
  .ticket .go-mark { right: -0.4em; }
  .menu-corner { top: auto; bottom: calc(3vh + var(--safe-b)); right: calc(3vw + var(--safe-r)); flex-direction: column-reverse; align-items: flex-end; gap: 7px; }
  .cash-chip { height: 34px; padding-right: 10px; }
  .cash-chip img { width: 22px; height: 22px; }
  .cash-chip span { font-size: 11px; }
  .sound-btn { width: 38px; height: 38px; }
  .menu-foot { left: calc(4.4vw + var(--safe-l)); bottom: calc(2.2vh + var(--safe-b)); font-size: 7.5px; letter-spacing: 0.18em; }
  .menu-foot .press { display: none; }

  .pos-frame { width: clamp(140px, 36vw, 210px); left: calc(1.6vw + var(--safe-l)); top: calc(1vh + var(--safe-t)); }
  .pos-num span { font-size: clamp(30px, 8vw, 44px); }
  .pos-clock { font-size: clamp(9px, 2.4vw, 12px); }
  .pos-kicker { font-size: 6px; letter-spacing: 0.16em; }
  .progress-strip { width: calc(100vw - clamp(150px, 38vw, 220px) - 8vw - var(--safe-l) - var(--safe-r)); right: calc(1.6vw + var(--safe-r)); top: calc(1vh + var(--safe-t)); }
  .strip-track { height: 36px; }
  .strip-label { font-size: 5.5px; letter-spacing: 0.08em; }
  .strip-chips .chip { width: 16px; height: 16px; border-width: 1.5px; }
  .strip-flags .flag { width: 12px; top: -7px; }
  .strip-finish { top: -8%; height: 116%; }

  .standings { top: calc(1vh + var(--safe-t) + 62px); right: calc(1.4vw + var(--safe-r)); width: 32px; gap: 4px; }
  .stand-row { height: 30px; padding: 0; justify-content: center; background: rgba(243,230,200,0.9); clip-path: polygon(0 0, 100% 0, 100% 100%, 12% 100%, 0 84%); }
  .stand-row .who, .stand-row .gap, .stand-row .tab { display: none; }
  .stand-row .place { display: block; position: absolute; left: -3px; top: -3px; width: 14px; height: 14px; line-height: 14px; text-align: center; background: var(--bone); border: 1.5px solid var(--ink); font-size: 8px; z-index: 3; }
  .stand-row .pic { width: 24px; height: 24px; border-width: 2px; }
  .stand-row.me { animation: pulseGold 1.4s ease-in-out infinite; }

  .gauge { width: clamp(116px, 30vw, 160px); bottom: calc(92px + var(--safe-b)); }
  .gauge-speed span { font-size: clamp(16px, 4.2vw, 22px); }
  .stamina { height: 11px; }

  .race-actions { top: calc(1vh + var(--safe-t)); }
  .round-btn { width: 28px; height: 28px; font-size: 11px; }

  .countdown .count-num { font-size: clamp(86px, 30vw, 200px); -webkit-text-stroke-width: 4px; }
  .countdown .count-sub { font-size: 8px; letter-spacing: 0.18em; }
  .marks img.spur { right: 2%; bottom: 33%; width: 48vw; }
  .marks img.overtake { width: 54vw; }

  .help-card { left: 50%; transform: translateX(-50%); bottom: calc(170px + var(--safe-b)); width: min(330px, 88vw); }
  .help-card ul { font-size: 11.5px; }

  .results-paper { max-height: 96vh; padding: 14px; }
  .results-top { grid-template-columns: auto 1fr auto; gap: 8px; }
  .results-cash span { font-size: 14px; }
  .results-cash small { font-size: 6px; }
  .results-title h2 { font-size: clamp(22px, 7vw, 34px); }
  .results-title .kicker { font-size: 6.5px; letter-spacing: 0.16em; }
  .results-title .qual { font-size: 6.5px; letter-spacing: 0.12em; }
  .results-place > span { font-size: 42px; }
  .results-place small { font-size: 6px; }
  .result-row { grid-template-columns: 24px 26px 1fr auto; gap: 6px; font-size: 10px; padding: 3px; }
  .result-row .pic { width: 22px; height: 22px; }
  .result-row .nm small { display: none; }
  .results-actions .stamp-btn { min-width: 120px; font-size: 11px; padding: 10px 8px; }
  .results-note { font-size: 6.5px; }
}

@media (max-height: 520px) {
  .title-art { width: min(34vw, 420px); }
  .ticket-stack { top: 44vh; width: min(20vw, 240px); }
  .menu-foot { display: none; }
  .standings { display: none; }
  .gauge { width: 120px; bottom: calc(8px + var(--safe-b)); }
  .control-line { display: none; }
  .progress-strip { width: min(34vw, 340px); }
  .pos-frame { width: min(21vw, 230px); }
}

@media (max-width: 760px) and (orientation: portrait) {
  .title-art { width: min(86vw, 560px); }
  .ticket-stack { top: 30vh; width: min(62vw, 300px); }
}

@media (prefers-reduced-motion: reduce) {
  .speedlines.on { animation: none; }
  .stand-row.me { animation: none; }
  .countdown .count-num { animation-duration: 0.9s; }
}
