:root {
  color-scheme: dark;
  --bg: #030508;
  --bg-elevated: #0a0f1c;
  --panel: #121933;
  --panel-border: #243055;
  --panel-border-bright: rgba(91, 140, 255, 0.35);
  --text: #edf2ff;
  --muted: #9fb0d9;
  --accent: #5b8cff;
  --accent-strong: #3d6ff0;
  --win: #2ecc71;
  --loss: #ff6b6b;
  --tie: #f1c40f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --ir-red: #ce3a2b;
  --ir-white: #ffffff;
  --ir-blue: #254185;
  --ir-dark-blue: #0f1f43;
  --stripe: linear-gradient(
    90deg,
    var(--ir-red) 0%,
    var(--ir-red) 33.33%,
    var(--ir-white) 33.33%,
    var(--ir-white) 66.66%,
    var(--ir-blue) 66.66%,
    var(--ir-blue) 100%
  );
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(91, 140, 255, 0.12), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(206, 58, 43, 0.07), transparent 35%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
  padding: 24px 24px 22px;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(135deg, rgba(18, 25, 51, 0.96) 0%, rgba(8, 12, 24, 0.98) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: var(--stripe);
}

.hero::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.14) 0%, transparent 70%);
  pointer-events: none;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: min(220px, 42vw);
  height: auto;
  max-height: 122px;
  border-radius: 14px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
  border: 1px solid rgba(82, 183, 136, 0.22);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  background: #0a0a0c;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 8px;
}

h1, h2 {
  margin: 0 0 8px;
}

.subtitle, .muted {
  color: var(--muted);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  white-space: nowrap;
  font-size: 0.88rem;
}

.status-pill.status-connected {
  border-color: rgba(46, 204, 113, 0.35);
  background: rgba(46, 204, 113, 0.1);
  color: #b8f5d0;
}

.status-pill.status-auth {
  border-color: rgba(241, 196, 15, 0.35);
  background: rgba(241, 196, 15, 0.08);
}

.panel {
  position: relative;
  background: rgba(18, 25, 51, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.panel-stripe::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--stripe);
  border-radius: 18px 18px 0 0;
  pointer-events: none;
}

.panel.panel-active,
.panel.panel-has-results,
#driver-stats-panel.driver-stats-loaded {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91, 140, 255, 0.14), transparent 60%),
    rgba(18, 25, 51, 0.92);
  border-color: rgba(91, 140, 255, 0.28);
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.panel-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.auth-panel-card {
  text-align: center;
  padding-top: 28px;
}

.auth-panel-card .btn.primary {
  margin-top: 8px;
  padding: 12px 24px;
  font-weight: 600;
}

.license-panel-card {
  text-align: left;
  padding-top: 24px;
}

.license-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-width: 520px;
}

.license-form input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.license-panel-card .btn.primary,
.license-panel-card .btn.secondary {
  justify-self: start;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.form-grid,
.search-row,
.filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, button {
  font: inherit;
}

input, select {
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #0d1430;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: rgba(91, 140, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15);
}

button.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  box-shadow: 0 8px 20px rgba(91, 140, 255, 0.25);
}

button.primary:not(:disabled):hover {
  box-shadow: 0 10px 24px rgba(91, 140, 255, 0.35);
}

button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--panel-border);
}

button.secondary:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(91, 140, 255, 0.35);
}

button.danger {
  background: rgba(206, 58, 43, 0.18);
  color: #ff8f84;
  border: 1px solid rgba(206, 58, 43, 0.45);
}

button.danger:not(:disabled):hover {
  background: rgba(206, 58, 43, 0.28);
  border-color: rgba(206, 58, 43, 0.7);
  box-shadow: 0 8px 20px rgba(206, 58, 43, 0.18);
}

.app-footer {
  margin-top: 28px;
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid rgba(206, 58, 43, 0.22);
  background: linear-gradient(135deg, rgba(18, 25, 51, 0.92) 0%, rgba(24, 12, 14, 0.88) 100%);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.app-footer h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.app-footer-copy {
  max-width: 560px;
}

.app-version {
  margin: 10px 0 0;
  font-size: 0.8rem;
  opacity: 0.75;
}

.app-footer-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 220px;
}

