/* Menu surfaces use the logical game stage, including orientation-locked phones. */
#stage {
  --stage-vw: 1vw;
  --stage-vh: 1vh;
}
:root {
  --menu-surface: #2b223b;
  --menu-border: rgba(255, 246, 229, 0.16);
}
.flow-head {
  min-height: 76px;
  gap: 16px;
  padding: 12px max(20px, var(--safe-right)) 8px max(20px, var(--safe-left));
}
.flow-head-text {
  text-align: left;
}
.flow-head-right {
  width: 148px;
}
.flow-h {
  font-size: 26px;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 8px #15101c;
}
.flow-eyebrow {
  font-size: 11px;
  letter-spacing: 0.13em;
  margin-bottom: 3px;
}
.flow-body {
  padding: 16px max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
}
.flow-back,
#chrome-gear {
  min-width: 44px;
  min-height: 44px;
}
.btn-gold,
.btn-cream,
.setup-choice,
.tap-card {
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}
button.small-pill {
  min-height: 44px;
  min-width: 44px;
}
.sticker-deep,
.settings-card,
.menu-card {
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
  box-shadow:
    0 5px 0 rgba(15, 8, 30, 0.7),
    0 16px 40px #100d1929;
}
.title-wrap {
  left: max(6%, var(--safe-left));
  top: 50%;
  transform: translateY(-50%);
  width: min(440px, 48%);
  align-items: stretch;
  gap: 12px;
}
.title-logo {
  font-size: clamp(25px, calc(var(--stage-vh) * 5), 43px);
  letter-spacing: 0;
}
.title-tag {
  text-align: left;
  font-size: 12px;
}
.title-play {
  min-height: 62px;
  font-size: 26px;
  letter-spacing: 0;
  margin-top: 8px;
}
.title-garage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  min-height: 58px;
  font-size: 18px;
  letter-spacing: 0;
}
.title-garage span {
  font-size: 12px;
  font-weight: 500;
}
.title-extras {
  gap: 10px;
}
.title-extras .extra-btn {
  min-height: 44px;
  font-size: 13px;
  letter-spacing: 0;
}
.title-extras .extra-btn:last-child:nth-child(odd) {
  grid-column: auto;
}
.build-stamp {
  text-align: left;
  margin-top: 4px;
}
.mode-grid {
  max-width: 850px;
  gap: 16px;
}
.mode-tap {
  min-height: 110px;
  padding: 22px;
}
/* Mode cards share the collectible racer cards' illustrated, filled surfaces. */
#stage #flow-mode .mode-grid { align-content: start; }
#stage #flow-mode .mode-tap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  grid-template-rows: auto 1fr;
  align-items: center;
  gap: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff3dc;
  color: #30263d;
  border-radius: var(--control-radius);
  box-shadow: none;
}
#stage #flow-mode .mode-tap:hover { background: #fff8ea; }
#stage #flow-mode .mode-art {
  grid-column: 1 / -1;
  position: relative;
  display: block;
  height: clamp(110px, 20vh, 180px);
  overflow: hidden;
  background: var(--mode-art-color, #a4bdd9);
}
#stage #mode-cup { --mode-art-color: #e5bd70; }
#stage #mode-tt { --mode-art-color: #9acdc9; }
#stage #mode-daily { --mode-art-color: #bfabda; }
#stage #mode-split { --mode-art-color: #dda6b5; }
#stage #flow-mode .mode-art::before {
  content: "";
  position: absolute;
  inset: 55% -20% -60%;
  background: #30263d1a;
  transform: rotate(-12deg);
}
#stage #flow-mode .tap-chip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: #30263d;
  font-size: 56px;
}
#stage #flow-mode .tap-text { padding: 14px; gap: 6px; }
#stage #flow-mode .tap-title { font-size: 18px; }
#stage #flow-mode .tap-sub { color: #6c6078; font-size: 13px; font-weight: 400; }
#stage #flow-mode .tap-chev { color: #6c6078; padding-right: 12px; }
#stage #flow-mode .mode-daily { grid-column: auto; }
#stage:not(.menu-portrait) #flow-mode .mode-grid:has(#mode-split:not(.hidden)) .mode-daily {
  grid-column: 1 / -1;
}
#stage.menu-portrait #flow-mode .mode-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
#stage.menu-portrait #flow-mode .mode-tap { grid-template-columns: 100px minmax(0, 1fr) 20px; grid-template-rows: 1fr; min-height: 124px; }
#stage.menu-portrait #flow-mode .mode-art { grid-column: auto; height: 100%; min-height: 124px; }
#stage.menu-portrait #flow-mode .tap-text { padding: 12px 8px 14px 12px; }
#stage.menu-portrait #flow-mode .tap-title { font-size: 17px; }
#stage.menu-portrait #flow-mode .tap-sub { font-size: 12px; }
#stage.menu-compact:not(.menu-portrait) #flow-mode .mode-tap {
  grid-template-columns: minmax(100px, .8fr) minmax(0, 1.2fr) 20px;
  grid-template-rows: 1fr;
  min-height: 112px;
}
#stage.menu-compact:not(.menu-portrait) #flow-mode .mode-art { grid-column: auto; height: 100%; min-height: 112px; }
#stage.menu-compact:not(.menu-portrait) #flow-mode .tap-text { padding: 12px; }
#stage.menu-compact:not(.menu-portrait) #flow-mode .tap-title { font-size: 16px; }
#stage.menu-compact:not(.menu-portrait) #flow-mode .tap-sub { font-size: 12px; }
.tap-title {
  font-size: 20px;
  letter-spacing: -0.3px;
}
.tap-sub {
  font-size: 13px;
  line-height: 1.45;
}
.tap-chip {
  width: 48px;
  height: 48px;
}
.picker-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px max(24px, var(--safe-right)) 8px max(24px, var(--safe-left));
}
.picker-toolbar .seg-btn {
  min-height: 44px;
  min-width: 86px;
}
/* Cats and karts share square artwork, so their cards share one size. */
.racer-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  max-width: 1100px;
  min-height: 0;
  align-content: start;
  gap: 16px;
}
.racer-tap {
  height: 235px;
  padding: 12px;
  gap: 8px;
}
.racer-shot {
  width: 100%;
  max-width: 220px;
}
.racer-tap .track-name {
  font-size: 16px;
}
.racer-tap .track-sub {
  font-size: 12px;
  min-height: 2.5em;
}
.racer-body {
  gap: 24px;
}

