:root {
  --night: #0a1430;
  --night-2: #0f1d42;
  --night-3: #16285a;
  --line: #2a3c72;
  --text: #eef2fa;
  --muted: #a9b6d3;
  --red: #d7263d;
  --yellow: #ffd23f;
  --blue: #2a6fdb;
  --white: #f4f6fb;
  --lantern: #3bd18a;
  --display: Copperplate, "Copperplate Gothic Bold", "Copperplate Gothic Light", "Engravers MT", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font: 400 1.0625rem/1.65 var(--body);
  background:
    radial-gradient(1.5px 1.5px at 10% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 6%, #dfe7ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 8%, #dfe7ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 24%, #dfe7ff 50%, transparent 51%),
    linear-gradient(180deg, #060c1f 0, var(--night) 600px);
  background-color: var(--night);
}
[hidden] { display: none !important; }
a { color: var(--yellow); text-underline-offset: 0.2em; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; line-height: 1.1; letter-spacing: 0.04em; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.skip { position: absolute; left: var(--gutter); top: -80px; z-index: 20; background: var(--yellow); color: var(--night); padding: 0.6rem 1rem; }
.skip:focus { top: 16px; }

/* Bunting */
.bunting { display: flex; justify-content: space-between; padding: 0 2%; height: 30px; background: linear-gradient(180deg, transparent 3px, #8b97b5 3px 4px, transparent 4px); overflow: hidden; }
.bunting span { width: 22px; height: 26px; margin-top: 4px; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.bunting span:nth-child(4n+1) { background: var(--red); }
.bunting span:nth-child(4n+2) { background: var(--yellow); }
.bunting span:nth-child(4n+3) { background: var(--blue); }
.bunting span:nth-child(4n+4) { background: var(--white); }

.site-header { max-width: 1180px; margin: 0 auto; padding: 14px var(--gutter); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.3rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand svg { width: 30px; height: 30px; }
.site-header ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin: 0; padding: 0; list-style: none; }
.site-header nav a { color: var(--text); text-decoration: none; font-family: var(--display); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.9rem; }
.site-header nav a:hover { color: var(--yellow); }

/* Hero */
.hero { position: relative; max-width: 1180px; margin: 0 auto; padding: clamp(36px, 7vw, 96px) var(--gutter) 0; text-align: center; }
.race-no { font-family: var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--yellow); font-size: 0.9rem; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 5rem); margin: 0.9rem auto 1.1rem; max-width: 16ch; text-transform: uppercase; }
.lede { max-width: 60ch; margin: 0 auto 1.75rem; color: var(--muted); font-size: 1.15rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0.7rem 1.3rem;
  background: var(--yellow); color: var(--night); border: 2px solid var(--yellow);
  font: 700 0.95rem/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--white); border-color: var(--white); color: var(--night); }
.btn-line { background: transparent; color: var(--text); border-color: var(--muted); }
.btn-line:hover { background: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-text { background: none; border: 0; color: var(--muted); font: 600 0.95rem var(--body); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; padding: 0.5rem; }
.btn-text:hover { color: var(--text); }

.sea { position: relative; height: 120px; margin-top: 3rem; background: repeating-linear-gradient(180deg, transparent 0 14px, rgba(42, 111, 219, 0.18) 14px 15px); border-top: 1px solid var(--line); }
.lantern { position: absolute; width: 10px; height: 10px; border-radius: 50%; animation: glow 3s ease-in-out infinite; }
.l1 { left: 18%; top: 30%; background: var(--lantern); box-shadow: 0 0 14px 4px rgba(59, 209, 138, 0.6); }
.l2 { left: 52%; top: 55%; background: var(--red); box-shadow: 0 0 14px 4px rgba(215, 38, 61, 0.6); animation-delay: -1s; }
.l3 { left: 80%; top: 25%; background: var(--lantern); box-shadow: 0 0 14px 4px rgba(59, 209, 138, 0.6); animation-delay: -2s; }
@keyframes glow { 50% { opacity: 0.45; transform: translateY(4px); } }

/* Rules */
.rules, .race-section, .leftout { max-width: 1180px; margin: 0 auto; padding: clamp(48px, 7vw, 88px) var(--gutter); }
.rules h2, .section-head h2, .leftout h2 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin-bottom: 1.5rem; text-transform: uppercase; }
.flag-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 1rem; }
.flag-list li { background: var(--night-2); border: 1px solid var(--line); padding: 1.2rem; }
.flag { display: block; width: 46px; height: 32px; margin-bottom: 0.8rem; border: 1px solid rgba(255, 255, 255, 0.4); }
.f-red { background: var(--red); clip-path: polygon(0 0, 100% 0, 70% 50%, 100% 100%, 0 100%); }
.f-yellow { background: var(--yellow); }
.f-blue { background: linear-gradient(var(--white), var(--white)) center / 40% 40% no-repeat, var(--blue); }
.f-white { background: linear-gradient(var(--red), var(--red)) center / 34% 34% no-repeat, linear-gradient(var(--white), var(--white)) center / 66% 66% no-repeat, var(--blue); }
.f-check { background: conic-gradient(var(--white) 25%, var(--night) 0 50%, var(--white) 0 75%, var(--night) 0) 0 0 / 50% 50%; }
.flag-list h3 { font-size: 1.1rem; text-transform: uppercase; margin-bottom: 0.5rem; }
.flag-list p { color: var(--muted); font-size: 0.98rem; }

/* Race */
.section-head p { color: var(--muted); max-width: 66ch; margin-top: -0.6rem; margin-bottom: 1.75rem; }
.race-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.crews { border: 1px solid var(--line); background: var(--night-2); margin: 0; padding: 1rem 1.1rem; min-width: 0; }
.crews legend { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0.4rem; }
.crew { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "sw label out" "range range range"; gap: 0.3rem 0.6rem; align-items: center; padding: 0.7rem 0; border-bottom: 1px dashed var(--line); }
.crew:last-child { border-bottom: 0; }
.swatch { grid-area: sw; width: 20px; height: 14px; border: 1px solid rgba(255, 255, 255, 0.5); }
.s-blue { background: var(--blue); } .s-yellow { background: var(--yellow); } .s-red { background: var(--red); } .s-white { background: var(--white); }
.crew label { grid-area: label; font-family: var(--display); letter-spacing: 0.04em; }
.crew output { grid-area: out; font: 700 1rem var(--body); font-variant-numeric: tabular-nums; color: var(--yellow); }
.crew input { grid-area: range; width: 100%; accent-color: var(--yellow); }

.course { border: 1px solid var(--line); background: var(--night-2); padding: 1rem; }
.lanes { position: relative; display: grid; gap: 6px; padding-right: 26px; }
.lane { position: relative; height: 46px; background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(169, 182, 211, 0.12) 22px 23px), var(--night-3); border-bottom: 1px dashed rgba(169, 182, 211, 0.35); }
.finish { position: absolute; top: 0; bottom: 0; right: 0; width: 22px; background: conic-gradient(var(--white) 25%, var(--night) 0 50%, var(--white) 0 75%, var(--night) 0) 0 0 / 11px 11px; }
.boat { position: absolute; top: 50%; left: 0; width: 48px; height: 26px; margin-top: -13px; transition-property: left; transition-timing-function: linear; }
.boat::before { content: ""; position: absolute; inset: 8px 0 0; background: var(--white); clip-path: polygon(0 0, 100% 0, 82% 100%, 8% 100%); }
.boat i { position: absolute; left: 16px; bottom: 16px; width: 18px; height: 14px; border: 1px solid rgba(0, 0, 0, 0.3); }
.boat::after { content: ""; position: absolute; left: 15px; bottom: 6px; width: 2px; height: 26px; background: var(--white); }
.b-blue i { background: var(--blue); } .b-yellow i { background: var(--yellow); } .b-red i { background: var(--red); } .b-white i { background: var(--white); }
.boat.winner::before { background: var(--lantern); box-shadow: 0 0 16px rgba(59, 209, 138, 0.7); }
.race-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 1rem; }
.race-status { margin-top: 0.8rem; min-height: 3em; color: var(--text); }
.race-status strong { color: var(--lantern); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); }
.season { width: 100%; border-collapse: collapse; min-width: 560px; font-variant-numeric: tabular-nums; }
.season caption { text-align: left; padding: 0.8rem 1rem; font-family: var(--display); text-transform: uppercase; letter-spacing: 0.08em; background: var(--night-2); }
.season th, .season td { padding: 0.65rem 1rem; text-align: left; border-top: 1px solid var(--line); }
.season thead th { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.season tbody th { font-family: var(--display); font-weight: 700; }
.bar-col { width: 34%; }
.bar { position: relative; height: 14px; background: var(--night-3); border: 1px solid var(--line); }
.bar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--lantern); }
.bar em { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--yellow); }

.leftout p { color: var(--muted); max-width: 66ch; margin-bottom: 1rem; }
.leftout ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.75rem; max-width: 820px; }
.leftout li { padding: 0.9rem 1rem; border-left: 4px solid var(--red); background: var(--night-2); color: var(--muted); }
.leftout li:nth-child(2) { border-color: var(--yellow); }
.leftout li:nth-child(3) { border-color: var(--blue); }
.leftout li:nth-child(4) { border-color: var(--white); }
.leftout strong { color: var(--text); }

.site-footer { max-width: 1180px; margin: 0 auto; padding: 1.5rem var(--gutter) 2.5rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; color: var(--muted); font-size: 0.95rem; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
