/* sailing/css/sailing.css  —  Nautical theme */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-app:      #0c1f12;   /* deep forest green — app shell */
  --bg-panel:    #122218;   /* dark nautical green — helm panel */
  --bg-ctrl:     #0d1a10;   /* darker green — input tracks & cells */
  --border:      #28483a;   /* muted green border */
  --text:        #a8c4b0;   /* light green-tinted text */
  --text-dim:    #507060;   /* muted green */
  --text-hi:     #cce4d4;   /* bright near-white with green cast */
  --accent:      #2a7cc0;   /* blue — good contrast on green */
  --accent-hi:   #40a0f0;
  --green:       #40c870;
  --amber:       #f08030;
}

html {
  height: 100%;
  overflow: hidden;   /* prevents page scroll without trapping child-element scroll on iOS */
}
body {
  height: 100%;
  background: var(--bg-app);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 20px;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
#app-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  background: #091610;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-hi);
}

#app {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 32px);
  height: calc(100svh - 32px);
}

/* ── Panel headings ──────────────────────────────────────────────────────── */
.panel-heading {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #091610;
  gap: 10px;
}
.chart-heading {
  border-bottom: 2px solid var(--border);
}
.panel-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-hi);
}
.chart-heading {
  justify-content: space-between;
}

/* ── Helm panel (left 50%) ───────────────────────────────────────────────── */
#helm-panel {
  position: relative;
  width: 50%;
  min-width: 360px;
  display: flex;
  flex-direction: column;
  background: transparent;
  border-right: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}

/* Top area: canvas fills full width; sim-col overlays top-left corner */
#helm-top {
  flex-shrink: 0;
  position: relative;
}

/* Sim controls column — absolutely overlaid on top-left of canvas */
#sim-col {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 10px;
  background: transparent;
}
#sim-col .btn {
  padding: 6px 10px;
}
#sim-col #lbl-status {
  text-align: center;
  font-size: 14px !important;
  padding: 2px 0;
}

/* Instruments canvas — full width and height of #helm-top */
#helm-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Helm controls (HTML sliders/buttons) — below the canvas */
#helm-controls {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Section within helm controls */
.hc-section {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.hc-section:last-child { border-bottom: none; }

.hc-section-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-hi);
  margin-bottom: 6px;
}

#closeup-label,
#wind-triangle-label {
  position: absolute;
  pointer-events: none;
  line-height: 1;
  margin-bottom: 0;
}

/* ── Chart panel (right 50%) ─────────────────────────────────────────────── */
#chart-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

#sail-canvas {
  flex: 1;
  min-height: 0;
  width:  100%;
  display: block;
  cursor: crosshair;
}

/* ── Chart mode buttons (Waterway / Wind / Launch) ──────────────────────── */
.chart-mode-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.chart-mode-btn {
  padding: 3px 10px;
  font-size: 15px;
  height: auto;
  border-radius: 4px;
}

/* ── Chart sub-panels (Waterway, Wind) — below heading, above canvas ─────── */
.chart-sub-panel {
  flex-shrink: 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px 12px;
}
.chart-sub-panel[hidden] { display: none; }

/* ── Launch overlay — absolute, centred below bullseye ───────────────────── */
#launch-overlay {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}
#launch-overlay[hidden] { display: none; }
#launch-overlay button  { pointer-events: auto; }
#launch-post-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}
#launch-post-btns[hidden] { display: none; }

/* ── Inline help icon buttons (? after section labels) ──────────────────── */
.help-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-left: 7px;
  border-radius: 50%;
  border: 1px solid var(--text-dim);
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  vertical-align: middle;
  transition: border-color 0.15s, color 0.15s;
}
.help-icon-btn:hover { border-color: var(--accent); color: var(--accent-hi); }

/* ── Inline help popover ─────────────────────────────────────────────────── */
#help-popover {
  position: fixed;
  z-index: 300;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 14px;
  max-width: 280px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  overflow-y: auto;
}
#help-popover[hidden] { display: none; }
#btn-help-popover-close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
#btn-help-popover-close:hover { color: var(--text-hi); }
#help-popover-content strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-hi);
  margin-bottom: 8px;
}

/* ? buttons inside absolutely-positioned labels must still receive clicks */
#closeup-label .help-icon-btn,
#wind-triangle-label .help-icon-btn {
  pointer-events: auto;
}

