/* Tiefgang – Oberfläche. Dunkel, industriell, mit säuregelbem Akzent. */
:root {
  --bg: #0b0b0a;
  --panel: #161512;
  --panel-2: #201e19;
  --line: #34312a;
  --text: #ece6d6;
  --muted: #9a927f;
  --accent: #d4e157;
  --accent-ink: #1a1c05;
  --good: #7fe08a;
  --warn: #ffb347;
  --bad: #ff6b5b;
  --radius: 10px;
  --nav-h: 62px;
  --top-h: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; }

/* ---------- Kopfzeile ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 5;
  display: flex; align-items: center; gap: 8px; padding: 0 8px;
  background: linear-gradient(#0b0b0aee, #0b0b0acc);
  border-bottom: 1px solid var(--line);
}
.resources { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.resources::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; white-space: nowrap;
}
.chip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.full { border-color: var(--warn); }
.chip.muted { color: var(--muted); }
.top-actions { display: flex; gap: 6px; flex: none; }
.pill {
  height: 32px; min-width: 32px; padding: 0 9px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.pill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
#power.bad { color: var(--bad); border-color: var(--bad); }
#power.storm { border-color: var(--warn); }
.meter { height: 8px; border-radius: 4px; background: #ffffff14; overflow: hidden; margin: 4px 0 10px; }
.meter i { display: block; height: 100%; background: var(--good); }

/* ---------- Karte ---------- */
#view {
  position: absolute; top: var(--top-h); left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-b));
  width: 100%; height: calc(100% - var(--top-h) - var(--nav-h) - var(--safe-b));
  touch-action: none; display: block; cursor: crosshair;
}
.tileinfo {
  position: absolute; top: calc(var(--top-h) + 8px); left: 50%; transform: translateX(-50%);
  background: #000c; border: 1px solid var(--line); padding: 5px 10px; border-radius: 8px;
  font-size: 12px; z-index: 4; pointer-events: none; white-space: nowrap;
}

