:root {
  color-scheme: dark;
  --bg: #101c29;
  --panel: #172737;
  --border: #2d4151;
  --mint: #9cf4ce;
  --muted: #91a6b7;
  font-family: 'Arial', sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: #edf5f7;
}
button,
select {
  font: inherit;
}
button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:focus-visible,
select:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}
.shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 1160px;
  height: 100vh;
  height: 100dvh;
  margin: auto;
  padding: 10px 24px;
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 36px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #e9f3f5;
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 2px;
}
.brand-icon {
  color: var(--mint);
  font-size: 32px;
}
.brand-sub {
  color: var(--muted);
  border-left: 1px solid var(--border);
  margin-left: 8px;
  padding-left: 20px;
  font-size: 10px;
  letter-spacing: 1px;
}
.quiet-button {
  color: #d4e1e9;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 9px 12px;
  font-size: 12px;
}
.quiet-button:hover {
  background: #2b4051;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 0 0 auto;
  padding: 2px 0;
  gap: 20px;
}
.eyebrow,
.section-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--mint);
  font-weight: 700;
}
h1 {
  font-size: clamp(26px, 3vw, 40px);
  letter-spacing: -2px;
  margin: 4px 0;
  font-weight: 900;
}
h1 > span:first-child {
  color: var(--mint);
}
.title-dot {
  color: #ffad79;
}
.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}
.track-tag {
  font: 10px monospace;
  color: var(--muted);
  letter-spacing: 1px;
  flex-shrink: 0;
}
.track-tag strong {
  display: block;
  margin-top: 10px;
  color: #e9f3f5;
  font-size: 13px;
}
.live-dot,
.mint-dot,
.orange-dot {
  display: inline-block;
  height: 7px;
  width: 7px;
  background: var(--mint);
  margin-right: 7px;
}
.live-dot {
  border-radius: 50%;
}
.orange-dot {
  background: #ffae7f;
  margin-left: 15px;
}
.game-panel {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 20px 60px #060e1833;
}
.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1.5fr 0.8fr;
  flex: 0 0 auto;
  padding: 12px 22px;
  gap: 22px;
}
.scoreboard > div {
  border-right: 1px solid var(--border);
}
.scoreboard > div:last-child {
  border: none;
  text-align: right;
}
.stat-label {
  display: block;
  font: 9px monospace;
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}
#best-scope {
  font-size: 8px;
  letter-spacing: 0;
}
.scoreboard strong {
  font: bold 25px monospace;
  letter-spacing: -1px;
}
.scoreboard small {
  color: var(--muted);
  font-size: 15px;
}
#position {
  color: var(--mint);
}
/* Fit the entire 4:3 arena into the space left by the score and controls.
   Keep overlays inside the same rectangle as the canvas, including fullscreen. */
.arena-stage {
  display: grid;
  flex: 1 1 0;
  min-height: 0;
  place-items: center;
  container-type: size;
  background: #203747;
}

