:root {
  --bg-deep: #06131f;
  --glass: rgba(8, 22, 34, 0.86);
  --glass-strong: rgba(7, 19, 30, 0.94);
  --glass-card: rgba(14, 34, 52, 0.78);
  --border: rgba(110, 195, 224, 0.24);
  --border-bright: rgba(56, 214, 245, 0.55);
  --text: #edf6fb;
  --ink: var(--text);
  --muted: #8eb0c2;
  --cyan: #38d6f5;
  --amber: #ffb443;
  --port: #ff5e6c;
  --stbd: #2ee6a6;
  --display: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Noto Sans TC', 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, a {
  -webkit-tap-highlight-color: transparent;
}

button, a {
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
svg:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

a {
  color: inherit;
}

/* =========================================================================
   Cockpit Shell (Desktop Full-Bleed 100dvh)
   ========================================================================= */

.cockpit {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.scene-stage {
  position: absolute;
  inset: 0;
  touch-action: none;
  background: radial-gradient(circle at 50% 35%, #5b93b5 0%, #1d4e6e 60%, #092033 100%);
}

.scene-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.scene-stage canvas:active {
  cursor: grabbing;
}

/* Glass Surface Utility (lightweight blur + layout containment for smooth 60fps) */
.hud-topbar,
.hud-left,
.hud-helm,
.hud-right {
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  box-shadow: 0 14px 36px rgba(2, 10, 18, 0.42);
  contain: layout style;
}

/* =========================================================================
   Top Command Bar
   ========================================================================= */

.hud-topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  height: 54px;
  border-radius: 14px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  z-index: 20;
}

.top-left,
.top-center,
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-text strong {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 1.6px;
}

.brand-text small {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.4px;
  color: var(--cyan);
}

.pos-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(56, 214, 245, 0.08);
  border: 1px solid rgba(56, 214, 245, 0.25);
  margin-left: 6px;
}

.pos-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.pos-meta span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.2px;
  color: var(--cyan);
}

.pos-meta strong {
  font-size: 13px;
}

.pos-twa {
  font-family: var(--mono);
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding-left: 10px;
  border-left: 1px solid rgba(143, 176, 194, 0.25);
}

.pos-twa b {
  font-size: 17px;
  color: #fff;
}

.pos-twa span {
  font-size: 10px;
  color: var(--muted);
}

.pill-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(4, 13, 22, 0.55);
  border: 1px solid rgba(110, 195, 224, 0.16);
}

.pill-group button {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.pill-group button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.pill-group button.active {
  background: rgba(56, 214, 245, 0.18);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(56, 214, 245, 0.45);
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 3px;
  border-radius: 2px;
}

.swatch.wind { background: var(--cyan); }
.swatch.apparent { background: var(--amber); }
.swatch.force { background: linear-gradient(90deg, var(--stbd) 50%, var(--port) 50%); }

.top-action {
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(110, 195, 224, 0.22);
  background: rgba(14, 34, 52, 0.55);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.15s, background 0.15s;
}

.top-action:hover {
  border-color: var(--cyan);
  background: rgba(56, 214, 245, 0.14);
}

.top-action.accent {
  border-color: rgba(255, 180, 67, 0.45);
  color: #ffe3b0;
}

.top-action.accent span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
}

/* =========================================================================
   Left Tactical Radar & Telemetry Pod
   ========================================================================= */

.hud-left {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 66px);
  left: max(12px, env(safe-area-inset-left));
  width: 268px;
  max-height: calc(100dvh - 92px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  z-index: 15;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 214, 245, 0.3) transparent;
}

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.block-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.6px;
  color: var(--cyan);
  font-weight: 700;
}

.tack-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tack-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tack-badge.starboard {
  color: var(--stbd);
  background: rgba(46, 230, 166, 0.14);
}

.tack-badge.port {
  color: var(--port);
  background: rgba(255, 94, 108, 0.14);
}

.tack-badge.neutral {
  color: var(--amber);
  background: rgba(255, 180, 67, 0.14);
}

.compass-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(4, 13, 22, 0.65);
  margin-bottom: 6px;
}

.compass-modes button {
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 5px;
  color: var(--muted);
}

.compass-modes button.active {
  background: rgba(56, 214, 245, 0.2);
  color: #fff;
  font-weight: 600;
}

#compass {
  width: 100%;
  max-width: 186px;
  margin: 0 auto;
  display: block;
  touch-action: none;
  cursor: crosshair;
  overflow: visible;
}

#compass text {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--muted);
}

.radar-outer {
  fill: rgba(4, 14, 24, 0.55);
  stroke: rgba(56, 214, 245, 0.35);
  stroke-width: 1.2;
}

.radar-mid {
  fill: none;
  stroke: rgba(110, 195, 224, 0.2);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.radar-inner {
  fill: none;
  stroke: rgba(110, 195, 224, 0.15);
  stroke-width: 1;
}

.radar-block p {
  margin: 4px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tel-tile {
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.16);
  border-radius: 10px;
  padding: 9px 10px;
}

.tel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

.tel-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  display: block;
}

.arc-gauge {
  width: 34px;
  height: 20px;
}

#heelIcon {
  width: 24px;
  height: 20px;
  transition: transform 0.2s ease;
}

.tel-val {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin: 2px 0;
}

