/* =========================================================================
   Bay to Breakers 2026 — Wrapped
   Technicolor sport graphic. Teal ground, ink hairlines, sticker accents.
   ========================================================================= */

:root {
  --teal:       #4FC0D4;
  --teal-dark:  #2EA8BD;
  --paper:      #FFFFFF;
  --ink:        #0A0A0A;
  --ink-soft:   #2B2B2B;
  --gray-100:   #F2F2F2;
  --gray-300:   #C7C7C7;
  --gray-500:   #6B6B6B;

  --pink:       #FF388F;
  --pink-2:     #E61F73;
  --yellow:     #FFD61F;
  --orange:     #FF6A1A;
  --green:      #6BD473;

  --sans: "Archivo", -apple-system, BlinkMacSystemFont, "Helvetica Neue",
           Helvetica, Arial, sans-serif;

  --hair:      1.5px solid var(--ink);
  --hair-thin: 1px solid var(--ink);
  --hair-soft: 1px solid rgba(10, 10, 10, 0.12);
  --grid: 32px;
}

/* --- reset ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--teal); }
body {
  margin: 0;
  background: var(--teal);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* leftover decorative grain from old design — kill it on this palette */
.grain { display: none; }

/* tabular figures for numerics */
.display,
input,
.stat-value,
.nearest table,
.masthead {
  font-feature-settings: "tnum", "lnum", "kern";
  font-variant-numeric: tabular-nums lining-nums;
}

/* --- masthead (top black bar) ----------------------------------------- */

.masthead {
  background: var(--ink);
  color: var(--paper);
  border-bottom: var(--hair);
  position: relative;
  z-index: 10;
}
.masthead-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px var(--grid);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.dateline {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--yellow);
}
.dateline.align-right { text-align: right; color: rgba(255,255,255,0.7); }
.masthead-link {
  color: var(--yellow);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}
.masthead-link:hover { color: var(--pink); border-bottom-color: var(--pink); }
.masthead-mark {
  margin: 0;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0;
  color: var(--paper);
}
.masthead-mark span {
  color: var(--pink);
  padding: 0 0.18em;
  font-weight: 800;
}
/* dashed sub-rule under masthead in old design — neutralize */
.masthead .lane-rule { display: none; }

/* --- main shell ------------------------------------------------------- */

.paper {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--grid);
}

/* --- rules ------------------------------------------------------------ */

.lane-rule {
  height: 0;
  border-top: var(--hair);
  margin: 32px 0;
}
.lane-rule.short {
  width: 80px;
  margin: 4px 0 8px;
  border-top: 3px solid var(--ink);
}

/* --- hero ------------------------------------------------------------- */

