:root {
  --bg: #0b1a26;
  --panel: rgba(10, 22, 32, 0.86);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f4f8fb;
  --text-2: #dbe7ef;      /* Sekundärtext bleibt hell – keine blassen Grautöne */
  --accent: #6fd3ff;
  --green: #3ecf6e;
  --yellow: #ffd23f;
  --red: #ff5a4f;
  --calm: #8fb8ff;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button, select, input { font: inherit; color: inherit; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; touch-action: none; }

/* Beschriftungen im 3D-Bild */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 12px; font-weight: 600;
  padding: 2px 7px; border-radius: 8px; background: rgba(8, 18, 26, 0.82); border: 1px solid var(--line); color: #fff;
  text-shadow: 0 1px 2px #000; }
.lbl.poi { font-size: 13px; border-color: var(--accent); pointer-events: auto; cursor: pointer; }
.lbl.station { font-size: 11px; font-weight: 500; }
.lbl.station b { color: var(--accent); }
.lbl.storm { border-color: var(--red); background: rgba(60, 8, 8, 0.85); }
.lbl.place { background: none; border: none; font-weight: 500; font-size: 11px; opacity: 0.95; }

/* Kopfzeile */
#top { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 14px;
  padding: 0 12px; background: linear-gradient(#0a1620ee, #0a162000); z-index: 5; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand svg { width: 32px; height: 32px; }
.brand b { display: block; font-size: 17px; letter-spacing: .3px; }
.brand span { display: block; font-size: 11px; color: var(--text-2); margin-top: -2px; }
#clock { font-variant-numeric: tabular-nums; font-weight: 600; padding: 5px 12px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--line); }
#clock .tag { font-size: 11px; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: #24465c; }
#clock .tag.fc { background: #5b4a14; }
#banner { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 10px; background: rgba(120, 20, 16, 0.9); border: 1px solid #ff7a70;
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#banner.ok { background: rgba(18, 84, 48, 0.92); border-color: var(--green); }
#banner.bad { background: rgba(40, 60, 96, 0.92); border-color: var(--calm); }
#btn-info { margin-left: auto; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-weight: 700; flex: none; }
.icon-btn:hover, .pill:hover, .cams button:hover { border-color: var(--accent); }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); }
#left, #right { position: fixed; top: 60px; bottom: 92px; width: 320px; overflow-y: auto; z-index: 4; padding: 0 12px 12px; }
#left { left: 10px; }
#right { right: 10px; width: 270px; }
#left.collapsed, #right.collapsed { width: 44px; overflow: hidden; }
#left.collapsed > :not(.panel-head), #right.collapsed > :not(.panel-head) { display: none; }
.collapsed .panel-head h2 { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; padding: 10px 0 6px;
  background: linear-gradient(var(--panel) 70%, transparent); z-index: 1; }
