/* Supasail UI: light glass over the moving sea. Tokens, surfaces and components
   (docs/plannen/loopbaan/UX_ONTWERP.md, section 5). Dark tokens apply only when the
   scene itself is dark: :root[data-scene="dark"], set by src/ui/scene.js. */
:root {
  /* surfaces */
  --glass: rgba(246, 251, 254, .80);
  --sheet: rgba(246, 251, 254, .90);
  --chip: rgba(246, 251, 254, .70);
  --solid: #f4f9fc;
  --chart: rgba(14, 52, 92, .78);            /* minimap and level chart: deep water, their drawings are light */
  --well: rgba(11, 42, 69, .06);
  --line: rgba(11, 42, 69, .12);
  --edge: rgba(255, 255, 255, .75);
  --haze: rgba(235, 245, 252, .30);
  /* text */
  --ink: #0b2a45;
  --ink-2: #35546e;
  --ink-3: #4f6b84;
  --dim: var(--ink-2);                       /* old name, still used by a few rules */
  /* brand and accents */
  --navy: #040047;
  --stripe: #1a1670;
  --coral: #f26122;
  --coral-ink: #c9440f;
  --sea: #0a67a6;
  --sea-soft: rgba(10, 103, 166, .12);
  --sea-line: rgba(10, 103, 166, .28);
  --sky: #bfe3f7;
  --sun: #f2a100;
  --sun-ink: #8a5a00;
  --foam: #ffffff;
  /* states */
  --good: #0a7350;
  --warn: #9a4f00;
  --bad: #b92f25;
  --good-soft: rgba(10, 115, 80, .12);
  --sun-soft: rgba(242, 161, 0, .16);
  /* instruments */
  --wind-true: #0a84d6;
  --wind-app: #d97a00;
  --nogo: rgba(200, 55, 45, .22);
  /* depth */
  --shadow-1: 0 2px 10px rgba(10, 60, 110, .10);
  --shadow-2: 0 12px 36px rgba(10, 60, 110, .16);
  --shadow-3: 0 24px 64px rgba(10, 60, 110, .22);
  --inset: inset 0 1px 0 rgba(255, 255, 255, .85);
  --blur: blur(22px) saturate(1.35) brightness(1.06);
  --vignette: rgba(6, 40, 80, .10);
  /* type */
  --font: "Inter", -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  /* space and shape */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --r-1: 8px; --r-2: 14px; --r-3: 22px; --r-pill: 999px;
  --gutter: 48px;
  /* motion */
  --d-1: 120ms; --d-2: 240ms; --d-3: 420ms; --d-4: 800ms;
  --e-out: cubic-bezier(.22, .8, .26, 1);
  --e-swell: cubic-bezier(.2, .9, .25, 1.18);
  --e-in: cubic-bezier(.5, 0, .9, .4);
}
:root[data-scene="dark"] {
  --glass: rgba(12, 30, 51, .70);
  --sheet: rgba(12, 30, 51, .86);
  --chip: rgba(12, 30, 51, .70);
  --solid: #10243b;
  --chart: rgba(6, 18, 32, .72);
  --well: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .14);
  --edge: rgba(255, 255, 255, .16);
  --haze: rgba(6, 16, 30, .30);
  --ink: #eef6fb;
  --ink-2: #b9cbdb;
  --ink-3: #93a9bd;
  --coral-ink: #ff9a63;
  --sea: #7fcbff;
  --sea-soft: rgba(127, 203, 255, .16);
  --sea-line: rgba(127, 203, 255, .34);
  --sky: rgba(127, 203, 255, .22);
  --sun-ink: #ffd166;
  --good: #6fe0a8;
  --warn: #ffc266;
  --bad: #ff8f80;
  --good-soft: rgba(111, 224, 168, .16);
  --sun-soft: rgba(255, 209, 102, .16);
  --foam: #eef6fb;
  --wind-true: #4fc3ff;
  --wind-app: #ffb347;
  --nogo: rgba(255, 74, 58, .24);
  --shadow-1: 0 2px 10px rgba(0, 8, 20, .30);
  --shadow-2: 0 12px 36px rgba(0, 8, 20, .40);
  --shadow-3: 0 24px 64px rgba(0, 8, 20, .50);
  --inset: inset 0 1px 0 rgba(255, 255, 255, .10);
  --blur: blur(22px) saturate(1.2);
  --vignette: rgba(0, 6, 16, .28);
}
@media (max-width: 1340px), (max-height: 800px) { :root { --gutter: 32px; } }

/* ---- surfaces ---- */
.glass, .sheet, .chip, .inst .strip, .inst .instDetails, .inst .trim, .panel, .gbox, .helpBox, .gbox2, .gh-top, .gh-nav, .gh-tip, .gh-msg, .gh-keys, .modes, .walletHud, .condChip {
  color: var(--ink); border: 1px solid var(--edge);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  transition: background-color 1.2s, color 1.2s, border-color 1.2s;
}
.glass, .inst .strip, .panel, .gh-top, .gh-nav { background: var(--glass); box-shadow: var(--shadow-2), var(--inset); }
.sheet, .gbox, .helpBox, .gbox2, .inst .instDetails, .inst .trim, .gh-tip, .gh-msg { background: var(--sheet); box-shadow: var(--shadow-3), var(--inset); }
.chip, .modes, .walletHud, .condChip, .gh-keys { background: var(--chip); box-shadow: var(--shadow-1); border-radius: var(--r-pill); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .inst .strip, .panel, .gh-top, .gh-nav, .chip, .modes, .walletHud, .condChip, .gh-keys { background: rgba(246, 251, 254, .94); }
  :root[data-scene="dark"] :is(.glass, .inst .strip, .panel, .gh-top, .gh-nav, .chip, .modes, .walletHud, .condChip, .gh-keys) { background: rgba(12, 30, 51, .94); }
}

/* ---- the game interface over the scene ---- */
#ui { position: fixed; inset: 0; pointer-events: none; user-select: none; color: var(--ink); font-variant-numeric: tabular-nums; }
#ui.hidden { display: none; }
.title { position: absolute; left: 26px; top: 16px; height: 44px; opacity: .95; }
.shot { display: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, var(--vignette) 100%); }
.fps { display: none; position: absolute; right: 24px; bottom: 8px; font: 11px var(--mono); color: #fff; text-shadow: 0 1px 4px rgba(4, 30, 70, .6); }
body.showFps .fps { display: block; }
kbd { font: 600 11px/1 var(--mono); padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--foam); box-shadow: 0 1px 0 var(--line); }
:root[data-scene="dark"] kbd { color: var(--navy); }

/* mode buttons: one quiet row under the logo */
.modes { position: absolute; left: 24px; top: 70px; display: flex; gap: 2px; padding: 4px; pointer-events: auto; }
.modes button { height: 30px; padding: 0 13px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink); font: 500 13px/1 var(--font); cursor: pointer; transition: background-color var(--d-1), color var(--d-1); }
.modes button:hover { background: var(--sea-soft); }
.modes button.on { background: var(--foam); color: var(--navy); font-weight: 600; box-shadow: var(--shadow-1); }
.modes button.helpBtn kbd { margin-right: 5px; font-size: 10px; padding: 2px 5px; }
body.playing .modes, body.playing .topright { display: none; }

