:root {
  color-scheme: dark;

  --neutral-1: oklch(0.145 0.004 80);
  --neutral-2: oklch(0.175 0.004 80);
  --neutral-3: oklch(0.205 0.004 80);
  --neutral-4: oklch(0.235 0.004 80);
  --neutral-5: oklch(0.265 0.004 80);
  --neutral-6: oklch(0.305 0.004 80);
  --neutral-7: oklch(0.36 0.004 80);
  --neutral-8: oklch(0.48 0.004 80);
  --neutral-10: oklch(0.775 0.004 80);
  --neutral-11: oklch(0.87 0.004 80);
  --neutral-12: oklch(0.97 0.004 80);
  --accent-3: oklch(0.26 0.05 95);
  --accent-7: oklch(0.5 0.1 95);
  --accent-9: oklch(0.88 0.17 95);
  --accent-11: oklch(0.9 0.14 95);
  --danger-11: oklch(0.79 0.121 25);

  --color-bg-page: var(--neutral-1);
  --color-bg-sunken: var(--neutral-2);
  --color-bg-surface: var(--neutral-3);
  --color-bg-surface-hover: var(--neutral-4);
  --color-bg-control: var(--neutral-4);
  --color-bg-control-hover: var(--neutral-5);
  --color-bg-selected: var(--neutral-6);
  --color-bg-inverse: var(--neutral-12);
  --color-bg-overlay: oklch(0.145 0.004 80 / 0.8);
  --color-bg-hud: oklch(0.145 0.004 80 / 0.72);
  --color-border-subtle: oklch(1 0 0 / 0.07);
  --color-border: var(--neutral-7);
  --color-border-strong: var(--neutral-8);
  --color-text-primary: var(--neutral-12);
  --color-text-secondary: var(--neutral-11);
  --color-text-tertiary: var(--neutral-10);
  --color-text-disabled: var(--neutral-8);
  --color-text-inverse: var(--neutral-1);
  --color-accent-subtle: var(--accent-3);
  --color-accent-border: var(--accent-7);
  --color-accent-solid: var(--accent-9);
  --color-accent-solid-hover: var(--accent-11);
  --color-accent-text: var(--accent-11);
  --color-danger-text: var(--danger-11);
  --color-focus-ring: var(--accent-9);
  --color-rank-1: var(--accent-9);
  --ring-accent: 0 0 0 2px var(--color-accent-solid);

  --shadow-surface: 0 0 0 1px var(--color-border-subtle), 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-popover: 0 0 0 1px oklch(1 0 0 / 0.09), 0 24px 64px oklch(0 0 0 / 0.55);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --sans: "Public Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scrollbar-gutter: stable;
  background: var(--color-bg-page);
}

body {
  min-height: 100svh;
  margin: 0;
  background: var(--color-bg-page);
  color: var(--color-text-secondary);
  font: 15px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--color-accent-solid);
  color: var(--color-text-inverse);
}

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  color: var(--color-text-primary);
  text-wrap: balance;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease-out);
}

.skip:focus {
  transform: none;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-primary);
  font-weight: 600;
  text-decoration: none;
}

.mark {
  width: 22px;
  height: 22px;
}

.slash {
  color: var(--color-border);
}

.crumb {
  overflow: hidden;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  padding: 3px;
  border-radius: 12px;
  background: var(--color-bg-sunken);
  box-shadow: inset 0 0 0 1px var(--color-border-subtle);
}

.tabs a {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--color-text-tertiary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition-property: color, background-color, transform;
  transition-duration: 0.2s, 0.2s, 0.15s;
  transition-timing-function: var(--ease-out);
}

.tabs a:active {
  transform: scale(0.96);
}

.tabs a[aria-current="page"] {
  background: var(--color-bg-selected);
  color: var(--color-text-primary);
}

.badge {
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--color-accent-solid);
  color: var(--color-text-inverse);
  font-size: 11px;
  font-weight: 800;
  animation: rise 0.3s var(--ease-out) both;
}

.badge[hidden] {
  display: none;
}

.watch-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.watch-chip svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-primary);
}

.bar-end {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.me-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 12px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
  animation: rise 0.45s var(--ease-out) both;
}

.me-chip[hidden] {
  display: none;
}

.me-meta {
  display: grid;
  gap: 4px;
}