.hero {
  padding: 56px 0 48px;
  max-width: 1180px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 40px 56px;
}
.hero-text {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.hero-medal {
  position: relative;
  z-index: 1; /* below .masthead (z:10) so the ribbon tucks behind it */
  width: clamp(204px, 27vw, 344px);
  justify-self: end;
  /* Pull the medal up so its ribbon disappears into the masthead. */
  margin-top: clamp(-172px, -12.5vw, -95px);
  margin-bottom: clamp(-120px, -8vw, -60px);
}
.hero-medal img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 0%; /* swings from the hidden pin inside the masthead */
  animation: medal-sway 5.4s ease-in-out infinite;
  filter: drop-shadow(8px 12px 0 rgba(10, 10, 10, 0.18))
          drop-shadow(0 0 22px rgba(255, 214, 31, 0.25));
  will-change: transform;
}
@keyframes medal-sway {
  0%, 100% { transform: rotate(-3.2deg); }
  50%      { transform: rotate(3.2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-medal img { animation: none; transform: rotate(0); }
}

@media (max-width: 780px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 32px 0 40px;
  }
  .hero-medal {
    width: clamp(180px, 56vw, 280px);
    justify-self: center;
    order: -1;
    /* On mobile the medal sits above the text, hanging from the masthead */
    margin-top: clamp(-236px, -39vw, -162px);
    margin-bottom: -12px;
  }
  .hero-medal img {
    filter: drop-shadow(5px 7px 0 rgba(10, 10, 10, 0.18));
  }
}

.kicker {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 14px;
  width: fit-content;
  background: var(--ink);
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1.display, .display {
  margin: 0;
  font-weight: 900;
  font-size: clamp(54px, 10.5vw, 156px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  color: var(--ink);
  max-width: none;
}
.display em {
  font-style: normal;
  color: var(--pink);
}
.display.medium {
  font-size: clamp(26px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.02;
}

.lede {
  margin: 0;
  max-width: 36rem;
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink-soft);
  font-weight: 500;
}
:root[data-theme="cardinal"] .hero .lede {
  max-width: 44rem;
  text-wrap: pretty;
}
.lede.small {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.hero-backline {
  margin-top: 4px;
}
.hero-back-link {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
.hero-back-link:hover {
  color: var(--pink-2);
}
.hero-back-link:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}

/* --- section heading -------------------------------------------------- */

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 28px;
  padding: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink);
  border: 0;
}
.section-heading.minor { font-size: 20px; margin-top: 16px; }
.section-num {
  display: inline-block;
  padding: 4px 10px;
  background: var(--ink);
  color: var(--pink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-family: var(--sans);
  flex-shrink: 0;
}
.section-name {
  font-style: normal;
  font-weight: 800;
}

/* --- form bay (white panel) ------------------------------------------ */

.form-bay {
  margin: 16px 0 40px;
  padding: 40px 36px 48px;
  background: var(--paper);
  border: var(--hair);
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 24px;
}
.field { display: block; }
.field.span-2 { grid-column: span 2; }

.field label { display: grid; gap: 8px; cursor: pointer; }

.field-tag {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.field-tag em {
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  text-transform: uppercase;
}

input, select {
  width: 100%;
  background: var(--paper);
  border: var(--hair-thin);
  border-radius: 0;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder { color: var(--gray-300); }
input:hover, select:hover { background: var(--gray-100); }
input:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--pink);
  background: var(--paper);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.inline { display: flex; gap: 0; }
.inline input { flex: 1; min-width: 0; border-right: 0; }

.ghost {
  padding: 0 22px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--paper);
  border: var(--hair-thin);
  color: var(--ink);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.ghost:hover { background: var(--pink); color: var(--paper); border-color: var(--pink); }

/* Strava foldout */
.strava {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding-top: 24px;
  border-top: var(--hair-soft);
}
.strava summary {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.strava summary::-webkit-details-marker { display: none; }
.summary-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: var(--hair-thin);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease, transform 200ms ease;
}
.strava[open] .summary-marker {
  background: var(--ink);
  color: var(--yellow);
  transform: rotate(45deg);
}
.strava-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.micro {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}
.details-grid { margin-top: 14px; }

/* --- primary CTA ----------------------------------------------------- */

.primary {
  width: 100%;
  margin-top: 36px;
  padding: 22px 28px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.005em;
  border: 0;
  border-radius: 0;
  transition: background 140ms ease;
}
.primary-label { font-weight: 700; }
.primary:hover { background: var(--pink); }
.primary:hover .primary-arrow { transform: translateX(8px); }
.primary:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}
.primary-arrow { font-size: 22px; font-weight: 500; transition: transform 200ms ease; }

.status {
  margin: 16px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray-500);
}

/* --- results --------------------------------------------------------- */

.results { display: grid; gap: 0; }
.results > .lane-rule { margin: 8px 0 24px; }

.results-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px 40px;
  max-width: 64rem;
  padding-bottom: 28px;
  background: transparent;
  border: 0;
  padding-top: 0;
}
.results-head-text {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.results-head .kicker { margin-bottom: 4px; }

/* --- scorecard medal (animates on results reveal) -------------------- */

.scorecard-medal {
  position: relative;
  width: clamp(108px, 13vw, 148px);
  justify-self: end;
  flex-shrink: 0;
  isolation: isolate;
}
.scorecard-medal img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 4%;
  filter: drop-shadow(5px 7px 0 rgba(10, 10, 10, 0.22));
  position: relative;
  z-index: 1;
  opacity: 0; /* hidden until the .animate class fires the entrance */
  will-change: transform, opacity;
}

/* yellow halo that flares behind the medal on reveal */
.scorecard-medal .medal-halo {
  position: absolute;
  inset: -28%;
  border-radius: 50%;
  background: radial-gradient(circle,
              rgba(255, 214, 31, 0.85) 0%,
              rgba(255, 214, 31, 0.35) 38%,
              rgba(255, 214, 31, 0) 70%);
  opacity: 0;
  transform: scale(0.55);
  z-index: 0;
  pointer-events: none;
}

/* confetti pieces — colors and trajectories assigned per-piece */
.scorecard-medal .medal-confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.scorecard-medal .medal-confetti i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 13px;
  margin: -7px 0 0 -5px;
  opacity: 0;
  border-radius: 1.5px;
  box-shadow: 1px 1px 0 rgba(10, 10, 10, 0.45);
}
.scorecard-medal .medal-confetti i:nth-child(1)  { background: var(--pink);      --tx:  120px; --ty: -110px; --rot:  280deg; --delay: 60ms;  }
.scorecard-medal .medal-confetti i:nth-child(2)  { background: var(--yellow);    --tx: -130px; --ty:  -90px; --rot: -240deg; --delay: 0ms;   }
.scorecard-medal .medal-confetti i:nth-child(3)  { background: var(--teal-dark); --tx:  140px; --ty:   80px; --rot:  340deg; --delay: 90ms;  }
.scorecard-medal .medal-confetti i:nth-child(4)  { background: var(--orange);    --tx: -140px; --ty:  100px; --rot: -300deg; --delay: 40ms;  }
.scorecard-medal .medal-confetti i:nth-child(5)  { background: var(--green);     --tx:   30px; --ty: -150px; --rot:  200deg; --delay: 110ms; }
.scorecard-medal .medal-confetti i:nth-child(6)  { background: var(--pink);      --tx:  -50px; --ty: -140px; --rot: -180deg; --delay: 130ms; }
.scorecard-medal .medal-confetti i:nth-child(7)  { background: var(--yellow);    --tx:  160px; --ty:   -10px;--rot:  320deg; --delay: 20ms;  }
.scorecard-medal .medal-confetti i:nth-child(8)  { background: var(--orange);    --tx: -160px; --ty:   20px; --rot: -320deg; --delay: 70ms;  }
.scorecard-medal .medal-confetti i:nth-child(9)  { background: var(--teal-dark); --tx:   75px; --ty:  130px; --rot:  240deg; --delay: 150ms; }
.scorecard-medal .medal-confetti i:nth-child(10) { background: var(--green);     --tx:  -80px; --ty:  140px; --rot: -260deg; --delay: 170ms; }

