/* База страницы */
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Компоновка: на компьютере 3D-окно (экран картплоттера) слева, приборная панель справа.
   На телефоне 3D закреплено сверху, под ним полоса приборов с изменениями, ниже прокручиваются настройки. */
:root {
  --bg: #e9eff0;
  --surface: #f8faf9;
  --surface-2: #e2e9e8;
  --surface-3: #d3dcdb;
  --ink: #0e2233;
  --ink-2: #4a5d6b;
  --ink-3: #6f818d;
  --line: #c8d3d3;
  --accent: #b3247c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(179, 36, 124, 0.11);
  --ok: #22845a;
  --warn: #b07306;
  --bad: #c0392d;
  --port: #d2343a;
  --stbd: #1b9a55;
  --glass: rgba(7, 20, 30, 0.74);
  --glass-2: rgba(7, 20, 30, 0.55);
  --glass-ink: #eaf3f6;
  --glass-dim: #93b2c0;
  --glass-line: rgba(255, 255, 255, 0.13);
  --instr: #0b1c27;
  --instr-hot: rgba(255, 255, 255, 0.09);
  --hi-good: #3cd18a;
  --hi-warn: #f2be4b;
  --hi-bad: #ff7b6e;
  --teak: #a56b37;
  --deck: #dfe5e3;
  --deck-2: #c7d0cd;
  --deck-line: #8a9aa3;
  --stage: #a9c9db;
  --sheet-shadow: rgba(14, 34, 51, 0.16);
  --stage-h: 44%;
  --f-display: "Sofia Sans Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --f-body: "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 1px 2px rgba(14, 34, 51, 0.06), 0 6px 24px rgba(14, 34, 51, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #061019; --surface: #0c1923; --surface-2: #13242f; --surface-3: #1b313e; --ink: #e2ebee; --ink-2: #97adb9; --ink-3: #6f8794; --line: #203646;
    --accent: #e45cb1; --accent-ink: #1a0712; --accent-soft: rgba(228, 92, 177, 0.15); --ok: #3cbb7f; --warn: #e2a232; --bad: #f0675b; --port: #f0545a; --stbd: #34c473;
    --teak: #b07a45; --deck: #1a2c37; --deck-2: #25404e; --deck-line: #5f7a88; --stage: #0f2533; --sheet-shadow: rgba(0, 0, 0, 0.45);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #061019; --surface: #0c1923; --surface-2: #13242f; --surface-3: #1b313e; --ink: #e2ebee; --ink-2: #97adb9; --ink-3: #6f8794; --line: #203646;
  --accent: #e45cb1; --accent-ink: #1a0712; --accent-soft: rgba(228, 92, 177, 0.15); --ok: #3cbb7f; --warn: #e2a232; --bad: #f0675b; --port: #f0545a; --stbd: #34c473;
  --teak: #b07a45; --deck: #1a2c37; --deck-2: #25404e; --deck-line: #5f7a88; --stage: #0f2533; --sheet-shadow: rgba(0, 0, 0, 0.45);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.phone-only { display: none; }

#app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 408px;
  gap: 14px;
  padding-block: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- 3D-окно ---------- */
#stageWrap { position: relative; min-width: 0; min-height: 0; border-radius: 16px; overflow: hidden; background: var(--stage); box-shadow: var(--shadow); }
#stage { position: absolute; inset: 0; }
#gl { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }
.glass { background: var(--glass); color: var(--glass-ink); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

#hud { position: absolute; top: 12px; left: 12px; right: 124px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
#hud::-webkit-scrollbar { display: none; }
.tile { flex: 0 0 auto; border-radius: 10px; padding: 6px 11px 7px; min-width: 92px; }
.tile .lbl { font-family: var(--f-display); font-weight: 600; font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--glass-dim); }
.tile .val { font-family: var(--f-display); font-weight: 700; font-size: 27px; line-height: 1.02; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.tile .val small { font-size: 13px; font-weight: 600; color: var(--glass-dim); margin-left: 3px; }
.tile .sub { font-size: 11.5px; color: var(--glass-dim); white-space: nowrap; }
.tile.speed .val { font-size: 34px; }
.tile .sub b { color: var(--glass-ink); font-weight: 600; }

#camBar { position: absolute; top: 12px; right: 12px; z-index: 6; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pill { display: flex; flex-direction: column; align-items: stretch; border-radius: 10px; padding: 3px; gap: 2px; width: 104px; }
.pill button { border: 0; background: transparent; color: var(--glass-ink); padding: 5px 9px; border-radius: 7px; font-size: 12.5px; cursor: pointer; white-space: nowrap; text-align: left; }
.pill button small { display: none; color: inherit; opacity: 0.75; }
.pill button:hover { background: rgba(255, 255, 255, 0.1); }
.pill button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.pill.toggles button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); color: var(--glass-ink); }
.pill.toggles button[aria-pressed="true"]::before { content: "✓ "; color: var(--hi-good); }
#camBtn { display: none; }

#topStack { position: absolute; left: 12px; top: 96px; width: min(540px, calc(100% - 140px)); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 3; }
#banner { pointer-events: auto; width: 100%; border-radius: 12px; padding: 10px 14px 11px; }
#banner .b-top { display: flex; align-items: baseline; gap: 10px; }
#banner .b-title { flex: 1; min-width: 0; font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
#banner .b-phase { font-family: var(--f-display); font-weight: 600; font-size: 13px; color: var(--glass-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
#banner .b-tog { display: none; }
#banner .b-obj { font-size: 12.5px; color: var(--glass-dim); margin-top: 2px; }
#banner .b-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#banner .b-todo { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; }
#banner .b-todo li { margin: 2px 0; }
.gbtn { border: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.07); color: var(--glass-ink); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
.gbtn:hover { background: rgba(255, 255, 255, 0.14); }
.gbtn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.okbar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); margin-top: 8px; overflow: hidden; }
.okbar i { display: block; height: 100%; width: 0; background: var(--hi-good); transition: width 0.2s; }