.me-name {
  max-width: 12ch;
  overflow: hidden;
  color: var(--color-text-primary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.level {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--color-accent-solid);
  color: var(--color-text-inverse);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.level.pulse {
  animation: pulse 0.9s var(--ease-out);
}

@keyframes pulse {
  30% {
    transform: scale(1.15);
    box-shadow: 0 0 0 4px var(--color-bg-page), 0 0 0 6px var(--color-accent-solid);
  }
}

.xp-bar {
  position: relative;
  display: block;
  width: 72px;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--color-bg-selected);
}

.xp-bar.big {
  flex: 1;
  width: auto;
  height: 8px;
  border-radius: 4px;
}

.xp-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--color-accent-solid);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  transition: transform 0.9s var(--ease-out);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--color-text-primary);
  cursor: pointer;
  transition-property: transform, background-color;
  transition-duration: 0.15s, 0.2s;
  transition-timing-function: var(--ease-out);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  transition-property: opacity, scale, filter;
  transition-duration: 0.25s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.icon-btn .off,
.icon-btn.off .on {
  opacity: 0;
  scale: 0.25;
  filter: blur(4px);
}

.icon-btn.off .off {
  opacity: 1;
  scale: 1;
  filter: none;
}

.screen {
  animation: rise 0.5s var(--ease-out) both;
}

.screen[hidden] {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(12px);
  }
}

.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: clamp(460px, 74svh, 660px);
  overflow: hidden;
  border-radius: 24px;
  background: var(--color-bg-sunken);
  box-shadow: var(--shadow-surface);
  isolation: isolate;
}

.hero canvas {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, oklch(0.145 0.004 80 / 0.88), oklch(0.145 0.004 80 / 0.3) 55%, transparent),
    linear-gradient(0deg, oklch(0.145 0.004 80 / 0.7), transparent 50%);
  pointer-events: none;
}

.hero-content {
  flex: 0 1 500px;
  min-width: 0;
  padding: 36px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lede {
  max-width: 30em;
  margin: 0 0 24px;
  color: var(--color-text-secondary);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.field {
  display: flex;
  gap: 4px;
  max-width: 440px;
  padding: 4px;
  border-radius: 16px;
  background: var(--color-bg-inverse);
  box-shadow: 0 8px 32px oklch(0 0 0 / 0.35);
  transition: box-shadow 0.25s var(--ease-out);
}

.field:focus-within {
  box-shadow: var(--ring-accent), 0 8px 32px oklch(0 0 0 / 0.35);
}

.field input {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--color-text-inverse);
  font: inherit;
  font-size: 16px;
}

.field input::placeholder {
  color: oklch(0.5 0.03 288);
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  text-decoration: none;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--color-bg-control);
  color: var(--color-text-primary);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition-property: transform, background-color, box-shadow, color;
  transition-duration: 0.15s, 0.2s, 0.25s, 0.2s;
  transition-timing-function: var(--ease-out);
}

.btn:active {
  transform: scale(0.96);
}

.btn.primary {
  height: 44px;
  padding: 0 20px;
  background: var(--color-accent-solid);
  color: var(--color-text-inverse);
}

.btn:disabled,
.btn.primary:disabled {
  background: var(--color-bg-control);
  color: var(--color-text-disabled);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.btn.small {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
}

.swap {
  display: inline-block;
  transition: opacity 0.15s linear;
}

.swap.out {
  opacity: 0;
}

.error {
  min-height: 1.55em;
  margin: 12px 0 0;
  color: var(--color-danger-text);
}

.hint {
  margin: 0;
  color: var(--color-text-tertiary);
  font-size: 14px;
}

.hint.center {
  text-align: center;
}

.fresh {
  animation: rise 0.3s var(--ease-out) both;
}

.section {
  padding-top: 64px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section > h2 {
  margin-bottom: 24px;
}

.section p {
  margin: 0;
  font-size: 14px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 0 0 32px;
  padding: 0;
  list-style: none;
}

.step-n {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--color-bg-control);
  box-shadow: inset 0 0 0 1px var(--color-border-subtle);
  color: var(--color-text-primary);
  font-size: 13px;
  font-weight: 700;
}

.rules {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.rule {
  display: flex;
  gap: 14px;
  padding: 18px;
  border-radius: 16px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
}

.rule svg {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--color-text-primary);
}

.seg {
  --i: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border-radius: 14px;
  background: var(--color-bg-sunken);
  box-shadow: inset 0 0 0 1px var(--color-border-subtle);
}

.seg-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 10px;
  background: var(--color-bg-selected);
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.08);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.3s var(--ease-in-out);
}

