:root {
  color-scheme: dark;
  --red: #e10600;
  --bg: #08090b;
  --ink: #f4f2ef;
  --muted: #9b9ba6;
  --line: rgba(255, 255, 255, 0.09);
  --card: rgba(255, 255, 255, 0.04);
  --team: #e10600;
  --accent: #ffffff;
  --on-team: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.28;
  pointer-events: none;
  z-index: 0;
}

.glow--team { width: 560px; height: 560px; background: var(--team); top: -220px; left: -160px; }
.glow--accent { width: 420px; height: 420px; background: var(--accent); opacity: 0.12; top: 28%; right: -200px; }

.wrap {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 18px 0 26px;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand__logo { width: 64px; height: 64px; object-fit: contain; }

.brand__logo--mono {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--team);
  color: var(--on-team);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  flex: none;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.brand__sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.record {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 140px;
  padding: 14px 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 16px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--team) 26%, transparent), rgba(0, 0, 0, 0.25));
}

.record__value {
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.record__label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.record__streak { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--accent); }

.strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.tile {
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.tile__label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.tile__value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile__value.is-gold { color: var(--accent); }

.driver-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.driver-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(140deg, color-mix(in srgb, var(--team) 30%, transparent), rgba(10, 10, 14, 0.92) 62%);
}

.driver-card__head { display: flex; align-items: center; gap: 14px; }

.avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--team);
  color: var(--on-team);
  font-size: 16px;
  font-weight: 800;
  flex: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}

.avatar.is-light { color: #101014; }

.driver-card__pos {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.driver-card h2 { margin: 2px 0 2px; font-size: 21px; letter-spacing: -0.01em; }
.driver-card__meta { margin: 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }

.flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  vertical-align: middle;
  flex: none;
}

.driver-card__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.driver-card__stats div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.driver-card__stats span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.driver-card__stats strong { font-size: 17px; font-variant-numeric: tabular-nums; }

.driver-card__link { font-size: 12px; color: var(--accent); text-decoration: none; }
.driver-card__link:hover { text-decoration: underline; }

.columns { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; }

.panel {
  padding: 18px 18px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  margin-bottom: 18px;
}

.panel--wide { padding: 8px 22px 14px; }

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

.panel__head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel__hint { font-size: 11px; color: var(--muted); }
.panel__link { font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.panel__link:hover { text-decoration: underline; }

.races { list-style: none; margin: 0; padding: 0; }

.race-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.races .race-row:first-child { border-top: 0; }

.race-row__round {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.race-row__name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-width: 0; }
.race-row__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-row__name small { display: block; margin-top: 1px; font-size: 11px; font-weight: 400; color: var(--muted); }

.race-row__result { display: flex; gap: 6px; }
.pos-pill {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pos-pill.is-win { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.pos-pill.is-points { background: rgba(74, 222, 128, 0.12); color: #86efac; }
.pos-pill.is-out { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }

.race-row__date { text-align: right; font-size: 13px; font-weight: 600; }
.race-row__date strong { display: block; font-size: 13px; font-weight: 600; }
.race-row__date small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

.races--next .race-row { grid-template-columns: 46px minmax(0, 1fr) auto; padding: 16px 0; }
.races--next .race-row__name { font-size: 16px; }
.next-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
}

.table-wrap { overflow-x: auto; margin: 0 -4px; }

.log { width: 100%; min-width: 720px; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.log th {
  padding: 9px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.log td {
  padding: 10px 6px;
  border-top: 1px solid var(--line);
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}

.log th:nth-child(-n+4),
.log td:nth-child(-n+4) { text-align: left; }

.log tbody tr:first-child td { border-top: 0; }
.log tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.log__date { color: var(--muted); }
.log__driver { font-weight: 600; }
.log__pts { color: var(--accent); font-weight: 700; }
.log__out { color: #fca5a5; }

.driver-log { margin-bottom: 22px; }
.driver-log__head { display: flex; align-items: center; gap: 10px; padding: 10px 0 8px; }
.driver-log__head h3 { margin: 0; font-size: 16px; }
.driver-log__head .avatar { width: 38px; height: 38px; font-size: 12px; }

.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.data-table th {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 8px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.data-table tbody tr:first-child td { border-top: 0; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.data-table .is-left { text-align: left; }
.data-table .rank-col, .data-table .rank-cell { text-align: center; }
.data-table td.is-active { color: var(--accent); font-weight: 650; }

.driver-compare { min-width: 640px; }
.driver-cell__name, .driver-cell__meta, .team-cell__name, .race-name { white-space: nowrap; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.foot p { margin: 0; }
.back { color: var(--accent); text-decoration: none; }
.back:hover { text-decoration: underline; }

@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; }
  .driver-cards { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .hero { align-items: flex-start; }
  .record { align-items: flex-start; }
  .brand__logo--mono { width: 58px; height: 58px; font-size: 18px; border-radius: 16px; }
  .panel--wide { padding: 6px 12px 10px; }
  .race-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .driver-card__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
}
