/* Shared menu primitives. Imported after the legacy layout rules so new screens
   can reuse these classes instead of growing screen-specific overrides. */
#stage {
  --menu-cream: #fff3dc;
  --menu-gold: #ffc64b;
  --menu-gap: 12px;
}
#stage .summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--menu-gap); }
#stage .summary-choice {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 4px; padding: 12px 16px; min-height: 60px; min-width: 0;
  background: var(--menu-surface); color: var(--menu-cream);
  border: 0; border-radius: var(--control-radius); box-shadow: none; text-align: left;
}
#stage .summary-choice small { color: var(--menu-muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
#stage .summary-choice small::after { content: ' ›'; color: var(--menu-gold); }
#stage .summary-choice strong { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
#stage .menu-fixed-actions { flex: 0 0 auto; display: flex; padding: 12px max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left)); }
#stage .menu-fixed-actions.hidden { display: none; }
#stage .menu-fixed-actions > button { width: 100%; min-height: var(--menu-button-height); margin: 0; }
#stage .players-body { display: flex; flex-direction: column; gap: var(--menu-gap); padding: 12px max(16px, var(--safe-right)) 0 max(16px, var(--safe-left)); }
#stage .players-body > * { flex-shrink: 0; }
#stage .players-help { margin: 0; color: var(--menu-muted); font-size: 14px; }
#stage #flow-players :is(.seat-row, #split-count-row) { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--menu-surface); border: 0; border-radius: var(--control-radius); }
#stage #flow-players .hidden { display: none; }
#stage #flow-players .mode-opt-row { width: 100%; display: flex; align-items: center; gap: 16px; }
#stage #flow-players .seg-toggle { flex: 1; }
#stage #flow-players .start-racer-text { flex: 1; min-width: 0; }
#stage #flow-players .seat-names { display: block; }
#stage #flow-players .seat-input { display: inline-block; }
#stage #flow-players .start-input-warn { margin: 0; }
#stage #flow-startline .setup-pickers:has(#players-row:not(.hidden)) { flex-wrap: wrap; }
#stage #flow-startline #players-row:not(.hidden) { flex: 1 0 100%; }
#stage .award-group-title { margin: 16px 0 4px; font-size: 16px; }
#stage .award-group { display: flex; flex-direction: column; gap: 8px; }