#garage-done {
  min-height: 52px;
}
.startline-body {
  padding-top: 4px;
}
.start-side {
  width: min(440px, calc(var(--stage-vw) * 47));
  gap: 12px;
}
.start-scroll {
  gap: 12px;
  padding: 3px 3px 7px;
}
.setup-pickers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.setup-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--menu-border);
  border-radius: 16px;
  padding: 14px;
  margin: 0;
  color: #fff6e5;
  background: var(--menu-surface);
  text-align: left;
  letter-spacing: 0;
  box-shadow: 0 4px 0 #170e29;
}
.setup-choice .setup-icon {
  color: #ffc24b;
  font-size: 25px;
  width: 32px;
  text-align: center;
}
.setup-choice > span:not(.setup-icon) {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}
.setup-choice small {
  font-size: 10px;
  color: var(--menu-muted);
  letter-spacing: 0.12em;
}
.setup-choice strong {
  font-size: 17px;
}
.setup-choice b {
  font-size: 11px;
  color: #ffc24b;
  white-space: nowrap;
}
.start-racer {
  padding: 12px;
  gap: 10px;
}
.setup-racer-actions {
  display: flex;
  gap: 6px;
}
.start-racer-text {
  min-width: 0;
}
#racer-summary {
  white-space: normal;
  font-size: 14px;
}
.seat-thumb {
  width: 34px;
  height: 34px;
}
.mode-opt-label {
  min-width: 48px;
  color: var(--menu-muted);
}
.seg-btn {
  min-width: 44px;
  min-height: 44px;
}
.start-opts {
  padding: 12px;
}
.go-btn {
  min-height: 58px;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.map-chip {
  left: max(24px, var(--safe-left));
  bottom: max(24px, var(--safe-bottom));
  width: 210px;
}
.racer-card {
  width: min(470px, calc(var(--stage-vw) * 51));
}
.racer-card .creator-label {
  font-size: 12px;
}
.racer-card .racer-actions {
  position: sticky;
  bottom: 0;
  background: var(--menu-surface);
  padding-top: 12px;
}
#pause-overlay,
#results {
  background: rgba(14, 12, 24, 0.6);
}
.menu-card h1 {
  font-size: 30px;
  color: #fff6e5;
  text-shadow: none;
  letter-spacing: -0.6px;
}
#stage.menu-compact .flow-eyebrow {
  font-size: 10px;
}
#stage.menu-compact .flow-body {
  padding: 8px max(16px, var(--safe-right)) max(12px, var(--safe-bottom)) max(16px, var(--safe-left));
}
#stage.menu-compact .title-tag {
  font-size: 10px;
  margin-bottom: 0;
}
#stage.menu-compact .title-play {
  min-height: 48px;
  margin-top: 2px;
  font-size: 21px;
}
#stage.menu-compact .title-garage {
  font-size: 16px;
}
#stage.menu-compact .mode-grid {
  gap: 12px;
}
#stage.menu-compact .mode-tap {
  min-height: 90px;
  padding: 12px 16px;
}
#stage.menu-compact .tap-title {
  font-size: 17px;
}
#stage.menu-compact .tap-sub {
  font-size: 12px;
}
#stage.menu-compact .picker-toolbar {
  padding: 0 16px 6px;
}
#stage.menu-compact .racer-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
#stage.menu-compact .racer-tap {
  height: 208px;
  padding: 10px;
}
#stage.menu-compact #kart-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
#stage.menu-compact .start-side {
  width: min(430px, calc(var(--stage-vw) * 52));
  gap: 8px;
}
#stage.menu-compact .start-scroll {
  gap: 8px;
}
#stage.menu-compact .setup-pickers {
  gap: 8px;
}
#stage.menu-compact .setup-choice {
  padding: 10px 12px;
}
#stage.menu-compact .setup-choice b {
  font-size: 10px;
}
#stage.menu-compact .setup-choice .setup-icon {
  display: none;
}
#stage.menu-compact .start-racer {
  padding: 8px;
}
#stage.menu-compact .seat-thumbs {
  display: none;
}
#stage.menu-compact .go-btn {
  min-height: 50px;
  font-size: 18px;
}
#stage.menu-compact .map-chip {
  width: 165px;
  left: 16px;
  bottom: 16px;
}

#stage.menu-compact #garage-done {
  min-height: 46px;
}

@media (prefers-reduced-motion: reduce) {
  .btn-gold,
  .btn-cream,
  .setup-choice,
  .tap-card {
    transition: none;
  }
}
/* Consistent compact menus; the next action never scrolls away. */
.map-chip .map-edit-hint {
  display: none;
}
.map-chip .map-label {
  max-width: calc(100% - 16px);
}
.menu-card.pause-card {
  width: min(380px, 100%);
  padding: 26px;
}
.pause-card > button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  font-size: 16px;
  letter-spacing: 0;
}
.pause-card .pause-row {
  margin-top: 12px;
}
.pause-context {
  color: var(--menu-muted);
  font-size: 13px;
  margin: 10px 0;
}
.pause-home-note {
  font-size: 12px;
  margin-top: 8px;
  color: var(--menu-muted);
}
.pause-row button.small {
  min-height: 44px;
  font-size: 13px;
  letter-spacing: 0;
}
#results {
  overflow: hidden;
  align-items: center;
}
.menu-card.results-main {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-width: 640px;
  max-height: 100%;
  padding: 24px;
  min-height: 0;
}
.results-main h1 {
  margin: 6px 0 12px;
  font-size: 28px;
  flex: 0 0 auto;
}
.results-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 0 4px;
  text-align: left;
}
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  flex: 0 0 auto;
}
.results-actions button {
  margin: 0;
  min-height: 46px;
  font-size: 15px;
  letter-spacing: 0;
}
.results-secondary {
  display: flex;
  gap: 10px;
}
.results-secondary button {
  flex: 1;
}
#menu-confirm {
  z-index: 61;
  background: rgba(13, 10, 23, 0.8);
}
.confirm-card {
  width: min(440px, 100%);
  padding: 28px;
}
.confirm-card h1 {
  font-size: 25px;
}
.confirm-card p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--menu-muted);
  margin: 16px 0;
}
.confirm-card button {
  width: 100%;
  min-height: 48px;
  margin: 12px 0 0;
  font-size: 16px;
  letter-spacing: 0;
}
#stage.menu-compact .setup-pickers {
  flex-direction: row;
}
#stage.menu-compact .setup-choice {
  min-width: 0;
  flex: 1;
}
#stage.menu-compact .setup-choice b {
  display: none;
}
#stage.menu-compact .setup-choice strong {
  font-size: 14px;
}
#stage.menu-compact .setup-choice small::after {
  content: "  ›";
  color: #ffc24b;
}
#stage.menu-compact .start-opts {
  padding: 8px;
}
#stage.menu-compact .mode-opt-row {
  gap: 6px;
}
#stage.menu-compact .mode-opt-label {
  flex-basis: 48px;
  font-size: 10px;
}

#stage.menu-compact .menu-card.pause-card {
  width: min(540px, 100%);
  padding: 16px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
#stage.menu-compact .pause-card > .flow-eyebrow,
#stage.menu-compact .pause-card > h1,
#stage.menu-compact .pause-context {
  grid-column: 1 / -1;
  margin: 0;
}
#stage.menu-compact .pause-card > h1 {
  font-size: 24px;
}
#stage.menu-compact .pause-card > button,
#stage.menu-compact #resume-btn {
  margin: 0;
  min-height: 46px;
  font-size: 15px;
  padding: 10px;
}
#stage.menu-compact .pause-card .pause-row {
  display: contents;
}
#stage.menu-compact .pause-home-note {
  display: none;
}
#stage.menu-compact .menu-card.results-main {
  padding: 14px 18px;
}
#stage.menu-compact .results-main h1 {
  font-size: 22px;
  margin: 2px 0 8px;
}
#stage.menu-compact .results-main > .flow-eyebrow {
  display: none;
}
#stage.menu-compact .results-actions {
  padding-top: 10px;
  gap: 8px;
}
#stage.menu-compact .results-secondary {
  gap: 8px;
}
#stage.menu-compact .confirm-card {
  padding: 16px 24px;
}
#stage.menu-compact .confirm-card p {
  margin: 10px 0;
}

.settings-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  width: min(680px, calc(100% - 32px));
  margin: 8px auto 0;
  padding: 5px;
  border-radius: 18px;
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
}
.settings-nav button {
  flex: 1;
  min-height: 46px;
  font-size: 14px;
  margin: 0;
}
.settings-main {
  max-width: 680px;
}
/* Keep the tabs floating inside the scroll area so cards pass behind them. */
#stage :is(#settings, #catalog, #flow-cat, #flow-kart) > .flow-body {
  padding-top: 12px;
  scroll-padding-top: 84px;
}
#stage :is(#settings, #catalog) .settings-nav,
#stage #menu .picker-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 100%;
  margin: 0 auto 12px;
}
#stage :is(#settings, #catalog) .settings-nav {
  max-width: 680px;
}
#stage #menu .picker-toolbar {
  padding: 0;
  background: transparent;
}
.settings-list {
  gap: 16px;
}
.settings-card .setting-note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--menu-muted);
  margin: 8px 0 16px;
}
.settings-section {
  font-size: 13px;
  letter-spacing: 0.08em;
}
.settings-card .setting-row {
  min-height: 54px;
}
#settings .flow-head-right,
.sheet .flow-head-right {
  width: 46px;
}
.settings-card .setting-label {
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}
#stage.menu-compact .settings-nav {
  margin-top: 0;
}
#stage.menu-compact .settings-nav button {
  font-size: 13px;
}