.tel-val b {
  font-family: var(--mono);
  font-size: 21px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.tel-val em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.tel-tile small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coach-card {
  background: rgba(56, 214, 245, 0.08);
  border: 1px solid rgba(56, 214, 245, 0.22);
  border-radius: 10px;
  padding: 9px 11px;
}

.coach-card span {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  display: block;
  margin-bottom: 3px;
}

.coach-card p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
}

/* =========================================================================
   Bottom-Center Floating Helm Bar
   ========================================================================= */

.hud-helm {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  border-radius: 14px;
  padding: 8px 14px 7px;
  z-index: 16;
  max-width: calc(100vw - 630px);
  min-width: 520px;
}

.helm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.presets,
.maneuvers {
  display: flex;
  align-items: center;
  gap: 5px;
}

.presets button {
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(4, 14, 24, 0.55);
  border: 1px solid rgba(110, 195, 224, 0.16);
  transition: all 0.15s;
}

.presets button:hover {
  color: #fff;
  border-color: var(--cyan);
}

.presets button.active {
  background: var(--cyan);
  color: #05131f;
  font-weight: 700;
  border-color: var(--cyan);
}

.helm-divider {
  width: 1px;
  height: 22px;
  background: rgba(110, 195, 224, 0.22);
}

.maneuvers button {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 180, 67, 0.14);
  border: 1px solid rgba(255, 180, 67, 0.35);
  color: #ffe3b0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.maneuvers button small {
  font-size: 10.5px;
  font-weight: 400;
  opacity: 0.85;
}

.maneuvers button:hover:not(:disabled) {
  background: rgba(255, 180, 67, 0.28);
}

#reset {
  background: rgba(143, 176, 194, 0.12);
  border-color: rgba(143, 176, 194, 0.28);
  color: var(--text);
}

.maneuver-note {
  margin: 5px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   Right Floating Tabbed Console
   ========================================================================= */

.hud-right {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 66px);
  right: max(12px, env(safe-area-inset-right));
  width: 318px;
  max-height: calc(100dvh - 92px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  z-index: 15;
  transition: width 0.22s ease, transform 0.22s ease, opacity 0.2s ease;
}

.hud-right.collapsed {
  width: 176px;
  max-height: calc(100dvh - 92px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  padding: 8px;
}

.hud-right.collapsed .right-full-body,
.hud-right.collapsed .console-footer {
  display: none;
}

.right-full-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.console-head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 4px;
}

.console-head-bar span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--cyan);
  font-weight: 700;
}

.right-mini-bar {
  display: none;
  flex-direction: column;
  gap: 7px;
}

.hud-right.collapsed .right-mini-bar {
  display: flex;
}

.mini-toggle-btn,
.panel-collapse-btn {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(56, 214, 245, 0.12);
  border: 1px solid rgba(56, 214, 245, 0.32);
  white-space: nowrap;
  touch-action: manipulation;
}

.mini-toggle-btn:hover,
.panel-collapse-btn:hover {
  background: rgba(56, 214, 245, 0.24);
  color: #fff;
}

.mini-toggle-btn.full {
  width: 100%;
  padding: 7px 10px;
}

.mini-mode-btn,
.mini-reef-btn {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  background: rgba(8, 22, 34, 0.65);
  border: 1px solid rgba(110, 195, 224, 0.24);
  touch-action: manipulation;
}

.mini-mode-btn.active {
  background: rgba(46, 230, 166, 0.18);
  border-color: rgba(46, 230, 166, 0.45);
  color: #aef7dc;
}

.mini-stepper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 7px;
  border-radius: 9px;
  background: rgba(4, 14, 24, 0.55);
  border: 1px solid rgba(110, 195, 224, 0.16);
}

.mini-stepper > span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

.mini-stepper > div {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 4px;
}

.mini-stepper b {
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--cyan);
}

.mini-stepper button {
  height: 28px;
  border-radius: 6px;
  background: rgba(56, 214, 245, 0.14);
  border: 1px solid rgba(56, 214, 245, 0.28);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
}

/* Left Panel Collapse & Mini Bar */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.left-mini-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.left-mini-metrics {
  display: flex;
  align-items: center;
  gap: 9px;
}

.left-mini-metrics span {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--mono);
}

.left-mini-metrics small {
  font-size: 9px;
  color: var(--muted);
}

.left-mini-metrics b {
  font-size: 13px;
  color: var(--cyan);
}

.left-mini-metrics em {
  font-style: normal;
  font-size: 9.5px;
  color: var(--muted);
}

.left-full-body {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.hud-left.collapsed {
  width: auto;
  min-width: 228px;
  padding: 8px 10px;
  overflow: visible;
}

.hud-left.collapsed .left-full-body {
  display: none;
}

.hud-left.collapsed .left-mini-bar {
  display: flex;
}

/* Bottom Helm Collapse (keeps steering + tack/jibe operable) */
.hud-helm.collapsed {
  min-width: 0;
  padding: 7px 10px;
}

.hud-helm.collapsed .presets,
.hud-helm.collapsed .helm-divider,
.hud-helm.collapsed #reset,
.hud-helm.collapsed .maneuver-note {
  display: none;
}

/* Top Bar Collapse & Mini Pill */
.hud-topbar.collapsed {
  display: none;
}

.topbar-mini {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 21;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(7, 21, 35, 0.84);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar-mini[hidden] {
  display: none;
}

body.topbar-collapsed .hud-left,
body.topbar-collapsed .hud-right {
  top: calc(max(12px, env(safe-area-inset-top)) + 48px);
  max-height: calc(100dvh - 70px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

body.topbar-collapsed .voyage-hud {
  top: max(12px, env(safe-area-inset-top));
}

.steer-btn,
.hud-helm button,
.right-mini-bar button,
.left-mini-bar button {
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.console-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: rgba(56, 214, 245, 0.18);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(56, 214, 245, 0.42);
}

.console-body {
  padding: 14px 15px;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 214, 245, 0.3) transparent;
}

.pane-head {
  margin-bottom: 12px;
}

.pane-head span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--cyan);
  display: block;
}

.pane-head h3 {
  margin: 2px 0 0;
  font-size: 16px;
  font-family: var(--display);
}

.range-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  margin-top: 12px;
  margin-bottom: 5px;
}