/* Audit alignment: collection uses the same edge-to-edge inventory cards. */
#stage #catalog .racer-tap {
  padding: 0 0 12px;
  height: auto;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--control-radius);
  background: #fff3dc;
  color: #30263d;
  box-shadow: none;
  gap: 8px;
  cursor: pointer;
}
#stage #catalog .racer-tap.is-current { background: #ffc64b; }
#stage #catalog .racer-shot {
  width: 100%;
  max-width: none;
  height: auto;
  aspect-ratio: 1;
  flex: 0 0 auto;
  align-self: stretch;
  border: 0;
  border-radius: 0;
}
#stage #catalog .racer-tap :is(.track-name, .track-sub) { padding: 0 var(--menu-inset); }
#stage #catalog .racer-tap .track-sub {
  min-height: 1.4em;
  font-size: 11px;
  white-space: nowrap;
  color: #6c6078;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  box-sizing: border-box;
}
#stage #catalog .prize-head { display: none; }
/* One card size for every Collection tab (cats, karts, creators). */
#stage #catalog .prize-grid {
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
/* Keep the shared flat indigo fill on utility surfaces, too. */
#stage :is(.how-item, .how-item.how-win, .shelf-cup, .ach-row, .name-picker) {
  background: var(--menu-surface);
  border: 0;
  box-shadow: none;
  border-radius: var(--control-radius);
}
#stage .studio-screen .name-picker { padding: 12px; box-sizing: border-box; }
#stage #pause-overlay .flow-eyebrow { display: none; }
/* Cup selection follows the coloured-icon / cream-copy cards used by Mode. */
#stage #flow-cup .cup-tap {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 16px;
  grid-template-rows: 1fr auto;
  gap: 8px 12px;
  padding: 0 16px 0 0;
  overflow: hidden;
  background: #fff3dc;
  border: 0;
  border-radius: var(--control-radius);
  box-shadow: none;
}
#stage #flow-cup .cup-tap .tap-chip {
  grid-row: 1 / -1;
  width: 76px;
  height: 100%;
  min-height: 120px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 32px;
}
#stage #flow-cup .cup-tap .tap-text { padding-top: 16px; }
#stage #flow-cup .cup-tap .tap-chev { grid-column: 3; grid-row: 1 / -1; align-self: center; }
#stage #flow-cup .cup-tap .cup-meta { grid-column: 2; padding: 0 0 16px; margin: 0; }
#stage #flow-cup .cup-pill { border: 0; box-shadow: none; background: #30263d12; }
#stage #settings .backup-row .share-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#stage #settings .backup-row .share-row button { margin: 0; width: 100%; }
#stage #settings #backup-restore { grid-column: 1 / -1; }
#stage :is(.shelf-cup, .ach-row) { opacity: 1; }
#stage .catalog-trophies { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
#stage.menu-portrait .catalog-trophies { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#stage .shelf-cup { min-width: 0; padding: 12px; }
#stage .catalog-achievements { gap: 8px; }
#stage .ach-row { padding: 12px; }
#stage .ach-desc { color: var(--menu-muted); font-size: 12px; line-height: 1.4; }
#stage #catalog .flow-head-right { display: flex; align-items: center; gap: 8px; }
#stage #catalog-treats {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--menu-button-height);
  padding: 0 12px;
  margin: 0;
  border: 0;
  border-radius: var(--control-radius);
  box-shadow: none;
  background: var(--menu-surface);
  color: var(--menu-ink);
  font-size: 14px;
  white-space: nowrap;
}
#stage #flow-cup .tap-sub { color: #6c6078; font-weight: 400; }
#stage:not(.menu-portrait) .players-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 8px; }
#stage:not(.menu-portrait) #flow-players :is(.players-help, #split-count-row, .start-input-warn) { grid-column: 1 / -1; }
#stage:not(.menu-portrait) #flow-players :is(.seat-row, #split-count-row) { padding: 10px 12px; }
#stage #flow-players.can-scroll::after { bottom: calc(72px + var(--safe-bottom)); }
/* Each seat already identifies missing input; avoid repeating the same warning
   below the grid where it steals space from the last row on short screens. */
#stage #flow-players #start-input-warn { display: none; }

/* Studio choices are selectable tiles, distinct from cream navigation actions. */
#stage #menu .studio-option {
  position: relative; min-height: 44px; padding: 10px 26px 10px 12px;
  background: rgb(255 243 220 / 6%); color: var(--menu-cream);
  border: 0; border-radius: 12px; box-shadow: none;
  font-size: 14px; line-height: 1.35; white-space: normal;
}
#stage #menu .studio-option[aria-pressed="true"] {
  background: rgb(255 198 75 / 12%); color: var(--menu-cream);
}
#stage #menu .studio-option[aria-pressed="true"]::after {
  content: ''; position: absolute; right: 10px; top: 50%;
  width: 5px; height: 9px; border: solid var(--menu-gold); border-width: 0 2px 2px 0;
  transform: translateY(-65%) rotate(45deg);
}
@media (hover: hover) {
  #stage #menu .studio-option:hover { background: rgb(255 243 220 / 11%); }
  #stage #menu .studio-option[aria-pressed="true"]:hover { background: rgb(255 198 75 / 18%); }
}
#stage #menu .studio-screen[data-studio-detail="number"] .studio-option { padding: 10px 16px 10px 4px; }
#stage #menu .studio-screen[data-studio-detail="number"] .studio-option::after { right: 5px; width: 3px; height: 6px; }

/* List fields (type, accessory, body, livery): a row per part with the photo
   of the roster racer it comes from on the left, its name on the right, and a
   lock on the photo while that racer is unclaimed. */
