/* CARBON — quiet, graphite-and-glass UI. One accent colour, hairline borders,
   tabular numerals, very little secondary text. */

:root {
  --bg: #08090b;
  --surface: rgba(16, 18, 22, 0.66);
  --surface-strong: rgba(14, 16, 20, 0.92);
  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f3;
  --text-2: rgba(238, 240, 243, 0.58);
  --text-3: rgba(238, 240, 243, 0.34);
  --accent: #e8283a;
  --green: #3ddc84;
  --purple: #a970ff;
  --amber: #f0b429;
  --radius: 14px;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --font-num: "SF Pro Display", -apple-system, "Helvetica Neue", "DIN Alternate", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}

button {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

#gl-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  outline: none;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
}

.screen.active {
  display: block;
}

/* ==================== LOBBY ==================== */
#menu-screen {
  display: none;
  flex-direction: column;
  padding: 28px 40px 32px;
}

#menu-screen.active {
  display: flex;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(8, 9, 11, 0.35) 0%, rgba(8, 9, 11, 0.86) 70%),
    linear-gradient(180deg, rgba(8, 9, 11, 0.55) 0%, rgba(8, 9, 11, 0.2) 40%, rgba(8, 9, 11, 0.9) 100%);
  backdrop-filter: blur(3px) saturate(0.85);
  z-index: -1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 26px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.32em;
}

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

.topnav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.lobby {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 40px;
}

.section-label {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.12em;
  margin-bottom: 14px;
}

/* Track list */
.col-tracks {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.track-card {
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.18s, border-color 0.18s;
}

.track-card:hover {
  background: rgba(255, 255, 255, 0.035);
}

.track-card.selected {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--hairline-strong);
}

.tc-name {
  font-size: 15px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
}

.tc-medal {
  font-size: 13px;
}

.tc-meta {
  margin-top: 4px;
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-3);
}

.track-list.locked .track-card {
  cursor: default;
}

.track-list.locked .track-card:not(.selected) {
  opacity: 0.4;
}

/* Preview */
.col-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.circuit-country {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.16em;
}