#toasts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: 100%; pointer-events: none; }
.toast { border-radius: 10px; padding: 8px 13px; font-size: 13px; font-weight: 500; animation: tin 0.25s ease-out; max-width: 100%; }
.toast.bad { border-color: rgba(240, 103, 91, 0.7); }
.toast.bad::before { content: "⚠ "; color: var(--hi-bad); }
.toast.warn::before { content: "• "; color: var(--hi-warn); }
.toast.info::before { content: "↻ "; color: #8fd3ff; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

#effChip { display: none; }

#helmBar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; border-radius: 12px; padding: 4px; z-index: 2; }
#helmBar button { border: 0; background: rgba(255, 255, 255, 0.07); color: var(--glass-ink); border-radius: 8px; padding: 7px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none; touch-action: none; }
#helmBar button:hover { background: rgba(255, 255, 255, 0.15); }
#helmBar button:active, #helmBar button.on { background: var(--accent); color: #fff; }
#helmBar .hdg { font-family: var(--f-display); font-weight: 700; font-size: 20px; padding: 0 8px; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; color: var(--glass-ink); }
#helmBar .sep { width: 1px; height: 22px; background: var(--glass-line); margin: 0 2px; }
#helmBar .ico { display: grid; place-items: center; padding: 6px 9px; }
#helmBar .ico[aria-pressed="true"] { background: var(--accent); color: #fff; }

#gauges { position: absolute; left: 12px; right: 12px; bottom: 64px; display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; z-index: 2; }
.gcard { border-radius: 14px; padding: 8px; pointer-events: auto; }
.gcard .gtitle { font-family: var(--f-display); font-weight: 600; font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--glass-dim); margin: 0 2px 4px; display: flex; justify-content: space-between; gap: 8px; }
#windDial { width: 150px; height: 150px; display: block; }
#tellCanvas { width: 236px; height: 150px; display: block; }

#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--glass-ink); font-family: var(--f-display); font-size: 18px; letter-spacing: 0.04em; background: linear-gradient(#6fa6d1, #b9d6e6 55%, #2d6c8c 56%, #164764); z-index: 8; }
#loading p { background: var(--glass); padding: 10px 16px; border-radius: 10px; max-width: 80%; text-align: center; }

#strip { display: none; }

/* ---------- Панель ---------- */
#panel { min-width: 0; min-height: 0; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
#panel > * { flex-shrink: 0; }
.brand { padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.brand svg { flex: 0 0 auto; }
.brand-text { flex: 1; min-width: 0; }
.langsw { display: flex; flex: 0 0 auto; align-self: flex-start; background: var(--surface-2); border-radius: 8px; padding: 2px; gap: 2px; }
.langsw button { border: 0; background: transparent; border-radius: 6px; padding: 4px 8px; font-family: var(--f-display); font-weight: 700; font-size: 12.5px; letter-spacing: 0.06em; color: var(--ink-3); cursor: pointer; }
.langsw button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
#langBtn { display: none; }
.brand h1 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: 21px; letter-spacing: 0.01em; line-height: 1.1; }
.brand p { margin: 0; font-size: 12px; color: var(--ink-2); }