.seg label {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 76px;
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--color-text-tertiary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition-property: color, transform;
  transition-duration: 0.2s, 0.15s;
  transition-timing-function: var(--ease-out);
}

.seg label:active {
  transform: scale(0.96);
}

.seg label:has(input:checked) {
  color: var(--color-text-primary);
}

.seg label:has(input:focus-visible) {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg.readonly label {
  cursor: default;
}

.seg.readonly label:active {
  transform: none;
}

.board {
  display: grid;
  gap: 6px;
  min-height: 120px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.board-row {
  display: grid;
  grid-template-columns: 36px 1fr repeat(3, 76px);
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
  animation: rise 0.45s var(--ease-out) both;
  animation-delay: calc(var(--n) * 40ms);
}

.board-head {
  padding-top: 0;
  padding-bottom: 0;
  background: none;
  box-shadow: none;
  color: var(--color-text-tertiary);
  font-size: 12px;
  animation: none;
}

.board-row .num {
  text-align: right;
}

.board-row strong {
  color: var(--color-text-primary);
  font-weight: 600;
}

.rank {
  color: var(--color-text-tertiary);
  font-weight: 700;
}

.board-row:nth-child(2) .rank {
  color: var(--color-rank-1);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

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

.who .level {
  min-width: 24px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px;
}

.board-empty {
  display: grid;
  place-items: center;
  padding: 32px;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1.5px var(--color-border-subtle);
  color: var(--color-text-tertiary);
  text-align: center;
  animation: rise 0.4s var(--ease-out) both;
}

.swatch {
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: 5px;
  box-shadow: inset 0 -4px 6px oklch(0 0 0 / 0.25), inset 0 0 0 1px oklch(1 0 0 / 0.15);
}

.room-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.garage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 520px;
  overflow: hidden;
  border-radius: 24px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
}

.garage-canvas {
  flex: 1;
  width: 100%;
  min-height: 300px;
  border-radius: 24px 24px 0 0;
  cursor: grab;
  touch-action: pan-y;
}

.garage-canvas:active {
  cursor: grabbing;
}

.garage-canvas:focus-visible {
  outline-offset: -4px;
}

.garage-controls {
  display: grid;
  gap: 16px;
  padding: 0 20px 20px;
}

.garage-row h3,
.panel-row h3 {
  margin-bottom: 8px;
  color: var(--color-text-tertiary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.swatches,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pick {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 12px;
  cursor: pointer;
  transition-property: transform, box-shadow, background-color, color;
  transition-duration: 0.15s, 0.25s, 0.2s, 0.2s;
  transition-timing-function: var(--ease-out);
}

.pick:active {
  transform: scale(0.96);
}

.pick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pick:has(input:focus-visible) {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.swatches .pick {
  width: 40px;
  height: 40px;
  padding: 4px;
  box-shadow: inset 0 0 0 1px var(--color-border-subtle);
}

.swatches .pick span:first-of-type {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  box-shadow: inset 0 -6px 10px oklch(0 0 0 / 0.3), inset 0 0 0 1px oklch(1 0 0 / 0.15);
}

.swatches .pick:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--color-text-primary);
}

.chips .pick {
  display: flex;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: var(--color-bg-control);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.chips .pick:has(input:checked) {
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
}

.pick.locked {
  cursor: not-allowed;
}

.swatches .pick.locked span:first-of-type {
  opacity: 0.25;
}

.chips .pick.locked {
  color: var(--color-text-tertiary);
}

.lock {
  position: absolute;
  inset: auto -4px -4px auto;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--color-bg-selected);
  color: var(--color-text-primary);
  font-size: 10px;
  font-weight: 700;
}

.chips .lock {
  position: static;
}

.pick.shake {
  animation: shake 0.35s var(--ease-out);
}

@keyframes shake {
  25% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}

.room-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  padding: 20px;
  border-radius: 24px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
}

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

.panel-title {
  font-size: 17px;
}

.room-grid.spectating {
  grid-template-columns: 1fr;
  max-width: 560px;
  margin-inline: auto;
}

.room-grid.spectating .garage,
.room-grid.spectating .start {
  display: none;
}

.slots {
  display: grid;
  gap: 8px;
}

.slot {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--color-bg-control);
  box-shadow: inset 0 0 0 1px var(--color-border-subtle);
}

.slot.enter {
  animation: rise 0.45s var(--ease-out) both;
}

.slot.empty {
  justify-content: center;
  gap: 10px;
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--color-border-subtle);
  color: var(--color-text-tertiary);
}