.arena-wrap {
  width: min(100cqw, calc(100cqh * 4 / 3));
  aspect-ratio: 4 / 3;
  container: arena / inline-size;
  position: relative;
  background: #294357;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.track-caption {
  position: absolute;
  inset: 17px 22px auto;
  display: flex;
  justify-content: space-between;
  color: #bad5e3;
  font: 9px monospace;
  letter-spacing: 2px;
  pointer-events: none;
}
.snowflake {
  color: var(--mint);
  margin-left: 8px;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #10233755;
}
.overlay[hidden] {
  display: none;
}
.start-card {
  text-align: center;
  padding: 30px 38px;
  background: #122635f2;
  border: 1px solid #8ab4c559;
  box-shadow: 8px 8px 0 #10223177;
  max-width: 90%;
}
h2 {
  font-size: clamp(27px, 4.5vw, 48px);
  line-height: 1.03;
  letter-spacing: -1px;
  margin: 19px 0;
  font-weight: 900;
}
#overlay-copy {
  font-size: 13px;
  color: #b6cbd6;
  line-height: 1.7;
}
.primary-button {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  background: var(--mint);
  color: #102f2b;
  border: 0;
  padding: 16px 22px;
  margin: 24px auto 19px;
  font-size: 12px;
  letter-spacing: 1.5px;
  font-weight: 800;
  box-shadow: 0 4px 0 #559a84;
}
.primary-button:hover {
  background: #c5ffe7;
}
.overlay-hint {
  font: 8px monospace;
  color: #92aebb;
  letter-spacing: 1px;
}
.countdown {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font: bold 76px monospace;
  color: #fff;
  text-shadow: 5px 5px #1f4a61;
  pointer-events: none;
}
.speed {
  position: absolute;
  right: 24px;
  bottom: 19px;
  color: #e3f8ff;
  text-align: right;
  pointer-events: none;
}
.speed strong {
  font: bold 28px monospace;
}
.speed > span {
  font: 9px monospace;
  margin-left: 7px;
}
.speed-track {
  height: 3px;
  background: #487185;
  width: 95px;
  margin-top: 7px;
}
.speed-track i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--mint);
}
.car-key {
  position: absolute;
  left: 24px;
  bottom: 23px;
  font: 9px monospace;
  color: #cce4ef;
  pointer-events: none;
}
.race-toolbar {
  display: flex;
  gap: 25px;
  align-items: center;
  flex: 0 0 auto;
  padding: 10px 18px;
}
.field label {
  display: block;
  font: 8px monospace;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 7px;
}
select {
  color: #e1ecf2;
  background: #172737;
  border: 0;
  font-size: 12px;
  max-width: 180px;
}
.toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
kbd {
  font: 10px monospace;
  display: inline-block;
  border: 1px solid #3d5364;
  border-bottom-width: 2px;
  padding: 3px 5px;
  border-radius: 3px;
  margin: 0 3px;
  color: #dbeaf0;
}
.below-track {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  flex: 0 0 auto;
  gap: 24px;
  margin: 0;
}
.controls-guide p {
  font-size: 11px;
  color: #c4d4df;
  line-height: 2;
  margin: 4px 0;
}
.muted {
  font-size: 10px;
  color: var(--muted);
}
.driving-tip {
  border-left: 2px solid #426458;
  margin: 0;
  padding: 0 0 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}
.driving-tip span {
  display: block;
  color: var(--mint);
  font: 9px monospace;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
  padding: 8px 0 0;
  font-size: 9px;
  color: #718c9e;
  letter-spacing: 0.5px;
}
.sr-only {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.touch-controls {
  display: none;
  position: absolute;
  bottom: 55px;
  left: 15px;
  right: 15px;
  justify-content: space-between;
  pointer-events: none;
}
.overlay:not([hidden]) ~ .touch-controls {
  visibility: hidden;
}

.touch-controls > div {
  display: flex;
  gap: 9px;
}
.touch-controls button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  border: 1px solid #b9e3ed88;
  color: #e8fbff;
  background: #193c54b3;
  width: 51px;
  height: 49px;
  border-radius: 8px;
  font-size: 21px;
}
.touch-controls .accelerator {
  background: #326b60cc;
}
.game-panel:fullscreen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
}
@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}
/* Scale menus and track labels with the arena, rather than the browser width. */
@container arena (max-width: 650px) {
  .start-card {
    padding: 12px 20px;
  }

  h2 {
    font-size: 28px;
    margin: 9px 0;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 1px;
  }

  #overlay-copy {
    font-size: 11px;
    margin: 7px 0;
  }

  .primary-button {
    padding: 12px 19px;
    margin: 13px auto;
  }

  .overlay-hint {
    font-size: 7px;
    letter-spacing: 0.5px;
  }

  .track-caption {
    inset: 10px 12px auto;
    font-size: 7px;
    letter-spacing: 1px;
  }

  .car-key {
    bottom: 12px;
    left: 12px;
    font-size: 7px;
  }

  .speed {
    right: 12px;
    bottom: 10px;
  }

  .speed strong {
    font-size: 18px;
  }

  .countdown {
    font-size: 48px;
  }
}

@container arena (max-width: 400px) {
  .start-card {
    padding: 8px 12px;
  }

  h2 {
    font-size: 24px;
  }

  .overlay-hint {
    display: none;
  }

  .touch-controls {
    bottom: 42px;
    left: 10px;
    right: 10px;
  }

  .touch-controls button {
    width: 44px;
    height: 44px;
  }
}