.app-footer-actions .message {
  margin: 0;
  text-align: right;
  max-width: 280px;
}

.confirm-clear-card {
  width: min(520px, 100%);
}

.confirm-clear-card::before {
  background: linear-gradient(90deg, #ce3a2b 0%, #ce3a2b 33%, #ffffff 33%, #ffffff 66%, #ce3a2b 66%, #ce3a2b 100%);
}

.confirm-clear-body {
  gap: 14px;
}

.confirm-clear-body p {
  margin: 0;
  line-height: 1.5;
}

.confirm-clear-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.driver-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.driver-card,
.driver-search-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.driver-search-card {
  padding: 12px 14px 12px 12px;
}

.driver-search-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.35), rgba(61, 111, 240, 0.2));
  border: 1px solid rgba(91, 140, 255, 0.35);
  color: #dce8ff;
}

.driver-search-meta {
  flex: 1;
  min-width: 0;
}

.driver-search-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-card:hover,
.driver-search-card:hover {
  border-color: var(--panel-border-bright);
  background: rgba(91, 140, 255, 0.06);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
}

.summary-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 4px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.2);
}

.results-panel-header {
  margin-bottom: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead {
  background: rgba(91, 140, 255, 0.1);
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

th.sortable {
  white-space: nowrap;
}

.sort-btn {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

th.sortable:hover,
th.sortable:hover .sort-btn {
  color: var(--text, #fff);
}

th.sortable[aria-sort="ascending"] .sort-btn,
th.sortable[aria-sort="descending"] .sort-btn {
  color: var(--text, #fff);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge.win { background: rgba(46, 204, 113, 0.18); color: var(--win); }
.badge.loss { background: rgba(255, 107, 107, 0.18); color: var(--loss); }
.badge.tie { background: rgba(241, 196, 15, 0.18); color: var(--tie); }
.badge.official { background: rgba(91, 140, 255, 0.18); color: var(--accent); }
.badge.unofficial { background: rgba(241, 196, 15, 0.16); color: #f1c40f; }
.badge.hosted { background: rgba(155, 89, 182, 0.18); color: #d7a8ff; }

.race-results-table {
  font-size: 0.84rem;
}

.race-results-table th,
.race-results-table td {
  padding: 5px 8px;
  line-height: 1.25;
  vertical-align: middle;
}

.race-results-table th {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.race-results-table .badge {
  padding: 2px 6px;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.race-results-table .col-date {
  white-space: nowrap;
}

.race-results-table .col-series,
.race-results-table .col-track,
.race-results-table .col-car {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-results-table .col-pos,
.race-results-table .col-winner {
  white-space: nowrap;
}

.compact-split {
  white-space: nowrap;
}

.compact-split .compact-sep {
  margin: 0 0.35em;
  color: var(--muted);
  opacity: 0.7;
}

.matchup-stat-pill {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.stats-comparison-leaderboards {
  margin-top: 16px;
}

.message {
  min-height: 1.2rem;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid transparent;
}

.message:empty {
  display: none;
}

.message.error {
  color: #ffb4b4;
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.25);
}

.hidden {
  display: none;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.clickable-row:hover {
  background: rgba(91, 140, 255, 0.08);
}

.clickable-row:active {
  background: rgba(91, 140, 255, 0.12);
}

.opponent-row td:first-child {
  font-weight: 500;
}

.opponent-stat {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.opponent-stat-highlight {
  color: var(--accent);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pager .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.winner-you {
  color: var(--win);
  font-weight: 600;
}

.winner-opp {
  color: var(--loss);
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 20, 0.82);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(24, 34, 68, 0.98) 0%, rgba(14, 20, 42, 0.98) 100%);
  border: 1px solid var(--panel-border-bright);
  border-radius: 18px;
  padding: 0 0 20px;
  box-shadow: var(--shadow);
}

.modal-card::before {
  content: "";
  display: block;
  height: 4px;
  background: var(--stripe);
  border-radius: 18px 18px 0 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
  padding: 20px 20px 0;
}

.modal-content {
  display: grid;
  gap: 16px;
  padding: 0 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.detail-card {
  padding: 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease;
}

.detail-card:hover {
  border-color: rgba(91, 140, 255, 0.25);
}

.detail-card .label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.detail-card .value {
  font-size: 1rem;
  font-weight: 600;
}

.driver-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.driver-panel {
  padding: 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
}

.driver-panel-a {
  border-color: rgba(91, 140, 255, 0.35);
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.08) 0%, rgba(0, 0, 0, 0.15) 100%);
}

.driver-panel-b {
  border-color: rgba(255, 107, 107, 0.35);
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.08) 0%, rgba(0, 0, 0, 0.15) 100%);
}

.driver-panel h3 {
  margin: 0 0 12px;
}

.driver-panel dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 0;
}

.driver-panel dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.driver-panel dd {
  margin: 0;
  font-weight: 600;
}

.session-block {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
}

.session-block h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.external-link {
  color: var(--accent);
  text-decoration: none;
}

.external-link:hover {
  text-decoration: underline;
}

.matchup-hero {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--panel-border-bright);
  background: linear-gradient(135deg, rgba(26, 36, 72, 0.95) 0%, rgba(12, 18, 38, 0.98) 100%);
  margin-bottom: 18px;
}

.matchup-hero-stripe {
  height: 4px;
  background: var(--stripe);
}

.matchup-hero-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 20px 22px;
}

.matchup-driver {
  min-width: 0;
}

.matchup-slot {
  margin: 0 0 6px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.matchup-name {
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matchup-driver-a .matchup-name {
  text-align: left;
}

.matchup-driver-b .matchup-name {
  text-align: right;
}

.matchup-driver-b .matchup-slot {
  text-align: right;
}

.matchup-vs {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  flex-shrink: 0;
}

.matchup-hero-sub {
  margin: 0;
  padding: 0 22px 16px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.matchup-hero-sub:not(:empty) + .matchup-hero-stats {
  margin-top: -4px;
}

.matchup-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 18px;
}

.fight-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(ellipse 55% 80% at 0% 50%, rgba(206, 58, 43, 0.22), transparent 55%),
    radial-gradient(ellipse 55% 80% at 100% 50%, rgba(61, 111, 240, 0.22), transparent 55%),
    linear-gradient(180deg, #141a2e 0%, #080b14 100%);
  margin-bottom: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.fight-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      -12deg,
      transparent 0 18px,
      rgba(255, 255, 255, 0.015) 18px 19px
    );
  pointer-events: none;
}

.fight-card-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.28);
}

.fight-card-kicker,
.fight-card-tape {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.fight-card-kicker {
  color: #ffd166;
}

.fight-card-tape {
  color: var(--muted);
}

.fight-card-body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 22px 18px 18px;
}

.fight-corner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-align: center;
  padding: 12px 10px;
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.fight-corner-bg {
  display: none;
}

.fight-corner.has-track-bg .fight-corner-bg {
  display: block;
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.fight-corner.has-track-bg .fight-corner-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.4) 0%, rgba(8, 12, 24, 0.78) 100%);
}

.fight-corner > *:not(.fight-corner-bg) {
  position: relative;
  z-index: 1;
}

.fight-corner-track {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.3;
  max-width: 12rem;
}

.fight-corner.is-winner {
  transform: scale(1.03);
}

.fight-corner.is-loser {
  opacity: 0.72;
}

.fight-corner-label {
  margin: 0;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.fight-corner-red .fight-corner-label {
  color: #ff8b7e;
}

.fight-corner-blue .fight-corner-label {
  color: #8eb6ff;
}

.fight-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  border: 3px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.fight-corner-red .fight-avatar {
  background: linear-gradient(145deg, #ce3a2b, #7a1c14);
  color: #fff;
}

.fight-corner-blue .fight-avatar {
  background: linear-gradient(145deg, #3d6ff0, #1a2f73);
  color: #fff;
}

.fight-corner.is-winner .fight-avatar {
  border-color: #ffd166;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.25), 0 10px 28px rgba(0, 0, 0, 0.4);
}

.fight-name {
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 800;
  line-height: 1.2;
  max-width: 100%;
}

.fight-name .driver-link {
  color: inherit;
}

.fight-winner-tag {
  display: inline-block;
  margin-top: 2px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #1a1408;
  background: linear-gradient(90deg, #ffe08a, #ffd166);
  animation: fight-winner-pulse 1.6s ease-in-out infinite;
}

@keyframes fight-winner-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.fight-vs-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}

.fight-vs {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #3a4258, #0c0f18 70%);
  border: 2px solid rgba(255, 209, 102, 0.55);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.18);
}

.fight-decision {
  max-width: 140px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.25;
  color: var(--muted);
}

.fight-decision.decision {
  color: #ffd166;
}

.fight-decision.draw {
  color: #f1c40f;
}

.fight-decision.pending {
  color: var(--muted);
}

.fight-scoreline {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.fight-verdict {
  position: relative;
  margin: 0;
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: 0.9rem;
  color: #c9d4f0;
}

.fight-tape-shell {
  border-color: rgba(255, 209, 102, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 209, 102, 0.04), transparent 40%),
    rgba(0, 0, 0, 0.22);
}

.fight-tape-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 16px 6px;
}

.fight-tape-heading h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fight-tape-heading .muted {
  margin: 0;
  font-size: 0.8rem;
}

.fight-tape-grid .stats-grid-row.header .value-a {
  color: #ff9b90;
}

.fight-tape-grid .stats-grid-row.header .value-b {
  color: #9ec0ff;
}

.fight-tape-grid .stats-grid-row.round-a > .value-a,
.fight-tape-grid .stats-grid-row.round-b > .value-b {
  box-shadow: inset 0 0 0 1px rgba(46, 204, 113, 0.28);
}

.fight-tape-grid .stats-grid-row.round-a > div,
.fight-tape-grid .stats-grid-row.round-b > div {
  background: rgba(46, 204, 113, 0.04);
}

.compare-shell {
  padding: 4px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.18);
  margin-bottom: 18px;
}

.h2h-stats-note:empty {
  display: none;
}

.h2h-stats-note:not(:empty) {
  margin: 0 0 14px;
  padding: 12px 14px;
  line-height: 1.45;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
}

.h2h-stats-note:not(:empty)::before {
  content: "Note";
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}

.stats-loading {
  margin-top: 16px;
  padding: 28px 20px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  text-align: center;
}

.stats-pickers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stats-picker label {
  font-weight: 600;
  color: var(--text);
}

.stats-selected {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
}

.stats-selected.active,
.panel .stats-selected.active {
  color: var(--text);
  border-color: rgba(91, 140, 255, 0.45);
  background: rgba(91, 140, 255, 0.08);
  padding: 10px 14px;
  border-radius: 12px;
}

.stats-filters {
  margin-bottom: 12px;
}

.stats-filter-hint {
  margin: -4px 0 14px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.stats-filter-hint .badge {
  font-size: 0.72rem;
  vertical-align: baseline;
}

.stats-filters select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stats-comparison {
  margin-top: 16px;
}

.race-track-loader {
  position: relative;
  height: 88px;
  max-width: 340px;
  margin: 0 auto 14px;
  overflow: hidden;
}

.race-track-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26px;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    rgba(159, 176, 217, 0.55) 0 14px,
    transparent 14px 28px
  );
  animation: race-track-scroll 0.55s linear infinite;
}

.race-car {
  position: absolute;
  bottom: 30px;
  width: 46px;
  height: 22px;
  border-radius: 7px 12px 5px 5px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
}

.race-car-a {
  background: linear-gradient(180deg, #6ea0ff 0%, var(--accent) 100%);
  animation: race-car-a 1.6s ease-in-out infinite;
}

.race-car-b {
  background: linear-gradient(180deg, #ff8a8a 0%, var(--loss) 100%);
  animation: race-car-b 1.6s ease-in-out infinite;
}

.race-wheel {
  position: absolute;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1a2238;
  border: 2px solid #dfe7ff;
  animation: race-wheel-spin 0.45s linear infinite;
}

.race-wheel-front {
  right: 6px;
}

.race-wheel-rear {
  left: 6px;
}

.race-loading-sub {
  margin: 0;
}

.sync-progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.sync-progress-overlay.hidden {
  display: none;
}

.sync-progress-panel {
  width: min(520px, 100%);
  padding: 28px 24px 24px;
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(24, 34, 68, 0.98) 0%, rgba(14, 20, 42, 0.98) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sync-progress-panel::before {
  content: "";
  display: block;
  height: 4px;
  background: var(--stripe);
  margin: -28px -24px 20px;
}

.sync-progress-eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}

.sync-progress-panel h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.sync-progress-message {
  margin: 0 0 22px;
  min-height: 1.4em;
  line-height: 1.45;
}

.sync-progress-track-wrap {
  padding: 18px 8px 8px;
}

.sync-progress-track {
  position: relative;
  height: 28px;
  border-radius: 999px;
  overflow: visible;
}

.sync-progress-asphalt {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.07) 0 18px,
      rgba(255, 255, 255, 0.02) 18px 36px
    ),
    linear-gradient(180deg, #2a3348 0%, #171e31 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.sync-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(46, 204, 113, 0.35) 0%,
    rgba(91, 140, 255, 0.55) 55%,
    rgba(91, 140, 255, 0.75) 100%
  );
  box-shadow: 0 0 18px rgba(91, 140, 255, 0.25);
  transition: width 0.35s ease;
}

.sync-progress-finish {
  position: absolute;
  top: -4px;
  right: -2px;
  width: 18px;
  height: calc(100% + 8px);
  border-radius: 3px;
  background:
    linear-gradient(45deg, #edf2ff 25%, transparent 25%) 0 0 / 8px 8px,
    linear-gradient(-45deg, #edf2ff 25%, transparent 25%) 0 0 / 8px 8px,
    linear-gradient(45deg, transparent 75%, #edf2ff 75%) 0 0 / 8px 8px,
    linear-gradient(-45deg, transparent 75%, #edf2ff 75%) 0 0 / 8px 8px;
  background-color: #111;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.12);
}

.sync-progress-car {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 132px;
  height: 56px;
  transform: translate(-42%, -62%);
  transition: left 0.35s ease;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55));
  opacity: 1;
  background: transparent;
  z-index: 2;
}

.sync-progress-car-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  background: transparent;
}

.sync-progress-overlay[aria-busy="true"] .sync-progress-car {
  animation: sync-car-bob 0.55s ease-in-out infinite alternate;
}

.sync-progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.sync-progress-percent {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.sync-progress-steps {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

@keyframes sync-car-bob {
  from { transform: translate(-42%, -62%); }
  to { transform: translate(-42%, -72%); }
}

@keyframes race-track-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-28px); }
}

@keyframes race-car-a {
  0%, 100% { left: 6%; transform: translateY(0); }
  45% { left: 54%; transform: translateY(-3px); }
  55% { left: 54%; transform: translateY(-1px); }
}

@keyframes race-car-b {
  0%, 100% { left: 54%; transform: translateY(-1px); }
  45% { left: 6%; transform: translateY(-3px); }
  55% { left: 6%; transform: translateY(0); }
}

@keyframes race-wheel-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.stats-top-card h4 {
  margin: 0 0 4px;
}

.stats-top-note {
  margin: 0 0 8px;
  font-size: 0.82rem;
}

.win-rate-list {
  list-style: decimal;
  padding-left: 1.35em;
}

.win-rate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5rem 3.25rem;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
}

.win-rate-track {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.win-rate-pct {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

.win-rate-record {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.82rem;
}

.iracing-career-note {
  margin: 0 0 14px;
  font-size: 0.88rem;
}

#driver-stats-panel.driver-stats-loaded {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91, 140, 255, 0.18), transparent 60%),
    rgba(18, 25, 51, 0.92);
}

.driver-stats-profile {
  margin-top: 18px;
  scroll-margin-top: 16px;
}

.driver-stats-content {
  margin-top: 0;
}

.driver-dashboard {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 18px;
}

.driver-hero {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(91, 140, 255, 0.35);
  background: linear-gradient(135deg, rgba(26, 36, 72, 0.95) 0%, rgba(12, 18, 38, 0.98) 100%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.driver-hero-bg {
  display: none;
}

.driver-hero.has-track-bg .driver-hero-bg {
  display: block;
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.06);
  filter: saturate(1.05) contrast(1.05);
  z-index: 0;
}

.driver-hero.has-track-bg .driver-hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(105deg, rgba(8, 12, 24, 0.82) 0%, rgba(8, 12, 24, 0.45) 52%, rgba(8, 12, 24, 0.28) 100%),
    linear-gradient(180deg, rgba(8, 12, 24, 0.15) 0%, rgba(8, 12, 24, 0.55) 100%);
}

.driver-hero-glow,
.driver-hero-stripe,
.driver-hero-body {
  position: relative;
  z-index: 1;
}

.driver-hero-glow {
  position: absolute;
  inset: -40% auto auto -10%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.22) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

.driver-hero-track {
  margin: 6px 0 0;
  font-size: 0.82rem;
}

.driver-hero-stripe {
  height: 5px;
  background: var(--stripe);
}

.driver-hero-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px 24px;
  flex-wrap: wrap;
}

.driver-hero-copy {
  flex: 1;
  min-width: 0;
}

.driver-hero-top {
  display: flex;
  align-items: flex-end;
  gap: 20px 28px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.driver-hero-identity {
  flex: 0 1 auto;
  min-width: 0;
  text-align: left;
}

.driver-hero-licenses {
  flex: 1 1 280px;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.driver-hero-eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: var(--muted);
}

.driver-hero-name {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.driver-region {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.driver-region-flag {
  display: block;
  width: 24px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.driver-region-emoji {
  font-size: 1.15rem;
  line-height: 1;
}

.driver-region-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.driver-license-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 8px 14px;
  width: 100%;
  padding: 0 4px;
}

.ir-license {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
  text-align: center;
}

.ir-license-peak {
  transform: scale(1.1);
  padding: 6px 8px 8px;
  margin: 0 -2px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--lic-color) 50%, transparent),
    0 0 22px color-mix(in srgb, var(--lic-color) 38%, transparent),
    0 8px 20px rgba(0, 0, 0, 0.25);
}

.ir-license-peak .ir-license-arc-progress {
  stroke-width: 4.5;
  filter: drop-shadow(0 0 5px var(--lic-color));
}

.ir-license-peak .ir-license-class {
  font-size: 0.82rem;
  font-weight: 800;
}

.ir-license-peak .ir-license-ir {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 1;
}

.ir-license-peak .ir-license-icon-group {
  color: #fff;
}

.ir-license-arc-wrap {
  position: relative;
  width: 52px;
  height: 40px;
  margin-bottom: 2px;
  overflow: visible;
}

.ir-license-arc {
  display: block;
  width: 52px;
  height: 40px;
  overflow: visible;
}

.ir-license-arc-track {
  stroke: rgba(255, 255, 255, 0.12);
}

.ir-license-arc-progress {
  stroke: var(--lic-color);
  transition: stroke-dashoffset 0.35s ease;
}

.ir-license-icon-group {
  color: rgba(255, 255, 255, 0.9);
}

.ir-license-class {
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--lic-color);
  white-space: nowrap;
}

.ir-license-ir {
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--lic-color);
  opacity: 0.92;
  white-space: nowrap;
}

