:root {
  color-scheme: dark;
  --bg: #080d12;
  --bg-deep: #03060b;
  --panel: rgba(15, 21, 31, 0.88);
  --panel-solid: #121a25;
  --panel-strong: rgba(20, 29, 42, 0.96);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(0, 229, 255, 0.42);
  --text: #f8fbff;
  --muted: #95a4b7;
  --muted-2: #69788d;
  --cyan: #00e5ff;
  --blue: #1268ff;
  --purple: #a02ff0;
  --pink: #ff2da0;
  --lime: #b6ff00;
  --yellow: #ffd02e;
  --red: #ff4848;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.55);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --font-text: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-data: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: var(--font-text);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 5%, rgba(18, 104, 255, 0.26), transparent 31rem),
    radial-gradient(circle at 88% 9%, rgba(255, 45, 160, 0.22), transparent 30rem),
    radial-gradient(circle at 52% 100%, rgba(0, 229, 255, 0.12), transparent 38rem),
    linear-gradient(145deg, var(--bg-deep) 0%, var(--bg) 48%, #0e101a 100%);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.82), transparent 90%);
}

button,
select,
a {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
}

.app-main {
  width: min(1380px, calc(100% - 34px));
  margin: 0 auto;
  padding: 28px 0 22px;
}

.site-footer {
  min-height: 30px;
  padding: 7px 16px 8px;
  border-top: 1px solid rgba(0, 229, 255, 0.20);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  background: rgba(3, 6, 11, 0.7);
  backdrop-filter: blur(14px);
}

.site-footer a {
  color: var(--cyan);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.home-hero {
  padding: clamp(24px, 4.5vw, 52px) 0 18px;
}

.home-hero-topline {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  font-weight: 850;
}

.home-hero h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.9;
  letter-spacing: -0.07em;
}

.home-hero p:not(.eyebrow) {
  max-width: 760px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.brand-logos {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.08);
}

.brand-logos img {
  display: block;
  width: auto;
  max-width: 112px;
  height: 26px;
  object-fit: contain;
}

.brand-logos-compact {
  min-height: 42px;
  padding: 8px 12px;
  gap: 12px;
}

.brand-logos-compact img {
  max-width: 82px;
  height: 20px;
}

.race-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  padding: 24px 0 48px;
}

.race-card {
  position: relative;
  min-height: 218px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(130deg, rgba(18, 104, 255, 0.12), transparent 38%),
    linear-gradient(145deg, rgba(16, 23, 34, 0.92), rgba(11, 14, 24, 0.86));
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.race-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(120deg, rgba(0, 229, 255, 0.55), transparent 35%, rgba(255, 45, 160, 0.48));
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.62;
  pointer-events: none;
}

.race-card::after {
  content: '';
  position: absolute;
  inset: auto -28% -48% 42%;
  height: 170px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(18, 104, 255, 0.28), rgba(255, 45, 160, 0.26));
  filter: blur(10px);
}

.race-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 229, 255, 0.55);
  background:
    linear-gradient(130deg, rgba(18, 104, 255, 0.20), transparent 40%),
    linear-gradient(145deg, rgba(21, 31, 47, 0.98), rgba(13, 16, 28, 0.96));
}

