:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #0d1117;
  color: #edf1f3;
  --subtle: #a1adb8;
  --green: #e2fd64;
  --orange: #ffb05c;
  --line: #2a333f;
  --panel: #141b24;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #a8edff; outline-offset: 3px; }
p, h1, h2 { margin: 0; }
.masthead { border-bottom: 1px solid #26303c; background: #10161e; }
.mast-inner { max-width: 1480px; height: 67px; margin: auto; padding-inline: 40px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; gap: 13px; align-items: center; text-decoration: none; color: #f3f5f4; font-size: 1.28rem; font-weight: 900; font-style: italic; letter-spacing: -.05em; white-space: nowrap; }
.brand b { color: var(--green); }
.brand-icon { display: flex; gap: 4px; padding-inline: 3px; transform: skew(-21deg); }
.brand-icon i { width: 6px; height: 20px; background: var(--green); }
.brand-icon i:first-child { height: 11px; margin-top: 9px; opacity: .5; }
.brand-icon i:nth-child(2) { height: 15px; margin-top: 5px; opacity: .77; }
.mast-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sound-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 4px 8px; border: 1px solid #394552; border-radius: 5px; color: #edf1f3; background: #19222c; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.sound-state { color: var(--subtle); }
.sound-toggle[aria-pressed="true"] .sound-state { color: var(--green); }
.sound-toggle.in-race { display: none; }
.network { align-items: center; display: flex; gap: 8px; color: var(--subtle); font-size: .84rem; font-weight: 600; }
.network > span:first-child, .training-status i { width: 7px; height: 7px; background: #7f8a96; border-radius: 50%; }
.network.live > span:first-child, .training-status.live i { background: var(--green); box-shadow: 0 0 12px #e2fd6466; }
.layout { max-width: 1480px; margin-inline: auto; padding: 30px 40px 40px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 305px); gap: 22px; align-items: start; }
.arena, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.arena-head { padding: 19px 22px 17px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
.eyebrow { font-size: .76rem; letter-spacing: .12em; font-weight: 750; color: var(--subtle); }
h1, h2 { font-weight: 820; letter-spacing: -.04em; line-height: 1.12; }
h1 { margin-top: 4px; font-size: clamp(1.7rem, 3vw, 2.45rem); font-style: italic; }
.track-spec { display: flex; gap: 8px; align-items: center; color: #c4ccd4; border: 1px solid #34404b; font-size: .75rem; font-weight: 750; letter-spacing: .07em; padding: 8px 10px; border-radius: 4px; white-space: nowrap; }
.track-spec i { width: 12px; height: 12px; background: repeating-conic-gradient(#adbbc9 0% 25%, transparent 0% 50%) 0 0 / 8px 8px; }
.viewport { position: relative; display: grid; place-items: center; overflow: hidden; background: #111d22; border-block: 1px solid #2b3941; }
canvas { display: block; width: 100%; aspect-ratio: 960 / 650; object-fit: contain; }
.arena-foot { min-height: 56px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 12px; padding: 5px 21px; }
.keyboard { display: flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--subtle); }
.keyboard span { margin-left: 5px; }
kbd { min-width: 22px; padding: 3px 4px; border: 1px solid #394652; border-bottom-width: 2px; border-radius: 4px; text-align: center; color: #dee2e9; font-weight: 700; }
.arena-actions { display: flex; flex-wrap: wrap; gap: 0 16px; }
.text-button { min-height: 40px; padding: 6px 0; color: var(--green); background: transparent; border: 0; font-weight: 720; font-size: .875rem; white-space: nowrap; }
.text-button:hover:enabled { text-decoration: underline; }
.holdout-summary, .review-status { padding: 10px 16px 16px; }
.review-status { color: var(--subtle); }
.holdout-summary table { border-collapse: collapse; width: 100%; font-size: .875rem; font-variant-numeric: tabular-nums; }
.holdout-summary caption { text-align: left; color: var(--subtle); margin-bottom: 7px; }
.holdout-summary th, .holdout-summary td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.holdout-summary thead { color: var(--subtle); }
.holdout-summary .model-replay { min-height: 30px; padding: 3px 5px; color: var(--green); border: 1px solid transparent; border-radius: 4px; background: transparent; font-size: inherit; }
.holdout-summary .model-replay[aria-pressed="true"] { border-color: #607446; background: #202b22; }
.rail { display: grid; gap: 16px; }
.panel { padding: 21px; }
.tag-line { display: inline-block; background: var(--green); height: 10px; width: 3px; margin: 0 5px 0 1px; transform: skew(-16deg); }
.panel h2 { font-size: 1.72rem; margin-top: 10px; }
.muted { color: var(--subtle); line-height: 1.48; margin-top: 8px; font-size: .94rem; }
form { margin-top: 20px; }
label { display: block; font-size: .875rem; font-weight: 650; margin-bottom: 7px; color: #d4dde5; }
input { display: block; width: 100%; min-width: 0; color: #fff; background: #0e151e; border: 1px solid #394552; border-radius: 6px; min-height: 46px; padding: 8px 11px; }
input::placeholder { color: #8695a5; }
.join-row { margin-top: 12px; }
.entry-choice { margin-top: 12px; }
#room-code { text-transform: uppercase; letter-spacing: .12em; }
.button { width: 100%; min-height: 44px; border: 1px solid transparent; border-radius: 6px; padding: 8px 11px; font-weight: 790; }
.button.primary { color: #182006; background: var(--green); }
.button.primary:hover:enabled { background: #edff9e; }
.button.secondary { background: #202b37; color: #e5eaef; border-color: #34414e; }
.button.secondary:hover { background: #2b3844; }
.button.quiet { color: var(--subtle); background: transparent; font-size: .875rem; }
#submit { margin-top: 12px; }
#join-mode { margin-top: 3px; }
.form-error { margin: 10px 0 0; font-size: .875rem; color: #ff969b; }
.room-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.room-code { color: var(--green); font: 700 .87rem ui-monospace, monospace; letter-spacing: .06em; }
.room-feedback { display: grid; gap: 5px; margin-top: 12px; padding: 11px 12px; border: 1px solid #34404b; border-inline-start: 3px solid #7096ab; border-radius: 6px; background: #0e151e; color: var(--subtle); font-size: .875rem; line-height: 1.4; overflow-wrap: anywhere; scroll-margin-top: 12px; }
.room-feedback[data-ready] { border-inline-start-color: var(--green); }
.room-status { color: #edf1f3; font-weight: 800; font-size: 1rem; }
.qualify-summary { color: #d0dce5; font-variant-numeric: tabular-nums; }
.start-race { margin-top: 9px; }
.roster { margin: 15px 0 16px; display: grid; }
.roster-line { display: grid; grid-template-columns: 19px 1fr auto; gap: 8px; align-items: center; min-height: 40px; border-bottom: 1px solid #2a3440; font-size: .94rem; }
.roster-line .color { display: block; width: 9px; height: 9px; border: 1px solid #fff8; transform: skew(-16deg); }
.roster-line .driver { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-line small { color: var(--subtle); font-size: .78rem; font-variant-numeric: tabular-nums; }
.room-actions { display: grid; gap: 8px; }
.room-choice { margin-bottom: 4px; position: relative; }
.room-choice::after { content: ''; position: absolute; bottom: 19px; right: 14px; width: 7px; height: 7px; border: solid var(--subtle); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.room-choice select { appearance: none; width: 100%; min-height: 44px; padding: 8px 34px 8px 11px; color: #edf1f3; background: #0e151e; border: 1px solid #394552; border-radius: 6px; }
.room-choice select:disabled { opacity: .78; }
.share-status { margin: 0; color: var(--subtle); font-size: .8rem; min-height: 0; }
.share-status:empty { display: none; }
.share-link { font-size: .82rem; }
.lab .tag-line { background: var(--orange); }
.lab-overline { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.training-status { display: flex; gap: 6px; align-items: center; white-space: nowrap; color: var(--subtle); font-size: .76rem; font-weight: 650; }
.lab h2 > span { margin-left: 4px; font: 600 .82rem ui-monospace, monospace; color: var(--orange); }
.lab-stats { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lab-stats div { min-width: 0; border: 1px solid #303b48; background: #111821; border-radius: 6px; padding: 9px; }
.lab-stats small, .hud small { display: block; color: var(--subtle); font-size: .71rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.lab-stats strong { display: block; margin-top: 4px; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.lab-stats .gain { color: var(--green); }
.lab-foot { margin-top: 14px; display: flex; gap: 6px 12px; justify-content: space-between; flex-wrap: wrap; font-size: .79rem; color: var(--subtle); }
.training-progress { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); }
.training-progress svg { display: block; width: 100%; margin-block: 6px 3px; overflow: visible; }
.training-progress path { fill: none; vector-effect: non-scaling-stroke; }
.training-grid { stroke: #34404b; stroke-width: 1; }
.accepted-line { stroke: var(--green); stroke-width: 2; }
.trial-line { stroke: var(--orange); stroke-width: 1.5; stroke-dasharray: 3 3; }
.training-key { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .76rem; }
.training-key .accepted { color: var(--green); }
.training-key .trial { color: var(--orange); }
.training-detail { color: var(--subtle); font-size: .76rem; margin-top: 8px; line-height: 1.4; }
.hud { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; }
.hud:not([hidden]) + .track-spec { display: none; }
.hud-meter { display: flex; align-items: baseline; gap: 5px; padding: 4px 7px; background: #0e151e; border: 1px solid #34404b; border-radius: 5px; }
.hud strong { color: #f9fafa; font-size: 1rem; font-variant-numeric: tabular-nums; }
.hud .speed strong { color: var(--green); }
.qualify-cancel { color: #e5eaef; background: #202b37; border: 1px solid #394552; border-radius: 5px; padding: 4px 7px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.powerups { display: flex; flex-wrap: wrap; gap: 4px; }
.ability { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 3px 7px; background: #172635; color: #abedff; border: 1px solid #456577; border-radius: 5px; font-size: .82rem; font-weight: 750; }
.ability.oil { color: #f1d0ff; background: #291f36; border-color: #624879; }
.ability kbd { padding: 1px 3px; min-width: 0; font-size: .7rem; }
.ability .ability-status { min-width: 3ch; text-align: end; font-variant-numeric: tabular-nums; }
.ability:disabled { opacity: .72; }
#hud-time { min-inline-size: 7ch; }
#hud-speed { min-inline-size: 3ch; text-align: end; }
.countdown { z-index: 2; position: absolute; inset: auto; display: grid; justify-items: center; gap: 8px; max-width: calc(100% - 24px); text-align: center; color: var(--green); font-size: clamp(3rem, 13vw, 8rem); line-height: 1; text-shadow: 0 4px 0 #131a10, 0 0 26px #adff5b52; font-style: italic; font-weight: 950; pointer-events: none; }
.countdown strong { font-weight: inherit; }
.countdown-label { padding: 5px 8px; border-radius: 4px; background: #111a24; color: #edf1f3; font-size: .82rem; font-style: normal; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; text-shadow: none; }
.countdown[data-preparing] { padding: 15px clamp(12px, 4vw, 25px); border: 1px solid #809749; border-radius: 9px; background: #111a24f5; font-size: clamp(1.55rem, 5.5vw, 3rem); line-height: 1.15; text-shadow: none; }
.replay-key { position: absolute; top: 11px; left: 11px; display: flex; flex-wrap: wrap; gap: 5px; }
.replay-key span { display: inline-flex; align-items: center; gap: 6px; background: #101821f2; border: 1px solid #4a535e; border-radius: 5px; padding: 7px 8px; font-size: .78rem; }
.replay-key i { width: 8px; height: 8px; background: #91caff; border-radius: 50%; }
.replay-key span + span i { background: var(--orange); }
.finish-card { position: absolute; z-index: 3; display: grid; gap: 11px; min-width: min(250px, 85%); text-align: center; border: 1px solid #4b5743; border-radius: 10px; background: #111a24f5; padding: 18px; }
.finish-card h2 { font-style: italic; overflow-wrap: anywhere; }
.finish-card .eyebrow { color: var(--green); }
.touch-dock, .touch-hint { display: none; }
@media (max-width: 900px) {
  .mast-inner { padding-inline: 20px; }
  .layout { padding: 20px; gap: 13px; grid-template-columns: minmax(0, 1fr) 240px; }
  .panel { padding: 16px; }
  .arena-head, .arena-foot { padding-inline: 13px; }
}
@media (max-width: 680px) {
  .mast-inner { height: 52px; padding-inline: 14px; }
  .mast-actions { gap: 8px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  body[data-invited] .rail { grid-row: 1; }
  body[data-invited] .lab { display: none; }
}
@media (max-width: 400px) {
  .network { max-width: 86px; font-size: .75rem; line-height: 1.15; }
  .network > span:first-child { flex: 0 0 7px; }
}
@media (pointer: coarse) {
  .keyboard { display: none; }
  .sound-toggle { min-height: 44px; }
  .touch-hint { display: block; font-size: .76rem; color: var(--subtle); }
  .touch-dock { display: flex; justify-content: space-between; gap: 5px; position: absolute; z-index: 4; inset: auto max(7px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); pointer-events: none; }
  .touch-group { display: flex; gap: 6px; pointer-events: auto; }
  .touch { color: #f6f9ff; background: #1b293bea; border: 1px solid #68768a; border-radius: 10px; min-width: clamp(51px, 12vw, 78px); min-height: clamp(51px, 11vh, 70px); font-size: .8rem; font-weight: 830; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .touch span { font-size: 1.17rem; }
  .touch.gas { background: #daf260; color: #17210a; border-color: #eaedb7; }
  .touch.pressed { background: #577080; }
  .touch.gas.pressed { background: #a8c332; }
  body[data-driving] { overflow: hidden; overscroll-behavior: none; }
  body[data-driving] .masthead, body[data-driving] .rail, body[data-driving] .arena-heading, body[data-driving] .arena-foot, body[data-driving] .track-spec { display: none; }
  body[data-driving] .layout, body[data-driving] .arena { width: 100%; height: 100dvh; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; }
  body[data-driving] .layout { display: block; }
  body[data-driving] .arena { display: flex; flex-direction: column; }
  body[data-driving] .arena-head { display: block; padding: 0; }
  body[data-driving] .hud {
    justify-content: center;
    padding: max(4px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left));
  }
  body[data-driving] .qualify-cancel { min-height: 36px; }
  body[data-driving] .sound-toggle.in-race { display: inline-flex; }
  .ability kbd { display: none; }
  .ability { min-height: 44px; }
  body[data-driving] .viewport { flex: 1; min-height: 0; border-block: 0; touch-action: none; }
  body[data-driving] canvas { width: 100%; height: 100%; min-width: 0; min-height: 0; }
}
@media (min-width: 901px) and (pointer: fine) {
  canvas { max-height: max(325px, calc(100dvh - 255px)); }
}