.circuit-title {
  margin-top: 6px;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.blueprint-wrap {
  flex: 1;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#track-blueprint {
  width: 100%;
  height: 100%;
  max-height: 46vh;
  object-fit: contain;
}

.elevation {
  width: 100%;
  height: 44px;
  opacity: 0.9;
}

.stats-row {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.stat span {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.stat strong {
  font-family: var(--font-num);
  font-size: 20px;
  font-weight: 500;
}

.stat.accent strong {
  color: #fff;
}

.stat i {
  font-style: normal;
}

.ghost-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.ghost-label {
  color: var(--text-3);
  margin-right: 8px;
}

.ghost-val {
  font-family: var(--font-num);
  color: var(--text-2);
  margin-right: auto;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.text-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.text-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.text-btn.danger:hover {
  color: #ff6b78;
}

/* Setup column */
.col-setup {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.setup-group {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.cfg-label {
  font-size: 12px;
  color: var(--text-3);
}

.seg-control {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-control button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 13px;
  padding: 8px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.seg-control button:hover {
  color: var(--text);
}

.seg-control button.active {
  background: rgba(255, 255, 255, 0.92);
  color: #0b0c0f;
  font-weight: 600;
}

.seg-control.big button {
  font-size: 14px;
  padding: 11px 6px;
}

.seg-control.small {
  min-width: 170px;
}

.seg-control.small button {
  padding: 6px 4px;
  font-size: 12px;
}

.drawer-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  border-top: 1px solid var(--hairline);
  padding: 14px 0 0;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.drawer-toggle i {
  font-style: normal;
  transition: transform 0.2s;
}

.drawer-toggle:hover {
  color: var(--text);
}

.assists-drawer {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.assists-drawer.open {
  display: flex;
}

.drawer-toggle:has(+ .assists-drawer.open) i {
  transform: rotate(90deg);
}

.setup-spacer {
  flex: 1;
}

.champ-card {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.cc-title {
  font-size: 14px;
  font-weight: 600;
}

.cc-line {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
}

.champ-card .text-btn {
  margin-left: -10px;
  font-size: 12px;
}

.controls-card {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--text-3);
}

.controls-card span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

kbd {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline-strong);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-2);
}

.btn-launch {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: filter 0.15s, transform 0.15s;
}

.btn-launch:hover {
  filter: brightness(1.08);
}

.btn-launch:active {
  transform: scale(0.99);
}

/* ==================== HUD ==================== */
#hud-screen.active {
  pointer-events: none;
}

#hud-screen button {
  pointer-events: auto;
}

#hud-screen.replay-mode > * {
  display: none !important;
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--hairline);
}

/* Start lights */
.start-lights {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 30;
}

.gantry-pod {
  display: flex;
  gap: 16px;
  background: rgba(6, 7, 9, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid var(--hairline);
  padding: 14px 22px;
  border-radius: 18px;
}

.light-bulb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1a1214;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8);
  transition: background 0.05s, box-shadow 0.05s;
}

.light-bulb.red {
  background: radial-gradient(circle at 40% 35%, #ff6a75, #e8283a 55%, #9e0f1d);
  box-shadow: 0 0 18px rgba(232, 40, 58, 0.85);
}

.light-bulb.green {
  background: radial-gradient(circle at 40% 35%, #8af3b7, #3ddc84 55%, #178a4c);
  box-shadow: 0 0 18px rgba(61, 220, 132, 0.8);
}

.start-msg {
  font-size: 13px;
  color: var(--text-2);
  letter-spacing: 0.2em;
}

/* Top left */
.hud-top-left {
  position: absolute;
  top: 22px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.race-pos-card {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.pos-box strong {
  font-family: var(--font-num);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
}

.pos-box small {
  font-family: var(--font-num);
  font-size: 16px;
  color: var(--text-3);
  margin-left: 2px;
}

.lap-box .lbl {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.14em;
  margin-right: 6px;
}

.lap-box strong {
  font-family: var(--font-num);
  font-size: 18px;
  font-weight: 500;
}

.standings-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 210px;
}

.st-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 5px 10px;
  background: rgba(8, 9, 11, 0.5);
  backdrop-filter: blur(10px);
  color: var(--text-2);
}

.st-row:first-child { border-radius: 8px 8px 0 0; }
.st-row:last-child { border-radius: 0 0 8px 8px; }

.st-row b {
  font-family: var(--font-num);
  font-weight: 500;
  color: var(--text-3);
}

.st-row em {
  font-style: normal;
  font-family: var(--font-num);
  color: var(--text-3);
}

.st-row.player {
  color: #fff;
  background: rgba(232, 40, 58, 0.32);
}

.st-row.player b,
.st-row.player em {
  color: #fff;
}

/* Top centre timing */
.hud-top-center {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 20;
}

.timing-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timing-main strong {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

.invalid-tag {
  font-size: 11px;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
}

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

.delta-bar-track {
  position: relative;
  width: 220px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.delta-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  transition: width 0.1s linear, left 0.1s linear;
}

.delta-fill.faster { background: var(--green); }
.delta-fill.slower { background: var(--accent); }

.delta-val {
  font-family: var(--font-num);
  font-size: 13px;
  min-width: 46px;
  color: var(--text-3);
}

.delta-val.faster { color: var(--green); }
.delta-val.slower { color: #ff5a68; }

.sectors-row {
  display: flex;
  gap: 4px;
}

.sector-pill {
  width: 86px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 9px 6px;
  font-size: 12px;
  background: rgba(8, 9, 11, 0.5);
  backdrop-filter: blur(10px);
  border-radius: 7px;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
}

.sector-pill span {
  font-size: 10px;
  color: var(--text-3);
}

.sector-pill strong {
  font-family: var(--font-num);
  font-weight: 500;
}

.sector-pill.green { border-color: var(--green); color: #fff; }
.sector-pill.purple { border-color: var(--purple); color: #fff; }
.sector-pill.yellow { border-color: var(--amber); color: #fff; }
.sector-pill.invalid { border-color: var(--accent); color: var(--text-3); }
.sector-pill.prev { opacity: 0.5; }

.time-sub {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-3);
}

.time-sub b {
  font-family: var(--font-num);
  font-weight: 500;
  color: var(--text-2);
  margin-left: 4px;
}

.time-sub b.invalid {
  color: #ff5a68;
  text-decoration: line-through;
}

.banner-alert {
  background: rgba(232, 40, 58, 0.88);
  color: #fff;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 99px;
}

.banner-alert.pit {
  background: rgba(240, 180, 41, 0.92);
  color: #16120a;
}

.hud-toast {
  font-size: 13px;
  color: #fff;
  background: rgba(8, 9, 11, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hairline-strong);
  padding: 7px 16px;
  border-radius: 99px;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* Corner preview (AR) */
.ar-hud {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  z-index: 15;
  opacity: 0.85;
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.ar-dist {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
  margin-top: -6px;
  padding: 7px 14px 8px;
  border-radius: 12px;
  background: rgba(8, 9, 11, 0.5);
  backdrop-filter: blur(8px);
  text-shadow: none;
}

.ar-dist b {
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 600;
  color: #fff;
}

.ar-dist span {
  font-family: var(--font-num);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

.ar-dist em {
  font-style: normal;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
}

.ar-hud.state-brake .ar-dist em { color: #ff8a94; font-weight: 600; }

.ar-hud.state-straight { opacity: 0.45; }
.ar-hud.state-corner { opacity: 0.75; }
.ar-hud.state-approach { opacity: 0.9; }
.ar-hud.state-approach .ar-dist b { color: #f6c453; }
.ar-hud.state-brake { opacity: 1; }
.ar-hud.state-brake .ar-dist b { color: #ff5a68; }

/* Top right */
.hud-top-right {
  position: absolute;
  top: 22px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hud-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(8, 9, 11, 0.45);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.icon-btn.wide {
  min-width: 52px;
}

.assist-pills {
  display: flex;
  gap: 4px;
}

.apill {
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 5px;
  color: transparent;
  transition: background 0.08s, color 0.08s;
}

.apill.active-flash {
  color: #16120a;
  background: var(--amber);
}

.hud-fps {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--text-3);
}

/* Proximity radar */
.proximity-radar {
  position: absolute;
  top: 178px;
  left: 50%;
  transform: translateX(-50%) scale(0.62);
  transform-origin: top center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.proximity-radar.visible {
  opacity: 0.9;
}

/* Bottom left minimap */
.hud-bottom-left {
  position: absolute;
  left: 24px;
  bottom: 24px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(8, 9, 11, 0.4);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hairline);
}

#hud-minimap {
  display: block;
  width: 176px;
  height: 140px;
}

/* Bottom centre cluster */
.hud-bottom-center {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.cluster {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: end;
  column-gap: 16px;
  row-gap: 8px;
  padding: 12px 20px 14px;
  border-radius: 18px;
  background: rgba(8, 9, 11, 0.42);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
}

.gear-num {
  font-family: var(--font-num);
  font-size: 46px;
  font-weight: 600;
  line-height: 0.9;
  min-width: 30px;
  text-align: center;
}

.speed-stack {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.speed-stack strong {
  font-family: var(--font-num);
  font-size: 34px;
  font-weight: 400;
  line-height: 0.9;
  min-width: 64px;
  text-align: right;
}

.speed-stack span {
  font-size: 11px;
  color: var(--text-3);
}

.rpm-mini-wrap {
  grid-column: 1 / span 2;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.rpm-mini-bar {
  height: 100%;
  width: 0;
  background: rgba(255, 255, 255, 0.85);
}

.rpm-mini-bar.shift {
  background: var(--accent);
}

.pbar {
  position: relative;
  width: 4px;
  height: 64px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.pbar .fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
}

.pbar .fill.brk { background: var(--accent); }
.pbar .fill.thr { background: var(--green); }

/* Bottom right tyres */
.hud-bottom-right {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.tires-grid {
  display: grid;
  grid-template-columns: 46px 46px;
  gap: 4px 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(8, 9, 11, 0.42);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hairline);
}

.tire-box {
  height: 40px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.3s, background 0.3s;
}

.tire-box b {
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 500;
}

.tire-box .wear {
  font-family: var(--font-num);
  font-size: 10px;
  color: var(--text-3);
}

.tire-box.ok { border-color: rgba(61, 220, 132, 0.35); }
.tire-box.cold { border-color: rgba(120, 170, 255, 0.45); }
.tire-box.hot { border-color: rgba(232, 40, 58, 0.7); background: rgba(232, 40, 58, 0.12); }
.tire-box.worn .wear { color: #ff7a85; }

.fuel-line {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(8, 9, 11, 0.42);
}

.fuel-line.low {
  color: #fff;
  background: rgba(232, 40, 58, 0.7);
}

.key-viz {
  display: flex;
  gap: 3px;
  opacity: 0.55;
}

.key-viz span {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text-3);
  border: 1px solid var(--hairline-strong);
}

.key-viz span.on {
  color: #0b0c0f;
  background: rgba(255, 255, 255, 0.9);
}

/* ==================== REPLAY BAR ==================== */
.replay-bar {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 48px));
  z-index: 40;
  padding: 14px 18px 12px;
  border-radius: 18px;
  background: rgba(10, 11, 14, 0.72);
  backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--hairline-strong);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rp-top {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 13px;
}

.rp-badge {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.14em;
  font-size: 11px;
}

.rp-car {
  font-weight: 500;
}

.rp-info {
  color: var(--text-2);
  font-family: var(--font-num);
}

.rp-time {
  margin-left: auto;
  color: var(--text-2);
  font-family: var(--font-num);
}

.rp-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rp-sep {
  flex: 1;
}

/* ==================== RANGE INPUTS ==================== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
}

/* ==================== MODALS ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 5, 7, 0.62);
  backdrop-filter: blur(16px) saturate(0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--surface-strong);
  border: 1px solid var(--hairline-strong);
  border-radius: 22px;
  padding: 30px 32px;
  width: 440px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.modal-card.wide {
  width: min(720px, calc(100vw - 48px));
}

.modal-kicker {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.16em;
  margin-bottom: -10px;
}

.modal-card h2 {
  font-size: 24px;
  font-weight: 600;
}

.modal-card h2.headline {
  font-size: 34px;
}

.modal-note {
  font-size: 12px;
  color: var(--text-3);
}

.modal-note.warn {
  color: #ff7a85;
}

.pause-toggles {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.pt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 14px;
  color: var(--text-2);
}

.pt-row > span:first-child {
  min-width: 84px;
}

.pt-row b {
  font-family: var(--font-num);
  font-weight: 500;
  min-width: 42px;
  text-align: right;
  color: var(--text);
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-btns.row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal-btns.row .btn-launch {
  order: 10;
  padding: 12px 22px;
  font-size: 14px;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row .btn-secondary {
  flex: 1;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 11px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.btn-secondary:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-secondary.danger {
  color: #ff7a85;
}

.finish-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  padding: 4px 0 2px;
}

.finish-summary .stat-cell span {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 5px;
}

.finish-summary .stat-cell strong {
  font-family: var(--font-num);
  font-size: 20px;
  font-weight: 500;
}

.badge {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--purple);
  border-radius: 4px;
  padding: 2px 5px;
  vertical-align: middle;
}

.finish-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--hairline);
}

.finish-tabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-3);
  cursor: pointer;
}

.finish-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.finish-body {
  min-height: 140px;
  overflow-y: auto;
}

.results-table-wrap {
  max-height: 300px;
  overflow-y: auto;
}

.results-table-wrap.tall {
  max-height: 46vh;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results-table th {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-3);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
}

.results-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-num);
  color: var(--text-2);
}

.results-table td:first-child {
  color: var(--text-3);
}

.results-table td small {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-ui);
  margin-top: 1px;
}

.results-table tr.me td {
  color: #fff;
  background: rgba(232, 40, 58, 0.14);
}

.results-table tr.best td {
  color: #fff;
}

.results-table tr.invalid td {
  color: var(--text-3);
}

.results-table td.purple {
  color: var(--purple);
}

.tag {
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-2);
}

.tag.bad {
  background: rgba(232, 40, 58, 0.2);
  color: #ff7a85;
}

.bind-btn {
  min-width: 96px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.bind-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.bind-btn.capturing {
  border-color: var(--accent);
  color: #fff;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% { background: rgba(232, 40, 58, 0.2); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1180px) {
  .lobby {
    grid-template-columns: 200px 1fr 290px;
    gap: 28px;
  }
  .circuit-title { font-size: 32px; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  #menu-screen {
    overflow-y: auto;
    padding: 20px;
  }
  .lobby {
    grid-template-columns: 1fr;
  }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* Keep the start button reachable while the setup column scrolls (assists drawer open) */
.col-setup > .btn-launch {
  position: sticky;
  bottom: 0;
  flex-shrink: 0;
  box-shadow: 0 -18px 24px 6px rgba(8, 9, 11, 0.85);
}
.col-setup > .controls-card { flex-shrink: 0; }

/* PB video player */
.video-card { width: min(980px, calc(100vw - 48px)); }
.video-card video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 16 / 9; }
.modal-btns a.btn-secondary { text-decoration: none; display: inline-flex; align-items: center; }

.ar-dist .brake-bar {
  display: block;
  width: 150px;
  height: 3px;
  margin-top: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.ar-dist .brake-bar i {
  display: block;
  height: 100%;
  background: #f6c453;
  transition: width 0.1s linear;
}
.ar-hud.state-brake .ar-dist .brake-bar i { background: #ff4555; }

.ar-hud.state-guide {
  opacity: 0;
  transition: opacity 0.45s ease, margin-top 0.45s ease;
  margin-top: 8px;
}
.ar-hud.state-guide.show { opacity: 0.92; margin-top: 0; }
.ar-hud.state-guide .ar-dist em { font-size: 12px; color: rgba(255, 255, 255, 0.6); }