.race-card-topline {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 12px;
  border: 1px solid rgba(182, 255, 0, 0.42);
  border-radius: 999px;
  color: var(--lime);
  background: rgba(182, 255, 0, 0.08);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-finished {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.race-card h2 {
  position: relative;
  margin: 34px 0 10px;
  font-size: 31px;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.race-card p {
  position: relative;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.race-card-action {
  position: relative;
  margin-top: 32px;
  color: var(--cyan);
  font-weight: 850;
}

.race-header {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(280px, 1.4fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: 18px;
  margin-bottom: 20px;
}

.race-header-left,
.race-header-right {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.race-header-right {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.race-title-link {
  min-width: 0;
  text-align: center;
  text-decoration: none;
}

.race-title-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 11px;
  font-weight: 850;
}

.race-title-link h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 0.94;
  letter-spacing: -0.06em;
}

.home-button,
.race-menu summary {
  min-height: 42px;
  border: 1px solid rgba(0, 229, 255, 0.24);
  border-radius: var(--radius-md);
  background: rgba(8, 13, 18, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.home-button:hover {
  border-color: rgba(255, 45, 160, 0.56);
  color: var(--cyan);
}

.race-menu {
  position: relative;
  z-index: 30;
  width: min(340px, 100%);
}

.race-menu summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 8px 14px;
  cursor: pointer;
  list-style: none;
}

.race-menu summary::-webkit-details-marker {
  display: none;
}

.menu-trigger-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: #021018;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.race-menu summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.race-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(360px, calc(100vw - 34px));
  padding: 12px;
  border: 1px solid rgba(0, 229, 255, 0.34);
  border-radius: var(--radius-lg);
  background: rgba(7, 11, 17, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.menu-group + .menu-group {
  margin-top: 8px;
}

.menu-section,
.menu-subsection {
  display: flex;
  align-items: center;
  min-height: 38px;
  border-radius: 12px;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.menu-section {
  padding: 0 12px;
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 850;
}

.menu-subsections {
  display: grid;
  gap: 4px;
  margin: 5px 0 8px 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(0, 229, 255, 0.18);
}

.menu-subsection {
  padding: 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.menu-section:hover,
.menu-subsection:hover,
.menu-section-active,
.menu-subsection-active {
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.08);
}

.menu-section-active,
.menu-subsection-active {
  border-color: rgba(0, 229, 255, 0.24);
}

.content-card,
.empty-state {
  position: relative;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(0, 229, 255, 0.23);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(18, 104, 255, 0.08), transparent 34%),
    rgba(12, 18, 27, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.content-card::before,
.empty-state::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.14), transparent 42%, rgba(255, 45, 160, 0.12));
  opacity: 0.72;
  mask-image: linear-gradient(to bottom, #000, transparent 44%);
}

.content-card > *,
.empty-state > * {
  position: relative;
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading h2,
.empty-state h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.section-heading p,
.empty-state p,
.muted {
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.pilot-list {
  display: grid;
  gap: 9px;
}

.pilot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.pilot-row:hover {
  transform: translateX(4px);
  border-color: rgba(0, 229, 255, 0.42);
  background: rgba(0, 229, 255, 0.075);
}

.pilot-row span:first-child {
  font-size: 19px;
  font-weight: 850;
}

.pilot-row-arrow {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(12px);
}

.pilot-modal {
  position: relative;
  width: min(520px, 100%);
  padding: 58px 24px 24px;
  border: 1px solid rgba(0, 229, 255, 0.42);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(0, 229, 255, 0.08), transparent 36%),
    linear-gradient(155deg, rgba(15, 23, 34, 0.98), rgba(21, 17, 34, 0.98));
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.065);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  border-color: rgba(255, 45, 160, 0.58);
}

.pilot-modal h3 {
  margin: 0 0 18px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.pilot-stats {
  display: grid;
  gap: 10px;
  margin: 0;
}

.pilot-stats div {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.045);
}

.pilot-stats dt {
  color: var(--muted);
}

.pilot-stats dd {
  margin: 0;
  text-align: right;
  font-family: var(--font-data);
  font-size: 21px;
  font-weight: 900;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(0, 229, 255, 0.18);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.035);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  text-align: left;
}

th.table-cell-center,
td.table-cell-center {
  text-align: center;
}

th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

td {
  font-size: 16px;
}

td:first-child,
td.table-cell-center {
  font-family: var(--font-data);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(0, 229, 255, 0.055);
}

.leaderboard-table tbody tr:first-child td {
  color: var(--cyan);
  font-weight: 900;
}

.qualification-board {
  display: grid;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.qual-group-card {
  min-width: calc(240px + var(--round-count) * 88px);
  overflow: hidden;
  border: 1px solid rgba(0, 229, 255, 0.34);
  border-radius: var(--radius-lg);
  background: rgba(8, 13, 18, 0.68);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.qual-group-grid {
  display: grid;
  grid-template-columns: minmax(230px, 1.25fr) repeat(var(--round-count), minmax(78px, 1fr));
  align-items: stretch;
}

.qual-group-title,
.qual-head-cell,
.qual-pilot-cell,
.qual-cell {
  min-height: 38px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.qual-group-title {
  padding: 0 14px;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.065);
  font-weight: 950;
  letter-spacing: 0.08em;
}

.qual-head-cell {
  justify-content: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-family: var(--font-data);
  font-weight: 800;
}

.qual-pilot-cell {
  gap: 9px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.025);
}

.qual-cell {
  justify-content: center;
  padding: 0 8px;
  color: #dfe8f5;
  font-family: var(--font-data);
  font-size: 13px;
  white-space: nowrap;
}

.qual-cell-muted {
  color: rgba(149, 164, 183, 0.56);
}

.qual-cell-highlight {
  color: var(--text);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.15), rgba(255, 45, 160, 0.10));
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.42), 0 0 20px rgba(0, 229, 255, 0.12);
}

.qual-empty {
  grid-column: 1 / -1;
  padding: 16px;
  color: var(--muted);
}

.pilot-name-clip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 7px;
  color: #021018;
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 950;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.14);
}

.channel-red { background: var(--red); color: #180202; }
.channel-yellow { background: var(--yellow); color: #1a1100; }
.channel-green { background: var(--lime); color: #061400; }
.channel-blue { background: var(--blue); color: #ffffff; }
.channel-neutral { background: rgba(255, 255, 255, 0.28); color: #ffffff; }

.match-card {
  overflow: hidden;
  border: 1px solid rgba(0, 229, 255, 0.34);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(18, 104, 255, 0.12), transparent 42%),
    rgba(8, 13, 18, 0.74);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.match-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 13px 14px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.match-card-header h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.match-card-header span {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 13px;
}

.match-head,
.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(96px, 0.9fr) 66px;
  align-items: center;
  gap: 10px;
}

.match-head {
  padding: 9px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.match-body {
  display: grid;
}

.match-row {
  min-height: 42px;
  padding: 7px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.match-row-leader {
  background: rgba(0, 229, 255, 0.06);
}

.match-pilot {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.match-pilot-index {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--font-data);
}

.match-places {
  display: grid;
  grid-template-columns: repeat(var(--place-count), 1fr);
  overflow: hidden;
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.match-places span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
  font-family: var(--font-data);
  font-weight: 750;
}

.match-places span:first-child {
  border-left: 0;
}

.match-points {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid rgba(0, 229, 255, 0.32);
  border-radius: 10px;
  color: var(--text);
  background: rgba(0, 229, 255, 0.10);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.14);
  font-family: var(--font-data);
  font-size: 18px;
  font-weight: 950;
}

@media (max-width: 980px) {
  .app-main {
    width: min(100% - 22px, 1380px);
    padding-top: 18px;
  }

  .home-hero-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .race-header {
    grid-template-columns: 1fr;
  }

  .race-title-link {
    order: -1;
    text-align: left;
  }

  .race-header-left,
  .race-header-right,
  .race-menu {
    width: 100%;
  }

  .race-header-right {
    justify-content: flex-start;
  }

  .race-menu-panel {
    position: static;
    width: 100%;
    margin-top: 10px;
  }
}

@media (max-width: 620px) {
  .home-hero {
    padding-top: 22px;
  }

  .home-hero h1 {
    font-size: clamp(40px, 17vw, 70px);
  }

  .brand-logos {
    width: 100%;
    justify-content: space-between;
  }

  .brand-logos img {
    max-width: 96px;
  }

  .race-card {
    min-height: 190px;
    padding: 20px;
  }

  .content-card,
  .empty-state {
    padding: 17px;
    border-radius: 20px;
  }

  .pilot-stats div {
    grid-template-columns: 1fr;
  }

  .pilot-stats dd {
    text-align: left;
  }

  .match-head,
  .match-row {
    grid-template-columns: minmax(0, 1fr) 92px 58px;
    gap: 7px;
  }
}


/* v3 refinements */
body.modal-open {
  overflow: hidden;
}

#global-modal-root {
  position: relative;
  z-index: 1000;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pilot-modal {
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
}

.qual-pilot-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.qual-pilot-cell .channel-chip {
  justify-self: end;
}

.group-stage-bracket {
  display: grid;
  grid-template-columns: repeat(var(--stage-count), minmax(330px, 1fr));
  gap: 18px;
  align-items: stretch;
  min-height: var(--bracket-min-height, 680px);
  overflow-x: auto;
  padding-bottom: 4px;
}

.group-stage-bracket-1 {
  grid-template-columns: minmax(320px, 560px);
  justify-content: center;
  min-height: 0;
}

.bracket-column {
  min-width: 330px;
  display: flex;
  flex-direction: column;
}

.bracket-stage-cards {
  min-height: var(--bracket-cards-min-height, 646px);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 18px;
}

.bracket-column-final .bracket-stage-cards {
  justify-content: center;
}

.group-stage-bracket-1 .bracket-stage-cards {
  min-height: 0;
  justify-content: flex-start;
}

.match-card {
  min-height: 172px;
}

.match-card-header {
  justify-content: center;
  min-height: 46px;
}

.match-card-header h3 {
  text-align: center;
}

@media (max-width: 980px) {
  .group-stage-bracket {
    grid-template-columns: repeat(var(--stage-count), minmax(320px, 82vw));
  }
}

@media (max-width: 620px) {
  .group-stage-bracket,
  .group-stage-bracket-1 {
    grid-template-columns: 1fr;
    min-height: 0;
    overflow-x: visible;
  }

  .bracket-column,
  .bracket-stage-cards {
    min-width: 0;
    min-height: 0;
  }
}


/* v4 refinements */
.match-head span:nth-child(2),
.match-head span:nth-child(3) {
  text-align: center;
}

.match-pilot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
}

.match-pilot .channel-chip {
  justify-self: end;
}

.group-stage-bracket {
  grid-template-columns: repeat(var(--stage-count), minmax(292px, 1fr));
  gap: 14px;
  min-height: var(--bracket-min-height, 620px);
}

.bracket-stage-cards {
  min-height: var(--bracket-cards-min-height, 620px);
  gap: 14px;
}

.match-card {
  min-height: 0;
  border-radius: 16px;
}

.match-card-header {
  min-height: 36px;
  padding: 8px 10px 7px;
}

.match-card-header h3 {
  font-size: 17px;
}

.match-head,
.match-row {
  grid-template-columns: minmax(0, 1.25fr) minmax(78px, 0.72fr) 52px;
  gap: 7px;
}

.match-head {
  padding: 6px 8px;
  font-size: 11px;
}

.match-row {
  min-height: 32px;
  padding: 4px 8px;
}

.match-places span {
  min-height: 23px;
  font-size: 12px;
}

.match-points {
  min-height: 27px;
  border-radius: 8px;
  font-size: 15px;
}

.match-pilot-index {
  font-size: 12px;
}

.match-row .pilot-name-clip {
  font-size: 13px;
}

.match-row .channel-chip {
  min-width: 25px;
  height: 19px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 11px;
}

@media (max-width: 980px) {
  .group-stage-bracket {
    grid-template-columns: repeat(var(--stage-count), minmax(292px, 82vw));
  }
}

@media (max-width: 620px) {
  .group-stage-bracket,
  .group-stage-bracket-1 {
    grid-template-columns: 1fr;
    min-height: 0;
    overflow-x: visible;
  }

  .bracket-column,
  .bracket-stage-cards {
    min-width: 0;
    min-height: 0;
  }
}

/* v5 refinements */
.race-title-link .race-description {
  max-width: min(720px, 90vw);
  margin: 10px auto 0;
  color: rgba(223, 232, 245, 0.82);
  font-size: clamp(14px, 1.35vw, 18px);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

th {
  color: var(--cyan);
  background:
    linear-gradient(90deg, rgba(0, 229, 255, 0.10), rgba(255, 45, 160, 0.07)),
    rgba(255, 255, 255, 0.045);
}

.leaderboard-table tbody tr:first-child td {
  color: inherit;
  font-weight: inherit;
}

.table-empty-cell {
  text-align: center;
  color: var(--muted);
}

.stats-table table,
.results-table table {
  table-layout: fixed;
}

.stats-table .col-place,
.results-table .col-place {
  width: 88px;
}

.stats-table .col-pilot,
.results-table .col-pilot {
  width: auto;
}

.stats-table .col-meta,
.results-table .col-meta {
  width: 170px;
}

.results-table .col-meta-wide {
  width: 240px;
}

.stats-table .col-value,
.results-table .col-value {
  width: 170px;
}

.final-results-table .col-qual {
  width: 82px;
}

.final-results-table .col-region {
  width: 220px;
}

.qual-group-title {
  color: var(--cyan);
}

.qual-head-cell,
.match-head span:nth-child(2),
.match-head span:nth-child(3) {
  color: var(--cyan);
}

.match-row-leader {
  background: transparent;
}

.group-stage-bracket {
  grid-template-columns: repeat(var(--stage-count), minmax(260px, 1fr));
  gap: 12px;
}

.group-stage-bracket-1 {
  grid-template-columns: minmax(260px, 460px);
}

.bracket-column {
  min-width: 260px;
}

.bracket-stage-cards {
  gap: 10px;
}

.match-card {
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(18, 104, 255, 0.08), transparent 42%),
    rgba(8, 13, 18, 0.70);
}

.match-card-header {
  min-height: 32px;
  padding: 6px 9px 5px;
}

.match-card-header h3 {
  font-size: 15px;
}

.match-head,
.match-row {
  grid-template-columns: minmax(0, 1.2fr) minmax(68px, 0.66fr) 48px;
  gap: 6px;
}

.match-head {
  padding: 5px 7px;
  font-size: 10px;
}

.match-row {
  min-height: 29px;
  padding: 3px 7px;
}

.match-pilot {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.match-pilot-index,
.match-row .pilot-name-clip {
  font-size: 12px;
}

.match-row .channel-chip {
  justify-self: end;
  min-width: 24px;
  height: 18px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 10px;
}

.match-places span {
  min-height: 21px;
  font-size: 11px;
}

.match-points {
  min-height: 24px;
  border-radius: 7px;
  font-size: 14px;
}

@media (max-width: 980px) {
  .race-title-link .race-description {
    margin-left: 0;
  }

  .group-stage-bracket {
    grid-template-columns: repeat(var(--stage-count), minmax(260px, 82vw));
  }
}

/* v6 refinements */
.channel-red { background: #FF0000; color: #ffffff; }
.channel-yellow { background: #FFFF00; color: #121200; }
.channel-green { background: #00FF00; color: #001800; }
.channel-blue { background: #0000FF; color: #ffffff; }

.stats-table .col-place {
  width: 76px;
}

.stats-table .col-pilot {
  width: 36%;
}

.stats-table .col-meta,
.stats-table .col-value {
  width: 24%;
  min-width: 190px;
}

.qualification-results-table .col-place,
.group-results-table .col-place,
.final-results-table .col-place {
  width: 76px;
}

.qualification-results-table .col-pilot,
.group-results-table .col-pilot {
  width: 38%;
}

.qualification-results-table .col-meta,
.qualification-results-table .col-value {
  width: 24%;
  min-width: 180px;
}

.group-results-table .col-meta-wide {
  width: 42%;
  min-width: 240px;
}

.final-results-table .col-qual {
  width: 90px;
}

.final-results-table .col-pilot {
  width: 34%;
}

.final-results-table .col-region {
  width: 28%;
  min-width: 180px;
}

.qual-group-grid {
  grid-template-columns: minmax(230px, 0.92fr) repeat(var(--round-count), minmax(92px, 1fr));
}

.qual-cell {
  font-size: 12px;
}

.group-stage-bracket-2 .bracket-column:nth-child(2) .bracket-stage-cards,
.group-stage-bracket-3 .bracket-column:nth-child(2) .bracket-stage-cards,
.group-stage-bracket-3 .bracket-column:nth-child(3) .bracket-stage-cards {
  justify-content: center;
}

/* v7 interaction and summary modal refinements */
.qual-summary-trigger,
.group-summary-trigger,
.summary-nav-button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

.qual-summary-trigger,
.group-summary-trigger {
  cursor: pointer;
  text-align: inherit;
}

.qual-group-title.qual-summary-trigger,
.qual-head-cell.qual-summary-trigger,
.qual-pilot-cell.qual-summary-trigger,
.qual-cell.qual-summary-trigger,
.match-row.group-summary-trigger {
  background-clip: padding-box;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.qual-group-title.qual-summary-trigger:hover,
.qual-head-cell.qual-summary-trigger:hover,
.qual-pilot-cell.qual-summary-trigger:hover,
.qual-cell.qual-summary-trigger:hover,
.match-card.group-summary-trigger:hover,
.match-row.group-summary-trigger:hover {
  background: rgba(0, 229, 255, 0.09);
}

.match-card.group-summary-trigger {
  cursor: pointer;
}

.match-row.group-summary-trigger {
  width: 100%;
  background: transparent;
}

.match-row.group-summary-trigger:hover {
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.18);
}

.summary-modal {
  width: min(1280px, calc(100vw - 32px));
  max-width: 1280px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.summary-modal-titlebar {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

.summary-modal-titlebar h3 {
  margin: 0;
}

.summary-modal-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.summary-modal-heading {
  display: grid;
  gap: 2px;
  text-align: center;
}

.summary-modal-heading strong {
  font-size: 22px;
}

.summary-modal-heading span {
  color: var(--muted);
  font-size: 14px;
}

.summary-nav-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
}

.summary-nav-button:hover:not(:disabled) {
  background: rgba(0, 229, 255, 0.16);
}

.summary-nav-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.summary-section-label {
  margin: 4px 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 229, 255, 0.18);
  color: #03161f;
  font-size: 18px;
  font-weight: 900;
}

.summary-table-wrap {
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  min-width: 860px;
}

.summary-col-starts,
.summary-col-laps {
  width: 86px;
}

.summary-col-time {
  width: 150px;
}

.summary-lap-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.lap-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.lap-card header {
  padding: 9px 12px;
  background: rgba(0, 229, 255, 0.18);
  color: #04161d;
  font-weight: 900;
}

.lap-card-body {
  max-height: 420px;
  overflow: auto;
}

.lap-line {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-data);
}

.lap-line:first-child {
  border-top: 0;
}

.lap-line-holeshot {
  background: rgba(255, 255, 255, 0.08);
}

.lap-number {
  font-size: 20px;
}

.lap-cumulative,
.lap-split {
  justify-self: end;
  font-size: 14px;
}

.stats-table .col-pilot {
  width: 32%;
}

.stats-table .col-meta,
.stats-table .col-value {
  width: 26%;
  min-width: 210px;
}

.qualification-results-table .col-place,
.group-results-table .col-place,
.final-results-table .col-place {
  width: 68px;
}

.final-results-table .col-qual {
  width: 68px;
}

.final-results-table .col-pilot {
  width: 32%;
}

.final-results-table .col-region {
  width: auto;
  min-width: 240px;
}

@media (max-width: 900px) {
  .summary-modal {
    width: min(100vw - 16px, 1280px);
    max-height: calc(100vh - 16px);
    padding: 20px 16px;
  }

  .summary-modal-heading strong {
    font-size: 18px;
  }

  .summary-section-label {
    font-size: 16px;
  }

  .lap-card-body {
    max-height: 300px;
  }
}

/* v8/v5 fixes: keep qualification grid visual style while using clickable cells */
.qual-group-title.qual-summary-trigger {
  background: rgba(0, 229, 255, 0.065);
  color: var(--cyan);
}

.qual-head-cell.qual-summary-trigger {
  background: rgba(255, 255, 255, 0.035);
  color: var(--cyan);
}

.qual-pilot-cell.qual-summary-trigger {
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
}

.qual-cell.qual-summary-trigger {
  background: transparent;
  color: #dfe8f5;
}

.qual-cell.qual-summary-trigger.qual-cell-muted {
  color: rgba(149, 164, 183, 0.56);
}

.qual-cell.qual-summary-trigger.qual-cell-highlight {
  color: var(--text);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.15), rgba(255, 45, 160, 0.10));
}

.qual-head-cell.qual-column-hover,
.qual-cell.qual-column-hover {
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.18), rgba(255, 45, 160, 0.09));
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.35);
}

.qual-head-cell.qual-column-hover {
  color: var(--text);
}

.lap-card header {
  color: var(--text);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.32), rgba(255, 45, 160, 0.16));
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.26);
}

.match-head span:first-child {
  color: var(--cyan);
}

.summary-section-label {
  color: var(--text);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.30), rgba(255, 45, 160, 0.14));
}

