.race-page {
  background: radial-gradient(ellipse at 10% 14%, #e4f6ff 0%, transparent 42%),
    radial-gradient(ellipse at 97% 45%, #f7edff 0%, transparent 38%), #f9fcff;
}
.race-main { padding-top: 23px; padding-bottom: 26px; }
.race-intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.race-intro h1 {
  margin-top: 3px;
  font-size: clamp(2.45rem, 5.2vw, 3.9rem);
  line-height: 1.03;
  letter-spacing: -.065em;
}
.mode-chip {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 2px 6px;
  border: 1px solid #dac6f6;
  border-radius: 5px;
  background: #eee2ff;
  color: #553186;
  font-size: .62rem;
  letter-spacing: .07em;
}
.soft-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #ddcef2;
  border-radius: 10px;
  background: #f5edff;
  color: #52328d;
  font-size: .83rem;
  font-weight: 800;
}
.soft-button:hover { background: #ebdefb; }
.soft-button:disabled { opacity: .54; cursor: default; }
.race-help { flex: none; white-space: nowrap; }
.race-toolbar { display: flex; flex: none; align-items: center; gap: 6px; margin-top: 7px; }
.race-display-controls { display: flex; gap: 6px; }
.race-toolbar .soft-button { white-space: nowrap; }
.race-toolbar .icon { width: 19px; height: 19px; }
.race-sound .audio-off, .race-sound[aria-pressed="true"] .audio-on { display: none; }
.race-sound[aria-pressed="true"] .audio-off { display: block; }
.race-fullscreen .shrink-icon,
.race-layout:is(:fullscreen, .is-expanded) .expand-icon { display: none; }
.race-layout:is(:fullscreen, .is-expanded) .shrink-icon { display: block; }
.race-help .help-symbol {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6a44b8;
  color: #fff;
  line-height: 1;
}

.race-layout {
  display: grid;
  grid-template-columns: clamp(220px, 22vw, 266px) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}
.cabinet {
  min-width: 0;
  padding: 10px;
  border: 1px solid #ccdce9;
  border-radius: 23px;
  background: linear-gradient(138deg, #fff, #eff9ff 62%, #f7f4ff);
  box-shadow: 0 10px 27px #446a9219;
  color: #283951;
}
.scoreboard {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
}
.scoreboard > div {
  flex: 1;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid #c3e1d6;
  border-radius: 10px;
  background: #e8f8f1;
  text-align: center;
}
.scoreboard > div:nth-child(3) { background: #f2ecff; border-color: #e0d3f6; }
.scoreboard > div:nth-child(4) { background: #eaf5ff; border-color: #cfe3f5; }
.scoreboard .score-best { background: #fff5dc; border-color: #ebd5a4; }
.scoreboard span { display: block; color: #43536b; font-size: .72rem; font-weight: 750; }
.scoreboard strong { display: block; color: #263956; font-size: 1.12rem; line-height: 1.28; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.scoreboard .score-current strong { color: #225845; }
.scoreboard .score-best strong { color: #694b21; }
.pause-button {
  min-height: 44px;
  padding: 4px 11px;
  border: 1px solid #d7c7f0;
  border-radius: 10px;
  background: #f8f3ff;
  color: #482675;
  font-size: .82rem;
  font-weight: 800;
}
.pause-button span { display: inline; color: inherit; }

.arena {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 1.85;
  min-height: 300px;
  border: 1px solid #b5d3e3;
  border-radius: 15px;
  background: #75c9ee;
}
.arena canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: pan-y; }
.race-page:is([data-phase="racing"], [data-phase="countdown"]) .arena canvas { cursor: pointer; }
.arena:focus-visible { outline-color: #547c9f; }
.race-prompt {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 4px 16px 7px;
  border: 1px solid #d1deef;
  border-radius: 12px;
  transform: translateX(-50%);
  background: #fafdff;
  color: #243958;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 5px 15px #22496c27;
}
.race-prompt span { display: block; color: #57437e; font-size: .67rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.race-prompt strong { display: block; font-size: clamp(1.34rem, 3.6vw, 2.2rem); font-weight: 800; line-height: 1.12; letter-spacing: -.04em; white-space: nowrap; }
.gate-effect {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 4px 9px;
  background: #dffe97;
  color: #22372d;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  white-space: nowrap;
  pointer-events: none;
}
.gate-effect[data-kind="miss"] { background: #ffddb1; color: #60351a; }
.track-countdown {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #344c70;
  font-size: clamp(3rem, 13vw, 6rem);
  font-weight: 800;
  text-shadow: 0 2px 1px #fff, 0 0 12px #fff;
  pointer-events: none;
}
.arena-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 11px;
  background: linear-gradient(#eefaff0c, #e9f6ff39);
}
.overlay-card {
  width: min(100%, 366px);
  padding: 18px 21px;
  border: 1px solid #d1dcec;
  border-radius: 16px;
  background: #fbfdff;
  box-shadow: 0 10px 24px #1a466c29;
  text-align: center;
}
.overlay-card .eyebrow { color: #644b93; }
.overlay-card h2 { margin: 3px 0 5px; color: #293952; font-size: clamp(1.7rem, 5vw, 2.55rem); line-height: 1.12; letter-spacing: -.05em; }
.overlay-card p:not(.eyebrow) { margin: 0 auto; max-width: 29ch; color: #445470; font-size: .88rem; }
.overlay-card h2:focus { outline: none; }
.finish-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 9px 0 1px; }
.finish-scores div { padding: 4px; border: 1px solid #ded3f2; border-radius: 8px; background: #f3edff; }
.finish-scores div:nth-child(2) { border-color: #ebd5a4; background: #fff5dc; }
.finish-scores span { display: block; color: #514568; font-size: .68rem; font-weight: 800; }
.finish-scores strong { display: block; color: #283956; font-size: 1.22rem; line-height: 1.15; }
.new-best { display: block; margin-top: 6px; color: #316343; font-size: .65rem; font-weight: 800; letter-spacing: .1em; }
.race-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 45px;
  padding: 7px 14px;
  border: 1px solid #c7df87;
  border-radius: 10px;
  background: #e3ff91;
  color: #242e23;
  font-size: .86rem;
  font-weight: 800;
}
.race-primary:hover { background: #efffc1; }
.overlay-card .race-primary { margin-top: 12px; }
.overlay-card .race-primary:focus-visible { outline-color: #6c51b5; }

.steering { margin-top: 8px; }
.lane-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.lane-button {
  min-height: 61px;
  padding: 5px 4px;
  border: 2px solid #e0d1f4;
  border-radius: 10px;
  background: #f1e6ff;
  color: #382267;
  text-align: center;
}
.lane-button:nth-child(2) { background: #dcf8ef; color: #224d49; border-color: #bfe5d8; }
.lane-button:nth-child(3) { background: #fff2ce; color: #593b16; border-color: #eed9aa; }
.lane-button:hover { filter: brightness(.98); }
.lane-button[aria-pressed="true"] { border-color: #7560a9; box-shadow: inset 0 0 0 1px #fff; }
.lane-button:focus-visible { outline-color: #6c51b5; outline-offset: 2px; }
.lane-button span { display: block; font-size: .62rem; font-weight: 800; letter-spacing: .055em; }
.lane-button strong { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.14; }
.steering-note { margin: 6px 0 2px; color: #4b5670; font-size: .69rem; text-align: center; }
kbd {
  display: inline-block;
  padding: 0 3px;
  border: 1px solid #d8c9ed;
  border-radius: 4px;
  background: #f7efff;
  color: #443073;
  font: 800 .78em Manrope, sans-serif;
}
.race-progress { flex: 1; height: 7px; overflow: hidden; border-radius: 99px; background: #dce7ef; }
.race-progress > div { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #62b8a5, #a6cd64); }

.race-layout:is(:fullscreen, .is-expanded) {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  width: 100%;
  height: 100%;
  overflow: auto;
  background: #f6fbff;
}
.race-layout.is-expanded { position: fixed; inset: 0; z-index: 100; }
.race-page:has(.race-layout.is-expanded) { overflow: hidden; }
.race-page:has(.race-layout:is(:fullscreen, .is-expanded)) :is(.skip, .site-header, .race-intro, .local-note) {
  visibility: hidden;
}
.race-layout:is(:fullscreen, .is-expanded) .race-panel { display: none; }
.race-layout:is(:fullscreen, .is-expanded) .cabinet {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(170px, 1fr) auto 10px;
  min-height: 0;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.race-layout:is(:fullscreen, .is-expanded) .scoreboard { grid-area: 1 / 1; }
.race-layout:is(:fullscreen, .is-expanded) .arena { grid-area: 2 / 1; min-height: 0; aspect-ratio: auto; }
.race-layout:is(:fullscreen, .is-expanded) .arena-overlay { overflow: auto; align-items: safe center; }
.race-layout:is(:fullscreen, .is-expanded) .steering { grid-area: 3 / 1; }
.race-layout:is(:fullscreen, .is-expanded) .race-toolbar { display: contents; }
.race-layout:is(:fullscreen, .is-expanded) .race-progress { grid-area: 4 / 1; align-self: end; }
.race-layout:is(:fullscreen, .is-expanded) .race-display-controls {
  grid-area: 2 / 1;
  place-self: end end;
  z-index: 5;
  margin: 10px;
}
.race-layout:is(:fullscreen, .is-expanded) .race-display-controls .soft-button {
  width: 44px;
  padding: 0;
  border-color: #fff9;
  border-radius: 12px;
  background: #ffffffb8;
  color: #293e5f;
  box-shadow: 0 2px 9px #25425c25;
}
.race-layout:is(:fullscreen, .is-expanded) .race-display-controls .soft-button:hover { background: #ffffffd9; }
.race-layout:is(:fullscreen, .is-expanded) .race-display-controls span { display: none; }

.race-panel {
  min-width: 0;
  padding: 13px;
  border: 1px solid #e0d2f4;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 6px 18px #3c236910;
}
.paxa-guide {
  min-height: 72px;
  display: grid;
  grid-template-columns: 69px 1fr;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  padding: 4px 7px 0 0;
  margin-bottom: 10px;
  border: 1px solid #e1cef9;
  border-radius: 13px;
  background: linear-gradient(115deg, #e3d3ff, #ffe8e9);
  color: #432565;
}
.paxa-guide img { width: 72px; height: auto; }
.paxa-guide .eyebrow { font-size: .64rem; }
.paxa-guide h2 { margin-top: 1px; font-size: 1.42rem; letter-spacing: -.05em; }
.race-panel h3 { margin: 4px 0 8px; font-size: 1.17rem; letter-spacing: -.035em; }
.setup-field { display: grid; gap: 3px; min-width: 0; margin: 8px 0; }
.setup-field label { color: #483167; font-size: .76rem; font-weight: 800; }
.setup-field select {
  min-height: 44px;
  min-width: 0;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ded1ed;
  border-radius: 8px;
  background: #fbf7ff;
  color: #372151;
  font: 750 .83rem Manrope, system-ui, sans-serif;
}
.setup-start { width: 100%; margin-top: 4px; }
.setup-note { margin: 5px 0; color: #5b4974; font-size: .75rem; font-weight: 650; line-height: 1.3; }
#setup-pending { color: #694613; background: #fff2c7; padding: 5px 7px; border-radius: 6px; }
#driving-panel, #paused-panel, #results-panel { margin-top: 9px; padding-top: 9px; border-top: 1px solid #e0d2f4; }
.coach-message { min-height: 67px; margin-bottom: 8px; padding: 8px 10px; border-radius: 10px; background: #f3ebff; color: #453075; font-size: .83rem; }
.coach-message p { margin-top: 3px; font-size: .78rem; line-height: 1.42; }
.coach-message[data-tone="miss"] { background: #fff1df; color: #633a1c; }
.coach-message[data-tone="correct"] { background: #e5f9de; color: #23512a; }
.coach-message[data-tone="hint"] { background: #e5f5ff; color: #244f75; }
.panel-copy { color: var(--muted); font-size: .85rem; }
#restart { margin-top: 8px; }
.results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0 0 10px; }
.results div { padding: 5px 7px; border-radius: 8px; background: #f2e8ff; }
.results div:nth-child(even) { background: #e9f7ef; }
.results dt { color: #49366a; font-size: .68rem; font-weight: 800; }
.results dd { margin: 0; color: #2d2149; font-size: 1.15rem; font-weight: 800; }
.local-note { margin-top: 9px; color: var(--muted); font-size: .72rem; }
.race-instructions { padding-inline-start: 21px; color: #332452; font-size: .9rem; }
.race-instructions li { padding-left: 2px; margin: 7px 0; }

@media (max-width: 760px) {
  .race-main { padding-top: 12px; padding-bottom: 16px; }
  .race-intro { margin-bottom: 9px; align-items: center; }
  .race-intro h1 { font-size: clamp(2rem, 9vw, 2.8rem); }
  .race-help { font-size: .76rem; padding-inline: 8px; }
  .race-toolbar .soft-button { min-width: 44px; padding-inline: 8px; }
  #sound-state, #fullscreen-state { display: none; }
  .race-layout { grid-template-columns: 1fr; gap: 9px; }
  .race-layout:is(:fullscreen, .is-expanded) .steering-note { display: none; }
  .race-layout:is(:fullscreen, .is-expanded) .gate-effect { bottom: 61px; }
  .cabinet { padding: 6px; border-radius: 16px; }
  .scoreboard { gap: 4px; margin-bottom: 5px; }
  .scoreboard > div { padding: 4px 2px; border-radius: 8px; }
  .scoreboard span { font-size: .65rem; }
  .scoreboard strong { font-size: .96rem; }
  .scoreboard .score-best strong { font-size: clamp(.72rem, 3.6vw, .96rem); }
  .pause-button { padding-inline: 8px; font-size: .72rem; min-height: 44px; }
  .arena { aspect-ratio: 1.16; min-height: 218px; border-radius: 11px; }
  .race-prompt { top: 7px; padding: 4px 11px 6px; }
  .race-prompt span { font-size: .58rem; }
  .race-prompt strong { font-size: clamp(1.25rem, 6vw, 1.7rem); }
  .race-layout:is(:fullscreen, .is-expanded) .race-prompt {
    display: flex;
    align-items: center;
    gap: 7px;
    top: 4px;
    padding: 4px 9px;
    border-radius: 8px;
  }
  .race-layout:is(:fullscreen, .is-expanded) .race-prompt strong { font-size: clamp(1.15rem, 5vw, 1.4rem); }
  .overlay-card { padding: 12px 11px; max-width: 250px; }
  .overlay-card p:not(.eyebrow) { font-size: .8rem; }
  #finish-overlay .overlay-card { padding: 8px 10px; }
  #finish-overlay .overlay-card h2 { font-size: 1.6rem; }
  #finish-overlay .race-primary { margin-top: 7px; }
  .steering { margin-top: 6px; }
  .lane-button { min-height: 53px; }
  .lane-button strong { font-size: 1.19rem; }
  .lane-button span { font-size: .56rem; }
  .steering-note { font-size: .61rem; }
  .race-panel { position: relative; padding: 8px; border-radius: 13px; }
  .paxa-guide { grid-template-columns: 45px 1fr; min-height: 42px; margin-bottom: 6px; padding-block-start: 0; }
  .paxa-guide img { width: 45px; }
  .paxa-guide h2 { font-size: 1.12rem; }
  #race-setup { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 7px; }
  .setup-field { margin: 0; }
  .setup-field select { padding-inline: 4px; font-size: .72rem; }
  .setup-note, .setup-start { grid-column: 1 / -1; margin: 0; }
  .setup-note { font-size: .68rem; }
  .race-page:is([data-phase="racing"], [data-phase="countdown"]) .paxa-guide { padding-inline-end: 83px; }
  #driving-panel { margin: 0; padding: 0; border: 0; }
  .coach-message { min-height: 0; margin: 6px 0 0; }
  .coach-message:not([data-tone="hint"]) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #hint { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; padding-inline: 6px; font-size: .7rem; }
}
@media (min-width: 761px) {
  .race-panel { position: sticky; top: 12px; align-self: start; }
}
@media (max-width: 420px) {
  .race-help { min-width: 44px; }
  .help-label { display: none; }
}