.panel-head h2 { margin: 0; font-size: 15px; }
.collapse { border: 1px solid var(--line); background: none; border-radius: 8px; width: 26px; height: 26px; cursor: pointer; }
.group { border-top: 1px solid var(--line); padding: 8px 0; }
.group h3 { margin: 2px 0 6px; font-size: 13px; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.group label { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.group label.sel { flex-direction: column; align-items: stretch; gap: 3px; }
.group select { background: #10283a; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
.group input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.mini { font-size: 11px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); background: #10283a; cursor: pointer; }
.fx-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
.fx-row small { margin-left: auto; font-size: 11px; color: var(--text-2); }
.cams { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cams button, .pill { border: 1px solid var(--line); background: #10283a; border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 13px; }

/* POI-Karten */
.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0; background: rgba(16, 36, 50, 0.7); cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h4 { margin: 0; font-size: 14px; flex: 1; }
.lamp { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 8px currentColor; background: currentColor; flex: none; }
.lamp.gruen { color: var(--green); } .lamp.gelb { color: var(--yellow); } .lamp.rot { color: var(--red); } .lamp.flaute { color: var(--calm); }
.big { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px; }
.big .val { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big .unit { font-size: 13px; color: var(--text-2); }
.big .arrow { width: 26px; height: 26px; margin-left: auto; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; font-size: 12.5px; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; margin-top: 6px; padding: 5px 7px; border-radius: 7px; background: rgba(111, 211, 255, 0.12); line-height: 1.35; }
.hint.warn { background: rgba(255, 90, 79, 0.2); }
.spark { width: 100%; height: 46px; display: block; margin-top: 6px; }
.jumpgauge { width: 100%; height: 64px; display: block; margin-top: 4px; }

/* Zeitleiste */
#timeline { position: fixed; left: 10px; right: 10px; bottom: 10px; height: 72px; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.t-track { position: relative; flex: 1; height: 44px; }
#t-slider { position: absolute; left: 0; right: 0; top: 4px; width: 100%; accent-color: var(--accent); margin: 0; }
#t-radar { position: absolute; top: 0; height: 4px; background: #3ecf6e; border-radius: 2px; }
#t-ticks { position: absolute; left: 0; right: 0; top: 24px; height: 18px; font-size: 11px; }
#t-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#t-ticks span.day { font-weight: 700; color: var(--accent); }
#t-ticks i { position: absolute; top: -6px; width: 1px; height: 5px; background: #fff8; }
#legend { width: 230px; font-size: 11px; }
#legend .bar { height: 10px; border-radius: 3px; margin: 2px 0; }
#legend .ticks { display: flex; justify-content: space-between; }

/* Popup (Klick ins Gelände) */
#popup { position: fixed; z-index: 6; width: 290px; padding: 10px 12px; font-size: 13px; }
#popup h4 { margin: 0 0 4px; font-size: 14px; display: flex; justify-content: space-between; }
#popup h4 button { background: none; border: none; cursor: pointer; font-size: 16px; }
#popup .fx { display: grid; grid-template-columns: 1fr 90px 44px; gap: 2px 6px; align-items: center; margin-top: 6px; }
#popup .fx .b { height: 8px; border-radius: 4px; background: #ffffff22; position: relative; }
#popup .fx .b i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
#popup .fx span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Info-Dialog */
dialog#info, dialog#stats, dialog#alarm { max-width: 820px; width: calc(100% - 24px); max-height: calc(100% - 40px); background: #0e2130; color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; }
dialog::backdrop { background: #000a; }
dialog#info h2 { margin-top: 0; }
dialog#info h3 { color: var(--accent); margin-bottom: 6px; }
dialog#info table { border-collapse: collapse; width: 100%; font-size: 13px; }
dialog#info td, dialog#info th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
dialog#info .ok { color: var(--green); } dialog#info .err { color: var(--red); }
dialog#info a { color: var(--accent); }
.close-x { float: right; }

#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); z-index: 20; font-size: 15px; }
#loading.hidden { display: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #ffffff22; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  #left, #right { top: auto; bottom: 90px; max-height: 46vh; width: calc(100% - 20px); left: 10px; right: 10px; }
  #left.collapsed, #right.collapsed { width: 44px; height: 44px; }
  #right.collapsed { left: auto; }
  #left:not(.collapsed) ~ #right:not(.collapsed) { display: none; }
  #legend { display: none; }
  #t-ticks span:not(.day) { display: none; }
  #banner { position: fixed; top: 54px; left: 10px; right: 10px; }
  .brand span { display: none; }
  #popup { left: 10px !important; right: 10px; width: auto; top: 60px !important; }
}


/* Napoli: Taktik */
.card-head small { font-size: 11px; color: var(--text-2); }
.leg { width: 13px; height: 13px; border-radius: 3px; flex: none; }
.leg.up { background: #6fd3ff; } .leg.down { background: #ff7ad9; } .leg.start { background: #fff; }
.hint.cur { background: rgba(72, 214, 194, 0.16); }
.spark { height: 54px; }
.spark-legend { font-size: 11px; display: flex; gap: 4px 10px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.spark-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: -6px; }
.wins { display: grid; gap: 5px; }
.win-row { display: grid; grid-template-columns: 70px auto 1fr; gap: 8px; align-items: center; font-size: 12.5px; cursor: pointer; padding: 3px 4px; border-radius: 6px; }
.win-row:hover { background: #ffffff12; }
.win-row .d { font-weight: 700; }
.win-row .bars { display: flex; gap: 2px; }
.win-row .bars i { width: 12px; height: 16px; border-radius: 2px; }
.win-row .w { font-size: 12px; }
.note.small { font-size: 11.5px; padding: 5px 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.group input[type=number] { background: #10283a; border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; width: 100%; }
.pill.wide { width: 100%; margin: 4px 0; text-align: left; }
.pill.active { border-color: var(--yellow); background: #3d3510; }
.lbl.mark { border-color: #ffe14d; font-size: 12px; }
.lbl.mark.start { border-color: #fff; }
.lbl.peak { background: rgba(60, 40, 30, 0.8); }
#pickhint { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 7; background: #3d3510; border: 1px solid var(--yellow);
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; }
#popup { width: 310px; }
dialog#info pre { background: #10283a; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; overflow-x: auto; }
@media (max-width: 820px) {
  #pickhint { width: calc(100% - 20px); text-align: center; }
  .win-row { grid-template-columns: 62px auto; }
  .win-row .w { grid-column: 1 / -1; }
}
#lang { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; height: 34px; padding: 0 8px; font-weight: 700; cursor: pointer; margin-left: auto; }
#lang + #btn-info { margin-left: 0; }
@media (max-width: 820px) {
  #top { gap: 8px; padding: 0 8px; }
  .brand > div { display: none; }
  #clock { font-size: 13px; padding: 4px 8px; white-space: nowrap; }
  #clock .tag { display: none; }
  #lang { padding: 0 4px; }
}

/* Rennen */
#race-bar { padding: 4px 0 6px; }
.race-btn { width: 100%; padding: 11px 12px; border-radius: 11px; border: 2px solid #ffe14d; background: linear-gradient(#5a4a0e, #3d3208);
  color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; letter-spacing: .2px; box-shadow: 0 0 14px #ffe14d44; }
.race-btn:hover { background: linear-gradient(#6d5a12, #4a3d0a); }
.race-btn:disabled { opacity: .7; cursor: wait; }
.race-btn.stale { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 22px #ffe14daa; } }
.race-opts { display: flex; gap: 10px; align-items: center; font-size: 12px; margin-top: 6px; flex-wrap: wrap; }
.race-opts select { background: #10283a; border: 1px solid var(--line); border-radius: 7px; padding: 2px 4px; }
.race-opts label { display: flex; gap: 5px; align-items: center; }
.card.race { border-color: #ffe14d88; cursor: default; }
.race-legs { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.race-legs th, .race-legs td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.race-legs td.up { color: #6fd3ff; font-weight: 700; } .race-legs td.down { color: #ff7ad9; font-weight: 700; }
.race-legs tr.cur { background: #ffe14d22; }
.race-play { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.race-play input[type=range] { flex: 1; accent-color: #ffe14d; min-width: 60px; }
.race-play .btn { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.race-boat { font-size: 12px; margin-top: 4px; }
.pill.race-mini { border-color: #ffe14d; background: #3d3208; font-weight: 700; white-space: nowrap; }
.lbl.leg { font-size: 12px; font-weight: 800; padding: 1px 7px; }
.lbl.leg.up { border-color: #6fd3ff; } .lbl.leg.down { border-color: #ff7ad9; }
.lbl.boat { border-color: #ffe14d; background: rgba(61, 50, 8, 0.9); }
@media (min-width: 821px) { .pill.race-mini { display: none; } }
@media (max-width: 820px) { .pill.race-mini span { display: none; } }
.btn { border: 1px solid var(--accent); background: #17405a; border-radius: 9px; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--text); }
.btn:hover { background: #1d5070; }
.race-play .btn { border-color: #ffe14d; background: #3d3208; }
.race-legs td:nth-child(2) { white-space: nowrap; }
.card.race { overflow-x: auto; }
@media (max-width: 820px) { .race-legs { font-size: 11px; } .race-legs th, .race-legs td { padding: 3px 2px; } }
