/* ============================================================
   box-box web companion — dark F1 theme
   Mirrors styles.go palette as CSS custom properties.
   ============================================================ */

:root {
  --f1-red:    #E10600;
  --surface-0: #0d0d1a;   /* page background */
  --surface-1: #1B1B2F;   /* card background */
  --surface-2: #222236;   /* elevated card */
  --surface-3: #2D2D44;   /* borders, dividers */
  --text-1:    #ffffff;
  --text-2:    #8888aa;
  --text-3:    #555577;

  --soft:  #FF3333;
  --medium:#FFD700;
  --hard:  #CCCCCC;
  --inter: #39B54A;
  --wet:   #0080FF;

  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface-0);
}

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

a { color: inherit; text-decoration: none; }

/* ---- Nav ---- */
.nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--surface-3);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--f1-red);
  letter-spacing: 0.04em;
}
.nav-links {
  display: flex;
  gap: 1.5rem;
}
.nav-links a {
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text-1); }
.nav-links a.active { border-bottom: 2px solid var(--f1-red); padding-bottom: 2px; }

/* ---- Live dot ---- */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #E10600;
  animation: pulse 1.2s ease-in-out infinite;
}
.live-dot.large { width: 12px; height: 12px; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ---- Stale banner ---- */
.stale-banner {
  background: #2a1800;
  border-bottom: 1px solid #aa6600;
  color: #ffcc66;
  padding: 0.5rem 1.5rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stale-banner details summary { cursor: pointer; color: #aa8844; }
.stale-banner details p { padding: 0.4rem 0; color: var(--text-2); }

/* ---- Page layout ---- */
.page-header {
  padding: 1.25rem 1.5rem 0.75rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.back-btn {
  color: var(--text-2);
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.15s;
}
.back-btn:hover { color: var(--text-1); }
.session-info { color: var(--text-2); font-size: 0.85rem; }

/* ---- Cards ---- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.card-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.6rem;
}

/* ---- Home hero ---- */
.home-hero {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  padding: 1rem 1.5rem;
}
@media (max-width: 900px) {
  .home-hero { grid-template-columns: 1fr; }
}

/* ---- Next race card — rich hero ---- */
.next-race {
  text-align: center;
  background: linear-gradient(135deg, #1a0000 0%, #2d0a0a 40%, var(--surface-2) 100%);
  position: relative;
  overflow: hidden;
  border-color: rgba(225,6,0,0.25);
  padding: 2rem 1.5rem 1.5rem;
}
.next-race::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--f1-red), #ff4422, var(--f1-red));
  background-size: 200% 100%;
  animation: shimmer-red 2.5s linear infinite;
}
@keyframes shimmer-red {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Animated speed lines */
.speed-lines {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.speed-line {
  position: absolute;
  left: -10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(225,6,0,0.18), transparent);
  width: 60%;
  animation: speedline 3s ease-in-out infinite;
}
.speed-line:nth-child(1)  { top: 18%; animation-delay: 0s;    animation-duration: 2.8s; width: 55%; }
.speed-line:nth-child(2)  { top: 30%; animation-delay: 0.4s;  animation-duration: 3.2s; width: 70%; }
.speed-line:nth-child(3)  { top: 42%; animation-delay: 0.9s;  animation-duration: 2.5s; width: 45%; }
.speed-line:nth-child(4)  { top: 55%; animation-delay: 1.3s;  animation-duration: 3.5s; width: 65%; }
.speed-line:nth-child(5)  { top: 65%; animation-delay: 0.2s;  animation-duration: 2.9s; width: 50%; }
.speed-line:nth-child(6)  { top: 75%; animation-delay: 1.7s;  animation-duration: 3.1s; width: 60%; }
.speed-line:nth-child(7)  { top: 85%; animation-delay: 0.6s;  animation-duration: 2.7s; width: 40%; }
.speed-line:nth-child(8)  { top: 92%; animation-delay: 1.1s;  animation-duration: 3.4s; width: 55%; }
@keyframes speedline {
  0%   { transform: translateX(-20%); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateX(220%); opacity: 0; }
}

/* Circuit name watermark */
.circuit-watermark {
  position: absolute;
  bottom: -0.25rem;
  right: -0.5rem;
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.03);
  pointer-events: none;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}

/* Checkered flag corner decoration */
.checkered-corner {
  position: absolute;
  top: 0; right: 0;
  width: 64px; height: 64px;
  background-image:
    repeating-conic-gradient(rgba(255,255,255,0.07) 0% 25%, transparent 0% 50%);
  background-size: 16px 16px;
  mask-image: linear-gradient(225deg, rgba(0,0,0,0.5) 30%, transparent 70%);
  -webkit-mask-image: linear-gradient(225deg, rgba(0,0,0,0.5) 30%, transparent 70%);
  pointer-events: none;
}

.next-race .card-label { position: relative; z-index: 1; }
.next-race-flag   { font-size: 3.5rem; margin: 0.5rem 0; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3)); position: relative; z-index: 1; }
.next-race-name   { font-size: 1.8rem; font-weight: 800; margin: 0.25rem 0; letter-spacing: -0.02em; position: relative; z-index: 1; text-shadow: 0 2px 12px rgba(0,0,0,0.5); }
.next-race-circuit { color: var(--text-2); font-size: 0.95rem; margin-bottom: 0.75rem; font-weight: 500; position: relative; z-index: 1; }
.next-race-session {
  display: inline-block;
  background: rgba(225, 6, 0, 0.15);
  color: var(--f1-red);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(225, 6, 0, 0.3);
  position: relative; z-index: 1;
}
.next-race-countdown {
  font-size: 2.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  letter-spacing: 0.02em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  position: relative; z-index: 1;
}

/* Championship sidebar */
.champ-sidebar { display: flex; flex-direction: column; gap: 0.45rem; background: var(--surface-1); }
.champ-row {
  display: grid;
  grid-template-columns: 24px 4px 40px 1fr 45px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  transition: background 0.2s;
}
.champ-row:hover { background: var(--surface-2); }
.champ-row.podium-1 { background: rgba(255, 215, 0, 0.05); border: 1px solid rgba(255, 215, 0, 0.1); }
.champ-row.podium-1 .champ-pos { color: #FFD700; font-weight: 800; }
.champ-row.podium-2 .champ-pos { color: #C0C0C0; font-weight: 800; }
.champ-row.podium-3 .champ-pos { color: #CD7F32; font-weight: 800; }

.champ-pos  { color: var(--text-2); font-size: 0.9rem; text-align: center; font-weight: 600; }
.champ-tla  { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; }
.champ-bar-wrap {
  background: var(--surface-3);
  border-radius: 3px;
  height: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}
.champ-bar {
  height: 100%;
  background: var(--team-color, var(--f1-red));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.champ-pts { font-size: 0.9rem; color: var(--text-1); text-align: right; font-weight: 700; }

/* Team color swatch */
.team-swatch {
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--team-color, #666);
  border-radius: 2px;
  vertical-align: middle;
}

/* ---- Season meetings grid ---- */
.section-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 0.75rem 1.5rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-label::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1em;
  background: var(--f1-red);
  border-radius: 2px;
  flex-shrink: 0;
}
.meetings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  padding: 0 1.5rem 2rem;
}

/* ---- Meeting card ---- */
.meeting-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* background is set directly via inline style by meetingCardStyle() */
  border: 1px solid var(--surface-3);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  position: relative;
  overflow: hidden;
  min-height: 140px;
  text-decoration: none;
}
.meeting-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--country-r,100), var(--country-g,100), var(--country-b,150), 0.55);
  box-shadow: 0 6px 22px rgba(0,0,0,0.4),
              0 0 0 1px rgba(var(--country-r,100), var(--country-g,100), var(--country-b,150), 0.2);
}
.meeting-card.past {
  opacity: 0.45;
  filter: grayscale(0.4);
}
.meeting-card.meeting-next {
  border-color: rgba(var(--country-r,225), var(--country-g,6), var(--country-b,0), 0.55);
  box-shadow: 0 0 0 1px rgba(var(--country-r,225), var(--country-g,6), var(--country-b,0), 0.2),
              0 4px 20px rgba(0,0,0,0.35);
}