#scoreCard { padding: 12px 16px 6px; border-bottom: 1px solid var(--line); }
.score-head { display: flex; gap: 14px; align-items: center; }
.score-num { font-family: var(--f-display); font-weight: 800; font-size: 46px; line-height: 0.95; font-variant-numeric: tabular-nums; min-width: 92px; }
.score-num span { font-size: 22px; font-weight: 700; color: var(--ink-2); margin-left: 2px; }
.score-meta { flex: 1; min-width: 0; }
.score-label { font-family: var(--f-display); font-weight: 600; font-size: 11.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-2); }
.segbar { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; margin: 6px 0 5px; }
.segbar i { height: 8px; border-radius: 2px; background: var(--surface-3); }
.segbar i.on { background: var(--ok); }
.segbar.warn i.on { background: var(--warn); }
.segbar.bad i.on { background: var(--bad); }
.score-sub { font-size: 12.5px; color: var(--ink-2); }
.score-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); }

.items { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 2px 0 8px; }
.item { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 7px; align-items: center; padding: 6px 8px; border: 1px solid transparent; background: var(--surface-2); text-align: left; cursor: pointer; border-radius: 9px; min-width: 0; }
.item:hover { border-color: var(--line); }
.item[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.dot { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; line-height: 1; }
.st-ok .dot { background: var(--ok); }
.st-warn .dot { background: var(--warn); }
.st-bad .dot { background: var(--bad); }
.st-na .dot { background: var(--surface-3); color: var(--ink-3); }
.item .nm { font-weight: 500; font-size: 12.8px; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.item .nm small { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; }
.st-na .nm { color: var(--ink-3); }
.hint { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; border-left: 3px solid var(--ink-3); }
.hint.st-ok { border-left-color: var(--ok); }
.hint.st-warn { border-left-color: var(--warn); }
.hint.st-bad { border-left-color: var(--bad); }
.hint-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hint-h b { font-weight: 600; }
.hint-h span { font-family: var(--f-display); font-weight: 600; font-size: 12.5px; color: var(--ink-3); }
.hint-h .x { margin-left: auto; border: 0; background: transparent; font-size: 18px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 4px; }
.hint p { margin: 0; }
.hint .diag { font-weight: 500; }
.hint .act { margin-top: 5px; color: var(--ink-2); }
.hint .act:empty { display: none; }

/* оценка рядом с настройкой */
.st { width: 20px; height: 20px; flex: 0 0 auto; border-radius: 50%; border: 0; padding: 0; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; line-height: 1; color: #fff; cursor: pointer; }
.st.st-ok { background: var(--ok); }
.st.st-warn { background: var(--warn); }
.st.st-bad { background: var(--bad); }
.st.st-na { background: var(--surface-3); color: var(--ink-3); }
.st[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.ihint { margin-top: 6px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border-left: 3px solid var(--ink-3); font-size: 12.8px; }
.ihint.st-ok { border-left-color: var(--ok); }
.ihint.st-warn { border-left-color: var(--warn); }
.ihint.st-bad { border-left-color: var(--bad); }
.ihint .ih-h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ihint .ih-h b { font-weight: 600; }
.ihint .ih-h span { font-family: var(--f-display); font-weight: 600; font-size: 12px; color: var(--ink-3); }
.ihint p { margin: 3px 0 0; }
.ihint .diag { font-weight: 500; }
.ihint .act { color: var(--ink-2); }
.ihint .act:empty { display: none; }

.tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 4; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 9px 10px 10px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; flex: 0 0 auto; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .ts, .tabs .tab-score { display: none; }
.pane { padding: 14px 16px 22px; display: flex; flex-direction: column; gap: 14px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 7px 8px; font-size: 13px; cursor: pointer; color: var(--ink-2); line-height: 1.2; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg button small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); }

.group h3 { margin: 0 0 6px; font-family: var(--f-display); font-weight: 700; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.group h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.ctl { padding: 6px 0 8px; }
.ctl-top { display: flex; gap: 8px; align-items: center; min-height: 22px; }
.ctl-top label, .ctl-top .lbl-b { font-weight: 500; font-size: 13.5px; }
.ctl-top output { margin-left: auto; font-family: var(--f-display); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.range { position: relative; padding-top: 4px; }
.range input { width: 100%; margin: 0; accent-color: var(--accent); height: 24px; cursor: pointer; }
.range .tgt { position: absolute; top: -3px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid var(--ok); transform: translateX(-6px); pointer-events: none; transition: left 0.3s; }
.ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: -2px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; }
.hove { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 6px; }
.hove .check { font-size: 13.5px; color: var(--ink); }
.hove .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Палуба ---------- */
.deckwrap { background: var(--surface-2); border-radius: 12px; padding: 6px; }
#deckSvg { width: 100%; height: auto; display: block; }
#deckSvg .hit { cursor: pointer; outline: none; }
#deckSvg .hit:hover .body { stroke: var(--accent); }
#deckSvg .hit.sel .body, #deckSvg .hit:focus-visible .body { stroke: var(--accent); stroke-width: 3; }
#deckSvg text { font-family: var(--f-display); fill: var(--ink-2); }
.selcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 9px; background: var(--surface); }
.selcard .sh { display: flex; align-items: center; gap: 9px; }
.selcard .sw { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
.selcard h4 { margin: 0; font-size: 15px; font-weight: 600; }
.selcard .where { font-size: 12px; color: var(--ink-3); margin-left: auto; text-align: right; }
.selcard .about { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.evalrow { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.evalrow b { color: var(--ink); font-weight: 600; }
.gauge { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: visible; }
.gauge i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--ink-2); }
.gauge .mk { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-3); }
.gauge .mk span { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--ink-3); white-space: nowrap; }
.gauge .tg { position: absolute; top: -5px; bottom: -5px; width: 3px; border-radius: 2px; background: var(--ok); }
.gval { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); }
.gval b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); }
.chip b { color: var(--ink); font-weight: 600; }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.chip.danger { background: rgba(192, 57, 45, 0.12); color: var(--bad); }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.acts .btn { padding: 8px 10px; }
.hold { touch-action: none; user-select: none; -webkit-user-select: none; font-weight: 600; }
.hold.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.warnline { margin: 0; font-size: 12.5px; color: var(--bad); }
.warnline.soft { color: var(--ink-2); }
.selcard .sh .st { margin-left: 2px; }
.msgline { margin: 0; font-size: 12.5px; padding: 8px 10px; border-radius: 9px; background: rgba(176, 115, 6, 0.12); color: var(--ink); }
.log { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; }
.log li.bad { color: var(--bad); font-weight: 500; }

