:root {
  --bg: #07090d;
  --panel: #11151d;
  --panel-2: #171c26;
  --text: #f7f7f5;
  --muted: #9ca6b5;
  --red: #ec1c24;
  --yellow: #ffd400;
  --blue: #0878d8;
  --line: rgba(255,255,255,.11);
  --shadow: 0 18px 50px rgba(0,0,0,.38);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(8,120,216,.22), transparent 34rem),
    radial-gradient(circle at 20% 5%, rgba(236,28,36,.15), transparent 25rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }
img { max-width: 100%; display: block; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.site-shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; }
.site-header { padding: 24px 0 10px; text-align: center; }
.site-logo { width: min(740px, 94vw); margin: 0 auto; filter: drop-shadow(0 16px 24px rgba(0,0,0,.45)); }
.main-page-logo { width: min(610px, 86vw); }

.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  position: sticky;
  top: 10px;
  z-index: 20;
  width: fit-content;
  max-width: 100%;
  margin: 12px auto 28px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9,12,17,.86);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
}
.tab-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .02em;
}
.tab-button:hover { color: #fff; }
.tab-button.active {
  color: #0a0b0d;
  background: linear-gradient(135deg, var(--yellow), #ffae00);
  box-shadow: 0 6px 20px rgba(255,212,0,.22);
}
.tab-panel { display: none; animation: fade-in .18s ease-out; }
.tab-panel.active { display: block; }
@keyframes fade-in { from { opacity: .3; transform: translateY(4px); } }

/* Same-day event reminder */
.today-event-reminder {
  display: grid;
  grid-template-columns: minmax(160px, .55fr) minmax(0, 1.8fr);
  gap: 12px;
  align-items: center;
  margin: -12px 0 22px;
  padding: 11px 14px;
  border: 1px solid rgba(255,212,0,.46);
  border-radius: 13px;
  background:
    linear-gradient(105deg, rgba(236,28,36,.16), rgba(255,212,0,.10) 46%, rgba(8,120,216,.14)),
    rgba(15,19,27,.96);
  box-shadow: 0 10px 26px rgba(0,0,0,.24);
}
.today-event-reminder.hidden { display: none; }
.today-reminder-heading { display: grid; gap: 3px; }
.today-reminder-label {
  color: var(--yellow);
  font-size: .7rem;
  font-weight: 950;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.today-reminder-heading strong { font-size: .94rem; }
.today-reminder-events { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.today-reminder-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: min(230px, 100%);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #fff;
  background: rgba(0,0,0,.28);
  cursor: pointer;
  text-align: left;
}
.today-reminder-track-logo {
  width: 52px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.38));
}
.today-reminder-event-copy { min-width: 0; }
.today-reminder-event:hover {
  border-color: rgba(255,212,0,.62);
  background: rgba(255,212,0,.08);
  transform: translateY(-1px);
}
.today-reminder-event strong,
.today-reminder-event span { display: block; }
.today-reminder-event strong { font-size: .88rem; }
.today-reminder-event span { margin-top: 2px; color: var(--muted); font-size: .72rem; }

.section-heading { margin: 0 0 18px; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.7rem); }
.section-heading p { margin: 7px 0 0; color: var(--muted); }