/* Top accent stripe */
.meeting-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--country-accent, var(--surface-3));
  transition: opacity 0.2s;
}
.meeting-card.past .meeting-card-accent { opacity: 0.35; }
.meeting-card.meeting-next .meeting-card-accent {
  background: linear-gradient(90deg,
    var(--country-accent, var(--f1-red)) 0%,
    rgba(var(--country-r,225), var(--country-g,6), var(--country-b,0), 0.5) 50%,
    var(--country-accent, var(--f1-red)) 100%);
  background-size: 200% 100%;
  animation: shimmer-red 2s linear infinite;
}

/* Card body: country code + flag */
.meeting-card-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 0.85rem 0.25rem;
}

/* Large bold country code — colored with the accent */
.meeting-country-code {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--country-accent, var(--text-1));
  /* soften very dark accents a little so they're legible */
  filter: brightness(1.4);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.meeting-card.past .meeting-country-code {
  color: var(--text-3);
  filter: none;
}

/* Small flag emoji — top-right corner */
.meeting-card-flag {
  font-size: 1.25rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

/* Card footer: name, circuit, date */
.meeting-card-foot {
  padding: 0.5rem 0.85rem 0.75rem;
}
.meeting-name {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text-1);
  margin-bottom: 0.1rem;
}
.meeting-circuit {
  color: var(--text-2);
  font-size: 0.73rem;
  margin-top: 0.1rem;
}
.meeting-date {
  color: var(--text-3);
  font-size: 0.7rem;
  margin-top: 0.25rem;
}

