:root {
  --bg: 10 12 16;
  --panel: 20 24 30;
  --row: 26 31 39;
  --row-hi: 33 40 50;
  --line: 255 255 255;
  --ink: 236 241 246;
  --muted: 139 149 161;
  --lime: 200 245 60;
  --lime-deep: 154 196 32;
  --gold: 242 199 68;
  --silver: 205 213 221;
  --bronze: 209 138 78;
  --down: 240 104 96;

  --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  padding: 2.5rem 1.25rem 3.5rem;
  background:
    radial-gradient(ellipse at 50% -10%, rgb(30 38 50), rgb(var(--bg)) 62%);
  color: rgb(var(--ink));
  font-family: 'Barlow Condensed', system-ui, sans-serif;
}

.page {
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.board-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(var(--lime));
  margin-bottom: 0.15rem;
}

.title {
  font-family: 'Anton', sans-serif;
  font-size: clamp(2.2rem, 7vw, 3.1rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgb(var(--bg));
  background: rgb(var(--lime));
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

.live-badge.is-paused {
  color: rgb(var(--muted));
  background: rgb(var(--line) / 0.12);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(var(--bg));
  animation: pulse 1.4s ease-in-out infinite;
}

.live-badge.is-paused .live-dot {
  background: rgb(var(--muted));
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.72);
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
  }
}

/* ---------- Board ---------- */
.board {
  position: relative;
  padding: 0.9rem 0.9rem 1rem;
  border-radius: 6px;
  background: rgb(var(--panel));
  border: 1px solid rgb(var(--line) / 0.07);
  box-shadow: 0 30px 60px -30px rgb(0 0 0 / 0.8);
}

.board::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgb(var(--lime)), transparent 70%);
}

.board-cols,
.row {
  display: grid;
  grid-template-columns: 56px 1fr 96px;
  align-items: center;
  gap: 0.7rem;
}

.board-cols {
  padding: 0 0.7rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(var(--muted));
}

.col-right {
  text-align: right;
}

.rows {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ---------- Row ---------- */
.row {
  position: relative;
  padding: 0.55rem 0.7rem;
  background: rgb(var(--row));
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
}

/* Accent sits inside the clipped area — a real border-left gets sliced
   diagonally by the clip-path and reads as a stray notch. */
.row::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: rgb(var(--line) / 0.08);
}

.row.is-leader {
  background: rgb(var(--row-hi));
}

.row.is-leader::before {
  background: rgb(var(--lime));
}

.rank-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  font-family: 'Anton', sans-serif;
  font-size: 1.15rem;
  color: rgb(var(--muted));
  background: rgb(var(--line) / 0.06);
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
}

.row[data-rank='1'] .rank-chip {
  color: rgb(var(--bg));
  background: rgb(var(--gold));
}

.row[data-rank='2'] .rank-chip {
  color: rgb(var(--bg));
  background: rgb(var(--silver));
}

.row[data-rank='3'] .rank-chip {
  color: rgb(var(--bg));
  background: rgb(var(--bronze));
}

.racer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: rgb(var(--bg));
}

.racer-id {
  min-width: 0;
  flex: 1;
}

.name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.handle {
  display: block;
  font-size: 0.78rem;
  color: rgb(var(--muted));
}

.delta {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.delta.is-up {
  color: rgb(var(--lime));
  background: rgb(var(--lime) / 0.14);
}

.delta.is-down {
  color: rgb(var(--down));
  background: rgb(var(--down) / 0.14);
}

.score {
  font-family: 'Anton', sans-serif;
  font-size: 1.25rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--ink));
}

.row.is-leader .score {
  color: rgb(var(--lime));
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.ctrl {
  padding: 0.5rem 1rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(var(--ink));
  background: rgb(var(--line) / 0.07);
  border: 1px solid rgb(var(--line) / 0.1);
  border-radius: 4px;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    transform 120ms var(--ease-out-quad);
}

.ctrl:hover {
  border-color: rgb(var(--lime) / 0.5);
}

.ctrl:active {
  transform: translateY(1px);
}

.ctrl-primary {
  color: rgb(var(--bg));
  background: rgb(var(--lime));
  border-color: rgb(var(--lime));
}

.ctrl-primary:hover {
  background: rgb(var(--lime-deep));
  border-color: rgb(var(--lime-deep));
}

.footnote {
  margin-top: 1.1rem;
  font-size: 0.82rem;
  color: rgb(var(--muted));
}

@media (max-width: 520px) {
  .board-cols,
  .row {
    grid-template-columns: 44px 1fr 74px;
  }

  .handle {
    display: none;
  }
}
