@font-face {
 font-family: 'Stunts Narrow';
 src: url('stunts-narrow.woff2') format('woff2');
 font-style: normal;
 font-weight: 400;
 font-display: block;
}
:root { color-scheme: dark; font-family: 'Stunts Narrow', monospace; font-size: 16px; line-height: 1.25; font-synthesis: none; background: #151716; color: #e7e9e5; }
* { box-sizing: border-box; }
body { margin: 0; }
header { display: flex; align-items: center; gap: 16px; max-width: 1480px; margin: 20px auto 0; padding: 0 20px; }
h1 { margin: 0; font-size: 24px; font-weight: 400; }
main { max-width: 1480px; margin: 24px auto; padding: 0 20px; display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; }
.screen-panel { align-self: start; min-width: 0; }
.display { aspect-ratio: 8/5; position: relative; display: grid; place-items: center; background: #000; }
.display canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; outline: none; }
.display canvas:focus-visible { outline: 1px solid #a9ba8c; outline-offset: 2px; }
.display:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; }
#boot { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #111; padding: 24px; }
button { font: inherit; font-size: 16px; border: 1px solid #454b42; background: #242a23; color: inherit; padding: 8px 12px; border-radius: 3px; cursor: pointer; }
button:hover { background: #354332; }
button:focus-visible { outline: 2px solid #c6df92; outline-offset: 2px; }
button:disabled { opacity: .4; cursor: default; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; }
#state { margin-left: auto; font-size: 16px; color: #a5ada1; }
h2, h3 { font-size: 16px; font-weight: 400; margin: 0 0 10px; }
#track-status { font-size: 16px; color: #abb4a5; margin: 8px 0; }
#track-status:empty, #network:empty { display: none; }
#tracks { --track-row-height: 36px; list-style: none; margin: 0; padding: 3px; --track-list-height: calc(260px + 4 * var(--track-row-height)); max-height: max(var(--track-row-height), calc(var(--track-list-height) - var(--track-list-reduction, 0px))); overflow-y: auto; border: 1px solid #3a4236; background: #1b2119; }
#tracks button { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: 0; border-radius: 0; background: transparent; font: inherit; padding: 8px 10px; line-height: 20px; }
#tracks button:hover, #tracks button[aria-pressed=true] { background: #354332; color: #d5edac; }
#tracks button:focus-visible { outline-offset: -2px; }
.map-panel { margin-top: 20px; }
#track-map, #selection-map { display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated; border: 1px solid #3a4236; }
.map-key { display: flex; align-items: center; gap: 6px; font-size: 16px; color: #a5ada1; }
.you-dot, .peer-dot { width: 7px; height: 7px; border-radius: 50%; background: #e5ff78; }
.peer-dot { background: #f29c85; margin-left: 12px; }
#network { font-size: 16px; color: #a5ada1; margin: 8px 0; }
.touch { display: none; padding: 0 20px 20px; gap: 8px; justify-content: center; }
.touch button { padding: 8px; touch-action: none; user-select: none; }
.hidden { display: none !important; }
@media (max-width: 730px) {
 main { display: block; margin: 12px auto; padding: 0 12px; }
 aside { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
 .map-panel { margin-top: 0; }
 #tracks { --track-list-height: calc(300px + 4 * var(--track-row-height)); }
 .touch { display: flex; }
}
@media (max-width: 420px) {
 aside { display: block; }
 .map-panel { max-width: 240px; margin-top: 16px; }
 #tracks { --track-list-height: calc(200px + 4 * var(--track-row-height)); }
}

.track-count { margin-left: auto; font-size: 16px; font-variant-numeric: tabular-nums; }
#tracks button[data-empty=true] { color: #8c9585; }
#tracks button[data-full=true] { color: #e5c894; opacity: 1; background: #302d22; }

#race-standings, #fastest-times-label { margin-top: 12px; }
#race-standings:not([hidden]) + #fastest-times-label { margin-top: 40px; }
#race-standings th:first-child, #standings td:first-child { width: 2ch; padding-left: 3px; }
#standings td:nth-child(3) { overflow-wrap: anywhere; }
#standings td:last-child { white-space: nowrap; }
#standings tr[data-self=true] { background: #354332; color: #d5edac; }
.scores { width: 100%; border-collapse: collapse; font-size: 16px; margin-top: 8px; }
.scores th { color: #a5ada1; font-weight: 400; }
.scores th, .scores td { text-align: left; padding: 5px 0; border-bottom: 1px solid #30382c; }
.scores th:last-child, .scores td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

#race-overlay { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%); color: transparent; background: #101010; background-size: 100% 100%; background-repeat: no-repeat; image-rendering: pixelated; padding: 0; font-size: 0; line-height: 0; pointer-events: none; }
#restart-race { width: 100%; margin: 4px 0; }

#restart-race[data-attention=true]:not(:disabled) { background: #584319; border-color: #e6be63; color: #fff0bf; font-weight: 400; box-shadow: 0 0 0 2px #e6be6340; animation: restart-vote-pulse 2s ease-in-out infinite; }
#restart-race[data-attention=true]:not(:disabled):hover { background: #725821; }

.tip-box { flex-wrap: wrap; max-width: 1440px; margin: 0 auto 20px; padding: 10px 12px; display: flex; align-items: baseline; gap: 12px; border: 1px solid #30382c; color: #a5ada1; font-size: 16px; }
.tip-box > span { color: #c6df92; font-size: 16px; font-weight: 400;  }
.tip-box p { margin: 0; }
@media (max-width: 1480px) { .tip-box { margin-left: 20px; margin-right: 20px; } }
@media (max-width: 730px) { .tip-box { margin-left: 12px; margin-right: 12px; } }

#join-active { width: 100%; margin-top: 8px; }

@keyframes restart-vote-pulse {
 0%, 100% { box-shadow: 0 0 0 2px #e6be6328; }
 50% { box-shadow: 0 0 0 4px #e6be6355; }
}
@media (prefers-reduced-motion: reduce) {
 #restart-race[data-attention=true]:not(:disabled) { animation: none; }
}

#you-label, #menu-you-label { border: 0; border-radius: 0; background: none; padding: 0; font: inherit; color: inherit; }
#you-label:disabled, #menu-you-label:disabled { opacity: 1; cursor: default; }
#you-label:not(:disabled), #menu-you-label:not(:disabled) { text-decoration: underline dotted; text-underline-offset: 3px; }

#players { list-style: none; margin: 0; padding: 0; }
.player-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
.player-row > span:last-child { color: #a5ada1; }
.player-row button { padding: 0; border: 0; background: none; }
.player-row button:not(:disabled) { text-decoration: underline dotted; text-underline-offset: 3px; }

.player-row button { white-space: nowrap; }
.pre-race-marker { display: inline-block; width: 1ch; margin-right: .3em; color: #d5edac; }
.pre-race-marker:not(:empty) { animation: pre-race-blink 1.2s steps(1, end) infinite; }
@keyframes pre-race-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pre-race-marker:not(:empty) { animation: none; } }
[hidden] { display: none !important; }
#players-panel { margin-top: 20px; }
@media (min-width: 421px) and (max-width: 730px) { #players-panel { margin-top: 0; } }

/* Each mode starts at the canvas edge; only later sidebar sections add space. */
#race-panel { margin-top: 0; }

.site-logo { display: block; flex: 0 0 auto; width: 140px; height: auto; image-rendering: pixelated; }
@media (max-width: 730px) {
 header { padding: 0 12px; gap: 12px; }
 .site-logo { width: 104px; }
}

#tracks button:focus { outline: 2px solid; outline-offset: -2px; }

#tracks-panel[data-selecting=true], #selection-preview { grid-column: 1 / -1; }
#tracks-panel[data-selecting=true] #tracks { --track-list-reduction: calc(3 * var(--track-row-height)); }
#selection-preview { max-width: 300px; }

.scores .score-car { width: 36px; }
.car-icon { display: inline-block; flex: 0 0 30px; width: 30px; height: 20px; vertical-align: middle; image-rendering: pixelated; background-image: var(--car-atlas); background-repeat: no-repeat; }
@media (prefers-reduced-motion: reduce) { .car-icon { background-image: var(--car-atlas-still); } }

.player-identity { display: flex; align-items: center; gap: 6px; min-width: 0; }

#track-selector-home, #track-selector { display: contents; }
.display:fullscreen[data-track-selection=true] > #screen { visibility: hidden; }
.display:fullscreen > #track-selector {
 position: absolute; inset: 0; display: grid;
 grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
 align-items: start; align-content: center; gap: 24px; padding: 24px;
 background: #151716; overflow: auto;
}
.display:fullscreen #tracks-panel, .display:fullscreen #selection-preview { grid-column: auto; min-width: 0; }
.display:fullscreen #tracks { --track-list-height: calc(100dvh - 110px); }
.display:fullscreen #selection-preview { width: 100%; max-width: min(100%, calc(100dvh - 100px)); margin: 0; }
.display:fullscreen #selection-map { height: auto; }