/* Menus stay upright in portrait. Racing still uses the landscape stage. */
#stage.menu-portrait .flow-head {
  min-height: 80px;
  gap: 10px;
  padding: max(12px, var(--safe-top)) 16px 8px;
}
#stage.menu-portrait .flow-h {
  font-size: 22px;
}
#stage.menu-portrait .flow-eyebrow {
  font-size: 9px;
  letter-spacing: 0.08em;
}
#stage.menu-portrait .flow-body {
  padding: 12px 16px max(20px, var(--safe-bottom));
}
#stage.menu-portrait #menu-chrome {
  gap: 6px;
}
#stage.menu-portrait #chrome-treats {
  padding: 8px 10px;
}
#stage.menu-portrait .title-logo {
  font-size: clamp(25px, calc(var(--stage-vw) * 8), 36px);
}
#stage.menu-portrait .title-garage span {
  font-size: 11px;
}
#stage.menu-portrait .title-play {
  font-size: 24px;
  min-height: 58px;
}
#stage.menu-portrait .mode-grid,
#stage.menu-portrait .cup-grid {
  grid-template-columns: 1fr;
  align-content: start;
}
#stage.menu-portrait .mode-tap {
  padding: 18px;
  min-height: 100px;
}
#stage.menu-portrait .mode-daily {
  grid-column: auto;
}
#stage.menu-portrait .track-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#stage.menu-portrait .racer-grid,
#stage.menu-portrait #kart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
#stage.menu-portrait .racer-tap {
  height: 220px;
  padding: 9px;
}
#stage.menu-portrait #kart-grid .racer-tap {
  height: 190px;
}
#stage.menu-portrait .picker-toolbar {
  padding: 4px 16px 8px;
  gap: 8px;
}
#stage.menu-portrait .picker-toolbar .seg-btn {
  min-width: 64px;
}
#stage.menu-portrait .picker-toolbar > button {
  font-size: 11px;
  padding: 8px 12px;
}
#stage.menu-portrait .startline-body {
  align-items: stretch;
  justify-content: flex-end;
  flex-direction: column;
}
#stage.menu-portrait .start-side {
  width: 100%;
  max-height: calc(100% - 140px);
  gap: 12px;
}
#stage.menu-portrait .start-scroll {
  gap: 10px;
}
#stage.menu-portrait .setup-pickers {
  flex-direction: row;
  gap: 10px;
}
#stage.menu-portrait .setup-choice {
  padding: 12px;
  min-width: 0;
  flex: 1;
}
#stage.menu-portrait .setup-choice .setup-icon,
#stage.menu-portrait .setup-choice b {
  display: none;
}
#stage.menu-portrait .setup-choice small::after {
  content: "  ›";
  color: #ffc24b;
}
#stage.menu-portrait .setup-choice strong {
  font-size: 14px;
}
#stage.menu-portrait .start-racer {
  padding: 10px;
}
#stage.menu-portrait .seat-thumbs {
  display: none;
}
#stage.menu-portrait .mode-opt-row {
  gap: 6px;
}
#stage.menu-portrait .mode-opt-label {
  flex-basis: 44px;
  font-size: 10px;
}
#stage.menu-portrait .seg-btn {
  min-width: 44px;
}
#stage.menu-portrait .map-chip {
  display: none;
}
#stage.menu-portrait .racer-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0;
}
#stage.menu-portrait .racer-card {
  width: 100%;
  max-height: calc(var(--stage-vh) * 62);
  overflow-y: auto;
  flex: 0 1 auto;
  padding: 16px;
}

#stage.menu-portrait .settings-nav {
  gap: 3px;
  border-radius: 16px;
  padding: 4px;
}
#stage.menu-portrait .settings-nav button {
  font-size: 12px;
  padding: 8px;
  min-width: 0;
}
#stage.menu-portrait .setting-row {
  flex-wrap: wrap;
  gap: 8px;
}
#stage.menu-portrait .setting-row .setting-label {
  flex-basis: auto;
}
#stage.menu-portrait #quality-toggle {
  flex-wrap: wrap;
}
#stage.menu-portrait .setting-row .seg-toggle {
  max-width: 100%;
}
#stage.menu-portrait .settings-card {
  padding: 16px;
}
#stage.menu-portrait .sheet-inner {
  padding: 0;
}
#stage.menu-portrait .track-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#stage.menu-portrait .track-col-map,
#stage.menu-portrait .track-col-ctrl {
  width: 100%;
  flex: 0 0 auto;
}
#stage.menu-portrait .how-grid {
  grid-template-columns: 1fr;
}
#stage.menu-portrait .prize-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#stage.menu-portrait .menu-card.results-main {
  padding: 18px;
}
#stage.menu-portrait .results-main h1 {
  font-size: 23px;
}
#stage.menu-portrait #results-list li {
  padding: 8px;
  gap: 6px;
}

#menu-keyboard {
  z-index: 62;
  background: rgba(13, 10, 23, 0.9);
}
.keyboard-card {
  width: min(660px, 100%);
  max-width: 660px;
  max-height: 100%;
  overflow-y: auto;
}
.keyboard-card h1 {
  font-size: 20px;
}
#keyboard-draft {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 14px 0;
  padding: 12px;
  color: #fff6e5;
  background: #151120;
  border: 1px solid var(--menu-border);
  border-radius: 12px;
  user-select: text;
  font-size: 18px;
}
.keyboard-keys {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}
.keyboard-keys button {
  padding: 8px 0;
  margin: 0;
  min-height: 44px;
  font-size: 15px;
}
.keyboard-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.keyboard-actions button {
  flex: 1;
  min-height: 44px;
  margin: 0;
  padding: 8px;
  font-size: 13px;
}
#stage.menu-narrow .keyboard-keys {
  grid-template-columns: repeat(6, 1fr);
}

.racer-card .swatch-dot {
  width: 44px;
  height: 44px;
}
.racer-card .creator-input,
.name-pick-btn,
.name-grid button {
  min-height: 44px;
}
.biome-chip,
.adv-toggle {
  min-height: 44px;
}
#track-panel > .track-actions {
  flex: 0 0 auto;
  width: min(640px, calc(100% - 32px));
  margin: 0 auto;
  padding: 10px 0 max(16px, var(--safe-bottom));
}
#track-panel > .track-actions button {
  min-height: 48px;
  width: 100%;
  margin: 0;
}
.prize-tile.is-current {
  border-color: #ffc24b;
  box-shadow:
    0 0 0 2px #ffc24b,
    0 4px 0 #281735;
}

/* Shared visual system: one type scale, restrained surfaces, one header row. */
#stage {
  --menu-font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --menu-ink: #f8f3e9;
  --menu-muted: #c3b8cf;
}
#menu,
.overlay,
#menu-chrome {
  font-family: var(--menu-font);
}
#menu button,
.overlay button,
.overlay input,
.overlay textarea,
#menu-chrome button {
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0;
}
#menu {
  background: linear-gradient(180deg, rgba(18, 14, 28, 0.78), rgba(18, 14, 28, 0.42) 42%, rgba(18, 14, 28, 0.72));
}
#stage .flow-head {
  flex: 0 0 auto;
  min-height: 76px;
  padding: calc(var(--safe-top) + 12px) max(20px, var(--safe-right)) 14px max(20px, var(--safe-left));
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#stage .flow-head-right {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}
#stage .flow-head-text {
  min-width: 0;
  text-align: left;
}
#stage .flow-h {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
  text-shadow: none;
}
#stage .flow-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
  color: var(--menu-muted);
  text-shadow: none;
}
#stage #menu-chrome {
  position: static;
  inset: auto;
  padding: 0;
  gap: 8px;
  z-index: auto;
  width: auto;
}
#stage #menu-chrome button,
#stage .flow-back {
  min-width: 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: var(--menu-surface);
  color: #fff6e5;
  box-shadow: none;
  font-size: 20px;
}
#stage #menu-chrome #chrome-treats {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
#stage .picker-toolbar {
  padding: 12px max(20px, var(--safe-right)) 12px max(20px, var(--safe-left));
  gap: 12px;
  align-items: center;
}
#stage .picker-toolbar .seg-toggle {
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: var(--menu-surface);
}
#stage .picker-toolbar .seg-btn {
  min-width: 64px;
  min-height: 44px;
  font-size: 14px;
  border-radius: 11px;
  box-shadow: none;
}
#stage .picker-toolbar .btn-cream {
  min-height: 44px;
  border-radius: 12px;
  font-size: 14px;
  padding: 10px 14px;
  margin: 0;
  box-shadow: none;
  border: 1px solid #84728f;
  background: var(--menu-surface);
  color: #fff6e5;
}
#stage .btn-cream,
#stage .btn-gold {
  border-radius: 16px;
  box-shadow: 0 3px 0 #160f23;
  border-width: 1px;
}
#stage .racer-grid {
  gap: 16px;
}
#stage .racer-tap {
  border-radius: 18px;
  color: #30263d;
  padding: 10px;
  height: auto;
  min-height: 210px;
  gap: 8px;
}
#stage .racer-tap .racer-shot {
  border: 0;
  border-radius: 12px;
  box-shadow: none;
}
#stage .racer-tap .track-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
#stage .racer-tap .track-sub {
  font-size: 12px;
  line-height: 1.4;
  font-weight: 400;
  min-height: 2em;
  color: #6c6078;
}
#stage .racer-tap.is-current {
  border-color: #ffbf47;
}
#stage .tap-title {
  font-size: 18px;
  font-weight: 700;
}
#stage .tap-sub,
#stage .setting-label,
#stage .setup-choice strong,
#stage #racer-summary {
  font-size: 14px;
  line-height: 1.45;
}
#stage .settings-card,
#stage .racer-card,
#stage .sticker-deep,
#stage .setup-choice,
#stage .menu-card {
  border-radius: 18px;
  box-shadow: 0 6px 20px #100a1833;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
