:root {
  --bg: #080a18;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7dff00;
  --accent-2: #00e5ff;
  --line: rgba(255, 255, 255, 0.1);
  --chrome-height: 128px; /* header + footer, used to size the stage */
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  /* Two soft lights and a faint grid over the dark. */
  background:
  radial-gradient(1100px 560px at 10% -8%, rgba(120, 60, 255, 0.24), transparent 62%),
  radial-gradient(1000px 520px at 100% 108%, rgba(0, 229, 255, 0.14), transparent 60%),
  linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px) 0 0 / 48px 48px,
  linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px) 0 0 / 48px 48px,
  var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
}

.logo {
  margin: 0;
  font-size: 1.6rem;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 0 20px rgba(125, 255, 0, 0.4);
}

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

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--badge, #888);
  box-shadow: 0 0 14px color-mix(in srgb, var(--badge, #888) 55%, transparent);
  color: #111;
  font-weight: 800;
}

.badge:empty {
  display: none;
}

.stage-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0 16px;
}

/* Fixed 16:9 so every player sees exactly the same amount of upcoming level. */
.stage {
  position: relative;
  width: min(100%, calc((100dvh - var(--chrome-height)) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 70px rgba(0, 229, 255, 0.12);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  animation: fade-in 0.14s ease-out both;
}

/* Darkened corners over the game, composited by the browser so the canvas never pays for them. */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.42) 100%);
  pointer-events: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 10px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(60%, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.progress {
  flex: 1;
  height: 14px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.4), 0 2px 0 rgba(0, 0, 0, 0.4);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left;
}

.progress-label {
  min-width: 4ch;
  font-style: italic;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, 0.7);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 16px;
  background: rgba(5, 8, 20, 0.55);
  text-align: center;
  pointer-events: none;
}

.overlay[hidden] {
  display: none;
}

.overlay p {
  position: relative; /* above the win's rays */
  margin: 0;
}

.overlay-title {
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  font-weight: 900;
  text-shadow: 0 3px 0 #000;
}

.overlay-detail {
  font-weight: 700;
}

.overlay-prompt {
  color: var(--muted);
}

.overlay .overlay-note {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 700;
}

.overlay-note:empty {
  display: none;
}

/* The win: rays turning behind a title that pops in. Only transforms and opacity animate,
   so the browser's compositor runs it without touching layout or the game's canvas. */
.overlay.win {
  overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(5, 8, 20, 0.1), rgba(5, 8, 20, 0.62));
  animation: fade-in 0.25s ease-out both;
}

.overlay.win::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 170vmax;
  height: 170vmax;
  margin: -85vmax 0 0 -85vmax;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.08) 0 7deg, transparent 7deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000, transparent 36%);
  mask-image: radial-gradient(circle, #000, transparent 36%);
  animation: rays 30s linear infinite;
}