#stage #menu .studio-option-grid.has-thumbs { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
#stage #menu .studio-option-grid.has-thumbs .studio-option {
  display: flex; align-items: center; gap: 12px; min-height: 64px;
  padding: 6px 30px 6px 6px; text-align: left;
}
#stage #menu .studio-option-thumb {
  position: relative; flex: 0 0 52px; width: 52px; height: 52px;
  border-radius: 9px; overflow: hidden; background: rgb(255 243 220 / 8%);
}
#stage #menu .studio-option-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* The catalog photos frame the whole racer with room to spare: fill the tile. */
#stage #menu .studio-option-grid[data-field="type"] .studio-option-thumb img { transform: scale(1.45); transform-origin: 50% 58%; }
#stage #menu .studio-option-grid:is([data-field="style"], [data-field="livery"]) .studio-option-thumb img { transform: scale(1.4); }
/* An accessory sits on the head or neck: zoom the photo in on it. */
#stage #menu .studio-option-grid[data-field="accessory"] .studio-option-thumb img {
  transform: scale(1.75); transform-origin: 50% 24%;
}
#stage #menu .studio-option-lock {
  display: none; position: absolute; right: 2px; bottom: 1px; font-size: 14px;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 70%));
}
#stage #menu .studio-option.locked .studio-option-lock { display: block; }
#stage #menu .studio-option.locked .studio-option-thumb img { filter: saturate(0.35) brightness(0.72); }
#stage #menu .studio-option.locked .studio-option-label { opacity: 0.62; }

#stage .rotatable-preview { touch-action: pan-y; cursor: grab; }
#stage .rotatable-preview:active { cursor: grabbing; }
#stage .rotatable-preview:focus-visible { outline: 2px solid var(--menu-gold); outline-offset: -3px; }
#stage .racer-details-art { position: relative; aspect-ratio: 1; align-self: start; overflow: hidden;
  background: radial-gradient(ellipse 100% 100% at 50% 125%, #30263d26 99.5%, transparent 100%), var(--racer-backdrop, #a4dedf); }
#stage #racer-details-preview { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; }
#stage .racer-details-art [hidden] { display: none; }

/* Shared settings controls: labels and switches above roomy, full-width inputs. */
#stage #settings .setting-row:has(> .toggle),
#stage #settings .setting-row.setting-row-audio:has(> .toggle) {
  display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 12px; align-items: center;
}
#stage #settings .setting-row > .setting-label { min-width: 0; width: auto; }
#stage #settings .setting-row > button.toggle {
  position: relative; width: 64px; min-width: 64px; height: 44px; min-height: 44px;
  padding: 0; margin: 0; background: transparent; border: 0; box-shadow: none;
  font-size: 0; color: transparent; justify-self: end;
}
#stage #settings button.toggle::before {
  content: ''; position: absolute; inset: 6px 2px; border-radius: 999px;
  background: var(--menu-gold); transition: background .15s;
}
#stage #settings button.toggle::after {
  content: ''; position: absolute; top: 10px; left: 34px; width: 24px; height: 24px;
  border-radius: 50%; background: #30263d; transition: left .15s, background .15s;
}
#stage #settings button.toggle.off::before { background: rgb(255 243 220 / 16%); }
#stage #settings button.toggle.off::after { left: 6px; background: var(--menu-cream); }
#stage #settings .setting-row:has(> input[type="range"]) { row-gap: 8px; margin-bottom: 20px; }
#stage #settings .setting-row > input[type="range"] { grid-column: 1 / -1; width: 100%; min-width: 0; margin: 0; }
#stage :is(#settings, #track-panel) .seg-toggle:not(.settings-nav) { background: rgb(255 243 220 / 6%); border: 0; box-shadow: none; }
#stage #settings .setting-row > .seg-toggle { background: rgb(255 243 220 / 6%); width: 100%; }
#stage #settings .setting-row.setting-row-segmented { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
#stage #track-panel .track-row:has(input[type="range"]) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
#stage #track-panel .track-row > input[type="range"] { grid-column: 1 / -1; grid-row: 2; width: 100%; min-width: 0; margin: 0; }
#stage #track-panel .track-row > .track-val { grid-column: 2; grid-row: 1; }
@media (prefers-reduced-motion: reduce) { #stage #settings button.toggle::before, #stage #settings button.toggle::after { transition: none; } }