.driver-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.driver-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.driver-badge-accent {
  color: #dce8ff;
  border-color: rgba(91, 140, 255, 0.45);
  background: rgba(91, 140, 255, 0.12);
}

.driver-hero-ring {
  --ring: 0;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: conic-gradient(
    var(--win) calc(var(--ring) * 1%),
    rgba(255, 255, 255, 0.08) 0
  );
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.15);
}

.driver-hero-ring-inner {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(10, 14, 28, 0.92);
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.driver-hero-ring-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.driver-hero-ring-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.driver-highlight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.driver-highlight-card {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
}

.driver-highlight-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: var(--stripe);
}

.driver-highlight-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.driver-highlight-value {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.driver-race-table .col-link {
  width: 2.5rem;
  text-align: center;
  white-space: nowrap;
}

.driver-race-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
  background: rgba(91, 140, 255, 0.12);
}

.driver-race-link:hover {
  background: rgba(91, 140, 255, 0.22);
  color: #fff;
}

.driver-race-table .col-irating {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.driver-race-history-section .table-wrap {
  margin-top: 0;
}

.driver-race-table .col-series,
.driver-race-table .col-track,
.driver-race-table .col-car {
  max-width: 9rem;
}

.driver-race-table td.col-pos .badge.win {
  margin-left: 4px;
  vertical-align: middle;
}

.driver-career-table-wrap {
  margin-top: 0;
}

.driver-career-table th,
.driver-career-table td {
  white-space: nowrap;
}

.driver-highlight-note {
  margin: 8px 2px 0;
  font-size: 0.82rem;
}

.driver-career-strip,
.driver-detail-section {
  padding: 18px 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.025);
}