.card {
  background: linear-gradient(145deg, rgba(23,28,38,.97), rgba(13,17,24,.97));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; background: rgba(255,255,255,.025); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.position { width: 64px; font-weight: 950; font-size: 1.05rem; }
.position-1 { color: var(--yellow); }
.position-2 { color: #dfe6ee; }
.position-3 { color: #d88a45; }
.driver-cell strong { display: block; }
.driver-cell span { color: var(--muted); font-size: .86rem; }
.points { font-weight: 950; font-size: 1.05rem; color: var(--yellow); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-state strong { display: block; color: #fff; margin-bottom: 5px; font-size: 1.1rem; }

.race-list { display: grid; gap: 22px; }
.race-card { overflow: hidden; }
.race-card-header {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 26px 24px 22px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(236,28,36,.10), rgba(8,120,216,.08));
}
.race-header-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
}
.race-track-logo {
  flex: 0 0 auto;
  width: min(340px, 72vw);
  height: 210px;
  object-fit: contain;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.42));
}
.race-card-header h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); }
.race-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 7px; color: var(--muted); font-size: .92rem; }
.race-count { justify-self: center; background: rgba(255,212,0,.12); border: 1px solid rgba(255,212,0,.3); color: var(--yellow); border-radius: 999px; padding: 7px 11px; font-weight: 850; font-size: .84rem; }
.race-notes { margin: 0; padding: 18px 24px 0; color: #d7dce4; line-height: 1.6; }
.race-results { padding: 18px 24px 0; }
.race-results h3 { margin: 0 0 14px; font-size: 1rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.race-results + .race-results { margin-top: 6px; }
.race-results .table-wrap { border: 1px solid var(--line); box-shadow: none; }
.race-results table { min-width: 760px; }
.race-subsection { padding: 24px; }
.race-subsection + .race-subsection { border-top: 1px solid var(--line); }
.race-subsection h3 { margin: 0 0 14px; font-size: 1rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.link-list { display: flex; flex-wrap: wrap; gap: 10px; }
.youtube-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  border: 1px solid rgba(236,28,36,.45);
  background: rgba(236,28,36,.10);
  padding: 10px 13px;
  border-radius: 10px;
  font-weight: 800;
}
.youtube-link:hover { background: rgba(236,28,36,.18); }
.youtube-icon { width: 9px; height: 12px; background: #fff; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 12px; }
.race-image {
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #07090d;
  padding: 0;
  cursor: zoom-in;
  aspect-ratio: 4/3;
  position: relative;
}
.race-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.race-image:hover img { transform: scale(1.025); }
.race-image span { position: absolute; inset: auto 0 0; padding: 22px 10px 8px; color: #fff; text-align: left; font-size: .84rem; background: linear-gradient(transparent, rgba(0,0,0,.82)); }

.lightbox { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.9); }
.lightbox.open { display: flex; }
.lightbox img { max-width: min(1200px, 95vw); max-height: 88vh; border-radius: 12px; box-shadow: 0 25px 80px #000; }
.lightbox-close { position: absolute; top: 18px; right: 20px; border: 0; width: 44px; height: 44px; border-radius: 50%; color: #fff; background: rgba(255,255,255,.12); cursor: pointer; font-size: 1.4rem; }

.site-footer {
  margin-top: 48px;
  padding: 34px 0 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: linear-gradient(180deg, rgba(12,15,21,.72), rgba(7,9,13,.98));
  font-size: .84rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(220px, .55fr);
  gap: 42px;
  align-items: start;
}
.footer-column h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: .95rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.footer-about p {
  max-width: 690px;
  margin: 0;
  color: #aab3c1;
  line-height: 1.65;
}
.footer-links {
  display: grid;
  justify-items: start;
  gap: 9px;
}
.footer-links h2 { margin-bottom: 3px; }
.footer-links-list { display: grid; justify-items: start; gap: 9px; }
.footer-no-links { margin: 0; color: var(--muted); font-size: .8rem; }
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: #dce2eb;
  font-weight: 800;
  text-decoration: none;
}
.footer-links a::after {
  content: '↗';
  margin-left: 7px;
  color: var(--yellow);
  font-size: .9em;
}
.footer-links a:hover { color: var(--yellow); }
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.075);
}
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 999px; font-size: .78rem; background: rgba(255,255,255,.06); color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #6a7280; }
.status-pill.online .status-dot { background: #33d17a; box-shadow: 0 0 0 4px rgba(51,209,122,.12); }
.status-pill.error .status-dot { background: var(--red); }

/* Admin */
.admin-body { background: #080a0f; }
.admin-shell { width: min(1220px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 50px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.admin-brand { display: flex; align-items: center; gap: 14px; }
.admin-brand img { width: 210px; }
.admin-brand h1 { margin: 0; font-size: 1.45rem; }
.admin-brand p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.admin-grid { display: grid; grid-template-columns: 330px minmax(0,1fr); gap: 20px; align-items: start; }
.admin-sidebar { position: sticky; top: 18px; display: grid; gap: 16px; }
.admin-card { padding: 20px; }
.admin-card h2, .admin-card h3 { margin: 0 0 16px; }
.auth-card { max-width: 460px; margin: 70px auto; padding: 28px; }
.auth-card .site-logo { width: 100%; margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: .8rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  color: #fff;
  background: #0b0f16;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(255,212,0,.7); box-shadow: 0 0 0 3px rgba(255,212,0,.08); }
.field textarea { resize: vertical; min-height: 86px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 850; color: #fff; background: #252d3a; }
.btn:hover { filter: brightness(1.1); }
.btn-primary { color: #111; background: var(--yellow); }
.btn-danger { background: #b91c24; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-small { padding: 7px 10px; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.driver-list, .admin-race-list { display: grid; gap: 9px; }
.driver-row, .admin-race-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: rgba(255,255,255,.025); }
.driver-row strong, .admin-race-row strong { display: block; }
.driver-row small, .admin-race-row small { color: var(--muted); }
.footer-link-admin-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.footer-link-actions { justify-content: flex-end; }
.footer-move-button {
  min-width: 36px;
  padding-inline: 9px;
  color: var(--yellow);
  font-size: 1rem;
  line-height: 1;
}
.footer-move-button:disabled { color: var(--muted); }

.repeater { display: grid; gap: 10px; }
.result-row, .link-row {
  display: grid;
  grid-template-columns: 1.7fr .65fr .65fr .65fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.link-row { grid-template-columns: 1fr 2fr auto; }
.result-row .field label, .link-row .field label { font-size: .68rem; }
.remove-row { width: 38px; height: 42px; padding: 0; }
.subsection-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 10px; }
.subsection-bar h3 { margin: 0; }
.help-text { color: var(--muted); font-size: .84rem; line-height: 1.5; }

.track-logo-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.track-logo-preview img {
  width: 110px;
  height: 80px;
  object-fit: contain;
  border-radius: 9px;
  background: rgba(0,0,0,.3);
}
.media-manager { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.admin-images { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 10px; margin-top: 12px; }
.admin-image { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #090c11; }
.admin-image img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.admin-image-info { padding: 8px; display: grid; gap: 7px; }
.admin-image-info small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; z-index: 200; right: 18px; bottom: 18px; max-width: 360px; padding: 13px 15px; border-radius: 12px; background: #202733; color: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #741b22; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .result-row { grid-template-columns: repeat(3,1fr); }
  .result-row .field:first-child { grid-column: 1 / -1; }
  .remove-row { grid-column: 3; justify-self: end; }
}
@media (max-width: 640px) {
  .site-shell, .admin-shell { width: min(100% - 18px, 1180px); }
  .site-header { padding-top: 16px; }
  .tabs { width: 100%; }
  .tab-button { flex: 1; padding-inline: 8px; }
  .race-card-header { padding: 18px; }
  .race-track-logo { width: min(280px, 80vw); height: 170px; }
  .race-results, .race-subsection { padding: 16px; }
  .race-notes { padding-inline: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .admin-sidebar { grid-template-columns: 1fr; }
  .admin-topbar { align-items: flex-start; }
  .admin-brand img { width: 150px; }
  .admin-brand h1 { font-size: 1.15rem; }
  .result-row, .link-row { grid-template-columns: 1fr 1fr; }
  .result-row .field:first-child, .link-row .field:nth-child(2) { grid-column: 1 / -1; }
  .remove-row { grid-column: 2; }
  .site-footer { margin-top: 36px; padding-top: 28px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .import-grid { grid-template-columns: 1fr; }
  .footer-bottom { margin-top: 20px; }
}

/* LapMonitor imports */
.import-intro { margin: -2px 0 14px; }
.import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.import-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255,212,0,.28);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,212,0,.06), rgba(41,105,255,.035));
}
.import-panel strong { display: block; margin-bottom: 4px; }
.import-panel input[type="file"] { width: 100%; min-width: 0; }
.qualifying-results table { min-width: 560px; }
.file-status { color: var(--muted); font-size: .84rem; line-height: 1.45; }
.admin-sidebar-heading { margin-top: 0; }

/* Race history tabs */
.race-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin: 0 0 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.race-tab-button {
  flex: 0 0 auto;
  min-width: 175px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 14px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  cursor: pointer;
  text-align: left;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.race-tab-button:hover {
  color: #fff;
  border-color: rgba(255,255,255,.24);
  transform: translateY(-1px);
}
.race-tab-button strong {
  display: block;
  max-width: 230px;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.race-tab-button span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .78rem;
}
.race-tab-button.active {
  color: #111;
  border-color: var(--yellow);
  background: linear-gradient(135deg, var(--yellow), #ffad00);
  box-shadow: 0 9px 24px rgba(255,212,0,.17);
}
.race-tab-button.active span { color: rgba(0,0,0,.66); }
.race-detail { min-height: 220px; }
.race-tab-panel { animation: fade-in .18s ease-out; }

/* League rules */
.rules-card { overflow: hidden; }
.rule-section {
  display: grid;
  grid-template-columns: 62px minmax(0,1fr);
  gap: 18px;
  padding: 25px 27px;
  align-items: start;
}
.rule-section + .rule-section { border-top: 1px solid var(--line); }
.rule-number {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255,212,0,.32);
  border-radius: 14px;
  color: var(--yellow);
  background: rgba(255,212,0,.08);
  font-weight: 950;
  font-size: .92rem;
}
.rule-section h2 {
  margin: 0 0 8px;
  font-size: clamp(1.1rem, 2.6vw, 1.38rem);
}
.rule-section p {
  margin: 0;
  max-width: 880px;
  color: #cbd2dd;
  line-height: 1.68;
}
.rule-link {
  color: var(--yellow);
  font-weight: 850;
  text-underline-offset: 3px;
}
.rule-link:hover { color: #ffe66a; }
.approved-links {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 11px;
  margin-top: 14px;
}
.rule-product {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #fff;
  background: rgba(255,255,255,.03);
  text-decoration: none;
}
.rule-product:hover {
  border-color: rgba(255,212,0,.48);
  background: rgba(255,212,0,.055);
}
.rule-product strong { line-height: 1.35; }
.rule-product span { color: var(--yellow); font-size: .8rem; font-weight: 850; }

@media (max-width: 640px) {
  .tabs {
    justify-content: flex-start;
    overflow-x: auto;
    border-radius: 16px;
  }
  .tab-button {
    flex: 0 0 auto;
    padding: 10px 13px;
    white-space: nowrap;
    font-size: .84rem;
  }
  .race-tab-button { min-width: 150px; }
  .rule-section {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px 18px;
  }
  .rule-number { width: 44px; height: 44px; }
  .approved-links { grid-template-columns: 1fr; }
}

/* Race history two-column header */
.race-card-header {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  align-items: center;
  justify-items: stretch;
  gap: 28px;
  text-align: left;
}
.race-card-header.no-track-logo { grid-template-columns: 1fr; }
.race-header-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}
.race-header-info h2 { margin: 0; }
.race-meta { justify-content: flex-start; }
.race-count { justify-self: auto; align-self: flex-start; }
.race-track-logo {
  justify-self: end;
  width: min(340px, 100%);
  height: 210px;
}

/* Event calendar */
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(290px, .75fr);
  gap: 18px;
  align-items: start;
}
.calendar-card { overflow: hidden; }
.calendar-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(236,28,36,.08), rgba(8,120,216,.08));
}
.calendar-toolbar h2 { margin: 0; text-align: center; font-size: clamp(1.25rem, 3vw, 1.7rem); }
.calendar-nav-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.04);
  cursor: pointer;
  font-size: 1.55rem;
  line-height: 1;
}
.calendar-nav-button:hover { border-color: rgba(255,212,0,.5); background: rgba(255,212,0,.08); }
.calendar-weekdays,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays {
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.025);
}
.calendar-weekdays span {
  padding: 10px 5px;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .7rem;
  font-weight: 850;
}
.calendar-day {
  min-height: 112px;
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.012);
}
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day:nth-last-child(-n+7) { border-bottom: 0; }
.calendar-day.outside-month { opacity: .36; background: rgba(0,0,0,.2); }
.calendar-day.today { box-shadow: inset 0 0 0 2px rgba(255,212,0,.6); }
.calendar-day-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 6px;
  border-radius: 50%;
  font-size: .82rem;
  font-weight: 900;
}
.calendar-day.today .calendar-day-number { color: #111; background: var(--yellow); }
.calendar-event-chip {
  overflow: hidden;
  margin-top: 5px;
  padding: 6px 7px;
  border-left: 3px solid var(--yellow);
  border-radius: 7px;
  color: #fff;
  background: rgba(8,120,216,.18);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
  font-weight: 780;
}
.calendar-more { display: block; margin: 6px 0 0 5px; color: var(--muted); font-size: .7rem; }
.calendar-load-error { grid-column: 1 / -1; padding: 45px 20px; text-align: center; color: var(--muted); }
.upcoming-card { padding: 20px; }
.upcoming-card > h2 { margin: 0 0 14px; font-size: 1.2rem; }
.upcoming-events { display: grid; gap: 10px; }
.upcoming-event {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.event-date-box {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 58px;
  border-radius: 10px;
  color: #111;
  background: linear-gradient(145deg, var(--yellow), #ffac00);
  text-transform: uppercase;
}
.event-date-box span { font-size: .68rem; font-weight: 900; letter-spacing: .08em; }
.event-date-box strong { font-size: 1.45rem; line-height: 1; }
.event-details { min-width: 0; }
.event-details h3 { margin: 1px 0 5px; font-size: .98rem; }
.event-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--muted); font-size: .78rem; }
.event-details p { margin: 7px 0 0; color: #cbd2dd; font-size: .82rem; line-height: 1.45; }
.compact-empty { padding: 28px 10px; }

/* Admin section tabs and calendar editor */
.admin-tabs {
  display: flex;
  width: fit-content;
  gap: 7px;
  margin: 0 0 20px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
}
.admin-tab-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 850;
}
.admin-tab-button.active { color: #111; background: var(--yellow); }
.admin-panel { display: none; }
.admin-panel.active { display: block; animation: fade-in .18s ease-out; }
.calendar-admin-grid { align-items: start; }

/* Approved rule product layouts */
.approved-links.one-column { grid-template-columns: minmax(0, 460px); }
.approved-links.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .race-card-header { grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 18px; }
  .race-track-logo { width: min(310px, 100%); }
  .calendar-layout { grid-template-columns: 1fr; }
  .upcoming-card { order: 2; }
  .approved-links.three-column { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .race-card-header,
  .race-card-header.no-track-logo {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .race-track-logo {
    justify-self: center;
    width: min(280px, 82vw);
    height: 170px;
  }
  .calendar-card { overflow-x: auto; }
  .calendar-toolbar,
  .calendar-weekdays,
  .calendar-grid { min-width: 680px; }
  .calendar-day { min-height: 100px; }
  .admin-tabs { width: 100%; }
  .admin-tab-button { flex: 1; }
}

/* Linked track information */
.linked-track-name {
  margin: 18px 0 3px;
  color: var(--yellow);
  font-size: 1.05rem;
}
.linked-track-location,
.linked-track-details {
  margin: 0;
  max-width: 680px;
  color: var(--muted);
  line-height: 1.55;
}
.linked-track-details { margin-top: 7px; color: #d5dbe4; }

/* Clickable calendar entries */
.calendar-event-chip {
  display: block;
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  cursor: pointer;
  text-align: left;
}
.calendar-event-chip:hover,
.calendar-event-chip.selected {
  background: rgba(255,212,0,.16);
  border-left-color: #fff;
}
.upcoming-event {
  width: 100%;
  color: #fff;
  cursor: pointer;
  text-align: left;
}
.upcoming-event:hover,
.upcoming-event.selected {
  border-color: rgba(255,212,0,.55);
  background: rgba(255,212,0,.07);
  transform: translateY(-1px);
}

/* Event detail box */
.event-detail-card {
  position: relative;
  margin-top: 18px;
  overflow: hidden;
  background: linear-gradient(110deg, rgba(236,28,36,.08), rgba(8,120,216,.08));
}
.event-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 30px;
  align-items: center;
  padding: 28px;
}
.event-detail-layout.no-event-logo { grid-template-columns: 1fr; }
.event-detail-info { min-width: 0; }
.event-detail-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--yellow);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.event-detail-info h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
}
.event-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 9px;
  color: var(--muted);
  font-weight: 700;
}
.event-description {
  margin: 20px 0 0;
  color: #e1e5eb;
  line-height: 1.65;
}
.event-track-info {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.event-track-info > h3 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .75rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.event-track-info .linked-track-name { margin-top: 7px; }
.event-track-logo-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
}
.event-track-logo {
  width: min(360px, 100%);
  max-height: 250px;
  object-fit: contain;
  filter: drop-shadow(0 16px 26px rgba(0,0,0,.5));
}
.event-detail-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #fff;
  background: rgba(0,0,0,.48);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}
