.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding: 32px 16px;
}

.screen-panel {
  width: min(640px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 24px;
}

.screen-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: var(--accent);
  text-transform: uppercase;
}

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.progress {
  width: 100%;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}

/* Developer track view (M3). */
.track-list button.link {
  background: none; border: none; padding: 0; color: inherit; font: inherit;
  text-decoration: underline; cursor: pointer;
}
.dev-view { position: fixed; inset: 0; background: #000; }
.dev-canvas { width: 100%; height: 100%; display: block; }
.dev-status {
  position: absolute; left: 12px; bottom: 8px; margin: 0; padding: 4px 8px;
  color: #fff; background: rgba(0, 0, 0, 0.5); font: 13px/1.4 system-ui, sans-serif;
}
.dev-back { position: absolute; right: 12px; top: 12px; }
.dev-hud {
  position: absolute; left: 12px; top: 8px; margin: 0; padding: 4px 8px;
  color: #fff; background: rgba(0, 0, 0, 0.5); font: 600 15px/1.4 ui-monospace, monospace;
}

/* Menus (M7). */
.pick-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.pick-list .pick { width: 100%; text-align: left; }
.pick-list .pick.selected { outline: 2px solid var(--accent); }
.form-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
.laps-input { width: 4em; }
table.results { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.results th, table.results td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--panel-edge); }
table.results tr.player td { color: var(--accent); font-weight: 600; }

