@font-face {
  font-family: Barlow;
  src: url("/fonts/barlow-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: Barlow;
  src: url("/fonts/barlow-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --sea: #0b3436;
  --deep: #092b30;
  --foam: #c8e4d9;
  --ivory: #fbf4e3;
  --paper: #f2e8d3;
  --line: #c7bda5;
  --ink: #153f3e;
  --muted: #495e50;
  --coral: #ff9c7d;
  --coral-hover: #ffb091;
  --alert: #952e24;
  font: 400 1rem/1.42 Barlow, system-ui, sans-serif;
  color: var(--ink);
  background: var(--sea);
  scrollbar-color: #91b6a8 var(--deep);
}

*, *::after, *::before { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3 { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; line-height: .98; letter-spacing: -.025em; overflow-wrap: anywhere; }
h2 { font-size: 2.5rem; }
h3 { font-size: 1.48rem; }
a { color: inherit; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--alert); outline-offset: 3px; }
.chart :focus-visible, .masthead :focus-visible { outline-color: var(--coral); }
::selection { background: var(--coral); color: var(--deep); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.masthead {
  width: min(100%, 90rem);
  min-height: 3.55rem;
  margin-inline: auto;
  padding: .5rem clamp(1rem, 3.5vw, 3.6rem);
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--ivory);
  border-bottom: 1px solid #346365;
}
.home { margin-right: auto; display: inline-flex; align-items: center; min-height: 2.5rem; gap: .4rem; text-decoration: none; }
.home span { font-size: 1.15rem; line-height: 1; }
.home:hover { text-decoration: underline; }
.connection { color: var(--foam); text-align: right; font-size: .875rem; }
.connection[data-offline] { color: #ffd2bb; }
.mast-button {
  border: 1px solid #7eaaa0;
  border-radius: .4rem;
  background: transparent;
  padding: .4rem .7rem;
  min-height: 2.625rem;
  white-space: nowrap;
}
.mast-button:hover { background: #214b4b; }
.regatta { max-width: 90rem; margin-inline: auto; }
.chart { color: var(--ivory); padding: 1.35rem clamp(1rem, 3.5vw, 3.6rem) 1.1rem; min-width: 0; }
.chart-heading { display: flex; justify-content: space-between; gap: .75rem; align-items: end; margin-bottom: .85rem; }
h1 { font-size: clamp(3.1rem, 9.5vw, 5.75rem); }
.chart-heading p { color: var(--foam); margin-top: .25rem; font-size: 1.04rem; }
.course {
  position: relative;
  min-width: 0;
  border: 1px solid #588982;
  border-radius: .65rem;
  overflow: hidden;
  background: #124341;
}
.regatta-board { display: block; width: 100%; height: clamp(210px, 32dvh, 460px); }
.race-hud, .race-clock, .race-status { pointer-events: none; user-select: none; }
.race-hud {
  position: absolute;
  z-index: 1;
  top: max(.65rem, env(safe-area-inset-top));
  left: max(.65rem, env(safe-area-inset-left));
  display: flex;
  overflow: hidden;
  color: var(--ivory);
  background: #082b2d;
  border-radius: .6rem;
  font-variant-numeric: tabular-nums;
}
.life-meter, .distance-meter {
  min-height: 3.4rem;
  display: grid;
  align-content: center;
  gap: .15rem;
  padding: .42rem .65rem .5rem;
}
.life-meter + .distance-meter { border-left: 1px solid #396565; }
.hud-label { color: var(--foam); font-size: .78rem; line-height: 1; }
#lives { display: flex; align-items: center; gap: .24rem; height: 1.3rem; }
.life {
  position: relative;
  width: .85rem;
  height: .85rem;
  border-radius: 50%;
  background: repeating-conic-gradient(from 22deg, #ffa37c 0 52deg, #fff1d2 52deg 90deg);
}
.life::after {
  content: "";
  position: absolute;
  inset: 29%;
  border-radius: 50%;
  background: #082b2d;
}
.life[data-lost] { background: transparent; border: 1.5px solid #5e8584; }
.distance-value { line-height: 1.3rem; white-space: nowrap; }
.distance-value strong { font-size: 1.2rem; }
.race-clock {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: min(88%, 19rem);
  min-height: 11.5rem;
  display: grid;
  place-content: center;
  padding: 1rem;
  text-align: center;
  color: var(--ivory);
  background: #082b2d;
  border-radius: 1rem;
  box-shadow: 0 12px 38px #08202578;
}
.race-clock strong {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 6rem;
  font-weight: 400;
  line-height: .86;
  color: #ffc276;
  font-variant-numeric: tabular-nums;
}
.race-clock span { color: var(--foam); }
.race-clock p { margin-top: .75rem; }
.race-status {
  position: absolute;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 50%;
  translate: -50%;
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: .48rem .85rem;
  text-align: center;
  border-radius: .5rem;
  color: var(--ivory);
  background: #082b2d;
  font-weight: 600;
}
.screen-button {
  display: inline-grid;
  place-content: center;
  width: 2.75rem;
  padding: .4rem;
}
.screen-button svg { width: 1.25rem; height: 1.25rem; }
body[data-screen="running"] {
  overflow: hidden;
  overscroll-behavior: none;
}
body[data-screen="running"] .masthead {
  position: fixed;
  z-index: 2;
  top: max(.65rem, env(safe-area-inset-top));
  right: max(.65rem, env(safe-area-inset-right));
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  justify-content: end;
  align-items: start;
  gap: .3rem;
  border: 0;
  pointer-events: none;
}
body[data-screen="running"] .masthead .mast-button {
  min-height: 2.75rem;
  background: #082b2d;
  border: 0;
  border-radius: .55rem;
  pointer-events: auto;
}
body[data-screen="running"] .masthead .mast-button:hover { background: #164746; }
body[data-screen="running"] .connection {
  position: fixed;
  top: max(4.6rem, calc(env(safe-area-inset-top) + 4rem));
  left: 50%;
  translate: -50%;
  padding: .3rem .65rem;
  white-space: nowrap;
  background: #082b2d;
  border-radius: .4rem;
}
body[data-screen="running"] .regatta,
body[data-screen="running"] .chart {
  display: block;
  max-width: none;
  margin: 0;
  padding: 0;
}
body[data-screen="running"] :is(.home, .chart-heading, .course-caption) { display: none; }
body[data-screen="running"] .course { border: 0; border-radius: 0; }
body[data-screen="running"] .regatta-board {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body[data-screen="running"]:not([data-display]) .regatta-board { cursor: crosshair; }
.course-caption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; padding: .4rem .7rem; background: var(--deep); color: var(--foam); font-size: .875rem; border-top: 1px solid #588982; }
.course-caption span:last-child { font-variant-numeric: tabular-nums; }
.chart-event { color: var(--ivory); margin-top: .7rem; min-height: 1.4em; font-weight: 600; }
.display-url { margin-top: .85rem; }
.deck { color: var(--ink); background: var(--ivory); min-width: 0; padding: 1.65rem clamp(1rem, 4vw, 2.1rem) max(2rem, env(safe-area-inset-bottom)); }
.deck h2 + p { margin-top: .45rem; color: var(--muted); }
.entry-description { max-width: 36ch; margin-bottom: .85rem; }
form { display: grid; gap: .8rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: .45rem; }
.mode-picker { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.mode-picker label { display: flex; align-items: center; gap: .3rem; min-height: 2.75rem; cursor: pointer; }
input[type="radio"], input[type="checkbox"] { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--ink); }
.field-label { display: grid; gap: .28rem; font-weight: 600; }
input:not([type="radio"], [type="checkbox"]), select {
  width: 100%;
  min-width: 0;
  padding: .6rem .72rem;
  border: 1px solid #7d8f7b;
  border-radius: .35rem;
  background: #fffbef;
  caret-color: var(--ink);
}
input::placeholder { color: var(--muted); }
.primary, .outline, .text-button {
  min-height: 2.8rem;
  padding: .5rem .72rem;
  border-radius: .35rem;
  font-weight: 600;
}
.primary { width: 100%; border: 1px solid #da765c; background: var(--coral); color: var(--deep); }
.primary:hover:not(:disabled) { background: var(--coral-hover); }
.outline { background: transparent; border: 1px solid #7d8f7b; }
.outline:hover:not(:disabled), .text-button:hover { background: var(--paper); }
.text-button { justify-self: start; padding-inline: .3rem; border: 0; background: transparent; text-decoration: underline; text-underline-offset: .22em; }
.invitation { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .7rem; margin-top: 1.2rem; }
.invitation span { display: block; font-size: .85rem; color: var(--muted); }
.invitation strong { display: block; font-size: clamp(1.28rem, 6vw, 1.8rem); letter-spacing: .04em; overflow-wrap: anywhere; }
.invitation input { grid-column: 1 / -1; }
details { margin: .6rem 0; }
summary { cursor: pointer; min-height: 2.65rem; padding-block: .55rem; font-weight: 600; }
details img { display: block; max-width: 100%; height: auto; background: white; }
.how-to { margin-top: 1rem; padding-top: .15rem; border-top: 1px solid var(--line); }
.how-to ul { margin: 0; padding-left: 1.15rem; color: var(--muted); }
.how-to li + li { margin-top: .42rem; }
.deck > section + section, .deck > p + section { margin-top: 0; }
.error { margin-top: .75rem; color: var(--alert); font-weight: 600; }
.fleet { border-top: 1px solid var(--line); padding-top: .85rem; margin-top: 1.2rem !important; }
.fleet h2 { font-size: 1.85rem; margin-bottom: .45rem; }
.fleet ol { list-style: none; margin: 0; padding: 0; }
.fleet li {
  display: grid;
  grid-template-columns: .65rem minmax(0, 1fr);
  align-items: center;
  gap: .45rem;
  min-height: 2.35rem;
  border-bottom: 1px solid var(--line);
  padding-block: .2rem;
}
.fleet li[data-self] { font-weight: 600; }
.fleet li > span { overflow-wrap: anywhere; }
.fleet .presence { width: .52rem; height: .52rem; border-radius: 50%; border: 1px solid #3e5b4d; }
.fleet .presence[data-presence="online"] { background: #3e5b4d; }
.fleet .presence[data-presence="away"] { background: linear-gradient(90deg, #3e5b4d 50%, transparent 50%); }
.fleet small { color: var(--muted); }
.display-link { display: inline-flex; align-items: center; min-height: 2.65rem; margin-top: .55rem; font-weight: 600; }
dialog { width: min(100% - 2rem, 27rem); max-height: calc(100% - 2rem); padding: 1.35rem; border: 0; border-radius: .75rem; background: var(--ivory); color: var(--ink); }
dialog::backdrop { background: #061d20bf; }
dialog h2 { margin-bottom: 1rem; }
.dialog-actions { display: grid; gap: .6rem; }
body[data-display]:not([data-screen="running"]) .regatta-board { height: clamp(220px, 53dvh, 680px); }
body[data-display] .deck { display: grid; grid-template-columns: 1fr; align-content: start; }
body[data-display] .fleet:first-of-type, body[data-display] .deck > .fleet { margin-top: 0 !important; }
body[data-display] .fleet li { font-size: clamp(1rem, 2.2vw, 1.8rem); min-height: 2.85rem; }

@media (min-width: 48rem) {
  .regatta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 31%); align-items: start; }
  .chart { padding-top: 2.15rem; }
  .chart-heading { margin-bottom: 1.4rem; }
  .deck { min-height: calc(100dvh - 3.55rem); padding-top: 2.85rem; }
  .regatta-board { height: clamp(360px, 64dvh, 650px); }
  body[data-display]:not([data-screen="running"]) .regatta-board { height: clamp(340px, 65dvh, 760px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.menu-symbol, .sound-off, #sound[aria-pressed="false"] .sound-on { display: none; }
#sound[aria-pressed="false"] .sound-off { display: block; }
body[data-screen="running"] #options { min-width: 2.75rem; }
body[data-screen="running"] .menu-symbol { display: inline; }
body[data-screen="running"] .menu-word { display: none; }
.speed-meter { border-left: 1px solid #396565; }
.speed-meter strong { color: #ffbd86; }
#lives strong { font-size: 1.2rem; }
.power-slot {
  position: absolute;
  right: max(.8rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: .28rem;
  pointer-events: none;
}
.power-slot small {
  color: var(--ivory);
  background: var(--deep);
  padding: .12rem .42rem;
  border-radius: .25rem;
}
#use-power {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .48rem;
  min-height: 3.2rem;
  padding: .4rem 1rem;
  color: var(--deep);
  background: #ffc286;
  border: 2px solid var(--deep);
  border-radius: .7rem;
  box-shadow: 0 3px 0 var(--deep);
  pointer-events: auto;
  touch-action: manipulation;
}
#power-mark { font: bold 1.8rem/1 Barlow, sans-serif; }
#use-power:active { transform: translateY(2px); box-shadow: none; }
.power-slot:not([hidden]) ~ .race-status { bottom: max(6.3rem, calc(env(safe-area-inset-bottom) + 5rem)); }
@media (max-width: 25rem) {
  .race-hud > div { padding-inline: .4rem; }
  body[data-screen="running"] .masthead { gap: .12rem; }
}
@media (max-width: 22rem) {
  body[data-screen="running"] #fullscreen {
    position: fixed;
    left: max(.65rem, env(safe-area-inset-left));
    bottom: max(.75rem, env(safe-area-inset-bottom));
  }
}

.masthead .language { width:auto; min-height:2.65rem; background:var(--deep); color:var(--ivory); border:1px solid #7eaaa0; }
body[data-screen="running"] .language { display:none; }
body[data-screen="entry"] .regatta { display:block; width:min(100% - 2rem, 28rem); margin:clamp(.8rem,5vh,3rem) auto 2rem; }
body[data-screen="entry"] .chart { position:relative; overflow:hidden; padding:0; border-radius:.75rem .75rem 0 0; }
body[data-screen="entry"] .chart-heading { position:absolute; z-index:1; left:1.25rem; bottom:1rem; margin:0; pointer-events:none; }
body[data-screen="entry"] h1 { font-size:clamp(2.8rem,8vw,3.8rem); text-shadow:0 2px 5px #072b35; }
body[data-screen="entry"] :is(.course-caption,#phase,#entry-title) { display:none; }
body[data-screen="entry"] .course { border:0; border-radius:0; }
body[data-screen="entry"] .regatta-board { height:8.5rem; }
body[data-screen="entry"] .deck { min-height:0; padding:1.2rem; border-radius:0 0 .75rem .75rem; }

body[data-screen="waiting"]:not([data-display]) .regatta {
  display: block;
  width: min(100% - 1.5rem, 34rem);
  margin: .8rem auto;
}
body[data-screen="waiting"]:not([data-display]) .chart { padding: .25rem .3rem .8rem; }
body[data-screen="waiting"]:not([data-display]) h1 { font-size: 2.5rem; }
body[data-screen="waiting"]:not([data-display]) .chart-heading { margin: 0; }
body[data-screen="waiting"]:not([data-display]) :is(.course,#phase) { display: none; }
body[data-screen="waiting"]:not([data-display]) .deck { min-height: 0; padding: 1rem; border-radius: .65rem; }
body[data-screen="waiting"] #waiting-description { margin: .75rem 0 .45rem; }
body[data-screen="waiting"] .masthead { flex-wrap: wrap; }
body[data-board-host][data-screen="running"] .regatta-board { cursor: default; }

body[data-screen="completed"] .regatta {
  display: block;
  width: min(100% - 2rem, 68rem);
  margin: clamp(1rem, 4dvh, 3rem) auto 2rem;
  overflow: hidden;
  border-radius: .75rem;
}
body[data-screen="completed"] .masthead { flex-wrap: wrap; }
body[data-screen="completed"] .chart {
  position: relative;
  isolation: isolate;
  padding: clamp(1rem, 4vw, 3.4rem);
  background: var(--deep);
}
body[data-screen="completed"] .course {
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 0;
  border-radius: 0;
}
body[data-screen="completed"] .course::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, #092b30 0%, #092b30e8 50%, #092b309e 100%);
  content: "";
}
body[data-screen="completed"] .course .regatta-board { height: 100%; }
body[data-screen="completed"] .course-caption,
body[data-screen="completed"] #display-feedback:empty { display: none; }
body[data-screen="completed"] .chart-heading { margin-bottom: clamp(1rem, 5dvh, 2.6rem); }
body[data-screen="completed"] #page-title { font-size: clamp(1.5rem, 3vw, 2.2rem); }
body[data-screen="completed"] #phase { font-size: .9rem; }
.result-banner {
  display: grid;
  gap: clamp(.85rem, 3vw, 2rem);
}
#winner { font-size: clamp(2.9rem, 7vw, 5.5rem); text-wrap: balance; }
.winner-names { font-size: clamp(1.2rem, 3vw, 2rem); overflow-wrap: anywhere; }
.finish-reason { color: var(--foam); margin-top: .5rem; }
.result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, auto));
  column-gap: clamp(.65rem, 4vw, 3rem);
  margin: 0;
  padding: .85rem 0 0;
  border-top: 1px solid #7eaaa0;
  align-self: end;
}
.result-summary dt { color: var(--foam); }
.result-summary dd {
  margin: .1rem 0 0;
  font-size: clamp(1.32rem, 3vw, 2rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
body[data-screen="completed"] .deck {
  min-height: 0;
  padding: clamp(1rem, 4vw, 3.4rem);
}
#results-heading { font-size: clamp(1.9rem, 4vw, 3rem); margin-bottom: .65rem; }
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.result-table :is(th, td) {
  padding: .6rem clamp(.25rem, 2vw, 1rem);
  border-bottom: 1px solid var(--line);
}
.result-table th:first-child { width: 45%; text-align: left; overflow-wrap: anywhere; }
.result-table thead { font-size: clamp(.85rem, 2vw, 1rem); color: var(--muted); }
.result-table tbody td { white-space: nowrap; }
.result-table tbody th { font-weight: 600; }
.result-table small { display: block; font-weight: 400; color: var(--muted); }
.result-table tr[data-winner] { background: var(--paper); }
.result-actions:has(:not([hidden])) { margin-top: 1.15rem; }
.result-actions .primary { width: min(100%, 18rem); }
#rematch-note { color: var(--muted); }

@media (min-width: 48rem) {
  .result-banner { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
}

@media (min-width: 64rem) {
  body[data-display] .result-table tbody,
  body[data-board-host] .result-table tbody { font-size: 1.28rem; }
}