/* Speed unit toggle (kn / m/s) in wind triangle label */
#btn-speed-unit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 15px;
  min-width: 28px;
  flex-shrink: 0;
  margin-left: 7px;
  border-radius: 8px;
  border: 1px solid var(--text-dim);
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  vertical-align: middle;
  transition: border-color 0.15s, color 0.15s;
  padding: 0 4px;
}
#btn-speed-unit:hover { border-color: var(--accent); color: var(--accent-hi); }

/* ── Help button (in sim row of helm controls) ───────────────────────────── */
.help-btn {
  flex-shrink: 0;
  align-self: center;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.help-btn:hover { border-color: var(--accent); color: var(--accent-hi); }
.help-btn.btn-active {
  border-color: var(--accent-hi) !important;
  color: var(--accent-hi) !important;
  background: rgba(40,120,190,0.2) !important;
}

/* ── Keyboard shortcuts modal ────────────────────────────────────────────── */
#help-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#help-modal[hidden] { display: none; }

#help-modal-box {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px 16px;
  min-width: 280px;
  max-width: 380px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#btn-help-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
#btn-help-close:hover { color: var(--text-hi); }

.help-modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-hi);
  margin-bottom: 12px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
  color: var(--text);
}
.help-table td {
  padding: 3px 0;
  vertical-align: middle;
}
.help-table td:first-child {
  white-space: nowrap;
  padding-right: 12px;
  color: var(--text-dim);
}
.help-table td.help-group {
  padding-top: 8px;
  padding-bottom: 2px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.help-table kbd {
  background: var(--bg-ctrl);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1px 4px;
  font-family: monospace;
  font-size: 14px;
  color: var(--text);
}

/* ── Physics section in help modal ──────────────────────────────────────────── */
.physics-section {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.physics-section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-hi);
  margin-bottom: 12px;
}
.physics-topic {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-hi);
  margin: 10px 0 3px;
  letter-spacing: 0.04em;
}
.physics-topic:first-of-type { margin-top: 0; }
.physics-para {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}
.physics-links {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
}
.physics-links a {
  color: var(--accent-hi);
  text-decoration: none;
}
.physics-links a:hover { text-decoration: underline; }

.physics-glossary {
  margin: 0 0 10px 0;
  padding: 0;
}
.physics-glossary dt {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-hi);
  margin-top: 9px;
  float: left;
  clear: left;
  width: 108px;
}
.physics-glossary dd {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
  margin-left: 114px;
  margin-top: 9px;
  margin-bottom: 0;
}
.physics-glossary::after { content: ''; display: table; clear: both; }

.help-modal-note {
  margin-top: 10px;
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Section title (used in env modal and help modal) ─────────────────────── */
.section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-hi);
  margin-bottom: 8px;
}

/* ── Control rows ────────────────────────────────────────────────────────── */
.ctrl-row {
  margin-bottom: 10px;
}
.ctrl-row:last-child { margin-bottom: 0; }

.ctrl-row label {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.ctrl-row label span {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Course select */
select {
  width: 100%;
  background: var(--bg-ctrl);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23507060'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
select:focus { border-color: var(--accent); }

/* Range inputs */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-ctrl);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-hi);
  border: 2px solid var(--bg-ctrl);
  box-shadow: 0 0 4px rgba(64,160,240,0.5);
  cursor: pointer;
  margin-top: -5px;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--accent) calc(50% - 1px),
    rgba(0,0,0,0.85) calc(50% - 1px),
    rgba(0,0,0,0.85) calc(50% + 1px),
    var(--accent) calc(50% + 1px));
}
input[type=range]:focus { outline: none; }

/* ── Wind section — purple theme matching TW arrow ───────────────────────── */
#section-wind .section-title {
  color: #d060e0;
}
#section-wind input[type=range]::-webkit-slider-thumb {
  background: #d060e0;
  box-shadow: 0 0 4px rgba(208,96,224,0.5);
}
#section-wind input[type=range]::-webkit-slider-runnable-track {
  background: linear-gradient(to right,
    #9040b0              calc(25% - 0.5px),
    rgba(0,0,0,0.70)     calc(25% - 0.5px),
    rgba(0,0,0,0.70)     calc(25% + 0.5px),
    #9040b0              calc(25% + 0.5px),
    #9040b0              calc(50% - 1px),
    rgba(0,0,0,0.88)     calc(50% - 1px),
    rgba(0,0,0,0.88)     calc(50% + 1px),
    #9040b0              calc(50% + 1px),
    #9040b0              calc(75% - 0.5px),
    rgba(0,0,0,0.70)     calc(75% - 0.5px),
    rgba(0,0,0,0.70)     calc(75% + 0.5px),
    #9040b0              calc(75% + 0.5px));
}