.event-detail-close:hover { border-color: var(--yellow); color: var(--yellow); }

@media (max-width: 800px) {
  .event-detail-layout {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 24px 20px;
  }
  .event-track-logo-wrap { min-height: auto; }
  .event-track-logo { width: min(320px, 82vw); max-height: 210px; }
}

@media (max-width: 720px) {
  .today-event-reminder { grid-template-columns: 1fr; margin-top: -12px; }
  .today-reminder-events { justify-content: stretch; }
  .today-reminder-event { width: 100%; min-width: 0; }
}


/* Mobile compatibility and small-screen layout hardening */
html,
body { max-width: 100%; overflow-x: hidden; }
body { -webkit-text-size-adjust: 100%; }
button,
a,
input,
textarea,
select { -webkit-tap-highlight-color: transparent; }
button,
.btn,
.tab-button,
.admin-tab-button,
.calendar-nav-button { min-height: 44px; }
.site-shell,
.admin-shell,
.card,
.tab-panel,
.admin-panel,
.admin-grid,
.admin-sidebar,
.form-grid,
.field,
.race-card,
.race-card-header,
.race-header-info,
.calendar-layout,
.calendar-card,
.upcoming-card,
.event-detail-layout,
.rule-section,
.rule-section > div { min-width: 0; }
.section-heading h1,
.section-heading h2,
.race-card-header h2,
.event-detail-info h2,
.rule-section h2,
.rule-product,
.linked-track-location,
.linked-track-details,
.event-description,
.help-text { overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .site-shell,
  .admin-shell { width: min(100% - 16px, 1180px); }

  .site-header { padding: 12px 0 6px; }
  .main-page-logo { width: min(470px, 82vw); }

  .tabs {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
    margin: 8px auto 18px;
    padding: 5px;
    overflow: visible;
    border-radius: 15px;
  }
  .tab-button {
    width: 100%;
    min-width: 0;
    padding: 9px 7px;
    white-space: normal;
    line-height: 1.15;
    font-size: .79rem;
    text-align: center;
  }

  .today-event-reminder {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: -5px 0 17px;
    padding: 9px 10px;
  }
  .today-reminder-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .today-reminder-label { font-size: .61rem; }
  .today-reminder-heading strong { font-size: .82rem; text-align: right; }
  .today-reminder-events { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .today-reminder-event { width: 100%; min-width: 0; padding: 6px 8px; gap: 8px; }
  .today-reminder-track-logo { width: 44px; height: 36px; }

  .section-heading { margin-bottom: 13px; }
  .section-heading h1,
  .section-heading h2 { font-size: clamp(1.45rem, 7vw, 2rem); }
  .section-heading p { font-size: .88rem; line-height: 1.45; }

  /* Turn public data tables into readable mobile cards instead of horizontal scrollers. */
  .table-wrap { overflow: visible; border-radius: 0; }
  .standings-table,
  .race-results-table,
  .race-results .race-results-table {
    width: 100%;
    min-width: 0;
    display: block;
    table-layout: fixed;
  }
  .standings-table thead,
  .race-results-table thead { display: none; }
  .standings-table tbody,
  .race-results-table tbody {
    width: 100%;
    display: grid;
    gap: 9px;
    padding: 10px;
  }
  .standings-table tr,
  .race-results-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
  }
  .standings-table td,
  .race-results-table td {
    display: flex;
    min-width: 0;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 0;
    border: 0;
    text-align: right;
    font-size: .88rem;
  }
  .standings-table td::before,
  .race-results-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: .67rem;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
  }
  .standings-table .driver-cell,
  .race-results-table .driver-cell {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    justify-content: start;
    text-align: left;
  }
  .standings-table .driver-cell::before,
  .race-results-table .driver-cell::before { align-self: start; padding-top: 2px; }
  .standings-table .driver-cell strong,
  .race-results-table .driver-cell strong,
  .standings-table .driver-cell span,
  .race-results-table .driver-cell span { grid-column: 2; overflow-wrap: anywhere; }
  .standings-table .position,
  .race-results-table .position { width: auto; }

  .race-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    padding: 0;
    margin-bottom: 11px;
  }
  .race-tab-button {
    min-width: 0;
    width: 100%;
    padding: 9px 10px;
  }
  .race-tab-button strong { max-width: 100%; font-size: .82rem; }
  .race-tab-button span { font-size: .7rem; }

  .race-card-header,
  .race-card-header.no-track-logo {
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 16px 14px;
  }
  .race-header-info { gap: 11px; }
  .race-track-logo {
    justify-self: center;
    width: min(270px, 78vw);
    height: 155px;
  }
  .race-meta { gap: 5px 10px; font-size: .82rem; }
  .race-count { padding: 6px 9px; font-size: .76rem; }
  .race-notes { padding: 14px 14px 0; font-size: .9rem; }
  .race-results { padding: 14px 10px 0; }
  .race-results .table-wrap { border: 0; }
  .race-subsection { padding: 17px 14px; }
  .link-list { display: grid; grid-template-columns: 1fr; }
  .youtube-link { width: 100%; min-width: 0; overflow-wrap: anywhere; }
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

  .calendar-layout { grid-template-columns: 1fr; gap: 12px; }
  .calendar-card { overflow: hidden; }
  .calendar-toolbar,
  .calendar-weekdays,
  .calendar-grid { min-width: 0; width: 100%; }
  .calendar-toolbar {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    padding: 11px 9px;
  }
  .calendar-toolbar h2 { font-size: 1.08rem; }
  .calendar-nav-button { width: 38px; height: 38px; min-height: 38px; }
  .calendar-weekdays span { padding: 7px 1px; font-size: .58rem; letter-spacing: 0; }
  .calendar-day {
    min-width: 0;
    min-height: 70px;
    padding: 3px;
  }
  .calendar-day-number {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    font-size: .68rem;
  }
  .calendar-event-chip {
    display: -webkit-box;
    width: 100%;
    max-height: 28px;
    margin-top: 3px;
    padding: 3px 2px;
    overflow: hidden;
    border-left-width: 2px;
    border-radius: 4px;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: .56rem;
    line-height: 1.05;
  }
  .calendar-more { margin: 3px 0 0 1px; font-size: .55rem; }
  .upcoming-card { padding: 14px; }
  .upcoming-event { grid-template-columns: 48px minmax(0, 1fr); gap: 9px; padding: 9px; }
  .event-date-box { min-height: 50px; }
  .event-date-box strong { font-size: 1.2rem; }
  .event-details h3 { font-size: .9rem; overflow-wrap: anywhere; }
  .event-meta { font-size: .72rem; }
  .event-details p { font-size: .78rem; }

  .event-detail-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px 14px 16px;
  }
  .event-detail-info h2 { padding-right: 30px; font-size: 1.5rem; }
  .event-detail-meta { font-size: .82rem; }
  .event-description { margin-top: 14px; font-size: .9rem; }
  .event-track-info { margin-top: 15px; padding-top: 14px; }
  .event-track-logo-wrap { min-height: 0; }
  .event-track-logo { width: min(280px, 76vw); max-height: 180px; }

  .rule-section { padding: 17px 14px; }
  .rule-number { width: 40px; height: 40px; border-radius: 11px; }
  .rule-section p { font-size: .9rem; line-height: 1.55; }
  .approved-links,
  .approved-links.one-column,
  .approved-links.three-column { grid-template-columns: 1fr; }
  .rule-product { min-height: 0; padding: 12px; }

  /* Admin: keep every editor and list inside the viewport. */
  .admin-shell { padding: 12px 0 34px; }
  .auth-card { width: 100%; margin: 20px auto; padding: 18px 14px; }
  .auth-card .site-logo { width: min(330px, 82vw); }
  .admin-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
  }
  .admin-brand { min-width: 0; gap: 9px; }
  .admin-brand img { width: 110px; flex: 0 0 auto; }
  .admin-brand h1 { font-size: 1.05rem; }
  .admin-brand p { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
  #logout-button { padding: 8px 10px; font-size: .78rem; white-space: nowrap; }

  .admin-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 5px;
    margin-bottom: 13px;
    padding: 4px;
    border-radius: 13px;
  }
  .admin-tab-button {
    min-width: 0;
    padding: 8px 4px;
    white-space: normal;
    font-size: .72rem;
    line-height: 1.15;
  }
  .admin-grid,
  .admin-sidebar { grid-template-columns: 1fr; gap: 12px; }
  .admin-sidebar { position: static; }
  .admin-card { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 11px; }
  .field.full { grid-column: auto; }
  .field input,
  .field textarea,
  .field select { min-width: 0; font-size: 16px; padding: 11px; }
  .field input[type="file"] { overflow: hidden; padding: 8px; }
  .subsection-bar { flex-wrap: wrap; gap: 8px; margin: 19px 0 9px; }
  .subsection-bar > div { min-width: 0; }
  .subsection-bar h2,
  .subsection-bar h3 { overflow-wrap: anywhere; }
  .import-panel { padding: 12px; }
  .button-row { width: 100%; }
  .button-row > .btn { flex: 1 1 130px; }
  .file-status { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
  .track-logo-preview { align-items: flex-start; flex-direction: column; }
  .track-logo-preview img { width: min(180px, 100%); height: 110px; }
  .admin-race-row,
  .driver-row { align-items: flex-start; }
  .admin-race-row > div:first-child,
  .driver-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
  .admin-race-row .button-row,
  .driver-row .button-row { width: auto; flex: 0 0 auto; }
  .admin-race-row .button-row > .btn,
  .driver-row .button-row > .btn { flex: 0 0 auto; }
  .link-row,
  .result-row { grid-template-columns: 1fr; gap: 9px; padding: 10px; }
  .link-row .field,
  .result-row .field,
  .result-row .field:first-child,
  .link-row .field:nth-child(2),
  .remove-row { grid-column: 1; }
  .remove-row { width: 100%; height: 42px; }
  .admin-images { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { left: 8px; right: 8px; bottom: 8px; max-width: none; }
}

@media (max-width: 420px) {
  .site-shell,
  .admin-shell { width: min(100% - 12px, 1180px); }
  .main-page-logo { width: min(390px, 88vw); }
  .tab-button { font-size: .74rem; padding-inline: 4px; }
  .race-tabs { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: 1fr; }
  .standings-table tr,
  .race-results-table tr { grid-template-columns: 1fr; }
  .standings-table .driver-cell,
  .race-results-table .driver-cell { grid-column: 1; }
  .calendar-day { min-height: 62px; padding: 2px; }
  .calendar-weekdays span { font-size: .52rem; }
  .calendar-event-chip { max-height: 22px; font-size: .5rem; -webkit-line-clamp: 1; }
  .admin-brand img { width: 88px; }
  .admin-brand p { max-width: 35vw; }
  .admin-race-row,
  .driver-row { display: grid; grid-template-columns: 1fr; }
  .admin-race-row .button-row,
  .driver-row .button-row { width: 100%; }
  .admin-race-row .button-row > .btn,
  .driver-row .button-row > .btn { flex: 1 1 0; }
  .admin-images { grid-template-columns: 1fr; }
}

/* Home dashboard */
.home-heading {
  max-width: 760px;
  margin: 0 auto 18px;
  text-align: center;
}
.home-eyebrow,
.home-card-kicker {
  display: block;
  color: var(--yellow);
  font-size: .72rem;
  font-weight: 950;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.home-heading h1 { margin-top: 5px; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.home-card {
  min-width: 0;
  padding: 20px;
  overflow: hidden;
}
.home-latest-race {
  grid-column: 1 / -1;
  padding: 18px;
}
.home-latest-race .home-feature-layout {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 9, 13, .22);
}
.home-card-header h2 {
  margin: 5px 0 0;
  font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.home-card-header p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
.home-feature-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  min-height: 330px;
}
.home-feature-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 32px 34px;
  overflow: hidden;
}
.home-feature-content .home-card-header,
.home-feature-content .home-card-header h2,
.home-feature-content .home-card-header p {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}
.home-feature-visual {
  display: grid;
  min-width: 0;
  min-height: 280px;
  place-items: center;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(255,212,0,.12), transparent 55%),
    linear-gradient(145deg, rgba(8,120,216,.14), rgba(236,28,36,.10));
}
.home-race-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-race-logo {
  width: min(360px, 82%);
  max-height: 245px;
  object-fit: contain;
  filter: drop-shadow(0 15px 24px rgba(0,0,0,.42));
}
.home-race-placeholder { font-size: 5rem; filter: drop-shadow(0 10px 20px rgba(0,0,0,.4)); }
.home-podium {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}
.home-podium-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.025);
}
.home-podium-row strong { min-width: 0; overflow-wrap: anywhere; }
.home-podium-position,
.home-standing-position {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: rgba(255,255,255,.08);
  font-weight: 950;
}
.home-podium-position.position-1,
.home-standing-position.position-1 { color: #111; background: var(--yellow); }
.home-podium-position.position-2,
.home-standing-position.position-2 { color: #111; background: #dfe6ee; }
.home-podium-position.position-3,
.home-standing-position.position-3 { color: #111; background: #d88a45; }
.home-podium-points { color: var(--yellow); font-size: .85rem; font-weight: 900; white-space: nowrap; }
.home-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 22px;
}
.home-link-button,
.race-like-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 14px;
  color: #fff;
  background: rgba(255,255,255,.045);
  cursor: pointer;
  font-weight: 850;
}
.home-link-button:hover,
.race-like-button:hover:not(:disabled) {
  border-color: rgba(255,212,0,.58);
  background: rgba(255,212,0,.08);
}
.home-card > .home-link-button { width: 100%; margin-top: 18px; }
.race-like-button {
  border-color: rgba(255,212,0,.35);
  background: rgba(255,212,0,.08);
}
.race-like-button.compact { min-height: 36px; padding: 6px 10px; font-size: .78rem; }
.race-like-button.liked {
  color: #111;
  border-color: var(--yellow);
  background: var(--yellow);
  opacity: 1;
}
.race-like-button.saving { opacity: .7; }
.race-like-button.error { border-color: var(--red); color: #ffb8bc; }
.race-like-flag { font-size: 1.15em; line-height: 1; }
.race-like-count {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #111;
  background: var(--yellow);
  text-align: center;
  font-size: .75rem;
  font-weight: 950;
}
.race-like-button.liked .race-like-count { background: rgba(0,0,0,.14); }
.race-header-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

.home-event-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  margin-top: 18px;
}
.home-event-logo {
  width: 92px;
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.38));
}
.home-event-info { min-width: 0; }
.home-event-info strong,
.home-event-info span { display: block; }
.home-event-info span { margin-top: 4px; color: var(--muted); font-size: .82rem; line-height: 1.4; overflow-wrap: anywhere; }
.home-event-info p { margin: 10px 0 0; color: #d9dee7; font-size: .86rem; line-height: 1.45; }
.home-standings-list { display: grid; gap: 7px; margin-top: 17px; }
.home-standing-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
}
.home-standing-row:last-child { border-bottom: 0; }
.home-standing-position { width: 27px; height: 27px; border-radius: 8px; font-size: .82rem; }
.home-standing-driver { min-width: 0; }
.home-standing-driver strong,
.home-standing-driver span { display: block; overflow-wrap: anywhere; }
.home-standing-driver span { margin-top: 1px; color: var(--muted); font-size: .72rem; }
.home-standing-points { color: var(--yellow); font-size: 1.02rem; }
.home-rule-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.home-rule-chips span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #dce2eb;
  background: rgba(255,255,255,.03);
  font-size: .76rem;
  font-weight: 750;
}

