/* Formula Mach typeface (15 Nov, the user's own font, Bold Italic only; respaced by tools/fixfont.mjs): every text uses it. --mono stays for the F3
   telemetry and the benchmark table, whose columns line up only in a fixed-width font. */
@font-face {
  font-family: 'Formula Mach';
  src: url('/fonts/FormulaMach-BoldItalic.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal italic;
  font-display: swap;
}
:root {
  --font: "Formula Mach", "Segoe UI", system-ui, sans-serif;
  --mono: "Consolas", ui-monospace, monospace;
  --ink: #f4f6fa;
  --dim: #aab3c2;
  --panel: rgba(12, 16, 24, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --ahead: #4aa8ff;
  --behind: #ff5a5a;
  --accent: #ffd24a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fc3ea; }
body {
  font-family: var(--font);
  font-synthesis: none; /* one face: no faux bold or slant on top of it */
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  user-select: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
/* HUD layout editor (hudlayout.js): every piece shown, outlined and grabbable while it is open. */
body.hudEditing #hud.hidden, body.hudEditing #mini.hidden { display: block !important; }
body.hudEditing #slide { opacity: 1; }
body.hudEditing #top, body.hudEditing #speed, body.hudEditing #mini, body.hudEditing #slide, body.hudEditing #board { pointer-events: auto; cursor: move; outline: 2px dashed rgba(255, 255, 255, 0.55); outline-offset: 4px; }
#hudEditBar { position: fixed; left: 50%; top: 42%; transform: translateX(-50%); z-index: 50; display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 8px; background: rgba(10, 12, 16, 0.85); font: 14px var(--font); pointer-events: auto; }
body.touch #pHud { display: none; }
#top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); text-align: center; }
#timer {
  font: 700 44px/1 var(--font);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  letter-spacing: 1px;
}
#cps { margin-top: 4px; font-size: 15px; color: var(--dim); text-shadow: 0 1px 3px #000; }
.split {
  margin-top: 6px; display: inline-block; min-width: 120px; padding: 3px 12px; border-radius: 4px;
  font: 700 22px/1.2 var(--font); background: var(--panel);
  opacity: 0; transition: opacity 0.25s;
}
.split.show { opacity: 1; }
.split.ahead { color: var(--ahead); }
.split.behind { color: var(--behind); }

#countdown {
  position: absolute; top: 38%; width: 100%; text-align: center;
  font: 800 72px/1 var(--font); text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}
/* Speedometer (15 Nov): a curved rev band (speedo.js) over big digits and the gear, white and red, on a dark tint. */
#speed {
  position: absolute; bottom: 18px; left: 20px; width: 300px; height: 170px; transform-origin: bottom left;
  font: 700 46px/1 var(--font); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  background: radial-gradient(ellipse 60% 70% at 50% 85%, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0) 75%);
}
#warp { position: absolute; left: 0; top: 0; width: 300px; height: 150px; -webkit-mask-image: radial-gradient(ellipse 50% 60% at 50% 68%, #000 55%, transparent 100%); mask-image: radial-gradient(ellipse 50% 60% at 50% 68%, #000 55%, transparent 100%); }
#machTag { position: absolute; left: 0; right: 0; top: 157px; text-align: center; font: 700 12px/1 var(--font); letter-spacing: 2px; color: #ff4a4a; }
#machTag b { color: #fff; letter-spacing: 0; font-size: 14px; }
#tacho { position: absolute; left: 0; top: 0; width: 300px; height: 125px; overflow: visible; }
#tacho .seg { fill: rgba(255, 255, 255, 0.13); }
#tacho .seg.red { fill: rgba(255, 60, 60, 0.22); }
#tacho .seg.on { fill: #fff; }
#tacho .seg.red.on { fill: #ff3b3b; }
#tacho .tick { stroke: rgba(255, 255, 255, 0.75); stroke-width: 1.5; }
#tacho .tick.red, #tacho .num.red { stroke: #ff3b3b; fill: #ff3b3b; }
#tacho .num { fill: #fff; font: 600 13px var(--font); }
#tacho .num.red { stroke: none; }
#speedRow { position: absolute; left: 0; right: 0; top: 80px; display: flex; justify-content: center; font-size: 40px; }
#speed small { font-size: 12px; margin-left: 5px; color: #ff4a4a; }
/* Four digits always: the unused leading ones are dim, so the box never stretches as the speed climbs. */
#speedZ { color: rgba(255, 255, 255, 0.28); }
#speedBox { white-space: nowrap; }
/* Gear: a big number beside the speed. Revs: a bar under it, the last fifth is the redline. */
#gear {
  position: absolute; left: 50%; top: 125px; transform: translateX(-50%); /* centred on the line from the band's 0 to its 20 */
  min-width: 24px; height: 26px; padding: 0 3px; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  font: 800 20px/1 var(--font); color: #ff3b3b; border: 2px solid rgba(255, 59, 59, 0.7); border-radius: 6px; background: rgba(0, 0, 0, 0.35);
}
#gear.shift { color: rgba(255, 255, 255, 0.35); }
/* Speedslide meter: the slide width against the ideal (centre tick); the band is where it pushes. */
/* Speedslide meter: centred under the car (15 Nov, user), clear of the speedometer. */
#slide { position: absolute; left: 50%; width: 240px; margin-left: -120px; bottom: 26px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); opacity: 0; transition: opacity 0.3s ease; }
#slide.on { opacity: 1; }
#slide::after { content: ""; position: absolute; left: 50%; top: -2px; width: 2px; height: 10px; margin-left: -1px; background: rgba(255, 255, 255, 0.6); }
#slideZone { position: absolute; left: 25%; width: 50%; top: 0; bottom: 0; border-radius: 3px; background: rgba(255, 255, 255, 0.18); }
#slideMark { position: absolute; top: -3px; width: 6px; height: 12px; margin-left: -3px; border-radius: 2px; background: var(--dim); transition: background-color 0.2s ease; }
#slideMark.push { background: var(--accent); }
#debug {
  position: absolute; left: 12px; top: 12px; padding: 8px 10px; background: var(--panel);
  font: 12px/1.45 var(--mono); white-space: pre; border-radius: 4px; /* F3 telemetry: columns need a fixed width */
}

