:root {
  --bg: #14161c;
  --panel: #1e222b;
  --panel-soft: #262b36;
  --line: #343b48;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #e08a3c;
  --accent-soft: #ffb163;
  --ok: #7ddc8a;
  --warn: #ffcf4a;
  --bad: #ff6b5a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  /* No rubber-banding under a thumb that misses a control. */
  overscroll-behavior: none;
}

#app {
  position: relative;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
}

.screen.active {
  display: block;
}

.screen.race.active {
  display: block;
  overflow: hidden;
}

.title-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  text-align: center;
}

/* The title screen is wider: the circuit carousel wants the room. The lobby
   shows the same one, so it needs the same width. */
#screen-title .title-wrap,
#screen-lobby .title-wrap {
  max-width: 820px;
}

.logo {
  margin: 0 0 6px;
  font-size: clamp(40px, 8.5vw, 66px);
  letter-spacing: -1.5px;
  font-weight: 800;
  /* Solid offsets before the soft one: that stack is what gives a plain web
     font the extruded weight of a cartoon title. */
  text-shadow:
    0 3px 0 #1e2128,
    0 6px 0 rgba(0, 0, 0, 0.45),
    0 18px 26px rgba(0, 0, 0, 0.6);
}

.logo span {
  color: var(--accent-soft);
}

.logo em {
  display: inline-block;
  margin-left: 10px;
  padding: 0 12px 4px;
  transform: rotate(-6deg);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffc178, #dd7f2f);
  color: #1e2128;
  font-style: normal;
  text-shadow: none;
  box-shadow: 0 4px 0 #1e2128, 0 12px 18px rgba(0, 0, 0, 0.5);
}

.tagline {
  margin: 0 0 4px;
  color: var(--muted);
}

.version {
  margin: 0 0 24px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--line);
}

.section-title {
  font-size: clamp(24px, 5vw, 34px);
  margin: 10px 0 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-shadow: 0 3px 0 #1e2128, 0 10px 18px rgba(0, 0, 0, 0.5);
}

.section-title span {
  color: var(--accent-soft);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  text-align: left;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span,
.field > label > span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.field.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pick-name {
  font-style: normal;
  color: var(--accent-soft);
  text-transform: none;
  letter-spacing: 0;
}

/* One row, always: sixteen coats share whatever width there is rather than
   spilling onto a second line and shoving the panel about. */
.swatches {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
}

.swatches button {
  flex: 1 1 0;
  min-width: 0;
  max-width: 30px;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.swatches button.square {
  border-radius: 9px;
}

.swatches button.on {
  border-color: var(--text);
  transform: scale(1.12);
}

/* The little turntable, standing beside the two rows of swatches it shows. */
.look-config {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 16px;
}

.look-config .look-rows > .field:last-child {
  margin-bottom: 0;
}

.preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #232833;
  overflow: hidden;
}

.preview canvas {
  display: block;
  width: 100%;
  /* Pixels, not a percentage: a canvas would otherwise stretch itself to the
     aspect ratio of its drawing buffer. */
  height: 178px;
}

/* Hyper speed: the edges of the screen streak past and the middle stays put,
   which is what makes it read as speed rather than as a flash. */
#hud-warp {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s linear;
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, 0) 24%, rgba(159, 232, 255, 0.32) 62%, rgba(120, 200, 255, 0.6) 100%),
    repeating-conic-gradient(
      from 0deg at 50% 52%,
      rgba(255, 255, 255, 0.5) 0deg 0.5deg,
      rgba(255, 255, 255, 0) 0.5deg 3.2deg
    );
  mix-blend-mode: screen;
}

#hud-warp.on {
  opacity: 1;
  animation: warp-pulse 0.45s linear infinite;
}

/* The white core the streaks are coming out of. */
#hud-warp b {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 26vmin;
  height: 26vmin;
  margin: -13vmin 0 0 -13vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 68%);
}