@media (max-width: 900px) {
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-latest-race { grid-column: 1 / -1; }
  .home-feature-layout { grid-template-columns: minmax(0, 1.1fr) minmax(230px, .9fr); }
}

@media (max-width: 700px) {
  .home-grid { grid-template-columns: 1fr; gap: 12px; }
  .home-latest-race { grid-column: 1; }
  .home-card { padding: 16px 14px; }
  .home-latest-race { padding: 12px; }
  .home-feature-layout { grid-template-columns: 1fr; min-height: 0; }
  .home-feature-content { padding: 22px 20px 18px; }
  .home-feature-visual {
    grid-row: 1;
    min-height: 180px;
    max-height: 230px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }
  .home-race-logo { width: min(270px, 76vw); max-height: 170px; }
  .home-race-photo { max-height: 230px; }
  .home-podium { margin-top: 16px; }
  .home-podium-row { grid-template-columns: 34px minmax(0, 1fr) auto; padding: 9px; }
  .home-card-actions { display: grid; grid-template-columns: 1fr; padding-top: 16px; }
  .home-card-actions > * { width: 100%; }
  .home-event-body { grid-template-columns: 74px minmax(0, 1fr); }
  .home-event-logo { width: 74px; height: 62px; }
  .race-header-actions { width: 100%; }
  .race-header-actions .race-like-button { flex: 1 1 auto; }
}