/* Tip text under controls */
.ctrl-tip {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 3px;
  text-align: center;
}

/* ── Boom push compact controls ─────────────────────────────────────────── */
.boom-arrow {
  padding: 6px 8px;
  flex-shrink: 0;
}
.boom-label {
  font-size: 15px;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 0 2px;
  flex-shrink: 0;
}

/* ── Sim controls ────────────────────────────────────────────────────────── */
.sim-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.btn {
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent-hi);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: rgba(40,120,190,0.25);
  border-color: var(--accent-hi);
}
.btn:active { background: rgba(40,120,190,0.45); }

.btn-secondary {
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-secondary:not(:disabled) {
  color: var(--text);
  border-color: #3a5a4a;
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-dim);
  color: var(--text-hi);
  background: rgba(255,255,255,0.05);
}
.btn-active {
  border-color: var(--green) !important;
  color: var(--green) !important;
  background: rgba(64,200,112,0.12) !important;
}

#btn-refloat.btn-active {
  border-color: var(--amber) !important;
  color: var(--amber) !important;
  background: rgba(240,128,48,0.15) !important;
}
#btn-refloat:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── 2D control pad ──────────────────────────────────────────────────────── */
#pad-controls {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 4px;
}

#sail-pad {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  max-height: 100%;
  display: block;
  border-radius: 6px;
  border: 1.5px solid #3a6a52;
  box-shadow: 0 0 8px rgba(40, 130, 80, 0.18), inset 0 0 12px rgba(0, 0, 0, 0.25);
  cursor: crosshair;
  touch-action: none;
}

.pad-side-col {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

#btn-hdghold-pad,
#btn-cleat-pad,
.pad-side-col .boom-arrow {
  text-align: center;
  line-height: 1.3;
  padding: 4px 6px;
  font-size: 12px;
}

.pad-side-col .boom-label {
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
}

/* ── Scrollbar styling (helm-controls) ──────────────────────────────────── */
#helm-controls::-webkit-scrollbar { width: 4px; }
#helm-controls::-webkit-scrollbar-track { background: var(--bg-panel); }
#helm-controls::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Narrow viewport warning ─────────────────────────────────────────────── */
#narrow-warning {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}
@media (max-height: 500px) and (orientation: landscape) {
  #narrow-warning { display: flex; }
}
/* Portrait phone: phone layout takes over — suppress warning */
body.layout-phone #narrow-warning { display: none; }
#narrow-warning-box {
  max-width: 320px;
}
#narrow-warning h2 {
  font-size: 27px;
  font-weight: 600;
  color: var(--text-hi);
  margin-bottom: 16px;
  letter-spacing: 0.04em;
}
#narrow-warning p {
  font-size: 20px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
}

/* ── Phone layout (portrait phones ≤640px wide) ──────────────────────────── */
body.layout-phone #app-banner { display: none; }
body.layout-phone #app {
  flex-direction: column;
  height: 100svh;
}
body.layout-phone #chart-panel {
  order: 1;
  flex: 0 0 22%;
  width: 100%;
  min-width: 0;
  min-height: 0;
  position: relative;
}
body.layout-phone #sail-canvas {
  flex: none;
  width: 100%;
  height: 100%;
}
body.layout-phone #helm-panel {
  order: 2;
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  min-height: 0;
}
body.layout-phone #helm-top {
  flex: 2;
  flex-shrink: 1;
  min-height: 0;
  overflow: hidden;
}
body.layout-phone #helm-controls {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: visible;
}
body.layout-phone .hc-section {
  padding: 4px 6px 4px;
}

/* Hide desktop-only elements on phone */
body.layout-phone .panel-heading      { display: none; }
body.layout-phone #sim-col            { display: none; }
body.layout-phone #wind-triangle-label,
body.layout-phone #closeup-label      { display: none; }
body.layout-phone .hc-section-label   { display: none; }