/* The race (M7). */
.race-view { position: fixed; inset: 0; background: #000; overflow: hidden; }
.race-canvas { width: 100%; height: 100%; display: block; }
.race-loading { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.race-loading-art { max-width: 100%; max-height: 100%; width: auto; height: 100%; object-fit: contain; image-rendering: pixelated; }
.race-loading-text { position: absolute; bottom: 16px; margin: 0; color: #fff; font: 600 16px/1.4 system-ui, sans-serif; text-shadow: 0 1px 2px #000; }
/* The drag race's Christmas tree (ui/drag-tree.js): two lanes of seven lamps, labels between. */
.drag-tree { position: absolute; z-index: 3; top: 8px; right: 10px; padding: 6px 8px; background: rgba(0, 0, 0, 0.55); border: 1px solid #555; color: #cfcfcf; font: 600 12px/1 ui-monospace, monospace; }
.drag-row, .drag-marks { display: grid; grid-template-columns: 18px 84px 18px; align-items: center; justify-items: center; height: 18px; }
.drag-marks { height: 14px; font-size: 10px; color: #fff; }
.drag-label { font-size: 11px; }
.drag-slip { display: grid; grid-template-columns: 1fr 26px 1fr; align-items: center; justify-items: center; height: 16px; color: #fff; font-size: 11px; }
.drag-row + .drag-slip { margin-top: 4px; }
.drag-time { font-variant-numeric: tabular-nums; }
.drag-lamp { width: 13px; height: 13px; border-radius: 50%; background: #262626; border: 1px solid #000; box-shadow: inset 0 0 2px #000; }
.drag-lamp.lit { background: var(--lit); box-shadow: 0 0 8px var(--lit); }
.race-hud { position: absolute; z-index: 3; top: 4px; left: 6px; color: #fff; font: 600 15px/1.35 ui-monospace, monospace; image-rendering: pixelated; }
/* The toggleable FPS counter: a small debug panel in the top right, below the drag tree. */
.fps-counter { position: absolute; z-index: 3; top: 8px; right: 10px; display: grid; gap: 4px; padding: 6px 8px; background: rgba(0, 0, 0, 0.55); border: 1px solid #555; color: #cfcfcf; font: 600 12px/1.4 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.fps-counter[hidden] { display: none; }
.fps-sub { font-size: 11px; font-weight: 400; color: #9f9f9f; }
.fps-graph { display: block; width: 200px; height: 48px; }
/* On a drag strip the Christmas tree sits in the top right, so the counter drops below it. */
.drag-tree:not([hidden]) ~ .fps-counter { top: 84px; }
.race-gauges { position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.race-pause { position: absolute; z-index: 10; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(0, 0, 0, 0.55); }
.race-pause[hidden], .race-loading[hidden] { display: none; }
.load-report { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; padding: 18px 22px; }
.load-report h1 { margin: 0 0 6px; font-size: 20px; color: var(--accent, #f2c14e); }
.load-report ul { margin: 10px 0 16px; padding-left: 18px; font: 13px/1.5 ui-monospace, monospace; }
.race-replay-overlay { position: absolute; inset: 0; z-index: 20; background: #000; }
.race-pause-title { margin: 0; color: #fff; font: 800 36px/1 system-ui, sans-serif; text-transform: uppercase; }
/* Entering a headset (src/ui/vr-button.js); shown only where the browser can. */
.vr-button[hidden] { display: none; }
.race-vr { position: absolute; z-index: 4; left: 50%; top: 10px; transform: translateX(-50%); padding: 0.5em 1.4em; background: rgba(0, 0, 0, 0.62); border-color: var(--accent); color: #fff; font-weight: bold; }

/* The classic skin (src/ui/frame.js): the game's 640 x 480 menu art, scaled to fit. */
.stage-view { position: fixed; inset: 0; background: #000; overflow: hidden; display: grid; place-items: center; }
.stage { position: relative; flex: none; width: 640px; height: 480px; transform: scale(var(--stage-scale, 1)); transform-origin: center; color: #fff; font-size: 13px; }
.stage-backdrop { position: absolute; inset: 0; width: 640px; height: 480px; user-select: none; }
.stage-panel { position: absolute; overflow: auto; padding: 6px 8px; background: rgba(0, 0, 0, 0.62); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 3px; }
.stage-panel h2 { font-size: 15px; margin: 6px 0; color: #f2c14e; }
.stage-panel p { margin: 4px 0; line-height: 1.3; }
.stage-panel button { padding: 3px 10px; font-size: 13px; border-radius: 3px; }
.stage-panel .pick-list { grid-template-columns: 1fr; gap: 2px; margin: 0 0 6px; }
.stage-panel .pick-list .pick { padding: 2px 8px; }
.stage-panel .form-row { gap: 8px; margin: 6px 0; }
.stage-panel table.results { margin: 0; font-size: 12px; }
.stage-panel table.results th, .stage-panel table.results td { padding: 2px 5px; }
.stage-panel select, .stage-panel input { font-size: 13px; }
.stage-hotspot { position: absolute; padding: 0; border: 0; border-radius: 16px; background: transparent; cursor: pointer; }
.stage-hotspot:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }
.stage-hotspot:focus-visible { outline: 2px solid #f2c14e; }
.stage-hotspot:disabled { cursor: default; }
.garage-dot { position: absolute; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.garage-dot:hover { background: rgba(255, 255, 255, 0.15); }
.garage-dot.on { box-shadow: 0 0 0 2px #f2c14e, 0 0 8px 2px rgba(242, 193, 78, 0.8); }
.garage-slider { position: absolute; margin: 0; padding: 0; accent-color: #f2c14e; background: transparent; opacity: 0.9; }
.garage-race { position: absolute; left: 16px; top: 296px; }
.stage-panel .tabs { flex-direction: column; margin: 0; }
.stage-panel .tabs button { width: 100%; }
.stage-panel-first, .stage-panel-second { background: transparent; border: 0; overflow: hidden; }
.stage-panel .menu { flex-direction: column; align-items: stretch; }
.stage-panel .menu { gap: 4px; }
.stage-panel .menu button { padding: 2px 8px; }
.stage-panel-menu > p { margin: 0 0 4px; }
.screen-utility { position: fixed; z-index: 20; top: 14px; right: 14px; }
.stage-utility { position: absolute; z-index: 20; top: 10px; right: 10px; padding: 5px 12px; background: rgba(0, 0, 0, 0.72); }
/* The note that the game is saved for starting without its server (src/ui/offline-note.js). */
.offline-note { position: fixed; z-index: 30; left: 16px; bottom: 16px; max-width: min(30em, calc(100vw - 32px)); padding: 0.7em 1em; border: 1px solid var(--accent); border-radius: var(--radius); background: rgba(8, 10, 13, 0.92); color: var(--text); line-height: 1.4; cursor: pointer; }
.offline-note strong { color: var(--accent); }
/* "Enter VR" on the menus, beside Options. */
.screen-vr { position: fixed; z-index: 20; top: 14px; right: 124px; border-color: var(--accent); }
.stage-vr { position: absolute; z-index: 20; top: 10px; right: 92px; padding: 5px 12px; background: rgba(0, 0, 0, 0.72); border-color: var(--accent); white-space: nowrap; }

/* The controls below sit inside labelled openings already present in the classic BMPs. */
.stage-panel-name, .stage-panel-skill, .stage-panel-truck, .stage-panel-message,
.stage-panel-lengthLabel, .stage-panel-length, .stage-panel-opponents, .stage-panel-preview, .stage-panel-weather,
.stage-panel-summary, .stage-panel-tracks {
  padding: 0; border: 0; border-radius: 0; background: transparent; overflow: hidden;
}
.stage-panel-name input, .stage-panel-skill select, .stage-panel-truck select,
.stage-panel-length input, .stage-panel-weather select, .stage-panel-tracks select {
  width: 100%; height: 100%; margin: 0;
}
.stage-panel-message { background: transparent; }
.driver-message { font-size: 11px; }
.truck-preview-canvas { display: block; width: 100%; height: 100%; }
.truck-preview { width: 100%; max-width: 360px; aspect-ratio: 242 / 184; margin: 12px 0; border: 1px solid var(--panel-edge); }
.truck-preview-placeholder { min-height: 160px; display: grid; place-items: center; margin: 12px 0; border: 1px dashed var(--panel-edge); color: var(--muted); text-align: center; }

.stage-panel-list { padding: 0; border: 0; border-radius: 0; background: transparent; }
.race-track-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.race-track-table td { padding: 3px 5px; border: 0; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.race-track-table td:first-child { width: 56%; }
.race-track-table tr:hover td { background: rgba(255, 255, 255, 0.18); }
.race-track-table tr.selected td { background: #293a92; color: #fff; }
.stage-panel-list .race-track-table { font-size: 10px; line-height: 1.05; }
.stage-panel-list .race-track-table td { padding: 1px 5px; }
.stage-panel-opponents .opponents-button { width: 100%; height: 100%; padding: 0; border: 0; border-radius: 12px; background: transparent; }
.stage-panel-opponents .opponents-button:hover { background: rgba(255, 255, 255, 0.16); }
.track-preview { display: block; width: 100%; height: 100%; object-fit: fill; image-rendering: auto; }
.track-preview-modern { width: 257px; height: 210px; margin: 12px 0; background: #000; }
.track-preview[hidden], .track-info[hidden] { display: none; }
/* A track without a picture: its facts in the picture's place. */
.track-info { box-sizing: border-box; width: 100%; height: 100%; overflow: hidden; padding: 6px 8px 22px; color: #fff; font-size: 11px; line-height: 1.25; background: linear-gradient(#10183a, #050812); text-shadow: 0 1px 2px #000; }
.track-info-name { margin: 0 0 5px; font-size: 14px; font-weight: 700; color: #ffd84a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-info dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; margin: 0; }
.track-info dt { color: #9fb2ff; }
.track-info dd { margin: 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.race-length { text-align: center; }
.stage-panel-lengthLabel { display: grid; place-items: center end; padding: 0 4px 0 0; border: 0; background: transparent; }
.race-length-label { color: #fff; font-weight: 700; text-shadow: 0 1px 3px #000; }

.garage-summary { display: inline-block; width: 100%; color: #fff; font-weight: 700; text-transform: lowercase; text-align: center; text-shadow: 0 1px 3px #000; }
.stage-panel-summary { display: grid; align-items: center; }

.stage-panel-table { padding: 0; border: 0; border-radius: 0; background: transparent; }
.stage-panel-table .hall-results { font-size: 11px; table-layout: fixed; }
.stage-panel-table .hall-results td { padding: 2px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 0; }
.stage-panel-table .hall-results td:nth-child(1) { width: 9%; }
.stage-panel-table .hall-results td:nth-child(2) { width: 21%; }
.stage-panel-table .hall-results td:nth-child(3) { width: 26%; }
.stage-panel-table .hall-results td:nth-child(4) { width: 22%; }
.stage-panel-table .hall-results td:nth-child(5) { width: 10%; }
.stage-panel-table .hall-results td:nth-child(6) { width: 12%; }
.stage-panel-table .winners-table { width: 100%; height: 100%; table-layout: fixed; color: #111; font-size: 10px; line-height: 1; }
.stage-panel-table .winners-table td { padding: 1px 3px; border: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stage-panel-table .winners-table tr.player td { color: #213a9a; }
.stage-panel-table .winners-table td:nth-child(1) { width: 8%; }
.stage-panel-table .winners-table td:nth-child(2) { width: 17%; }
.stage-panel-table .winners-table td:nth-child(3) { width: 26%; }
.stage-panel-table .winners-table td:nth-child(4) { width: 16%; }
.stage-panel-table .winners-table td:nth-child(5) { width: 10%; }
.stage-panel-table .winners-table td:nth-child(6) { width: 11%; }
.stage-panel-table .winners-table td:nth-child(7) { width: 12%; }

dialog { color: var(--text); background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius); }
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.options-modal { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: hidden; }
.options-modal-title { padding: 18px 22px 8px; border-bottom: 1px solid var(--panel-edge); }
.options-modal-title h1 { margin: 0; color: var(--accent); text-transform: uppercase; }
.options-modal-panel { max-height: calc(100vh - 112px); padding: 18px 22px; overflow: auto; }
.options-footer { position: sticky; bottom: -18px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin: 18px -22px -18px; padding: 14px 22px; background: var(--panel); border-top: 1px solid var(--panel-edge); }
.bindings .form-row { align-items: center; }
.binding-label { min-width: 180px; }
.opponents-modal { width: min(720px, calc(100vw - 32px)); }
.opponent-lists { display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr); gap: 14px; align-items: center; }
.opponent-lists label { display: grid; gap: 6px; }
.opponent-lists select { min-height: 260px; }
/* Add, Remove and Remove all in the middle of the column, Fill at its foot. */
.opponent-moves { display: flex; flex-direction: column; justify-content: center; gap: 10px; align-self: stretch; padding-top: 22px; }
.opponent-moves-group { display: grid; gap: 10px; margin: auto 0; }

@media (max-width: 620px) {
  .opponent-lists { grid-template-columns: 1fr; }
  .opponent-moves { flex-direction: row; flex-wrap: wrap; gap: 10px; padding-top: 0; }
  .opponent-moves-group { grid-template-columns: 1fr 1fr 1fr; margin: 0; flex: 1 1 100%; }
}
.gold-overlay { position: absolute; image-rendering: pixelated; background: rgba(0, 0, 0, 0.35); }
.gold-overlay[hidden] { display: none; }
.gold-fps { right: 6px; top: 4px; }
.gold-z { right: 6px; top: 40px; }
.race-minimap { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.race-cockpit, .race-finder { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
.race-cockpit { z-index: 2; }
.race-finder { z-index: 3; }
.race-mirror { position: absolute; z-index: 2; pointer-events: none; }
/* The 640 x 480 caption canvas keeps its shape, at the bottom of the view: the letters are the game's size against the height. */
.race-caption { position: absolute; z-index: 4; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; pointer-events: none; image-rendering: pixelated; }
.race-caption[hidden] { display: none; }
.replay-controls { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; background: rgba(8, 10, 8, 0.78); color: #e8e8e8; font: 600 13px system-ui, sans-serif; }
.replay-controls button, .replay-controls select { font: inherit; padding: 3px 8px; }
.replay-scrub { flex: 1 1 200px; min-width: 120px; }
.replay-time, .replay-speed { min-width: 4.5em; font-variant-numeric: tabular-nums; }
.replay-view .race-caption { inset: 0 0 auto 0; height: calc(100% - 44px); }

.name-tags { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.name-tag { position: absolute; left: 0; top: 0; white-space: nowrap; font: 600 13px/1 Arial, sans-serif; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
/* Hockey's team colour over a truck: larger, in that colour. */
.name-tag.name-tag-mark { font-size: 16px; font-weight: 700; }

/* Winner's Circle and Hall of Fame: the game's yellow italic text beside the truck previews. */
.stage-panel-lit { pointer-events: none; }
.winner-lit { display: block; width: 100%; height: 100%; pointer-events: none; }
.stage-panel-firstName, .stage-panel-secondName, .stage-panel-firstStats, .stage-panel-secondStats, .stage-panel-hallInfo, .stage-panel-hallStats {
  font: 15px/25px Arial, Helvetica, sans-serif; color: #f4e66a; text-shadow: 1px 1px 0 #000; white-space: nowrap;
}
/* These panels sit straight on the artwork: no dark box, no border. */
.stage-panel-lit, .stage-panel-firstPreview, .stage-panel-secondPreview, .stage-panel-firstName, .stage-panel-secondName, .stage-panel-firstStats,
.stage-panel-secondStats, .stage-panel-hallInfo, .stage-panel-hallStats, .stage-panel-hallPreview {
  background: none; border: 0; border-radius: 0; padding: 0; overflow: hidden;
}
.winner-label { color: #fff; display: inline-block; min-width: 46px; }
.stage-panel-firstPreview canvas, .stage-panel-secondPreview canvas, .stage-panel-hallPreview canvas { display: block; width: 100%; height: 100%; }
.place-icon { display: block; height: 14px; width: auto; }
.hall-results tr { cursor: pointer; }
.stage-panel-table .hall-results tr.selected td { background: #0a1fe0; color: #fff; }

/* The modern skin: the classic layout on a plain stage that draws what the art would. */
.stage-view-modern { background: #0b0d12; }
.stage-modern { background: radial-gradient(120% 90% at 30% 20%, #2a3550 0%, #151a26 55%, #0b0d12 100%); border: 1px solid #2c3346; border-radius: 6px; box-shadow: 0 0 40px rgba(0, 0, 0, 0.6); }
.stage-title { position: absolute; left: 22px; top: 14px; margin: 0; font: italic 800 40px/1 var(--font-heading); letter-spacing: 1px; color: #e9eefc; text-shadow: 2px 2px 0 #3a5bbf, 4px 4px 0 rgba(0, 0, 0, 0.6); text-transform: uppercase; }
.stage-title-plain { text-transform: none; font-style: normal; font-weight: 700; }
/* The Start screen: a photo fills the stage (credit in README.md), the four switches run along its foot. */
.stage-scene-start { background: linear-gradient(rgba(0, 0, 0, 0) 62%, rgba(0, 0, 0, 0.6)), url("../assets/start-background.webp") center / cover #0b0d12; }
.stage-scene-start .stage-title { text-shadow: 2px 2px 0 #1c2f73, 4px 4px 0 rgba(0, 0, 0, 0.6); }
.stage-modern.stage-scene-start .stage-panel-main { padding: 0; border: 0; background: none; overflow: visible; }
.stage-scene-start .start-actions { flex-direction: row; flex-wrap: nowrap; align-items: stretch; gap: 8px; height: 100%; }
.stage-scene-start .start-actions button { flex: 1; padding: 0 8px; font-size: 14px; }
.stage-scene-start .start-actions button:not(.primary) { background: rgba(10, 14, 24, 0.78); }
.stage-credit { position: absolute; right: 24px; bottom: 12px; margin: 0; font-size: 10px; line-height: 1.2; color: #e9eefc; text-shadow: 0 1px 2px #000; }
.stage-credit a { color: inherit; }
.stage-label { position: absolute; display: grid; place-items: center; font: 700 12px/1 Arial, sans-serif; color: #f2c14e; text-transform: uppercase; letter-spacing: 0.5px; pointer-events: none; }
.stage-modern .stage-panel { background: rgba(10, 14, 24, 0.72); border: 1px solid rgba(160, 180, 230, 0.35); border-radius: 4px; }
.stage-modern .stage-panel-lit { background: none; border: 0; }
.stage-button { position: absolute; padding: 0 6px; border: 1px solid #6c7fb3; border-radius: 8px; background: linear-gradient(#56637f, #2b3348); color: #fff; font: italic 700 13px/1.1 Arial, sans-serif; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.stage-button:hover:not(:disabled) { background: linear-gradient(#6a7aa0, #364163); }
.stage-button:disabled { opacity: 0.45; cursor: default; }
.stage-button.current { background: linear-gradient(#2b3348, #1a2030); color: #f2c14e; border-color: #f2c14e; }
.stage-button.go { border-radius: 22px; font-size: 20px; color: #9cf27a; }
/* The Races screen's way into a drag weekend, and the weekend's own screen (ui/screens/drag-event.js). */
.stage-event { position: absolute; z-index: 20; top: 10px; right: 236px; padding: 5px 12px; background: rgba(0, 0, 0, 0.72); }
.stage-event[hidden] { display: none; }
.drag-event { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; }
.drag-event-head { margin: 0; font-weight: 700; font-size: 15px; color: #f2c14e; }
.drag-event-note { margin: 0; min-height: 17px; }
.drag-event-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.stage-panel table.drag-event-table td:nth-child(n+4), .stage-panel table.drag-event-table th:nth-child(n+4) { text-align: right; font-variant-numeric: tabular-nums; }
.drag-event-table th { color: #f2c14e; font-size: 10px; text-transform: uppercase; }
.drag-bracket { display: flex; gap: 8px; align-items: stretch; }
.drag-round { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-around; gap: 4px; }
.drag-round h2 { margin: 0; font-size: 11px; text-transform: uppercase; }
.drag-pair { border: 1px solid rgba(160, 180, 230, 0.35); border-radius: 3px; background: rgba(255, 255, 255, 0.04); }
.drag-pair.current { border-color: #f2c14e; box-shadow: 0 0 6px rgba(242, 193, 78, 0.6); }
.drag-pair-line { display: flex; justify-content: space-between; gap: 6px; min-height: 15px; padding: 0 4px; font-size: 11px; white-space: nowrap; overflow: hidden; }
.drag-pair-line + .drag-pair-line { border-top: 1px solid rgba(160, 180, 230, 0.2); }
.drag-pair-line.won { font-weight: 700; color: #9cf27a; }
.drag-pair-line.player span:first-child { color: #f2c14e; }
.drag-event-actions { justify-content: flex-end; gap: 8px; }
.stage-back { position: absolute; z-index: 20; top: 10px; right: 96px; padding: 5px 12px; background: rgba(0, 0, 0, 0.72); }

/* Options: tabs by category, and rows of one height. */
.options-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-right: auto; }
/* The ways out to other screens, in the light blue of the menus' own buttons (Driver Check-in). */
.options-nav button.nav { border: 1px solid #6c7fb3; background: linear-gradient(#56637f, #2b3348); color: #fff; font-weight: 700; }
.options-nav button.nav:hover:not(:disabled) { border-color: #9fb0e0; background: linear-gradient(#6a7aa0, #364163); }
.options-footer button.unsaved { border-color: var(--accent); color: var(--accent); }
.options-sub { width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto; }
.options-sub h2 { margin: 0 0 10px; color: var(--accent); }
.options-sub-list { display: grid; gap: 6px; }
.options-sub-list input[type="text"] { width: 100%; }
.options-sub-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.opt-tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--panel-edge); }
.opt-tab { padding: 8px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; background: transparent; color: var(--muted, #aab); }
.opt-tab.selected { background: var(--panel, #1a2030); border-color: var(--panel-edge); color: var(--accent, #f2c14e); }
/* Every page the same size, whatever it holds: a longer one scrolls. */
.opt-pages { height: min(470px, calc(100vh - 230px)); overflow-y: auto; padding-right: 4px; }
.opt-page[hidden] { display: none; }
.opt-page { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 6px 18px; align-content: start; }
.opt-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 1px solid var(--panel-edge); border-radius: 6px; background: rgba(255, 255, 255, 0.03); }
.opt-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-control { display: flex; justify-content: flex-end; align-items: center; min-width: 0; }
.opt-control select { width: 100%; height: 26px; }
.opt-slider { display: flex; align-items: center; gap: 8px; width: 100%; }
.opt-slider input { flex: 1; min-width: 0; }
.opt-value { width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.opt-switch { width: 18px; height: 18px; }
.opt-fixed { color: var(--muted, #aab); }
.opt-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.opt-page > .muted, .opt-page > .bindings, .opt-page > .opt-switches { grid-column: 1 / -1; }
.opt-page > h3 { grid-column: 1 / -1; margin: 10px 0 2px; font-size: 13px; color: var(--muted, #aab); text-transform: uppercase; letter-spacing: 0.05em; }
.opt-page > h3:first-child { margin-top: 0; }
.opt-page > .opt-switches { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 6px 18px; }
.opt-page > .opt-switches:empty { display: none; }
.opt-page > .bindings { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 6px 18px; }
.opt-page > .bindings .form-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; height: 36px; margin: 0; padding: 0 10px; border: 1px solid var(--panel-edge); border-radius: 6px; }
/* On the modern stage the controls that sit in the art's openings have no box of their own either. */
.stage-modern :is(.stage-panel-name, .stage-panel-skill, .stage-panel-truck, .stage-panel-message, .stage-panel-sonic, .stage-panel-lengthLabel,
  .stage-panel-length, .stage-panel-opponents, .stage-panel-weather, .stage-panel-weatherLabel, .stage-panel-tracks, .stage-panel-list) { background: none; border: 0; }
.stage-panel-weatherLabel { display: grid; place-items: center end; padding: 0 4px 0 0; }
.stage-panel-sonic { padding: 0; border: 0; background: transparent; display: flex; align-items: center; }
.sonic-trucks { display: flex; align-items: center; gap: 6px; color: #fff; font-weight: 700; text-shadow: 0 1px 3px #000; }
.race-track-table th { padding: 2px 5px; font: 700 10px/1.2 Arial, sans-serif; color: #f2c14e; text-transform: uppercase; text-align: center; border-bottom: 1px solid rgba(160, 180, 230, 0.35); }
.stage-modern .stage-panel-list .race-track-table { background: rgba(10, 14, 24, 0.72); }
.stage-modern .stage-panel-opponents .opponents-button { border: 1px solid #6c7fb3; background: linear-gradient(#56637f, #2b3348); color: #fff; font-weight: 700; }
.stage-modern .garage-dot { border: 2px solid #6c7fb3; background: rgba(10, 14, 24, 0.7); }
.stage-modern .garage-dot.on { background: #f2c14e; }
/* Winner's Circle on the modern stage: the data stands on its own, and the list is light on dark. */
.stage-modern :is(.stage-panel-firstName, .stage-panel-firstStats, .stage-panel-secondName, .stage-panel-secondStats) { background: none; border: 0; font-size: 13px; line-height: 18px; }
.stage-modern :is(.stage-panel-firstName, .stage-panel-secondName) .winner-line { overflow: hidden; text-overflow: ellipsis; }
/* The Hall of Fame's selected entry stands on the stage too, with no box behind it. */
.stage-modern :is(.stage-panel-hallInfo, .stage-panel-hallStats, .stage-panel-hallPreview) { background: none; border: 0; }
.stage-modern .stage-panel-table .winners-table { color: #fff; }
.stage-modern .stage-panel-table .winners-table tr.player td { color: #f2c14e; }
.stage-modern .stage-panel-table .winners-table th { color: #f2c14e; font-size: 9px; text-align: left; padding: 2px 3px; border-bottom: 1px solid rgba(160, 180, 230, 0.35); }
.stage-modern .stage-panel-table .hall-results { color: #fff; }
.stage-modern .stage-panel-table .hall-results th { color: #f2c14e; font-size: 9px; text-align: left; }

/* POD manager (ui/pod-manager.js). */
.pod-manager { width: min(980px, calc(100vw - 32px)); }
.pod-manager-list { max-height: calc(100vh - 260px); overflow: auto; border: 1px solid var(--panel-edge); border-radius: 6px; }
.pod-manager table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pod-manager th, .pod-manager td { padding: 5px 8px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--panel-edge); }
.pod-manager th { position: sticky; top: 0; background: var(--panel); color: var(--muted, #aab); font-weight: normal; }
.pod-manager td.num, .pod-manager th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pod-manager td.pod-actions { text-align: right; }
.pod-manager td.pod-actions button { min-width: 0; margin-left: 4px; padding: 2px 8px; }

/* The Races screen's Mode list: the list on the bottom row, its label beside it. */
.stage-panel-mode, .stage-panel-modeLabel, .stage-modern .stage-panel-mode, .stage-modern .stage-panel-modeLabel { padding: 0; border: 0; border-radius: 0; background: none; }
.stage-panel-mode select { width: 100%; height: 100%; margin: 0; }
.stage-panel-modeLabel { display: grid; place-items: center end; padding: 0 4px 0 0; overflow: visible; }

/* The track filter above the Races list. */
.race-track-filter { display: block; box-sizing: border-box; width: 100%; height: 22px; margin: 0; padding: 1px 6px; font: inherit; font-weight: 700; border: 1px solid #6c7fb3; border-radius: 0; background: #10141f; color: #fff; }
.race-track-filter::placeholder { color: #b8c0d8; font: inherit; font-weight: 700; opacity: 1; }
/* A little smaller than the list's own type, as the column headings are. */
.race-track-filter, .race-track-filter::placeholder { font-size: 0.88em; }
/* The picked track and the filter stay at the top of the list while it scrolls, and so do the column headings under them. */
.race-track-head { position: sticky; top: 0; z-index: 2; }
/* The picked track, beside the Computer Opponents button, in the type of Laps and Weather. */
.stage-panel-selected, .stage-modern .stage-panel-selected { display: grid; place-items: center start; padding: 0; overflow: hidden; border: 0; border-radius: 0; background: none; }
.race-track-selected { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.race-track-table thead th { position: sticky; top: 22px; z-index: 1; background: #10141f; }
.race-off { opacity: 0.45; }
input.race-off { background: #777; color: #222; }

/* The in-game console (ui/console.js). */
.game-console { position: absolute; z-index: 20; top: 0; left: 0; right: 0; height: 45%; min-height: 160px; display: flex; flex-direction: column; background: rgba(8, 10, 16, 0.88); border-bottom: 2px solid #f2c14e; color: #d8e0ee; font: 13px/1.35 ui-monospace, Menlo, Consolas, monospace; }
.game-console[hidden] { display: none; }
.game-console-log { flex: 1; overflow-y: auto; padding: 6px 10px 2px; white-space: pre-wrap; }
.game-console-echo { color: #f2c14e; }
.game-console-error { color: #ff8a7a; }
.game-console-line { display: flex; align-items: center; gap: 6px; padding: 4px 10px 6px; color: #f2c14e; }
.game-console-input { flex: 1; min-width: 0; padding: 2px 4px; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; }

.race-hud[hidden] { display: none; }
/* A watched race flown free: the race's lap and clock at the top in the middle; the watched truck's times are put away. */
.race-fly-hud { position: absolute; z-index: 3; top: 4px; left: 50%; transform: translateX(-50%); image-rendering: pixelated; pointer-events: none; }
.race-fly-hud[hidden], .race-flying .race-hud { display: none; }

/* The pause menu: every button the same width. */
.race-pause > button { box-sizing: border-box; width: 220px; }
/* Zoom sits inside the track's picture, in its bottom right corner, the track's place left of it. */
.stage-panel-preview, .track-preview-modern { position: relative; }
.race-preview-foot { position: absolute; left: 4px; right: 4px; bottom: 4px; z-index: 2; display: flex; justify-content: flex-end; align-items: center; gap: 6px; pointer-events: none; }
.race-preview-foot > * { pointer-events: auto; }
.race-locale { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 1px 6px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; border-radius: 3px; background: rgba(0, 0, 0, 0.55); }
.race-locale[hidden] { display: none; }
.stage-panel .race-zoom, .race-zoom { position: static; flex: none; padding: 1px 8px; font: inherit; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 3px; background: rgba(0, 0, 0, 0.7); cursor: pointer; }
.race-zoom:hover { background: rgba(60, 80, 160, 0.85); }
.race-zoom[hidden] { display: none; }
/* MTM1's zoom map: the map bitmap as a 640 x 480 stage, the description in the game's rectangle. */
.zoom-map-modal { padding: 0; border: 2px solid #6c7fb3; background: #000; max-width: none; max-height: none; overflow: hidden; }
.zoom-map-modal::backdrop { background: rgba(0, 0, 0, 0.7); }
.zoom-map-stage { position: relative; width: min(960px, 96vw, calc(96vh * 4 / 3)); aspect-ratio: 4 / 3; container-type: inline-size; }
.zoom-map-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.zoom-map-text { position: absolute; left: 53.75%; top: 5.42%; width: 43.75%; height: 86.25%; box-sizing: border-box; overflow: auto; color: #fff; font: 700 2.1cqw/1.3 Arial, sans-serif; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.zoom-map-text p { margin: 0 0 0.6em; min-height: 0.6em; }
.zoom-map-ok { position: absolute; right: 2%; bottom: 2.5%; min-width: 12%; }
/* The DANCE code's oscilloscope, over the race. */
.gold-scope { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gold-scope[hidden] { display: none; }
/* Tournaments: the button beside Options (the Drag weekend button sits left of it), and the screen. */
.stage-event.stage-tourney { right: 96px; }
.tournament .tournament-body { display: flex; flex-direction: column; gap: 6px; overflow: auto; min-height: 0; flex: 1; }
.tournament-pick { display: grid; grid-template-columns: 230px 1fr; gap: 10px; }
.tournament-pick select { width: 100%; }
.tournament-detail p { white-space: pre-line; }
.tournament-events { margin: 4px 0; padding-left: 22px; line-height: 1.35; }
.tournament-events .tournament-next, th.tournament-next { color: #f2c14e; font-weight: 700; }
.tournament textarea { width: 360px; font: inherit; }
.tournament input[type="text"] { width: 280px; }

/* The fly camera's list of keys (ui/fly-controller.js), shown by the O key. */
.fly-keys { position: absolute; left: 16px; top: 16px; z-index: 6; padding: 10px 14px; background: rgba(0, 0, 0, 0.62); color: #e8e8e8; font: 13px/1.5 system-ui, sans-serif; border-radius: 4px; pointer-events: none; }
.fly-keys[hidden] { display: none; }
.fly-keys-font { padding: 6px 8px; image-rendering: pixelated; }
.fly-keys p { margin: 0; }
.fly-keys-title { color: var(--accent, #f2c14e); font-weight: 700; margin-bottom: 4px !important; }
.fly-key { display: inline-block; min-width: 96px; color: #fff; font-weight: 600; }
/* A name tag in the game's bitmap font is a canvas (render/name-tags.js); without the font, lines of plain text. */
.name-tag-font { image-rendering: pixelated; text-shadow: none; }
.name-tag-line { display: block; text-align: center; }

/* Tournament: the button that races sits at the far right of its row. */
.tournament .screen-actions .tournament-race { margin-left: auto; }