@media (max-width: 420px) {
  .home-heading { margin-bottom: 14px; }
  .home-latest-race { padding: 10px; }
  .home-feature-content { padding: 20px 17px 17px; }
  .home-eyebrow { font-size: .64rem; }
  .home-card-header h2 { font-size: 1.22rem; }
  .home-podium-points { font-size: .72rem; }
  .race-like-label { font-size: .8rem; }
}

/* Footer-link ordering controls */
@media (max-width: 640px) {
  .footer-link-admin-row { display: grid; grid-template-columns: 1fr; }
  .footer-link-actions { width: 100% !important; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .footer-link-actions .btn { width: 100%; min-width: 0; padding-inline: 6px; }
}
@media (max-width: 360px) {
  .footer-link-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* Race or practice session selector */
.field-label {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.session-type-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.session-type-toggle label {
  position: relative;
  display: block;
  cursor: pointer;
}
.session-type-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.session-type-toggle label > span {
  display: grid;
  gap: 4px;
  min-height: 86px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.session-type-toggle label:hover > span {
  border-color: rgba(255,212,0,.38);
}
.session-type-toggle input:checked + span {
  color: #111;
  border-color: var(--yellow);
  background: linear-gradient(135deg, var(--yellow), #ffad00);
  box-shadow: 0 8px 22px rgba(255,212,0,.14);
}
.session-type-toggle strong {
  font-size: .95rem;
}
.session-type-toggle small {
  color: var(--muted);
  font-size: .77rem;
  line-height: 1.4;
}
.session-type-toggle input:checked + span small {
  color: rgba(0,0,0,.68);
}
.session-type-toggle input:focus-visible + span {
  outline: 3px solid rgba(255,212,0,.28);
  outline-offset: 2px;
}
.session-type-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 9px;
  border: 1px solid rgba(255,212,0,.32);
  border-radius: 999px;
  color: var(--yellow);
  background: rgba(255,212,0,.08);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.session-type-badge.practice {
  color: #8bc8ff;
  border-color: rgba(78,163,255,.38);
  background: rgba(8,120,216,.12);
}

@media (max-width: 640px) {
  .session-type-toggle { grid-template-columns: 1fr; }
  .session-type-toggle label > span { min-height: 0; }
}


/* Fastest-lap points bonus */
.best-lap-cell {
  white-space: normal;
}

.fastest-lap-time {
  color: #ffd34e;
  font-weight: 950;
  text-shadow: 0 0 12px rgba(255, 211, 78, 0.24);
}

.fastest-lap-icon {
  display: inline-block;
  margin-left: 0.38rem;
  font-size: 1rem;
  line-height: 1;
  vertical-align: -0.08em;
  cursor: help;
}

.fastest-lap-row .points {
  font-weight: 900;
}


/* Compact points-system help */
.section-heading-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: fit-content;
  max-width: 100%;
}

.section-heading-title-row h1 { margin: 0; }

.points-info {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.points-info-button {
  display: inline-block;
  padding: 0.08rem 0.18rem;
  border: 0;
  background: transparent;
  color: var(--yellow);
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  cursor: help;
}

.points-info-button:hover,
.points-info-button:focus-visible {
  color: #ffe66b;
  outline: none;
}

.points-info-tooltip {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  width: min(260px, calc(100vw - 30px));
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 212, 0, 0.42);
  border-radius: 10px;
  background: #11141b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  color: #f5f7fb;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.4;
  text-transform: none;
  transform: translate(-50%, 0.25rem);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.points-info:hover .points-info-tooltip,
.points-info:focus-within .points-info-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

@media (max-width: 480px) {
  .points-info-tooltip {
    left: auto;
    right: -0.25rem;
    transform: translate(0, 0.25rem);
  }

  .points-info:hover .points-info-tooltip,
  .points-info:focus-within .points-info-tooltip {
    transform: translate(0, 0);
  }
}

/* Preserve uploaded image proportions on phones */
@media (max-width: 700px) {
  .site-logo,
  .main-page-logo,
  .race-track-logo,
  .event-track-logo,
  .today-reminder-track-logo,
  .home-race-logo,
  .home-event-logo,
  .track-logo-preview img {
    height: auto;
    object-fit: contain;
  }

  .race-track-logo { max-height: 170px; }
  .event-track-logo { max-height: 210px; }
  .today-reminder-track-logo { max-height: 42px; }
  .home-event-logo { max-height: 62px; }

  .home-feature-visual {
    min-height: 0;
    max-height: none;
  }

  .home-race-photo {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
  }

  .race-image {
    aspect-ratio: auto;
  }

  .race-image img,
  .admin-image img {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    object-fit: contain;
  }

  .lightbox img {
    width: auto;
    height: auto;
    max-width: 95vw;
    max-height: 85vh;
    object-fit: contain;
  }
}
