/* Longboat: a calm, fixed river palette (the same in light and dark OS modes).
   One accent (deep teal) means "your move": water you can row to, and Go. */
:root {
  color-scheme: light;
  --bg: #e7eef0;
  --card: #fbfdfd;
  --ink: #16242b;
  --muted: #6b7f88;
  --soft: rgba(22, 36, 43, .07);
  --line: rgba(22, 36, 43, .14);
  --accent: #0d6e79;
  --accent-soft: rgba(13, 110, 121, .16);
  --bad: #c0392b;
  --good: #1d7a3c;
  --water: #4f93c4;
  --water-deep: #35719e;
  --water-pale: #7fb6dc;
  --shore: #b9ab86;
  --shore-dark: #8d7f5d;
  --rock: #7b7468;
  --radius: 14px;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #0d6e79;
  --tut-accent-ink: #ffffff;
  --tut-bubble: #fbfdfd;
  --tut-ink: #16242b;
  --tut-muted: #6b7f88;
  --tut-dim: rgba(10, 24, 30, .58);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- top bar */
.topbar {
  display: flex; align-items: center; gap: 4px;
  max-width: 1100px; margin: 0 auto; height: 48px;
  padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
}
.back, .icon-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  text-decoration: none; font-size: 22px; line-height: 1; cursor: pointer;
}
.back:hover, .icon-btn:hover { background: var(--soft); }
.brand {
  flex: 1; margin: 0; text-align: center; font-size: 18px; font-weight: 750;
  letter-spacing: .06em; font-variant: small-caps;
}
.back:focus-visible, .icon-btn:focus-visible, .btn:focus-visible, .crew:focus-visible,
.seg button:focus-visible, .menu button:focus-visible, .target:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ------------------------------------------------------------- buttons */
.btn {
  min-height: 44px; padding: 0 15px; border-radius: 12px; border: 0;
  background: var(--soft); cursor: pointer; font-weight: 650; line-height: 1.1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.warn { background: var(--bad); color: #fff; }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; }
.btn.icon { min-width: 44px; padding: 0 10px; }
.btn .ico { font-size: 19px; line-height: 1; }
.btn small { display: block; font-size: 11px; font-weight: 500; opacity: .8; }

/* ------------------------------------------------------------- layout: fill the screen */
.app {
  max-width: 1100px; margin: 0 auto;
  min-height: calc(100vh - 48px); min-height: calc(100dvh - 48px);
  padding: 0 max(10px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 6px;
}

/* ------------------------------------------------------------- crew chips */
.crews { display: flex; gap: 5px; flex-wrap: nowrap; min-width: 0; align-items: stretch; }
.crew {
  position: relative; display: flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 3px 9px 3px 4px; border: 0; border-radius: 21px;
  background: transparent; cursor: pointer; min-width: 0; flex: 1 1 0;
  transition: background .2s, box-shadow .2s;
}
.crew:hover { background: var(--soft); }
.crew.turn { background: var(--card); box-shadow: 0 0 0 2px color-mix(in srgb, var(--pc) 45%, transparent), 0 1px 4px rgba(22, 36, 43, .08); }
.crew .av {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--pc, #888); color: #fff; font-size: 12px; font-weight: 800;
}
.crew .who { display: flex; flex-direction: column; min-width: 0; align-items: flex-start; }
.crew .nm { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.crew .oars { display: flex; gap: 1.5px; margin-top: 2px; }
.crew .oar { width: 4px; height: 9px; border-radius: 2px; background: var(--line); }
.crew .oar.on { background: var(--pc); }
.crew .rank { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.crew.done .rank { color: var(--good); }
.crew.bump .av { animation: bump 1s ease-out 1 both; }
@keyframes bump { 0% { box-shadow: 0 0 0 0 var(--pc); } 30% { box-shadow: 0 0 0 7px transparent; transform: scale(1.12); } 100% { box-shadow: none; transform: none; } }
@media (max-width: 460px) { .crews[data-n="4"] .nm, .crews[data-n="3"] .rival .nm { display: none; } }

/* ------------------------------------------------------------- status */
.status-row { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.status { display: flex; align-items: center; gap: 8px; min-height: 22px; font-size: 15px; font-weight: 650; padding: 0 2px; }
.status .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--pc); }
.status.mine .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.status.thinking .msg { color: var(--muted); }
.status.thinking .msg::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.status-row .net { color: var(--muted); font-size: 13px; justify-content: flex-start; padding: 0 3px; }

/* ------------------------------------------------------------- minimap: the whole course at a glance */
.minimap {
  position: relative; height: 22px; border-radius: 11px; background: var(--water-deep);
  overflow: hidden; flex: none;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .22);
}
.minimap .mm-bend { position: absolute; top: 0; bottom: 0; background: var(--shore-dark); opacity: .85; }
.minimap .mm-bend.south { top: 50%; }
.minimap .mm-bend.north { bottom: 50%; }
.minimap .mm-finish { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; opacity: .9; }
.minimap .mm-boat {
  position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--pc); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85);
  transition: left .45s ease-out;
}
.minimap .mm-boat.mine { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; }

/* ------------------------------------------------------------- the river */
.river-box {
  position: relative; flex: 1 1 auto; min-height: 190px;
  border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, var(--shore) 0 var(--bank), var(--water-pale) var(--bank), var(--water) 50%, var(--water-pale) calc(100% - var(--bank)), var(--shore) calc(100% - var(--bank)) 100%);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .16);
}
.river-scroll {
  position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.river-scroll::-webkit-scrollbar { display: none; }
.river { position: relative; height: 100%; }

/* lane bands */
.lane { position: absolute; left: 0; right: 0; }
.lane::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .11) 0 1px, transparent 1px var(--cellw));
}
.lane.alt { background: rgba(255, 255, 255, .055); }