#replayTag {
  position: absolute; top: 118px; left: 50%; transform: translateX(-50%); padding: 3px 12px;
  background: var(--panel); border-radius: 4px; color: var(--accent); font-size: 14px; white-space: nowrap;
}
#inputs {
  position: absolute; bottom: 86px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px;
  align-items: center; font: 700 11px/1 var(--font);
}
#inputs span { padding: 4px 6px; border-radius: 3px; background: var(--panel); color: var(--dim); }
#inputs span.on { background: var(--ink); color: #111; }
#inputs .steer { position: relative; width: 160px; height: 10px; background: var(--panel); border-radius: 3px; overflow: hidden; }
#inSteer { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: var(--accent); }
#help .link { text-decoration: underline; cursor: pointer; }
/* The build, bottom right: physics version and map generator version (what a replay or a bug report ran on). */
#ver {
  position: fixed; right: 10px; bottom: 6px; z-index: 5; cursor: default; /* pointer events on: the tooltip has the build */
  font: 11px var(--font); color: var(--dim); opacity: 0.7; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
#board {
  position: fixed; right: 12px; top: 44px; width: 250px; max-height: calc(100% - 110px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
  font-size: 13px;
}
#board header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
#board .title { font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 12px; color: var(--accent); }
#mapDate { color: var(--dim); font-family: var(--font); }
#boardList, #lbList { list-style: none; margin: 0; padding: 0; }
#boardList li, #boardMe .row, #lbList li, #lbMe .row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; padding: 3px 0;
  border-bottom: 1px solid var(--line);
}
#boardList li.me, #lbList li.me { color: var(--accent); }
#boardList li:not(.empty):not(.noreplay), #lbList li:not(.empty):not(.noreplay) { cursor: pointer; }
#boardList li:not(.empty):not(.noreplay):hover, #lbList li:not(.empty):not(.noreplay):hover { background: rgba(255, 255, 255, 0.06); }
#boardList .rk, #boardMe .rk, #lbList .rk, #lbMe .rk { color: var(--dim); }
#boardList .nm, #lbList .nm { display: flex; align-items: center; gap: 5px; min-width: 0; }
#boardList .nm .tx, #lbList .nm .tx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Replay kept on the server: a pixel-art outline of a video-play badge. */
.play { display: inline-block; flex: none; width: 14px; height: 10px; vertical-align: middle; image-rendering: pixelated;
  background: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2014%2010'%20shape-rendering='crispEdges'%3E%3Cpath%20fill='%23c8ccd2'%20d='M2%200h1v1h-1zM3%200h1v1h-1zM4%200h1v1h-1zM5%200h1v1h-1zM6%200h1v1h-1zM7%200h1v1h-1zM8%200h1v1h-1zM9%200h1v1h-1zM10%200h1v1h-1zM11%200h1v1h-1zM1%201h1v1h-1zM12%201h1v1h-1zM0%202h1v1h-1zM5%202h1v1h-1zM6%202h1v1h-1zM13%202h1v1h-1zM0%203h1v1h-1zM5%203h1v1h-1zM7%203h1v1h-1zM13%203h1v1h-1zM0%204h1v1h-1zM5%204h1v1h-1zM8%204h1v1h-1zM13%204h1v1h-1zM0%205h1v1h-1zM5%205h1v1h-1zM8%205h1v1h-1zM13%205h1v1h-1zM0%206h1v1h-1zM5%206h1v1h-1zM7%206h1v1h-1zM13%206h1v1h-1zM0%207h1v1h-1zM5%207h1v1h-1zM6%207h1v1h-1zM13%207h1v1h-1zM1%208h1v1h-1zM12%208h1v1h-1zM2%209h1v1h-1zM3%209h1v1h-1zM4%209h1v1h-1zM5%209h1v1h-1zM6%209h1v1h-1zM7%209h1v1h-1zM8%209h1v1h-1zM9%209h1v1h-1zM10%209h1v1h-1zM11%209h1v1h-1z'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
#boardList .tm, #boardMe .tm, #lbList .tm, #lbMe .tm { font-family: var(--font); }
#boardList .empty, #lbList .empty { display: block; color: var(--dim); border: 0; }
#boardMe, #lbMe { margin-top: 6px; color: var(--accent); }
#driver { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--dim); }
#driver button, .panel button, .home button {
  font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 10px; cursor: pointer;
}
#driver button:hover, .panel button:hover, .home button:hover { background: rgba(255, 255, 255, 0.16); }

#help {
  /* above the speed, under the chat (6 Nov: at the bottom it covered the speed before the start) */
  position: fixed; left: 12px; bottom: 76px; max-width: min(720px, calc(100% - 300px)); font-size: 12px; color: var(--ink);
  background: var(--panel); padding: 6px 10px; border-radius: 4px; opacity: 0.85;
}

.overlay { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; }
.overlay .panel {
  pointer-events: auto; min-width: 300px; text-align: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 18px 26px;
}
.overlay .label { text-transform: uppercase; letter-spacing: 2px; color: var(--accent); font-size: 13px; font-weight: 700; }
.overlay .big { font: 700 52px/1.15 var(--font); margin: 6px 0; }
.overlay .hint { margin-top: 12px; color: var(--dim); font-size: 13px; }
#finPb.ahead { color: var(--ahead); }
#finPb.behind { color: var(--behind); }
#finRank { margin-top: 6px; font-size: 18px; min-height: 2.6em; } /* two lines: "Checking your run…" turning into the rank keeps the panel's height */
#nameDlg { background: rgba(0, 0, 0, 0.35); pointer-events: auto; }
#nameInput {
  width: 100%; margin-top: 10px; padding: 8px 10px; font: 18px var(--font);
  color: var(--ink); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 4px;
}
.panel .row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.err { color: var(--behind); min-height: 1.2em; font-size: 13px; margin-top: 4px; }
.fine { color: var(--dim); font-size: 11px; max-width: 280px; margin: 12px auto 0; }