.slot.empty::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--color-accent-solid);
  animation: wait 1.4s var(--ease-in-out) infinite;
}

@keyframes wait {
  50% {
    opacity: 0.25;
    transform: scale(0.7);
  }
}

.slot-main {
  display: grid;
  min-width: 0;
}

.slot-name {
  overflow-wrap: anywhere;
  color: var(--color-text-primary);
  font-weight: 600;
}

.tags {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.tag {
  padding: 0 6px;
  border-radius: 6px;
  background: var(--color-bg-selected);
  color: var(--color-text-secondary);
  font-size: 12px;
}

.slot .level {
  margin-left: auto;
}

.slots-count {
  color: var(--color-text-tertiary);
  font-size: 13px;
}

.panel-row .seg {
  margin-bottom: 8px;
}

.share {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 14px;
  border-radius: 12px;
  background: var(--color-bg-sunken);
  box-shadow: inset 0 0 0 1px var(--color-border-subtle);
}

.link {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--color-text-primary);
  font: 13px var(--mono);
  scrollbar-width: none;
}

.start {
  width: 100%;
  margin-top: auto;
}

.stage {
  position: relative;
  border-radius: 24px;
}

.track-stage {
  height: clamp(320px, 54svh, 540px);
  margin-top: 8px;
  overflow: hidden;
  background: var(--color-bg-sunken);
  box-shadow: var(--shadow-surface);
  isolation: isolate;
}

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

.hud {
  position: absolute;
  inset: 12px;
  color: var(--color-text-primary);
  pointer-events: none;
}

.hud-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--color-bg-hud);
  font-weight: 700;
}

.hud-chip > span {
  font-size: 26px;
  line-height: 1.1;
}

.hud-chip small {
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.hud-top {
  display: flex;
  gap: 8px;
}

.track-bar {
  position: relative;
  flex: 1;
  height: 44px;
  padding: 0 40px 0 18px;
  border-radius: 12px;
  background: var(--color-bg-hud);
}

.track-line {
  position: absolute;
  inset: 50% 40px auto 18px;
  height: 4px;
  border-radius: 2px;
  background: oklch(1 0 0 / 0.16);
  transform: translateY(-50%);
}

.track-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--color-accent-solid);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
}

.flag {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 18px;
  height: 18px;
  color: var(--color-text-primary);
  transform: translateY(-50%);
}

.markers {
  position: absolute;
  inset: 0 40px 0 18px;
}

.marker {
  position: absolute;
  top: 50%;
  left: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 7px;
  color: var(--color-text-inverse);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 0 2px var(--color-bg-page);
  will-change: transform;
}

.marker.me {
  z-index: 2;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 9px;
  font-size: 12px;
  box-shadow: 0 0 0 2px var(--color-bg-page), 0 0 0 4px var(--color-text-primary);
}

.marker.left {
  opacity: 0.35;
}

.hud-watch {
  flex: none;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s var(--ease-out);
}

.hud-watch > span {
  font-size: 15px;
}

.hud-watch svg {
  width: 16px;
  height: 16px;
}

.hud-watch.none {
  opacity: 0;
}

.hud-togo {
  flex: none;
  align-items: center;
}

.tower {
  position: absolute;
  top: 56px;
  left: 0;
  width: 208px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tower-row {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: 18px 4px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--color-bg-hud);
  font-size: 13px;
  transform: translateY(calc(var(--rank) * 34px));
  transition: transform 0.3s var(--ease-in-out);
}

.spectating .tower {
  pointer-events: auto;
}

.spectating .tower-row {
  cursor: pointer;
}

.tower-row:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 1px;
}

.tower-row.me {
  background: var(--color-accent-subtle);
  box-shadow: inset 0 0 0 1px var(--color-accent-border);
}

.tower-row.left {
  opacity: 0.5;
}

.tower-pos {
  color: var(--color-text-secondary);
  font-weight: 800;
  text-align: right;
}

.tower-stripe {
  width: 4px;
  height: 16px;
  border-radius: 2px;
}