@keyframes warp-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.25);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@media (max-width: 620px) {
  .look-config {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------- circuit carousel */

.carousel {
  /* One fixed height for every circuit: a longer description must not make
     the whole box grow, or flicking through them jumps about. */
  --car-height: 194px;
  --car-view: 174px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  grid-template-areas: 'prev stage next' 'dots dots dots';
  align-items: center;
  gap: 8px;
  outline: none;
}

.carousel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.car-nav {
  grid-area: prev;
  height: var(--car-height);
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.car-nav.next {
  grid-area: next;
}

.car-nav:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.car-stage {
  position: relative;
  grid-area: stage;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 10px;
  padding: 10px;
  height: var(--car-height);
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: rgba(224, 138, 60, 0.1);
  touch-action: pan-y;
}

/* The window on the circuit: a lap flown from the racing line.
   The height is spelled out in pixels on purpose. A canvas carries the aspect
   ratio of its width/height attributes, and `height: 100%` next to
   `width: 100%` lets that ratio win — which stretched it well past its box. */
.car-3d {
  display: block;
  width: 100%;
  height: var(--car-view);
  border-radius: 10px;
  background: #232833;
}

.carousel.flat .car-3d {
  display: none;
}

.carousel.flat .car-stage {
  grid-template-columns: minmax(0, 1fr);
}

.car-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.car-map {
  width: 100%;
  height: 88px;
  flex: none;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
}

.car-info {
  min-width: 0;
}

.car-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Always two lines' worth, however short the description is. */
.car-sub {
  display: block;
  height: 2.6em;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}

.car-dist {
  font-style: normal;
  font-weight: 700;
  color: var(--accent-soft);
}

.car-count {
  position: absolute;
  top: 8px;
  left: 12px;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.55);
  color: var(--muted);
  font-size: 11.5px;
  pointer-events: none;
}

.car-dots {
  grid-area: dots;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 8px;
}

.car-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--line);
  cursor: pointer;
}

.car-dot:hover {
  background: var(--muted);
}

.car-dot.on {
  background: var(--accent);
  transform: scale(1.3);
}