/* a headland: rock on the shore, and the bent water beside it */
.point { position: absolute; }
.point .rock { position: absolute; inset: 0; }
.point .toll {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; font-weight: 800; color: #fff; opacity: .85; letter-spacing: .04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5); white-space: nowrap;
}
.bendwater { position: absolute; background: rgba(255, 255, 255, .13); pointer-events: none; }
.bendwater.wide { background: rgba(20, 40, 60, .16); }

/* distance ticks and the finish */
.tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .3); pointer-events: none; }
.tick span { position: absolute; top: 1px; left: 3px; font-size: 9px; color: rgba(255, 255, 255, .8); font-weight: 700; }
.finish {
  position: absolute; top: 0; bottom: 0; width: 8px; pointer-events: none;
  background: repeating-linear-gradient(180deg, #fff 0 7px, #1b2b33 7px 14px);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

/* water you can row to */
.target {
  position: absolute; border: 0; padding: 0; cursor: pointer; background: transparent;
  border-radius: 9px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85);
  transition: box-shadow .15s, background .15s;
}
.target::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: #fff; opacity: .9;
}
.target:hover { background: rgba(255, 255, 255, .2); }
.target.picked { background: var(--accent); box-shadow: inset 0 0 0 2px #fff, 0 3px 10px rgba(0, 0, 0, .3); }
.target.picked::after { opacity: 1; }
.target.clash { box-shadow: inset 0 0 0 2px var(--bad); }
.target.clash::after { background: var(--bad); }

/* boats */
.boat {
  position: absolute; left: 0; top: 0; pointer-events: none;
  transition: transform .5s cubic-bezier(.3, .8, .4, 1);
  will-change: transform;
}
.boat.mine { z-index: 3; }
.boat .hull { position: absolute; inset: 0; }
.boat.turn .hull { filter: drop-shadow(0 0 0 #fff); }
.boat .ring {
  position: absolute; inset: -3px; border-radius: 40% / 50%;
  box-shadow: 0 0 0 2.5px #fff, 0 0 0 4px rgba(0, 0, 0, .25);
}
.boat.clashed { animation: shake .45s ease-out 1 both; }
@keyframes shake { 0%, 100% { filter: none; } 20% { filter: brightness(1.7) saturate(.4); } 60% { filter: brightness(1.7) saturate(.4); } }
.boat .label {
  position: absolute; left: 50%; transform: translateX(-50%); top: -13px;
  font-size: 9.5px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); white-space: nowrap;
}
.ghost-boat { position: absolute; left: 0; top: 0; opacity: .5; pointer-events: none; transition: transform .2s; }

/* ------------------------------------------------------------- what happened */
.happened {
  margin: 0; padding: 0 3px; min-height: 19px; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none;
}
.happened b { color: var(--ink); font-weight: 700; }

/* ------------------------------------------------------------- action bar */
.actionbar {
  flex: none; min-height: 56px; margin: 0 auto; width: 100%; max-width: 560px;
  display: flex; gap: 6px; align-items: center; justify-content: center; padding: 5px;
  background: var(--card); border-radius: 18px;
  box-shadow: 0 3px 16px rgba(22, 36, 43, .14);
}
.actionbar:empty { visibility: hidden; box-shadow: none; }
/* The tutorial kit's first-visit chip is fixed to the bottom centre, where it sat straight on top
   of the action bar and hid Go. Lift it clear of the bar. */
.tut-chip { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
.actionbar .btn { flex: 0 1 auto; }
.actionbar .btn.go { flex: 1 1 auto; max-width: 260px; }
.actionbar .toggle { box-shadow: inset 0 0 0 1.5px var(--line); background: transparent; }
.actionbar .toggle[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: none; }
.actionbar .hintline { font-size: 13.5px; color: var(--muted); padding: 0 8px; text-align: center; }

/* ------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(10, 24, 30, .44); padding: 14px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 420px; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow-y: auto;
  background: var(--card); border-radius: 20px; padding: 18px;
  box-shadow: 0 12px 40px rgba(6, 18, 24, .3);
  animation: pop .18s ease-out;
}
.modal.wide { max-width: 620px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 12px; font-size: 20px; text-align: center; }
.modal-head { display: flex; align-items: center; gap: 8px; margin: -6px -6px 8px 0; }
.modal-head h2 { flex: 1; margin: 0; text-align: left; }
.modal .lede { margin: -4px 0 14px; text-align: center; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .btn { flex: 1 1 auto; }

/* menu */
.menu-overlay { background: rgba(10, 24, 30, .12); place-items: start end; padding: 48px 10px 0; }
.menu {
  min-width: 218px; background: var(--card); border-radius: 16px; padding: 6px;
  box-shadow: 0 10px 30px rgba(6, 18, 24, .24); animation: pop .15s ease-out; display: grid;
}
.menu button {
  min-height: 48px; padding: 0 14px; border: 0; background: transparent; text-align: left;
  border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 550;
}
.menu button:hover { background: var(--soft); }
.menu #menu-online { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; }
@media (min-width: 1120px) { .menu-overlay { padding-right: calc((100vw - 1100px) / 2 + 8px); } }

/* setup */
.field { margin: 14px 0; }
.field-label { font-weight: 650; margin-bottom: 6px; font-size: 14px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--soft); }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 650; }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }

