:root {
  --bg-glass: rgba(20, 29, 38, 0.78);
  --bg-glass-strong: rgba(15, 23, 32, 0.92);
  --border-glass: rgba(255, 255, 255, 0.14);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #ffd426; /* Iconic Kolkata Yellow Cab */
  --accent-dim: rgba(255, 212, 38, 0.16);
  --p2-accent: #38bdf8; /* Kolkata Nil-Sada Blue */
  --danger: #f87171;
  --warn-bg: rgba(120, 53, 15, 0.88);
  --warn-border: #f59e0b;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1e293b;
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.hidden {
  display: none !important;
}

/* Shared Glassmorphic Elements */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
}

.pill-btn {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.pill-btn:hover {
  border-color: var(--accent);
  background: rgba(30, 41, 59, 0.9);
}

.pill-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.pill-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Top Bar */
.top-bar {
  position: fixed;
  top: 16px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 30;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  font-size: 14px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.brand-slashes {
  color: var(--accent);
  font-style: italic;
  font-size: 18px;
}

.brand-sep {
  opacity: 0.4;
}

.brand-city {
  font-weight: 600;
  letter-spacing: 0.16em;
  opacity: 0.85;
  font-size: 12px;
}

.top-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Landing Overlay */
#landing {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: linear-gradient(90deg, rgba(15, 23, 32, 0.84) 0%, rgba(15, 23, 32, 0.42) 55%, rgba(15, 23, 32, 0.25) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 72px 48px 40px;
}

.hero-left {
  max-width: 540px;
}

.corridor-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: rgba(15, 23, 32, 0.72);
  border: 1px solid rgba(255, 212, 38, 0.35);
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.hero-title {
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 900;
  line-height: 0.94;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero-title .accent {
  color: var(--accent);
  font-style: italic;
  display: block;
}

.hero-route {
  font-size: 15px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 6px;
}

.hero-tagline {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 22px;
  max-width: 460px;
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-primary {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 13px 22px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(15, 23, 32, 0.82);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: rgba(30, 41, 59, 0.92);
}

.join-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.text-input {
  background: rgba(15, 23, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  width: 170px;
}

.text-input:focus {
  border-color: var(--accent);
}

.key-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 12px;
}

.keycap {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 800;
  font-size: 11px;
  color: var(--accent);
  margin-right: 4px;
}

.hero-footnote {
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Landing Corridor Card */
.landing-map-card {
  width: 270px;
  padding: 16px;
  align-self: flex-end;
}

.card-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

#landing-minimap {
  width: 100%;
  height: 175px;
  display: block;
}

.metro-footer {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fb923c;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Modals (Invite Lobby, Pause, Finish) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 15, 22, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: min(560px, 100%);
  padding: 26px 28px;
  background: var(--bg-glass-strong);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.modal-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.45;
}

/* Invite Box */
.invite-box {
  background: rgba(255, 212, 38, 0.08);
  border: 1px solid rgba(255, 212, 38, 0.32);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.invite-code-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.room-code-display {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--accent);
}

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

.invite-url-input {
  flex: 1;
  background: rgba(15, 23, 32, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #e2e8f0;
  padding: 8px 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.lan-tip {
  margin-top: 8px;
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.4;
}

.lan-tip code {
  color: var(--accent);
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Lobby Slots & Car Picker */
.lobby-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.player-slot {
  padding: 12px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.player-slot.filled {
  border-color: rgba(255, 212, 38, 0.45);
}

.player-slot.p2.filled {
  border-color: rgba(56, 189, 248, 0.55);
}

.slot-tag {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 4px;
}

.player-slot.p2 .slot-tag {
  color: var(--p2-accent);
}

.slot-name {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
}

.slot-car {
  font-size: 11px;
  color: var(--text-muted);
}

.profile-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.car-picker {
  display: flex;
  gap: 6px;
  flex: 1;
}

.car-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: 7px;
  background: rgba(15, 23, 32, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.car-btn.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.error-banner {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.5);
  color: #fecaca;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 12px;
}

/* In-Race HUD (Faithful ORR Rush Layout) */
#race-hud {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

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

.hud-top-left {
  position: absolute;
  top: 64px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pos-time-row {
  display: flex;
  gap: 22px;
  align-items: flex-end;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.hud-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #cbd5e1;
  text-transform: uppercase;
}

.pos-value {
  font-size: 40px;
  font-weight: 900;
  line-height: 0.95;
}

.pos-total {
  font-size: 18px;
  color: #cbd5e1;
  font-weight: 700;
}

.time-value {
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.landmark-card {
  width: 235px;
  padding: 10px 13px;
  border-left: 3px solid var(--accent);
}

.landmark-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.landmark-idx {
  color: var(--accent);
}

.landmark-name {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.landmark-dist {
  font-size: 11px;
  color: #cbd5e1;
}

.opponent-gap-pill {
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-left: 3px solid var(--p2-accent);
  width: fit-content;
}

/* Top Center Checkpoint + Warning */
.hud-top-center {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: min(320px, 50vw);
}

.cp-index {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.cp-name {
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  margin: 2px 0 6px;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 5px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.cp-rem {
  font-size: 11px;
  color: #e2e8f0;
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.hazard-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #fef3c7;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

/* Bottom Left Speedometer, Gear, Boost, Points */
.hud-bottom-left {
  position: absolute;
  bottom: 22px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.speed-cluster {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.speed-num {
  font-size: 48px;
  font-weight: 900;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.gear-num {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.boost-points {
  min-width: 160px;
}

.boost-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.boost-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}

.boost-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
}

.points-val {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Bottom Right Actions & Minimap */
.hud-bottom-right {
  position: absolute;
  bottom: 22px;
  right: 20px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.action-pad {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 186px;
}

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

.action-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

.minimap-card {
  width: 158px;
  padding: 10px;
}

#race-minimap {
  width: 100%;
  height: 128px;
  display: block;
}

/* Center Toast & Countdown */
#race-toast {
  position: fixed;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  padding: 8px 18px;
  border-radius: 8px;
  background: rgba(15, 23, 32, 0.86);
  border: 1px solid rgba(255, 212, 38, 0.45);
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

#race-toast.show {
  opacity: 1;
}

#countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.countdown-num {
  font-size: 110px;
  font-weight: 900;
  font-style: italic;
  color: var(--accent);
  text-shadow: 0 8px 36px rgba(0, 0, 0, 0.65);
}

.countdown-sub {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #fff;
  text-transform: uppercase;
  margin-top: -8px;
}

/* Split-Screen Overlay */
#split-hud {
  position: fixed;
  inset: 0;
  z-index: 16;
  pointer-events: none;
}

.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: rgba(255, 212, 38, 0.65);
  transform: translateX(-50%);
}

.split-pane-hud {
  position: absolute;
  bottom: 18px;
  padding: 10px 14px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.split-pane-hud.p1 {
  left: 18px;
  border-left: 3px solid var(--accent);
}

.split-pane-hud.p2 {
  right: 18px;
  border-left: 3px solid var(--p2-accent);
}

.split-controls-hint {
  position: absolute;
  top: 62px;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.split-controls-hint.p1 {
  left: 18px;
  color: var(--accent);
}

.split-controls-hint.p2 {
  right: 18px;
  color: var(--p2-accent);
}

/* Scorecard Table */
.score-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  font-size: 13px;
}

.score-table th,
.score-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.score-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.score-table tr.winner td {
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 820px) {
  #landing {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 72px 22px 24px;
  }
  .landing-map-card,
  .minimap-card {
    display: none;
  }
  .lobby-players {
    grid-template-columns: 1fr;
  }
}