/* ---------- Navigation ---------- */
#nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--panel); border-top: 1px solid var(--line);
}
#nav button {
  position: relative; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted);
}
#nav button .ico { font-size: 19px; line-height: 1; }
#nav button.active { color: var(--accent); }
#nav button.active::before {
  content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--accent);
}
.badge {
  position: absolute; top: 6px; right: calc(50% - 22px); font-style: normal;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 10px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.badge.alert { background: var(--warn); color: #000; border-color: var(--warn); font-weight: 700; }
.badge[hidden], #nav button[hidden] { display: none; }

/* ---------- Funk ---------- */
.chat { list-style: none; margin: 0 0 10px; padding: 0; }
.chat li { padding: 7px 10px; margin: 0 0 6px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.chat li.me { background: #d4e15714; border-color: #d4e15755; margin-left: 24px; }
.chat li b { color: var(--accent); }
.chat-form { position: sticky; bottom: -16px; display: flex; gap: 8px; padding: 8px 0 4px; background: var(--panel); }
.chat-form input { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }

/* ---------- Panel ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 5;
  max-height: 58%; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0; box-shadow: 0 -10px 30px #000a;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 6px; }
.sheet-head h2 { margin: 0; font-size: 16px; letter-spacing: .02em; }
.sheet-body { overflow-y: auto; padding: 4px 14px 16px; -webkit-overflow-scrolling: touch; user-select: text; }
.sheet-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 6px; }

.hint { color: var(--muted); margin: 4px 0 10px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row.tools { flex-wrap: wrap; margin-bottom: 8px; }
.row.wrap { flex-wrap: wrap; }

.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 650; padding: 9px 14px; border-radius: 9px; cursor: pointer;
}
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.on { box-shadow: 0 0 0 2px var(--accent-ink) inset; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); margin-top: 8px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--warn); text-decoration: underline; cursor: pointer; padding: 0 0 0 6px; font-size: 12px; }

.card { border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.card p { margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.card.locked { opacity: .6; }
.card.done { opacity: .75; }
.card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-head strong { margin-right: auto; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #ffffff10; color: var(--muted); }
.tag.good { color: var(--good); }
.tag.bad { color: var(--warn); }
.cost { white-space: nowrap; margin-right: 4px; }
.cost.missing { color: var(--bad); }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 12px 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
/* Klassen mit k-Präfix: "radio" ist schon das Funkfenster (sonst liegen die Einträge übereinander) */
.log li.k-good { color: var(--good); }
.log li.k-warn { color: var(--warn); }
.log li.k-event { color: var(--accent); }
.log li.k-radio { color: #9cf5a8; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.alert { border: 1px solid var(--accent); background: #d4e15714; border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; }
.alert .btn { margin-top: 8px; }
.alert.warn { border-color: var(--warn); background: #ffb34714; }
.alert.ok { border-color: var(--good); background: #7fe08a14; }
.list .good { color: var(--good); }
.list .bad { color: var(--warn); }

/* ---------- Bau-Leiste ---------- */
.placebar {
  position: absolute; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 6;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 6px 24px #000a;
}

/* ---------- Meldungen ---------- */
.toasts {
  position: absolute; top: calc(var(--top-h) + 44px); left: 50%; transform: translateX(-50%);
  z-index: 8; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  background: #000e; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 8px 12px; border-radius: 8px; font-size: 13px; transition: opacity .4s, transform .4s;
}
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(-6px); }

/* ---------- Dialog ---------- */
.modal { position: absolute; inset: 0; z-index: 10; background: #000b; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden], .sheet[hidden], .placebar[hidden], .tileinfo[hidden] { display: none; }
.modal-card {
  width: min(440px, 100%); max-height: 85vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 14px; padding: 18px;
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-body { max-height: calc(100dvh - 190px); overflow-y: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ---------- Funksprüche ---------- */
.radio {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 12px calc(var(--nav-h) + var(--safe-b) + 14px);
  background: linear-gradient(transparent 35%, #000c);
}
.radio[hidden] { display: none; }
.radio-card {
  position: relative; overflow: hidden; width: min(520px, 100%);
  background: #07110a; border: 1px solid #2f6b3a; border-radius: 12px; padding: 14px 16px 12px;
  box-shadow: 0 0 0 1px #000, 0 10px 40px #000c, inset 0 0 40px #1f5a2a40;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: #9cf5a8;
}
.radio-card::after {           /* Bildschirmzeilen */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(transparent 0 2px, #00000038 2px 3px);
}
.radio-noise { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; opacity: .5; }
.radio-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: .12em; color: #5fd474; margin-bottom: 8px; }
.radio-bars { display: inline-flex; align-items: flex-end; gap: 2px; }
.radio-bars i { width: 4px; background: #1f3b24; display: inline-block; }
.radio-bars i.on { background: #6ff085; box-shadow: 0 0 6px #6ff085; }
.radio-text { position: relative; margin: 0; min-height: 5.6em; font-size: 14px; line-height: 1.5; text-shadow: 0 0 6px #4fd06688; user-select: none; }
.radio-foot { position: relative; display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 11px; color: #4f9e5b; }
.radio-skip { background: none; border: 1px solid #2f6b3a; color: #6fbf7c; border-radius: 6px; padding: 4px 9px; font: inherit; cursor: pointer; }
.radio.lost .radio-text { color: #ff8a7a; text-align: center; font-size: 18px; letter-spacing: .1em; min-height: 3em; padding-top: 1em; animation: flicker .25s steps(2) infinite; }
@keyframes flicker { 50% { opacity: .55; } }

@media (min-width: 900px) {
  .sheet { left: auto; right: 12px; width: 400px; border-radius: 14px; bottom: calc(var(--nav-h) + 12px); border: 1px solid var(--line); }
}

/* ---------- Anmeldung und Online ---------- */
.pill[hidden] { display: none; }
.screen { z-index: 20; background: radial-gradient(circle at 50% 30%, #1d1b14, var(--bg) 70%); }
.screen[hidden] { display: none; }
.tabs { display: flex; gap: 4px; margin: 4px 0 14px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 4px; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form label[hidden], .hint[hidden] { display: none; }
input { user-select: text; -webkit-user-select: text; }
.form input {
  font: inherit; font-size: 16px; /* 16px: iOS zoomt sonst beim Antippen */
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px;
}
.form input:focus { outline: none; border-color: var(--accent); }
.form .btn { margin-top: 4px; }
.form-error { margin: 0; color: var(--bad); font-size: 13px; }
.form-error[hidden] { display: none; }
.checks { display: flex; flex-direction: column; gap: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

.form label.check-inline { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- Schmale Bildschirme: Kopfzeile zweizeilig, Rohstoffe in eigener Zeile ---------- */
@media (max-width: 700px) {
  :root { --top-h: 86px; }
  #topbar { flex-wrap: wrap; align-content: center; row-gap: 6px; padding: 6px 8px; }
  .top-actions { order: 1; flex: 1 1 100%; }
  #power { margin-right: auto; }
  .resources { order: 2; flex: 1 1 100%; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); padding-right: 24px; }
  #nav button { font-size: 10px; }
}

/* Neuigkeiten und Rückmeldungen */
.form textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 90px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 11px; font: inherit; font-size: 16px; user-select: text; -webkit-user-select: text;
}
.form textarea:focus { outline: none; border-color: var(--accent); }
.news h3 { margin-bottom: 4px; }
.news .list li { line-height: 1.4; }
.modal-body .news h3 { display: none; }

/* ---------- Startseite (Anmeldung) ----------
   Gemalter Querschnitt wie eine Tafel aus einem alten Atlas, daneben ein schlichtes Feld.
   Die Beschriftung der Schichten liegt in derselben Box wie das Bild und bleibt deshalb immer an Ort und Stelle. */
.start {
  --paper: #e9dfc6;
  --ink: #12110e;
  --cond: "Bahnschrift Condensed", "Bahnschrift", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  position: absolute; inset: 0; z-index: 20;
  display: grid; grid-template-columns: auto minmax(320px, 1fr);
  background: var(--ink); overflow: hidden;
  user-select: none;
}
.start[hidden] { display: none; }
.start-art { margin: 0; height: 100dvh; position: relative; background: #2a2620; border-right: 1px solid #000; }
.start-plate { position: relative; height: 100%; aspect-ratio: 1360 / 2048; }
.start-plate img { display: block; width: 100%; height: 100%; object-fit: cover; }
.start-layers, .start-scale { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; pointer-events: none; }
.start-layers li { position: absolute; right: 0; transform: translateY(-50%); display: flex; align-items: center; }
.start-layers li::before { content: ""; width: 26px; height: 1px; background: rgba(233,223,198,.75); }
.start-layers span {
  font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--paper); background: rgba(18,17,14,.78); padding: 3px 6px 3px 5px;
}
.start-scale li { position: absolute; left: 0; width: 14px; height: 1px; background: rgba(233,223,198,.8); }
.start-scale span {
  position: absolute; left: 18px; top: -6px; white-space: nowrap;
  font: 10px/1 var(--mono); color: var(--paper); text-shadow: 0 1px 2px #000;
}

.start-panel {
  height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; justify-content: center; gap: 28px;
  padding: 40px clamp(24px, 6vw, 88px);
  max-width: 620px;
}
.start-kicker {
  margin: 0 0 10px; font: 11px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.start-title {
  margin: 0; font-family: var(--cond); font-stretch: condensed; font-weight: 700;
  font-size: clamp(56px, 9vw, 104px); line-height: .86; letter-spacing: .01em; text-transform: uppercase;
  color: var(--paper);
}
/* Grabstrich unter dem Schriftzug: säuregelb, links bündig, wie eine Markierung im Plan */
.start-title::after { content: ""; display: block; width: 2.1em; height: 6px; margin-top: 14px; background: var(--accent); }
.start-lede { margin: 18px 0 0; max-width: 34ch; font-size: 17px; line-height: 1.45; color: #cfc6b0; }

.start-card { max-width: 380px; }
.start-card h2 { margin: 0 0 12px; font: 700 20px/1.2 var(--cond); letter-spacing: .02em; text-transform: uppercase; color: var(--paper); }
.start-card h2[hidden] { display: none; }
.start-card .tabs { margin: 0 0 18px; gap: 18px; border: 0; justify-content: flex-start; }
.start-card .tabs button {
  flex: none; padding: 0 0 4px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  font: 700 15px/1.2 var(--cond); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.start-card .tabs button.on { color: var(--paper); border-bottom-color: var(--accent); }
.start-card .form { gap: 14px; }
.start-card .form label { font: 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); gap: 7px; }
.start-card .form label.check-inline { font: 13px/1.3 system-ui, sans-serif; letter-spacing: 0; text-transform: none; }
.start-card .form input:not([type=checkbox]) {
  background: #1b1915; border: 1px solid #3a362d; border-radius: 2px; padding: 11px 12px;
  font-family: system-ui, sans-serif; letter-spacing: 0; text-transform: none;
}
.start-card .form input:focus { border-color: var(--paper); box-shadow: inset 3px 0 0 var(--accent); }
.start-card .btn {
  align-self: flex-start; min-width: 180px; padding: 12px 22px; border-radius: 2px;
  font: 700 15px/1 var(--cond); letter-spacing: .08em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-ink); border: 0;
}
.start-card .btn:active { transform: translateY(1px); }
.start-card .hint { color: var(--muted); }
.start-card .modal-foot { justify-content: flex-start; }

.start-foot { border-top: 1px solid #2c2922; padding-top: 16px; max-width: 420px; }
.start-quote { margin: 0 0 6px; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 14px; color: #b9b09a; }
.start-sign { margin: 0; font: 10px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #6f685a; }

/* Handy: Bild als Streifen oben (Himmel, Kapsel, erste Schichten), darunter das Feld */
@media (max-width: 760px) {
  .start { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .start-art { height: auto; border: 0; overflow: hidden; }
  .start-plate { width: 100%; height: auto; max-height: 46dvh; aspect-ratio: auto; overflow: hidden; }
  .start-plate img { height: auto; aspect-ratio: 1360 / 2048; object-fit: initial; }
  .start-scale, .start-layers li:nth-child(n+5) { display: none; }
  .start-layers { height: auto; aspect-ratio: 1360 / 2048; bottom: auto; }
  .start-art::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px; background: linear-gradient(transparent, var(--ink)); }
  .start-panel { height: auto; overflow: visible; justify-content: flex-start; gap: 22px; padding: 4px 22px calc(28px + var(--safe-b)); margin-top: -40px; position: relative; }
  .start-title { font-size: 64px; }
  .start-lede { font-size: 15px; }
  .start-card .btn { width: 100%; }
}

/* Bau-Menü: gemaltes Gebäude als Vorschau links neben dem Text */
.card.has-pic { display: grid; grid-template-columns: 84px 1fr; column-gap: 12px; }
.card.has-pic > :not(.card-pic) { grid-column: 2; }
.card-pic { grid-row: 1 / span 4; width: 84px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 3px; background: #0e0d0b; align-self: start; }
.card-pic.cut { object-fit: contain; background: linear-gradient(#6f7a3a, #3b3f22); padding: 4px; }