/* info */
.info-round { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.info-standings { display: grid; gap: 6px; }
.info-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 12px; background: var(--soft); }
.info-row .av { width: 24px; height: 24px; font-size: 11px; }
.info-row .nm { font-weight: 700; }
.info-row .det { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sub-title { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 13px; max-height: 40vh; overflow-y: auto; }
.log li { display: flex; gap: 7px; align-items: flex-start; }
.log li .av { width: 18px; height: 18px; font-size: 10px; margin-top: 1px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--pc); color: #fff; font-weight: 800; flex: none; }
.log li.note { color: var(--muted); font-style: italic; }

/* help */
.help-body h3 { margin: 16px 0 4px; font-size: 15px; }
.help-body h3:first-child { margin-top: 0; }
.help-body p, .help-body li { font-size: 14px; }
.help-body ul, .help-body ol { padding-left: 20px; margin: 4px 0; }
.effort-key { list-style: none; padding: 0 !important; display: grid; gap: 5px; }
.effort-key li { display: flex; align-items: baseline; gap: 8px; }
.effort-key b { min-width: 58px; }
.effort-key small { color: var(--muted); }

/* result */
.go-table { display: grid; gap: 4px; }
.go-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; }
.go-row.win { background: var(--accent-soft); }
.go-row .place { width: 26px; color: var(--muted); font-size: 13px; font-weight: 700; }
.go-row .av { width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--pc); color: #fff; font-size: 12px; font-weight: 800; flex: none; }
.go-name { display: flex; flex-direction: column; font-weight: 700; min-width: 0; }
.go-name small { font-weight: 400; color: var(--muted); font-size: 12px; }
.go-row .gap { margin-left: auto; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
#over-leave { display: flex; width: 100%; margin-top: 8px; }
body.is-online #btn-new { display: none; }

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

/* Desktop: the river gets taller, everything else stays the same shape. */
@media (min-width: 820px) {
  .app { gap: 8px; padding-bottom: 10px; }
  .river-box { min-height: 260px; }
  .happened { font-size: 14px; }
}
