/* ==========================================================================
   Basisbildschirm (Hochformat-tauglich)
   ========================================================================== */

#scene-base { display: none; }
#scene-base.active { display: flex; flex-direction: column; }

.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: calc(8px + var(--safe-t)) 12px 8px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 700; letter-spacing: .1em; font-size: 14px; color: var(--gold); }
.topbar-res { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.topbar-right { display: flex; gap: 6px; }

.tabbar {
  flex: 0 0 auto;
  display: flex; gap: 4px; padding: 6px 8px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  flex: 0 0 auto;
  min-height: 42px; padding: 8px 14px;
  background: transparent; color: var(--text-dim);
  border: 1px solid transparent; border-radius: 8px;
  font-family: inherit; font-size: 14px; cursor: pointer;
  touch-action: manipulation; white-space: nowrap;
}
.tab.active { background: var(--bg-3); color: var(--text); border-color: var(--line); }

.base-body { flex: 1 1 auto; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.tabpanel { display: none; }
.tabpanel.active { display: block; }

.basebar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: var(--bg-2); border-top: 1px solid var(--line);
}
.basebar .btn { flex: 0 0 auto; width: auto; min-width: 160px; }

/* ---------- Basisraster ---------- */
.base-layout { display: flex; flex-direction: column; gap: 16px; }
.base-gridwrap { min-width: 0; }

.base-grid {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 6;                 /* folgt RULES.BASE_GRID_* */
  background: #14110e center/cover no-repeat;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  /* Zeilen UND Spalten fest vorgeben - sonst wachsen Zeilen mit dem Inhalt */
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

.bg-cell {
  border: 1px solid rgba(255,255,255,.045);
  min-width: 0; min-height: 0;
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
}
.bg-cell.valid   { background: rgba(78,154,90,.28); box-shadow: inset 0 0 0 1px rgba(78,154,90,.5); }
.bg-cell.invalid { background: rgba(179,69,63,.24); }

.bg-room {
  position: absolute;
  padding: 4px;
  background: rgba(30,38,32,.92);
  border: 2px solid #4d5c4a;
  border-radius: 6px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  overflow: hidden;
  min-width: 0; min-height: 0;
  cursor: pointer; touch-action: manipulation;
  font-size: clamp(9px, 1.5vw, 13px);
  line-height: 1.15;
}
/**
 * 049 §25 — die Raumkachel zeigt ihr Bild.
 *
 * Das Bild kommt als zweite Lage aus dem Renderer (`background-image`), darueber liegt
 * ein flaechiger Verlauf in der Grundfarbe. `background-color` bleibt als Rueckfallebene:
 * fehlt eine Bilddatei, sieht die Kachel exakt so aus wie vorher.
 */
.bg-room--bebildert {
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}
/* Text bleibt vorn und lesbar, auch ueber einem hellen Bildausschnitt. */
.bg-room--bebildert .rn,
.bg-room--bebildert .rs { position: relative; text-shadow: 0 1px 2px rgba(0,0,0,.9); }

.bg-room.building { border-style: dashed; border-color: var(--warn); background: rgba(44,38,26,.9); }
.bg-room.fixed    { border-color: var(--gold); background: rgba(40,34,20,.92); }
.bg-room.selected { outline: 2px solid var(--gold); outline-offset: -2px; }
.bg-room .rn { font-weight: 600; }
.bg-room .rs { font-size: .82em; color: var(--text-dim); margin-top: 2px; }

.base-side { min-width: 0; }
.base-side h3 { font-size: 15px; margin: 14px 0 8px; }

.power-box {
  padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13.5px;
}
.power-bar { height: 8px; background: #2a2f37; border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.power-fill { height: 100%; background: var(--info); }
.power-fill.tight { background: var(--warn); }
.power-fill.over  { background: var(--bad); }

.panel-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.panel-actions .btn { width: auto; min-width: 160px; }

.crew-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.crew-stats span { white-space: nowrap; }

.progress { height: 6px; background: #2a2f37; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--gold); }

@media (min-width: 980px) {
  /* V3 (020 D): rechte Flaeche deutlich breiter -> grosse Vorschau + Bildkatalog nutzen sie. */
  .base-layout { flex-direction: row; align-items: flex-start; }
  .base-gridwrap { flex: 1 1 auto; min-width: 380px; }
  /* Spalte breit genug, dass das Vorschaubild auch auf 1024er-Tablets >=500px bleibt. */
  .base-side { flex: 0 0 clamp(536px, 42vw, 560px); }
  .base-side h3 { margin-top: 14px; }
}

/* ---------- Forschungsketten (Auftrag 7.1) ---------- */
.res-unlock { font-size: 12.5px; color: #a9dcb2; margin-top: 4px; }
.res-next   { font-size: 12px;  color: var(--text-off); margin-top: 3px; }
.res-chain {
  margin-top: 6px; padding: 6px 8px;
  background: rgba(200,137,43,.10);
  border-left: 3px solid var(--warn);
  border-radius: 0 6px 6px 0;
}
.res-chain-head { font-size: 11.5px; color: var(--warn); margin-bottom: 2px; }
.res-chain-item { font-size: 12.5px; color: #e8d3a8; }
.res-chain-item.raum { color: #f0cd94; }

/* Nutzen eines Raumes vor dem Bau */
.room-research { margin-top: 5px; font-size: 12px; }
.rr-ok   { color: #a9dcb2; }
.rr-warn { color: #f0cd94; }

/* ---------- Basisraster aufgewertet (Auftrag 7.2) ---------- */
.bg-room {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.45);
  background: linear-gradient(180deg, rgba(36,46,38,.94), rgba(24,32,26,.96));
}
.bg-room .rn { text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.bg-room.selected { box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px rgba(201,162,39,.4); }
.bg-room.nopower  { border-color: var(--bad); background: linear-gradient(180deg, rgba(50,30,30,.94), rgba(34,22,22,.96)); }

/* Bauzeit als sichtbarer Fortschritt */
.bg-room .rprog {
  position: absolute; left: 4px; right: 4px; bottom: 3px;
  height: 4px; background: rgba(0,0,0,.5); border-radius: 2px; overflow: hidden;
}
.bg-room .rprog > i { display: block; height: 100%; background: var(--warn); }

/* Wirkung eines Raumes direkt erkennbar */
.bg-room .reff { font-size: .78em; color: #a9c0a2; margin-top: 1px; }

/* Bau-/Versetzmodus deutlicher */
.base-grid.mode-build  { outline: 2px dashed var(--ok);   outline-offset: 2px; }
.base-grid.mode-move   { outline: 2px dashed var(--gold); outline-offset: 2px; }
.bg-cell.valid   { background: rgba(78,154,90,.30); }
.bg-cell.valid:hover { background: rgba(78,154,90,.45); }
.mode-banner {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; padding: 8px 10px;
  border-radius: var(--radius); font-size: 13px;
  background: rgba(201,162,39,.12); border: 1px solid var(--gold); color: #f0e2b4;
}
.mode-banner .btn { margin-left: auto; }

/* ==========================================================================
   V2 P3 — Basisbau-Ueberarbeitung: Bildkarten-Baukatalog (Ebene B),
   Detail mit Vorschaubild (Ebene C), Anlagenuebersicht + Grundriss-Legende (A).
   Thumbnails sind Ausschnitte der Krea2-Bunkerkulissen (assets/base/rooms/).
   ========================================================================== */
/* V3 (020 D): Katalog als Bild-Grid statt schmaler Liste. */
#build-list.build-catalog {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
}
@media (max-width: 520px) { #build-list.build-catalog { grid-template-columns: 1fr; } }

/* Auftrag 018 Phase D 6.3: Baukarte als technisches Bunker-/Konstruktionsmodul,
   NICHT als runde Shop-/Produktkarte. Eckige Form, technische Spine links,
   Konstruktions-Eckwinkel am Bild, Spec-Tags. */
.build-card {
  position: relative;
  display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 8px 8px 8px 11px; border-radius: 2px;
  background: linear-gradient(180deg, rgba(14,24,32,.94), rgba(9,16,22,.96));
  border: 1px solid var(--line); border-left: 3px solid #2f6f88;   /* technische Spine */
  cursor: pointer; touch-action: manipulation;
  font-family: inherit; color: var(--text);
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.build-card:hover:not(.disabled) { border-color: #2f6f88; background: linear-gradient(180deg, rgba(18,30,40,.96), rgba(11,20,27,.97)); }
.build-card.selected {
  border-color: #4fd6ff; border-left-color: #4fd6ff;
  box-shadow: 0 0 0 1px rgba(79,214,255,.5), 0 0 16px rgba(79,214,255,.22);
}
.build-card.disabled { opacity: .5; filter: grayscale(.45); cursor: not-allowed; }

.bc-thumb {
  position: relative; flex: 0 0 104px; width: 104px; height: 66px;
  border-radius: 2px; background: #0a141c center/cover no-repeat;
  border: 1px solid rgba(79,214,255,.22);
  box-shadow: inset 0 0 22px rgba(0,0,0,.5);
}
/* Konstruktions-Eckwinkel oben links am Bild (Bauakte-Anmutung) */
.bc-thumb::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 11px; height: 11px;
  border-left: 2px solid rgba(79,214,255,.75); border-top: 2px solid rgba(79,214,255,.75);
}
.bc-size {
  position: absolute; left: 3px; bottom: 3px;
  font-size: 10px; padding: 1px 5px; border-radius: 0;
  background: rgba(6,12,18,.85); color: #bfe8ff; letter-spacing: .06em;
  border-left: 2px solid rgba(79,214,255,.5);
}
.bc-have {
  position: absolute; right: 3px; top: 3px;
  font-size: 10px; padding: 1px 5px; border-radius: 0;
  background: rgba(79,214,255,.9); color: #04121a; font-weight: 700; letter-spacing: .03em;
}
.bc-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bc-title { font-weight: 700; font-size: 13.5px; line-height: 1.12; }
.bc-fn { font-size: 12px; color: #9fe0c0; }
.bc-fn.dim { color: var(--text-dim); }
.bc-costs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 1px; }
.bc-cost {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
  background: rgba(255,255,255,.06); color: #d6eef8; border: 1px solid rgba(255,255,255,.08);
}
.bc-cost.matb   { color: #bcd4e6; border-color: rgba(150,190,220,.32); }
.bc-cost.mat    { color: #e6c98a; border-color: rgba(230,201,138,.3); }
.bc-cost.pw     { color: #f0cd94; border-color: rgba(240,205,148,.28); }
.bc-cost.pwplus { color: #a9dcb2; border-color: rgba(169,220,178,.3); }
.bc-blocked { font-size: 11.5px; color: #f0a9a2; margin-top: 1px; }

/* Raumdetail mit Vorschaubild */
.detail-box .rd-head { display: flex; gap: 10px; margin-bottom: 8px; }
.rd-thumb {
  flex: 0 0 110px; width: 110px; height: 72px; border-radius: 7px;
  background: #0a141c center/cover no-repeat;
  border: 1px solid rgba(79,214,255,.3); box-shadow: inset 0 0 22px rgba(0,0,0,.5);
}
.rd-headtext { min-width: 0; }
.rd-headtext h4 { margin: 0 0 3px; font-size: 15px; }
.rd-facts { display: flex; flex-direction: column; margin: 6px 0 8px; }
.rd-row { display: flex; gap: 8px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.rd-k { flex: 0 0 84px; color: var(--text-dim); }
.rd-v { flex: 1 1 auto; color: var(--text); }

/* Anlagenuebersicht-Kopf + Grundriss-Legende */
.anl-head { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.anl-head strong { font-size: 13px; letter-spacing: .04em; color: #bfe8ff; }
.anl-sub { font-size: 11.5px; color: var(--text-dim); }
.anl-strom { font-size: 12.5px; margin-top: 2px; }
.grid-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.grid-legend .lg {
  font-size: 10.5px; padding: 1px 7px 1px 16px; border-radius: 4px;
  position: relative; background: rgba(255,255,255,.04); color: var(--text-dim);
}
.grid-legend .lg::before {
  content: ''; position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 2px;
}
.lg-build::before { background: var(--warn); }
.lg-nopow::before { background: var(--bad); }
.lg-fixed::before { background: var(--gold); }
.lg-sel::before   { background: #4fd6ff; }

/* ==========================================================================
   AUFTRAG 020 PHASE D — Basisbau V3
   Grosse Fokus-Vorschau (>=500x310) rechts nutzt die vorher leere Flaeche;
   Baukatalog als Bild-Grid mit Kacheln >=180x110; Bauen bleibt 2-Tap
   (Katalog-Karte -> gruenes Feld im Grundriss).
   ========================================================================== */
.base-preview {
  padding: 12px; margin-bottom: 12px;
  background: linear-gradient(180deg, rgba(12,20,28,.96), rgba(8,14,20,.97));
  border: 1px solid var(--line); border-left: 3px solid #2f6f88; border-radius: 4px;
}
/* Grosses Vorschaubild — garantiert >=500x310 (Spalte ist >=500 breit) */
.bpreview-img {
  width: 100%; min-height: 310px; aspect-ratio: 500 / 310;
  background: #0a141c center/cover no-repeat;
  border: 1px solid rgba(79,214,255,.30); border-radius: 4px;
  box-shadow: inset 0 0 40px rgba(0,0,0,.55);
  position: relative;
}
.bp-empty-img { display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, #0c1620 0 14px, #0a131b 14px 28px); }
.bp-empty .hint { margin-top: 8px; }
.bp-corner {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 12px; padding: 2px 8px; letter-spacing: .06em;
  background: rgba(6,12,18,.85); color: #bfe8ff; border-left: 2px solid rgba(79,214,255,.6);
}
.bp-headtext { margin-top: 10px; }
.bp-headtext h4 { margin: 0 0 3px; font-size: 17px; }
.bp-costs { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.bp-fn { font-size: 13px; color: #9fe0c0; margin-top: 2px; }
.bp-prereq { font-size: 12.5px; color: #f0cd94; margin-top: 3px; }
.bp-action { margin-top: 10px; padding: 8px 10px; border-radius: 4px; font-size: 13.5px; font-weight: 600; }
.bp-go { background: rgba(78,154,90,.16); border: 1px solid var(--ok); color: #bfe9c6; }
.bp-blocked { background: rgba(179,69,63,.16); border: 1px solid var(--bad); color: #f0b3ad; }

/* Katalogkarte V3: Bild OBEN (>=180x110), Text darunter — bleibt eckiges
   Bau-Modul (border-radius/Spine/Eckwinkel aus der 018er-Regel bleiben). */
.build-card { flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.build-card .bc-thumb {
  flex: none; width: 100%; height: 122px; border: none;
  border-bottom: 1px solid rgba(79,214,255,.22); border-radius: 0;
}
.build-card .bc-body { padding: 8px 9px 9px; }
.build-card .bc-title { font-size: 14px; }
/* Auswahl-/Bau-Zustand der Karte bleibt ueber .selected (frueher definiert). */