.qual-group-title.qual-summary-trigger,
.qual-head-cell.qual-summary-trigger,
.qual-pilot-cell.qual-summary-trigger,
.qual-cell.qual-summary-trigger {
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.qual-group-title.qual-summary-trigger:hover,
.qual-pilot-cell.qual-summary-trigger:hover,
.qual-cell.qual-summary-trigger:hover:not(.qual-column-hover) {
  background: rgba(0, 229, 255, 0.09);
}

/* v9/v6 modal layout and softer qualification hover */
.qual-summary-trigger {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
}

.qual-group-title.qual-summary-trigger:hover,
.qual-pilot-cell.qual-summary-trigger:hover,
.qual-head-cell.qual-summary-trigger:hover:not(.qual-column-hover),
.qual-cell.qual-summary-trigger:hover:not(.qual-column-hover) {
  background: rgba(0, 229, 255, 0.045);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.12);
}

.qual-head-cell.qual-column-hover,
.qual-cell.qual-column-hover,
.qual-head-cell.qual-column-hover:hover,
.qual-cell.qual-column-hover:hover {
  background: rgba(0, 229, 255, 0.055) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.13) !important;
  color: #dfe8f5;
}

.qual-cell.qual-column-hover.qual-cell-highlight,
.qual-cell.qual-column-hover.qual-cell-highlight:hover {
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.12), rgba(255, 45, 160, 0.06)) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.14) !important;
}