#stage .menu-card h1 {
  font-size: 26px;
  font-weight: 700;
}
#stage .results-actions button {
  font-size: 16px;
}
#stage.menu-compact .flow-head {
  padding-top: max(8px, var(--safe-top));
  padding-bottom: 8px;
  min-height: 60px;
}
#stage.menu-compact .flow-h {
  font-size: 22px;
}
#stage.menu-compact .picker-toolbar {
  padding-top: 8px;
  padding-bottom: 8px;
}
#stage.menu-narrow .flow-head {
  gap: 10px;
  padding-left: 16px;
  padding-right: 16px;
}
#stage.menu-narrow .flow-h {
  font-size: 20px;
}
#stage.menu-narrow .flow-eyebrow {
  display: none;
}
#stage.menu-narrow #menu-chrome {
  gap: 6px;
}
#stage.menu-narrow #menu-chrome #chrome-treats {
  padding: 0 8px;
  font-size: 13px;
}
#stage.menu-narrow .picker-toolbar {
  padding-left: 16px;
  padding-right: 16px;
  gap: 8px;
}
#stage.menu-narrow .picker-toolbar .btn-cream {
  font-size: 12px;
  padding: 10px;
}
#stage.menu-narrow .racer-grid {
  gap: 12px;
}

#stage #menu-chrome #chrome-treats {
  white-space: nowrap;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#stage #chrome-gear {
  display: grid;
  place-items: center;
}
.overlay .flow-head-spacer:empty {
  display: none;
}
#stage.menu-portrait .flow-head-right {
  width: auto;
}
#stage.menu-compact .picker-toolbar {
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}

/* Filled surfaces: depth from tone and spacing, outlines reserved for focus. */
.ui-icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.18em;
  flex: 0 0 auto;
}
#stage #menu :is(button, .sticker-deep, .start-opts, .start-racer, .setup-choice, .racer-card, .map-chip, .seg-toggle),
#stage .overlay :is(button, .menu-card, .settings-card, .seg-toggle, .prize-tile),
#stage #menu-chrome button {
  border-color: transparent;
  box-shadow: none;
}
#stage .flow-head {
  border: 0;
  background: #211a30;
}
#stage .picker-toolbar {
  background: #211a30;
}
#stage :is(.seg-toggle, .settings-nav) {
  background: var(--menu-surface);
  border: 0;
  box-shadow: none;
}
#stage .seg-btn {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #c4b9d2;
}
#stage .seg-btn.is-active {
  background: #fff2d8;
  color: #261c36;
  box-shadow: none;
}
#stage :is(.start-opts, .start-racer, .setup-choice, .settings-card, .menu-card, .racer-card) {
  background: var(--menu-surface);
}
#stage .btn-gold {
  background: #ffc64b;
  box-shadow: none;
  border: 0;
}
#stage .btn-cream {
  background: #fff2d8;
  box-shadow: none;
  border: 0;
}
#stage .racer-tap {
  background: #fff2d8;
  border: 0;
  box-shadow: none;
}
#stage .racer-tap.is-current {
  background: #ffc64b;
  box-shadow: none;
  border: 0;
}
#stage .prize-tile.is-current {
  background: #ffc64b;
  border: 0;
  box-shadow: none;
}
#stage .tap-card {
  box-shadow: none;
  border: 0;
}
#stage .flow-back,
#stage #menu-chrome button {
  background: var(--menu-surface);
  border: 0;
  box-shadow: none;
}
/* One ring for every way of moving focus: the pad's seat, Tab, or focus that
   arrives from outside the page (menu-ui.js turns .keyboard-navigation on). */
#stage .pad-focus,
#stage :is(button, input, textarea):focus-visible {
  outline: 3px solid #83e5db;
  outline-offset: 3px;
}
#menu[data-step="title"] {
  background: linear-gradient(90deg, #181321f2 0%, #181321dc 38%, #18132126 100%);
}
#stage .title-wrap {
  width: min(440px, calc(100vmin - 48px));
  left: max(6%, var(--safe-left));
  top: 50%;
  transform: translateY(-50%);
  gap: 12px;
  align-items: stretch;
}
#stage .title-logo {
  order: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.7px;
  color: #ffc64b;
  text-shadow: none;
  line-height: 1;
  margin: 0;
}
#stage .title-logo span {
  background: none;
  color: #ffc64b;
  -webkit-text-fill-color: #ffc64b;
  filter: none;
  text-shadow: none;
}
#stage .title-logo .menu-cat {
  height: 36px;
  width: 32px;
  filter: none;
}
#stage .title-tag {
  order: 1;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: #baaccb;
  margin: 0 0 12px 42px;
}
#stage .title-play,
#stage .title-resume {
  order: 3;
  min-height: 68px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  text-align: left;
  font-size: 22px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: -0.3px;
  margin: 0;
  border-radius: 18px;
}
#stage .title-play::after,
#stage .title-resume::after {
  content: "";
  margin-left: auto;
  width: 10px;
  height: 10px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
#stage .title-play.btn-cream {
  order: 4;
  background: var(--menu-surface);
  color: #fff2d8;
  min-height: 52px;
  font-size: 17px;
}
#stage .title-garage {
  order: 5;
  background: var(--menu-surface);
  color: #fff2d8;
  min-height: 76px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-radius: 18px;
}
#stage .title-garage > .ui-icon {
  width: 26px;
  height: 26px;
  color: #d2b6ef;
}
#stage .title-garage .home-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-size: 18px;
  font-weight: 650;
}
#stage .title-garage small {
  color: #c2b3d1;
  font-size: 12px;
  font-weight: 400;
}
#stage .title-extras {
  order: 6;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
#stage .title-extras .extra-btn {
  grid-column: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--menu-surface);
  color: #ded3e8;
  font-size: 13px;
  font-weight: 500;
}
#stage .title-extras .ui-icon {
  width: 18px;
  height: 18px;
  color: #bfa3d8;
}
#stage #open-catalog {
  order: 0;
}
#stage #open-settings {
  order: 1;
}
#stage #howto-btn {
  order: 2;
}
#stage #download-btn,
#stage #install-btn {
  order: 3;
}
#stage #quit-btn-title {
  order: 4;
}
#stage .tile-alert {
  width: 7px;
  height: 7px;
  top: 10px;
  right: 10px;
  font-size: 0;
  box-shadow: none;
  background: #ffc64b;
}
#stage .build-stamp {
  order: 7;
  font-family: var(--menu-font);
  font-size: 10px;
  color: #a798b7;
  opacity: 0.6;
  margin: 8px 0 0;
  text-align: left;
}
/* Upright: the stack sits at the BOTTOM of the screen, under the thumb, with
   the world showing above it (the scrim darkens toward the bottom to match). */