.range-label output {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-x;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--cyan) 0%,
    var(--cyan) var(--fill, 50%),
    rgba(143, 176, 194, 0.22) var(--fill, 50%),
    rgba(143, 176, 194, 0.22) 100%
  );
  outline: none;
  margin: 4px 0;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--cyan);
  box-shadow: 0 0 10px rgba(56, 214, 245, 0.65);
  cursor: pointer;
}

input[type='range']::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--cyan);
  cursor: pointer;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}

.mini-info-box {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.16);
}

.mini-info-box strong {
  font-size: 11.5px;
  color: var(--cyan);
  display: block;
  margin-bottom: 4px;
}

.mini-info-box p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 10px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: rgba(4, 14, 24, 0.65);
  gap: 3px;
}

.segmented button {
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 6px;
  color: var(--muted);
}

.segmented button.active {
  background: rgba(56, 214, 245, 0.22);
  color: #fff;
  font-weight: 600;
}

.target-trim {
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.2);
  border-radius: 10px;
  padding: 10px 11px;
  margin-bottom: 8px;
}

.target-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  margin-bottom: 6px;
}

.target-heading small {
  color: var(--muted);
  margin-left: 3px;
}

#alignTrim {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(56, 214, 245, 0.18);
  border: 1px solid rgba(56, 214, 245, 0.4);
  color: var(--cyan);
}

#alignTrim:hover {
  background: var(--cyan);
  color: #05131f;
}

.target-angles {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
}

.target-angles b {
  font-family: var(--mono);
  color: #fff;
}

.target-angles small {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--stbd);
}

.trim-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  background: var(--glass-card);
  border: 1px solid rgba(46, 230, 166, 0.28);
}

.trim-feedback[data-state='luff'] {
  border-color: rgba(255, 180, 67, 0.4);
}

.trim-feedback[data-state='stall'] {
  border-color: rgba(255, 94, 108, 0.4);
}

#telltalePreview {
  width: 56px;
  height: 44px;
  flex-shrink: 0;
  background: rgba(4, 13, 22, 0.6);
  border-radius: 8px;
}

.trim-feedback strong {
  display: block;
  font-size: 12.5px;
}

.trim-feedback p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.input-note {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.45;
}

/* Spinnaker Tab */
.spin-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.16);
}

.spin-heading strong {
  display: block;
  font-size: 13px;
}

.spin-heading small {
  font-size: 10.5px;
  color: var(--muted);
}

#toggleSpinnaker {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--cyan);
  color: #05131f;
  font-size: 12px;
  font-weight: 700;
}

#toggleSpinnaker[aria-pressed='true'] {
  background: var(--port);
  color: #fff;
}

.spin-hoist-steps ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  list-style: none;
  padding: 0;
  margin: 8px 0 6px;
}

.spin-hoist-steps li {
  background: rgba(4, 14, 24, 0.65);
  border: 1px solid rgba(110, 195, 224, 0.15);
  border-radius: 7px;
  padding: 5px;
  font-size: 10.5px;
  text-align: center;
  color: var(--muted);
}

.spin-hoist-steps li.active {
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 700;
}

.spin-hoist-steps li.done {
  border-color: rgba(46, 230, 166, 0.45);
  color: var(--stbd);
}

.spin-hoist-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(143, 176, 194, 0.2);
  overflow: hidden;
  margin-bottom: 8px;
}

.spin-hoist-track i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--amber);
}

.spin-advice {
  font-size: 12px;
  font-weight: 600;
  color: var(--cyan);
  margin: 6px 0 2px;
}

.spin-route-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(110, 195, 224, 0.2);
}

.route-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.route-head span {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.spin-route-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 7px 0;
}

.spin-route-buttons button {
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
  border: 1px solid rgba(110, 195, 224, 0.2);
  background: rgba(4, 14, 24, 0.5);
  color: var(--muted);
}

.spin-route-buttons button.active {
  background: rgba(255, 180, 67, 0.18);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 700;
}

#spinRouteText {
  font-size: 11px;
  color: var(--text);
  margin: 0 0 7px;
}

#spinDiagram {
  width: 100%;
  background: rgba(4, 14, 24, 0.72);
  border: 1px solid rgba(110, 195, 224, 0.2);
  border-radius: 9px;
  display: block;
}

.diagram-label {
  font-size: 10px;
  fill: var(--muted);
}

.spin-demo-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 6px;
  margin-top: 9px;
}

.spin-demo-actions button {
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid rgba(56, 214, 245, 0.35);
  background: rgba(56, 214, 245, 0.12);
  color: var(--cyan);
}

