.sort-button {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.sort-button::after {
  content: "↕";
  color: #536d79;
}

.sort-button.active::after {
  content: attr(data-direction);
  color: var(--gold);
}

.mobile-label {
  display: none;
}

.market-sort {
  display: grid;
  grid-template-columns: auto auto;
  align-content: end;
  gap: 5px;
}

.market-sort span {
  grid-column: 1 / -1;
  color: #78909b;
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.market-sort button {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid #405660;
  background: #162630;
  color: #a9bbc4;
  font-weight: 900;
  cursor: pointer;
}

.market-sort button::after {
  content: " ↕";
  color: #536d79;
}

.market-sort button.active {
  border-color: var(--gold);
  color: #fff;
}

.market-sort button.active::after {
  content: " " attr(data-direction);
  color: var(--gold);
}

.driver-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cyan);
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.driver-link:hover,
.event-link:hover {
  text-decoration: underline;
}

.driver-back {
  margin-bottom: 10px;
}

.event-link {
  color: var(--cyan);
  font-weight: 800;
  text-decoration: none;
}

.daily-roster-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.daily-roster-tabs button {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.daily-roster-tabs button.active {
  border-color: var(--orange);
  box-shadow: inset 0 -3px var(--orange);
}

.daily-roster-tabs button.locked {
  opacity: .65;
}

.daily-roster-tabs span,
.daily-roster-tabs small,
.daily-deadline {
  color: var(--muted);
}

.daily-roster-tabs small {
  font-size: 10px;
}

.daily-deadline {
  margin: 0 0 14px;
  font-size: 12px;
}

@media (max-width: 760px) {
  .daily-roster-tabs {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .daily-roster-tabs button {
    min-width: 0;
    padding: 8px 5px;
    font-size: 10px;
  }

  .daily-roster-tabs span,
  .daily-roster-tabs small {
    overflow: hidden;
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.event-corner-logo {
  display: grid;
  width: 100%;
  height: 150px;
  place-items: center;
  margin: -12px 0 22px;
  padding: 4px;
}

.event-corner-logo img {
  width: 100%;
  height: 142px;
  object-fit: contain;
  transform: none;
}

.mobile-event-logo {
  display: none;
}

@media (max-width: 760px) {
  .mobile-event-logo {
    display: grid;
    width: 190px;
    height: 70px;
    place-items: center;
    margin-right: auto;
  }

  .mobile-event-logo img {
    width: 185px;
    height: 68px;
    object-fit: contain;
  }

  .topbar-title {
    display: none;
  }
}

body {
  background: #061017 url("assets/whynot-aerial-background.png") center center / cover fixed no-repeat;
}

main {
  background:
    linear-gradient(#061017d9, #061017ed),
    url("assets/whynot-aerial-background.png") center center / cover fixed no-repeat;
}

.hero {
  grid-template-columns: 1.25fr .75fr;
  background:
    linear-gradient(90deg, #071017f5 0%, #0a1921dc 48%, #0811177a),
    url("assets/whynot-aerial-background.png") center center / cover no-repeat;
}

.hero-copy {
  max-width: 850px;
}

.hero-copy .kicker {
  text-transform: uppercase;
}

.hero-event-logo {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 300px;
  place-items: center;
  padding: 18px;
}

.hero-event-logo img {
  width: min(100%, 430px);
  max-height: 310px;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px #000b);
}

.timing-source {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.timing-status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.timing-status-grid article {
  padding: 17px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  background: var(--panel);
}

.timing-status-grid span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.timing-status-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 18px;
}

.timing-leader td {
  background: #18372d;
  color: #8ff0bf;
  font-weight: 900;
}

.timing-disclaimer {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.account-button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #49616d;
  border-radius: 3px;
  background: transparent;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.auth-dialog form {
  display: grid;
  gap: 12px;
}

.auth-dialog label {
  margin: 0;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 14px;
}

.auth-tabs button {
  min-height: 42px;
  border: 1px solid #49616d;
  background: #162630;
  color: #9fb2bc;
  font-size: 10px;
  font-weight: 950;
  cursor: pointer;
}

.auth-tabs button.active {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}

.auth-dialog form[hidden] {
  display: none;
}

.auth-field-note {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: none;
}

.auth-divider {
  margin: 22px 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-align: center;
}

.scoring-chart {
  margin: 20px 0;
  overflow: hidden;
  border: 1px solid #38505d;
}

.scoring-chart table {
  table-layout: fixed;
}

.scoring-chart th,
.scoring-chart td {
  padding: 10px 12px;
  text-align: center;
}

.scoring-chart th:nth-child(odd),
.scoring-chart td:nth-child(odd) {
  background: #0e1d25;
  color: var(--muted);
}

.scoring-chart td:nth-child(even) {
  color: var(--gold);
  font-size: 16px;
  font-weight: 1000;
}

.formula h3 {
  margin: 24px 0 10px;
  font-size: 12px;
  letter-spacing: .12em;
}

.movement-chart {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.movement-chart article {
  padding: 14px;
  border: 1px solid #38505d;
  background: #0e1d25;
}

.movement-chart b,
.movement-chart small {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.movement-chart strong {
  margin: 5px 0;
  color: var(--cyan);
  font-size: 20px;
}

.scoring-example {
  margin-top: 16px !important;
  padding: 12px;
  background: #0e1d25;
}

.scoring-example strong {
  display: inline;
  margin: 0;
  font-size: inherit;
}

@media (max-width: 1050px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-event-logo {
    min-height: 210px;
  }

  .hero-event-logo img {
    max-height: 220px;
  }
}

@media (max-width: 760px) {
  .timing-status-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .timing-status-grid article {
    min-width: 0;
    padding: 9px 7px;
  }

  .timing-status-grid strong {
    overflow: hidden;
    margin-top: 4px;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .desktop-label {
    display: none;
  }

  .mobile-label {
    display: inline;
  }

  .compact-table {
    overflow: hidden;
  }

  .compact-table table {
    width: 100%;
    table-layout: fixed;
  }

  .compact-table th,
  .compact-table td {
    overflow: hidden;
    padding: 6px 3px;
    font-size: 8px;
    line-height: 1.15;
    text-overflow: ellipsis;
  }

  .compact-table th {
    font-size: 7px;
    letter-spacing: 0;
  }

  .compact-table .sort-button {
    justify-content: center;
    gap: 1px;
    overflow: hidden;
    white-space: nowrap;
  }

  .compact-table .driver-link {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .compact-table td small {
    display: none;
  }

  .research-table th:first-child,
  .research-table td:first-child {
    width: 30%;
  }

  .research-table th:nth-child(2),
  .research-table td:nth-child(2),
  .research-table th:nth-child(3),
  .research-table td:nth-child(3) {
    width: 12%;
    text-align: center;
  }

  .research-table th:nth-child(4),
  .research-table td:nth-child(4) {
    width: 10%;
    text-align: center;
  }

  .research-table th:nth-child(5),
  .research-table td:nth-child(5) {
    width: 12%;
    text-align: center;
  }

  .research-table th:nth-child(6),
  .research-table td:nth-child(6) {
    width: 24%;
    text-align: center;
  }

  .research-table td:nth-child(6) .handicap {
    display: inline-grid;
    min-width: 0;
    max-width: 100%;
    padding: 4px 3px;
    font-size: 10px;
  }

  .standings-table th:nth-child(1) { width: 9%; }
  .standings-table th:nth-child(2) { width: 31%; }
  .standings-table th:nth-child(3) { width: 12%; }
  .standings-table th:nth-child(n+4) { width: 16%; }

  .timing-table th:nth-child(1) { width: 7%; }
  .timing-table th:nth-child(2) { width: 7%; }
  .timing-table th:nth-child(3) { width: 22%; }
  .timing-table th:nth-child(4) { width: 6%; }
  .timing-table th:nth-child(5) { width: 8%; }
  .timing-table th:nth-child(6) { width: 8%; }
  .timing-table th:nth-child(7) { width: 9%; }
  .timing-table th:nth-child(8) { width: 9%; }
  .timing-table th:nth-child(9) { width: 6%; }
  .timing-table th:nth-child(10) { width: 8%; }
  .timing-table th:nth-child(11) { width: 10%; }

  .page-heading {
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px 0 10px;
  }

  .page-heading h1 {
    font-size: 34px;
  }

  .page-heading span,
  .daily-deadline,
  .timing-disclaimer {
    font-size: 9px;
    line-height: 1.35;
  }

  .formula {
    padding: 18px 10px;
  }

  .formula > strong {
    font-size: 21px;
  }

  .scoring-chart th,
  .scoring-chart td {
    padding: 7px 2px;
    font-size: 8px;
  }

  .scoring-chart td:nth-child(even) {
    font-size: 12px;
  }

  .movement-chart {
    gap: 4px;
  }

  .movement-chart article {
    padding: 9px 5px;
  }

  .movement-chart strong {
    font-size: 13px;
  }

  .movement-chart small {
    font-size: 7px;
  }

  .auth-dialog {
    max-height: calc(100dvh - 16px);
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .auth-dialog h2 {
    margin: 8px 0 12px;
    padding-right: 22px;
    font-size: 23px;
  }

  .auth-tabs {
    margin-bottom: 10px;
  }

  .auth-dialog form {
    gap: 7px;
  }

  .auth-dialog label {
    gap: 3px;
  }

  .auth-dialog input {
    min-height: 39px;
  }

  .auth-divider {
    margin: 12px 0;
  }

  .auth-field-note,
  .auth-note {
    font-size: 8px;
    line-height: 1.25;
  }
}