#replayTag {
  position: absolute; top: 118px; left: 50%; transform: translateX(-50%); padding: 3px 12px;
  background: var(--panel); border-radius: 4px; color: var(--accent); font-size: 14px; white-space: nowrap;
}
#inputs {
  position: absolute; bottom: 86px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px;
  align-items: center; font: 700 11px/1 var(--font);
}
#inputs span { padding: 4px 6px; border-radius: 3px; background: var(--panel); color: var(--dim); }
#inputs span.on { background: var(--ink); color: #111; }
#inputs .steer { position: relative; width: 160px; height: 10px; background: var(--panel); border-radius: 3px; overflow: hidden; }
#inSteer { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: var(--accent); }
#help .link { text-decoration: underline; cursor: pointer; }
@media (max-width: 700px) {
  #board { width: 190px; font-size: 12px; }
  #help { display: none; }
  #timer { font-size: 32px; }
  #speed { transform: scale(0.85); }
}

/* The button picked with the keyboard or a gamepad in a menu (menunav.js). */
.overlay .kbsel { outline: 2px solid var(--accent); outline-offset: 2px; background: rgba(255, 255, 255, 0.16); }

/* Pause menu: a column of full-width buttons, each showing its key. */
#pause .panel, #finish .panel { pointer-events: auto; min-width: 300px; }
#finish .panel { width: min(380px, calc(100vw - 24px)); box-sizing: border-box; } /* one width, whatever the status line says */
.stars button:disabled { cursor: default; }
.stars button:disabled:not(.on):hover { color: rgba(255, 255, 255, 0.28); }
.stars button.on:disabled:hover { color: var(--accent); }
#pause .menu, #finish .menu { display: flex; flex-direction: column; gap: 8px; }
#pause .pGroup { display: contents; } /* the main and Settings buttons sit in the panel's own column */
#pause .vol { padding: 4px 2px; }
#pause .big, #finish .big { font-size: 34px; }
#finish .menu > div:not(.label):not(.big) { text-align: center; }
#pause button, #finish button { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 15px; text-align: left; }
#pause button:disabled, #finish button:disabled { opacity: 0.4; cursor: default; }
#pause kbd, #finish kbd { font: 12px var(--font); color: var(--dim); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 4px; padding: 1px 6px; }

/* Up to 1024x768: the pause and finish menus a little tighter, so they sit clear of the clock at the top. */
@media (max-height: 860px) {
  #pause .big, #finish .big { font-size: 28px; margin: 2px 0; }
  #pause button, #finish button { padding: 7px 12px; font-size: 14px; }
  #pause .menu, #finish .menu { gap: 5px; }
  #pause .panel, #finish .panel { padding: 12px 20px; max-height: calc(100vh - 24px); overflow-y: auto; box-sizing: border-box; }
}

/* World / region tabs on the side board and the full leaderboard. */
.tabs { display: flex; gap: 4px; margin: 0 0 6px; flex-wrap: wrap; }
.tabs button { flex: 1; padding: 3px 6px; font-size: 11px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent; color: var(--dim); cursor: pointer; white-space: nowrap; }
.tabs button.on { background: rgba(255, 255, 255, 0.14); color: inherit; }
#lb .panel { pointer-events: auto; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; text-align: left; }
#lb .label { text-align: center; }
#lb .tabs { margin: 10px 0; }
#lb .tabs button { font-size: 12px; padding: 5px 8px; }
#lb .tabs button:last-child { flex-basis: 100%; } /* History: its own full row, not a stray label under the regions */
#lbList li { font-size: 14px; }

/* Paint dialog: panel list and colour presets on the left, the car in view. */
#paint { place-items: center start; padding-left: 20px; z-index: 9; } /* above the chat and the vote card */
body.painting #chat, body.painting #board { display: none; }
body.painting #voteCard { left: auto; right: 12px; width: 150px; } /* the panel holds the left edge; narrow so both fit in a 520 px window */
#paint .panel { pointer-events: auto; width: 270px; text-align: left; }
#paint .label { text-align: center; }
#paintParts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 10px 0 6px; }
#paintParts button { display: flex; align-items: center; gap: 6px; padding: 4px 6px; font-size: 11px; text-align: left; white-space: nowrap; overflow: hidden; }
#paintParts button.on { background: rgba(255, 255, 255, 0.22); outline: 1px solid var(--accent); }
#paintParts .dot, #paintSwatches button { border: 1px solid rgba(255, 255, 255, 0.35); }
#paintParts .dot { flex: none; width: 11px; height: 11px; border-radius: 3px; }
#paintSwatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 4px 0 12px; }
#paintSwatches button { height: 28px; padding: 0; border-radius: 5px; }
#paintSwatches button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
#paintPicked { margin: 2px 0; text-align: left; }
.roleSwatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 3px 0 8px; }
.roleSwatches button { height: 22px; padding: 0; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.35); }
.roleSwatches button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
#paintSchemes { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 6px; }
#paintSchemes .empty { font-size: 11px; opacity: 0.6; }
.scheme { display: flex; align-items: center; gap: 4px; }
.scheme .use { flex: 1; display: flex; align-items: center; gap: 6px; padding: 4px 6px; font-size: 11px; text-align: left; overflow: hidden; white-space: nowrap; }
.scheme .use.on { background: rgba(255, 255, 255, 0.22); outline: 1px solid var(--accent); }
.scheme .dots { flex: none; display: flex; }
.scheme .dots span { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(255, 255, 255, 0.35); margin-right: 2px; }
.scheme .del { flex: none; padding: 4px 7px; font-size: 11px; }
#paintSaveRow { gap: 6px; margin-bottom: 8px; }
#paintSchemeName { flex: 1; min-width: 0; font: inherit; font-size: 12px; padding: 5px 7px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.35); color: inherit; }
#paint .row button kbd { margin-left: 8px; }
#paint .panel { max-height: calc(100vh - 40px); overflow-y: auto; }
#paintTabs { margin: 8px 0 2px; }
#paintTabs button.on, #kitPacks button.on { background: rgba(255, 255, 255, 0.22); outline: 1px solid var(--accent); }
#kitPacks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 4px 0 8px; }
#kitPacks button { padding: 4px 6px; font-size: 11px; line-height: 1.25; text-align: left; } /* long names wrap, not cut */
#kitSlots { display: grid; gap: 4px; margin: 4px 0 10px; }
.kitSlot { display: grid; grid-template-columns: 26px 1fr 26px; gap: 4px; align-items: center; }
.kitSlot button { padding: 3px 0; font-size: 12px; }
.kitSlot .kitName { font-size: 11px; line-height: 1.25; text-align: center; }
.kitSlot .kitName b { display: block; font-size: 10px; opacity: 0.7; font-weight: normal; }