.spin-demo-actions button:hover:not(:disabled) {
  background: rgba(56, 214, 245, 0.24);
}

.reef-row {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.reef-row .segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.console-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
}

/* =========================================================================
   3D Stage Labels & Maneuver Overlay
   ========================================================================= */

.labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.part-label,
.spin-hatch-label,
.spin-corner-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.part-label {
  background: rgba(8, 22, 34, 0.88);
  border: 1px solid rgba(56, 214, 245, 0.45);
  color: var(--text);
}

.spin-hatch-label {
  background: rgba(56, 214, 245, 0.92);
  color: #05131f;
}

.spin-corner-label {
  background: rgba(255, 180, 67, 0.94);
  color: #081622;
}

.spin-note-floating {
  position: absolute;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  background: var(--glass-strong);
  border: 1px solid rgba(255, 180, 67, 0.45);
  color: var(--amber);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  z-index: 12;
}

.maneuver-overlay {
  position: absolute;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  min-width: 250px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--glass-strong);
  border: 1px solid rgba(56, 214, 245, 0.42);
  backdrop-filter: blur(14px);
  text-align: center;
  pointer-events: none;
  z-index: 13;
}

.maneuver-overlay span {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--amber);
}

.maneuver-overlay strong {
  display: block;
  font-size: 14px;
  margin: 3px 0 8px;
}

.maneuver-progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(143, 176, 194, 0.2);
  overflow: hidden;
  margin-bottom: 6px;
}

.maneuver-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--cyan);
}

.maneuver-overlay p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.load-message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--glass-strong);
  border: 1px solid var(--border);
  padding: 15px 22px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 18;
}

.load-message span {
  display: inline-block;
  border: 2px solid var(--cyan);
  border-top-color: transparent;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================================
   Slide-Over Lessons Drawer & About Modal
   ========================================================================= */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 18, 0.58);
  backdrop-filter: blur(4px);
  z-index: 40;
}

.lessons-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(680px, 96vw);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-right: env(safe-area-inset-right);
  background: #081826;
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.55);
  z-index: 45;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lessons-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h2 {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: 20px;
}

.drawer-close {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 22px;
  line-height: 1;
}

.drawer-close:hover {
  background: rgba(255, 94, 108, 0.22);
  color: var(--port);
}

.spec-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 22px;
  background: rgba(56, 214, 245, 0.07);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.spec-bar b {
  color: var(--cyan);
}

.lesson-list {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lesson-card {
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.2);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 0.15s, transform 0.15s;
}

.lesson-card:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.lesson-card.active {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(255, 180, 67, 0.45);
}

.lesson-progress-wrap {
  padding: 12px 22px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 16, 27, 0.55);
}

.lesson-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.lesson-progress-top b {
  font-family: var(--mono);
  color: var(--stbd);
}

.lesson-filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.lesson-filter-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(110, 195, 224, 0.22);
  background: rgba(8, 22, 34, 0.72);
  font-size: 11.5px;
  color: var(--muted);
  touch-action: manipulation;
  transition: all 0.15s;
}

.lesson-filter-btn:hover {
  color: #fff;
  border-color: var(--cyan);
}

.lesson-filter-btn.active {
  background: rgba(56, 214, 245, 0.2);
  border-color: var(--cyan);
  color: var(--cyan);
  font-weight: 700;
}

.lesson-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lesson-level-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 214, 245, 0.14);
  color: var(--cyan);
}

.lesson-done-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(46, 230, 166, 0.16);
  color: var(--stbd);
}

.lesson-svg-box {
  background: rgba(4, 13, 22, 0.85);
  border: 1px solid rgba(56, 214, 245, 0.24);
  border-radius: 10px;
  padding: 6px;
  margin: 8px 0 10px;
}

.lesson-svg-box svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.lesson-analogy {
  background: rgba(56, 214, 245, 0.08);
  border-left: 3px solid var(--cyan);
  border-radius: 0 8px 8px 0;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.55;
  color: #dff4ff;
}

.lesson-analogy b {
  color: var(--cyan);
  margin-right: 4px;
}

.lesson-pitfall {
  background: rgba(255, 180, 67, 0.1);
  border: 1px solid rgba(255, 180, 67, 0.34);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #ffe8c2;
}

.lesson-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.lesson-sub-btn {
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(110, 195, 224, 0.25);
  background: rgba(7, 20, 32, 0.78);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  touch-action: manipulation;
}

.lesson-sub-btn:hover {
  border-color: var(--cyan);
  color: #fff;
}

.lesson-sub-btn.done {
  border-color: rgba(46, 230, 166, 0.45);
  color: var(--stbd);
  background: rgba(46, 230, 166, 0.1);
}

/* Live 3D Lesson Mission Card (Left HUD) */
.mission-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 180, 67, 0.42);
  background: rgba(7, 22, 36, 0.9);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: 0 10px 26px rgba(2, 8, 16, 0.45);
}

.mission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mission-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--amber);
}

#closeMissionCard {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(110, 195, 224, 0.24);
  background: rgba(10, 28, 44, 0.8);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}

.mission-card strong {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.35;
}

.mission-steps {
  margin: 0;
  padding-left: 16px;
  font-size: 11.5px;
  line-height: 1.48;
  color: var(--muted);
  max-height: 105px;
  overflow-y: auto;
  touch-action: pan-y;
}

