:root {
  --bg: #f7f8fa;
  --text: #0f172a;
  --muted: #5b6575;
  --green: #22c55e;
  --red: #e10600;
  --border: #e2e8f0;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}
.sandbox-badge {
  display: inline-block;
  margin: 0 0 0.5rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.top h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  letter-spacing: -0.02em;
}
.tag {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.main {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.15rem;
}
@media (min-width: 820px) {
  .main {
    grid-template-columns: 1.4fr 0.85fr;
    align-items: start;
  }
}
.map-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.75rem;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}
.track-map {
  display: block;
  width: 100%;
  height: auto;
}
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.15rem 1.25rem 1.35rem;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}
.panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.pole-driver {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.pole-event {
  margin: 0.15rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0 0 1rem;
}
.stats div {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
}
.stats dt {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stats dd {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
}
.note {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  background: #111;
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.live {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 1rem 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.92rem;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: livePulse 1.4s ease-out infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
#pole-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: ringPulse 1.1s ease-out infinite;
}
@keyframes ringPulse {
  0% { transform: scale(0.75); opacity: 0.95; }
  100% { transform: scale(2.1); opacity: 0; }
}
.foot {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.zone {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.zone strong { color: var(--text); }
.stats { grid-template-columns: 1fr 1fr; }

/* —— Simulate Race —— */
.race-entry {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.race-entry-note {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.btn-race {
  background: var(--red);
  width: 100%;
}
.btn-green-flag {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25);
}
.btn-yellow-flag {
  background: #ca8a04;
  color: #111;
  box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.28);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.race-event {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.race-status {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  background: #f1f5f9;
}
.status-pace {
  background: #e2e8f0;
  color: #334155;
}
.status-green {
  background: #dcfce7;
  color: #166534;
}
.status-yellow {
  background: #fef08a;
  color: #854d0e;
}
.status-checkered {
  background: repeating-linear-gradient(
    90deg,
    #111 0 10px,
    #f8fafc 10px 20px
  );
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.race-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.race-controls .btn-green-flag,
.race-controls .btn-yellow-flag,
.race-controls .btn-race {
  flex: 1 1 auto;
}
.lb-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}
.lb-head {
  display: grid;
  grid-template-columns: 2rem 2.6rem 1fr 2.4rem 3.4rem;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: #eef2f7;
  border-bottom: 1px solid var(--border);
}
.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.lb-row {
  display: grid;
  grid-template-columns: 2rem 2.6rem 1fr 2.4rem 3.4rem;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid #e8edf3;
  font-size: 0.8rem;
}
.lb-row:last-child { border-bottom: none; }
.lb-leader {
  background: #fff7ed;
}
.lb-pos {
  font-weight: 800;
  color: var(--muted);
}
.lb-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  padding: 0.12rem 0.3rem;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
}
.lb-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-laps,
.lb-time {
  text-align: right;
  font-weight: 700;
  font-size: 0.78rem;
}
.race-source {
  margin: 0.75rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}
.race-car.is-leader {
  filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.9));
}