.tower-name {
  overflow: hidden;
  color: var(--color-text-primary);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tower-gap {
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.hud-speed,
.hud-place {
  position: absolute;
  bottom: 0;
}

.hud-speed {
  left: 0;
}

.hud-speed > span {
  min-width: 2.4ch;
  text-align: right;
}

.hud-sub {
  margin-left: 6px;
  padding-left: 10px;
  box-shadow: inset 1px 0 0 oklch(1 0 0 / 0.16);
}

.hud-place {
  right: 0;
}

.banner {
  position: absolute;
  top: 56px;
  left: 50%;
  margin: 0;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--color-bg-hud);
  box-shadow: inset 0 0 0 1px var(--color-accent-border);
  color: var(--color-text-primary);
  font-weight: 600;
  white-space: nowrap;
  transform: translateX(-50%);
  animation: rise 0.45s var(--ease-out) both;
}

.banner[hidden] {
  display: none;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--color-text-primary);
  font-size: 96px;
  font-weight: 800;
  text-shadow: 0 2px 16px oklch(0 0 0 / 0.6);
  pointer-events: none;
}

.countdown span {
  animation: count 0.9s var(--ease-out) both;
}

@keyframes count {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: scale(0.6);
  }
  60% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
  to {
    opacity: 0;
    filter: blur(4px);
    transform: scale(1.15);
  }
}

.words {
  position: relative;
  height: calc(3 * 1.7em);
  margin-top: 20px;
  overflow: hidden;
  color: var(--color-text-tertiary);
  font: 25px/1.7 var(--mono);
  cursor: text;
}

.words-inner {
  transition: transform 0.25s var(--ease-out);
}

.word {
  display: inline-block;
  white-space: pre;
}

.done {
  color: var(--color-text-primary);
  transition: color 0.12s linear;
}

.wrong,
.extra {
  color: var(--color-danger-text);
}

.wrong {
  text-decoration: underline 2px;
  text-underline-offset: 5px;
}

.missed {
  color: var(--color-danger-text);
  opacity: 0.6;
  text-decoration: underline dotted 2px;
  text-underline-offset: 5px;
}

.caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 1.2em;
  border-radius: 1px;
  background: var(--color-accent-solid);
  transition: transform 0.08s linear;
}

.caret.over {
  animation: over 0.3s;
}

@keyframes over {
  30% {
    background: var(--color-danger-text);
    translate: 3px 0;
  }
}

.words.idle .caret {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.spectate-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
  animation: rise 0.45s var(--ease-out) both;
}

.spectate-bar[hidden],
.keys[hidden] {
  display: none;
}

.spectate-bar .hint {
  flex: 1;
  min-width: 200px;
}

.page-title {
  font-size: 32px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 6px;
}

.live-head {
  align-items: flex-end;
  margin: 24px 0 24px;
}

.live-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.live-card {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-surface);
  animation: rise 0.45s var(--ease-out) both;
  animation-delay: calc(var(--n, 0) * 50ms);
}

.live-meta {
  display: grid;
  gap: 4px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-primary);
  font-size: 13px;
  font-weight: 700;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--color-text-tertiary);
}

.status.racing::before {
  background: var(--color-accent-solid);
  animation: wait 1.4s var(--ease-in-out) infinite;
}

.status.countdown::before {
  background: var(--color-rank-1);
}

.live-code {
  color: var(--color-text-tertiary);
  font: 13px var(--mono);
}

.live-racers {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.live-racer {
  display: grid;
  grid-template-columns: 20px minmax(0, 110px) 1fr;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.live-racer .swatch {
  width: 20px;
  height: 12px;
  border-radius: 4px;
}

.live-racer strong {
  overflow: hidden;
  color: var(--color-text-primary);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.live-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--color-bg-selected);
}

.live-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  transition: transform 1s linear;
}

.live-side {
  display: flex;
  align-items: center;
  gap: 14px;
}

.live-empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 48px 24px;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1.5px var(--color-border-subtle);
  color: var(--color-text-tertiary);
  text-align: center;
  animation: rise 0.4s var(--ease-out) both;
}

.live-empty strong {
  color: var(--color-text-primary);
  font-size: 16px;
}

.keys {
  margin-top: 14px;
  font-size: 13px;
}

.ghost {
  position: fixed;
  top: 0;
  left: -100px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.finish {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  overscroll-behavior: contain;
  background: var(--color-bg-overlay);
  animation: fade 0.3s var(--ease-out) both;
}

.finish[hidden] {
  display: none;
}

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

.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 460px;
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 24px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-popover);
  animation: rise 0.5s var(--ease-out) both;
}

.card:focus {
  outline: none;
}

.card h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card .hint:empty {
  display: none;
}

.card .hint {
  margin-top: -10px;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row {
  display: grid;
  grid-template-columns: 28px auto 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--color-bg-control);
  font-size: 14px;
  animation: rise 0.45s var(--ease-out) both;
  animation-delay: calc(var(--n, 0) * 60ms);
}