/* Round number badge — bottom right */
.meeting-round {
  position: absolute;
  bottom: 0.6rem;
  right: 0.7rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-3);
  opacity: 0.7;
}

/* ---- Session pills ---- */
.session-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
}
.pill {
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: 20px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pill:hover { background: var(--surface-3); color: var(--text-1); }
.pill.active {
  background: var(--team-color, var(--f1-red));
  border-color: transparent;
  color: #fff;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--surface-3);
  padding: 0 1.5rem;
  margin-bottom: 1rem;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.6rem 1rem;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--text-1); border-bottom-color: var(--f1-red); }

/* ---- Data table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0 1.5rem 1.5rem;
  width: calc(100% - 3rem);
}
.data-table th {
  background: var(--surface-2);
  border-bottom: 2px solid var(--surface-3);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.75rem 1rem;
  text-align: left;
  text-transform: uppercase;
}
.data-table td {
  border-bottom: 1px solid var(--surface-3);
  padding: 0.85rem 1rem;
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.data-table tr.podium-1 td { background: rgba(255, 215, 0, 0.03); }
.data-table tr.podium-1 .pos-cell { color: #FFD700; font-weight: 900; }
.data-table tr.podium-2 .pos-cell { color: #C0C0C0; font-weight: 900; }
.data-table tr.podium-3 .pos-cell { color: #CD7F32; font-weight: 900; }

.pos-cell { font-weight: 700; font-size: 1rem; }
.driver-cell { display: flex; align-items: center; gap: 0.75rem; font-weight: 600; font-size: 0.95rem; }
.pts-cell { font-weight: 800; font-size: 1rem; color: var(--text-1); }

/* ---- Badges ---- */
.badge {
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  text-transform: uppercase;
}
.badge.dnf { background: #442200; color: #ff8844; }
.badge.dns { background: #333355; color: #8888cc; }
.badge.dsq { background: #220000; color: #ff4444; }
.badge.pit { background: #003366; color: #66aaff; }
.badge.out { background: #330000; color: #ff6666; }

/* ---- Tyre badges ---- */
.tyre-badge {
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
}
.tyre-soft   { background: var(--soft);   color: #fff; }
.tyre-medium { background: var(--medium); color: #111; }
.tyre-hard   { background: var(--hard);   color: #111; }
.tyre-inter  { background: var(--inter);  color: #fff; }
.tyre-wet    { background: var(--wet);    color: #fff; }
.tyre-unknown { background: var(--surface-3); color: var(--text-2); }

/* ---- Timing tower ---- */
.live-meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 1.5rem 0.75rem;
  font-size: 0.85rem;
}
.timing-tower {
  width: calc(100% - 3rem);
  margin: 0 1.5rem 1.5rem;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.timing-tower th {
  background: var(--surface-1);
  border-bottom: 1px solid var(--surface-3);
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.75rem;
  text-align: left;
  text-transform: uppercase;
}
.timing-tower td {
  border-bottom: 1px solid var(--surface-3);
  padding: 0.45rem 0.75rem;
  vertical-align: middle;
}
.timing-tower .in-pit td   { background: rgba(0,51,102,0.25); }
.timing-tower .retired td  { background: rgba(60,0,0,0.3); opacity: 0.7; }
.timing-tower .pit-out td  { background: rgba(0,80,0,0.2); }
.timing-tower .pb          { color: #aaffaa; }
.timing-tower .ob          { color: #cc44ff; }
.pos-delta { color: var(--text-3); font-size: 0.75rem; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; margin-left: auto; }

/* Track status */
.track-status {
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  text-transform: uppercase;
}
.track-green  { background: #1a3a1a; color: #44cc44; }
.track-yellow { background: #3a2a00; color: #ffcc00; }
.track-red    { background: #3a0000; color: #ff4444; }
.track-sc     { background: #3a2a00; color: #ffaa00; }
.track-vsc    { background: #1a2a3a; color: #6699ff; }

/* ---- Race control panel ---- */
.rc-panel {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: 8px;
  margin: 0 1.5rem 1.5rem;
  padding: 0.75rem 1rem;
}
.rc-message {
  border-bottom: 1px solid var(--surface-3);
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
  padding: 0.4rem 0;
}
.rc-message:last-child { border-bottom: none; }
.rc-time  { color: var(--text-3); flex-shrink: 0; font-size: 0.75rem; }
.rc-flag  { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.rc-flag  { background: var(--surface-3); border-radius: 2px; padding: 1px 5px; }
.rc-safetycarpanel .rc-flag,
.rc-safetycarpanel { color: #ffcc00; }

/* ---- Driver selector ---- */
.driver-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.5rem 0.75rem;
}
.driver-selector label { color: var(--text-2); font-size: 0.8rem; margin-right: 0.25rem; }

/* ---- Year selector ---- */
.year-selector {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

/* ---- Skeleton loading ---- */
.skeleton-wrap { padding: 0.75rem 1.5rem; }
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-1) 25%,
    var(--surface-2) 50%,
    var(--surface-1) 75%
  );
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Empty state ---- */
.empty-msg {
  color: var(--text-2);
  font-size: 0.9rem;
  padding: 2rem 1.5rem;
  text-align: center;
}
.empty-msg.large { font-size: 1.1rem; padding: 4rem 1.5rem; }

/* ---- D3 charts ---- */
#strategy-chart,
#laps-chart,
#telemetry-chart,
#track-chart {
  overflow-x: auto;
  padding: 0 1.5rem 1.5rem;
}
#strategy-chart svg,
#laps-chart svg,
#telemetry-chart svg,
#track-chart svg { display: block; }

/* D3 axis text */
.tick text { fill: var(--text-2); font-size: 11px; }
.domain, .tick line { stroke: var(--surface-3); }

/* Tooltip */
.chart-tooltip {
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: 6px;
  color: var(--text-1);
  font-size: 0.8rem;
  padding: 6px 10px;
  pointer-events: none;
  position: fixed;
  z-index: 200;
}

/* ============================================================
   Standings — custom row layout
   ============================================================ */
.standings-table {
  padding: 0 1.5rem 2rem;
}
.standings-header {
  display: grid;
  grid-template-columns: 52px 1fr 180px 120px 70px 70px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem 0.5rem 1.25rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-3);
  text-transform: uppercase;
  border-bottom: 2px solid var(--surface-3);
  margin-bottom: 0.25rem;
}
@media (max-width: 700px) {
  .standings-header { grid-template-columns: 44px 1fr 0 80px 55px 55px; }
  .sh-team { display: none; }
}
.standings-row {
  display: grid;
  grid-template-columns: 52px 1fr 180px 120px 70px 70px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem 0.6rem 0;
  border-bottom: 1px solid var(--surface-3);
  transition: background 0.15s;
  position: relative;
  border-left: 3px solid var(--team-color, transparent);
  padding-left: 1rem;
  border-radius: 0 4px 4px 0;
}
.standings-row:hover { background: rgba(255,255,255,0.025); }
.standings-row.podium-1 { background: rgba(255,215,0,0.04); }
.standings-row.podium-2 { background: rgba(192,192,192,0.03); }
.standings-row.podium-3 { background: rgba(205,127,50,0.03); }
@media (max-width: 700px) {
  .standings-row { grid-template-columns: 44px 1fr 0 80px 55px 55px; }
  .sr-team { display: none; }
}

/* Position column */
.sr-pos {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}
.trophy-icon  { font-size: 1.3rem; line-height: 1; }
.pos-num      { font-size: 1rem; font-weight: 800; color: var(--text-2); }
.standings-row.podium-1 .pos-num { color: #FFD700; }
.standings-row.podium-2 .pos-num { color: #C0C0C0; }
.standings-row.podium-3 .pos-num { color: #CD7F32; }

/* Driver number badge */
.driver-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  border: 1px solid;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Driver column */
.sr-driver {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.sr-driver-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sr-full-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-tla {
  font-size: 0.72rem;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Team column */
.sr-team {
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Points bar */
.sr-bar-wrap {
  background: var(--surface-3);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}
.sr-bar {
  height: 100%;
  background: var(--team-color, var(--f1-red));
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 2px;
}

/* Points */
.sr-pts {
  font-weight: 800;
  font-size: 1rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

/* Gap */
.sr-gap {
  font-size: 0.78rem;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.standings-row.podium-1 .sr-gap {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--f1-red);
  text-transform: uppercase;
}

/* Constructor color block */
.constructor-color-block {
  width: 5px;
  height: 32px;
  border-radius: 3px;
  flex-shrink: 0;
}
.constructor-row .sr-full-name {
  font-size: 0.95rem;
  font-weight: 700;
}

/* Constructor table has no TEAM column — use 5-col grid */
.constructor-header,
.constructor-row {
  grid-template-columns: 52px 1fr 140px 70px 70px;
}
@media (max-width: 700px) {
  .constructor-header,
  .constructor-row {
    grid-template-columns: 44px 1fr 80px 55px 55px;
  }
}

/* ---- Scrollable table wrapper ---- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 1.5rem 1.5rem;
}
.table-scroll .data-table,
.table-scroll .timing-tower {
  margin: 0;
  width: 100%;
}

/* ============================================================
   Mobile responsive overrides (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
  /* Reduce global horizontal padding */
  .home-hero       { padding: 0.75rem; }
  .meetings-grid   { padding: 0 0.75rem 1.5rem; }
  .section-label   { padding: 0.75rem 0.75rem 0.5rem; }
  .page-header     { padding: 0.75rem 0.75rem 0.5rem; flex-wrap: wrap; gap: 0.5rem; }
  .year-selector   { margin-left: 0; }
  .session-pills   { padding: 0.5rem 0.75rem; }
  .driver-selector { padding: 0.5rem 0.75rem 0.75rem; }
  .table-scroll    { margin: 0 0.75rem 1.5rem; }
  .rc-panel        { margin: 0 0.75rem 1.5rem; }
  .standings-table { padding: 0 0.75rem 1.5rem; }
  .skeleton-wrap   { padding: 0.75rem; }
  .empty-msg       { padding: 2rem 0.75rem; }

  /* Charts */
  #strategy-chart,
  #laps-chart,
  #telemetry-chart,
  #track-chart     { padding: 0 0.75rem 1.5rem; }

  /* Nav */
  .nav             { gap: 0.75rem; padding: 0.6rem 0.75rem; }

  /* Tabs — allow horizontal scroll so all tabs are reachable */
  .tabs            { overflow-x: auto; padding: 0 0.75rem; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab             { padding: 0.6rem 0.75rem; font-size: 0.78rem; white-space: nowrap; }

  /* Stale banner */
  .stale-banner    { padding: 0.5rem 0.75rem; flex-wrap: wrap; }

  /* Live timing meta row */
  .live-meta       { gap: 0.5rem; padding: 0.5rem 0.75rem; flex-wrap: wrap; }
  .clock           { margin-left: 0; }

  /* Tighten table cell padding */
  .data-table th,
  .data-table td   { padding: 0.6rem 0.6rem; }
  .timing-tower th,
  .timing-tower td { padding: 0.4rem 0.5rem; }

  /* Hide TEAM column in race results table */
  .data-table th:nth-child(3),
  .data-table td:nth-child(3) { display: none; }

  /* Hide BEST LAP column in timing tower */
  .timing-tower th:nth-child(7),
  .timing-tower td:nth-child(7) { display: none; }

  /* Scale down hero text */
  .next-race-name      { font-size: 1.35rem; }
  .next-race-countdown { font-size: 1.6rem; }
}

@media (max-width: 420px) {
  /* Hide position delta column on very small phones to save space */
  .timing-tower th:nth-child(2),
  .timing-tower td:nth-child(2) { display: none; }
}