.summary-context-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.12), rgba(255, 45, 160, 0.10));
  color: var(--cyan);
  font-weight: 950;
  letter-spacing: 0.03em;
}

.summary-modal-titlebar {
  margin-bottom: 14px;
}

.summary-modal-heading strong {
  color: var(--text);
}

.summary-modal-heading span,
.summary-section-label {
  display: none;
}

.lap-card header {
  color: var(--cyan);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.13), rgba(255, 45, 160, 0.12));
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.20);
}

.match-head span:first-child {
  color: var(--cyan);
}

/* v10/v7 requested table and modal refinements */
.summary-pilot-cell,
.summary-lap-pilot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.summary-pilot-cell .channel-chip,
.summary-lap-pilot .channel-chip {
  justify-self: end;
}

.summary-col-points {
  width: 86px;
}

.summary-lap-pilot {
  width: 100%;
}

.lap-card header {
  display: grid;
  align-items: center;
}

.lap-card-body:empty {
  min-height: 40px;
}

.lap-split,
.lap-cumulative {
  text-align: right;
}

.group-stage-bracket .match-card {
  border: 1px solid rgba(0, 229, 255, 0.46);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    0 0 0 1px rgba(255, 255, 255, 0.025);
}


/* v11/v8 requested mobile and lap detail refinements */
.lap-line {
  grid-template-columns: 54px minmax(0, 1fr);
}