.mission-steps li {
  margin-bottom: 3px;
}

.mission-status {
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.42;
  background: rgba(56, 214, 245, 0.12);
  border: 1px solid rgba(56, 214, 245, 0.32);
  color: #dff4ff;
}

.mission-status.done {
  background: rgba(46, 230, 166, 0.16);
  border-color: rgba(46, 230, 166, 0.5);
  color: #c2ffea;
  font-weight: 600;
}

.mission-actions {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.mission-btn {
  flex: 1 1 auto;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(110, 195, 224, 0.28);
  background: rgba(10, 28, 44, 0.85);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  touch-action: manipulation;
}

.mission-btn.next {
  border-color: rgba(255, 180, 67, 0.45);
  color: var(--amber);
}

.lesson-card .eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--amber);
}

.lesson-card h3 {
  margin: 4px 0 8px;
  font-size: 17px;
  font-family: var(--display);
}

.lesson-card p {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.lesson-steps {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
}

.lesson-btn {
  padding: 7px 14px;
  border-radius: 8px;
  background: rgba(56, 214, 245, 0.16);
  border: 1px solid rgba(56, 214, 245, 0.4);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
}

.lesson-btn:hover {
  background: var(--cyan);
  color: #05131f;
}

/* Drawer Tabs & Body */
.drawer-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 16, 27, 0.72);
}

.dtab-btn {
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.dtab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.dtab-btn.active {
  background: rgba(56, 214, 245, 0.18);
  color: var(--cyan);
  border-color: rgba(56, 214, 245, 0.45);
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 214, 245, 0.3) transparent;
}

/* ASA Course Units */
.asa-hero {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(56, 214, 245, 0.1) 0%, rgba(255, 180, 67, 0.06) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.asa-hero h3 {
  margin: 2px 0 4px;
  font-family: var(--display);
  font-size: 17px;
}

.asa-hero p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  max-width: 420px;
}

.asa-quiz-cta {
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--amber);
  color: #05131f;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.asa-quiz-cta:hover {
  filter: brightness(1.08);
}

.asa-unit-list {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.asa-unit-card {
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.2);
  border-radius: 12px;
  padding: 16px 18px;
}

.asa-unit-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.asa-unit-head span {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 1.2px;
}

.asa-unit-head small {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.asa-unit-card h4 {
  margin: 4px 0 8px;
  font-family: var(--display);
  font-size: 16px;
}

.asa-unit-card > p {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.asa-points {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

.asa-points li {
  margin-bottom: 4px;
}

.term-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.term-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(4, 14, 24, 0.72);
  border: 1px solid rgba(110, 195, 224, 0.22);
  color: var(--text);
}

.term-chip b {
  font-family: var(--mono);
  color: var(--cyan);
  font-weight: 600;
  margin-right: 4px;
}

/* Visual Course Reader & Interactive Mini-Labs */
.course-progress-wrap {
  padding: 12px 22px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 16, 27, 0.55);
}

.course-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.course-progress-top b {
  font-family: var(--mono);
  color: var(--stbd);
}

.course-progress-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(143, 176, 194, 0.18);
  overflow: hidden;
  margin-bottom: 10px;
}

.course-progress-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--stbd));
  transition: width 0.25s ease;
}

.chapter-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chapter-pill {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  border: 1px solid rgba(110, 195, 224, 0.18);
  background: rgba(8, 22, 34, 0.68);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  transition: all 0.15s;
}

.chapter-pill:hover {
  color: #fff;
  border-color: var(--cyan);
}

.chapter-pill.active {
  background: rgba(56, 214, 245, 0.18);
  border-color: var(--cyan);
  color: #fff;
}

.chapter-pill.done::after {
  content: '✓';
  font-family: var(--mono);
  font-size: 11px;
  color: var(--stbd);
}

.unit-reader {
  padding: 16px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unit-visual-box {
  background: rgba(4, 13, 22, 0.85);
  border: 1px solid rgba(56, 214, 245, 0.28);
  border-radius: 12px;
  padding: 8px;
}

.unit-visual-box svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.beginner-tip {
  background: rgba(255, 180, 67, 0.1);
  border: 1px solid rgba(255, 180, 67, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: #ffe8c2;
}

.beginner-tip strong {
  color: var(--amber);
  display: block;
  font-size: 11.5px;
  margin-bottom: 2px;
}

.mini-lab {
  background: rgba(12, 32, 48, 0.85);
  border: 1px solid rgba(56, 214, 245, 0.32);
  border-radius: 12px;
  padding: 12px 14px;
}

.mini-lab-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.mini-lab-head strong {
  font-size: 13px;
  color: var(--cyan);
}

.mini-lab-head span {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.lab-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.lab-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}

.lab-field b {
  font-family: var(--mono);
  color: #fff;
}

.lab-field select {
  background: rgba(4, 14, 24, 0.85);
  border: 1px solid rgba(110, 195, 224, 0.3);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 11.5px;
}

.lab-result {
  background: rgba(4, 14, 24, 0.72);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.55;
}

.lab-result strong {
  font-family: var(--mono);
  color: var(--amber);
  font-size: 14px;
}

.night-sky-sim {
  background: #020810;
  border: 1px solid rgba(110, 195, 224, 0.25);
  border-radius: 8px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
  position: relative;
}

.night-horizon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  height: 1px;
  background: rgba(56, 214, 245, 0.22);
}

.light-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  z-index: 2;
}