#stage.menu-portrait .title-wrap {
  width: calc(100% - 48px);
  max-width: 440px;
  left: 24px;
  top: auto;
  bottom: max(28px, calc(var(--safe-bottom, 0px) + 20px));
  transform: none;
  gap: 12px;
}
#stage.menu-portrait #menu[data-step="title"] {
  background: linear-gradient(180deg, #18132126 0%, #181321a6 45%, #181321f2 70%);
}
#stage.menu-compact .title-wrap {
  width: min(440px, calc(100vmin - 48px));
  gap: 8px;
}
#stage.menu-compact .title-logo {
  font-size: 22px;
}
#stage.menu-compact .title-logo .menu-cat {
  height: 26px;
  width: 24px;
}
#stage.menu-compact .title-tag {
  display: block;
}
#stage.menu-compact .title-play,
#stage.menu-compact .title-resume {
  min-height: 48px;
  padding: 10px 16px;
  font-size: 18px;
}
#stage.menu-compact .title-garage {
  min-height: 48px;
  padding: 8px 16px;
}
#stage.menu-compact .title-garage small {
  display: none;
}
#stage.menu-compact .title-extras {
  margin-top: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#stage.menu-compact .title-extras .extra-btn {
  padding: 8px;
  min-height: 44px;
  font-size: 12px;
  gap: 6px;
}
#stage.menu-compact .build-stamp {
  display: none;
}
#stage .title-garage > span.home-label {
  font-size: 18px;
}
#stage .tile-alert {
  min-width: 7px;
  min-height: 7px;
  padding: 0;
  line-height: 0;
}
html:not(.keyboard-navigation) #stage button:focus-visible:not(.pad-focus) {
  outline: none;
}
.keyboard-navigation #stage :is(button, input, textarea):focus {
  outline: 3px solid #83e5db;
  outline-offset: 3px;
}

/* A shared control shape, with smaller matching corners inside button groups. */
#stage {
  --control-radius: 14px;
  --segment-radius: 10px;
}
#stage #menu button,
#stage .overlay button,
#stage #menu-chrome button {
  border-radius: var(--control-radius);
}
#stage #menu .seg-btn,
#stage .overlay .seg-btn,
#stage .settings-nav button {
  border-radius: var(--segment-radius);
}
#stage #menu .seg-toggle,
#stage .overlay .seg-toggle,
#stage .settings-nav {
  border-radius: var(--control-radius);
  padding: 4px;
  gap: 4px;
}
#stage #menu .swatch-dot {
  border-radius: var(--segment-radius);
}

/* The map now owns a full panel instead of a thumbnail corner. */
#stage #flow-startline .startline-body {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(340px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  padding: 20px max(20px, var(--safe-right)) max(20px, var(--safe-bottom)) max(20px, var(--safe-left));
  overflow: hidden;
}
#stage #flow-startline .map-chip {
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  padding: 20px;
  margin: 0;
  background: var(--menu-surface);
  text-align: left;
  border-radius: var(--control-radius);
  overflow: hidden;
}
#stage #flow-startline .map-preview-heading {
  flex: 0 0 auto;
  color: #bfb0d0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#stage #flow-startline .map-chip .track-map {
  display: block;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  height: 0;
  object-fit: contain;
  border: 0;
  background: transparent;
}
#stage #flow-startline .map-chip .map-label {
  position: static;
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  display: block;
  margin: 0;
  padding: 8px 0 0;
  font-size: 13px;
  line-height: 1.3;
  color: #fff2d8;
  white-space: normal;
  text-align: left;
  -webkit-line-clamp: unset;
}
#stage #flow-startline .start-side {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  gap: 12px;
  justify-content: center;
  align-self: stretch;
}
#stage #flow-startline .start-scroll {
  gap: 10px;
  padding: 0;
  flex-shrink: 1;
}
#stage #flow-startline .start-scroll > * {
  flex-shrink: 0;
}
#stage #flow-startline .setup-pickers {
  flex-direction: row;
}
#stage #flow-startline .setup-choice {
  min-width: 0;
  flex: 1;
  padding: 10px 12px;
  gap: 0;
}
#stage #flow-startline .setup-choice .setup-icon,
#stage #flow-startline .setup-choice b {
  display: none;
}
#stage #flow-startline .start-racer {
  padding: 10px;
}
#stage #flow-startline .start-opts {
  padding: 10px;
}
#stage #flow-startline .mode-opt-row {
  gap: 6px;
}
#stage #flow-startline .mode-opt-label {
  min-width: 40px;
  flex: 0 0 40px;
  font-size: 10px;
}
#stage #flow-startline .seg-toggle {
  min-width: 0;
  flex: 1;
}
#stage #flow-startline .seg-btn {
  min-width: 44px;
  padding: 8px 4px;
  font-size: 12px;
}
#stage #flow-startline #go-btn {
  flex: 0 0 auto;
  min-height: 52px;
  margin: 0;
  padding: 12px;
}
#stage.menu-compact #flow-startline .startline-body {
  padding: 8px max(16px, var(--safe-right)) max(12px, var(--safe-bottom)) max(16px, var(--safe-left));
  gap: 12px;
}
#stage.menu-compact #flow-startline .start-side {
  gap: 8px;
}
#stage.menu-compact #flow-startline .start-scroll {
  gap: 4px;
}
#stage.menu-compact #flow-startline .start-racer {
  padding: 4px 8px;
}
#stage.menu-compact #flow-startline .start-opts {
  padding: 4px 8px;
  gap: 4px;
}
#stage.menu-compact #flow-startline .seg-toggle {
  padding: 2px;
  gap: 2px;
}
#stage.menu-compact #flow-startline .map-chip {
  padding: 14px;
}
#stage.menu-portrait #flow-startline .startline-body {
  gap: 12px;
  padding: 12px 16px max(16px, var(--safe-bottom));
}
#stage.menu-portrait #flow-startline .map-chip {
  padding: 12px 16px;
}
#stage.menu-portrait #flow-startline .start-side {
  justify-content: flex-end;
  gap: 10px;
}

/* Settings controls get their own available width; no implicit grid columns. */
#stage #settings .setting-row:not(.backup-row) {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 2fr);
  gap: 12px;
}
#stage #settings .setting-row.setting-row-audio {
  grid-template-columns: minmax(70px, 1fr) 72px minmax(100px, 1fr);
}
#stage #settings .setting-row > * {
  min-width: 0;
}
#stage #settings .setting-row > .seg-toggle {
  grid-column: auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}
#stage #settings .setting-row > .seg-toggle .seg-btn {
  min-width: 44px;
  padding: 8px 4px;
  font-size: 13px;
  width: 100%;
}
#stage #settings .setting-row > button {
  justify-self: start;
  min-width: 72px;
}
#stage.menu-portrait #settings .setting-row.setting-row-segmented {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
#stage.menu-portrait #settings .setting-row.setting-row-audio {
  grid-template-columns: minmax(60px, 1fr) 64px minmax(80px, 1fr);
  gap: 8px;
}
#stage.menu-portrait #settings .setting-row > .seg-toggle .seg-btn {
  font-size: 12px;
}
#stage.menu-portrait #settings .setting-label {
  font-size: 14px;
}
#stage #settings .settings-card {
  min-width: 0;
}

@media (max-width: 360px) and (orientation: portrait) {
  #stage.menu-portrait #flow-startline .mode-opt-row:has(.seg-toggle) {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  #stage.menu-portrait #flow-startline .mode-opt-row:has(.seg-toggle) .mode-opt-label {
    flex: 0 0 auto;
  }
  #stage.menu-portrait #settings .settings-card {
    padding: 14px;
  }
}

/* Race setup presents the current recipe; choices live one level below. */
#stage #flow-startline .setup-pickers .setup-choice {
  width: 100%;
  min-height: 56px;
}
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-radius: var(--control-radius);
  overflow: hidden;
  gap: 0;
  padding: 0;
}
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview > .start-racer-label {
  padding: 12px 14px 0;
}
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .racer-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--menu-surface);
}
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .racer-summary {
  font-size: 14px;
  min-width: 0;
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-actions button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 12px;
}
#stage.menu-compact #flow-startline .setup-pickers {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
#stage.menu-compact #flow-startline .setup-choice {
  padding: 6px;
  min-height: 52px;
}
#stage.menu-compact :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .racer-preview-footer {
  padding: 4px 8px;
}
#stage.menu-compact :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .racer-summary {
  font-size: 12px;
}
#stage .race-detail-inner {
  width: min(800px, 100%);
  margin: 0 auto;
}
#stage .race-detail-inner > p {
  color: #d3c7df;
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 20px;
}
#stage .race-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
#stage #menu .race-detail-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  white-space: normal;
  padding: 20px;
  gap: 8px;
  background: var(--menu-surface);
  color: #fff2d8;
}
#stage #menu .race-detail-choice.is-active {
  background: #fff2d8;
  color: #261c36;
}
#stage .race-detail-choice strong { font-size: 20px; }
#stage .race-detail-choice span { font-size: 14px; line-height: 1.5; }
#stage.menu-portrait .race-detail-grid { grid-template-columns: minmax(0, 1fr); }
/* An odd fifth card (Legend) spans the row instead of sitting alone bottom-left. */
#stage .race-detail-grid .race-detail-choice:last-child:nth-child(odd) { grid-column: 1 / -1; }

