/* Farbwelt: Join The Crew (Petrol, Mint, Gelb, Creme) */
:root {
  --panel: rgba(18, 42, 44, 0.88);
  --panel-border: rgba(71, 237, 188, 0.22);
  --text: #f9f6f3;
  --text-dim: #9fb7b0;
  --accent: #47edbc;
  --good: #34cfa1;
  --warn: #ffd12f;
  --bad: #ff554a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: var(--font); color: var(--text); }
body { background: #0e3235; overscroll-behavior: none; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
canvas#sea { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
canvas#sea.dragging { cursor: grabbing; }

.hidden { display: none !important; }

/* ---------- Topbar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(6px); z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.3px; white-space: nowrap; }
#topbar select, #topbar button {
  background: rgba(255,255,255,0.08); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
}
#topbar select:hover, #topbar button:hover { background: rgba(255,255,255,0.16); }
#topbar button.active { background: var(--accent); color: #113b34; border-color: var(--accent); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 24px; height: auto; display: block; }
.windctl { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.windctl .lbl { color: var(--text-dim); font-size: 13px; }
.windctl .val { font-size: 13px; min-width: 44px; font-variant-numeric: tabular-nums; }
.windctl input[type="range"] { width: 110px; accent-color: var(--accent); }

/* ---------- Leinen-Panel ---------- */
#linesPanel {
  position: fixed; left: 14px; top: 68px; width: 304px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 12px; z-index: 15; backdrop-filter: blur(6px);
}
.panel-title { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.panel-title .chev { transition: transform 0.2s; }
#linesPanel.collapsed .line-row { display: none; }
#linesPanel.collapsed { padding-bottom: 6px; }
#linesPanel.collapsed .panel-title { margin-bottom: 0; }
#linesPanel.collapsed .chev { transform: rotate(-90deg); }
.line-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto auto; align-items: center;
  gap: 6px; padding: 6px 4px; border-radius: 8px;
}
.line-row + .line-row { border-top: 1px solid rgba(255,255,255,0.06); }
.line-dot { width: 9px; height: 9px; border-radius: 50%; background: #4a5a68; }
.line-dot.fest { background: var(--good); box-shadow: 0 0 6px var(--good); }
.line-dot.steif { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.line-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-name small { display: block; color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.line-row button {
  background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 6px; font-size: 12px; padding: 4px 8px; cursor: pointer;
}
.line-row button:hover:not(:disabled) { background: rgba(255,255,255,0.18); }
.line-row button:disabled { opacity: 0.35; cursor: default; }
.line-row button.primary { min-width: 74px; }
.line-row button.attached { background: rgba(52,207,161,0.18); border-color: rgba(52,207,161,0.5); }

/* ---------- HUD ---------- */
#hud {
  position: fixed; right: 14px; top: 68px; width: 178px; z-index: 15;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 12px; text-align: center; backdrop-filter: blur(6px);
}
/* Join-The-Crew-Logo dezent hinter der Windanzeige */
#hud::before {
  content: ""; position: absolute; left: 50%; top: 38px; transform: translateX(-50%);
  width: 104px; height: 92px;
  background: url("../assets/jtc-logo.svg") center / contain no-repeat;
  opacity: 0.14; pointer-events: none;
}
#compass { width: 150px; height: 150px; }
#hudText { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.5; font-variant-numeric: tabular-nums; }
#hudText b { color: var(--text); }

/* ---------- Controls ---------- */
#controls {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 22px; z-index: 15;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  padding: 12px 18px; backdrop-filter: blur(6px);
}
.ctl-block { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ctl-label { font-size: 12px; color: var(--text-dim); }
.ctl-label span { color: var(--text); font-variant-numeric: tabular-nums; }
.lever { position: relative; touch-action: none; user-select: none; }
.lever.vertical { width: 56px; height: 150px; }
.lever.horizontal { width: 220px; height: 44px; }
.lever-track {
  position: absolute; background: rgba(0,0,0,0.45); border: 1px solid var(--panel-border); border-radius: 8px;
}
.vertical .lever-track { left: 50%; top: 4px; bottom: 4px; width: 12px; transform: translateX(-50%); }
.horizontal .lever-track { top: 50%; left: 4px; right: 4px; height: 12px; transform: translateY(-50%); }
.lever-detent { position: absolute; background: rgba(255,255,255,0.35); }
.vertical .lever-detent { left: 8px; right: 8px; top: 50%; height: 2px; }
.horizontal .lever-detent { top: 6px; bottom: 6px; left: 50%; width: 2px; }
.lever-knob {
  position: absolute; width: 44px; height: 22px; border-radius: 6px;
  background: linear-gradient(180deg, #47edbc, #1fae87); border: 1px solid #8ff5d8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5); cursor: grab;
}
.vertical .lever-knob { left: 50%; transform: translate(-50%, -50%); top: 50%; }
.horizontal .lever-knob { top: 50%; width: 22px; height: 36px; transform: translate(-50%, -50%); left: 50%; }
.lever-mark { position: absolute; font-size: 10px; color: var(--text-dim); pointer-events: none; }
.lever-mark.top { top: 2px; left: -4px; }
.lever-mark.bottom { bottom: 2px; left: -4px; }
.lever-mark.left { left: 2px; top: -2px; }
.lever-mark.right { right: 2px; top: -2px; }
button.mini {
  background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 6px; font-size: 11px; padding: 3px 10px; cursor: pointer;
}
.readouts { gap: 4px; min-width: 110px; }
.ro { display: flex; justify-content: space-between; width: 100%; font-size: 13px; }
.ro-lbl { color: var(--text-dim); }
.ro-val { font-variant-numeric: tabular-nums; }

/* ---------- Banner / Toast ---------- */
#banner {
  position: fixed; top: 90px; left: 50%; transform: translateX(-50%); z-index: 30;
  padding: 14px 28px; border-radius: 12px; font-size: 18px; font-weight: 700;
  background: var(--panel); border: 1px solid var(--panel-border); backdrop-filter: blur(6px);
  animation: pop 0.25s ease-out;
}
#banner.good { border-color: var(--good); color: var(--good); }
#banner.bad { border-color: var(--bad); color: var(--bad); }
#toast {
  position: fixed; bottom: 218px; left: 50%; transform: translateX(-50%); z-index: 30; max-width: 640px; text-align: center;
  padding: 8px 18px; border-radius: 10px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--panel-border);
}
@keyframes pop { from { transform: translateX(-50%) scale(0.85); opacity: 0; } }