.driver-section-head {
  margin-bottom: 14px;
}

.driver-section-head h4 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.driver-section-head p {
  margin: 0;
  font-size: 0.84rem;
}

.driver-career-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.driver-career-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) 3.5rem;
  gap: 12px;
  align-items: center;
}

.driver-career-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.driver-career-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.driver-career-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8eb4ff);
}

.driver-career-fill-oval {
  background: linear-gradient(90deg, #ff8a65, #ff5722);
}

.driver-career-fill-road {
  background: linear-gradient(90deg, #4dd0e1, #0097a7);
}

.driver-career-fill-dirt-oval {
  background: linear-gradient(90deg, #bcaaa4, #8d6e63);
}

.driver-career-fill-dirt-road {
  background: linear-gradient(90deg, #aed581, #689f38);
}

.driver-career-value {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.driver-secondary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.driver-secondary-card {
  padding: 14px 14px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.driver-secondary-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.driver-secondary-value {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.driver-leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.driver-leaderboard-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.16);
}

.driver-leaderboard-card-accent {
  border-color: rgba(91, 140, 255, 0.28);
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.08) 0%, rgba(0, 0, 0, 0.12) 100%);
}

.driver-leaderboard-card-wins {
  border-color: rgba(46, 204, 113, 0.28);
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.07) 0%, rgba(0, 0, 0, 0.12) 100%);
}

.driver-leaderboard-head h4 {
  margin: 0;
  font-size: 0.95rem;
}

.driver-leaderboard-note {
  margin: 4px 0 0;
  font-size: 0.78rem;
}

.driver-leaderboard-empty {
  margin: 8px 0 0;
  font-size: 0.86rem;
}

.driver-ranked-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.driver-ranked-row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.driver-winrate-row {
  grid-template-columns: 1.75rem minmax(0, 1fr) 3.25rem 3.25rem;
}

.driver-rank {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.driver-rank.gold {
  background: linear-gradient(135deg, #ffe082, #ffb300);
  color: #3e2723;
}

.driver-rank.silver {
  background: linear-gradient(135deg, #eceff1, #b0bec5);
  color: #263238;
}

.driver-rank.bronze {
  background: linear-gradient(135deg, #ffccbc, #bf360c);
  color: #fff;
}

.driver-ranked-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.driver-ranked-name {
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-ranked-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.driver-ranked-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8eb4ff);
}

.driver-ranked-bar-win::after {
  background: linear-gradient(90deg, var(--win), #7dffb0);
}

.driver-ranked-bar-wins::after {
  background: linear-gradient(90deg, #ffd54f, var(--win));
}

.driver-ranked-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.92rem;
}

.driver-ranked-sub {
  font-size: 0.78rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.individual-stats-picker {
  max-width: none;
  margin-bottom: 16px;
}

.individual-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.individual-stat-card {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
}

.individual-stat-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.individual-stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  margin-top: 4px;
  line-height: 1.2;
}

.individual-top-list {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stats-comparison-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  scroll-margin-top: 16px;
}

.stats-driver-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.driver-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  text-align: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(91, 140, 255, 0.45);
  text-underline-offset: 2px;
}

.driver-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.stats-grid-row.header .driver-link {
  font-weight: 700;
}

.matchup-title-names .driver-link {
  font-size: inherit;
  font-weight: 700;
}

.winner-you .driver-link {
  color: var(--win);
}

.winner-opp .driver-link {
  color: var(--loss);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0;
  border: none;
  border-radius: 12px;
  overflow: hidden;
}

.stats-grid-row {
  display: contents;
}

.stats-grid-row > div {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.stats-grid-row:last-child > div {
  border-bottom: none;
}

.stats-grid-row.header > div {
  background: rgba(91, 140, 255, 0.14);
  font-weight: 700;
  padding-top: 14px;
  padding-bottom: 14px;
}

.stats-grid-row.header .value-a {
  color: #9ec0ff;
}

.stats-grid-row.header .value-b {
  color: #ff9a9a;
}

.stats-grid-row .label {
  color: var(--muted);
  text-align: center;
}

.stat-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
}

.stat-center-header {
  justify-content: center;
}

.stat-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.stat-bar {
  display: flex;
  width: 100%;
  max-width: 120px;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.stat-bar-a,
.stat-bar-b {
  transition: width 0.35s ease;
}

.stat-bar-a.win,
.stat-bar-b.win {
  background: var(--win);
}

.stat-bar-a.loss,
.stat-bar-b.loss {
  background: var(--loss);
}

.stat-bar-a.tie,
.stat-bar-b.tie {
  background: var(--muted);
  opacity: 0.45;
}

.stats-grid-row .value-a {
  text-align: right;
  font-weight: 600;
}

.stats-grid-row .value-b {
  text-align: left;
  font-weight: 600;
}

.stats-grid-row .better {
  color: var(--win);
}

.stats-top-list {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stats-top-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.16);
}

.stats-top-card h4 {
  margin: 0 0 10px;
}

.stats-top-card ol {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 720px) {
  .hero, .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    align-items: center;
  }

  .app-footer {
    align-items: stretch;
  }

  .app-footer-actions {
    align-items: stretch;
    min-width: 0;
  }

  .app-footer-actions .message {
    text-align: left;
    max-width: none;
  }

  input, select {
    min-width: 100%;
  }

  .stats-pickers,
  .stats-top-list,
  .driver-leaderboard-grid,
  .driver-highlight-grid {
    grid-template-columns: 1fr;
  }

  .driver-hero-body {
    flex-direction: column;
    align-items: stretch;
  }

  .driver-hero-top {
    flex-direction: column;
    align-items: stretch;
  }

  .driver-hero-licenses {
    flex-basis: auto;
    justify-content: center;
  }

  .driver-license-row {
    justify-content: center;
  }

  .ir-license-peak {
    transform: scale(1.06);
  }

  .driver-career-row {
    grid-template-columns: 4.5rem minmax(0, 1fr) 3rem;
    gap: 8px;
  }

  .driver-winrate-row {
    grid-template-columns: 1.75rem minmax(0, 1fr) 2.75rem;
  }

  .driver-winrate-row .driver-ranked-sub {
    grid-column: 2 / -1;
    text-align: left;
  }

  .matchup-hero-body {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .matchup-driver-a .matchup-name,
  .matchup-driver-b .matchup-name,
  .matchup-driver-b .matchup-slot {
    text-align: center;
  }

  .matchup-vs {
    margin: 0 auto;
  }

  .fight-card-body {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .fight-vs-block {
    order: 0;
    margin: 4px 0;
  }

  .fight-corner-red {
    order: 1;
  }

  .fight-corner-blue {
    order: 2;
  }

  .fight-card-top {
    justify-content: center;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid-row.header {
    display: none;
  }

  .stats-grid-row > div.stat-center {
    order: 0;
    padding-top: 0;
  }

  .stats-grid-row > div.value-a {
    order: 1;
  }

  .stats-grid-row > div.value-b {
    order: 2;
  }

  .stats-grid-row > div.value-a,
  .stats-grid-row > div.value-b {
    text-align: left;
  }

  .stats-grid-row > div.value-a::before {
    content: "Driver A: ";
    color: var(--muted);
    font-weight: 400;
  }

  .stats-grid-row > div.value-b::before {
    content: "Driver B: ";
    color: var(--muted);
    font-weight: 400;
  }

  .stat-bar {
    max-width: none;
  }
}