.light-dot.red { background: #ff4757; box-shadow: 0 0 14px #ff4757; }
.light-dot.green { background: #2ee6a6; box-shadow: 0 0 14px #2ee6a6; }
.light-dot.white { background: #fff9e6; box-shadow: 0 0 14px #fff9e6; transform: translateY(-16px); }
.light-dot.stern { background: #fff9e6; box-shadow: 0 0 14px #fff9e6; }

.mini-check {
  background: rgba(8, 22, 34, 0.85);
  border: 1px solid rgba(110, 195, 224, 0.22);
  border-radius: 12px;
  padding: 12px 14px;
}

.mini-check > span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--cyan);
}

.mini-check h5 {
  margin: 4px 0 8px;
  font-size: 13px;
  line-height: 1.5;
}

.mini-check-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-check-opt {
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(110, 195, 224, 0.2);
  background: rgba(4, 14, 24, 0.65);
  font-size: 12px;
}

.mini-check-opt:hover:not(:disabled) {
  border-color: var(--cyan);
}

.mini-check-opt.ok {
  border-color: var(--stbd);
  background: rgba(46, 230, 166, 0.16);
  color: var(--stbd);
}

.mini-check-opt.no {
  border-color: var(--port);
  background: rgba(255, 94, 108, 0.16);
  color: var(--port);
}

.mini-check-why {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.5;
}

.unit-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* Interactive COLREGs Visual Sandbox */
.colregs-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.colregs-pill {
  padding: 6px 6px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(110, 195, 224, 0.22);
  background: rgba(4, 14, 24, 0.72);
  color: var(--muted);
  transition: all 0.14s;
}

.colregs-pill:hover {
  color: #fff;
  border-color: var(--cyan);
}

.colregs-pill.active {
  background: rgba(56, 214, 245, 0.2);
  border-color: var(--cyan);
  color: var(--cyan);
}

.colregs-stage {
  width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid rgba(56, 214, 245, 0.28);
  background: #030e18;
  margin-bottom: 9px;
}

.colregs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.colregs-guess {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid rgba(110, 195, 224, 0.28);
  background: rgba(4, 14, 24, 0.75);
  color: var(--text);
}

.colregs-guess:hover {
  border-color: var(--cyan);
}

.colregs-guess.ok {
  border-color: var(--stbd);
  background: rgba(46, 230, 166, 0.18);
  color: var(--stbd);
}

.colregs-guess.no {
  border-color: var(--port);
  background: rgba(255, 94, 108, 0.18);
  color: var(--port);
}

.colregs-verdict {
  background: rgba(4, 14, 24, 0.75);
  border: 1px solid rgba(56, 214, 245, 0.24);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.55;
}

.colregs-verdict strong {
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
}

@media (max-width: 560px) {
  .chapter-pills,
  .colregs-pills {
    grid-template-columns: repeat(2, 1fr);
  }
  .lab-grid {
    grid-template-columns: 1fr;
  }
}

/* Interactive Quiz UI */
.quiz-wrap {
  padding: 18px 22px 26px;
}

.quiz-lobby-intro {
  margin-bottom: 16px;
}

.quiz-lobby-intro h3 {
  margin: 4px 0 6px;
  font-family: var(--display);
  font-size: 18px;
}

.quiz-lobby-intro p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

.quiz-tracks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-track-card {
  background: var(--glass-card);
  border: 1px solid rgba(110, 195, 224, 0.22);
  border-radius: 12px;
  padding: 15px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.quiz-track-card h4 {
  margin: 3px 0 4px;
  font-family: var(--display);
  font-size: 16px;
}

.quiz-track-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.best-badge {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(46, 230, 166, 0.14);
  color: var(--stbd);
}

.quiz-start-btn {
  padding: 9px 15px;
  border-radius: 9px;
  background: var(--cyan);
  color: #05131f;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.quiz-start-btn:hover {
  filter: brightness(1.08);
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.quiz-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  font-weight: 700;
}

.quiz-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.quiz-progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(143, 176, 194, 0.2);
  overflow: hidden;
  margin-bottom: 14px;
}

.quiz-progress i {
  display: block;
  height: 100%;
  background: var(--cyan);
  transition: width 0.2s ease;
}

.quiz-diagram-box {
  margin-bottom: 12px;
}

.quiz-svg {
  width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid rgba(110, 195, 224, 0.24);
}

.quiz-prompt {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.58;
  margin: 0 0 14px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-opt {
  text-align: left;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid rgba(110, 195, 224, 0.24);
  background: rgba(6, 18, 30, 0.72);
  font-size: 13px;
  line-height: 1.48;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: border-color 0.14s, background 0.14s;
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--cyan);
  background: rgba(56, 214, 245, 0.12);
}

.quiz-opt b {
  font-family: var(--mono);
  color: var(--cyan);
  flex-shrink: 0;
}

.quiz-opt.correct {
  border-color: var(--stbd);
  background: rgba(46, 230, 166, 0.16);
}

.quiz-opt.correct b {
  color: var(--stbd);
}

.quiz-opt.wrong {
  border-color: var(--port);
  background: rgba(255, 94, 108, 0.16);
}

.quiz-opt.wrong b {
  color: var(--port);
}

.quiz-opt.dimmed {
  opacity: 0.55;
}

.quiz-explain {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(56, 214, 245, 0.08);
  border: 1px solid rgba(56, 214, 245, 0.26);
}

.quiz-explain strong {
  display: block;
  font-size: 12.5px;
  margin-bottom: 4px;
}

.quiz-explain p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.58;
}

.quiz-nav {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quiz-back-link {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid rgba(143, 176, 194, 0.2);
}

.quiz-back-link:hover {
  color: #fff;
  border-color: var(--muted);
}

.quiz-report-head {
  text-align: center;
  padding: 18px;
  border-radius: 12px;
  background: var(--glass-card);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.score-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 12px;
  margin: 6px 0;
}

.score-badge.pass {
  color: var(--stbd);
  background: rgba(46, 230, 166, 0.15);
}

.score-badge.fail {
  color: var(--port);
  background: rgba(255, 94, 108, 0.15);
}

.missed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.missed-item {
  background: rgba(255, 94, 108, 0.08);
  border: 1px solid rgba(255, 94, 108, 0.28);
  border-radius: 10px;
  padding: 12px 14px;
}

.missed-item h5 {
  margin: 0 0 6px;
  font-size: 13px;
}

.missed-item p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.quiz-report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

dialog#aboutDialog {
  max-width: 640px;
  max-height: 88dvh;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  width: calc(100% - 28px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 28px;
  background: #081826;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

dialog#aboutDialog::backdrop {
  background: rgba(3, 10, 18, 0.68);
  backdrop-filter: blur(5px);
}

.dialog-close {
  float: right;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
}

dialog#aboutDialog h2 {
  font-family: var(--display);
  margin: 6px 0 12px;
}

dialog#aboutDialog p {
  font-size: 13px;
  line-height: 1.68;
  color: var(--muted);
}