/* wallet and conditions, top right */
.topright { position: absolute; right: 24px; top: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.topright > * { pointer-events: auto; }
.walletHud { display: flex; gap: 12px; align-items: center; height: 36px; padding: 0 16px; font-size: 14px; color: var(--ink); }
.walletHud b { font-weight: 600; }
.walletHud .wc { display: inline-flex; align-items: center; gap: 6px; }
.walletHud .wc svg { width: 16px; height: 16px; }
.walletHud .wp { display: inline-flex; flex-direction: column; gap: 3px; } .walletHud .wp b { font-size: 13px; line-height: 14px; }
.walletHud .rbar { display: block; height: 3px; border-radius: 2px; background: var(--well); overflow: hidden; } .walletHud .rbar i { display: block; height: 100%; background: var(--sea); border-radius: 2px; transition: width .5s var(--e-out); }
.walletHud .wd { color: var(--good); font-size: 13px; font-weight: 600; display: none; }
.walletHud .wd.show { display: inline; }
.icoin circle { fill: var(--sun); stroke: var(--sun-ink); stroke-width: 1.5; }
.icoin path { fill: none; stroke: var(--navy); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.condChip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; font: 500 13px/1 var(--font); color: var(--ink); cursor: pointer; }
.condChip:hover, .condChip.on { background: var(--sheet); }
.condChip svg { width: 15px; height: 15px; fill: none; stroke: var(--sea); stroke-width: 1.75; stroke-linecap: round; }
.panel { display: none; width: 236px; padding: 14px 16px 16px; border-radius: var(--r-3); font-size: 12.5px; text-align: left; }
#ui.condOpen .panel { display: block; animation: swell var(--d-3) var(--e-swell) backwards; }
.panel .ptitle { font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
.panel .row { display: grid; grid-template-columns: 62px 1fr 36px; align-items: center; gap: 8px; margin: 7px 0; }
.panel label { color: var(--ink-2); }
.panel .val { text-align: right; color: var(--ink); font-weight: 500; }
.panel input[type=range] { width: 100%; accent-color: var(--sea); height: 14px; }
.panel .toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 10px; }
.panel .toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--ink); }
.panel .toggles input { accent-color: var(--sea); }
.panel .btns { display: flex; gap: 6px; margin-top: 12px; }
.panel button { flex: 1; height: 34px; border-radius: var(--r-pill); border: 1px solid var(--sea-line); background: var(--sea-soft); color: var(--sea); font: 600 13px/1 var(--font); cursor: pointer; }