/* ---------- Ветер и курс ---------- */
.windrow { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; }
#dirDial { width: 150px; height: 150px; touch-action: none; cursor: pointer; }
#dirDial text { font-family: var(--f-display); font-weight: 700; fill: var(--ink-2); font-size: 13px; }
.shiftbtns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.shiftbtns .btn { padding: 7px 4px; line-height: 1.15; }
.shiftbtns small { display: block; font-size: 11px; color: var(--ink-3); }
.note { font-size: 12.5px; color: var(--ink-2); margin: 0; }

/* ---------- Сценарии ---------- */
.scgroup h3 { margin: 4px 0 8px; }
.sclist { display: grid; gap: 8px; }
.sc-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; background: var(--surface); }
.sc-item.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sc-item h4 { margin: 0; font-size: 14px; font-weight: 600; }
.sc-item p { margin: 0; font-size: 12.5px; color: var(--ink-2); grid-column: 1 / -1; }
.lvl { font-family: var(--f-display); font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-3); }
.sc-item .btn { grid-row: 1; grid-column: 2; }
.sc-item.done h4::after { content: " ✓"; color: var(--ok); }
.freebox { border-radius: 12px; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }

/* ---------- Справка ---------- */
.help h3 { margin: 6px 0 4px; font-size: 14.5px; }
.help p, .help li { font-size: 13px; color: var(--ink-2); max-width: 62ch; }
.help ul { padding-left: 18px; margin: 4px 0; }
.help dl { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: 13px; }
.help dt { font-weight: 600; }
.help dd { margin: 0; color: var(--ink-2); }
.pos-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pos-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.pos-table td:first-child { font-family: var(--f-display); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Разбор ---------- */
#debrief { position: fixed; inset: 0; background: rgba(4, 12, 18, 0.5); display: grid; place-items: center; z-index: 20; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px; }
#debrief .card { background: var(--surface); color: var(--ink); border-radius: 16px; width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 20px 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
#debrief .kicker { font-family: var(--f-display); font-weight: 700; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ok); }
#debrief h2 { margin: 2px 0 6px; font-family: var(--f-display); font-weight: 800; font-size: 26px; text-wrap: balance; }
#debrief .stats { display: flex; gap: 18px; margin: 4px 0 10px; }
#debrief .stats div { font-size: 12px; color: var(--ink-2); }
#debrief .stats b { display: block; font-family: var(--f-display); font-size: 26px; color: var(--ink); font-variant-numeric: tabular-nums; }
#debrief h3 { margin: 12px 0 4px; font-size: 14px; }
#debrief ol, #debrief ul { margin: 0; padding-left: 20px; font-size: 13.5px; }
#debrief li { margin: 3px 0; }
#debrief p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
#debrief .mist li { color: var(--bad); }
#debrief .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

@media (max-width: 1180px) { #app { grid-template-columns: minmax(0, 1fr) 360px; } .tile { min-width: 80px; } .tile .val { font-size: 23px; } .tile.speed .val { font-size: 29px; } }

/* ============================================================
   Телефон: общее для вертикальной и горизонтальной ориентации
   ============================================================ */
@media (max-width: 860px) and (orientation: portrait), (max-width: 620px), (orientation: landscape) and (max-height: 520px) {
  html, body { overflow: hidden; overscroll-behavior: none; }
  #app { gap: 0; padding: 0; }
  #stageWrap { border-radius: 0; box-shadow: none; }
  #panel { border-radius: 0; box-shadow: none; overscroll-behavior: contain; }
  .brand, #hud { display: none; }
  .phone-only { display: block; }

  .tabs { order: -1; padding: 4px 6px 0; }
  .tabs .tl { display: none; }
  .tabs .ts { display: inline; }
  .tabs .tab-score { display: block; }
  .tabs button { padding: 10px 11px 11px; font-size: 14px; }
  .pane { padding: 12px 16px 28px; gap: 12px; }
  #scoreCard { border-bottom: 0; padding: 14px 16px 18px; }

  /* язык, камера: кнопки и меню */
  #langBtn { display: grid; place-items: center; position: absolute; top: 10px; right: 56px; z-index: 6; width: 40px; height: 40px; padding: 0; border-radius: 12px; cursor: pointer; font-family: var(--f-display); font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
  #camBtn { display: grid; place-items: center; position: absolute; top: 10px; right: 10px; z-index: 6; width: 40px; height: 40px; padding: 0; border-radius: 12px; cursor: pointer; }
  #camBtn[aria-expanded="true"] { background: var(--accent); border-color: transparent; color: #fff; }
  #camBar { display: none; top: 56px; right: 10px; gap: 5px; }
  #camBar.open { display: flex; }
  #camBar .pill { width: 236px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 4px; }
  #camBar .pill button { padding: 8px 10px; font-size: 13.5px; }
  #camBar .pill button[data-view="auto"] { grid-column: 1 / -1; }
  #camBar .pill button small { display: inline; }

  /* оверлеи 3D */
  #topStack { top: 10px; left: 10px; right: 104px; width: auto; gap: 6px; }
  #banner { padding: 7px 8px 8px 11px; }
  #banner .b-top { align-items: center; gap: 8px; cursor: pointer; }
  #banner .b-title { font-size: 15px; line-height: 1.2; }
  #banner .b-phase { font-size: 12.5px; }
  #banner .b-tog { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--glass-line); border-radius: 8px; background: rgba(255, 255, 255, 0.08); color: var(--glass-ink); padding: 0; font-size: 13px; cursor: pointer; }
  #banner:not(.open) .b-obj, #banner:not(.open) .b-todo, #banner:not(.open) .b-acts { display: none; }
  #banner .okbar { margin-top: 6px; }
  .toast { font-size: 12.5px; padding: 7px 11px; }

  #effChip:not([hidden]) { display: flex; flex-direction: column; position: absolute; right: 10px; bottom: 54px; z-index: 2; max-width: min(200px, calc(100% - 172px)); padding: 5px 9px 6px; border-radius: 10px; font-size: 11px; line-height: 1.3; pointer-events: none; }
  #effChip .eff-k { font-family: var(--f-display); font-weight: 600; font-size: 9.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--glass-dim); }
  #effChip b { font-weight: 600; font-size: 12.5px; }
  #effTrend { color: var(--glass-dim); }

  #gauges { left: 10px; right: auto; bottom: 54px; }
  #gauges .wind { display: none; }
  .gcard.tell { padding: 4px 5px 5px; border-radius: 12px; cursor: pointer; user-select: none; -webkit-user-select: none; }
  .gcard.tell .gtitle { font-size: 9px; margin: 0 1px 2px; }
  .gcard.tell.min .gtitle { margin: 0; }
  .gcard.tell.min canvas { display: none; }
  #tellCanvas { width: 136px; height: 62px; }

  #helmBar { bottom: 8px; padding: 3px; gap: 3px; }
  #hLeft, #hRight, #helmBar .sep { display: none; }
  #helmBar[data-man="tack"] #hGybe, #helmBar[data-man="gybe"] #hTack, #helmBar[data-man="none"] #hTack, #helmBar[data-man="none"] #hGybe { display: none; }
  #helmBar button { padding: 7px 10px; font-size: 13.5px; }
  #helmBar .ico { padding: 6px 8px; }
  #helmBar .hdg { font-size: 18px; min-width: 50px; padding: 0 2px; }

  /* полоса приборов */
  #strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; position: relative; background: var(--instr); color: var(--glass-ink); padding: 4px 6px 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
  #strip .sc { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 2px 2px 1px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: center; transition: background-color 0.3s; }
  #strip .sc.hot { background: var(--instr-hot); }
  #strip .k { font-family: var(--f-display); font-weight: 600; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--glass-dim); white-space: nowrap; }
  #strip b { font-family: var(--f-display); font-weight: 700; font-size: 21px; line-height: 1.05; font-variant-numeric: tabular-nums; }
  #strip .d { font-size: 11px; line-height: 1.25; color: var(--glass-dim); white-space: nowrap; font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  #strip .d.good { color: var(--hi-good); font-weight: 600; }
  #strip .d.bad { color: var(--hi-bad); font-weight: 600; }
  #strip .d.chg { color: var(--glass-ink); font-weight: 600; }
  #cScore { cursor: pointer; }
  #sScore.ok { color: var(--hi-good); }
  #sScore.warn { color: var(--hi-warn); }
  #sScore.bad { color: var(--hi-bad); }
  #strip .grip { position: absolute; left: 50%; bottom: 4px; width: 38px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); transform: translateX(-50%); }

  /* палуба: компактная карточка снасти прилипает к низу панели */
  #selCard { position: sticky; bottom: 0; z-index: 3; box-shadow: 0 -10px 22px -10px var(--sheet-shadow); padding: 9px 11px 11px; gap: 7px; }
  #selCard h4 { font-size: 14px; }
  #selCard .where, #selCard .about:not(.keep), #selCard .warnline.soft { display: none; }
  #selCard .chips { flex-wrap: nowrap; overflow: hidden; gap: 4px; }
  #selCard .chip { font-size: 11px; padding: 2px 7px; white-space: nowrap; }
  #selCard .actrow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  #selCard .actrow .acts { display: contents; }
  #selCard .acts .btn { padding: 7px 4px; font-size: 12px; line-height: 1.15; min-height: 40px; }
  #deckPane > .note { display: none; }
}

/* ---------- Телефон вертикально: 3D сверху, настройки снизу ---------- */
@media (max-width: 860px) and (orientation: portrait), (max-width: 620px) {
  #app { display: flex; flex-direction: column; }
  #stageWrap { flex: 0 0 auto; height: var(--stage-h); min-height: 120px; }
  #strip { flex: 0 0 auto; cursor: ns-resize; }
  #panel { flex: 1 1 0; min-height: 0; border: 0; overflow-y: auto; }
}

/* ---------- Телефон горизонтально: 3D слева, настройки справа ---------- */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 621px) {
  #app { grid-template-columns: minmax(0, 1fr) minmax(300px, 42%); grid-template-rows: minmax(0, 1fr) auto; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  #stageWrap { grid-column: 1; grid-row: 1; }
  #strip { grid-column: 1; grid-row: 2; padding-bottom: 6px; }
  #strip .grip { display: none; }
  #panel { grid-column: 2; grid-row: 1 / span 2; border-width: 0 0 0 1px; overflow-y: auto; }
}

/* ---------- Совсем узкие экраны ---------- */
@media (max-width: 380px) {
  #strip b { font-size: 18px; }
  #strip .k { font-size: 9px; letter-spacing: 0.04em; }
  #strip .d { font-size: 10px; }
  #helmBar button { padding: 8px 7px; font-size: 12.5px; }
  #helmBar .ico { padding: 6px 6px; }
  #helmBar .hdg { font-size: 16px; min-width: 42px; }
  .tabs button { padding: 10px 8px 11px; font-size: 13px; }
  .windrow { grid-template-columns: 1fr; justify-items: center; }
  .score-num { font-size: 40px; min-width: 80px; }
}