.overlay.win .overlay-title {
  font-size: clamp(1.9rem, 6.5vw, 3.8rem);
  font-style: italic;
  text-shadow: 0 3px 0 #0b3d00, 0 0 22px var(--accent), 0 0 64px rgba(125, 255, 0, 0.6);
  animation: title-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.overlay.win .overlay-detail {
  font-size: 1.15rem;
  animation: rise-in 0.4s 0.18s ease-out both;
}

.overlay.win .overlay-note {
  color: #ffd75e;
  font-size: 1.1rem;
  text-shadow: 0 0 16px rgba(255, 197, 49, 0.7);
  animation: rise-in 0.45s 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes title-pop {
  from {
    opacity: 0;
    transform: scale(0.5) rotate(-4deg);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes rays {
  to {
    transform: rotate(360deg);
  }
}

/* Screens slide in when they're shown. */
.menu,
.customize {
  animation: screen-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  padding: 10px 16px 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

kbd {
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  font: inherit;
  font-size: 0.8rem;
}

@media (hover: none) {
  .desktop-only {
    display: none;
  }
}

/* Practice mode: place and remove checkpoints with a tap (Z / X on a keyboard). */
.checkpoint-buttons {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
}

.checkpoint-buttons[hidden] {
  display: none;
}

.checkpoint-buttons button {
  min-width: 52px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}

.checkpoint-buttons button:first-child {
  color: #2bff6a;
}

.checkpoint-buttons span {
  color: var(--muted);
  font-size: 0.75rem;
}

@media (hover: none) {
  .checkpoint-buttons span {
    display: none;
  }
}

/* Start screen: start on the left, today's leaderboard on the right; stacked on phones. */
.menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  width: min(100%, 960px);
  padding: 8px 0 16px;
}

.menu[hidden],
.stage[hidden],
[hidden].name-field,
[hidden].name-show {
  display: none;
}

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

/* Track tabs: one level a day per track, each with its own leaderboard. */
.tracks {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Test levels, on localhost only: one per vehicle, at any rating and speed. */
.tests {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 0.85rem;
}

.tests[hidden] {
  display: none;
}

.tests-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin: 0;
}

.tests-label {
  min-width: 4.5em;
  color: var(--muted);
  font-weight: 700;
}

.tests a {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
}

.tests a:hover {
  border-color: var(--accent-2);
}

.tests a[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: #06110a;
  font-weight: 700;
}

.track {
  display: grid;
  gap: 2px;
  padding: 12px 16px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(40, 46, 90, 0.45), rgba(14, 17, 36, 0.6));
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.track:hover {
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.track[aria-selected='true'] {
  border-color: var(--accent);
  background: linear-gradient(160deg, rgba(125, 255, 0, 0.14), rgba(125, 255, 0, 0.04));
  box-shadow: 0 0 24px rgba(125, 255, 0, 0.2);
}

#track-demon[aria-selected='true'] {
  border-color: #ff4d6d;
  background: linear-gradient(160deg, rgba(255, 77, 109, 0.16), rgba(255, 77, 109, 0.04));
  box-shadow: 0 0 24px rgba(255, 77, 109, 0.24);
}

.track-name {
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 900;
}

.track-done {
  color: var(--accent);
}

.track-done[hidden] {
  display: none;
}

.track-range {
  color: var(--muted);
  font-size: 0.8rem;
}

.track-today {
  color: var(--badge, var(--text));
  font-size: 0.9rem;
  font-weight: 800;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(40, 46, 90, 0.5), rgba(14, 17, 36, 0.72));
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.panel p,
.panel h2 {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-title {
  color: var(--badge, var(--text));
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-style: italic;
  font-weight: 900;
  text-shadow: 0 0 26px color-mix(in srgb, var(--badge, #fff) 50%, transparent);
}

.menu-detail {
  color: var(--muted);
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

.name-field input {
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
}

.name-field input:focus {
  border-color: var(--accent);
  outline: none;
}

.name-error {
  min-height: 1.2em;
  color: #ff6b6b;
  font-size: 0.9rem;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.stats div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.32);
  text-align: center;
}

.stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.stats dd {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.menu-result {
  font-weight: 800;
}

.menu-result:empty {
  display: none;
}

/* After the day's win: the result, where it stands among today's players, and a histogram of
   the attempts winners needed, with yours lit and the rest grey. */
.results {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(125, 255, 0, 0.3);
  border-radius: 12px;
  background: rgba(125, 255, 0, 0.05);
}

.results[hidden],
.dist[hidden] {
  display: none;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.results-line {
  flex: 1 1 14em;
  font-weight: 800;
  line-height: 1.35;
}

.share-button {
  flex: none;
  min-width: 6.5em;
  padding: 8px 16px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: rgba(125, 255, 0, 0.12);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.share-button:hover {
  background: rgba(125, 255, 0, 0.24);
}

.dist {
  margin: 0;
  padding-top: 18px; /* room for "You" over a full-height bar */
}

/* No gap between columns: each bar is narrower than its column, so the air between bars comes
   from that, and the baseline under them runs unbroken. */
.dist-bars {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dist-bar {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  outline: none;
}

.dist-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  height: 64px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.dist-fill {
  flex: none;
  width: min(24px, calc(100% - 4px));
  border-radius: 4px 4px 0 0;
  background: rgba(255, 255, 255, 0.24);
}

.dist-bar:hover .dist-fill,
.dist-bar:focus-visible .dist-fill {
  background: rgba(255, 255, 255, 0.4);
}

.dist-bar.mine .dist-fill {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(125, 255, 0, 0.45);
}

.dist-you {
  flex: none;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 800;
}

.dist-tick {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dist-bar.mine .dist-tick {
  color: var(--text);
  font-weight: 800;
}

.dist-bar:focus-visible .dist-slot {
  border-radius: 4px;
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

/* Each column's bin and count, on hover and keyboard focus. */
.dist-bar::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  z-index: 1;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0e1c;
  color: var(--text);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.12s;
}

.dist-bar:first-child::after {
  left: 0;
  transform: none;
}

.dist-bar:last-child:not(:first-child)::after {
  right: 0;
  left: auto;
  transform: none;
}

.dist-bar:hover::after,
.dist-bar:focus-visible::after {
  opacity: 1;
}

.dist-axis {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.results-note {
  color: var(--muted);
  font-size: 0.85rem;
}

/* The fallback copy's text box: never seen. */
.copy-buffer {
  position: fixed;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
}

.menu-actions {
  display: grid;
  grid-template-columns: auto 2fr 1fr;
  gap: 10px;
  margin-top: auto;
}

/* After the day's win only Practice is left, and it takes the rest of the row. */
.menu-actions:has(.start[hidden]) {
  grid-template-columns: auto 1fr;
}

/* Opens the customize screen; shows the player's cube. */
.skin-button {
  position: relative;
  width: 58px;
  padding: 5px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

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

/* A Victor reward the player hasn't looked at yet. */
.skin-button.new::after {
  content: '';
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: #ffc531;
}

.victor-link {
  padding: 8px 12px;
  border: 1px solid rgba(255, 197, 49, 0.35);
  border-radius: 10px;
  background: rgba(255, 197, 49, 0.08);
  color: #ffd76a;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.victor-link:hover {
  border-color: #ffc531;
}

.victor-link.new {
  border-color: #ffc531;
  background: rgba(255, 197, 49, 0.18);
  color: #fff1a8;
  animation: victor-pulse 1.6s ease-in-out infinite;
}

@keyframes victor-pulse {
  50% {
    box-shadow: 0 0 18px rgba(255, 197, 49, 0.55);
  }
}

@media (prefers-reduced-motion: reduce) {
  .victor-link.new {
    animation: none;
  }
}

.skin-button canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.start[hidden] {
  display: none;
}

.practice-button {
  padding: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}

.practice-button:hover {
  border-color: #2bff6a;
}

.start {
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #a8ff3a, #62d800);
  box-shadow: 0 4px 0 #2f6b00, 0 0 26px rgba(125, 255, 0, 0.35);
  color: #0b0e1c;
  font: inherit;
  font-size: 1.3rem;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.start:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #2f6b00, 0 0 16px rgba(125, 255, 0, 0.3);
}

.start:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #2f6b00, 0 0 36px rgba(125, 255, 0, 0.55);
}

.start:disabled {
  opacity: 0.6;
  cursor: progress;
}

.start-hint {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.board-head h2 {
  font-size: 1.3rem;
  font-weight: 900;
}

.board-head span {
  color: var(--muted);
  font-size: 0.85rem;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Rank, name, best %, attempts: the column labels share the rows' grid so they line up. */
.board-row,
.board-cols {
  display: grid;
  grid-template-columns: 2.5em minmax(0, 1fr) 3.6em 4.6em;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.board-cols {
  padding-block: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.board-cols span:nth-child(n + 3),
.board-percent,
.board-attempts {
  text-align: right;
}

.board-row {
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-variant-numeric: tabular-nums;
}

.board-percent {
  font-weight: 900;
}

/* Beaten: 100%. */
.board-row.beaten .board-percent {
  color: var(--accent);
}

.board-row.you {
  border-color: var(--accent);
  background: rgba(125, 255, 0, 0.07);
  box-shadow: 0 0 16px rgba(125, 255, 0, 0.18);
}

/* The podium. */
.board-row.rank-1 .board-rank {
  color: #ffd75e;
  text-shadow: 0 0 10px rgba(255, 197, 49, 0.6);
}

.board-row.rank-2 .board-rank {
  color: #d6deef;
}

.board-row.rank-3 .board-rank {
  color: #e2955a;
}

.board-row.apart {
  margin-top: 10px;
}

.board-rank {
  color: var(--muted);
  font-weight: 800;
}

.board-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-attempts {
  font-weight: 700;
}

.board-note {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Customize: icons on the left, colours on the right; stacked on phones. */
.customize {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  width: min(100%, 960px);
  padding: 8px 0 16px;
}

.customize[hidden] {
  display: none;
}

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

.customize-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.customize-head h2 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 900;
}

.customize-done {
  padding: 10px 28px;
  font-size: 1.1rem;
}

.vehicle-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.vehicle-tab {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.vehicle-tab canvas {
  width: 38px;
  height: 38px;
}

.vehicle-tab:hover,
.icon-cell:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.vehicle-tab[aria-selected='true'] {
  border-color: var(--accent);
  background: rgba(125, 255, 0, 0.08);
  color: var(--text);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.icon-cell {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.icon-cell canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.icon-cell[aria-pressed='true'] {
  border-color: var(--accent);
  background: rgba(125, 255, 0, 0.1);
}

/* Victor rewards: the track across the top of Customize, and each vehicle's reward cell. */
.victor {
  grid-column: 1 / -1;
  gap: 10px;
  border-color: rgba(255, 197, 49, 0.3);
  background: linear-gradient(120deg, rgba(120, 40, 220, 0.2), rgba(255, 197, 49, 0.08));
}

.victor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.victor-head h3 {
  margin: 0;
  color: #ffd76a;
  font-size: 1.15rem;
  font-weight: 900;
}

.victor-head span,
.victor-next {
  color: var(--muted);
  font-weight: 700;
}

.victor-next {
  font-size: 0.85rem;
}

.victor-track {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 720px) {
  .victor-track {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.victor-badge {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 2px solid rgba(255, 197, 49, 0.5);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: #ffd76a;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 900;
  cursor: pointer;
}

.victor-badge canvas {
  width: 100%;
  max-width: 64px;
  height: auto;
  aspect-ratio: 1;
}

.victor-badge[aria-pressed='true'] {
  border-color: #ffc531;
  background: rgba(255, 197, 49, 0.14);
  box-shadow: 0 0 14px rgba(255, 197, 49, 0.5);
}

.victor-badge.locked {
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

.victor-badge.locked canvas,
.reward-cell.locked canvas {
  filter: grayscale(1) brightness(0.5);
}

.reward-cell {
  position: relative;
  border-color: rgba(255, 197, 49, 0.45);
  background: linear-gradient(135deg, rgba(120, 40, 220, 0.4), rgba(255, 197, 49, 0.15));
}

.reward-cell[aria-pressed='true'] {
  border-color: #ffc531;
}

.reward-lock {
  position: absolute;
  inset: auto 0 3px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.customize-colors {
  align-items: center;
}

/* The preview sits on a sky like the game's. */
.skin-preview {
  width: 100%;
  height: 112px;
  border-radius: 10px;
  background: linear-gradient(hsl(222, 70%, 42%), hsl(222, 75%, 18%));
}

.color-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.color-slot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  padding: 8px 10px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.color-slot[aria-pressed='true'] {
  border-color: var(--accent);
}

.slot-swatch {
  grid-row: span 2;
  width: 30px;
  height: 30px;
  border: 2px solid #000;
  border-radius: 6px;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.slot-name {
  font-size: 0.9rem;
  font-weight: 800;
}

.slot-hex,
.color-hex input {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

.slot-hex {
  color: var(--muted);
  font-size: 0.8rem;
}

.color-wheel {
  width: min(100%, 220px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: crosshair;
  touch-action: none;
}

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

.color-value {
  display: grid;
  gap: 6px;
  width: min(100%, 260px);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.color-value input {
  height: 16px;
  margin: 0;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: linear-gradient(90deg, #000, var(--top, #fff));
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.color-value input::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  border: 3px solid #000;
  border-radius: 50%;
  background: #fff;
  -webkit-appearance: none;
}

.color-value input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid #000;
  border-radius: 50%;
  background: #fff;
}

.palette {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.swatch {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid #000;
  border-radius: 6px;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.swatch[aria-pressed='true'] {
  box-shadow: 0 0 0 3px var(--text);
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  width: 100%;
}

.color-hex {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.color-hex input {
  width: 10ch;
  padding: 6px 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.9rem;
}

.color-hex input:focus {
  border-color: var(--accent);
  outline: none;
}

.color-hex input.invalid {
  border-color: #ff6b6b;
}

/* 404.html */
.notfound {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
}

.notfound p {
  margin: 0;
}

.notfound a {
  color: var(--accent);
  font-weight: 800;
}