#stage.menu-compact :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview > .start-racer-label:has(.seat-input.hidden) {
  display: none;
}
#stage.menu-compact :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview {
  padding: 0;
}

#stage.menu-compact #flow-startline .setup-choice small {
  white-space: nowrap;
  font-size: 9px;
  letter-spacing: .08em;
}
#stage.menu-compact #flow-startline .setup-choice strong {
  font-size: 11px;
  line-height: 1.2;
}
#stage .race-detail-choice span {
  font-weight: 400;
}

/* Shared picker gutters, and one flexible row for the remaining race choices. */
#stage :is(#flow-mode, #flow-track, #flow-cup, #flow-rivals, #flow-length) > .flow-body {
  padding: 16px max(20px, var(--safe-right)) max(20px, var(--safe-bottom)) max(20px, var(--safe-left));
}
#stage :is(.mode-grid, .track-grid, .cup-grid, .race-detail-inner) {
  width: 100%;
  max-width: none;
  margin: 0;
}
#stage .race-detail-inner {
  padding: 0;
}
#stage.menu-portrait :is(#flow-mode, #flow-track, #flow-cup, #flow-rivals, #flow-length) > .flow-body {
  padding: 12px max(16px, var(--safe-right)) max(20px, var(--safe-bottom)) max(16px, var(--safe-left));
}
#stage #flow-startline .setup-racer-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 8px;
}
#stage #flow-startline #setup-mode {
  flex: 0 0 auto;
  width: 100%;
  min-height: 56px;
}
#stage #flow-startline .setup-racer-panel .setup-racer-preview {
  flex: 1 1 0;
  height: auto;
}
#stage #flow-startline .setup-pickers {
  display: flex;
  gap: 8px;
}
#stage #flow-startline .setup-pickers > * {
  flex: 1 1 0;
  min-width: 0;
}
#stage.menu-compact #flow-startline #setup-mode {
  min-height: 52px;
}
/* One spacing rhythm, with no empty summary row or footer copy. */
#stage #flow-startline { --setup-gap: 12px; }
#stage.menu-compact #flow-startline { --setup-gap: 8px; }
#stage #flow-startline.flow-screen :is(.startline-body, .setup-racer-panel, .start-side, .start-scroll, .setup-pickers) {
  gap: var(--setup-gap);
}
#stage #flow-startline .setup-pickers:not(:has(> :not(.hidden))) {
  display: none;
}
#stage #flow-startline .map-chevron {
  color: #ffc64b;
  margin-left: 4px;
}
#stage.menu-portrait #flow-startline .startline-body {
  display: flex;
  flex-direction: column;
}
#stage.menu-portrait #flow-startline .setup-racer-panel {
  flex: 1 1 0;
}
#stage.menu-portrait #flow-startline .start-side {
  flex: 0 1 auto;
  height: auto;
}
#stage.menu-portrait #flow-startline .start-scroll {
  flex: 0 1 auto;
}

/* Keep both landscape columns stretched to the available height. */
#stage:not(.menu-portrait) #flow-startline .start-side {
  justify-content: flex-start;
}
#stage:not(.menu-portrait) #flow-startline .start-scroll {
  flex: 1 1 0;
}
#stage:not(.menu-portrait) :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview {
  flex: 1 0 auto;
}
#stage:not(.menu-portrait) :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview > :not(canvas) {
  flex-shrink: 0;
}

/* Racer artwork fills the card; only the caption has an inset. */
#stage #menu :is(#cat-grid, #kart-grid) .racer-tap {
  padding: 0 0 12px;
  height: auto;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--control-radius);
}
#stage #menu .racer-tap .racer-shot {
  width: 100%;
  max-width: none;
  aspect-ratio: 1;
  height: auto;
  flex: 0 0 auto;
  align-self: stretch;
  border: 0;
  border-radius: 0;
}
#stage #menu .racer-tap :is(.track-name, .track-sub) {
  padding: 0 12px;
}
#stage #menu .racer-tap .track-sub {
  min-height: 1.4em;
  white-space: nowrap;
  font-size: 11px;
}
#stage #racer-details {
  background: #100b1db3;
  padding: 16px;
}
#stage .racer-details-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  width: min(640px, 100%);
  max-height: calc(100% - 16px);
  overflow-y: auto;
  padding: 0;
  gap: 0;
  border: 0;
  border-radius: var(--control-radius);
  background: var(--menu-surface);
  color: #fff3dc;
}
#racer-details-image { width: 100%; height: auto; aspect-ratio: 1; align-self: start; object-fit: contain; min-height: 0; background: #211a30; }
.racer-details-copy { padding: 20px; text-align: left; }
.racer-details-copy h2 { margin: 0; font-size: 22px; }
.racer-details-copy p { font-size: 14px; line-height: 1.45; margin: 12px 0; }
#racer-details-type, #racer-details-balance { color: #c2b8ce; }
.racer-details-copy button { width: 100%; min-height: 44px; margin-top: 8px; }
#racer-details-action[hidden] { display: none; }
#stage.menu-portrait .racer-details-card { grid-template-columns: minmax(0, 1fr); max-width: 360px; }
#stage.menu-portrait #racer-details-image { height: auto; }

/* Setup repeats the visual identity of the choices that lead into it. */
#stage #flow-startline #setup-mode {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  background: #fff3dc;
  color: #30263d;
  border: 0;
}
#stage #flow-startline #setup-mode .setup-icon {
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 100%;
  height: 100%;
  font-size: 28px;
  color: #30263d;
  background: var(--mode-art-color);
}
#stage #flow-startline #setup-mode > span:not(.setup-icon) { padding: 8px 12px; }
#stage #flow-startline #setup-mode small { color: #6c6078; }
#stage #flow-startline #setup-mode small::after { color: #6c6078; }
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview {
  background: radial-gradient(ellipse 100% 100% at 50% 125%, #30263d26 99.5%, transparent 100%), var(--racer-backdrop, #a4dedf);
  color: var(--racer-ink, #30263d);
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview > canvas,
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .racer-preview-footer { background: transparent; }
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .setup-racer-preview .start-racer-label,
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) .racer-summary { color: inherit; }

/* Racer leads the setup; the track fills the space above Start. */
#stage #flow-startline .start-scroll > .map-chip {
  flex: 1 0 130px;
  height: auto;
}
#stage.menu-portrait #flow-startline .setup-racer-panel {
  min-height: 260px;
}
#stage.menu-portrait #flow-startline .start-side {
  max-height: calc(100% - 272px);
}
#stage.menu-portrait #flow-startline .start-scroll > .map-chip {
  height: clamp(100px, 19svh, 180px);
  flex: 0 0 auto;
}

/* Shared content insets: compact layouts reduce height, never side padding. */
#stage {
  --menu-inset: 16px;
  --menu-control-y: 12px;
  --menu-content-gap: 8px;
}
#stage.menu-compact { --menu-control-y: 8px; }
#stage #menu :is(.btn-cream, .btn-gold),
#stage .overlay :is(.btn-cream, .btn-gold),
#stage #flow-startline.flow-screen .setup-choice,
#stage #flow-startline.flow-screen #setup-mode > span:not(.setup-icon),
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit).flow-screen .racer-preview-footer,
#stage #flow-startline.flow-screen #go-btn,
#stage :is(#flow-startline, #flow-garage).flow-screen .setup-racer-actions button,
#stage .picker-toolbar .btn-cream,
#stage .racer-details-copy button {
  padding: var(--menu-control-y) var(--menu-inset);
}
#stage #flow-startline.flow-screen #setup-mode { padding: 0; }
#stage #flow-startline.flow-screen .map-chip,
#stage #menu .race-detail-choice,
#stage .racer-details-copy {
  padding: var(--menu-inset);
}
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit).flow-screen .setup-racer-preview > .start-racer-label {
  padding: var(--menu-inset) var(--menu-inset) 0;
}
#stage #flow-mode.flow-screen .tap-text {
  padding: var(--menu-control-y) var(--menu-inset);
}
#stage :is(#flow-startline, #flow-garage).flow-screen .setup-racer-actions,
#stage :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit).flow-screen .racer-preview-footer {
  gap: var(--menu-content-gap);
}
#stage #menu :is(#cat-grid, #kart-grid) .racer-tap :is(.track-name, .track-sub) {
  padding-inline: var(--menu-inset);
}