.row.me {
  box-shadow: inset 0 0 0 1px var(--color-accent-border);
}

.row .place {
  color: var(--color-text-secondary);
  font-weight: 800;
}

.row:nth-child(1) .place {
  color: var(--color-rank-1);
}

.row .swatch {
  width: 20px;
  height: 12px;
  border-radius: 4px;
}

.row strong {
  overflow: hidden;
  color: var(--color-text-primary);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.finish-xp {
  display: grid;
  gap: 10px;
  animation: rise 0.45s var(--ease-out) 0.2s both;
}

.finish-xp[hidden] {
  display: none;
}

.xp-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.xp-gain {
  min-width: 7ch;
  color: var(--color-text-primary);
  font-weight: 700;
  text-align: right;
}

.unlock {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--color-accent-subtle);
  box-shadow: inset 0 0 0 1px var(--color-accent-border);
  color: var(--color-text-primary);
  font-size: 14px;
  animation: rise 0.45s var(--ease-out) both;
}

.unlock[hidden] {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .tabs a:not([aria-current="page"]):hover {
    color: var(--color-text-primary);
  }
  .spectating .tower-row:not(.me):hover {
    background: oklch(0.265 0.004 80 / 0.9);
  }
  .brand:hover {
    opacity: 0.8;
  }
  .icon-btn:hover {
    background: oklch(1 0 0 / 0.07);
  }
  .btn:hover {
    background: var(--color-bg-control-hover);
  }
  .btn.primary:hover {
    background: var(--color-accent-solid-hover);
  }
  .btn:disabled:hover,
  .btn.primary:disabled:hover {
    background: var(--color-bg-control);
    box-shadow: none;
  }
  .chips .pick:not(:has(input:checked)):hover {
    background: var(--color-bg-control-hover);
  }
  .rule {
    transition-property: transform, box-shadow;
    transition-duration: 0.25s;
    transition-timing-function: var(--ease-out);
  }
  .rule:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px oklch(1 0 0 / 0.12), 0 12px 32px oklch(0 0 0 / 0.35);
  }
}

@media (max-width: 860px) {
  .room-grid {
    grid-template-columns: 1fr;
  }
  .garage {
    min-height: 440px;
  }
}

@media (max-width: 760px) {
  .live-card {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .live-side {
    justify-content: space-between;
  }
  .steps,
  .rules {
    grid-template-columns: 1fr;
  }
  .steps {
    gap: 20px;
  }
  .board-row {
    grid-template-columns: 28px 1fr 68px 44px;
  }
  .board-row .acc {
    display: none;
  }
}

@media (max-width: 560px) {
  .crumb,
  .me-meta {
    display: none;
  }
  .brand-text {
    display: none;
  }
  .tabs a {
    padding: 0 10px;
  }
  .hero-content {
    padding: 20px;
  }
  .hero::before {
    background: linear-gradient(0deg, oklch(0.145 0.004 80 / 0.94), oklch(0.145 0.004 80 / 0.4) 65%, transparent);
  }
  .seg label {
    min-width: 0;
  }
  .words {
    font-size: 19px;
  }
  .hud-chip > span {
    font-size: 20px;
  }
  .hud-togo,
  .hud-sub {
    display: none;
  }
  .tower {
    width: 92px;
  }
  .tower-row {
    grid-template-columns: 14px 4px 1fr;
    gap: 6px;
    padding: 0 8px;
  }
  .tower-gap {
    display: none;
  }
  .countdown {
    font-size: 72px;
  }
  .row {
    grid-template-columns: 22px auto 1fr auto auto;
  }
  .row .time {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes rise {
    from {
      opacity: 0;
    }
  }
  @keyframes count {
    from {
      opacity: 0;
    }
    50% {
      opacity: 1;
    }
    to {
      opacity: 0;
    }
  }
  @keyframes pulse {
    30% {
      box-shadow: 0 0 0 4px var(--color-bg-page), 0 0 0 6px var(--color-accent-solid);
    }
  }
  .pick.shake,
  .slot.empty::before,
  .status.racing::before,
  .caret.over {
    animation: none;
  }
  .btn:active,
  .icon-btn:active,
  .pick:active,
  .seg label:active {
    transform: none;
  }
  .tower-row,
  .live-fill,
  .seg-thumb,
  .words-inner,
  .caret {
    transition-duration: 0.01ms;
  }
  .rule:hover {
    transform: none;
  }
}