/* History: a minimap, the day's top times and a replay link per past day. */
#lbHistory.hidden, #lbList.hidden { display: none; }
#lbHistory .day { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
#lbHistory canvas { width: 150px; height: 110px; flex: none; background: #1a1e24; border-radius: 6px; }
#lbHistory .info { flex: 1; min-width: 0; font-size: 12px; }
#lbHistory .info b { color: var(--accent); }
#lbHistory ol { list-style: none; margin: 4px 0 0; padding: 0; }
#lbHistory li { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 1px 0; }
#lbHistory li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbHistory li .tm, #lbHistory .archive .tm { font-family: var(--font); }
#lbHistory .play { margin-left: 5px; }
#lbHistory .archive { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.1); font-size: 12px; }
#lbHistory .archive > div:not(.label) { display: grid; grid-template-columns: 82px 1fr auto; gap: 6px; padding: 1px 0; color: var(--dim); }
#lbHistory .empty { color: var(--dim); padding: 8px 0; }

/* The start menu stands alone: no HUD, side board or key help behind it. */
body.atStart #hud, body.atStart #board, body.atStart #help { display: none; }
/* No room for the chat beside the menu on a narrow screen (1024x768): it waits until the race starts. */
@media (max-width: 1180px) { body.atStart:not(.touch) #chat { display: none; } }

/* Broadcast banner, maintenance bar, spectator strip, map ratings. */
#banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 20; max-width: min(640px, 92vw);
  display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; border-radius: 6px;
  background: rgba(12, 16, 24, 0.86); border: 1px solid var(--accent); color: var(--ink); font-size: 14px;
}
#banner button { pointer-events: auto; background: none; border: 0; color: var(--dim); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
#maint {
  position: fixed; top: 0; left: 0; right: 0; z-index: 19; padding: 5px 12px; text-align: center; font-size: 13px;
  background: #7a4b00; color: #fff3d6;
}
body.atStart #banner { top: 62px; }
#spec {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 18; padding: 6px 14px; border-radius: 6px;
  background: var(--panel); color: var(--accent); font: 600 14px/1.4 var(--font); white-space: nowrap;
}
#wrongWay { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 12; padding: 6px 22px; border-radius: 6px; background: rgba(150, 20, 28, 0.82); color: #fff; font: 800 28px/1.2 var(--font); letter-spacing: 3px; text-transform: uppercase; pointer-events: none; }
#specExit { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 19; padding: 6px 12px; border-radius: 6px; border: 0; background: var(--panel); color: var(--accent); font: 600 14px/1.4 var(--font); cursor: pointer; }
#specExit:hover { background: #26324a; }
#specMap { position: fixed; right: 14px; bottom: 14px; z-index: 19; width: 260px; height: 260px; border-radius: 8px; background: rgba(12, 17, 26, 0.82); cursor: crosshair; }
#bug { z-index: 40; background: rgba(0, 0, 0, 0.5); }
#bug:not(.hidden) { pointer-events: auto; }
#bug .panel { pointer-events: auto; background: #151b27; width: min(460px, 92vw); }
#bugText { width: 100%; box-sizing: border-box; margin: 10px 0 6px; padding: 8px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.35); color: var(--ink, #fff); font: 14px/1.4 var(--font); resize: vertical; }
#bug .check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--dim); }
#bug .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.stars { display: inline-flex; gap: 2px; align-items: center; }
.stars button { background: none; border: 0; padding: 0 1px; font-size: 20px; line-height: 1; color: rgba(255, 255, 255, 0.28); cursor: pointer; }
.stars button.on { color: var(--accent); }
.stars button:hover { color: #fff; }
.rate { display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; }
.rate small { color: var(--dim); }
#finRate { margin-top: 8px; display: flex; align-items: center; gap: 8px; justify-content: center; }
#finRate .hint { margin: 0; }

#consent {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 40; width: min(760px, 94vw);
  display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: 8px;
  background: rgba(12, 16, 24, 0.94); border: 1px solid var(--accent); color: var(--ink); font-size: 13px; line-height: 1.45;
}
#consent.hidden { display: none; }
#consent .cBtns { display: flex; flex-direction: column; gap: 8px; flex: none; }
#consent button { pointer-events: auto; cursor: pointer; padding: 7px 18px; border-radius: 5px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); color: var(--ink); font: inherit; font-weight: 600; }
#consent button.go { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
@media (max-width: 560px) { #consent { flex-direction: column; align-items: stretch; } #consent .cBtns { flex-direction: row; } #consent .cBtns button { flex: 1; } }

/* --- touch controls (touch.js) and small screens --- */
:root { --tr: clamp(56px, 9vw, 96px); } /* the steering stick's travel, as in touch.js */
#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#touch > * { pointer-events: auto; touch-action: none; }
#tLook { position: absolute; inset: 0; }
#tStickZone { position: absolute; left: 0; bottom: 0; width: 42%; height: 62%; }
#tBase {
  position: absolute; left: max(84px, 15vh); top: calc(100% - max(84px, 15vh)); width: calc(var(--tr) * 2); height: calc(var(--tr) * 2);
  transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); background: rgba(12, 16, 24, 0.25);
  pointer-events: none; transition: opacity 0.2s; opacity: 0.7;
}
#tBase.on { opacity: 1; border-color: rgba(255, 255, 255, 0.7); }
#tKnob { position: absolute; left: 50%; top: 50%; width: 44%; height: 44%; margin: -22% 0 0 -22%; border-radius: 50%; background: rgba(255, 255, 255, 0.55); }
#touch button {
  position: absolute; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 14px; background: rgba(12, 16, 24, 0.45); color: #fff;
  font: 800 15px/1 var(--font); letter-spacing: 1px; padding: 0; -webkit-tap-highlight-color: transparent;
}
#touch button.on { background: rgba(255, 255, 255, 0.38); }
#tGas { right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); width: clamp(110px, 22vw, 190px); height: clamp(100px, 40vh, 170px); background: rgba(60, 190, 100, 0.38); font-size: 20px; }
#tBrake { right: calc(max(16px, env(safe-area-inset-right)) + clamp(110px, 22vw, 190px) + 14px); bottom: max(16px, env(safe-area-inset-bottom)); width: clamp(84px, 16vw, 140px); height: clamp(80px, 28vh, 120px); background: rgba(230, 70, 70, 0.38); }
#tSlide { right: calc(max(16px, env(safe-area-inset-right)) + clamp(110px, 22vw, 190px) + 14px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + clamp(80px, 28vh, 120px) + 12px); width: clamp(84px, 16vw, 140px); height: clamp(56px, 16vh, 84px); background: rgba(90, 150, 255, 0.38); }
#tPause, #tCam, #tResp, #tTilt, #tChat { top: max(10px, env(safe-area-inset-top)); height: 46px; }
#tPause { right: max(10px, env(safe-area-inset-right)); width: 46px; font-size: 18px; }
#tCam { right: calc(max(10px, env(safe-area-inset-right)) + 56px); width: 62px; font-size: 12px; }
#tResp { right: calc(max(10px, env(safe-area-inset-right)) + 128px); width: 92px; font-size: 11px; }
#tTilt { right: calc(max(10px, env(safe-area-inset-right)) + 230px); width: 56px; font-size: 11px; }
#tChat { left: max(10px, env(safe-area-inset-left)); width: 62px; font-size: 12px; }
#tChat.on { outline: 2px solid var(--accent); }
#tTilt.on { outline: 2px solid var(--accent); }
#tStickZone.off { pointer-events: none; opacity: 0.25; }
#touch.watch > :not(#tPause):not(#tLook) { display: none; }
body.touch #board, body.touch #help { display: none; }
body.touch #speed { left: 50%; bottom: 6px; transform-origin: bottom center; transform: translateX(-50%) scale(0.72); }
@media (max-height: 520px) { body.touch #speed { transform: translateX(-50%) scale(0.55); } }
body.touch #slide { bottom: 140px; width: 180px; margin-left: -90px; }
@media (max-height: 520px) { body.touch #slide { bottom: 104px; } }
#tRotate { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(8, 12, 20, 0.86); text-align: center; font-size: 18px; line-height: 1.6; padding: 24px; }
#tRotate button { margin-top: 14px; padding: 10px 18px; font-size: 16px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.1); color: inherit; }
#sFull.hidden { display: none; }

/* Short screens (a phone on its side): everything smaller, menus scroll instead of running off. */
@media (max-height: 520px) {
  #timer { font-size: 30px; }
  #top { top: 6px; }
  #cps { font-size: 12px; margin-top: 2px; }
  #countdown { font-size: 48px; top: 30%; }
  .overlay .panel { max-height: calc(100vh - 12px); overflow-y: auto; padding: 10px 16px; }
  .overlay .big { font-size: 34px; margin: 2px 0; }
  #pause .big, #finish .big { font-size: 26px; }
  #pause button, #finish button { padding: 6px 12px; font-size: 14px; }
  #pause .menu, #finish .menu { gap: 5px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  #touch #tGas { width: 38vw; height: 22vh; }
  #touch #tBrake { right: calc(max(16px, env(safe-area-inset-right)) + 38vw + 12px); width: 22vw; height: 16vh; }
  #tBase { left: calc(var(--tr) + 12px); top: calc(100% - var(--tr) - 14px); }
  #tResp { right: auto; left: max(10px, env(safe-area-inset-left)); }
  body.touch #speed { bottom: 26vh; }
}

/* Controls dialog: opaque, over the menu behind it. */
#controls { background: rgba(0, 0, 0, 0.55); pointer-events: auto; }
#controls .panel { width: min(480px, calc(100vw - 24px)); background: rgba(12, 16, 24, 0.97); }
#controls label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
#controls label input { flex: 1; max-width: 55%; }
#controls .row { flex-wrap: wrap; }
#controls .fine { max-width: none; text-align: left; }

/* The in-game minimap (N toggles it): the whole track, you in white and the ghost in blue. */
#mini { position: absolute; top: 24%; left: 18px; width: 170px; height: 170px; }
body.touch #mini, body.atStart #mini { display: none; }
@media (max-height: 520px) { #mini { width: 110px; height: 110px; top: 18%; left: 8px; } }

/* A driver's name in a board is a button that opens their records. */
button.who, #start button.who, #lb button.who, #profile button.who, #board button.who {
  all: unset; box-sizing: border-box; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px dotted transparent;
}
button.who:hover, button.who:focus-visible { border-bottom-color: currentColor; }
#profile { background: rgba(0, 0, 0, 0.5); pointer-events: auto; }
#profile .panel { width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow-y: auto; text-align: left; background: rgba(12, 16, 24, 0.97); }
#profile .label { text-align: center; font-size: 15px; }
#profile .hint { text-align: center; }
#profList { list-style: none; margin: 8px 0 0; padding: 0; }
#profList li { display: grid; grid-template-columns: 1fr auto auto 28px; gap: 10px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
#profList .tm { font-family: var(--font); }
#profList .pl { color: var(--dim); }
#profList li.win .pl { color: var(--accent); }
#profList .pbtn { all: unset; cursor: pointer; display: inline-flex; padding: 3px 6px; border-radius: 4px; }
#profList .pbtn:hover, #profList .pbtn:focus-visible { background: rgba(255, 255, 255, 0.14); }

/* Painting on a touch screen: only the look layer, clear of the paint panel on the left. */
#touch.lookonly > :not(#tLook) { display: none; }
#touch.lookonly #tLook { left: 300px; }

/* the map rotation's clock and the chat */
#mapClock {
  position: fixed; top: 8px; right: 10px; z-index: 6; padding: 3px 9px; border-radius: 12px; cursor: pointer;
  font: 12px var(--font); color: var(--dim); background: rgba(8, 10, 16, 0.55); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
#mapClock.hidden { display: none; }
#voteCard { position: fixed; left: 12px; top: 50%; transform: translateY(-50%); z-index: 8; width: 190px; padding: 10px 12px; border-radius: 8px; background: rgba(8, 10, 16, 0.78); color: #fff; font: 13px var(--font); text-align: center; }
#voteCard.hidden { display: none; }
#voteCard .tally { margin: 4px 0 8px; color: var(--dim); font-size: 12px; }
#voteCard .btns { display: flex; gap: 10px; justify-content: center; }
#voteCard button { width: 64px; height: 44px; border-radius: 6px; border: 2px solid transparent; font-size: 24px; line-height: 1; color: #fff; cursor: pointer; }
#voteCard .yes { background: #1f8f3d; }
#voteCard .no { background: #c0392b; }
#voteCard button.picked { border-color: #fff; }
/* Chat: a grey panel, always there on a computer; on a touch screen only the messages show, and the CHAT button opens the rest. */
#chat { position: fixed; left: 12px; bottom: 150px; z-index: 7; width: min(340px, calc(100vw - 24px)); padding: 6px; box-sizing: border-box; border-radius: 6px; pointer-events: none; font: 13px var(--font); background: rgba(70, 74, 84, 0.34); border: 1px solid rgba(255, 255, 255, 0.12); }
#chat.open { background: rgba(60, 64, 74, 0.55); }
#chatHead { padding: 0 2px 4px; color: rgba(255, 255, 255, 0.85); font-weight: 600; text-shadow: 0 1px 2px #000; }
#chatHead span { margin-left: 6px; font-weight: 400; font-size: 11px; color: rgba(255, 255, 255, 0.6); }
#chatHead kbd { padding: 0 4px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 3px; font: inherit; }
#chatPin { margin: 0 0 6px; padding: 5px 7px; border-radius: 4px; background: rgba(40, 30, 0, 0.6); border: 1px solid var(--accent); color: #fff; text-shadow: 0 1px 2px #000; overflow-wrap: anywhere; }
#chatPin b { color: var(--accent); margin-right: 6px; font-weight: 700; }
body.touch #chatPin { background: rgba(40, 30, 0, 0.75); }
/* the last 30 lines scroll (wheel or drag); the first one is pushed down so a short log still sits on the input */
#chatLog { list-style: none; margin: 0 0 6px; padding: 0 2px 0 0; display: flex; flex-direction: column; min-height: 3.2em; max-height: 26vh; overflow-y: auto; overscroll-behavior: contain; pointer-events: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.35) transparent; }
#chatLog li:first-child { margin-top: auto; }
body.touch #chat:not(.open) #chatLog { overflow: hidden; pointer-events: none; }
#chatLog li { padding: 1px 4px; color: #fff; text-shadow: 0 1px 2px #000; margin-top: 1px; border-radius: 3px; transition: opacity 0.6s; overflow-wrap: anywhere; }
#chatLog li b { color: #ffd54a; margin-right: 6px; font-weight: 600; }
#chatLog li.old { opacity: 0; height: 0; padding: 0; margin: 0; overflow: hidden; }
#chatInput { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 4px; background: rgba(8, 10, 16, 0.55); color: #fff; font: inherit; pointer-events: auto; }
#chatInput::placeholder { color: rgba(255, 255, 255, 0.5); }
#chat.open #chatInput { background: rgba(8, 10, 16, 0.85); }
body.touch #chat { left: max(10px, env(safe-area-inset-left)); top: 64px; bottom: auto; width: min(46vw, 340px); background: none; border: 0; padding: 0; }
body.touch #chat.open { background: rgba(60, 64, 74, 0.7); padding: 6px; }
body.touch #chat:not(.open) #chatHead, body.touch #chat:not(.open) #chatInput { display: none; }
body.touch #chat:not(.open) #chatLog { min-height: 0; }
body.touch #chat:not(.open) #chatLog li { background: rgba(8, 10, 16, 0.5); }
body.touch #chat.open { pointer-events: auto; }
body.touch #chatHead span { display: none; }
#chatInput.hidden, #chatNote.hidden { display: none; }
#chatNote { margin-top: 4px; padding: 3px 6px; color: #ffb4b4; background: rgba(8, 10, 16, 0.7); border-radius: 3px; }

/* Ghost pick on a leaderboard row */
.gbtn { margin-right: 8px; padding: 0 6px; font-size: 10px; line-height: 16px; border-radius: 3px; opacity: 0.6; }
li:hover .gbtn, .gbtn:focus-visible { opacity: 1; }

/* Patch notes (notes.js, public/patchnotes.json): a scrolling list, newest first; a dot on the menu button until the newest is read. */
#notes { z-index: 9; }
#notes .panel { background: rgba(14, 17, 24, 0.97); width: min(560px, 92vw); max-height: 82vh; overflow: auto; text-align: left; }
#notes .label { text-align: center; }
#notesList h3 { margin: 14px 0 2px; font-size: 15px; color: var(--ink); }
#notesList h3 small { margin-left: 8px; color: var(--dim); font-weight: 400; font-size: 12px; }
#notesList h4 { margin: 8px 0 2px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
#notesList ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.45; color: var(--ink); }
#sNotes.new::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.gbtn.on { opacity: 1; background: #ff9a2e; color: #000; }

/* Community maps, the map report and the server browser (js/community.js). */
/* Opaque, over a dimmed menu, like the controls dialog. */
#cmaps, #servers, #cmReport { z-index: 8; background: rgba(0, 0, 0, 0.55); pointer-events: auto; }
#cmaps .panel, #servers .panel, #cmReport .panel { background: rgba(12, 16, 24, 0.97); }
#cmReport { z-index: 9; }
#cmReport .panel { width: min(440px, calc(100vw - 24px)); box-sizing: border-box; }
#cmaps .panel { width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-sizing: border-box; display: flex; flex-direction: column; text-align: left; padding: 14px 18px; }
#cmaps .label, #servers .label, #cmReport .label { text-align: center; }
.cmBar { display: flex; gap: 8px; align-items: center; margin: 10px 0 8px; flex-wrap: wrap; }
.cmBar .tabs { flex: 1 1 280px; margin: 0; }
.cmBar .tabs button { font-size: 12px; padding: 5px 8px; }
#cmSearch, #cmReportText { flex: 1 1 200px; padding: 6px 9px; color: var(--ink); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 4px; font: 14px var(--font); }
#cmReportText { width: 100%; box-sizing: border-box; margin-top: 10px; resize: vertical; }
.cmCols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 12px; min-height: 0; flex: 1; }
#cmList { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; max-height: calc(100vh - 230px); display: grid; gap: 4px; align-content: start; }
#cmList button { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; text-align: left; padding: 7px 10px; }
#cmList button.on { outline: 1px solid var(--accent); background: rgba(255, 255, 255, 0.12); }
#cmList .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cmList .by, #cmList .dr { color: var(--dim); font-size: 12px; }
#cmList .st { color: var(--accent); font-size: 12px; text-align: right; }
#cmList .dr { text-align: right; }
#cmList .empty, #cmPickBoard .empty { color: var(--dim); padding: 6px 2px; list-style: none; }
#cmPick { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#cmPick .cmName { font-size: 17px; font-weight: 700; }
#cmPick .hint { margin-top: 0; }
#cmPickMap { width: 100%; height: auto; aspect-ratio: 3 / 2; background: rgba(0, 0, 0, 0.25); border-radius: 6px; }
#cmPickBoard { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#cmPickBoard li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 6px; padding: 2px 4px; }
#cmPickBoard li.me { color: var(--accent); }
#cmPickBoard .rk { color: var(--dim); }
#cmPickBoard .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cmPickBoard .tm { font-family: var(--font); }
#cmPick .row { justify-content: flex-start; flex-wrap: wrap; margin-top: 4px; }
#cmaps button:disabled, #servers button:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 700px) { .cmCols { grid-template-columns: 1fr; } #cmList { max-height: 34vh; } }
/* The server browser: a plain grid of servers in the old style. */
#servers .panel { width: min(640px, calc(100vw - 24px)); box-sizing: border-box; text-align: left; }
#servers .tabs { margin: 10px 0 6px; }
#servers .tabs button { flex: 0 0 auto; font-size: 12px; padding: 4px 12px; }
#svTable { width: 100%; border-collapse: collapse; font: 13px var(--font); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
#svTable th { text-align: left; color: var(--dim); font-weight: 400; padding: 4px 8px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); }
#svTable td { padding: 3px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); white-space: nowrap; }
#svTable td.dot { color: #7be08f; width: 1em; }
#svTable tr.on td { background: rgba(255, 210, 74, 0.18); }
#svTable td button { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
#servers .fine { max-width: none; margin-left: 0; }



/* Graphics dialog (gfx.js, gfxmenu.js): the look of the Controls dialog, one switch per row. */
#gfx { background: rgba(0, 0, 0, 0.55); pointer-events: auto; }
#gfx .panel { width: min(420px, calc(100vw - 24px)); background: rgba(12, 16, 24, 0.97); }
#gfx .tabs button { padding: 6px 6px; font-size: 13px; }
#gfx .tabs button.on { background: var(--accent); color: #111; }

/* Benchmark result (?bench=1, bench.js). */
#benchOut { background: rgba(0, 0, 0, 0.6); pointer-events: auto; z-index: 50; }
#benchOut .panel { width: min(760px, calc(100vw - 24px)); background: rgba(12, 16, 24, 0.97); }
#benchOut pre { font: 12px/1.45 var(--mono); white-space: pre; overflow-x: auto; margin: 10px 0; user-select: text; }

/* Page fades (fade.js): black over everything but the loading label, eased; a cut with reduced motion. */
#fade { position: fixed; inset: 0; z-index: 100; background: #000; opacity: 0; pointer-events: none; transition: opacity 300ms ease; }
#fade.on { opacity: 1; pointer-events: auto; }
#loading { z-index: 101; }
@media (prefers-reduced-motion: reduce) { #fade { transition: none; } }


/* Home (docs/UI-STUDY.md, 20 Nov; user: "a more radical UI overhaul", "rolling shots in the background of the main menu"). The show
   reel fills the screen; a shade on the left carries the logo, four doors (Play, Garage, Boards, Settings), the room of the door in
   focus and a small Create row. A door opens on hover or focus, so the mouse, the keys, a pad and a wheel all see the room before
   pressing anything. #reelFade dips the reel (not the menu) to black between shots. */
#reelFade { position: fixed; inset: 0; z-index: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 250ms ease; }
#reelFade.on { opacity: 1; }
body:not(.atStart) #reelFade { display: none; }
#start { pointer-events: auto; place-items: stretch; background:
  linear-gradient(90deg, rgba(4, 6, 10, 0.9) 0%, rgba(4, 6, 10, 0.72) 34%, rgba(4, 6, 10, 0.18) 62%, rgba(4, 6, 10, 0) 80%),
  linear-gradient(0deg, rgba(4, 6, 10, 0.6) 0%, rgba(4, 6, 10, 0) 22%); }
#start .home { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(170px, 230px) minmax(0, 640px) 1fr; grid-template-rows: auto minmax(0, 1fr) auto; gap: 18px 30px; padding: 26px 34px 18px; text-align: left; }
#start .homeTop { grid-column: 1 / 3; display: flex; align-items: center; gap: 22px; min-width: 0; }
/* Jokkis: the logo (the user's, made with Gemini, 23 Nov) is drawn on black, so its box is black. */
#start .logo { flex: none; background: #000; padding: 8px 26px 6px 20px; transform: skewX(-12deg); border-radius: 3px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
#start .logo img { display: block; height: 64px; width: auto; transform: skewX(12deg); }
#startDriver { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--dim); }
#startDriver b { color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#startDriver button { flex: none; padding: 4px 10px; font-size: 12px; }
#start .doors { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; gap: 6px; align-self: start; }
#start .door { display: block; width: 100%; padding: 10px 18px; border: 0; border-left: 4px solid transparent; border-radius: 0; background: transparent; color: rgba(244, 246, 250, 0.62); font: italic 800 30px/1.1 var(--font); text-transform: uppercase; letter-spacing: 1px; text-align: left; cursor: pointer; transition: color 120ms ease, background 120ms ease, border-color 120ms ease; }
#start .door:hover { color: #fff; }
/* Jokkis: the menu's main colour is the logo's blue (#2442d2, the most common blue in jokkis-logo.jpg; it was Formula Mach's red #e30613). */
#start .door.on { color: #fff; border-left-color: #2442d2; background: linear-gradient(90deg, rgba(36, 66, 210, 0.34), rgba(36, 66, 210, 0)); }
#start .door.kbsel { outline: 2px solid var(--accent); outline-offset: -2px; }
#start .room { grid-column: 2; grid-row: 2; align-self: start; min-width: 0; max-height: 100%; overflow-y: auto; box-sizing: border-box; padding: 16px 18px; border-radius: 6px; background: rgba(10, 13, 19, 0.76); border: 1px solid var(--line); }
#start .roomText { margin: 8px 0 14px; color: var(--dim); font-size: 14px; line-height: 1.5; max-width: 52ch; }
.vol { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) 2.5em; align-items: center; gap: 10px; font-size: 14px; }
#start .vol { margin-top: 12px; }
.vol input { width: 100%; min-height: 28px; accent-color: #2442d2; }
.vol output { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.vol input.kbsel { outline: 2px solid #fff; outline-offset: 2px; }
#start .menu { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#start .menu button { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 9px 12px; font-size: 15px; text-align: left; min-width: 0; }
#start button.go { grid-column: 1 / -1; padding: 12px 16px; background: #2442d2; border-color: #2442d2; color: #fff; font: italic 800 20px/1.2 var(--font); text-transform: uppercase; letter-spacing: 1px; }
#start button.go:hover { background: #3b5cf0; }
#start button.go.half { grid-column: auto; }
#start button.go.half:not(.here) { background: #2a2f38; border-color: #4a515d; }
#start button.go.half:not(.here):hover { background: #3a414d; }
#start kbd { font: 12px var(--font); color: var(--dim); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 4px; padding: 1px 6px; }
#start button.go kbd { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
#start .mapCard { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-top: 14px; }
#start .mapCol .label, #startStats { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#startMap { display: block; width: 100%; aspect-ratio: 640 / 460; margin-top: 6px; background: rgba(26, 30, 36, 0.85); border-radius: 6px; }
#startStats { margin-top: 6px; text-align: left; }
/* The top 5 keeps one height whichever map the preview shows (a list that shrank moved the buttons under a still pointer, 19 Nov). */
#startTop { list-style: none; margin: 6px 0 0; padding: 0; min-height: 117px; }
#startTop li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; padding: 3px 0; font-size: 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#startTop li.noreplay { cursor: default; }
#startTop li.me { color: var(--accent); }
#startTop .rk { color: var(--dim); }
#startTop .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#startTop .tm { font-family: var(--font); }
#startTop .empty { display: block; color: var(--dim); border: 0; cursor: default; }
#startMe { margin-top: 6px; color: var(--accent); font-size: 13px; }
#startMe .row { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; }
#start .homeFoot { grid-column: 1 / -1; grid-row: 3; display: flex; align-items: center; gap: 16px; min-width: 0; }
#start .create { display: flex; gap: 6px; flex: none; }
#start .create button { padding: 6px 12px; font-size: 13px; background: rgba(10, 13, 19, 0.65); }
#startBookmark { margin: 0; font-size: 12px; color: var(--dim); min-width: 0; }
#startBookmark kbd { font-size: 11px; padding: 0 5px; }
#reelTag { margin: 0 0 0 auto; font-size: 12px; color: rgba(244, 246, 250, 0.8); text-shadow: 0 1px 3px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #start kbd, body.touch #startBookmark { display: none; }

/* Up to 1024x768 and laptops: a smaller logo and doors. */
@media (max-height: 860px) {
  #start .home { padding: 18px 26px 14px; gap: 14px 24px; }
  #start .logo img { height: 46px; }
  #start .door { font-size: 24px; padding: 8px 14px; }
  #start .room { padding: 12px 14px; }
}
@media (max-width: 1100px) { #start .home { grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) 8vw; } }
/* A phone on its side: everything compact, no stats line or bookmark hint. */
@media (max-height: 520px) {
  #start .home { padding: 8px 14px 8px; gap: 8px 14px; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr) 4vw; }
  #start .homeTop { gap: 12px; }
  #start .logo { padding: 4px 16px 3px 12px; }
  #start .logo img { height: 28px; }
  #startDriver { font-size: 11px; }
  #startDriver button { padding: 2px 8px; font-size: 11px; }
  #start .doors { gap: 2px; }
  #start .door { font-size: 17px; padding: 6px 10px; }
  #start .room { padding: 8px 10px; }
  #start .roomText { font-size: 12px; margin: 4px 0 8px; }
  #start .menu { gap: 4px; }
  #start .menu button { padding: 6px 9px; font-size: 13px; }
  #start button.go { font-size: 15px; padding: 8px 10px; }
  #start .mapCard { gap: 10px; margin-top: 8px; }
  #startMap { max-height: 40vh; margin-top: 3px; }
  #startStats, #startBookmark { display: none; }
  #startTop { min-height: 85px; margin-top: 3px; }
  #startTop li { font-size: 12px; padding: 1px 0; }
  #start .create button { padding: 3px 8px; font-size: 11px; }
}
@media (max-height: 430px) {
  #start .logo img { height: 22px; }
  #start .door { font-size: 15px; padding: 5px 8px; }
  #start .label { font-size: 11px; letter-spacing: 1px; }
  #startMap { max-height: 34vh; }
  #startTop { min-height: 51px; }
  #startTop li:nth-child(n+4) { display: none; }
}
/* A phone upright: one column, the doors as a row of tabs. */
@media (max-width: 640px) and (orientation: portrait) {
  #start { background: rgba(4, 6, 10, 0.72); }
  #start .home { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; padding: 12px 12px 10px; gap: 10px; }
  #start .homeTop { grid-column: 1; flex-wrap: wrap; gap: 10px; }
  #start .logo img { height: 34px; }
  #start .doors { grid-column: 1; grid-row: 2; flex-direction: row; gap: 4px; overflow-x: auto; }
  #start .door { width: auto; flex: 1; font-size: 15px; padding: 8px 6px; text-align: center; border-left: 0; border-bottom: 3px solid transparent; }
  #start .door.on { border-bottom-color: #2442d2; background: rgba(36, 66, 210, 0.22); }
  #start .room { grid-column: 1; grid-row: 3; }
  #start .mapCard { grid-template-columns: minmax(0, 1fr); }
  #start .homeFoot { grid-row: 4; flex-wrap: wrap; gap: 8px; }
  #reelTag { display: none; }
}
/* At home the chat moves to the bottom right, off the doors and the room. */
body.atStart #chat { left: auto; right: 12px; bottom: 44px; }