dialog#aboutDialog h3 {
  font-size: 14px;
  color: var(--cyan);
  margin: 16px 0 8px;
}

dialog#aboutDialog ul {
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.75;
}

dialog#aboutDialog a {
  color: var(--cyan);
}

/* =========================================================================
   Responsive / Tablet & Mobile Stack
   ========================================================================= */

@media (max-width: 1280px) {
  .hud-topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px 10px;
  }
  .hud-left,
  .hud-right {
    top: calc(max(12px, env(safe-area-inset-top)) + 104px);
    max-height: calc(100dvh - 128px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .hud-helm {
    min-width: 0;
    max-width: calc(100vw - 24px);
    padding: 7px 10px;
  }
  .presets button {
    padding: 5px 6px;
    font-size: 11px;
  }
  .maneuvers button small {
    display: none;
  }
}

/* iPad & Tablet Full-Bleed Adaptation (701px - 1180px) */
@media (min-width: 701px) and (max-width: 1180px) {
  .hud-left {
    width: 236px;
    padding: 10px;
  }
  .hud-right {
    width: 272px;
  }
  .hud-right.collapsed {
    width: 164px;
  }
  .hud-helm {
    max-width: calc(100vw - 24px);
  }
  .hud-helm .presets button {
    padding: 6px 8px;
    font-size: 11px;
  }
}

@media (max-width: 700px) {
  .cockpit {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    touch-action: pan-y;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: var(--bg-deep);
  }
  .hud-topbar {
    position: static;
    grid-column: 1 / -1;
    height: auto;
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .scene-stage {
    position: relative;
    grid-column: 1 / -1;
    height: 58vh;
    min-height: 360px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
  }
  .hud-helm {
    position: static;
    transform: none;
    grid-column: 1 / -1;
    max-width: none;
    min-width: 0;
  }
  .hud-left,
  .hud-right {
    position: static;
    width: auto !important;
    max-height: none;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .top-center {
    flex-wrap: wrap;
  }
  .pos-pill {
    display: none;
  }
}

@media (pointer: coarse) {
  .pill-group button,
  .top-action,
  .presets button,
  .maneuvers button,
  .tab-btn,
  .dtab-btn,
  .lesson-btn,
  .quiz-start-btn,
  .warp-btn,
  .voyage-trim-btn,
  .voyage-exit-btn,
  .mini-toggle-btn,
  .panel-collapse-btn,
  .mini-mode-btn,
  .mini-reef-btn {
    min-height: 44px;
  }
  .mini-stepper button {
    height: 36px;
  }
  .mini-stepper > div {
    grid-template-columns: 36px 1fr 36px;
  }
  .steer-btn {
    min-height: 46px;
    min-width: 86px;
    padding: 8px 14px;
    font-size: 13.5px;
  }
  input[type='range'] {
    height: 10px;
  }
  input[type='range']::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }
  input[type='range']::-moz-range-thumb {
    width: 26px;
    height: 26px;
  }
}

/* ============================================================================
   Coastal Passage / Long-Distance Voyage Challenge UI
   ============================================================================ */

.top-action.voyage-btn {
  border-color: rgba(255, 180, 67, 0.52);
  background: linear-gradient(135deg, rgba(255, 180, 67, 0.16), rgba(56, 214, 245, 0.1));
  color: #ffe2ad;
}

.top-action.voyage-btn span {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 180, 67, 0.22);
  color: var(--amber);
}

.voyage-hud {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  max-width: calc(100vw - 680px);
  min-width: 520px;
  border-radius: 14px;
  border: 1px solid rgba(56, 214, 245, 0.32);
  background: rgba(6, 19, 32, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(2, 8, 16, 0.55);
  padding: 8px 12px;
  pointer-events: auto;
}

.voyage-hud-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.voyage-wp-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 132px;
}

.voyage-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--amber);
}

