/* True Wind — marine instrument panels over a live 3D sea. Single, deliberately dark visual world. */
:root {
  --ink: #0e1a24;
  --ink-2: #13232f;
  --glass: rgba(11, 22, 31, 0.78);
  --line: rgba(233, 238, 242, 0.12);
  --text: #e9eef2;
  --muted: #8ea2b1;
  --accent: #ff7a1a;
  --port: #e0413a;
  --stbd: #27b36a;
  --amber: #f2b33d;
  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--ink); color: var(--text); font: 14px/1.4 var(--body); overflow: hidden; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
a { color: var(--text); }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.panel { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 6px; }
.eyebrow { font: 600 11px/1 var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.big { font: 800 40px/1 var(--display); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.big-ish { font: 800 28px/1.1 var(--display); }
.chip { background: transparent; border: 1px solid var(--line); border-radius: 3px; padding: 2px 8px; font: 500 12px var(--cond); letter-spacing: .06em; cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--text); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; font: 600 12px var(--cond); text-align: center; background: var(--ink-2); margin-right: 3px; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .panel, #hud button, #hud input { pointer-events: auto; }
#race-card { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; width: 230px; padding: 10px 12px; }
.rc-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
#rc-clock { margin: 6px 0 2px; }
#rc-clock.pre { color: var(--amber); }
#rc-leg { font: 500 14px var(--cond); letter-spacing: .03em; }
#rc-standings { margin: 8px 0 0; padding: 0; list-style: none; font: 500 13px var(--cond); max-height: 190px; overflow: auto; }
#rc-standings li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; padding: 2px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#rc-standings li.me { color: var(--accent); }
#toast { position: absolute; top: calc(18px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); font: 700 22px/1.1 var(--display); letter-spacing: .04em; text-shadow: 0 2px 10px rgba(0,0,0,.6); text-align: center; transition: opacity .4s; opacity: 0; white-space: nowrap; }
#toast.show { opacity: 1; }
/* racing: the next mark, over the mark itself or pinned to the screen edge pointing its way */
#nextmark { position: absolute; left: 0; top: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 1px; font: 600 12px/1.1 var(--cond); letter-spacing: .05em; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.8); white-space: nowrap; will-change: transform; }
#nextmark .nm-arrow { width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 12px solid var(--amber); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
#nextmark #nm-name { color: var(--amber); text-transform: uppercase; }
#nextmark #nm-dist { font-variant-numeric: tabular-nums; }
#nextmark.edge .nm-arrow { order: 3; }
/* the crew / coach line (hud.crew): what the automatic crew or the coach did and why */
/* (above the compass tape, which sits at 146 px) */
#crew { position: absolute; left: 50%; bottom: calc(186px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 6px); display: flex; gap: 8px; align-items: baseline; max-width: min(640px, calc(100% - 32px)); padding: 4px 12px 5px; border-radius: 4px; background: rgba(8,18,26,.72); font: 500 14px/1.25 var(--cond); letter-spacing: .02em; color: #e4ecf1; opacity: 0; transition: opacity .35s, transform .35s; pointer-events: none; }
#crew.show { opacity: 1; transform: translate(-50%, 0); }
#crew b { font: 700 10px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: #8fc2ea; flex: none; }
#crew.coach b { color: var(--amber); } #crew.warn b { color: #ff8a6a; }
/* the line in your hands: name, purchase, a big bar, load, winch turns, the sail's shape */
#work { position: absolute; left: 50%; bottom: calc(222px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: 300px; padding: 7px 10px 8px; font: 500 12px var(--cond); letter-spacing: .03em; transition: opacity .3s; pointer-events: none; }
#work.out { opacity: 0; }
#work .wk-h { display: flex; align-items: center; gap: 6px; }
#work .wk-h i { width: 16px; height: 7px; border-radius: 4px; }
#work .wk-h b { font: 700 14px var(--cond); } #work .wk-h em { font-style: normal; color: var(--muted); }
#work .wk-st { font: 600 9px/1 var(--cond); letter-spacing: .05em; padding: 2px 4px; border-radius: 3px; border: 1px solid var(--line); }
#work .wk-st.free { background: #b3322a; border-color: #e0413a; color: #fff; } #work .wk-st.busy { background: rgba(80,150,220,.22); border-color: #4d8fd0; } #work .wk-st.slip { background: #e08a1a; color: #1a1206; }
#work .wk-dir { margin-left: auto; color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: .1em; }
#work .wk-bar { position: relative; height: 8px; margin: 6px 0 4px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
#work .wk-bar span { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--rc, var(--accent)) 70%, #fff); border-radius: 4px; transition: width .1s linear; }
#work .wk-f { display: flex; gap: 10px; align-items: baseline; font-variant-numeric: tabular-nums; } #work .wk-f b { font: 700 16px var(--cond); min-width: 44px; } #work .wk-f span { color: #c5d1da; }
#work .wk-s { margin-top: 3px; color: #9fd0f5; font-variant-numeric: tabular-nums; }
#alert { position: absolute; top: calc(56px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); font: 600 15px var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: var(--amber); padding: 3px 10px; border-radius: 3px; opacity: 0; transition: opacity .3s; }
#alert.show { opacity: 1; }
#alert.bad { background: var(--port); color: #fff; }

#map-card { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; width: 240px; padding: 6px; }
#minimap { width: 100%; aspect-ratio: 1; display: block; border-radius: 4px; cursor: crosshair; }
.map-foot { display: flex; justify-content: space-between; font: 500 12px var(--cond); padding: 4px 2px 0; letter-spacing: .04em; }

#instruments { position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: grid; grid-template-columns: repeat(6, 92px); gap: 0; padding: 0; overflow: hidden; }
.inst { padding: 6px 10px 7px; border-right: 1px solid var(--line); border-top: 1px solid var(--line); }
.inst:nth-child(-n+6) { border-top: 0; }
.inst:nth-child(6n) { border-right: 0; }
.inst .lab { font: 600 10px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.inst .val { font: 700 28px/1.05 var(--display); font-variant-numeric: tabular-nums; margin-top: 3px; white-space: nowrap; }
.inst .val small { font: 500 12px var(--cond); color: var(--muted); margin-left: 2px; }
.inst.port .val { color: var(--port); } .inst.stbd .val { color: var(--stbd); } .inst.warn .val { color: var(--amber); } .inst.bad .val { color: var(--port); }

#rig { position: absolute; left: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: 250px; max-height: calc(100% - 175px); display: flex; flex-direction: column; }
#rig header, #polar-card header, #physics header { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 6px; }
#rig-body { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 0 10px 6px; }
#rig-body::-webkit-scrollbar { width: 5px; } #rig-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
#rig.collapsed #rig-body { display: none; }
.rg { border-top: 1px solid var(--line); padding: 4px 0 3px; }
.rg h3 { margin: 0 0 4px; font: 600 12px var(--cond); letter-spacing: .1em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.tt { display: flex; gap: 3px; }
.st { font: 600 10px/1 var(--cond); letter-spacing: .08em; padding: 3px 5px; border-radius: 2px; background: var(--ink-2); color: var(--muted); }
.st-ok { background: rgba(39,179,106,.2); color: #6fe0a2; }
.st-luff { background: rgba(242,179,61,.2); color: var(--amber); }
.st-stall { background: rgba(224,65,58,.22); color: #ff8a84; }
.sl { display: grid; grid-template-columns: 78px 1fr 44px; align-items: center; gap: 6px; font: 500 12px var(--cond); letter-spacing: .03em; }
.sl label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl output { text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: var(--line); border-radius: 2px; }
input[type=range]::-moz-range-track { height: 3px; background: var(--line); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); margin-top: -4.5px; border: 0; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 0; }
.loads { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font: 500 12px var(--cond); font-variant-numeric: tabular-nums; }
.loads span { color: var(--muted); }
.toggles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip.on { color: var(--ink); background: var(--accent); border-color: var(--accent); }
/* the rig panel's Boat section: damage, water, anchor, lines, crew fatigue (js/gear.js) */
.dmg { display: grid; grid-template-columns: 52px 1fr; gap: 2px 8px; font: 500 12px/1.3 var(--cond); font-variant-numeric: tabular-nums; }
.dmg > span { color: var(--muted); }
.dmg b { font-weight: 500; }
.dmg small { color: var(--muted); font-size: 11px; }
.dmg .warn, .dmg em.warn { color: var(--amber); } .dmg .bad, .dmg em.bad { color: #ff8a84; }
.dmg em { font-style: normal; }
.dmg .crew { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.meter { display: inline-block; width: 38px; height: 5px; background: var(--ink-2); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.meter > i { display: block; height: 100%; background: #6fe0a2; }
#gear-rg h3 .chip { margin-left: auto; font-size: 11px; padding: 1px 6px; }
#gear-rg h3 .muted { margin-left: 6px; }
.chip.mob { color: #ff8a84; border-color: rgba(224,65,58,.5); }
.chip.mob.on { color: #fff; background: #d0102a; border-color: #d0102a; }

#polar-card { position: absolute; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: 240px; }
#polar { width: 100%; display: block; }
#physics { position: absolute; right: 264px; top: calc(12px + env(safe-area-inset-top, 0px)); width: 250px; max-height: calc(100% - 140px); overflow: auto; }
#phys-body { padding: 0 10px 10px; font: 500 12px/1.5 var(--cond); font-variant-numeric: tabular-nums; }
#phys-body .kv { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 1px 0; }
#phys-body .kv span:first-child { color: var(--muted); }
#keys { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(126px + env(safe-area-inset-bottom, 0px)); animation: keysfade 1s ease 20s forwards; white-space: nowrap; color: #c5d1da; font: 500 12px var(--cond); letter-spacing: .04em; text-align: right; text-shadow: 0 1px 4px rgba(0,0,0,.8); }

/* ---------------- Menu ---------------- */
.overlay { position: fixed; inset: 0; background: radial-gradient(ellipse at 30% 20%, rgba(14,26,36,.55), rgba(8,14,20,.92)); display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 24px 16px; }
.menu-inner { width: min(1180px, 100%); }
.menu-head h1 { font: 800 clamp(48px, 8vw, 96px)/0.9 var(--display); letter-spacing: .01em; margin: 8px 0 10px; text-transform: uppercase; }
.menu-head h1::after { content: ''; display: block; width: 72px; height: 4px; background: var(--accent); margin-top: 12px; }
.lede { max-width: 64ch; color: #c5d1da; margin: 0 0 18px; font-size: 15px; }
.menu-grid { display: grid; grid-template-columns: 1.05fr 1.2fr 1fr; gap: 20px; }
.menu-grid h2 { font: 600 13px var(--cond); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.cards { display: grid; gap: 8px; }
.card { text-align: left; background: var(--glass); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; cursor: pointer; display: grid; gap: 3px; }
.card:hover { border-color: rgba(233,238,242,.3); }
.card.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.card .t { font: 700 20px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; }
.card .s { font: 500 12px var(--cond); color: var(--muted); letter-spacing: .03em; }
.card .d { font-size: 13px; color: #c5d1da; }
/* class picker: group tabs and a search over a short scrolling list, then the chosen class's card */
#boat-list { gap: 8px; }
.cls-tools { display: grid; gap: 6px; }
.cls-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.cls-tab { background: transparent; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; color: var(--muted); font: 600 12px var(--cond); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.cls-tab.on { color: var(--text); border-color: var(--accent); }
.cls-search { background: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 6px 9px; color: var(--text); font: 500 14px var(--cond); min-width: 0; }
.cls-list { display: grid; gap: 4px; max-height: 232px; overflow: auto; padding-right: 2px; }
.card.cls-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 10px; }
.card.cls-row[hidden] { display: none; }
.cls-row .n { font: 700 16px/1.1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
.cls-row .g { font: 500 11px var(--cond); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.cls-detail { display: grid; gap: 3px; background: var(--glass); border: 1px solid var(--accent); border-radius: 6px; padding: 10px 12px; box-shadow: inset 3px 0 0 var(--accent); }
.cls-detail .t { font: 700 20px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; }
.cls-detail .s { font: 500 12px var(--cond); color: var(--muted); letter-spacing: .03em; }
.cls-detail .d { font-size: 13px; color: #c5d1da; }
.venues { grid-template-columns: 1fr 1fr; max-height: 440px; overflow: auto; padding-right: 2px; }
.venues .card .t { font-size: 17px; }
.custom-loc { margin-top: 12px; }
.custom-loc label { font: 600 12px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; background: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; color: var(--text); font: 500 14px var(--cond); }
.field { margin: 10px 0; }
.field label { display: flex; justify-content: space-between; font: 600 12px var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field label b { color: var(--text); font-weight: 600; letter-spacing: .02em; text-transform: none; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.seg-b { background: transparent; border: 0; padding: 9px; cursor: pointer; font: 600 15px var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.seg-b.on { background: var(--accent); color: var(--ink); }
.checks { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; color: #c5d1da; }
.checks input { accent-color: var(--accent); margin-right: 6px; }
.menu-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin: 20px 0 0; padding: 18px 0 calc(12px + env(safe-area-inset-bottom, 0px)); position: sticky; bottom: 0; background: linear-gradient(to top, rgba(8,14,20,.97) 72%, rgba(8,14,20,0)); z-index: 2; }
/* the action bar: credits small on the left, Resume and Cast off on the right under the conditions you set last */
.menu-foot > span { order: -1; margin-right: auto; }
@media (max-width: 640px) { .menu-foot > span { order: 3; flex: 1 1 100%; text-align: center; margin: 0; } .menu-foot .btn { flex: 1 1 0; } }
.btn { border-radius: 4px; padding: 10px 16px; cursor: pointer; font: 700 16px var(--cond); letter-spacing: .1em; text-transform: uppercase; border: 1px solid var(--line); background: transparent; }
.btn.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); padding: 12px 28px; font-size: 19px; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost:hover { border-color: rgba(233,238,242,.35); }
body.racing .race-only { display: block; }
body.online .online-only { display: block; }
.online-only { display: none; margin-top: 8px; }
.online-only p { margin: 0 0 6px; }
#rc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#rc-actions:empty { display: none; }
#rc-actions .chip { font-size: 13px; padding: 4px 10px; }
.net-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--stbd); margin-right: 5px; }
.net-dot.off { background: var(--amber); }
.race-only { display: none; }

#help { z-index: 20; align-items: center; }
.help-inner { width: min(760px, 100%); padding: 18px 20px; }
.help-inner h2 { font: 800 26px var(--display); text-transform: uppercase; margin: 0 0 10px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 13px; margin-bottom: 14px; }
.help-grid > div { display: flex; gap: 6px; align-items: baseline; }
.help-grid span { color: #c5d1da; }
#loading { z-index: 30; align-items: center; }
#loading .panel { padding: 18px 24px; min-width: 260px; }

@media (max-width: 1100px) {
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .menu-grid section:last-child { grid-column: 1 / -1; }
  #instruments { grid-template-columns: repeat(6, 74px); }
  .inst .val { font-size: 22px; }
  #physics { right: 12px; top: 270px; }
}
@media (max-width: 720px) {
  .menu-grid { grid-template-columns: 1fr; }
  .venues { grid-template-columns: 1fr; }
  #map-card { width: 150px; }
  #race-card { width: 170px; }
  #rig, #polar-card, #keys { display: none; }
  #instruments { grid-template-columns: repeat(3, 1fr); width: calc(100% - 24px); }
  .inst:nth-child(-n+6) { border-top: 1px solid var(--line); }
  .inst:nth-child(-n+3) { border-top: 0; }
  .inst:nth-child(3n) { border-right: 0; }
  .help-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { #toast, #alert { transition: none; } }

@keyframes keysfade { to { opacity: 0; visibility: hidden; } }

#grab-tip { position: absolute; pointer-events: none; background: var(--glass); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 4px; padding: 5px 9px; display: grid; gap: 1px; font: 500 12px var(--cond); letter-spacing: .03em; max-width: 240px; z-index: 5; }
#grab-tip b { font: 700 15px var(--display); letter-spacing: .03em; text-transform: uppercase; }
#grab-tip span { font-variant-numeric: tabular-nums; }
#grab-tip em { color: var(--muted); font-style: normal; }
.lines { display: grid; gap: 1px; }
.ln { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; font: 500 12px var(--cond); letter-spacing: .03em; }
.nb { display: inline-flex; gap: 2px; }
.nbtn { min-width: 30px; padding: 1px 5px; font: 600 11px var(--cond); letter-spacing: .03em; color: var(--text); background: var(--ink-2); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; touch-action: none; user-select: none; }
.nbtn:hover { border-color: rgba(255,122,26,.6); }
.nbtn.held { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.acts { align-items: center; }
#rig { width: 318px; }
.ln i { width: 16px; height: 7px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.08); }
.ln span.rl { color: color-mix(in srgb, var(--rc) 42%, #c9d3da); }
.ln em.pr { font-style: normal; font-size: 10px; color: var(--muted); opacity: .85; }
.ln span { color: var(--muted); }
.ln b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; }
/* each line's setting as a bar under its row (in the rope's colour), animated; a row with hands on it lights up */
.ln { position: relative; padding-bottom: 3px; }
.ln .bar { position: absolute; left: 22px; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: rgba(255,255,255,.07); pointer-events: none; }
.ln .bar::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--v, 0%); border-radius: 1px; background: color-mix(in srgb, var(--rc, #9aa1a8) 75%, #fff); opacity: .75; transition: width .12s linear; }
.ln.work { background: linear-gradient(90deg, rgba(255,138,42,.16), rgba(255,138,42,0) 80%); border-radius: 3px; }
.ln.work .bar { height: 3px; } .ln.work .bar::after { opacity: 1; }
.ln.work b { color: var(--accent); }
.shape { font: 500 11px var(--cond); letter-spacing: .02em; color: var(--muted); padding: 0 0 3px; font-variant-numeric: tabular-nums; }
.shape b { color: #d7e2e9; font-weight: 600; }
.shape i { font-style: normal; font-size: 8px; margin-left: 1px; } .shape i.up { color: #7fd48a; } .shape i.dn { color: #ff9a6a; }
.rg p.hint { margin: 2px 0 4px; font: 500 12px/1.35 var(--cond); color: var(--muted); }
.sl2 { display: flex; justify-content: space-between; align-items: center; font: 500 12px var(--cond); color: var(--muted); padding: 1px 0; }
.tide-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.tide-row .tseg2 { grid-template-columns: 1fr 1fr; flex: 0 0 auto; }
.tide-row .tseg2 .seg-b { font-size: 12px; padding: 5px 9px; }
.tide-row input[type=date] { flex: 1; min-width: 0; background: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; color: var(--text); font: 500 13px var(--cond); color-scheme: dark; }
.tide-row input[type=range] { flex: 1; min-width: 0; }
.tide-f.steady input[type=date], .tide-f:not(.steady) input[type=range] { display: none; }
.tide-f.notide .tseg2 { display: none; }
.wseg { margin-top: 10px; }
.wseg .seg-b { font-size: 13px; padding: 7px; }
.trseg { grid-template-columns: repeat(4, 1fr); margin-top: 6px; }
.tseg { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.tseg .seg-b { font-size: 12px; padding: 6px 8px; flex: 1 1 22%; }
.lk { display: inline-flex; align-items: center; gap: 3px; font: 600 9px/1 "Barlow Condensed", sans-serif; letter-spacing: .04em; padding: 2px 4px; margin-right: 4px; border-radius: 3px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #cfd8df; cursor: pointer; min-width: 54px; }
.lk .ic { display: inline-flex; } .lk .lt { min-width: 30px; text-align: left; white-space: nowrap; }
.lk.warn { border-color: var(--amber); color: var(--amber); }
.lk.busy { background: rgba(80,150,220,.22); border-color: #4d8fd0; color: #d8e8f6; }
.lk.free { background: #b3322a; border-color: #e0413a; color: #fff; }
.lk.slip { background: #e08a1a; border-color: #ffb040; color: #1a1206; animation: lkslip .3s steps(2) infinite; }
@keyframes lkslip { 50% { background: #b3322a; color: #fff; } }
.lk-sp { display: inline-block; min-width: 58px; }

/* ---------------- toolbar, pause, results, touch ---------------- */
.tools { display: flex; gap: 4px; padding: 6px 2px 0; }
.tools .chip { flex: 1; padding: 5px 0; font-size: 13px; color: #c5d1da; min-height: 28px; }
.tools .chip[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
#tb-pause[aria-pressed="true"] { background: var(--amber); color: var(--ink); border-color: var(--amber); text-decoration: none; }
#tb-rig[aria-pressed="false"], #tb-pause[aria-pressed="false"] { text-decoration: none; }
.chip:focus-visible, .nbtn:focus-visible, .lk:focus-visible, .card:focus-visible, .seg-b:focus-visible, .tbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#paused-badge { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); font: 800 34px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; padding: 12px 22px; background: var(--glass); border: 1px solid var(--line); border-radius: 6px; color: var(--amber); }
.note { margin: 2px 0 0; min-height: 0; }
.note.warn { color: var(--amber); }
.help-inner ul.first { margin: 0 0 14px; padding-left: 18px; display: grid; gap: 5px; font-size: 14px; color: #dbe3e9; }
.help-inner { max-height: calc(100vh - 32px); overflow: auto; }
#rig header .chip + .chip { margin-left: 4px; }
#rig .rg.adv, #rig .ln.adv { display: none; }
#rig.adv .rg.adv { display: block; }
#rig.adv .ln.adv { display: grid; }
.ln span { overflow-wrap: anywhere; line-height: 1.1; }   /* long line names wrap onto a second line rather than being cut */

#results { z-index: 18; align-items: center; background: rgba(8,14,20,.55); }
.res-inner { width: min(460px, 100%); padding: 18px 20px; }
.res-inner h2 { font: 800 30px/1.1 var(--display); text-transform: uppercase; margin: 4px 0 10px; }
#res-list { margin: 0 0 14px; padding: 0; list-style: none; font: 500 16px var(--cond); max-height: 50vh; overflow: auto; }
#res-list li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#res-list li.me { color: var(--accent); font-weight: 700; }
#res-list li .muted { font-weight: 500; }
#res-list li.dsq span:last-child { color: var(--port); }
#res-rules { margin: -4px 0 14px; }
#res-inc { margin: 4px 0 0; padding: 0; list-style: none; font: 500 14px var(--cond); max-height: 22vh; overflow: auto; }
#res-inc li { display: grid; grid-template-columns: 40px 1fr; gap: 8px; padding: 3px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#res-inc li.me { color: var(--text); }
#res-inc li:not(.me) { color: var(--muted); }
#res-inc b { color: var(--amber); font-weight: 700; }
#rules-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#touch { display: none; }
body.touch #touch { display: flex; position: absolute; left: 12px; right: 12px; bottom: calc(130px + env(safe-area-inset-bottom, 0px)); justify-content: space-between; align-items: flex-end; gap: 10px; pointer-events: none; }
.tp { display: grid; gap: 6px; pointer-events: auto; }
.tp-helm { grid-template-columns: 64px 64px; grid-template-rows: auto auto; }
.tp-helm .tbtn:first-child { grid-row: 1; grid-column: 1; }
.tp-helm .tbtn:last-child { grid-row: 1; grid-column: 2; }
.tp-helm #tp-centre { grid-row: 2; grid-column: 1 / 3; }
.tp-trim { grid-template-columns: auto 58px 58px; align-items: center; }
.tp-trim #tp-auto { grid-column: 1 / 4; }
.tp-trim.has-gen #tp-auto { grid-column: 1 / 3; }
.tp-trim #tp-gen[hidden] { display: none; }
.tp-trim .tp-sel { min-height: 44px; padding: 0 8px; background: rgba(11,22,31,.5); color: #c5d1da; }
body.no-jib .tl-jib, body.no-jib .tp-jib { display: none; }
.tl { font: 600 12px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: #c5d1da; text-shadow: 0 1px 3px rgba(0,0,0,.8); text-align: right; }
.tbtn { min-height: 52px; border-radius: 8px; border: 1px solid rgba(233,238,242,.22); background: rgba(11,22,31,.72); color: var(--text); font: 700 22px/1 var(--display); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer; }
.tbtn small { font: 600 10px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tp-trim .tbtn { font: 700 15px var(--cond); letter-spacing: .06em; text-transform: uppercase; min-height: 44px; }
.tbtn.tsm { min-height: 34px; font: 600 13px var(--cond); letter-spacing: .08em; text-transform: uppercase; }
.tbtn.held { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.tbtn.on { background: var(--stbd); color: var(--ink); border-color: var(--stbd); }
body.touch #keys { display: none; }

@media (max-width: 720px) {
  .inst .val { font-size: 22px; }
  .inst { padding: 4px 8px 5px; }
  #i-sog, #i-awa, #i-aws, #i-lee, #i-depth, #i-perf { display: none; }
  #instruments .inst { border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
  #i-bsp, #i-hdg, #i-twa { border-top: 0 !important; }
  #i-twa, #i-heel { border-right: 0 !important; }
  #i-hdg, #i-vmg { border-right: 1px solid var(--line) !important; }
  #race-card { padding: 8px 10px; }
  #race-card .big { font-size: 30px; }
  #rc-standings { max-height: 110px; }
  .tools { flex-wrap: wrap; }
  .tools .chip { font-size: 12px; min-height: 32px; flex: 1 1 30%; }
  body.rig-open #rig { display: flex; left: 8px; right: 8px; width: auto; top: calc(8px + env(safe-area-inset-top, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); max-height: none !important; z-index: 12; background: rgba(11,22,31,.94); }
  body.rig-open #rig .nbtn { min-width: 44px; min-height: 32px; font-size: 13px; }
  body.rig-open #rig .lk { min-height: 30px; }
  body.rig-open #touch { display: none; }
  #paused-badge { font-size: 26px; }
  .menu-head h1 { font-size: 48px; }
  .lede { font-size: 14px; }
}
#help-close { position: sticky; bottom: 0; box-shadow: 0 -10px 18px rgba(11,22,31,.9); }
#paused-badge small { display: block; font: 600 13px var(--cond); letter-spacing: .1em; color: var(--muted); margin-top: 6px; text-align: center; }
body.menu-open #hud { visibility: hidden; }

/* ---------------- navigation: readout, steering compass, chart ---------------- */
#nav-read { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px 6px; padding: 5px 2px 0; font: 500 12px/1.25 var(--cond); letter-spacing: .03em; font-variant-numeric: tabular-nums; }
#nav-read div { display: flex; justify-content: space-between; gap: 4px; white-space: nowrap; }
#nav-read span { color: var(--muted); font-weight: 600; letter-spacing: .1em; font-size: 10px; align-self: center; }
#nav-read b { font-weight: 600; }
#nav-read b.warn { color: var(--amber); } #nav-read b.bad { color: var(--port); }
#nav-read .pos, #nav-read .tn { grid-column: 1 / -1; justify-content: center; }
#nav-read .tn em { font-style: normal; color: #39d0ff; overflow: hidden; text-overflow: ellipsis; }
#nav-read .eta { grid-column: 2 / 4; }
#nav-read:not(.has-wp) .wp { display: none; }
#nav-read:not(.has-td) .td, #nav-read:not(.has-ht) .ht { display: none; }
#nav-read:not(.has-wp) .tn em { color: var(--muted); }
#compass-tape { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(146px + env(safe-area-inset-bottom, 0px)); width: 360px; height: 32px; border-radius: 4px; border: 1px solid var(--line); pointer-events: none; }
#chart { position: absolute; inset: calc(12px + env(safe-area-inset-top, 0px)) 264px calc(10px + env(safe-area-inset-bottom, 0px)) 12px; display: flex; flex-direction: column; z-index: 8; background: rgba(11,22,31,.92); }
#chart header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
#chart header .grow { flex: 1; }
#chart header .chip { padding: 4px 10px; font-size: 13px; }
.chart-wrap { position: relative; flex: 1; min-height: 0; margin: 0 6px 6px; border-radius: 4px; overflow: hidden; }
#chart-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
#chart-tip { position: absolute; pointer-events: none; background: rgba(255,255,255,.95); color: #1d2530; border-left: 3px solid #c0268f; border-radius: 3px; padding: 5px 8px; font: 500 13px/1.3 var(--cond); max-width: 240px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
#chart-tip .muted { color: #5b6975; } #chart-tip em { color: #1690c8; font-style: normal; }
#tb-chart[aria-pressed="false"] { text-decoration: none; }
#tb-chart[aria-pressed="true"] { background: #1690c8; color: #fff; border-color: #1690c8; }
@media (max-width: 720px) {
  #nav-read { font-size: 11px; grid-template-columns: repeat(2, 1fr); }
  #nav-read div:nth-child(3), #nav-read .pos { display: none; }
  #nav-read .eta { grid-column: auto; }
  #compass-tape { width: calc(100% - 140px); max-width: 320px; height: 24px; bottom: calc(108px + env(safe-area-inset-bottom, 0px)); }
  #chart { inset: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px)) 8px; z-index: 13; }
  #chart header #chart-scale, #chart header #chart-title { display: none; }
}

/* boat name and sail number */
.boat-id { display: flex; gap: 6px; margin: 0 0 4px; }
.boat-id #boat-name { flex: 1 1 auto; min-width: 0; }
.boat-id #sail-no { flex: 0 0 96px; text-transform: uppercase; letter-spacing: .05em; }
.boat-id input.bad { outline: 2px solid #e0302a; outline-offset: -2px; }
#boat-id-msg:empty { display: none; }
#boat-id-msg.bad { color: #ff8a80; }
/* engine readout (only while the engine runs) and the touch throttle */
#engine-card { position: absolute; top: calc(88px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex; align-items: baseline; gap: 8px; padding: 4px 12px; border-radius: 4px; background: rgba(11,22,31,.72); border: 1px solid rgba(233,238,242,.16); font: 600 14px var(--cond); letter-spacing: .06em; white-space: nowrap; }
#engine-card[hidden] { display: none; }
#engine-card b { font: 700 22px/1 var(--display); min-width: 3.2ch; text-align: right; }
#engine-card small { color: var(--muted); font-size: 11px; margin-left: -4px; }
#eng-gear { text-transform: uppercase; }
#eng-gear.ahead { color: var(--stbd); } #eng-gear.astern { color: var(--amber); }
/* the engine: on a desktop a small horizontal bar under the engine readout at the top (clear of the panels at any
   window size); on a touch screen the vertical lever beside the touch pad */
/* the engine: on a desktop a row at the foot of the rig panel (Engine · gear · throttle · Start); on a touch screen
   the vertical lever beside the touch pad */
.tp-eng { grid-template-columns: auto auto 1fr auto; grid-auto-flow: column; align-items: center; gap: 8px; padding: 6px 10px 8px; border-top: 1px solid var(--line); }
.tp-eng::before { content: 'Engine'; font: 600 11px var(--cond); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
body:not(.touch) .tp-eng #tp-thr { writing-mode: horizontal-tb; direction: ltr; width: 100%; height: 18px; }
#rig.collapsed .tp-eng { display: none; }
body.touch .tp-eng { position: static; grid-template-columns: 54px; grid-auto-flow: row; justify-items: center; right: 12px; bottom: calc(300px + env(safe-area-inset-bottom, 0px)); padding: 8px 6px; background: rgba(11,22,31,.78); border: 1px solid var(--line); border-radius: 8px; }
body.touch .tp-eng::before { display: none; }
.tp-eng[hidden] { display: none; }
.tp-eng #tp-thr { accent-color: var(--accent); touch-action: none; }
body.touch .tp-eng #tp-thr { writing-mode: vertical-lr; direction: rtl; width: 44px; height: 120px; }
.tp-eng #tp-engine.on { background: var(--stbd); color: var(--ink); }
.tp-eng .tl { font: 700 14px var(--cond); letter-spacing: .08em; }
/* a narrow window: the rig panel stops above the instruments (they span the bottom middle and reach under it) */
@media (max-width: 1180px) { body:not(.touch) #rig { bottom: calc(126px + env(safe-area-inset-bottom, 0px)); max-height: calc(100% - 300px); } }

/* ---------------- the crew / coach line (under the toast, the alert, the engine readout and throttle); the autopilot's button ---------------- */
#coach { position: absolute; left: 50%; transform: translateX(-50%); top: calc(124px + env(safe-area-inset-top, 0px)); width: min(460px, calc(100% - 700px)); min-width: 300px; padding: 6px 10px 7px; border-left: 3px solid var(--stbd); }
#coach .co-top { display: flex; align-items: baseline; gap: 10px; font: 600 13px var(--cond); letter-spacing: .05em; font-variant-numeric: tabular-nums; white-space: nowrap; }
#coach .co-top .eyebrow { color: var(--stbd); }
#coach:not(.ap) #co-mode, #coach:not(.ap) #co-twa, #coach:not(.ap) #co-next { display: none; }
#coach:not(.ap) { border-left-color: var(--amber); } #coach:not(.ap) .co-top .eyebrow { color: var(--amber); }
#co-text { transition: opacity .8s; } #co-text.faded { opacity: 0; }
#coach.ap #co-text.faded { opacity: .45; }
#co-mode { color: #5fe39a; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
#co-next { color: #c5d1da; overflow: hidden; text-overflow: ellipsis; }
#co-txt { margin-left: auto; font-size: 11px; padding: 1px 6px; }
#co-now { margin: 4px 0 0; font: 500 15px/1.3 var(--body); color: var(--text); }
#co-prev { margin: 3px 0 0; font: 400 12px/1.3 var(--body); color: var(--muted); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#co-prev:empty { display: none; }
#coach.notext #co-text { display: none; }
#tb-pilot[aria-pressed="false"] { text-decoration: none; }
#tb-pilot[aria-pressed="true"] { background: var(--stbd); color: var(--ink); border-color: var(--stbd); }
.tp-helm #tp-pilot { grid-row: 3; grid-column: 1 / 3; }
@media (max-width: 720px) {
  #coach { top: auto; bottom: calc(140px + env(safe-area-inset-bottom, 0px)); width: calc(100% - 16px); min-width: 0; }
  body.touch #coach { bottom: calc(330px + env(safe-area-inset-bottom, 0px)); }
  #co-now { font-size: 13px; }
}

/* ---------------- the sound mixer (the Snd chip) and arranging the HUD (js/hudlayout.js) ---------------- */
#snd-pop { position: fixed; z-index: 14; width: 236px; padding: 0 10px 8px; box-shadow: 0 6px 24px rgba(0,0,0,.45); background: rgba(11,22,31,.94); }
#snd-pop header { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 4px; }
#snd-pop #snd-on { min-width: 44px; }
#snd-pop .sl { grid-template-columns: 84px 1fr 34px; padding: 1px 0; }
#snd-pop .sl.master label { color: var(--text); }
#snd-pop.muted .sl { opacity: .45; }
#snd-pop input[type=range] { touch-action: pan-y; height: 24px; }
body.touch #snd-pop input[type=range] { height: 34px; }
body.touch #snd-pop input[type=range]::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -7.5px; }
#tb-sound[aria-expanded="true"] { border-color: var(--accent); }
/* a moved panel: its place is inline (anchor + offset); a hidden one is gone except while arranging */
body:not(.hud-edit) .hud-off { display: none !important; }
body.hud-edit .hud-off { opacity: .35; }
body.hud-edit #coach[hidden] { display: block !important; }
body.hud-edit #engine-card[hidden] { display: flex !important; }
body.hud-edit #nextmark, body.hud-edit #work, body.hud-edit #grab-tip { visibility: hidden; }
#hud-edit { position: fixed; inset: 0; z-index: 16; pointer-events: none; }
#hud-edit .he-bar { position: absolute; top: calc(50% - 22px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 7px 10px; pointer-events: auto; white-space: nowrap; box-shadow: 0 6px 24px rgba(0,0,0,.45); background: rgba(11,22,31,.94); }
#hud-edit .he-tip { font: 500 13px var(--cond); color: #c5d1da; letter-spacing: .03em; }
#hud-edit .he-bar .chip { padding: 5px 10px; font-size: 13px; }
.he-frame { position: absolute; pointer-events: auto; border: 1.5px dashed rgba(255,122,26,.85); border-radius: 6px; background: rgba(255,122,26,.07); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.he-frame.moved { border-style: solid; }
.he-frame.drag { cursor: grabbing; background: rgba(255,122,26,.16); }
.he-frame.off { border-color: rgba(142,162,177,.7); background: rgba(8,14,20,.35); }
.he-frame .he-name { position: absolute; left: 4px; top: 4px; font: 700 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; padding: 3px 6px; border-radius: 3px; background: var(--accent); color: var(--ink); white-space: nowrap; }
.he-frame.off .he-name { background: var(--muted); }
.he-frame .he-hide { position: absolute; right: 4px; top: 4px; font: 600 11px/1 var(--cond); letter-spacing: .08em; text-transform: uppercase; padding: 3px 7px; border-radius: 3px; border: 1px solid rgba(233,238,242,.35); background: rgba(11,22,31,.9); color: var(--text); cursor: pointer; }
.he-gx, .he-gy { position: absolute; display: none; background: rgba(57,208,255,.8); pointer-events: none; }
.he-gx { top: 0; bottom: 0; width: 1px; } .he-gy { left: 0; right: 0; height: 1px; }
@media (max-width: 720px) {
  #hud-edit .he-bar { flex-wrap: wrap; justify-content: center; white-space: normal; width: calc(100% - 32px); max-width: 360px; }
  #hud-edit .he-tip { flex: 1 1 100%; text-align: center; }
  body.touch .he-frame .he-hide { padding: 7px 10px; }
}
@media (max-width: 640px) { .menu-foot #hud-arrange { flex: 0 1 auto; font-size: 13px; padding: 10px; } }