.lap-split {
  justify-self: end;
  text-align: right;
}

@media (max-width: 620px) {
  .race-menu summary {
    min-height: 54px;
    padding: 12px 16px;
  }

  .menu-trigger-label {
    min-height: 30px;
    padding: 0 12px;
    font-size: 12px;
  }

  .race-menu summary strong {
    font-size: 16px;
  }

  .summary-modal {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    padding: 14px 10px;
    border-radius: 18px;
  }

  .summary-context-bar {
    gap: 8px;
    padding: 9px 10px;
    font-size: 12px;
    letter-spacing: 0.02em;
  }

  .summary-modal-nav {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
  }

  .summary-nav-button {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .summary-modal-heading strong {
    font-size: 17px;
  }

  .summary-table-wrap {
    margin-inline: -2px;
  }

  .summary-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    font-size: 11px;
  }

  .summary-table th,
  .summary-table td {
    padding: 7px 5px;
  }

  .summary-table .col-place {
    width: 34px;
  }

  .summary-table .col-pilot {
    width: 32%;
  }

  .summary-col-starts,
  .summary-col-points,
  .summary-col-laps {
    width: 48px;
  }

  .summary-col-time {
    width: 62px;
  }

  .summary-pilot-cell {
    gap: 5px;
  }

  .summary-pilot-cell .channel-chip {
    min-width: 24px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
  }
}