/* ── Sub-panel header (title + close ×) — shown only in phone overlay mode ── */
.sub-panel-header {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 0 8px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.sub-panel-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sub-panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.sub-panel-close:hover { color: var(--text); }

/* Chart sub-panels become overlays on the canvas in phone mode */
body.layout-phone .chart-sub-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 15;
  border-bottom: none;
  border-radius: 0 0 6px 6px;
}
body.layout-phone .sub-panel-header { display: flex; }

/* ── Copyright badge + popover ───────────────────────────────────────────────── */
#btn-copyright {
  position: absolute;
  bottom: 8px; left: 8px;
  z-index: 20;
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 15px;
  color: rgba(160,200,180,0.50);
  cursor: pointer;
  line-height: 1;
}
#btn-copyright:hover { color: rgba(160,200,180,0.85); }

#copyright-popover {
  position: absolute;
  bottom: 32px; left: 8px;
  z-index: 25;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  max-width: 260px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  pointer-events: none;
}
#copyright-popover p { margin: 0; }
#copyright-popover[hidden] { display: none; }

/* ── Phone banner (title overlay on chart) ─────────────────────────────────── */
#phone-banner {
  display: none;
  position: absolute;
  top: 8px; left: 12px;
  z-index: 10;
  color: rgba(255,255,255,0.75);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
#app-banner .banner-beta,
#phone-banner .banner-beta {
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  color: #ffd84d;
  letter-spacing: 0.04em;
  text-transform: none;
  vertical-align: middle;
}
body.layout-phone #phone-banner { display: block; }

/* ── Hamburger button ──────────────────────────────────────────────────────── */
#btn-hamburger {
  display: none;
  position: absolute;
  top: 8px; right: 8px;
  z-index: 20;
  padding: 4px 12px;
  font-size: 22px;
  line-height: 1;
}
body.layout-phone #btn-hamburger { display: flex; align-items: center; }

/* ── Phone controls bar (Play/Pause + status below pad) ─────────────────── */
#phone-controls-bar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
}
body.layout-phone #phone-controls-bar { display: flex; }
#lbl-status-phone {
  font-size: 15px;
  font-weight: 600;
  color: #ffa040;
}

/* ── Phone menu (hamburger dropdown) ─────────────────────────────────────── */
#phone-menu {
  position: fixed;
  inset: 0;
  background: rgba(5,15,10,0.75);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
#phone-menu[hidden] { display: none; }
#phone-menu-content {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 0 8px;
  min-width: 190px;
}
.phone-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.phone-menu-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-hi);
}
#btn-phone-menu-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.phone-menu-items {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}
.phone-menu-item {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  text-align: left;
  padding: 11px 20px;
  cursor: pointer;
  width: 100%;
}
.phone-menu-item:hover, .phone-menu-item:active {
  background: rgba(40,72,58,0.5);
  color: var(--text-hi);
}
.phone-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 12px;
}

/* ── Race-course editor (hidden unless explicitly toggled) ───────────────── */

#race-edit-panel {
  position: absolute;
  top: 56px;
  right: 12px;
  z-index: 30;
  width: 220px;
  padding: 10px 12px;
  background: rgba(10, 26, 16, 0.94);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-size: 12px;
}
.race-edit-header {
  font-weight: 600;
  color: var(--text-hi);
  margin-bottom: 8px;
  font-size: 13px;
}
.race-edit-header #race-edit-lake {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 4px;
}
.race-edit-course-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.race-edit-course-row input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  background: var(--bg-ctrl);
  color: var(--text-hi);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}
.race-edit-course-row input:focus { outline: none; border-color: var(--accent); }
.race-edit-course-row .btn {
  padding: 6px 10px;
  font-size: 11px;
}
.race-edit-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}
.race-edit-tools .btn {
  padding: 6px 8px;
  font-size: 12px;
}
.race-edit-tools .btn.race-tool-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-hi);
}
.race-edit-status {
  font-size: 11px;
  color: var(--text-dim);
  min-height: 14px;
  margin-bottom: 8px;
}
.race-edit-actions {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}
.race-edit-actions .btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
}
.race-edit-hint {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}