.voyage-wp-group strong {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
}

.voyage-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voyage-metrics span {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--mono);
}

.voyage-metrics small {
  font-size: 10px;
  color: var(--muted);
}

.voyage-metrics b {
  font-size: 13.5px;
  color: var(--cyan);
}

.voyage-metrics em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
}

.voyage-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.steer-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(110, 195, 224, 0.28);
  background: rgba(10, 30, 48, 0.85);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.steer-btn:hover,
.steer-btn.active {
  border-color: var(--cyan);
  background: rgba(56, 214, 245, 0.2);
}

.voyage-warp {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(110, 195, 224, 0.24);
}

.warp-btn {
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(8, 22, 36, 0.82);
  color: var(--muted);
}

.warp-btn.active {
  background: rgba(255, 180, 67, 0.24);
  color: var(--amber);
  font-weight: 700;
}

.voyage-icon-btn,
.voyage-exit-btn {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid rgba(110, 195, 224, 0.24);
  background: rgba(8, 22, 36, 0.8);
  font-size: 12px;
  color: var(--muted);
}

.voyage-exit-btn:hover {
  border-color: var(--port);
  color: #ffb8bf;
}

.voyage-alert {
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 180, 67, 0.16);
  border: 1px solid rgba(255, 180, 67, 0.4);
  color: #ffe3b0;
  text-align: center;
}

.voyage-alert.danger {
  background: rgba(255, 94, 108, 0.2);
  border-color: rgba(255, 94, 108, 0.55);
  color: #ffd0d5;
}

.voyage-alert.good {
  background: rgba(46, 230, 166, 0.16);
  border-color: rgba(46, 230, 166, 0.45);
  color: #c2ffea;
}

.voyage-chart-card {
  border-radius: 14px;
  border: 1px solid rgba(56, 214, 245, 0.26);
  background: rgba(5, 18, 30, 0.78);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voyage-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.voyage-chart-head strong {
  font-family: var(--mono);
  color: var(--stbd);
  font-size: 11.5px;
}

#voyageChartSvg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 45%, #0c263e 0%, #05121e 100%);
  border: 1px solid rgba(110, 195, 224, 0.2);
}

.voyage-chart-tip {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

dialog#voyageDialog {
  width: min(640px, 94vw);
  max-height: 88dvh;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
  border: 1px solid rgba(110, 195, 224, 0.28);
  background: rgba(7, 21, 35, 0.96);
  color: var(--ink);
  padding: 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

dialog#voyageDialog::backdrop {
  background: rgba(2, 8, 15, 0.72);
  backdrop-filter: blur(4px);
}

dialog#voyageDialog h2 {
  margin: 6px 0 8px;
  font-size: 20px;
}

.voyage-route-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.voyage-route-card {
  border-radius: 12px;
  border: 1px solid rgba(110, 195, 224, 0.22);
  background: rgba(10, 28, 44, 0.78);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voyage-route-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.voyage-route-head h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.voyage-route-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
}

.voyage-route-meta span {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 214, 245, 0.12);
}

.voyage-route-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.voyage-route-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.voyage-skills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.voyage-skills span {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(143, 176, 194, 0.14);
  color: var(--ink);
}

.voyage-go-btn {
  padding: 8px 16px;
  border-radius: 9px;
  background: var(--cyan);
  color: #05131f;
  font-size: 13px;
  font-weight: 700;
}

.voyage-go-btn:hover {
  filter: brightness(1.08);
}

.voyage-stars {
  font-size: 28px;
  letter-spacing: 6px;
  color: var(--amber);
  margin: 8px 0 12px;
}

.voyage-debrief-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.voyage-stat-cell {
  border-radius: 10px;
  border: 1px solid rgba(110, 195, 224, 0.2);
  background: rgba(5, 17, 29, 0.72);
  padding: 10px;
}

.voyage-stat-cell small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.voyage-stat-cell b {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--ink);
}

.voyage-debrief-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voyage-secondary-btn {
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid rgba(110, 195, 224, 0.28);
  background: rgba(10, 28, 44, 0.8);
  color: var(--ink);
  font-size: 13px;
}

@media (max-width: 1280px) {
  .voyage-hud {
    top: calc(max(12px, env(safe-area-inset-top)) + 104px);
    max-width: calc(100vw - 620px);
    min-width: 0;
  }
}

@media (max-width: 980px) {
  .voyage-hud {
    top: 10px;
    width: calc(100% - 20px);
    max-width: none;
  }
  .voyage-debrief-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.voyage-helm-row {
  gap: 10px;
}

.voyage-steer-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.voyage-steer-group .steer-btn small {
  margin-left: 3px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--cyan);
}

.voyage-trim-btn {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid rgba(46, 230, 166, 0.34);
  background: rgba(11, 36, 42, 0.85);
  color: #bdfae3;
  font-size: 12px;
  font-weight: 600;
  touch-action: manipulation;
}

.voyage-trim-btn:hover {
  border-color: var(--stbd);
  background: rgba(46, 230, 166, 0.18);
}

.maneuvers button.dimmed {
  opacity: 0.5;
}