/* The group's outer frame, rather than each inset segment, is button-height. */
#stage { --menu-button-height: 44px; }
#stage :is(#menu, #settings, #catalog) .seg-toggle {
  box-sizing: border-box;
  height: var(--menu-button-height);
  min-height: var(--menu-button-height);
  padding: 4px;
  align-items: stretch;
}
#stage :is(#menu, #settings, #catalog) .seg-toggle > .seg-btn.seg-btn {
  height: 100%;
  min-height: 0;
  padding-block: 0;
  margin-block: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#stage #menu .picker-toolbar > .btn-cream {
  box-sizing: border-box;
  height: var(--menu-button-height);
  min-height: var(--menu-button-height);
  padding-block: 0;
}
#stage #menu .picker-toolbar .seg-toggle { margin: 0; }

/* All indigo control/card fills share one opaque surface color. */
#stage :is(.sticker-deep, .track-col-ctrl) {
  background: var(--menu-surface);
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--menu-content-gap);
}

/* Garage uses the same still racer card over the uninterrupted track orbit:
   the card spans the body (its footer opens the pickers), Done sits below. */
#stage #flow-garage .garage-body {
  display: flex;
  flex-direction: column;
  align-items: stretch; /* .racer-body centres its grid rows; here that would shrink-wrap the card */
  gap: 12px;
  padding: 12px max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
}
#stage #flow-garage .setup-racer-preview {
  flex: 1 1 0;
  min-height: 180px;
  min-width: 0;
}
#stage #flow-garage #garage-done {
  flex: 0 0 auto;
  width: 100%;
}
#stage:not(.menu-portrait) #flow-garage #garage-done {
  width: min(100%, 360px);
  align-self: flex-end;
}
/* Portrait caps the card at a square: a phone-tall card is mostly empty teal
   around a width-bound racer. Done stays pinned at the bottom in thumb reach;
   the auto margins centre the card in the space above it. */
#stage.menu-portrait #flow-garage .setup-racer-preview {
  flex: 0 1 auto;
  aspect-ratio: 1;
  min-height: 180px;
  margin-block: auto;
}

/* Home's two primary actions share one responsive height. */
#stage { --home-action-height: 68px; }
#stage.menu-portrait { --home-action-height: 58px; }
#stage.menu-compact { --home-action-height: 48px; }
#stage #menu :is(.title-play, .title-garage) {
  min-height: var(--home-action-height);
}

/* Portrait actions use one gap from Race through the last utility row. */
#stage.menu-portrait .title-extras {
  margin-top: 0;
  gap: 12px;
}

/* Studios: a shared racer preview, summaries, and one focused choice at a time. */
#stage .studio-screen .racer-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  align-items: stretch;
  gap: 12px;
  padding: 12px max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
  overflow: hidden;
}
#stage .studio-screen .setup-racer-preview { min-height: 160px; min-width: 0; }
#stage .studio-screen .setup-racer-preview canvas {
  display: block; width: 100%; height: 0; min-height: 90px; flex: 1 1 0;
  object-fit: contain; background: transparent;
}
#stage .studio-screen .racer-card {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: none; max-height: none; min-height: 0;
  padding: 0; margin: 0; background: transparent; border: 0; box-shadow: none;
  overflow: hidden; align-self: stretch;
}
#stage .studio-summary.has-color strong::before {
  content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 6px;
  border-radius: 4px; background: var(--choice-color); vertical-align: -2px;
}
#stage .studio-screen .creator,
#stage .studio-screen .studio-detail-done,
#stage .studio-screen .creator-row,
#stage .studio-screen .studio-legacy-stepper { display: none; }
#stage .studio-screen[data-studio-detail] .studio-overview,
#stage .studio-screen[data-studio-detail] .creator-rand,
#stage .studio-screen[data-studio-detail] .racer-actions,
#stage .studio-screen[data-studio-detail] .garage-lock-note { display: none; }
#stage .studio-screen[data-studio-detail] .creator {
  display: block; padding: 16px; background: var(--menu-surface);
  border: 0; border-radius: var(--control-radius); overflow: visible; min-height: 0; flex: 0 0 auto;
}
#stage .studio-screen .creator-row.studio-field-active {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 0;
}
#stage .studio-screen .creator-label { display: none; }
#stage .studio-screen .swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); width: 100%; gap: 12px; }
#stage .studio-screen .swatch-dot { width: 100%; height: 48px; min-height: 48px; border-radius: var(--control-radius); }
#stage .studio-option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#stage .studio-screen[data-studio-detail="number"] .studio-option-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#stage .studio-screen[data-studio-detail] .studio-detail-done { display: block; flex-shrink: 0; min-height: 44px; }
#stage .studio-screen .racer-actions { position: static; margin: 0; padding: 0; gap: 8px; background: transparent; flex-shrink: 0; }
#stage .studio-screen .racer-actions button { font-size: 14px; min-height: 44px; margin: 0; }
#stage .studio-screen .garage-lock-note { font-size: 12px; line-height: 1.4; margin: 0; padding: 0 4px; }
#stage .studio-screen .garage-lock-note:empty { display: none; }
#stage .studio-screen .creator-rand { margin: 0; min-height: 44px; }
#stage .studio-screen .picking-name .creator { display: none; }
#stage .studio-screen .name-picker { flex: 1; min-height: 0; overflow: auto; }
/* Both panes keep the same tracks regardless of the active editing field. */
#stage .studio-screen .racer-body { grid-template-rows: minmax(0, 1fr); }
#stage.menu-portrait .studio-screen .racer-body {
  grid-template-columns: minmax(0, 1fr);
}
#stage.menu-compact .studio-screen .studio-overview { gap: 8px; }
#stage.menu-compact #menu .studio-summary { min-height: 48px; padding: 8px 16px; }
#stage.menu-compact .studio-screen .racer-card { gap: 8px; }

#stage .studio-scroll { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; flex: 1 1 auto; }
#stage .studio-scroll > * { flex-shrink: 0; }
#stage .studio-screen[data-studio-detail] .studio-scroll { background: var(--menu-surface); border-radius: var(--control-radius); }
#stage .studio-screen .studio-detail-done { margin: 0; }
#stage .studio-screen .picking-name .studio-scroll { min-height: 0; }
#stage.menu-compact .studio-scroll { gap: 8px; }

#stage .studio-summary-wide { grid-column: 1 / -1; }

/* A quiet still beneath the high-contrast track outline and labels. */
#stage #flow-startline #track-scenery {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none; opacity: 0;
}
#stage #flow-startline #track-scenery[data-ready="true"] { opacity: 1; }
#stage #flow-startline .map-chip::before {
  content: ""; position: absolute; inset: 0;
  background: rgba(24, 18, 38, .62); pointer-events: none; z-index: 1;
}
#stage #flow-startline .map-chip > :not(#track-scenery) { position: relative; z-index: 2; }