/* fire the celebration when .animate is on the container */
.scorecard-medal.animate img {
  animation:
    medal-drop 950ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
    medal-sway 5.4s ease-in-out 1100ms infinite;
}
.scorecard-medal.animate .medal-halo {
  animation: medal-halo 1100ms ease-out both;
}
.scorecard-medal.animate .medal-confetti i {
  animation: confetti-fly 1100ms cubic-bezier(0.22, 1, 0.36, 1) var(--delay, 0ms) both;
}

@keyframes medal-drop {
  0%   { opacity: 0; transform: translateY(-220px) rotate(-90deg) scale(0.3); }
  55%  { opacity: 1; transform: translateY(8px) rotate(12deg) scale(1.08); }
  72%  {             transform: translateY(0)   rotate(-5deg) scale(0.99); }
  86%  {             transform: translateY(0)   rotate(2deg)  scale(1.01); }
  100% { opacity: 1; transform: translateY(0)   rotate(0)     scale(1);    }
}
@keyframes medal-halo {
  0%   { opacity: 0;   transform: scale(0.55); }
  35%  { opacity: 0.95;transform: scale(1.45); }
  100% { opacity: 0;   transform: scale(2.1);  }
}
@keyframes confetti-fly {
  0%   { opacity: 0; transform: translate(0,0) rotate(0); }
  18%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) rotate(var(--rot)); }
}