/* ---------- Daumensteuerung (Touch) ---------- */
#stick { position: fixed; inset: 0; pointer-events: none; z-index: 24; }
.stick-ring {
  position: absolute; width: 150px; height: 150px; border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.45);
  background: radial-gradient(circle, rgba(71,237,188,0.10) 0%, rgba(71,237,188,0.02) 70%);
  transform: translate(-50%, -50%);
}
.stick-ring::before, .stick-ring::after {
  content: ""; position: absolute; background: rgba(255,255,255,0.22);
}
.stick-ring::before { left: 50%; top: 8px; bottom: 8px; width: 1px; }
.stick-ring::after { top: 50%; left: 8px; right: 8px; height: 1px; }
.stick-lbl {
  position: absolute; font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8); white-space: nowrap;
}
.stick-lbl.up { top: -22px; left: 50%; transform: translateX(-50%); }
.stick-lbl.down { bottom: -20px; left: 50%; transform: translateX(-50%); }
.stick-lbl.left { left: -18px; top: 50%; transform: translateY(-50%); }
.stick-lbl.right { right: -58px; top: 50%; transform: translateY(-50%); }
.stick-knob {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(71,237,188,0.5); border: 2px solid #8ff5d8;
  box-shadow: 0 2px 12px rgba(0,0,0,0.55);
  transform: translate(-50%, -50%);
}

/* ---------- Hilfe-Overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2,10,18,0.7); z-index: 50; display: flex; align-items: center; justify-content: center; }
.overlay-card {
  max-width: 640px; max-height: 84vh; overflow-y: auto;
  background: #102b2c; border: 1px solid var(--panel-border); border-radius: 14px; padding: 26px 30px;
}
.overlay-card h2 { margin-bottom: 12px; }
.overlay-card h3 { margin: 14px 0 6px; color: var(--accent); font-size: 15px; }
.overlay-card ul, .overlay-card ol { padding-left: 20px; line-height: 1.65; font-size: 14px; }
.overlay-card li { margin-bottom: 4px; }
.overlay-card p { font-size: 14px; line-height: 1.6; margin: 8px 0; }
.guide-demo-hint { color: var(--text-dim); border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px; margin-top: 14px; }
.disclaimer {
  margin-top: 16px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid rgba(255, 209, 47, 0.35); background: rgba(255, 209, 47, 0.07);
  color: var(--text-dim); font-size: 13px; line-height: 1.55;
}
.overlay-card button { margin-top: 16px; background: var(--accent); border: 0; color: #113b34; font-weight: 700; padding: 9px 22px; border-radius: 8px; cursor: pointer; }

/* ---------- Mobil / kleine Bildschirme ---------- */
@media (max-width: 920px), (max-height: 600px) {
  #topbar { height: 46px; gap: 6px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
  .brand { font-size: 14px; }
  #topbar select, #topbar button { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
  #topbar select { max-width: 150px; }
  .windctl { gap: 5px; }
  .windctl .lbl { display: none; }
  .windctl input[type="range"] { width: 64px; }
  #linesPanel { width: 258px; top: 54px; left: 8px; padding: 8px; max-height: calc(100vh - 200px); overflow-y: auto; }
  .line-name { font-size: 12px; }
  .line-row { gap: 4px; }
  .line-row button.primary { min-width: 42px; padding: 5px 5px; }
  .line-row button.adj { padding: 5px 7px; }
  .line-row button.adj { padding: 5px 8px; }
  #hud { width: 120px; top: 54px; right: 8px; padding: 8px; }
  #hud::before { top: 22px; width: 70px; height: 62px; }
  #compass { width: 100px; height: 100px; }
  #hudText { font-size: 11px; }
  #controls { gap: 12px; padding: 8px 10px; bottom: 8px; border-radius: 12px; }
  .lever.vertical { height: 108px; width: 52px; }
  .lever.horizontal { width: 150px; height: 42px; }
  .readouts { min-width: 90px; }
  .ro { font-size: 12px; }
  #banner { top: 60px; font-size: 15px; padding: 10px 18px; max-width: 92vw; text-align: center; }
  #toast { bottom: 178px; font-size: 12px; max-width: 92vw; }
  .overlay-card { padding: 16px 18px; max-width: 94vw; }
}
@media (max-width: 560px) {
  .brand { display: none; }
  #topbar button .txt { display: none; }
  #topbar select { max-width: 124px; }
  .windctl input[type="range"] { width: 54px; }
  .windctl { margin-left: 0; }
  #linesPanel { width: 240px; }
  #hud { width: 104px; }
  #compass { width: 88px; height: 88px; }
  #hudText { display: none; }
}