@media (max-width: 620px) {
  /* Stacked, so the fixed height gives way to the content. */
  .carousel {
    --car-height: auto;
    --car-view: 130px;
  }

  .car-stage {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
}

.btn {
  padding: 11px 18px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #201306;
}

.btn.primary:hover {
  background: var(--accent-soft);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.actions .btn {
  flex: 1;
}

.controls-help {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 22px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: center;
}

/* A button sitting on its own under a panel needs room to breathe. */
.title-wrap > .btn {
  margin-top: 20px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

.status {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--bad);
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- binds */

.binds {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.binds li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.binds .def {
  color: var(--muted);
  font-size: 13px;
}

.binds li.capturing .bind {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------------------------------------------------------------- lobby */

.players {
  list-style: none;
  margin: 0;
  padding: 0;
}

.players li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

/* Each player is shown by their caddy itself, turning, rather than by a dot. */
.players canvas {
  width: 92px;
  height: 92px;
  flex: none;
  border-radius: 8px;
  background: #232833;
}

.players .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.players .tag {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------- results */

.results {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}

.results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
}

/* People stand out from the computer cats, and you stand out from them. */
.results li.human {
  color: var(--text);
  font-weight: 600;
}

.results li.me {
  background: rgba(224, 138, 60, 0.2);
  border: 1px solid var(--accent);
  padding: 8px 9px;
  font-weight: 800;
}

.results li.me .name::after {
  content: ' · toi';
  color: var(--accent-soft);
  font-weight: 600;
}

.results li.me .pos {
  color: var(--accent-soft);
}

.results .pos {
  width: 26px;
  font-weight: 800;
  color: var(--muted);
}

.results li.p1 .pos {
  color: var(--accent-soft);
}

.results .swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.results .name {
  flex: 1;
}

.results .time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

/* ---------------------------------------------------------------- race */

.screen.race {
  background: #0d0f14;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* A thumb dragged across the road must steer, not scroll the page. */
  touch-action: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.hud-corner {
  position: absolute;
  display: flex;
  gap: 10px;
}

.top-left {
  top: 16px;
  left: 16px;
  align-items: flex-start;
}

.top-right {
  top: 16px;
  right: 16px;
  flex-direction: column;
  align-items: flex-end;
}

/* The damage gauge lives dead centre at the top, where the eyes already are. */
.top-center {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 46%;
}

.bottom-left {
  bottom: 16px;
  left: 16px;
  flex-direction: column;
}

.bottom-right {
  bottom: 16px;
  right: 16px;
}

.badge {
  background: rgba(16, 18, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 13px;
  font-size: 13px;
  color: var(--muted);
}

.badge b {
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.badge.place b {
  color: var(--accent-soft);
}

/* Which circuit we are on, under the lap counter. */
.badge.track {
  padding: 5px 11px;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--accent-soft);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A mouse loose in the field. High on the screen, out of the way of the
   sens-interdit banner, and it flashes for as long as the thing is running. */
.hud-alert {
  position: absolute;
  top: 88px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 7px 18px 8px;
  border-radius: 12px;
  background: rgba(60, 22, 10, 0.82);
  border: 2px solid #ffb347;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.hud-alert.show {
  opacity: 1;
  transform: translate(-50%, 0);
  animation: alert-flash 0.6s ease-in-out infinite;
}

.hud-alert b {
  display: block;
  font-size: 19px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffd8a8;
}

.hud-alert i {
  font-style: normal;
  font-size: 13px;
  color: #ffb347;
}

.hud-alert i:empty {
  display: none;
}

@keyframes alert-flash {
  0%,
  100% {
    border-color: #ffb347;
    box-shadow: 0 0 0 rgba(255, 179, 71, 0);
  }
  50% {
    border-color: #fff0d0;
    box-shadow: 0 0 18px rgba(255, 179, 71, 0.55);
  }
}

/* Driving back down the track: impossible to miss, and it says what to do. */
.hud-wrongway {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 12px 26px;
  border-radius: 14px;
  background: rgba(120, 20, 14, 0.82);
  border: 2px solid var(--bad);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.hud-wrongway.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: wrongway 0.7s ease-in-out infinite;
}

.hud-wrongway b {
  display: block;
  font-size: 26px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hud-wrongway i {
  font-style: normal;
  font-size: 14px;
  color: #ffd0c8;
}

@keyframes wrongway {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.timebox {
  background: rgba(16, 18, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 168px;
}

.timebox .row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.timebox .row b {
  color: var(--text);
}

.timebox .row.best b {
  color: var(--ok);
}

.standings {
  list-style: none;
  margin: 0;
  padding: 6px 10px;
  background: rgba(16, 18, 24, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  min-width: 168px;
}

.standings li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 2px 0;
  color: var(--muted);
}

.standings.dense li {
  font-size: 11.5px;
  padding: 0;
  gap: 6px;
}

.standings.dense .gauge {
  height: 4px;
}

/* A person on the leaderboard, not a computer cat. */
.standings li.human {
  color: var(--text);
  font-weight: 600;
}

.standings li.me {
  color: var(--text);
  font-weight: 700;
}

.standings li.seen {
  color: #9fd0ff;
}

.standings i {
  width: 14px;
  font-style: normal;
  text-align: right;
}

/* A wrecked caddy: the skull stays until its cat is back on the track. */
.standings li.dead {
  color: var(--bad);
}

.standings li.dead i {
  font-size: 11px;
}

.standings b {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.standings span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  max-width: 104px;
}

.standings em {
  font-style: normal;
  margin-left: auto;
}

.standings .gauge {
  width: 34px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.standings .gauge u {
  display: block;
  height: 100%;
}

.standings .gauge.ok u {
  background: var(--ok);
}

.standings .gauge.warn u {
  background: var(--warn);
}

.standings .gauge.bad u {
  background: var(--bad);
}

.standings .done {
  font-size: 11px;
  color: var(--ok);
}

.damage {
  background: rgba(16, 18, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 14px;
  width: 260px;
}

.damage-title {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.damage-title i {
  font-style: normal;
  color: var(--text);
}

.damage-bar {
  margin-top: 5px;
  height: 9px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.damage-bar div {
  height: 100%;
  width: 100%;
  transition: width 0.15s linear;
}

.damage-bar .ok {
  background: var(--ok);
}

.damage-bar .warn {
  background: var(--warn);
}

.damage-bar .bad {
  background: var(--bad);
}

.item-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 18, 24, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 11px;
  padding: 5px 9px;
  width: 186px;
  opacity: 0.72;
}

.item-slot canvas {
  width: 32px;
  height: 32px;
  flex: none;
}

.item-meta {
  flex: 1;
  min-width: 0;
}

.item-meta span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-slot em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  opacity: 0.7;
}

.item-slot.armed {
  opacity: 1;
  background: rgba(16, 18, 24, 0.6);
  border-color: rgba(255, 210, 120, 0.45);
  box-shadow: 0 0 14px rgba(255, 190, 90, 0.14);
}

#minimap {
  width: 240px;
  height: 180px;
  background: rgba(16, 18, 24, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

#hud-effects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#hud-effects span {
  border: 1px solid;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(16, 18, 24, 0.68);
}

#hud-tags {
  position: absolute;
  inset: 0;
}

/* Milk on the windscreen: fat white blobs that fade away. */
#hud-splash {
  position: absolute;
  inset: 0;
  opacity: 0;
  display: none;
  overflow: hidden;
}

#hud-splash.show {
  display: block;
}

/* The first instant is a full coat: no track, no cat, nothing. */
#hud-splash u {
  position: absolute;
  inset: -2%;
  display: block;
  background: radial-gradient(circle at 44% 40%, #ffffff 0%, #ffffff 58%, #eef4ff 100%);
  opacity: 0;
}

#hud-splash i {
  position: absolute;
  border-radius: 48% 52% 44% 56% / 52% 46% 54% 48%;
  background: radial-gradient(circle at 38% 34%, #ffffff 0%, #f6f9ff 62%, rgba(240, 246, 255, 0.72) 100%);
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.7);
  filter: blur(1px);
}

#view {
  transition: filter 0.12s linear;
}

#hud-tags .tag {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 18, 24, 0.6);
  font-size: 11.5px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s linear;
}

#hud-tags .tag b {
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

#hud-tags .tag .hp {
  display: block;
  width: 30px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

#hud-tags .tag .hp u {
  display: block;
  height: 100%;
  background: var(--ok);
}

#hud-tags .tag .hp.warn u {
  background: var(--warn);
}

#hud-tags .tag .hp.bad u {
  background: var(--bad);
}

.hud-spectate {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(16, 18, 24, 0.72);
  border: 1px solid rgba(159, 208, 255, 0.5);
  white-space: nowrap;
}

.hud-spectate.show {
  display: flex;
}

.hud-spectate span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.hud-spectate b {
  color: #9fd0ff;
}

.hud-spectate em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 8px;
}

.hud-message {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  text-align: center;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.hud-message.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hud-message b {
  display: block;
  font-size: 56px;
  font-weight: 800;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.hud-message i {
  font-style: normal;
  color: var(--accent-soft);
  font-size: 20px;
}

.hud-toast {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 19px;
  font-weight: 700;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hud-toast.show {
  opacity: 1;
}

.btn.quit {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  opacity: 0.45;
}

.btn.quit:hover {
  opacity: 1;
}

@media (max-width: 720px) {
  .damage {
    width: 200px;
  }

  .item-slot {
    width: 180px;
  }

  #minimap {
    width: 150px;
    height: 112px;
  }

  .logo {
    font-size: 40px;
  }
}

/* ------------------------------------------------------- touch controls */

/* Nothing on a machine with a keyboard: `body.touch` is only set when the page
   is opened on something you drive with your thumbs.
   The overlay is addressed by its id on purpose — a bare `.touch` selector also
   matches the body itself, and hiding the body hides the game. */
#touch {
  display: none;
}

body.touch #touch {
  display: block;
  position: absolute;
  inset: 0;
  /* The overlay itself lets taps through; only the controls catch them. */
  pointer-events: none;
  z-index: 6;
}

body.touch .touch-steer,
body.touch .touch-btn {
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The HUD steps out of the way of the thumbs. */
body.touch .bottom-left,
body.touch .bottom-right {
  bottom: 148px;
}

body.touch #minimap {
  width: 168px;
  height: 126px;
}

body.touch .item-slot {
  width: 190px;
}

/* Two arrows, not a slider: a pad you slide a thumb across is impossible to
   hold a line with on a moving screen. */
.touch-steer {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 12px;
}

.touch-btn.steer {
  width: 104px;
  height: 104px;
  font-size: 26px;
  line-height: 1;
  background: rgba(224, 138, 60, 0.22);
}

.touch-right {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  flex-direction: row-reverse;
  gap: 12px;
}

.touch-btn {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(12, 14, 18, 0.42);
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 50%;
}

.touch-btn.gas {
  width: 118px;
  height: 118px;
  background: rgba(155, 226, 74, 0.28);
}

.touch-btn.brake {
  width: 88px;
  height: 88px;
  background: rgba(217, 79, 79, 0.26);
}

.touch-btn.item {
  width: 78px;
  height: 78px;
  background: rgba(224, 138, 60, 0.26);
}

.touch-btn.on {
  border-color: var(--accent);
  color: #fff;
}

/* Short screens held sideways: everything shrinks so the road stays visible. */
@media (max-height: 460px) {
  .touch-btn.steer {
    width: 82px;
    height: 82px;
  }

  .touch-btn.gas {
    width: 92px;
    height: 92px;
  }

  .touch-btn.brake {
    width: 72px;
    height: 72px;
  }

  .touch-btn.item {
    width: 64px;
    height: 64px;
  }

  body.touch .bottom-left,
  body.touch .bottom-right {
    bottom: 118px;
  }
}

/* The keyboard hints have nothing to say on a touch screen. */
body.touch .no-touch {
  display: none;
}

/* A phone held upright has no room for three round buttons in a row: the gas
   becomes a tall pill on the edge, with the other two stacked beside it. */
@media (max-width: 560px) {
  .touch-btn.steer {
    width: 78px;
    height: 78px;
    font-size: 22px;
  }

  .touch-steer {
    gap: 8px;
  }

  .touch-right {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas:
      'gas item'
      'gas brake';
    gap: 8px;
    align-items: end;
  }

  .touch-btn.gas {
    grid-area: gas;
    width: 94px;
    height: 152px;
    border-radius: 47px;
  }

  .touch-btn.brake {
    grid-area: brake;
    width: 72px;
    height: 72px;
  }

  .touch-btn.item {
    grid-area: item;
    width: 72px;
    height: 72px;
  }

  /* The buttons are taller here, so the HUD has to climb higher still — and
     shrink, or the minicard and the bonus slot meet in the middle. */
  body.touch .bottom-left,
  body.touch .bottom-right {
    bottom: 176px;
  }

  body.touch #minimap {
    width: 140px;
    height: 105px;
  }

  body.touch .item-slot {
    width: 168px;
  }

  /* Place, lap and the clock meet in the middle of a narrow screen. */
  body.touch .top-left {
    transform: scale(0.8);
    transform-origin: 0 0;
  }

  body.touch .top-right {
    transform: scale(0.8);
    transform-origin: 100% 0;
  }
}

/* On a touch screen the way out has to be somewhere a thumb can reach without
   crossing the controls, and visible enough to find in a hurry. */
body.touch .btn.quit {
  top: 10px;
  right: 10px;
  left: auto;
  bottom: auto;
  transform: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  opacity: 0.85;
  /* The word goes; the cross takes its place. */
  font-size: 0;
  z-index: 7;
}

body.touch .btn.quit::before {
  content: '✕';
  font-size: 19px;
  line-height: 42px;
}

/* The clock ducks under it, and the damage bar leaves the middle: a phone is
   too narrow for three groups across the top. */
body.touch .top-right {
  top: 60px;
}

/* On a phone it moves out from under the running order, which reaches down
   the right-hand side: left-hand edge, below the damage bar, and no subtitle. */
body.touch .hud-alert {
  top: 112px;
  left: 12px;
  transform: none;
  padding: 5px 12px 6px;
}

body.touch .hud-alert.show {
  transform: none;
}

body.touch .hud-alert b {
  font-size: 15px;
}

body.touch .hud-alert i {
  display: none;
}

body.touch .top-center {
  top: 60px;
  left: 16px;
  transform: none;
  align-items: flex-start;
}

/* The row that stands for everyone left out of a shortened list. */
.standings li.gap {
  justify-content: center;
  gap: 6px;
  padding: 1px 0;
  min-height: 12px;
  color: rgba(255, 255, 255, 0.55);
}

/* Dashed rules either side, so a shortened list reads as shortened. */
.standings li.gap::before,
.standings li.gap::after {
  content: '';
  flex: 1 1 0;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.4) 0 3px,
    transparent 3px 6px
  );
}

.standings li.gap span {
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