/* Keep the surrounding rows the same height as the window grows. */
.shell {
  gap: 5px;
  padding: 6px 16px;
}
.masthead {
  flex-basis: 28px;
}
.brand {
  font-size: 10px;
}
.brand-icon {
  font-size: 25px;
}
.quiet-button {
  padding: 6px 9px;
  font-size: 11px;
}
.intro {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  height: 42px;
  padding: 0;
  gap: 12px;
}
.taglines .eyebrow {
  font-size: 8px;
  letter-spacing: 0.5px;
  margin: 0 0 5px;
}
.subtitle {
  font-size: 10px;
}
h1 {
  font-size: 28px;
  letter-spacing: -1px;
  margin: 0;
  white-space: nowrap;
}
h1 > span:first-child {
  color: #edf5f7;
}
h1 > span:nth-child(2) {
  color: var(--mint);
}
.track-tag {
  text-align: right;
  font-size: 8px;
}
.track-tag strong {
  font-size: 10px;
  margin-top: 4px;
}
.scoreboard {
  padding: 8px 16px;
  gap: 12px;
}
.stat-label {
  margin-bottom: 4px;
}
.scoreboard strong {
  font-size: 21px;
}
.scoreboard small {
  font-size: 12px;
}
.race-toolbar {
  gap: 16px;
  padding: 7px 12px;
}
.field {
  min-width: 0;
}
.field label {
  margin-bottom: 4px;
}
select {
  font-size: 11px;
  max-width: 150px;
  width: 100%;
}
.toolbar-actions {
  gap: 5px;
}
.below-track {
  height: 48px;
  gap: 20px;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
}
.section-label {
  font-size: 8px;
  letter-spacing: 1px;
}
.controls-guide p {
  font-size: 10px;
  margin: 2px 0;
  line-height: 1.3;
}
.controls-guide .muted {
  font-size: 8px;
}
kbd {
  font-size: 8px;
  padding: 2px 3px;
  margin: 0 1px;
}
.driving-tip {
  font-size: 9px;
  line-height: 1.4;
  padding-left: 12px;
}
.driving-tip span {
  font-size: 8px;
  margin-bottom: 3px;
}
.driving-tip #tip-copy {
  color: var(--muted);
  font: inherit;
  letter-spacing: 0;
  margin: 0;
}
footer {
  height: 19px;
  padding: 5px 0 0;
  font-size: 8px;
  letter-spacing: 0;
}
body.dirt {
  --mint: #f3c889;
  --panel: #302c28;
  --border: #554a3c;
}
body.dirt .arena-stage {
  background: #423a2c;
}
body.dirt select {
  background: #302c28;
}
@media (max-width: 700px) {
  .shell {
    padding: 5px 8px;
  }
  .intro {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    height: 54px;
    gap: 6px;
  }
  h1 {
    font-size: clamp(16px, 4.8vw, 21px);
  }
  .track-tag {
    font-size: 7px;
  }
  .track-tag strong {
    margin-top: 4px;
    font-size: 8px;
  }
  .brand-sub {
    font-size: 8px;
    padding-left: 8px;
    margin-left: 0;
  }
  .taglines .eyebrow {
    font-size: 6px;
  }
  .subtitle {
    font-size: 7px;
  }
  .scoreboard {
    padding: 7px 8px;
    gap: 5px;
  }
  .scoreboard strong {
    font-size: 15px;
  }
  .stat-label {
    font-size: 7px;
    letter-spacing: 0;
  }
  #best-scope {
    font-size: 6px;
  }
  .race-toolbar {
    display: grid;
    grid-template-columns: 0.9fr 1.4fr 1.3fr 0.8fr;
    gap: 6px;
  }
  .toolbar-actions {
    grid-column: 1 / -1;
    justify-content: center;
    margin: 0;
  }
  .below-track {
    height: 88px;
    gap: 6px;
  }
  .controls-guide p {
    font-size: 8px;
  }
  .driving-tip {
    font-size: 8px;
    padding-left: 6px;
  }
  footer {
    height: 29px;
    font-size: 7px;
    gap: 8px;
  }
}

.cpu-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 5px 0 10px;
}

/* The player stays mint even when the interface uses the dirt palette. */
.mint-dot {
  background: #8ef2c9;
}