/* v12/v9 mobile modal table: keep readable columns and scroll horizontally */
@media (max-width: 620px) {
  .summary-table-wrap {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin-inline: -4px;
    padding: 0 4px 8px;
    scrollbar-width: thin;
  }

  .summary-table-wrap::after {
    content: '';
    position: sticky;
    right: -4px;
    display: block;
    float: right;
    width: 28px;
    height: 1px;
    pointer-events: none;
  }

  .summary-table {
    width: max-content;
    min-width: 760px;
    table-layout: auto;
    font-size: 12px;
  }

  .summary-table th,
  .summary-table td {
    padding: 8px 9px;
    white-space: nowrap;
  }

  .summary-table .col-place {
    width: 42px;
    min-width: 42px;
  }

  .summary-table .col-pilot {
    width: 230px;
    min-width: 230px;
  }

  .summary-col-starts,
  .summary-col-points,
  .summary-col-laps {
    width: 64px;
    min-width: 64px;
  }

  .summary-col-time {
    width: 112px;
    min-width: 112px;
  }

  .summary-pilot-cell {
    grid-template-columns: minmax(128px, 1fr) auto;
    gap: 10px;
    min-width: 210px;
  }

  .summary-pilot-cell .pilot-name-clip {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .summary-pilot-cell .channel-chip {
    min-width: 32px;
    height: 22px;
    padding: 0 7px;
    font-size: 11px;
  }

  .summary-modal {
    width: calc(100vw - 10px);
    max-width: calc(100vw - 10px);
  }
}

@media (max-width: 420px) {
  .summary-table {
    min-width: 720px;
  }

  .summary-table .col-pilot {
    width: 210px;
    min-width: 210px;
  }

  .summary-col-time {
    width: 104px;
    min-width: 104px;
  }
}


/* v14 public navigation and manual mode refinements */
.home-button[href="/"] { text-decoration: none; }
select option { background: #0d1622; color: #f8fbff; }
.group-stage-bracket-3 .bracket-column:nth-child(2) .bracket-stage-cards { justify-content: space-around; }
.group-stage-bracket-3 .bracket-column:nth-child(2) .match-card:nth-child(1) { margin-top: calc(var(--bracket-cards-min-height, 620px) * 0.10); }
.group-stage-bracket-3 .bracket-column:nth-child(2) .match-card:nth-child(2) { margin-bottom: calc(var(--bracket-cards-min-height, 620px) * 0.10); }
@media (max-width: 620px) {
  .group-stage-bracket-3 .bracket-column:nth-child(2) .match-card:nth-child(1),
  .group-stage-bracket-3 .bracket-column:nth-child(2) .match-card:nth-child(2) { margin: 0; }
}
