/* Puff Regatta: sunlit lagoon, retro regatta poster type, glass over live water. */

:root {
  --ink: #062a3a;
  --ink2: #0a3a50;
  --glass: rgba(5, 32, 46, 0.6);
  --glass2: rgba(8, 44, 62, 0.76);
  --line: rgba(255, 246, 229, 0.15);
  --line2: rgba(255, 246, 229, 0.28);
  --text: #f6fbff;
  --muted: #b3d3dc;
  --dim: #7aa3b1;
  --cream: #fff6e5;
  --coral: #ff5d73;
  --sun: #ffd23f;
  --foam: #4ee6c1;
  --sky: #5ec8ff;
  --orange: #ff9f43;
  --red: #ff4d5e;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ui: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #0a4a78; color: var(--text); }
body {
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
input, button { font: inherit; color: inherit; }
input { -webkit-user-select: text; user-select: text; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
b { font-weight: 700; }
a { color: var(--sun); }

/* ── the lagoon behind everything ───────────────────── */
.layer { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#water { z-index: 0; }
#scene { z-index: 1; touch-action: none; }
.shade {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 26, 38, 0.72) 0%, rgba(4, 26, 38, 0.18) 34%, rgba(4, 26, 38, 0.1) 52%, rgba(4, 26, 38, 0.78) 100%);
  opacity: 1; transition: opacity 0.6s ease;
}
body.racing .shade { opacity: 0; }
body.racing.sheet-up .shade { opacity: 0.7; }
body.endscreen .shade { background: linear-gradient(180deg, rgba(4, 26, 38, 0.8), rgba(4, 26, 38, 0.55) 40%, rgba(4, 26, 38, 0.85)); }

/* ── shared controls ─────────────────────────────── */
.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px -28px rgba(0, 10, 20, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 700; font-size: 17px; line-height: 1; letter-spacing: 0.01em;
  padding: 15px 20px; border-radius: 16px;
  border: 1px solid var(--line2); background: rgba(255, 246, 229, 0.06); color: var(--text);
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease, background 0.2s;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: default; transform: none; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary {
  border: 0; color: #2b0c12;
  background: linear-gradient(100deg, #ff5d73, #ff9f43 52%, #ffd23f);
  box-shadow: 0 16px 34px -14px rgba(255, 93, 115, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -2px 0 rgba(120, 30, 0, 0.18);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06) saturate(1.05); }
.btn.big { width: 100%; font-size: 19px; padding: 18px 22px; border-radius: 18px; }
.btn.ghost { background: transparent; }
.btn.soft { background: rgba(94, 200, 255, 0.12); border-color: rgba(94, 200, 255, 0.35); color: #dff4ff; }
.btn.soft:hover { background: rgba(94, 200, 255, 0.2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600;
  padding: 9px 13px; border-radius: 999px; border: 1px solid var(--line2);
  background: rgba(5, 32, 46, 0.55); color: var(--text);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.chip.ghost { background: transparent; }
.chip:active { transform: scale(0.97); }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--sun); }

.hub-link {
  position: fixed; z-index: 40; top: calc(12px + var(--sat)); left: calc(12px + var(--sal));
  display: inline-flex; gap: 6px; align-items: center;
  font: 600 13px var(--ui); color: var(--text); text-decoration: none;
  padding: 8px 13px; border-radius: 999px;
  background: rgba(4, 26, 38, 0.58); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
body.show-hub .hub-link { opacity: 1; pointer-events: auto; }
.sound-btn {
  position: fixed; z-index: 40; top: calc(10px + var(--sat)); right: calc(12px + var(--sar));
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(4, 26, 38, 0.58); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
body.show-hub .sound-btn { opacity: 1; pointer-events: auto; }
.sound-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--cream); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn svg path:first-child { fill: var(--cream); }
.sound-btn .off { display: none; }
body.muted .sound-btn .on { display: none; }
body.muted .sound-btn .off { display: inline; }

/* ── logo ────────────────────────────────────────── */
.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.78; text-align: center; }
.logo .l1 {
  font-family: var(--display); font-style: italic; font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
  font-size: clamp(88px, 31vw, 156px); letter-spacing: -0.035em;
  padding: 0 0.12em 0.04em;
  background: linear-gradient(176deg, #fff9ee 22%, #ffe9a8 44%, #ffd23f 58%, #ff9f43 76%, #ff5d73 96%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 10px 22px rgba(2, 20, 30, 0.45));
  animation: puff 4.8s ease-in-out infinite;
  transform-origin: 40% 70%;
}
@keyframes puff { 0%, 100% { transform: scale(1); } 46% { transform: scale(1.035, 1.05); } 56% { transform: scale(0.99, 0.985); } }
.logo .l2 {
  font-family: var(--ui); font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5em; padding-left: 0.5em; font-size: clamp(15px, 4.8vw, 21px);
  color: var(--cream); margin-top: 10px; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.bunting { width: min(300px, 78vw); height: auto; display: block; margin: 0 auto -4px; overflow: visible; }
.bunting .flag { transform: translate(var(--x), var(--y)); transform-box: view-box; }
.bunting .flag > * { transform-origin: 0 0; animation: flap 3.2s ease-in-out infinite; }
.bunting .f2 > * { animation-delay: -0.8s; }
.bunting .f3 > * { animation-delay: -1.6s; }
.bunting .f4 > * { animation-delay: -2.4s; }
@keyframes flap { 0%, 100% { transform: skewY(0deg) scaleX(1); } 50% { transform: skewY(5deg) scaleX(0.94); } }

/* ── screens ─────────────────────────────────────── */
.app { position: fixed; inset: 0; z-index: 3; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen.on { animation: in 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes in { from { opacity: 0; transform: translateY(10px); } }
.scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px max(16px, var(--sal)) 24px max(16px, var(--sar));
}
.scroll > * { max-width: 520px; margin-left: auto; margin-right: auto; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(12px + var(--sat)) max(14px, var(--sar)) 10px max(14px, var(--sal));
}
body.show-hub .bar { padding-top: calc(56px + var(--sat)); }
.bar-title { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 24px; font-variation-settings: "SOFT" 100, "opsz" 48; }
.bar-gap { width: 76px; }
.bar-acts { display: flex; gap: 8px; }
.foot { padding: 12px max(16px, var(--sar)) calc(14px + var(--sab)) max(16px, var(--sal)); display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.foot > * { max-width: 520px; width: 100%; margin: 0 auto; }
.foot-row { display: flex; gap: 10px; }
.foot-row .btn { flex: 1; }
.wait { text-align: center; color: var(--muted); font-size: 15px; min-height: 1.3em; }
.list-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; text-shadow: 0 1px 8px rgba(0, 20, 30, 0.8); font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 20px 2px 10px; }
.list-h span { letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--dim); font-size: 13px; }

/* ── home ────────────────────────────────────────── */
.home { justify-content: center; }
.home-in {
  width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: calc(56px + var(--sat)) max(18px, var(--sar)) calc(18px + var(--sab)) max(18px, var(--sal));
  max-height: 100%; overflow-y: auto;
}
.pitch { text-align: center; color: #e4f4f8; font-size: 16.5px; line-height: 1.45; max-width: 34ch; text-shadow: 0 1px 12px rgba(0, 20, 30, 0.6); }
.pitch b { color: var(--sun); }
.home-form { width: 100%; padding: 16px; display: flex; flex-direction: column; gap: 11px; margin-top: 6px; }
.home-form input {
  width: 100%; padding: 15px 16px; border-radius: 15px; border: 1px solid var(--line2);
  background: rgba(2, 18, 28, 0.45); font-size: 17px; font-weight: 600; outline: none;
}
.home-form input:focus { border-color: var(--sun); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.2); }
.join-row { display: flex; gap: 10px; }
.join-row .code-in { flex: 1; text-transform: uppercase; letter-spacing: 0.35em; font-family: var(--mono); text-align: center; }
.join-row .btn { padding: 0 22px; }
.home-form.has-code #btn-create { background: transparent; border: 1px solid var(--line2); color: var(--text); box-shadow: none; }
.home-form.has-code #btn-join { border: 0; color: #2b0c12; background: linear-gradient(100deg, #ff5d73, #ff9f43 52%, #ffd23f); }
.tv-tip { color: var(--muted); font-size: 13.5px; text-align: center; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5); }

/* ── controls card ───────────────────────────────── */
.ctl-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.ctl-card h3 { font-family: var(--display); font-style: italic; font-weight: 800; font-size: 22px; font-variation-settings: "SOFT" 100, "opsz" 36; }
.ctl-card p { color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.ctl-card .alt { align-self: center; font-size: 13.5px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.tests { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.test {
  position: relative; padding: 12px; border-radius: 16px; background: rgba(2, 18, 28, 0.42); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-height: 132px;
}
.test.done { border-color: rgba(78, 230, 193, 0.55); box-shadow: inset 0 0 0 1px rgba(78, 230, 193, 0.2); }
.test .t-lbl { font-size: 13px; font-weight: 700; color: var(--cream); }
.test .t-sub { font-size: 12px; color: var(--muted); line-height: 1.3; }
.test .tick { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--foam); color: var(--ink); display: none; place-items: center; font-size: 12px; font-weight: 900; }
.test.done .tick { display: grid; }
.lung-ico { width: 64px; height: 56px; }
.lung-meter { width: 100%; height: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.lung-meter i { display: block; height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--foam), var(--sun), var(--coral)); transition: width 0.06s linear; }
.rudder-ico { width: 64px; height: 56px; }
.steer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(2, 18, 28, 0.5); border: 1px solid var(--line); }
.seg button { padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--cream); color: var(--ink); }
.ctl-ok { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.ctl-ok .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--foam); box-shadow: 0 0 10px var(--foam); flex: none; }
.ctl-ok.warn .dot { background: var(--orange); box-shadow: 0 0 10px var(--orange); }

/* ── lobby ───────────────────────────────────────── */
.room-id { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.room-id .lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.room-id .code { font-family: var(--mono); font-weight: 700; font-size: 26px; letter-spacing: 0.18em; padding-left: 0.18em; color: var(--sun); margin-top: 4px; }
.qr-box { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }
.qr-box p { color: var(--muted); font-size: 14px; }
.qr { width: 200px; max-width: 70vw; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #fff; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.settings { padding: 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.set-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.set-note { letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--dim); }
.course-strip { list-style: none; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; margin: 0 -4px; scrollbar-width: none; }
.course-strip::-webkit-scrollbar { display: none; }
.course-strip li { flex: none; width: 128px; scroll-snap-align: start; }
.course-strip button {
  width: 100%; text-align: left; border-radius: 14px; padding: 6px; border: 1px solid var(--line);
  background: rgba(2, 18, 28, 0.42); display: flex; flex-direction: column; gap: 6px; transition: border-color 0.2s, transform 0.15s;
}
.course-strip button[aria-pressed="true"] { border-color: var(--sun); box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.35), 0 10px 24px -12px rgba(255, 210, 63, 0.6); }
.course-strip button:disabled { cursor: default; opacity: 0.55; }
.course-strip button:disabled[aria-pressed="true"] { opacity: 1; }
.course-strip .thumb { width: 100%; height: 76px; border-radius: 10px; overflow: hidden; background: #0a4a78; }
.course-strip .thumb canvas, .courses .thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-strip .nm { font-weight: 700; font-size: 13.5px; padding: 0 2px; line-height: 1.15; }
.course-strip .meta { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 2px; font-size: 11.5px; color: var(--muted); }
.lvl { display: inline-flex; gap: 3px; }
.lvl i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); }
.lvl i.on { background: var(--sun); }
.races-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.players { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: in 0.3s ease;
}
.players li.me { border-color: rgba(255, 210, 63, 0.4); }
.players li.off { opacity: 0.5; }
.av { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--pc) 22%, rgba(2, 18, 28, 0.6)); border: 1px solid color-mix(in srgb, var(--pc) 50%, transparent); }
.pname { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; display: flex; flex-direction: column; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pname small { font-weight: 500; font-size: 12.5px; color: var(--muted); }
.crown { color: var(--sun); margin-left: 6px; font-size: 13px; }
.ptag { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.ptag.ok { background: rgba(78, 230, 193, 0.16); color: var(--foam); }
.ptag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── solo ────────────────────────────────────────── */
.courses { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.courses button {
  width: 100%; display: grid; grid-template-columns: 104px 1fr; gap: 12px; text-align: left; padding: 8px;
  border-radius: 18px; background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: transform 0.15s, border-color 0.2s;
}
.courses button:active { transform: scale(0.985); }
.courses button:hover { border-color: var(--line2); }
.courses .thumb { width: 104px; height: 92px; border-radius: 12px; overflow: hidden; background: #0a4a78; }
.courses .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 2px 4px 2px 0; }
.courses .nm { font-family: var(--display); font-style: italic; font-weight: 800; font-size: 19px; font-variation-settings: "SOFT" 100, "opsz" 30; line-height: 1.05; }
.courses .sub { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.courses .bl { font-size: 13px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.courses .best { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--cream); margin-top: auto; }
.courses .best .none { font-family: var(--ui); font-weight: 600; color: var(--dim); }
.courses .best .tgt { font-family: var(--ui); font-weight: 600; color: var(--dim); font-size: 12px; }
.medal { flex: none; }

/* ── race HUD ────────────────────────────────────── */
.race { pointer-events: none; }
.race .hud, .race .overlay, .race .sheet, .race .touch-ctl { pointer-events: auto; }
.hud { position: absolute; inset: 0; pointer-events: none !important; display: flex; flex-direction: column; }
.hud-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px;
  padding: calc(10px + var(--sat)) max(12px, var(--sar)) 0 max(12px, var(--sal));
}
.hud-place {
  justify-self: start; display: flex; align-items: baseline; padding: 4px 14px 6px 12px; border-radius: 18px;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-family: var(--display); font-style: italic; font-variation-settings: "SOFT" 100, "opsz" 72;
}
.hud-place b { font-size: 40px; font-weight: 900; line-height: 1; }
.hud-place sup { font-size: 17px; font-weight: 800; margin-left: 1px; }
.hud-place span { font-family: var(--ui); font-style: normal; font-size: 15px; color: var(--muted); margin-left: 6px; font-weight: 600; }
.hud-place.first b { color: var(--sun); }
.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hud-time {
  font-family: var(--mono); font-weight: 700; font-size: 20px; padding: 8px 12px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.hud-split { font-family: var(--mono); font-weight: 700; font-size: 15px; padding: 4px 10px; border-radius: 10px; background: rgba(4, 26, 38, 0.7); animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.hud-split.ahead { color: var(--foam); }
.hud-split.behind { color: var(--coral); }
.minimap {
  justify-self: end; width: 96px; height: 96px; border-radius: 18px;
  background: rgba(4, 26, 38, 0.5); border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.hud-sub { display: flex; justify-content: center; gap: 8px; margin-top: 8px; padding: 0 12px; }
.chip-s {
  font-size: 13px; font-weight: 700; padding: 6px 11px; border-radius: 999px; letter-spacing: 0.02em;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.chip-s.warn { color: var(--sun); border-color: rgba(255, 210, 63, 0.4); }
.hud-status { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; padding-bottom: 10px; }
.stat-pill {
  font-size: 14px; font-weight: 800; letter-spacing: 0.04em; padding: 7px 13px; border-radius: 999px;
  background: rgba(4, 26, 38, 0.62); border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.stat-pill.tail { color: var(--foam); border-color: rgba(78, 230, 193, 0.5); }
.stat-pill.head { color: var(--coral); border-color: rgba(255, 93, 115, 0.5); }
.stat-pill.draft { color: var(--sky); border-color: rgba(94, 200, 255, 0.5); }
.stat-pill.cur { color: #c9b8ff; border-color: rgba(179, 139, 255, 0.5); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.hud-bottom { padding: 0 max(14px, var(--sar)) calc(14px + var(--sab)) max(14px, var(--sal)); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gauge {
  width: min(100%, 360px); display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.g-sail { width: 38px; height: 38px; flex: none; }
.g-bar { position: relative; flex: 1; height: 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.g-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 14px; width: 0; }
#g-fill { background: linear-gradient(90deg, #4ee6c1, #ffd23f 60%, #ff9f43 85%, #ff5d73); box-shadow: 0 0 14px rgba(255, 210, 63, 0.5); }
.g-in { background: rgba(255, 255, 255, 0.85); width: 3px !important; border-radius: 3px; transform: translateX(-1.5px); }
.g-lbl { font-weight: 800; font-size: 14px; min-width: 66px; text-align: right; letter-spacing: 0.02em; color: var(--cream); }
.gauge.full .g-lbl { color: var(--sun); }
.gauge.idle .g-lbl { animation: nudge 1.2s ease-in-out infinite; color: var(--coral); }
@keyframes nudge { 50% { transform: scale(1.12); } }
.touch-ctl { width: min(100%, 420px); display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 10px; }
.tc {
  height: 74px; border-radius: 22px; display: grid; place-items: center; touch-action: none;
  background: rgba(4, 26, 38, 0.5); border: 1px solid var(--line2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--cream); transition: transform 0.08s, background 0.15s;
}
.tc svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tc.on, .tc:active { background: rgba(255, 246, 229, 0.25); transform: scale(0.96); }
.tc.puff { background: linear-gradient(160deg, rgba(255, 93, 115, 0.55), rgba(255, 159, 67, 0.55)); border-color: rgba(255, 210, 63, 0.6); display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.tc.puff span { font-weight: 900; font-size: 20px; letter-spacing: 0.06em; }
.tc.puff small { font-size: 11px; opacity: 0.8; }

.race.finished .hud-top, .race.finished .hud-sub, .race.finished .hud-bottom, .race.finished .hud-status,
.race.done .hud-sub, .race.done .hud-bottom, .race.done .hud-status { opacity: 0; transition: opacity 0.4s; }
body.sheet-up .race .hud-top, body.sheet-up .race .hud-sub { opacity: 0; transition: opacity 0.4s; }

/* overlays on the race screen */
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px max(20px, var(--sar)) calc(24px + var(--sab)) max(20px, var(--sal));
}
.count { pointer-events: none !important; }
.count .kicker { text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5); }
.cd-course { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 96; font-size: clamp(40px, 12vw, 64px); line-height: 1; margin-top: 8px; text-shadow: 0 6px 30px rgba(0, 20, 30, 0.6); }
.cd-blurb { max-width: 30ch; color: #e8f6fa; font-size: 15.5px; line-height: 1.4; margin-top: 10px; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); }
.cd-num { font-family: var(--display); font-weight: 900; font-style: italic; font-variation-settings: "SOFT" 100, "opsz" 144; font-size: clamp(110px, 38vw, 190px); line-height: 1; margin-top: 10px; min-height: 1em; color: var(--cream); text-shadow: 0 10px 40px rgba(0, 20, 30, 0.6); }
.cd-num.tick { animation: tick 0.9s cubic-bezier(0.2, 1.2, 0.3, 1); }
.cd-num.go { color: var(--sun); font-size: clamp(80px, 26vw, 140px); animation: go 1s cubic-bezier(0.2, 1.3, 0.3, 1) forwards; }
@keyframes tick { from { transform: scale(1.7); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }
@keyframes go { from { transform: scale(0.4); opacity: 0; } 25% { opacity: 1; transform: scale(1.15); } 60% { transform: scale(1); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.cd-hint { margin-top: 14px; font-weight: 700; color: var(--cream); padding: 8px 14px; border-radius: 999px; background: rgba(4, 26, 38, 0.55); }
.finish { pointer-events: none !important; justify-content: flex-start; padding-top: calc(140px + var(--sat)); }
.finish > * { pointer-events: auto; }
.fin-big { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 144; font-size: clamp(76px, 26vw, 130px); line-height: 0.95; color: var(--sun); text-shadow: 0 10px 40px rgba(0, 20, 30, 0.6); animation: tick 0.7s cubic-bezier(0.2, 1.2, 0.3, 1); }
.fin-time { font-family: var(--mono); font-weight: 700; font-size: 26px; margin-top: 6px; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
.fin-time:empty { display: none; }
.fin-note { color: #e8f6fa; font-size: 15.5px; margin-top: 8px; max-width: 32ch; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fin-note .medal-line { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; padding: 6px 14px; border-radius: 999px; background: rgba(4, 26, 38, 0.6); }
.fin-acts { display: flex; flex-direction: column; gap: 10px; width: min(100%, 360px); margin-top: 18px; }
.fin-acts .row { display: flex; gap: 10px; }
.fin-acts .row .btn { flex: 1; }
.fin-tip { margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--cream); padding: 7px 13px; border-radius: 999px; background: rgba(4, 26, 38, 0.6); }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 0 max(10px, var(--sar)) calc(10px + var(--sab)) max(10px, var(--sal)); animation: up 0.45s cubic-bezier(0.2, 0.9, 0.2, 1); }
@keyframes up { from { transform: translateY(100%); } }
.sheet-in {
  width: 100%; max-width: 520px; max-height: 82dvh; overflow-y: auto; padding: 18px 16px 16px;
  border-radius: 26px; background: var(--glass2); border: 1px solid var(--line2);
  -webkit-backdrop-filter: blur(20px) saturate(1.3); backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 -10px 60px -20px rgba(0, 0, 0, 0.6);
}
.sh-title { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 72; font-size: 30px; margin: 4px 0 12px; }
.res-rows, .series-rows, .standings { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.res-rows li, .series-rows li, .standings li {
  display: grid; grid-template-columns: 30px 34px 1fr auto auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 14px; background: rgba(2, 18, 28, 0.42); border: 1px solid var(--line);
  animation: in 0.35s ease backwards;
}
.res-rows li.me, .series-rows li.me, .standings li.me { border-color: rgba(255, 210, 63, 0.45); background: rgba(255, 210, 63, 0.08); }
.pos { font-family: var(--display); font-style: italic; font-weight: 900; font-size: 22px; text-align: center; font-variation-settings: "SOFT" 100; }
li:first-child .pos { color: var(--sun); }
.tm { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--cream); }
.tm.dnf { color: var(--coral); font-family: var(--ui); }
.pts { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--muted); min-width: 44px; text-align: right; }
.places { font-family: var(--mono); font-size: 12px; color: var(--dim); letter-spacing: 0.08em; }
.series { margin-top: 4px; }
.sh-next { text-align: center; color: var(--muted); font-size: 14.5px; margin-top: 14px; font-weight: 600; }

/* ── regatta over ────────────────────────────────── */
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.over-in { padding-top: calc(60px + var(--sat)); text-align: center; }
.ov-title { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 144; font-size: clamp(46px, 15vw, 78px); line-height: 1; margin: 8px 0 8px; background: linear-gradient(180deg, #fff9ee 30%, #ffd23f 70%, #ff9f43); -webkit-background-clip: text; background-clip: text; color: transparent; animation: tick 0.8s cubic-bezier(0.2, 1.2, 0.3, 1); padding: 0 0.1em; }
.ov-sub { color: var(--muted); font-size: 16px; margin-bottom: 18px; }
.standings { text-align: left; }
.over .standings li, .tv-over .standings li { background: rgba(3, 22, 33, 0.72); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.awards { display: grid; gap: 8px; margin-top: 16px; text-align: left; align-content: start; }
.award { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: rgba(3, 22, 33, 0.72); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: in 0.4s ease backwards; }
.award .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 210, 63, 0.14); font-size: 20px; flex: none; }
.award b { display: block; font-size: 15px; }
.award small { color: var(--muted); font-size: 13px; }

/* ── toast ───────────────────────────────────────── */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%);
  max-width: min(92vw, 440px); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px; text-align: center;
  background: rgba(4, 26, 38, 0.9); border: 1px solid var(--line2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: toast 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes toast { from { transform: translate(-50%, 16px); opacity: 0; } }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; z-index: 99; font-size: 18px; }

/* ── big screen ──────────────────────────────────── */
.tv { position: fixed; inset: 0; z-index: 3; }
.tv-screen { position: absolute; inset: 0; }
.tv-lobby { display: grid; grid-template-columns: 1.1fr 1fr; gap: 4vw; padding: 5vh 5vw; align-items: center; }
.tvlogo .l1 { font-size: clamp(90px, 11vw, 200px); }
.tvlogo .l2 { font-size: clamp(18px, 1.6vw, 30px); }
.tv-left { display: flex; flex-direction: column; align-items: center; gap: 3vh; }
.tv-pitch { font-size: clamp(16px, 1.45vw, 26px); line-height: 1.45; color: #e8f6fa; max-width: 36ch; text-align: center; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5); }
.tv-pitch b { color: var(--sun); }
.join-card { display: flex; align-items: center; gap: 2vw; padding: 1.6vw; }
.join-card .qr { width: clamp(150px, 15vw, 280px); }
.join-text .lbl { color: var(--muted); font-size: clamp(13px, 1vw, 18px); }
.join-text .url { font-family: var(--mono); font-weight: 700; font-size: clamp(16px, 1.5vw, 28px); margin: 4px 0 10px; }
.join-text .code { font-family: var(--mono); font-weight: 700; font-size: clamp(44px, 5vw, 96px); letter-spacing: 0.16em; color: var(--sun); line-height: 1; }
.tv-lobby > * { min-width: 0; }
.tv-right { display: flex; flex-direction: column; gap: 2vh; max-height: 90vh; min-width: 0; }
.tv-right .settings { min-width: 0; }
.tv-h { font-family: var(--display); font-style: italic; font-weight: 900; font-size: clamp(26px, 2.4vw, 44px); font-variation-settings: "SOFT" 100; }
.tv-h span { color: var(--sun); }
.tv-players { list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tv-players li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-size: clamp(15px, 1.2vw, 22px); animation: in 0.35s ease; }
.tv-players li.off { opacity: 0.45; }
.tv-empty { color: var(--muted); font-size: clamp(15px, 1.2vw, 22px); }
.tv-actions { display: flex; gap: 12px; align-items: center; }
.tv-actions .btn.big { width: auto; flex: 1; }
.tv-join { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.tv-join input { width: 96px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(2, 18, 28, 0.45); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.2em; outline: none; }
.tv-stage { pointer-events: none; }
.tv-stage > * { pointer-events: auto; }
.tv-top { position: absolute; top: 2vh; left: 2vw; right: calc(2vw + 50px); display: flex; gap: 14px; align-items: center; }
.tv-top > span { padding: 10px 16px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-size: clamp(14px, 1.2vw, 22px); font-weight: 700; }
.tv-course { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100; }
.tv-clock { font-family: var(--mono); margin-left: auto; font-variant-numeric: tabular-nums; }
.tv-codechip b { color: var(--sun); font-family: var(--mono); letter-spacing: 0.1em; }
.tv-board { position: absolute; right: 2vw; top: 10vh; width: clamp(220px, 20vw, 360px); list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tv-board li {
  display: grid; grid-template-columns: 30px 30px 1fr; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: clamp(14px, 1.1vw, 20px); transition: transform 0.3s;
}
.tv-board .tm { font-size: clamp(11px, 0.9vw, 16px); color: var(--muted); font-weight: 600; }
.tv-board li.fin .tm { color: var(--sun); font-weight: 700; }
.tv-board .pname { font-size: inherit; }
.tv-board li.fin { border-color: rgba(255, 210, 63, 0.45); }
.tv-count { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none !important; }
.tv-count h2 { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 144; font-size: clamp(56px, 7vw, 130px); line-height: 1; text-shadow: 0 8px 40px rgba(0, 20, 30, 0.7); }
.tv-cd-blurb { font-size: clamp(16px, 1.5vw, 28px); color: #e8f6fa; margin-top: 10px; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7); }
.tv-cd-num { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 144; font-size: clamp(130px, 18vw, 320px); line-height: 1; color: var(--cream); text-shadow: 0 10px 50px rgba(0, 20, 30, 0.7); min-height: 1em; }
.tv-cd-num.tick { animation: tick 0.9s cubic-bezier(0.2, 1.2, 0.3, 1); }
.tv-cd-num.go { color: var(--sun); animation: go 1s cubic-bezier(0.2, 1.3, 0.3, 1) forwards; }
.tv-closing { position: absolute; left: 50%; bottom: 4vh; transform: translateX(-50%); padding: 12px 22px; border-radius: 999px; background: rgba(4, 26, 38, 0.75); border: 1px solid rgba(255, 210, 63, 0.5); color: var(--sun); font-weight: 800; font-size: clamp(16px, 1.4vw, 26px); }
.tv-results { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 1100px); display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; padding: 2.4vw; animation: in 0.4s ease; }
.tv-results h2 { font-family: var(--display); font-style: italic; font-weight: 900; font-size: clamp(30px, 3vw, 54px); font-variation-settings: "SOFT" 100; margin: 6px 0 14px; }
.tv-results li { font-size: clamp(14px, 1.15vw, 21px); }
.tv-over { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; padding: 4vh 5vw; background: radial-gradient(60% 60% at 50% 40%, rgba(4, 26, 38, 0.3), rgba(4, 26, 38, 0.75)); }
.tv-winner { font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "SOFT" 100, "opsz" 144; font-size: clamp(60px, 8vw, 150px); line-height: 1; background: linear-gradient(180deg, #fff9ee 30%, #ffd23f 70%, #ff9f43); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 0 0.1em; }
.tv-over-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 3vw; width: min(92vw, 1100px); }
.tv-over-cols li, .tv-over-cols .award { font-size: clamp(14px, 1.15vw, 21px); }
body.is-tv .sound-btn { opacity: 1; pointer-events: auto; }

/* ── small and landscape phones ──────────────────── */
@media (max-height: 640px) {
  .home-in { gap: 10px; padding-top: calc(48px + var(--sat)); }
  .bunting { width: 220px; }
  .logo .l1 { font-size: clamp(70px, 22vw, 110px); }
  .pitch { font-size: 15px; }
  .home-form { padding: 12px; gap: 9px; }
  .btn.big { padding: 15px 20px; }
  .tc { height: 62px; }
  .finish { padding-top: calc(96px + var(--sat)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .hud-top { grid-template-columns: auto 1fr auto; }
  .minimap { width: 80px; height: 80px; }
  .hud-place b { font-size: 32px; }
  .hud-bottom { flex-direction: row; justify-content: center; align-items: flex-end; }
  .gauge { width: min(46vw, 340px); }
  .touch-ctl { width: min(50vw, 400px); }
  .tc { height: 58px; }
  .finish { padding-top: calc(70px + var(--sat)); }
  .fin-big { font-size: 72px; }
}
@media (max-width: 760px) {
  .tv-lobby { grid-template-columns: 1fr; overflow-y: auto; }
  .tv-results, .tv-over-cols { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .logo .l1, .bunting .flag > *, .gauge.idle .g-lbl { animation: none; }
}