/* ---- instrument strip, bottom left, with the Trim and Details drawers above it ---- */
.inst { position: absolute; left: var(--gutter); bottom: var(--gutter); width: 392px; max-height: calc(100vh - 150px - var(--gutter)); display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; pointer-events: none; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.inst > * { pointer-events: auto; box-sizing: border-box; }
.inst .strip { border-radius: var(--r-3); padding: 12px 16px 10px; flex: none; }
.inst .cells { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 12px; }
.inst .cell { display: flex; flex-direction: column; min-width: 0; }
.inst .cell .cl, .spdLbl { font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.inst .cell .cv { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.inst .cell .cv b { font-size: 24px; line-height: 30px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.inst .trimline { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.inst .trimline b { color: var(--ink); font-weight: 600; }
/* the speed bar lies down: main.js sets the height of the fill and the bottom of the markers, the track is turned a quarter */
.spd { position: relative; flex: none; width: var(--spd-len, 150px); height: 14px; margin-right: 2px; }
.spdTrack { position: absolute; left: 50%; top: 50%; width: 6px; height: var(--spd-len, 150px); margin: calc(var(--spd-len, 150px) / -2) 0 0 -3px; transform: rotate(90deg); border-radius: 3px; background: var(--well); }
.spdFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; border-radius: 3px; background: var(--sea); transition: height .12s linear; }
.spdAstern { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; border-radius: 3px; background: var(--bad); transition: height .12s linear; }
.spdTarget { position: absolute; left: -4px; right: -4px; height: 0; border-top: 3px solid var(--wind-app); border-radius: 2px; transition: bottom .2s linear; }
.spdHull { position: absolute; left: -2px; right: -2px; height: 0; border-top: 1px solid var(--ink-3); opacity: .6; }
.inst .drawBtns { display: flex; gap: 4px; margin-left: auto; }
.inst .drawBtns button { height: 26px; padding: 0 9px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--sea); font: 600 12px/1 var(--font); cursor: pointer; }
.inst .drawBtns button:hover { background: var(--sea-soft); }
.inst.trimOpen #btnTrim, .inst.detailsOpen #btnDetails { background: var(--sea-soft); }
.inst .drawBtns kbd { font-size: 9.5px; padding: 1px 4px; margin-left: 3px; box-shadow: none; }
/* fixed one-line slot so the strip never changes height when a message appears */
.inst .alert { height: 18px; line-height: 18px; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--warn); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.inst .alert.bad { color: var(--bad); }
.inst .trim, .inst .instDetails { display: none; border-radius: var(--r-3); padding: 12px 16px; }
.inst.trimOpen .trim, .inst.detailsOpen .instDetails { display: block; animation: swell var(--d-3) var(--e-swell) backwards; }
.inst .instDetails { overflow-y: auto; min-height: 0; flex: 0 1 auto; }
/* low specificity on purpose: the rig rules in index.html hide the rows of sails the boat does not have */
.trow { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 8px; margin: 3px 0; }
.trim label { font: 600 10.5px/14px var(--font); white-space: nowrap; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.trim input[type=range] { width: 100%; accent-color: var(--wind-app); height: 12px; margin: 2px 0; }
.trim #tRud { accent-color: var(--bad); }
.trim span { text-align: right; color: var(--ink); font-weight: 600; }
.hoistWrap { position: relative; padding-bottom: 12px; }
.hoistTicks { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; font-size: 9px; color: var(--ink-2); letter-spacing: .04em; }
.hoistTicks span { position: absolute; transform: translateX(-50%); font-weight: 400; color: var(--ink-2); }
.trim span.hoistState { font-size: 10.5px; color: var(--wind-app); text-transform: uppercase; letter-spacing: .06em; }
.instDetails .dtop { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.instDetails .roseKey { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
.roseKey i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.roseKey .kT i { background: var(--wind-true); } .roseKey .kA i { background: var(--wind-app); } .roseKey .kN i { background: var(--nogo); border: 1px solid var(--bad); box-sizing: border-box; }
.instDetails .grp { color: var(--ink-2); padding: 1px 0; }
.instDetails .grp b { color: var(--ink); font-weight: 600; }
.instDetails .lbl { display: inline-block; width: 82px; font: 600 10.5px/14px var(--font); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
/* the rose in the Details drawer */
#rose .rDisc { fill: var(--well); stroke: var(--line); }
#rose .rCard { fill: var(--ink); } #rose .rN { fill: var(--bad); }
#roseTicks line { stroke: var(--ink-2); }
#rose .rNogo { fill: var(--nogo); stroke: var(--bad); stroke-opacity: .5; }
#rose .rT { stroke: var(--wind-true); } #rose .rTf { fill: var(--wind-true); }
#rose .rA { stroke: var(--wind-app); } #rose .rAf { fill: var(--wind-app); }
#rose .rHull { fill: var(--foam); stroke: var(--ink); }
#rose .rInk { fill: var(--ink); } #rose .rBoom { stroke: var(--ink); } #rose .rRud { stroke: var(--bad); }

/* ---- buttons ---- */
.btn { border: 1px solid var(--sea-line); background: var(--sea-soft); color: var(--sea); height: 38px; padding: 0 16px; border-radius: var(--r-pill); font: 600 13.5px/1 var(--font); cursor: pointer; transition: background-color var(--d-1), transform .18s var(--e-swell), box-shadow .18s; }
.btn:hover { background: rgba(10, 103, 166, .18); }
:root[data-scene="dark"] .btn:hover { background: rgba(127, 203, 255, .24); }
.btn:focus-visible, .modes button:focus-visible, .card:focus-visible, .lvtile:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
/* the primary button is the float of the start screen: white, navy text, a boot-top stripe */
.btn.primary { border: 0; background: var(--foam); color: var(--navy); font-weight: 700; letter-spacing: -.01em; box-shadow: var(--shadow-2), inset 0 -3px 0 var(--stripe); }
.btn.primary:hover { background: var(--foam); transform: translateY(-2px); box-shadow: var(--shadow-3), inset 0 -3px 0 var(--stripe); }
.btn.primary:active { transform: translateY(2px) scale(.985); box-shadow: var(--shadow-1), inset 0 -2px 0 var(--stripe); }
.btn.big { height: 50px; padding: 0 24px; font-size: 16px; }
.btn.primary.big { box-shadow: var(--shadow-2), inset 0 -4px 0 var(--stripe); }
.btn.small { height: 30px; padding: 0 12px; font-size: 12.5px; white-space: nowrap; }
.btn.dis { opacity: .5; pointer-events: none; box-shadow: none; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--well); }
.link { background: none; border: 0; color: var(--sea); cursor: pointer; font: 600 12.5px/1 var(--font); margin-left: 10px; padding: 0; }
.link:hover { text-decoration: underline; }
.muted { color: var(--ink-2); font-size: 12.5px; }
.sec { margin-top: 12px; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

/* ---- fleet screen ---- */
.garage, .help { position: fixed; inset: 0; display: grid; place-items: center; background: var(--haze); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--ink); }
.garage { z-index: 30; } .help { z-index: 20; }
.garage.hidden, .help.hidden { display: none; }
.gbox { width: min(1240px, 96vw); height: min(860px, 94vh); display: flex; flex-direction: column; border-radius: var(--r-3); overflow: hidden; }
.ghead { display: grid; grid-template-columns: auto auto 1fr auto; gap: 24px; align-items: center; padding: 18px 26px; border-bottom: 1px solid var(--line); }
.gtitle { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.gtitle img { height: 30px; content: url(../../assets/supasail-logo.svg); }
:root[data-scene="dark"] .gtitle img { content: url(../../assets/supasail-logo-light.svg); }
.gtitle span { font-weight: 500; letter-spacing: .02em; color: var(--ink-2); }
.wallet { display: flex; gap: 8px; }
.wallet .coins, .wallet .pts { height: 34px; display: inline-flex; align-items: center; gap: 5px; padding: 0 14px; border-radius: var(--r-pill); font-size: 14px; background: var(--well); color: var(--ink); }
.wallet .coins { background: var(--sun-soft); color: var(--sun-ink); }
.wallet b { font-weight: 700; }
.unlock .ul { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; } .unlock .ul b { color: var(--ink); }
.unlock .bar { height: 6px; border-radius: var(--r-pill); background: var(--well); overflow: hidden; }
.unlock .bar div { height: 100%; background: var(--sea); border-radius: var(--r-pill); transition: width .5s var(--e-out); }
.gbtns { display: flex; gap: 8px; align-items: center; }
.gbody { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: 1fr; gap: 12px; padding: 18px 20px; overflow: auto; }
.card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 10px 12px; border-radius: var(--r-2); border: 1px solid var(--line); background: var(--foam); color: var(--ink); cursor: pointer; text-align: center; transition: transform .18s var(--e-swell), box-shadow .18s, border-color .15s; font: inherit; }
:root[data-scene="dark"] .card { background: var(--well); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); }
.card.focus { border-color: var(--sea); box-shadow: 0 0 0 2px var(--sea) inset; }
.card.locked .silwrap { filter: grayscale(.85); opacity: .5; }
.card.locked .cname, .card.locked .ccls { color: var(--ink-3); }
/* a strip of sea behind each silhouette: a white hull stays visible on a light card */
.card .silwrap { width: 100%; flex: 1 1 86px; min-height: 64px; border-radius: var(--r-1); background: linear-gradient(180deg, #cfe9f8 0%, #9fd0ee 62%, #4d9bd0 62%, #2f7fbd 100%); }
:root[data-scene="dark"] .card .silwrap { background: linear-gradient(180deg, #1c3554 0%, #2a4d74 62%, #143352 62%, #0c2440 100%); }
.card .sil { width: 100%; height: 100%; filter: drop-shadow(0 1px 1px rgba(4, 30, 70, .35)); }
.card .cname { font-weight: 600; font-size: 14px; margin-top: 4px; } .card .ccls { font-size: 11.5px; color: var(--ink-2); }
.badge { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; padding: 3px 9px; border-radius: var(--r-pill); margin-top: 4px; }
.badge.owned { background: var(--good-soft); color: var(--good); } .badge.unlocked { background: var(--sun-soft); color: var(--sun-ink); } .badge.locked { background: var(--well); color: var(--ink-2); }
.selmark { position: absolute; top: 16px; right: 16px; font-size: 9.5px; letter-spacing: .12em; background: var(--foam); color: var(--navy); padding: 3px 7px; border-radius: var(--r-pill); font-weight: 700; box-shadow: var(--shadow-1); }
.drawer { border-left: 1px solid var(--line); padding: 20px 22px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.drawer > * { flex-shrink: 0; }
.dname { font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -.01em; } .dcls { color: var(--ink-2); font-size: 13px; } .dblurb { font-size: 14px; margin-top: 6px; line-height: 1.45; }
.dstats { display: flex; gap: 12px; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; flex-wrap: wrap; } .dstats b { color: var(--ink); }
.lockmsg { padding: 12px 14px; border-radius: var(--r-2); background: var(--well); font-size: 13px; color: var(--ink-2); } .lockmsg b { color: var(--ink); }
.fld { display: flex; flex-direction: column; gap: 4px; font: 600 11px/14px var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.fld small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.fld input, .fld select, .edf input[type=text], .edf input[type=number], .edf select, .edbar .edopen { font: 400 14px/1.2 var(--font); letter-spacing: 0; text-transform: none; height: 38px; padding: 0 10px; border-radius: var(--r-1); border: 1px solid var(--line); background: var(--foam); color: var(--navy); box-sizing: border-box; }
.fld input:focus, .fld select:focus, .edf input:focus, .edf select:focus { outline: 2px solid var(--sea); outline-offset: -1px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; padding: 3px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: var(--shadow-1), 0 0 0 1px var(--line); cursor: pointer; padding: 0; } .sw.on { box-shadow: 0 0 0 3px var(--sea); }
.uprow { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.uprow small { color: var(--ink-2); } .dots { color: var(--sea); letter-spacing: 2px; margin-left: 6px; } .max { color: var(--good); font-size: 12px; font-weight: 600; }
.gfoot { padding: 12px 26px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 40px; z-index: 46; transform: translateX(-50%) translateY(20px); background: var(--sheet); color: var(--ink); border: 1px solid var(--edge); box-shadow: var(--shadow-2); padding: 11px 20px; border-radius: var(--r-pill); font-weight: 600; font-size: 14px; opacity: 0; transition: opacity .3s, transform .3s var(--e-swell); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- controls overlay ---- */
.helpBox { width: min(1040px, 94vw); max-height: 94vh; overflow: auto; border-radius: var(--r-3); padding: 22px 30px 18px; box-sizing: border-box; }
.helpHead { display: flex; justify-content: space-between; align-items: center; gap: 16px; font: 700 24px/30px var(--font); letter-spacing: -.01em; margin-bottom: 14px; }
.helpHead .dim { font: 400 13px/1 var(--font); letter-spacing: 0; color: var(--ink-2); white-space: nowrap; }
.helpTabs, .lvtabs { display: flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--well); }
.helpTabs button, .lvtabs button { height: 34px; padding: 0 16px; border-radius: var(--r-pill); border: 0; background: transparent; color: var(--ink-2); font: 500 14px/1 var(--font); cursor: pointer; }
.helpTabs button.on, .lvtabs button.on { background: var(--foam); color: var(--navy); font-weight: 600; box-shadow: var(--shadow-1); }
.helpCols section.hidden { display: none; }
.helpCols h3 { margin: 0 0 4px; font-size: 18px; color: var(--ink); }
.helpCols .sub { font-size: 14px; color: var(--ink-2); margin-bottom: 12px; line-height: 1.45; }
.helpCols .rows { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 28px; align-items: start; }
.hgrp { background: var(--well); border-radius: var(--r-2); padding: 10px 16px 6px; }
.hgrp h4 { margin: 0 0 4px; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.hgrp .helpRow:last-child, .hgrp .helpEq:last-child { border-bottom: 0; }
.helpRow { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.helpRow .lbl, .helpEq .lbl { font-size: 15px; color: var(--ink); line-height: 1.3; }
.helpEq { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.helpEq .op { color: var(--ink-3); font-size: 18px; width: 14px; text-align: center; }
.helpEq .lbl { margin-left: 4px; }
.helpRow .lbl small, .helpEq .lbl small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.helpRow .lbl small b { color: var(--warn); font-weight: 600; }
.sailKeys { display: flex; gap: 12px; justify-content: space-between; padding: 6px 0 4px; }
.sk { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.sk small { font-size: 11px; color: var(--ink-3); }
.sk .k, .caps .k { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 9px; border-radius: var(--r-1); font: 600 14px/1 var(--mono); color: var(--navy); background: linear-gradient(to bottom, #ffffff, #e3ebf2); border: 1px solid #b6c4d1; box-shadow: 0 2px 0 #9fb0c0; box-sizing: border-box; }
.sk.off { color: var(--ink-3); }
.sk.off .k { background: var(--well); color: var(--ink-3); border-color: var(--line); box-shadow: none; }
.caps { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.caps .r { display: flex; gap: 4px; }
.caps .k.wide { min-width: 70px; }
.caps .k.ph { background: linear-gradient(to bottom, #ffe2b3, #ffc266); border-color: #d99a3a; box-shadow: 0 2px 0 #b97a22; font-style: italic; }
.caps .m { display: inline-grid; place-items: center; width: 28px; height: 40px; border-radius: 14px; border: 2px solid var(--ink-2); position: relative; background: var(--foam); box-sizing: border-box; }
.caps .m::after { content: ""; position: absolute; top: 7px; width: 4px; height: 11px; border-radius: 2px; background: var(--ink-2); }
.caps .m.wheel::after { background: var(--wind-app); }
.caps .sl { width: 100px; height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--wind-app) 55%, var(--line) 55%); position: relative; }
.caps .sl::after { content: ""; position: absolute; left: 50%; top: -6px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(4, 30, 70, .4); }
.helpFoot.hidden { display: none; }
.helpFoot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 14px; color: var(--ink-2); }
.helpFoot kbd { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; font: 600 13px/1 var(--mono); color: var(--navy); background: linear-gradient(to bottom, #fff, #e3ebf2); border: 1px solid #b6c4d1; border-radius: 7px; box-shadow: 0 2px 0 #9fb0c0; margin-right: 8px; vertical-align: middle; box-sizing: border-box; }

/* ---- Mist: bright sea haze for every cut. It replaces the fades to a dark screen. ---- */
#mist { position: fixed; inset: 0; z-index: 48; pointer-events: none; display: none; opacity: 0; background: linear-gradient(180deg, #eaf5fb 0%, #d5ebf7 55%, #c2e0f2 100%); }
:root[data-scene="dark"] #mist { background: linear-gradient(180deg, #1a2f48 0%, #0f2238 100%); }
#mist.show { display: block; animation: mistIn var(--mist-in, 800ms) ease forwards; }
#mist.show.lift { animation: mistOut var(--mist-out, 1200ms) cubic-bezier(.45, 0, .3, 1) forwards; }
@keyframes mistIn { from { opacity: 0; } to { opacity: var(--mist-peak, 1); } }
@keyframes mistOut { from { opacity: var(--mist-peak, 1); } to { opacity: 0; } }
@keyframes swell { from { opacity: 0; transform: translateY(16px); } }
/* the fleet screen rises out of the lifting mist */
.garage.arrive .gbox { animation: swell 700ms var(--e-swell) backwards; }

@media (prefers-reduced-motion: reduce) {
  #ui.condOpen .panel, .inst.trimOpen .trim, .inst.detailsOpen .instDetails, .garage.arrive .gbox { animation: none; }
  .btn, .card { transition: none; }
}
/* 1280 x 720 and smaller */
@media (max-width: 1340px), (max-height: 800px) {
  .inst { width: 360px; }
  .inst .cell .cv b { font-size: 22px; }
  .inst { --spd-len: 104px; }
  .helpBox { padding: 16px 22px 14px; }
  .helpRow .lbl, .helpEq .lbl { font-size: 14px; }
  .helpRow, .helpEq { padding: 4px 0; }
  .grid { gap: 8px; padding: 12px 14px; }
  .card .silwrap { min-height: 48px; }
  .ghead { padding: 12px 20px; gap: 16px; }
  .drawer { padding: 14px 18px; gap: 8px; }
}

/* ==================================================================================
   The journey screens: home, intro, challenges, brief, logbook, more
   (src/ui/home.js, intro.js, challenges.js, more.js). The left rule: the interface
   lives in a left column over open water, the boat sails right of centre.
   ================================================================================== */
.modes[hidden] { display: none; }                                  /* the old mode buttons: the dock and the keys replaced them */
body:is([data-screen="home"], [data-screen="intro"], [data-screen="challenges"], [data-screen="brief"], [data-screen="logbook"], [data-screen="more"], [data-screen="fleet"], [data-screen="unlock"], [data-screen="film"], [data-screen="studio"], [data-screen="tour"]) :is(.inst, .condChip, #ui .panel) { display: none; }
body:is([data-screen="intro"], [data-screen="film"], [data-screen="studio"], [data-screen="tour"]) .topright { display: none; }
#journey { position: fixed; inset: 0; z-index: 12; pointer-events: none; color: var(--ink); font: 15px/22px var(--font); user-select: none; }
#journey .screen { position: absolute; inset: 0; display: flex; align-items: center; padding: 76px 0 var(--gutter); box-sizing: border-box; }
#journey .screen[hidden], #journey .fleethost[hidden] { display: none; }
.jcol { width: 400px; max-height: 100%; margin-left: var(--gutter); display: flex; flex-direction: column; gap: 12px; pointer-events: auto; flex: none; }
.jcol.wide { width: 440px; }
.screen.in .jcol, .screen.in .jsheet { animation: gust var(--d-2) var(--e-out) backwards; }
@keyframes gust { from { opacity: 0; transform: translateX(-24px) skewX(-3deg); } }
.jcard { border-radius: var(--r-3); padding: 24px; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.jcard h2 { margin: 0; font: 700 24px/30px var(--font); letter-spacing: -.01em; color: var(--ink); }
.jcard .kicker, .jsheet .kicker { margin: 0; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.jcard .kicker i { font-style: normal; letter-spacing: 0; text-transform: none; font-weight: 400; }
.jcard .kicker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
.jcard .sub, .jcard .body { margin: 0; color: var(--ink-2); }
.jcard .body { color: var(--ink); }
.jcard .rew, .jcard .note { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.jcard .rew { color: var(--ink); font-weight: 500; }
.jcard > .float { margin-top: 16px; }
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* the float: the "Sail away..." button of the start screen, as the one primary button of a screen */
.float { height: 52px; padding: 0 28px; border-radius: var(--r-pill); border: 0; background: var(--foam); color: var(--navy); font: 700 17px/1 var(--font); letter-spacing: -.01em; cursor: pointer; flex: none;
  box-shadow: var(--shadow-2), inset 0 -4px 0 var(--stripe); transition: transform .18s var(--e-swell), box-shadow .18s; }
.float.away::after { content: "..."; color: var(--coral); margin-left: 2px; }
.float:hover { transform: translateY(-2px); box-shadow: var(--shadow-3), inset 0 -4px 0 var(--stripe); }
.float:active { transform: translateY(3px) scale(.985); box-shadow: var(--shadow-1), inset 0 -2px 0 var(--stripe); }
.float:focus-visible, .tlink:focus-visible, .sbtn:focus-visible, .lrow:focus-visible, .ltile:focus-visible, .goal:focus-visible, .dock button:focus-visible, .jpop button:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
.float[disabled] { background: var(--well); color: var(--ink-3); box-shadow: none; cursor: default; transform: none; }
.home .float { animation: bob 5s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -2px; } }
.tlink { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px 0; color: var(--sea); font: 600 13px/18px var(--font); cursor: pointer; align-self: flex-start; }
.tlink:hover { text-decoration: underline; }
.tlink.under { margin-left: 24px; color: var(--foam); text-shadow: 0 1px 8px rgba(4, 30, 70, .55); }
.tlink.fwd { margin-top: 8px; } .tlink.danger { color: var(--bad); }
.tlink kbd { margin-left: 6px; }
.sbtn { height: 36px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--sea-line); background: var(--sea-soft); color: var(--sea); font: 600 13.5px/1 var(--font); cursor: pointer; }
.jchip { background: var(--chip); border: 1px solid var(--edge); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--shadow-1); border-radius: var(--r-pill); color: var(--ink); transition: background-color 1.2s, color 1.2s, border-color 1.2s; }
.boatline { align-self: flex-start; padding: 5px 14px; font-size: 13px; line-height: 18px; font-weight: 500; }
.steps { display: flex; gap: 6px; justify-content: center; margin-top: 10px; } .steps i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); } .steps i.on { background: var(--ink); }
.jfld { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.jfld input { height: 44px; padding: 0 12px; border-radius: var(--r-1); border: 1px solid var(--line); background: var(--foam); color: var(--navy); font: 400 16px/1 var(--font); letter-spacing: 0; text-transform: none; user-select: text; }
.jfld input:focus { outline: 2px solid var(--sea); outline-offset: -1px; }
.jsw { display: flex; gap: 10px; padding: 3px; } .jsw .sw { width: 32px; height: 32px; }

/* home: two goal lines on one chip, the dock, the fleet on the horizon */
.goals { border-radius: var(--r-3); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.goal { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px; border: 0; border-radius: 16px; background: transparent; color: var(--ink); font: 13px/18px var(--font); text-align: left; cursor: pointer; }
.goal:hover { background: var(--sea-soft); }
.goal .gt { display: flex; justify-content: space-between; gap: 12px; } .goal b { font-weight: 600; } .goal i { font-style: normal; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jbar { display: block; height: 6px; border-radius: var(--r-pill); background: var(--well); overflow: hidden; } .jbar i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--sea); transition: width .5s var(--e-out); }
.dock { position: absolute; left: var(--gutter); bottom: var(--gutter); display: flex; gap: 2px; padding: 4px; pointer-events: auto; }
.dock button { height: 38px; padding: 0 16px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink); font: 600 14px/1 var(--font); cursor: pointer; }
.dock button:hover { background: var(--foam); color: var(--navy); box-shadow: var(--shadow-1); }
.coach { position: absolute; left: calc(var(--at) * 96px); bottom: 54px; width: 250px; padding: 12px 14px 8px; border-radius: var(--r-2); background: var(--sheet); border: 1px solid var(--edge); box-shadow: var(--shadow-2); font-size: 13px; line-height: 18px; animation: swell var(--d-3) var(--e-swell) backwards; }
.coach p { margin: 0 0 2px; } .coach::after { content: ""; position: absolute; left: 34px; bottom: -6px; width: 12px; height: 12px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.fleethost { position: absolute; right: var(--gutter); bottom: var(--gutter); pointer-events: none; }
.fleetline { display: flex; align-items: flex-end; gap: 2px; padding-bottom: 20px; border-bottom: 1px solid rgba(255, 255, 255, .55); color: #fff; }
.fl { position: relative; width: 60px; display: flex; justify-content: center; pointer-events: auto; }
.fl .sil { width: 46px; height: 38px; margin-bottom: -4px; transform-origin: 50% 100%; transform: scale(calc(1 - var(--far) * .07)); opacity: calc(.6 - var(--far) * .08); filter: drop-shadow(0 2px 6px rgba(4, 30, 70, .45)); }
.fl .sil path, .fl .sil rect { fill: currentColor; }
.fl.owned .sil { opacity: 1; } .fl.next .sil { opacity: .85; } .fl.far em { opacity: .8; font-weight: 500; }
.fl em { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); font: 600 11px/14px var(--font); font-style: normal; white-space: nowrap; text-shadow: 0 1px 6px rgba(4, 30, 70, .7); }
.fl.sel em { opacity: .85; font-weight: 500; }
.fleetline.draw .fl { animation: flin .5s var(--e-out) backwards; animation-delay: calc(var(--i) * 80ms + 300ms); }
@keyframes flin { from { opacity: 0; transform: translateY(8px); } }

/* challenges and brief */
.lrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: var(--r-2); border: 1px solid var(--line); background: var(--foam); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: transform .18s var(--e-swell), box-shadow .18s; flex: none; }
:root[data-scene="dark"] .lrow, :root[data-scene="dark"] .ltile { background: var(--well); }
.lrow:hover, .ltile:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.lrow .ln { display: flex; flex-direction: column; min-width: 0; } .lrow b { font-weight: 600; } .lrow i { font-style: normal; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.jcard .kicker + .lrow { margin-top: -2px; } .jcard .lrow + .kicker { margin-top: 8px; }
.jstars { display: inline-flex; gap: 2px; flex: none; } .jstars svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 1.2; stroke-linejoin: round; } .jstars svg.on { fill: var(--sun); stroke: var(--sun-ink); }
.tease { margin: 6px 0 0; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 18px; color: var(--ink-2); } .tease .ic { margin-top: 1px; }
.brief .jmap { width: 100%; height: auto; border-radius: var(--r-2); background: var(--well); border: 1px solid var(--line); box-sizing: border-box; flex: none; margin-top: 4px; }
.facts { margin: 4px 0 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 18px; }
.facts > div { display: grid; grid-template-columns: 92px 1fr; gap: 8px; } .facts dt { font: 600 10.5px/18px var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); } .facts dd { margin: 0; color: var(--ink); }
.facts .watch dd { color: var(--warn); font-weight: 500; }
.jgoals { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; line-height: 20px; color: var(--ink-2); } .jgoals li { display: flex; align-items: center; gap: 8px; } .jgoals li.ok { color: var(--ink); } .jgoals .jstars svg { width: 14px; height: 14px; }
.refuse { margin: 8px 0 0; display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-2); background: var(--well); font-size: 13px; line-height: 18px; font-weight: 500; color: var(--bad); }
.brief .links { display: flex; gap: 16px; margin-top: 4px; }
.brief > .float:not([disabled]) { position: sticky; bottom: 0; }                    /* the start stays in view when a long briefing scrolls */
.brief .rew { margin-top: 6px; }
.keys3 { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; } .keys3 > div { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 12px; } .keys3 b { font-weight: 500; font-size: 14px; }
.keys3 .caps { align-items: flex-start; } .keys3 .caps .r { align-items: center; } .keys3 .caps i { font-style: normal; color: var(--ink-3); margin: 0 2px; }

/* logbook: the one wide sheet, a reference view */
.jsheet { margin-left: var(--gutter); width: min(920px, calc(100vw - 2 * var(--gutter))); max-height: 100%; overflow: auto; padding: 22px 26px 24px; border-radius: var(--r-3); box-sizing: border-box; pointer-events: auto; border: 1px solid var(--edge); }
.lbar { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 18px; margin-bottom: 16px; } .lbar h2 { margin: 0; font: 700 24px/30px var(--font); letter-spacing: -.01em; }
.jtabs { display: flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--well); }
.jtabs button { height: 32px; padding: 0 14px; border-radius: var(--r-pill); border: 0; background: transparent; color: var(--ink-2); font: 500 13.5px/1 var(--font); cursor: pointer; }
.jtabs button.on { background: var(--foam); color: var(--navy); font-weight: 600; box-shadow: var(--shadow-1); }
.lgrid { display: grid; grid-template-columns: 176px repeat(var(--cols), minmax(118px, 170px)); gap: 7px; align-items: stretch; }
.lhead { font: 600 10.5px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); text-align: center; padding: 2px 0 4px; }
.ltype { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; } .ltype span { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--sea-soft); color: var(--sea); font-size: 15px; }
.ltype.teased { color: var(--ink-3); font-weight: 500; } .ltype.teased span { background: var(--well); color: var(--ink-3); }
.lnote { align-self: center; font-size: 13px; color: var(--ink-3); padding-left: 4px; }
.ltile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 6px; border-radius: var(--r-2); border: 1px solid var(--line); background: var(--foam); color: var(--ink); font: 500 12.5px/1.15 var(--font); text-align: center; cursor: pointer; transition: transform .18s var(--e-swell), box-shadow .18s; }
.ltile.played { background: var(--good-soft); }
.ltile.locked { background: transparent; border-style: dashed; color: var(--ink-3); cursor: default; } .ltile.locked:hover { transform: none; box-shadow: none; }
.ltile.noboat { color: var(--ink-2); } .ltile i { font-style: normal; font-size: 11px; color: var(--ink-3); display: inline-flex; gap: 4px; align-items: center; } .ltile i .ic { width: 12px; height: 12px; }
.ltile .jstars svg { width: 14px; height: 14px; }
.jsheet .kicker.off { margin: 18px 0 8px; } .jsheet .kicker i { font-style: normal; letter-spacing: 0; text-transform: none; font-weight: 400; margin-left: 6px; }
.lgrid.offg { grid-template-columns: repeat(4, minmax(118px, 170px)); }
.lown { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.log .tease { margin-top: 14px; }

/* more: a small menu above the dock; and the chip that leads back from the tour and the free camera */
.jpop { position: absolute; left: calc(var(--gutter) + 150px); bottom: calc(var(--gutter) + 54px); width: 250px; padding: 8px; border-radius: var(--r-3); display: flex; flex-direction: column; pointer-events: auto; }
.screen.in .jpop { animation: swell var(--d-3) var(--e-swell) backwards; }
.jpop > button { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 14px; border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink); font: 500 14.5px/1 var(--font); text-align: left; cursor: pointer; }
.jpop > button:hover { background: var(--sea-soft); } .jpop > button.quiet { color: var(--ink-2); font-size: 13.5px; }
.jpop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 8px; }
.jpop .plock { margin: 0; display: flex; gap: 8px; align-items: center; padding: 10px 14px; font-size: 13px; color: var(--ink-3); }
.jpop .ask { margin: 4px 14px 8px; font-size: 13.5px; line-height: 19px; font-weight: 500; } .jpop .askrow { display: flex; align-items: center; gap: 16px; padding: 0 10px 8px; }
#journey #scr-away { align-items: flex-end; justify-content: center; }
.jhint { display: flex; align-items: center; gap: 16px; padding: 4px 8px 4px 16px; font-size: 13px; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) { .screen.in .jcol, .screen.in .jsheet, .screen.in .jpop, .coach, .fleetline.draw .fl, .home .float { animation: none; } }
@media (max-width: 1340px), (max-height: 800px) {
  #journey .screen { padding-top: 68px; }
  .jcol { width: 360px; } .jcol.wide { width: 400px; }
  .jcard { padding: 20px; gap: 6px; }
  .boatline { display: none; }
  .fl { width: 52px; } .fl .sil { width: 40px; height: 33px; }
  .facts { font-size: 12.5px; } .jgoals { font-size: 12.5px; line-height: 18px; }
  .brief .jmap { height: 136px; object-fit: contain; }
  .ltile { min-height: 42px; } .lgrid { gap: 5px; grid-template-columns: 164px repeat(var(--cols), minmax(104px, 150px)); }
  .jsheet { padding: 16px 20px 18px; }
}

/* ---- sailing school (src/ui/school.js): the coach card over the free-sailing screen ---- */
#school { position: fixed; top: var(--gutter); left: 50%; transform: translateX(-50%); z-index: 15; font: 15px/22px var(--font); user-select: none; width: min(620px, calc(100vw - 2 * var(--gutter) - 460px)); min-width: 440px; pointer-events: none; }
.sccard { pointer-events: auto; display: flex; gap: 18px; align-items: flex-start; padding: 18px 22px; border-radius: var(--r-3); animation: gust var(--d-2) var(--e-out) backwards; }
.sccard .sctext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sccard .kicker { margin: 0; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.sccard h3 { margin: 0; font: 700 21px/26px var(--font); letter-spacing: -.01em; color: var(--ink); }
.sccard .body { margin: 0; font-size: 14px; line-height: 21px; color: var(--ink); }
.sckeys, .scsum { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 2px; }
.sckeys > div, .scsum > div { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.sckeys .caps i, .scsum .caps i { font-style: normal; align-self: center; color: var(--ink-3); }
.sckeys .caps .k, .scsum .caps .k { min-width: 28px; height: 28px; font-size: 12px; padding: 0 7px; }
.sckeys .caps .k.wide, .scsum .caps .k.wide { min-width: 58px; }
.sckeys b, .scsum b { font-weight: 500; }
.scgoal { display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 8px 12px; border-radius: var(--r-1); background: rgba(11, 42, 69, .06); font-size: 13px; color: var(--ink); }
:root[data-scene="dark"] .scgoal { background: rgba(255, 255, 255, .08); }
.scgoal .tick { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink-3); box-sizing: border-box; flex: none; transition: background .2s, border-color .2s; }
.scgoal .jbar { flex: 1; }
.scgoal .jbar i { transition: width .15s linear; }
.sccard.good .scgoal .tick { border-color: #1f9d6b; }
.sccard.ok .scgoal { background: rgba(31, 157, 107, .16); }
.sccard.ok .scgoal .tick { background: #1f9d6b; border-color: #1f9d6b; }
.sccard.ok .scgoal b::after { content: " · done"; color: #14724d; }
.scfoot { display: flex; justify-content: space-between; margin-top: 2px; }
.scfoot .tlink { font-size: 12px; }
.scdial { width: 92px; height: 92px; flex: none; margin-top: 4px; }
.scdial .ring { fill: rgba(255, 255, 255, .5); stroke: var(--line); stroke-width: 1.5; }
.scdial .nogo { fill: rgba(214, 69, 80, .32); }
.scdial .want { fill: rgba(31, 157, 107, .30); }
.scdial .wind { fill: none; stroke: #2f8fd6; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.scdial .boat path { fill: var(--navy); }
:root[data-scene="dark"] .scdial .ring { fill: rgba(255, 255, 255, .1); }
:root[data-scene="dark"] .scdial .boat path { fill: #eef6fb; }
.sccard.done .float { margin-top: 10px; align-self: flex-start; }
.sccard.done .tlink { align-self: flex-start; }
.sccard.done .tlink + .tlink { margin-top: 2px; }
@media (max-width: 1100px) { #school { width: calc(100vw - 2 * var(--gutter)); min-width: 0; top: 64px; } .scdial { display: none; } }

/* ==================================================================================
   Home as a hub (src/ui/home.js): a header with the boat, the rank, coins and stars;
   the Next card and what the player works towards on the left; a column of option
   tiles beside it, each with its progress. The boat keeps sailing right of centre.
   ================================================================================== */
:root { --hc1: 400px; --hc2: 300px; }
body:is([data-screen="home"], [data-screen="more"]) .topright { display: none; }   /* the header carries coins and rank here */
#journey #scr-home { align-items: stretch; padding: 0; }
#scr-home .hub { width: 100%; height: 100%; box-sizing: border-box; padding: 74px 0 var(--gutter) var(--gutter); display: grid; grid-template-columns: var(--hc1) var(--hc2); grid-template-rows: auto minmax(0, 1fr); gap: 14px 16px; align-content: start; }
#scr-home .hub > * { pointer-events: auto; }
.screen.in .hub > * { animation: gust var(--d-2) var(--e-out) backwards; } .screen.in .hub > .dock { animation-delay: 60ms; }
.hhead { grid-column: 1 / -1; display: flex; align-items: center; gap: 22px; padding: 10px 20px 10px 12px; border-radius: var(--r-3); }
.hboat { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink); text-align: left; cursor: pointer; font: inherit; min-width: 0; }
.hboat:hover { background: var(--sea-soft); }
.hboat .sil { width: 44px; height: 38px; flex: none; } .hboat .sil path, .hboat .sil rect { fill: var(--ink); }
.hboat > span { display: flex; flex-direction: column; min-width: 0; }
#scr-home .boatline { display: block; padding: 0; font: 600 15px/20px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.hboat i, .hrank i, .hstat i { font-style: normal; font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; }
.hrank { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 5px; }
.hrank > span { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; } .hrank b { font: 600 15px/20px var(--font); }
.hstat { display: flex; align-items: center; gap: 8px; } .hstat > span { display: flex; flex-direction: column; } .hstat b { font: 600 16px/20px var(--font); font-variant-numeric: tabular-nums; }
.hstat .icoin { width: 20px; height: 20px; } .hstat .jstars svg { width: 20px; height: 20px; }
.hmain { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
#scr-home .goals { border-radius: var(--r-3); padding: 14px 10px 8px; gap: 0; }
#scr-home .goals .kicker { margin: 0; padding: 0 12px 6px; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
#scr-home .goal { gap: 4px; padding: 8px 12px 10px; }
.goal .gd { font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scr-home .dock { position: static; display: flex; flex-direction: column; gap: 10px; padding: 0; background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; min-height: 0; overflow-y: auto; }
#scr-home .dock .tile { height: auto; display: flex; flex-direction: column; gap: 3px; padding: 12px 16px 13px; border-radius: 18px; border: 1px solid var(--edge); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--shadow-1), var(--inset); color: var(--ink); font: 13px/18px var(--font); text-align: left; cursor: pointer; flex: none; transition: transform .18s var(--e-swell), box-shadow .18s, background-color 1.2s; }
#scr-home .dock .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2), var(--inset); }
.tile:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
.tile .tt { display: flex; align-items: center; justify-content: space-between; gap: 8px; } .tile .tt b { font: 600 16px/22px var(--font); }
.tile .tt kbd { font-size: 10px; padding: 2px 6px; box-shadow: none; color: var(--navy); }
.tile .tl { color: var(--ink); } .tile .ts { color: var(--ink-2); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .jbar { margin-top: 6px; }
.tile .tk { font: 600 11px/14px var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--coral-ink); }
#scr-home .dock .tile.feature { background: var(--sheet); border: 2px solid var(--coral); padding: 14px 16px 15px; }
.tile.feature .tt b { font-size: 19px; line-height: 24px; }
.tile.feature .jbar i { background: var(--coral); }
#scr-home .dock .hmore { white-space: nowrap; height: auto; padding: 4px 0; border-radius: 0; background: none; box-shadow: none;  align-self: flex-start; margin-left: 6px; color: var(--foam); text-shadow: 0 1px 8px rgba(4, 30, 70, .6); flex: none; }
:root[data-scene="dark"] .hmore { color: var(--ink); }
/* the More menu opens beside the tile column */
.jpop { left: calc(var(--gutter) + var(--hc1) + var(--hc2) + 28px); bottom: var(--gutter); }
/* the logbook of achievements */
.achs .lbar { grid-template-columns: auto auto 1fr; } .achs .lbar .sub { margin: 0; color: var(--ink-2); font-size: 13px; }
.achs .kicker { margin: 14px 0 8px; }
.agrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ach { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border-radius: var(--r-2); background: var(--well); }
.ach .am { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--foam); color: var(--ink-3); border: 1px solid var(--line); margin-top: 1px; }
.ach.done .am { background: var(--good); color: #fff; border-color: transparent; }
.ach .at { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .ach b { font-weight: 600; font-size: 14px; } .ach .at > i { font-style: normal; font-size: 12.5px; line-height: 17px; color: var(--ink-2); }
.ach .ap { display: flex; align-items: center; gap: 8px; margin-top: 4px; } .ach .ap .jbar { flex: 1; } .ach .ap em { font-style: normal; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ach .ar { font-size: 12px; color: var(--sun-ink); font-weight: 600; white-space: nowrap; }
.ach.secret b, .ach.secret .at > i { color: var(--ink-3); }
@media (max-width: 1340px), (max-height: 800px) {
  :root { --hc1: 360px; --hc2: 264px; }
  #scr-home .hub { padding-top: 68px; gap: 10px 14px; }
  .hhead { gap: 16px; padding: 8px 16px 8px 10px; } .hboat .sil { width: 36px; height: 30px; } #scr-home .boatline { max-width: 150px; }
  #scr-home .dock .tile { padding: 9px 14px 10px; } #scr-home .dock .tile.feature { padding: 11px 14px 12px; } .tile .tt b { font-size: 15px; } .tile.feature .tt b { font-size: 17px; }
  .tile .jbar { margin-top: 4px; } #scr-home .dock { gap: 8px; }
  .hmain { gap: 10px; } #scr-home .goal { padding: 6px 12px 8px; }
  .agrid { grid-template-columns: 1fr 1fr; }
}

/* ---- the fleet tour (src/ui/tourfleet.js): a caption bottom left, the boat under the cinematic camera ---- */
#scr-home .dock .tile.compact { padding-top: 10px; padding-bottom: 11px; }
#journey #scr-tour { align-items: flex-end; padding-bottom: var(--gutter); }
.tf { margin-left: var(--gutter); width: 420px; box-sizing: border-box; padding: 20px 22px 14px; border-radius: var(--r-3); display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.screen.in .tf { animation: gust var(--d-2) var(--e-out) backwards; }
.tf .kicker { margin: 0; font: 600 11px/14px var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.tf .kicker i { font-style: normal; } .tf h2 { margin: 0; font: 700 26px/32px var(--font); letter-spacing: -.01em; }
.tf-facts { margin: 0; font-size: 14px; color: var(--ink); } .tf-blurb { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.tf-label { margin: 6px 0 0; display: flex; justify-content: space-between; font: 600 11px/14px var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); } .tf-label i { font-style: normal; letter-spacing: 0; text-transform: none; color: var(--ink); }
.tf-reqs { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 17px; }
.tf-reqs li { display: grid; grid-template-columns: 1fr 90px; gap: 10px; align-items: center; } .tf-reqs li span { display: flex; gap: 6px; align-items: center; min-width: 0; } .tf-reqs li.ok { color: var(--good); }
.tf-tease, .tf-own { margin: 6px 0 0; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 18px; color: var(--ink-2); } .tf-own { color: var(--good); font-weight: 600; }
.tf-nav { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tf-arrow { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--sea-line); background: var(--sea-soft); color: var(--sea); display: grid; place-items: center; cursor: pointer; padding: 0; }
.tf-arrow[disabled] { opacity: .35; cursor: default; }
.tf-dots { display: flex; gap: 5px; flex: 1; justify-content: center; } .tf-dots i { position: relative; width: 14px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.tf-dots i.seen { background: var(--ink-3); } .tf-dots i.on b { position: absolute; inset: 0; background: var(--sea); transform-origin: left; animation: tfrun var(--t) linear forwards; }
@keyframes tfrun { from { transform: scaleX(0); } }
.tf-nav .tlink { margin-left: 4px; white-space: nowrap; }
body[data-screen="tour"] #ui .title { opacity: .9; }
@media (max-width: 1340px), (max-height: 800px) { .tf { width: 380px; padding: 16px 18px 12px; } .tf h2 { font-size: 22px; line-height: 28px; } }
/* 720 px high: six tiles fit when the least needed lines step aside */
@media (max-height: 800px) {
  #scr-home .dock { gap: 6px; }
  #scr-home .dock .tile, #scr-home .dock .tile.compact { padding-top: 7px; padding-bottom: 8px; }
  #scr-home .dock .tile.feature { padding-top: 9px; padding-bottom: 10px; }
  #scr-home .dock :is([data-act="sail-free"], [data-act="achievements"]) .ts, #scr-home .dock [data-act="tour"] .tl { display: none; }
}

/* ---- top centre while sailing: speed, trim, distance and the one hint that matters (src/main.js, updateTopHud) ---- */
.tophud { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 5; }
body[data-screen="sail"] .tophud.on { display: flex; }
.tophud.inlevel { top: 96px; }
.tophud .th-row { display: flex; align-items: center; gap: 14px; height: 46px; padding: 0 20px; border-radius: var(--r-pill); color: var(--ink); border: 1px solid var(--edge); background: var(--glass); box-shadow: var(--shadow-2), var(--inset); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tophud .th-spd b { font: 700 26px/1 var(--font); letter-spacing: -.02em; }
.tophud .th-spd small { margin-left: 4px; font-size: 13px; color: var(--ink-2); }
.tophud .th-trim, .tophud .th-dist { font-size: 14px; color: var(--ink-2); }
.tophud .th-trim b, .tophud .th-dist b { color: var(--ink); font-weight: 600; font-size: 16px; }
.tophud .th-trim.good b { color: var(--good); }
.tophud .th-sep { width: 1px; height: 22px; background: var(--line); }
.tophud .th-hint { max-width: min(560px, calc(100vw - 2 * var(--gutter))); padding: 5px 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--warn); background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tophud .th-hint:empty { display: none; }
.tophud .th-hint.bad { color: var(--bad); }
:root[data-scene="dark"] .tophud .th-row, :root[data-scene="dark"] .tophud .th-hint { background: rgba(12, 30, 51, .78); }
/* the bottom strip keeps heading, wind and the drawers; speed, trim and the hint moved to the top */
body[data-screen="sail"] .inst .cells .cell:first-child, body[data-screen="sail"] .inst .alert, body[data-screen="sail"] .inst .trimline > span:not(.drawBtns) { display: none; }
/* a coin earned at the helm: a small +1 that rises beside the speed and fades */
.tophud .th-row { position: relative; }
.coinpop { position: absolute; right: -10px; top: 50%; width: 0; height: 0; pointer-events: none; }
.coinpop i { position: absolute; left: 0; top: -14px; padding: 6px 11px; border-radius: var(--r-pill); font: 700 14px/1 var(--font); font-style: normal; color: #7a5200; background: #fff3cf; border: 1px solid #f0d27a; box-shadow: var(--shadow-1); white-space: nowrap; animation: coinRise 1.6s var(--e-out) forwards; }
:root[data-scene="dark"] .coinpop i { color: #ffd766; background: rgba(40, 32, 8, .85); border-color: rgba(255, 207, 74, .45); }
@keyframes coinRise { 0% { opacity: 0; transform: translate(0, 8px) scale(.8); } 15% { opacity: 1; transform: translate(0, 0) scale(1.08); } 100% { opacity: 0; transform: translate(6px, -30px) scale(1); } }
@media (prefers-reduced-motion: reduce) { .coinpop i { animation-duration: .8s; } }
@media (max-width: 700px) { .tophud { top: 64px; } .tophud .th-row { gap: 10px; padding: 0 14px; height: 40px; } .tophud .th-spd b { font-size: 22px; } }

/* sound on or off (M): a short note at the bottom centre */
.soundchip { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 10px); z-index: 46; padding: 8px 16px; border-radius: var(--r-pill); font: 600 13px/1 var(--font); color: var(--ink); background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; white-space: pre; }
.soundchip.show { opacity: 1; transform: translate(-50%, 0); }

/* the navigation dock: Home and the sound, the same corner on every screen (src/ui/navdock.js) */
.navdock { position: fixed; right: 16px; bottom: 16px; z-index: 47; display: flex; gap: 6px; align-items: center; }
.navdock[hidden], .navdock [hidden] { display: none !important; }
.navdock button { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: var(--r-pill); font: 600 13px/1 var(--font); color: var(--ink); background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow-1); cursor: pointer; opacity: .8; transition: opacity .2s, transform .15s; }
.navdock .nd-sound { width: 32px; padding: 0; justify-content: center; }
.navdock button:hover, .navdock button:focus-visible { opacity: 1; transform: translateY(-1px); }
.navdock button:focus-visible { outline: 2px solid #2f8fd6; outline-offset: 2px; }
.navdock svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.navdock .nd-sound[aria-pressed="false"] { color: var(--ink-2); }
:root[data-scene="dark"] .navdock button { background: rgba(12, 30, 51, .8); }
/* the level's key hints sit bottom right too: they move left of the dock */
body .gh-keys { right: 140px; }

/* the rose shows every sail of the rig: jib and staysail from the bow, the mizzen boom aft (body.hasJib etc. from the rig) */
#rose .rJib { stroke: #2f8fd6; }
#rose .rSvgJib, #rose .rSvgStays, #rose .rSvgMizzen { display: none; }
body.hasJib #rose .rSvgJib, body.hasStays #rose .rSvgStays, body.hasMizzen #rose .rSvgMizzen { display: inline; }