@media (prefers-reduced-motion: reduce) {
  .scorecard-medal.animate img {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .scorecard-medal.animate .medal-halo,
  .scorecard-medal.animate .medal-confetti i { animation: none; opacity: 0; }
}

@media (max-width: 780px) {
  .results-head {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px 18px;
  }
  .scorecard-medal {
    width: clamp(82px, 22vw, 110px);
  }
}

/* --- stat cards ------------------------------------------------------ */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  padding: 28px 24px 32px;
  background: var(--paper);
  border: var(--hair);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 220px;
  position: relative;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.stat-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

.stat-head { margin: 0; padding: 0; border: 0; background: transparent; }

.stat-kicker {
  margin: 0 0 24px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

.stat-value {
  margin: 0;
  font-size: clamp(40px, 6.5vw, 76px);
  font-weight: 900;
  line-height: 0.94;
  letter-spacing: -0.04em;
  color: var(--ink);
  word-break: break-word;
}

.stat-copy {
  margin: 24px 0 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 24em;
}

/* rotating accents across the card grid */
.cards .stat-card:nth-child(1) .stat-value { color: var(--pink); }
.cards .stat-card:nth-child(2) .stat-value { color: var(--orange); }
.cards .stat-card:nth-child(3) .stat-value { color: var(--teal-dark); }
.cards .stat-card:nth-child(4) .stat-value { color: var(--ink); }
.cards .stat-card:nth-child(5) .stat-value { color: var(--pink); }
.cards .stat-card:nth-child(6) .stat-value { color: var(--orange); }

/* --- field graphic --------------------------------------------------- */

.field-graphic-section {
  margin: 8px 0 32px;
  display: grid;
  gap: 0;
}
.field-graphic-section .section-heading {
  margin: 0 0 16px;
}

.field-graphic {
  position: relative;
  background: var(--paper);
  border: var(--hair);
  padding: 20px 24px 16px;
  overflow: hidden;
}

/* tiny sticker decorations in the corners */
.field-graphic::before,
.field-graphic::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}
.field-graphic::before {
  top: 16px;
  left: 20px;
  width: 10px;
  height: 10px;
  background: var(--yellow);
  border: 1.4px solid var(--ink);
  transform: rotate(20deg);
}
.field-graphic::after {
  top: 24px;
  right: 28px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid var(--green);
  filter: drop-shadow(0.6px 0 0 var(--ink)) drop-shadow(-0.6px 0 0 var(--ink)) drop-shadow(0 0.6px 0 var(--ink)) drop-shadow(0 -0.6px 0 var(--ink));
  transform: rotate(-10deg);
}

.field-graphic-svg {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  z-index: 1;
}
.field-graphic-svg text { font-family: var(--sans); }
.field-graphic-svg .bar { transition: opacity 140ms ease; }

.field-graphic-caption {
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.45;
}
.field-graphic-caption strong {
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums lining-nums;
}
.field-graphic-caption .pct {
  display: inline-flex;
  align-items: center;
  background: var(--pink);
  color: var(--paper);
  padding: 2px 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums lining-nums;
}

@media (max-width: 640px) {
  .field-graphic { padding: 16px 12px 12px; }
  .field-graphic::before { top: 12px; left: 14px; }
  .field-graphic::after { top: 18px; right: 18px; }
  .field-graphic-caption { font-size: 12px; gap: 6px 14px; }
}

/* --- nearest --------------------------------------------------------- */

.nearest {
  background: var(--paper);
  border: var(--hair);
  padding: 4px;
  margin-top: 16px;
}
.nearest .section-heading {
  margin: 12px 16px 0;
  padding: 0;
  border: 0;
}
.nearest table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 0;
}
.nearest thead th {
  text-align: left;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--yellow);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.nearest tbody td {
  padding: 14px 18px;
  border-bottom: var(--hair-soft);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.nearest tbody tr:last-child td { border-bottom: 0; }
.nearest tbody td:first-child { font-weight: 700; }
.nearest tbody td:nth-child(2),
.nearest tbody td:nth-child(3),
.nearest tbody td:nth-child(4) {
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.nearest tbody tr:hover td { background: var(--gray-100); }

/* --- colophon -------------------------------------------------------- */

.colophon {
  padding: 24px 0 56px;
  text-align: left;
}
.colophon-mark {
  display: none; /* newspaper sign-off doesn't fit the technicolor look */
}
.colophon .micro {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.colophon em {
  font-style: normal;
  font-weight: 800;
  color: var(--ink);
  background: var(--yellow);
  padding: 0 6px;
}

/* --- responsive ------------------------------------------------------ */

@media (min-width: 1100px) and (max-height: 980px) {
  :root { --grid: 20px; }

  .masthead-inner,
  .paper {
    max-width: 1080px;
  }

  .hero {
    padding: 40px 0 32px;
    gap: 24px 36px;
  }
  .hero-text { gap: 18px; }
  h1.display, .display { font-size: clamp(46px, 8.2vw, 114px); }
  .hero-medal {
    width: clamp(176px, 22vw, 260px);
    margin-top: clamp(-176px, -13vw, -104px);
    margin-bottom: clamp(-92px, -6vw, -40px);
  }
  .lede { font-size: 17px; }

  .lane-rule { margin: 24px 0; }
  .lane-rule.short { margin: 0 0 8px; }

  .form-bay {
    margin: 12px 0 26px;
    padding: 30px 28px 34px;
  }
  .fields { gap: 22px 18px; }
  .primary {
    margin-top: 26px;
    padding: 18px 24px;
    font-size: 16px;
  }

  .results > .lane-rule { margin: 0 0 18px; }
  .results-head {
    gap: 16px 28px;
    padding-bottom: 18px;
  }
  .display.medium { font-size: clamp(24px, 3.1vw, 36px); }

  .cards {
    gap: 12px;
    margin-bottom: 22px;
  }
  .stat-card {
    min-height: 182px;
    padding: 22px 20px 24px;
  }
  .stat-kicker { margin-bottom: 16px; }
  .stat-value { font-size: clamp(36px, 5.1vw, 60px); }
  .stat-copy {
    margin-top: 14px;
    font-size: 12px;
  }

  .field-graphic-section { margin: 0 0 20px; }
  .field-graphic { padding: 16px 20px 12px; }
  .field-graphic-caption { margin-top: 10px; }

  .nearest { margin-top: 10px; }
  .nearest thead th { padding: 12px 14px; }
  .nearest tbody td { padding: 12px 14px; }

  .colophon { padding: 18px 0 34px; }
}

@media (max-width: 960px) {
  :root { --grid: 24px; }
  .hero { padding: 64px 0 48px; gap: 24px; }
  .form-bay { padding: 32px 24px 36px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strava-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================================
   Stanford / Cardinal edition
   Theme overrides + leaderboard table + auth UI. Only active when
   <html data-theme="cardinal">, so the main page is unaffected.
   ========================================================================= */

:root[data-theme="cardinal"] {
  --teal:       #F4E9E1;
  --teal-dark:  #8C1515;
  --pink:       #8C1515;
  --pink-2:     #6E0F11;
  --yellow:     #FFD200;
}
:root[data-theme="cardinal"] body { background: #F4E9E1; }
:root[data-theme="cardinal"] .cards .stat-card:nth-child(1) .stat-value { color: #8C1515; }
:root[data-theme="cardinal"] .cards .stat-card:nth-child(2) .stat-value { color: #6E0F11; }
:root[data-theme="cardinal"] .cards .stat-card:nth-child(3) .stat-value { color: #2E2A25; }
:root[data-theme="cardinal"] .cards .stat-card:nth-child(4) .stat-value { color: #8C1515; }
:root[data-theme="cardinal"] .cards .stat-card:nth-child(5) .stat-value { color: #6E0F11; }
:root[data-theme="cardinal"] .cards .stat-card:nth-child(6) .stat-value { color: #2E2A25; }

.crest {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: #8C1515;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.crest::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #FFD200;
  border: 1.4px solid #fff;
  transform: rotate(45deg);
}

.leaderboard {
  background: var(--paper);
  border: var(--hair);
  padding: 4px;
  margin-top: 16px;
}
.leaderboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: var(--hair-soft);
}
.tabs {
  display: inline-flex;
  gap: 0;
  border: var(--hair-thin);
}
.tab {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink);
  border-right: var(--hair-thin);
}
.tab:last-child { border-right: 0; }
.tab[aria-pressed="true"] { background: #8C1515; color: #fff; }
.leaderboard-meta {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.leaderboard table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}
.leaderboard thead th {
  text-align: left;
  padding: 14px 18px;
  background: var(--ink);
  color: #FFD200;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.leaderboard tbody td {
  padding: 14px 18px;
  border-bottom: var(--hair-soft);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.leaderboard tbody tr:last-child td { border-bottom: 0; }
.leaderboard tbody td.rank {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  width: 56px;
}
.leaderboard tbody td.time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.leaderboard tbody td.pace,
.leaderboard tbody td.event,
.leaderboard tbody td.aff,
.leaderboard tbody td.src {
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.leaderboard tbody tr.you td {
  background: #FFF7D1;
}
.leaderboard tbody tr.you td.rank::before {
  content: "★ ";
  color: #8C1515;
}
.leaderboard tbody tr:hover td { background: var(--gray-100); }
.leaderboard tbody tr.you:hover td { background: #FFEFA8; }

.src-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
}
.src-pill.official { background: #8C1515; color: #fff; border-color: #8C1515; }
.src-pill.strava { background: #FFD200; color: #0A0A0A; border-color: #0A0A0A; }
.src-pill.self { background: #fff; color: #0A0A0A; }

.leaderboard-empty {
  padding: 32px 18px;
  text-align: center;
  color: var(--gray-500);
  font-size: 13px;
  font-weight: 500;
}

.submit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.submit-actions .ghost { padding: 10px 16px; }
.you-banner {
  margin: 16px 0 0;
  padding: 14px 18px;
  background: #FFD200;
  border: var(--hair-thin);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.you-banner .clear {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: underline;
  cursor: pointer;
}

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
}
.nav-back:hover { color: #FFD200; }
.auth-status.error { color: #8C1515; }
.auth-status.success { color: #1E6E3B; }
.auth-status.warning { color: #7A5A00; }

.mobile-summary-wrapped {
  display: grid;
  gap: 14px;
  margin: 24px 0 8px;
  max-width: 720px;
}
.mobile-summary-card {
  background: var(--paper);
  border: var(--hair);
  padding: 0;
  display: grid;
  gap: 0;
  overflow: hidden;
}
.mobile-summary-head {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 18px 18px 16px;
  background: var(--pink);
  color: #fff;
  border-bottom: 4px solid var(--yellow);
}
.mobile-summary-title {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.04;
  color: #fff;
}
.mobile-summary-subtitle,
.mobile-summary-affiliation {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}
.mobile-summary-time,
.mobile-summary-rank {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--yellow);
  font-variant-numeric: tabular-nums lining-nums;
}
.mobile-summary-list {
  margin: 0;
  padding: 14px;
  list-style: none;
  display: grid;
  gap: 8px;
}
.mobile-summary-item {
  margin: 0;
  padding: 12px 14px 12px 18px;
  border: var(--hair-thin);
  background: #fff;
  display: grid;
  gap: 4px;
  position: relative;
}
.mobile-summary-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--pink);
}
.mobile-summary-list .mobile-summary-item:nth-child(2)::before { background: var(--yellow); }
.mobile-summary-list .mobile-summary-item:nth-child(3)::before { background: var(--pink-2); }
.mobile-summary-list .mobile-summary-item:nth-child(4)::before { background: var(--ink); }
.mobile-summary-list .mobile-summary-item:nth-child(5)::before { background: var(--pink); }
.mobile-summary-list .mobile-summary-item:nth-child(6)::before { background: var(--yellow); }
.mobile-summary-item-kicker {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.mobile-summary-item-value {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--pink);
  font-variant-numeric: tabular-nums lining-nums;
}
.mobile-summary-list .mobile-summary-item:nth-child(2) .mobile-summary-item-value { color: var(--pink-2); }
.mobile-summary-list .mobile-summary-item:nth-child(3) .mobile-summary-item-value { color: var(--ink); }
.mobile-summary-list .mobile-summary-item:nth-child(4) .mobile-summary-item-value { color: var(--pink); }
.mobile-summary-list .mobile-summary-item:nth-child(5) .mobile-summary-item-value { color: var(--pink-2); }
.mobile-summary-list .mobile-summary-item:nth-child(6) .mobile-summary-item-value { color: var(--ink); }
.mobile-summary-item-copy {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.4;
}
.mobile-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 14px 14px;
}
.mobile-summary-actions .ghost {
  flex: 1 1 180px;
  min-height: 44px;
  text-align: center;
  border-color: var(--pink);
  color: var(--pink);
}
.mobile-summary-actions .ghost:hover {
  background: var(--pink);
  color: var(--yellow);
  border-color: var(--pink);
}

@media (max-width: 640px) {
  :root { --grid: 14px; }
  body { font-size: 13px; }
  .lede {
    font-size: 14px;
    line-height: 1.32;
  }
  .hero .lede {
    margin-top: -6px;
  }
  .paper {
    padding-left: calc(var(--grid) + env(safe-area-inset-left));
    padding-right: calc(var(--grid) + env(safe-area-inset-right));
  }
  .masthead-inner {
    grid-template-columns: 1fr;
    gap: 6px;
    text-align: center;
    padding: 9px 18px;
  }
  .dateline.align-right { text-align: center; }
  .masthead-mark { font-size: 20px; }
  .hero { padding: 48px 0 22px; }
  .hero-text { gap: 14px; }
  .form-bay { padding: 24px 18px 28px; }
  .fields { grid-template-columns: 1fr; gap: 20px; }
  .field.span-2 { grid-column: span 1; }
  .strava-grid { grid-template-columns: 1fr; }
  .results-head {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .scorecard-medal {
    width: clamp(88px, 30vw, 120px);
    justify-self: center;
    order: -1;
  }
  .display.medium { font-size: clamp(24px, 8vw, 32px); }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .stat-card { min-height: 0; padding: 24px 20px 28px; }
  .stat-kicker { margin-bottom: 16px; }
  .stat-value { font-size: 56px; }
  .stat-copy { margin-top: 16px; }
  .stat-card:hover { transform: none; box-shadow: none; }
  .section-heading { font-size: 22px; }
  .primary { padding: 18px 22px; font-size: 16px; }
  .nearest {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nearest table { min-width: 520px; }
  .nearest thead th, .nearest tbody td { padding: 12px 14px; }
  .nearest table { font-size: 13px; }
  .inline { flex-direction: column; }
  .inline input { border-right: var(--hair-thin); }
  .ghost { padding: 12px 22px; }
  .mobile-summary-wrapped {
    gap: 10px;
    margin: 6px 0 4px;
    max-width: none;
  }
  .mobile-summary-title {
    font-size: 22px;
  }
  .mobile-summary-item-value {
    font-size: 20px;
  }
  .mobile-summary-actions .ghost {
    flex-basis: 100%;
  }
}