/* Track cards share the catalog tile, with artwork reaching the clipped edge. */
#stage #flow-startline #menu-map-btn { border: 0; box-shadow: none; }
#stage #menu #track-grid .racer-tap { padding: 0 0 12px; height: auto; min-height: 0; overflow: hidden; border-radius: var(--control-radius); }
#stage #track-grid .racer-shot { background: var(--menu-surface); }
#stage #track-grid .track-map { width: 100%; height: 100%; padding: 16px; box-sizing: border-box; }
#stage #track-grid .track-sub { overflow: hidden; text-overflow: ellipsis; }
#stage #flow-track .picker-toolbar { justify-content: flex-end; margin-bottom: 12px; }
#stage #track-panel .builder-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  gap: 12px; padding: 12px max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left)); overflow: hidden;
}
#stage #track-panel .track-col-map { min-width: 0; min-height: 0; width: auto; }
#stage #track-panel .map-frame { display: flex; flex-direction: column; height: 100%; box-sizing: border-box; padding: 16px; border: 0; border-radius: var(--control-radius); background: var(--menu-surface); gap: 8px; }
#stage #track-panel #track-preview { width: 100%; height: 0; flex: 1; min-height: 60px; object-fit: contain; }
#stage #track-panel .map-reroll { flex-shrink: 0; margin: 0; min-height: 44px; }
#stage #track-panel .track-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin: 0; flex-shrink: 0; font-size: 12px; line-height: 1.3; color: #e8dccb; }
#stage #track-panel .track-key:empty { display: none; }
#stage #track-panel .track-key span { display: inline-flex; align-items: center; gap: 6px; }
#stage #track-panel .track-key i { width: 14px; height: 4px; border-radius: 2px; background: var(--key); }
#stage #track-panel .builder-side { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 12px; }
#stage #track-panel .builder-scroll { flex: 1; min-height: 0; overflow-y: auto; }
#stage #track-panel .studio-summary:last-child { grid-column: 1 / -1; }
#stage #track-panel .builder-detail { background: var(--menu-surface); border-radius: var(--control-radius); padding: 16px; }
#stage #track-panel .biome-pick, #stage #track-panel .tod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#stage #track-panel .biome-chip { width: 100%; min-height: 44px; border: 0; border-radius: var(--control-radius); background: transparent; color: #fff3dc; }
#stage #track-panel .biome-chip.on { background: #fff2d8; color: #30263d; }
#stage #track-panel .track-actions { position: static; margin: 0; padding: 0; background: none; }
#stage #track-panel .track-actions button, #stage #track-panel .builder-done { width: 100%; margin: 0; min-height: 44px; flex-shrink: 0; }
#stage.menu-portrait #track-panel .builder-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(180px, 1fr) minmax(0, 1fr); }
#stage #track-panel .track-col-map { position: static; top: auto; align-self: stretch; max-width: none; height: 100%; overflow: hidden; }
#stage #track-panel .map-frame { align-self: stretch; min-height: 0; }
#stage #track-panel .track-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
#stage #track-panel .track-row .setting-label { flex: 0 0 60px; font-size: 13px; }
#stage #track-panel .track-row .slider { flex: 1; min-width: 0; width: auto; }
#stage #track-panel .track-val { font-size: 12px; }
#stage #track-panel .map-frame { box-shadow: none; }
#stage #track-panel :is(.map-reroll, .biome-chip) { display: flex; align-items: center; justify-content: center; gap: 6px; }
#stage #track-panel #biome-max-hint { display: block; font-size: 12px; line-height: 1.4; color: #c3b8cf; margin-bottom: 12px; }

/* Bundled scenery is available before a track has ever been selected. */
#stage #track-grid .track-preview-art {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#stage #track-grid .track-preview-art > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#stage #track-grid .track-preview-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 38, .62);
  pointer-events: none;
}
#stage #track-grid .track-preview-art > .track-map {
  position: relative;
  z-index: 1;
  background: transparent;
}

/* Studio overview fits the screen; only detailed choices need a scroll area. */
#stage .studio-screen:not([data-studio-detail]) .studio-scroll {
  overflow: visible;
}
#stage .studio-screen .racer-preview-footer {
  flex: 0 0 auto;
  gap: 8px;
}
#stage #menu .studio-screen .studio-name-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 4px;
  background: transparent;
  color: inherit;
  text-align: left;
  flex: 1 1 0;
}
#stage .studio-name-edit::after { content: '›'; flex-shrink: 0; }
#stage .studio-name-edit .racer-summary { overflow-wrap: anywhere; font-size: 14px; }
#stage #menu .studio-screen .racer-preview-footer .creator-rand {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 12px;
}
#stage .studio-screen[data-studio-detail] .racer-preview-footer .creator-rand {
  display: block;
  visibility: hidden;
}
#stage #menu .studio-screen .studio-name-edit:disabled { opacity: 1; }
#stage.menu-portrait .studio-screen .racer-body {
  grid-template-rows: minmax(160px, 1fr) minmax(208px, .65fr);
}

/* Desktop width. The phone-first flow layouts stretch edge to edge on a laptop
   or a 1440px MacBook, so every flow body past Home gets a cap and is centred
   under its full-width header, the way Collection and Settings already sit in
   their sheets. Two-column screens (setup, garage, studios, track builder) get
   the wide cap; lists get the narrower one. Phones never reach these widths. */
#stage #menu .flow-screen:not(#flow-title) > .flow-body,
#stage #track-panel > .flow-body {
  width: 100%;
  max-width: var(--flow-max, 1120px);
  margin-inline: auto;
}
#stage :is(#flow-mode, #flow-track, #flow-cup, #flow-rivals, #flow-length, #flow-players) > .flow-body {
  --flow-max: 900px;
}
#stage :is(#flow-cat, #flow-kart) > .flow-body {
  --flow-max: 1160px; /* the racer grids already cap at 1100px plus gutters */
}
#stage :is(#flow-cat, #flow-kart) .racer-grid {
  margin-inline: auto; /* centred under the cap, like the Collection grid */
}
/* …and height: the two-column screens grew to the window, so on a tall desktop
   window the racer card was a metre high. Cap them and centre them between
   the header and the bottom edge. Portrait keeps its own stacked layout. */
#stage:not(.menu-portrait) :is(#flow-startline, #flow-garage, #flow-cat-edit, #flow-kart-edit) > .flow-body,
#stage:not(.menu-portrait) #track-panel > .flow-body {
  max-height: 760px;
  margin-block: auto;
}

/* Cup mode: the track card is a preview of the series, not a picker. */
#stage #flow-startline #menu-map-btn:disabled {
  cursor: default;
  transform: none;
  opacity: 1;
}
#stage #flow-startline #menu-map-btn:disabled :is(.map-chevron, .map-edit-hint) {
  display: none;
}

/* Setup and garage racer cards: the portrait fills the whole card, with the
   label and the footer laid over it, and the fitter keeps the model between
   them (it reads --portrait-inset-top/bottom off the canvas). The model is as
   large as the card allows instead of a strip squeezed above a solid footer. */
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview {
  position: relative;
  --racer-footer-y: 8px;
  --portrait-inset-top: 16px;
  --portrait-inset-bottom: 60px; /* 44px pills + 2 × --racer-footer-y, spelled out: the fitter
                                    reads these with getComputedStyle, which leaves calc() unresolved */
}
#stage.menu-compact :is(#flow-startline, #flow-garage) .setup-racer-preview {
  --racer-footer-y: 4px;
  --portrait-inset-top: 10px;
  --portrait-inset-bottom: 52px;
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview > canvas {
  display: block;
  width: 100%;
  height: 90px;
  min-height: 150px;
  flex: 1 1 90px;
  object-fit: contain;
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview > .start-racer-label,
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview > .racer-preview-footer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview > .start-racer-label {
  top: 0;
  pointer-events: none;
}
#stage :is(#flow-startline, #flow-garage).flow-screen .setup-racer-preview > .racer-preview-footer {
  bottom: 0;
  padding: var(--racer-footer-y) var(--menu-inset);
}
#stage :is(#flow-startline, #flow-garage) .racer-preview-footer .racer-summary {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Developer racer toggles: compact rows, the toggled ones marked. */
.dev-racers {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0 10px;
}
.dev-racers h3 {
  margin: 10px 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}
.dev-racers .setting-row {
  min-height: 0;
  padding: 4px 0;
}
.dev-racer-claim {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.6;
}
.dev-racers .setting-label {
  color: rgba(255, 246, 229, 0.88);
  font-weight: 500;
}
.dev-racers .dev-toggled .setting-label {
  color: #f2c54b;
  font-weight: 700;
}

/* A racer portrait being re-rendered (a new cat or kart was just picked):
   the old still dims and a spinner turns over it until the new one lands.
   Both wait a beat so a fast device never flickers. */
#stage .setup-racer-preview > canvas {
  transition: opacity 0.2s, filter 0.2s;
}
#stage .setup-racer-preview > canvas[data-ready="false"] {
  opacity: 0.4;
  filter: saturate(0.5) blur(1.5px);
  transition-delay: 0.15s;
}
#stage :is(#flow-startline, #flow-garage) .setup-racer-preview:has(> canvas[data-ready="false"])::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--racer-ink, #30263d) 22%, transparent);
  border-top-color: var(--racer-ink, #30263d);
  z-index: 1;
  pointer-events: none;
  animation:
    racer-spin 0.8s linear infinite,
    racer-spin-in 0.2s 0.15s both;
}
@keyframes racer-spin {
  to { rotate: 360deg; }
}
@keyframes racer-spin-in {
  from { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #stage :is(#flow-startline, #flow-garage) .setup-racer-preview:has(> canvas[data-ready="false"])::after {
    animation: racer-spin-in 0.2s 0.15s both;
  }
}
