/* ==========================================================================
   Taktischer Bildschirm
   ========================================================================== */

#scene-tactical { background: #0b0d10; }

#tac-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;          /* Kamera-Gesten selbst behandeln */
  cursor: grab;
}
#tac-canvas:active { cursor: grabbing; }

/* Lokaler UI-freier Abnahmemodus (?ui=0). Er ändert nur die Darstellung. */
#scene-tactical.capture-clean #tac-canvas { width:100%; right:0; }
#scene-tactical.capture-clean .tac-top,
#scene-tactical.capture-clean .objective-box,
#scene-tactical.capture-clean .combat-log,
#scene-tactical.capture-clean .ticker,
#scene-tactical.capture-clean .presenter-bar,
#scene-tactical.capture-clean .tac-camera-controls,
#scene-tactical.capture-clean .move-confirm,
#scene-tactical.capture-clean .tac-side,
#scene-tactical.capture-clean .tac-bottom,
#scene-tactical.capture-clean .tutorial-overlay,
#scene-tactical.capture-clean .sheet { display:none !important; }

.tac-top {
  position: absolute; z-index: 20;
  top: var(--safe-t); left: var(--safe-l); right: var(--safe-r);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px;
  background: linear-gradient(180deg, rgba(11,13,16,.92), rgba(11,13,16,0));
  pointer-events: none;
}
.tac-top > * { pointer-events: auto; }
.tac-top-left, .tac-top-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.objective-box {
  position: absolute; z-index: 30;
  /**
   * ⚠️ DIE 58 PX WAREN EINE ANNAHME ÜBER EINE EINZEILIGE WERKZEUGLEISTE.
   * `.tac-top` hat `flex-wrap: wrap`. Bei 1024 px Breite bricht die Leiste auf ZWEI Zeilen
   * um — und dieses Fenster (`z-index: 30` gegen `20`) legte sich über die zweite. Gemessen
   * im gebauten RC7 bei 1024×768: der Knöpf „Menü" bei (277, 58, 62×44) war von
   * `.objective-box` verdeckt und damit unerreichbar, solange die Ziele offen standen.
   *
   * Der Abstand kommt jetzt aus `--tac-top-h`, das `app.js` nach dem Zeichnen aus der
   * echten Leistenhöhe setzt. Die 58 px bleiben als Notwert stehen, falls das Skript
   * einmal nicht dazu kommt.
   */
  top: calc(var(--tac-top-h, 58px) + var(--safe-t) + 4px); left: 10px; right: 10px;
  max-width: 420px;
  background: rgba(20,24,30,.97);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-size: 14px;
}
.objective-box ul { margin: 6px 0 0; padding-left: 18px; }
.objective-box li { margin-bottom: 4px; }
.objective-box li.done { color: #a9dcb2; }
.objective-box li.open { color: var(--text-dim); }

.objective-box.obertor-brief { max-width: 310px; background: rgba(13,23,28,.95); border-color: #48574f; border-radius: 3px; box-shadow: 0 8px 30px #0005; }
.obertor-location { color: #bfaa79; font-size: 10px; letter-spacing: .15em; margin-bottom: 8px; }
.obertor-brief > strong { font-size: 19px; font-weight: 600; color: #e5e0ce; }
.obertor-order { color: #c6cfc7; line-height: 1.45; }
.obertor-next { border-left: 2px solid #baa775; padding: 2px 0 2px 11px; margin: 13px 0; }
.obertor-next strong { font-size: 13px; color: #e2d5b1; }
.obertor-next p { font-size: 12px; line-height: 1.5; color: #b8c2bc; margin: 6px 0 0; }
.obertor-brief details { font-size: 11px; line-height: 1.5; color: #a0ada5; border-top: 1px solid #34423b; padding-top: 9px; }
.obertor-brief summary { cursor: pointer; color: #bdb89f; min-height: 24px; }
@media (max-height: 650px) { .obertor-brief .obertor-order { margin: 6px 0; } .obertor-next { margin: 8px 0; } }

/* ---------- Gefechtsprotokoll ---------- */
.combat-log {
  position: absolute; z-index: 30;
  top: calc(58px + var(--safe-t));
  right: calc(10px + var(--safe-r));
  width: min(340px, calc(100vw - 20px));
  max-height: min(46vh, 380px);
  display: flex; flex-direction: column;
  background: rgba(16,19,24,.96);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.log-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.log-lines {
  overflow-y: auto; padding: 6px 10px 10px;
  font-size: 13px; line-height: 1.45;
  scrollbar-width: thin;
}
.log-line { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.log-line:last-child { border-bottom: 0; }
.log-line.crit { color: #f0b6b3; }
.log-line.alien { color: #e8b48f; }
.log-line.crew  { color: #a8c6e8; }
.log-line.turn  { color: var(--gold); font-weight: 600; margin-top: 6px; }
.log-line.objective { color: #a9dcb2; }
.log-line.miss  { color: var(--text-off); }

/* ---------- Ticker: letzte Ereignisse ohne geoeffnetes Protokoll ---------- */
.ticker {
  position: absolute; z-index: 25;
  left: calc(10px + var(--safe-l));
  top: calc(58px + var(--safe-t));
  /* Wird ausgeblendet, solange die Zielanzeige offen ist (app.js) */
  max-width: min(360px, 60vw);
  display: flex; flex-direction: column; gap: 3px;
  pointer-events: none;
}
.ticker div {
  background: rgba(16,19,24,.88);
  border-left: 3px solid var(--line);
  padding: 4px 9px; border-radius: 0 6px 6px 0;
  font-size: 12.5px;
}
.ticker div.hit  { border-left-color: var(--bad); color: #f2c3c0; }
.ticker div.down { border-left-color: var(--bad); color: #f2c3c0; font-weight: 600; }
.ticker div.miss { border-left-color: var(--text-off); color: var(--text-dim); }
.ticker div.objective { border-left-color: var(--ok); color: #a9dcb2; }

/* ---------- Steuerung der Zugdarstellung ---------- */
.presenter-bar {
  position: absolute; z-index: 35;
  left: 50%; transform: translateX(-50%);
  bottom: var(--aktionsspur);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(16,19,24,.96);
  border: 1px solid var(--gold); border-radius: var(--radius);
  max-width: calc(100vw - 20px);
}
.presenter-label { font-size: 13px; color: var(--gold); white-space: nowrap; }

.tac-camera-controls {
  position: absolute; z-index: 20;
  right: calc(10px + var(--safe-r));
  top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px;
}

/* ---------- Bestaetigungsleiste Bewegung ---------- */
.move-confirm {
  position: absolute; z-index: 30;
  left: 10px; right: 10px;
  bottom: var(--aktionsspur);
  background: rgba(20,24,30,.97);
  border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 10px 12px;
  max-width: 520px; margin: 0 auto;
}
.mc-info { font-size: 14px; margin-bottom: 8px; }
.mc-info b { color: var(--gold); }
.mc-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-buttons .btn { flex: 1 1 100px; min-height: 46px; }

/* ---------- Untere Leiste ---------- */
.tac-bottom {
  position: absolute; z-index: 20;
  left: var(--safe-l); right: var(--safe-r); bottom: 0;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: linear-gradient(0deg, rgba(11,13,16,.95), rgba(11,13,16,.55) 70%, transparent);
  display: flex; gap: 8px; align-items: flex-end;
}
.unit-cards {
  flex: 1; display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: thin; padding-bottom: 2px;
}
.unit-card {
  flex: 0 0 auto;
  min-width: 112px; max-width: 150px;
  padding: 7px 9px;
  background: rgba(28,33,40,.95);
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; touch-action: manipulation;
  font-family: inherit; color: inherit; text-align: left;
}
.unit-card.selected { border-color: var(--gold); background: rgba(45,40,26,.95); }
.unit-card.done { opacity: .5; }
.unit-card.dead { opacity: .35; border-color: var(--bad); }
.unit-card.evac { opacity: .6; border-color: var(--info); }
.uc-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-cls { font-size: 10.5px; color: var(--text-off); margin-bottom: 3px; }
.uc-hpbar { height: 6px; background: #2a2f37; border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.uc-hpfill { height: 100%; background: var(--ok); }
.uc-hpfill.low { background: var(--warn); }
.uc-hpfill.crit { background: var(--bad); }
.uc-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.ap-pips { display: inline-flex; gap: 3px; }
.ap-pip { width: 9px; height: 9px; border-radius: 50%; background: #39404a; }
.ap-pip.on { background: var(--gold); }
.uc-flag { font-size: 10px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
.uc-flag.ow { border-color: var(--info); color: #a5cfe4; }
.uc-flag.hunk { border-color: var(--ok); color: #a9dcb2; }

.btn-endturn { flex: 0 0 auto; min-width: 112px; min-height: 60px; }

/* Querformat-Hinweis fuer sehr niedrige Displays */
@media (max-height: 430px) and (orientation: portrait) {
  .tac-bottom::before {
    content: "Fuer die Taktik das Geraet quer halten";
    position: absolute; top: -22px; left: 10px;
    font-size: 11px; color: var(--gold);
  }
}

@media (min-width: 900px) {
  .unit-card { min-width: 140px; }
}

/* ---------- Bewegungsvorschau: Deckung und Sichtlage ---------- */
.mc-info > div { margin: 2px 0; }
.mc-cover { display: flex; align-items: center; gap: 7px; }
.mc-cover .mc-sym { font-size: 15px; line-height: 1; }
.mc-cover.full { color: #a9dcb2; }
.mc-cover.half { color: #d6c48a; }
.mc-cover.none { color: var(--text-off); }
.mc-exposed { color: #f0b6b3; }
.mc-safe    { color: #9fc4a6; }

/* ---------- Ersteinsatz-Tutorial (Dialog) ---------- */
.tutorial-overlay { position: absolute; inset: 0; z-index: 50; }
.tutorial-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.tutorial-box {
  position: absolute; z-index: 1;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 24px));
  background: rgba(20,24,30,.99);
  border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 10px 34px rgba(0,0,0,.7);
}
.tut-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.tut-head strong { color: var(--gold); font-size: 15px; }
.tut-count { font-size: 12px; color: var(--text-off); }
.tutorial-box p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.tut-buttons { display: flex; gap: 8px; }
.tut-buttons .btn { flex: 1; }


/* ---------- Gemeinsame Aktionsspur ueber der Fussleiste ----------
   Bewegungsvorschau und Zugdarstellung belegen dieselbe Hoehe. Sie sind
   gegenseitig ausgeschlossen - waehrend der Zugdarstellung ist die Eingabe
   gesperrt. Dadurch koennen sie sich nicht ueberlagern, egal wie hoch die
   Vorschau durch zusaetzliche Zeilen wird. */
:root { --aktionsspur: calc(104px + var(--safe-b)); }
@media (min-width: 900px) { :root { --aktionsspur: calc(100px + var(--safe-b)); } }

/* Protokoll, Ticker und Zielfenster beginnen unterhalb der Kopfleiste.
   Die Kopfleiste selbst ist ein durchsichtiger Verlauf ohne Trefferflaeche - eine
   optische Ueberschneidung DORT ist gewollt.

   ⚠️ IHRE KNOEPFE HABEN ABER SEHR WOHL EINE TREFFERFLAECHE (`.tac-top > * {
   pointer-events: auto }`). Hier standen feste 62 px, weil die Leiste als einzeilig
   angenommen wurde. Bei 1024 px Breite bricht sie auf zwei Zeilen um und wird 110 px hoch -
   das Zielfenster legte sich dann ueber die zweite Zeile und machte den Knopf „Menue"
   unerreichbar. Gemessen im gebauten RC7 bei 1024x768.

   ⚠️ UND: DIESE REGEL IST DIE ZWEITE. Die erste steht bei `.objective-box` weiter oben.
   Beide haben dasselbe Gewicht, also gewinnt die spaetere - ein Korrigieren nur der oberen
   blieb wirkungslos (gemessen: Variable stand auf 110px, das Fenster trotzdem auf 62px).
   Genau dieselbe Falle wie bei der Panelbreite in `frames-v2.css`/`main.css`: eine gefundene
   Deckelung ist kein Beweis, dass es nur eine gab. */
.combat-log, .ticker, .objective-box {
  top: calc(var(--tac-top-h, 62px) + var(--safe-t) + 4px);
}

/* ==========================================================================
   PHASE 2C — PC-/Tablet-First
   Die Karte bleibt der Hauptbereich. Die rechte Leiste nimmt ihr Platz weg,
   statt darueber zu liegen: ein Panel, das die Karte verdeckt, ist auf einem
   grossen Bildschirm eine verschenkte Flaeche.
   ========================================================================== */

:root {
  --seitenleiste: 300px;
  --seitenleiste-schmal: 240px;
}

.tac-side {
  position: absolute; z-index: 25;
  top: calc(var(--safe-t) + 52px);
  right: var(--safe-r);
  bottom: calc(var(--aktionsspur) + 8px);
  width: var(--seitenleiste);
  display: flex; flex-direction: column;
  background: rgba(16, 20, 26, 0.94);
  border-left: 1px solid var(--line);
  border-radius: 10px 0 0 10px;
  overflow: hidden;
}
.tac-side.eingeklappt { width: auto; bottom: auto; }
.tac-side.eingeklappt .side-body { display: none; }
#scene-tactical.side-collapsed #tac-canvas { width: 100%; }
#scene-tactical.side-collapsed .tac-camera-controls { right: 12px; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.25);
}
.side-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px; }

.side-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 3px 0; font-size: 14px;
}
.side-label { color: var(--text-dim); }
.side-value { font-variant-numeric: tabular-nums; }
.side-block { margin-bottom: 8px; }
.side-bar { height: 6px; background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden; }
.side-bar-fill { height: 100%; background: var(--ok); }
.side-bar-fill.low { background: var(--warn); }
.side-bar-fill.crit { background: var(--bad); }
.side-cover { margin: 2px 0; font-size: 13px; color: #b6d9c2; }
.side-good { color: var(--ok); font-size: 13px; margin: 6px 0 0; }
.side-bad { color: var(--warn); font-size: 13px; margin: 6px 0 0; }
.side-marks { color: var(--text-dim); font-size: 13px; margin: 0; }

/* Karte laesst der Leiste Platz, statt sich verdecken zu lassen.
   WICHTIG: hier NICHT `width: auto` verwenden. Das Canvas ist ein ersetztes
   Element - `auto` bedeutet dort "nimm die Bitmapbreite", und die Angabe
   `right` wird dann als ueberbestimmt verworfen. Die Karte war deshalb
   breiter als das Fenster und die Seite lief quer. Gerechnete Breite ist
   eindeutig. */
.geraet-pc #tac-canvas { width: calc(100% - var(--seitenleiste)); }
.geraet-tablet #tac-canvas { width: calc(100% - var(--seitenleiste-schmal)); }
.geraet-tablet .tac-side { width: var(--seitenleiste-schmal); }

/* Auch die obere Leiste endet vor der Seitenleiste - sonst liegen
   Missionsnamen und Knoepfe unter dem Panel. */
.geraet-pc .tac-top { right: calc(var(--safe-r) + var(--seitenleiste)); }
.geraet-tablet .tac-top { right: calc(var(--safe-r) + var(--seitenleiste-schmal)); }

/* Die Leiste beginnt oberhalb des oberen Bandes und reicht bis zur
   Aktionsspur - eine echte Spalte, kein schwebendes Fenster. */
.geraet-pc .tac-side,
.geraet-tablet .tac-side { top: var(--safe-t); border-radius: 0; }

/* Auf dem Telefon wird die Leiste zur Schublade von unten. */
.geraet-phone .tac-side {
  top: auto; left: var(--safe-l); right: var(--safe-r);
  bottom: calc(var(--aktionsspur) + 8px);
  width: auto; max-height: 45%;
  border-radius: 10px; border: 1px solid var(--line);
}
.geraet-phone #tac-canvas { right: 0; width: 100%; }

/* Kamera-Knoepfe weichen der Leiste aus. */
.geraet-pc .tac-camera-controls { right: calc(var(--seitenleiste) + 12px); }
.geraet-tablet .tac-camera-controls { right: calc(var(--seitenleiste-schmal) + 12px); }

/* --- Hinweis fuer kleine Bildschirme (Auftrag 8.4) ---------------------- */
.smallnote {
  position: fixed; inset: 0; z-index: 950;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 11, .72);
  padding: 20px;
}
.smallnote-panel {
  max-width: 420px; padding: 20px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
}
.smallnote-panel h3 { margin: 0 0 8px; }
.smallnote-panel p { margin: 0 0 14px; color: var(--text-dim); line-height: 1.45; }
.smallnote-panel .btn { width: 100%; min-height: var(--tap); }

/* Auf grossen Bildschirmen ist der Hinweis nie sichtbar. */
.geraet-pc .smallnote { display: none; }

/* 037: Rundenzähler im Zielpanel — das Zuglimit ist Teil der Aufgabe, nicht nur eine
 * Zahl in der Ecke. Wird es knapp, färbt es sich bernstein. */
.objective-box .obj-runden {
  font-size: 11.5px; letter-spacing: .06em; color: #8fb2c2;
  margin: 2px 0 6px; padding-bottom: 5px;
  border-bottom: 1px solid rgba(95,179,201,.18);
}
.objective-box .obj-runden.warn { color: #d9a441; font-weight: 600; }

.mission-fold>summary{cursor:pointer;font-weight:700;padding:4px 0 10px}.combat-status{border-top:1px solid #52616a;margin-top:12px;padding-top:10px;max-height:210px;overflow:auto}.combat-status p{font-size:12px;line-height:1.4;margin:8px 0;color:#cbd7de}.combat-status p:first-of-type{color:#f6dfaa}.uc-enemies{color:#ff7575;font-weight:700;margin-left:auto}
