/* Weltsim – Kartenspiel mit rechtem Spielfeld (auf dem Handy unten) und Kopfzeile */
:root {
  --paper: #f1f2ec; --panel: #fbfbf8; --ink: #1d2a32; --muted: #5d6a70; --rule: #d6dad2; --accent: #1f5f8b; --accent-ink: #ffffff;
  --good: #2e7d4f; --bad: #b3383f; --warn: #a86a12;
  --sea: #a9cbe6; --water: #8fbadf; --river: #3f7bb5; --border: #a3343c; --region: #1f5f8b;
  --lbl-land: #6b5a44; --lbl-wald: #3d6b3a;
  --lu-acker: #ece6c8; --lu-gruen: #cfe0ae; --lu-wald: #8fb27b; --lu-heide: #d4c6a4; --lu-wohn: #e8d3c8; --lu-misch: #dfbeb3;
  --lu-gewerbe: #d6cbe0; --lu-industrie: #cabdd6; --lu-hof: #e6d8b6; --lu-bauland: #f0e2a0; --lu-gemein: #d9c3c9;
  --rd-b: #e7a23d; --rd-l: #f1cf68; --rd-k: #fbf1c6; --rd-ort: #ffffff; --rd-weg: #e4d7b8; --rd-case: #978b7c;
  --bd-wohnen: #b9897a; --bd-gemischt: #a5766a; --bd-gewerbe: #8e80a8; --bd-industrie: #7d7095; --bd-land: #a98f6e; --bd-oeff: #6c5c56;
  --lu-handel: #efc6ae; --lu-park: #bfe0a0; --lu-gruenfl: #d9e8c3; --lu-friedhof: #b7cfa6; --lu-sport: #b3dbb0; --lu-platz: #e8e3da;
  --lu-gehoelz: #a6c48d; --lu-obst: #d7e6a8; --lu-moor: #c9cbb6;
  --bd-handel: #c9805b; --bd-buero: #7f97ad;
  --gb-eigen: #1f5f8b; --gb-fremd: #9a4f8f; --gb-miet: #3f9a5c; --gb-kauf: #d9a520;
  --bt-hof: #5f8f2f; --bt-muehle: #b07a2a; --bt-baeckerei: #c4572e; --bt-molkerei: #3f86b8; --bt-mosterei: #8a3f70; --bt-laden: #2f6f8f;
  --halo: rgba(241, 242, 236, 0.92);
  --f-display: "Barlow Semi Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --f-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --panel-w: 420px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #13191d; --panel: #192126; --ink: #e3e8e6; --muted: #9aa7ad; --rule: #2c363c; --accent: #6eb0dd; --accent-ink: #0f1a22;
    --good: #6cc48d; --bad: #e2717a; --warn: #e0a64a;
    --sea: #1d3446; --water: #2a5174; --river: #5b9bd3; --border: #e2717a; --region: #6eb0dd;
    --lbl-land: #c9b89a; --lbl-wald: #8fc48a;
    --lu-acker: #2d2f27; --lu-gruen: #2b3a26; --lu-wald: #2f4a2c; --lu-heide: #3a3529; --lu-wohn: #3d302c; --lu-misch: #45332e;
    --lu-gewerbe: #362f40; --lu-industrie: #322a3d; --lu-hof: #3c3626; --lu-bauland: #4d4524; --lu-gemein: #43333a;
    --rd-b: #c9892f; --rd-l: #b59a4b; --rd-k: #6f6a58; --rd-ort: #59615f; --rd-weg: #4b4536; --rd-case: #0c1013;
    --bd-wohnen: #8d6a5e; --bd-gemischt: #7f5c52; --bd-gewerbe: #6d6283; --bd-industrie: #5f5574; --bd-land: #7e6b52; --bd-oeff: #a08c84;
    --lu-handel: #4a3329; --lu-park: #2f4a2a; --lu-gruenfl: #2c3a27; --lu-friedhof: #2b3d2a; --lu-sport: #2a4532; --lu-platz: #33302c;
    --lu-gehoelz: #34492e; --lu-obst: #39452a; --lu-moor: #33362c;
    --bd-handel: #a06a4e; --bd-buero: #5f7487;
    --gb-eigen: #6eb0dd; --gb-fremd: #c27ab7; --gb-miet: #5fbf7d; --gb-kauf: #e6bd4a;
    --halo: rgba(19, 25, 29, 0.9);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #13191d; --panel: #192126; --ink: #e3e8e6; --muted: #9aa7ad; --rule: #2c363c; --accent: #6eb0dd; --accent-ink: #0f1a22;
  --good: #6cc48d; --bad: #e2717a; --warn: #e0a64a;
  --sea: #1d3446; --water: #2a5174; --river: #5b9bd3; --border: #e2717a; --region: #6eb0dd;
  --lbl-land: #c9b89a; --lbl-wald: #8fc48a;
  --lu-acker: #2d2f27; --lu-gruen: #2b3a26; --lu-wald: #2f4a2c; --lu-heide: #3a3529; --lu-wohn: #3d302c; --lu-misch: #45332e;
  --lu-gewerbe: #362f40; --lu-industrie: #322a3d; --lu-hof: #3c3626; --lu-bauland: #4d4524; --lu-gemein: #43333a;
  --rd-b: #c9892f; --rd-l: #b59a4b; --rd-k: #6f6a58; --rd-ort: #59615f; --rd-weg: #4b4536; --rd-case: #0c1013;
  --bd-wohnen: #8d6a5e; --bd-gemischt: #7f5c52; --bd-gewerbe: #6d6283; --bd-industrie: #5f5574; --bd-land: #7e6b52; --bd-oeff: #a08c84;
  --lu-handel: #4a3329; --lu-park: #2f4a2a; --lu-gruenfl: #2c3a27; --lu-friedhof: #2b3d2a; --lu-sport: #2a4532; --lu-platz: #33302c;
  --lu-gehoelz: #34492e; --lu-obst: #39452a; --lu-moor: #33362c;
  --bd-handel: #a06a4e; --bd-buero: #5f7487;
  --gb-eigen: #6eb0dd; --gb-fremd: #c27ab7; --gb-miet: #5fbf7d; --gb-kauf: #e6bd4a;
  --halo: rgba(19, 25, 29, 0.9);
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
.app { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); grid-template-rows: auto minmax(0, 1fr); }

/* Kopfzeile */
.top { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--rule); min-width: 0; }
.brand { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: 0.04em; }
.clock { font-family: var(--f-data); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }
.tabs button { position: relative; border: 0; background: transparent; padding: 6px 10px; border-radius: 4px; font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: 0.03em; color: var(--muted); cursor: pointer; }
.tabs button[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.badge { display: inline-block; min-width: 8px; height: 8px; margin-left: 5px; border-radius: 50%; background: var(--bad); vertical-align: middle; }
.money { font-family: var(--f-data); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; padding: 4px 10px; border: 1px solid var(--rule); border-radius: 6px; }
.money.neg { color: var(--bad); border-color: var(--bad); }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px; font-size: 14px; }

/* Karte */
.stage { position: relative; min-width: 0; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--sea); }
.maplibregl-ctrl-attrib { display: none; }
.maplibregl-canvas-container.pointer { cursor: pointer; }
.toolbar { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; pointer-events: none; z-index: 5; }
.toolbar > * { pointer-events: auto; }
.search { position: relative; flex: 1 1 240px; max-width: 340px; }
.search input { width: 100%; box-sizing: border-box; font-size: 15px; padding: 9px 12px 9px 34px; border-radius: 6px; border: 1px solid var(--rule); background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.search svg { position: absolute; left: 10px; top: 11px; width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.14); overflow: hidden; }
.results button { display: flex; width: 100%; gap: 8px; justify-content: space-between; align-items: baseline; text-align: left; border: 0; background: transparent; padding: 8px 12px; cursor: pointer; border-top: 1px solid var(--rule); }
.results button:first-child { border-top: 0; }
.results button:hover, .results button:focus-visible { background: var(--paper); outline: none; }
.results .kind { font-family: var(--f-display); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); flex: none; }
.layers { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-display); font-weight: 600; font-size: 13px; letter-spacing: 0.04em; padding: 5px 9px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--rule); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.miet { background: var(--gb-miet); } .sw.kauf { background: var(--gb-kauf); } .sw.betrieb { background: var(--bt-laden); border-radius: 50%; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.lbl { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-family: var(--f-display); color: var(--ink);
  text-shadow: 0 0 3px var(--halo), 0 0 3px var(--halo), 0 0 6px var(--halo); }
.lbl.t1 { font-size: 17px; font-weight: 700; } .lbl.t2 { font-size: 15px; font-weight: 600; } .lbl.t3 { font-size: 13px; font-weight: 600; }
.lbl.t4 { font-size: 12px; font-weight: 500; color: var(--muted); }
.lbl.big { font-size: 22px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.lbl.st { font-size: 20px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.lbl.nr { font-size: 14px; font-weight: 500; font-style: italic; letter-spacing: 0.12em; color: var(--lbl-land); }
.lbl.wd { font-size: 12px; font-weight: 500; font-style: italic; color: var(--lbl-wald); }
.lbl.gp { font-size: 11px; font-weight: 600; color: var(--lbl-land); }
.lbl.se { font-size: 12px; font-weight: 500; font-style: italic; color: var(--river); }
.lbl.bt { font-size: 12px; font-weight: 600; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; padding: 0 4px; text-shadow: none; }
.lbl.bt.ich { border-color: var(--accent); color: var(--accent); }
.status { position: absolute; left: 16px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--f-data); font-size: 12px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 5px 10px; z-index: 4; max-width: calc(100% - 90px); box-sizing: border-box; }
.status .load { color: var(--accent); }
.mapbtns { position: absolute; right: 16px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 6px; z-index: 4; }
.mapbtns button { width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--rule); background: var(--panel); font-family: var(--f-display); font-weight: 700; font-size: 16px; cursor: pointer; }
.mapbtns button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Spielfeld */
.panel { background: var(--panel); border-left: 1px solid var(--rule); overflow-y: auto; box-sizing: border-box; padding: 16px 20px 28px; min-width: 0; min-height: 0; }
#sheet { display: flex; flex-direction: column; gap: 18px; }
.eyebrow { font-family: var(--f-display); font-size: 12px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.panel h1 { font-family: var(--f-display); font-weight: 700; font-size: 25px; line-height: 1.12; margin: 2px 0 0; text-wrap: balance; }
.panel h2 { font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 8px; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.panel h3 { font-family: var(--f-display); font-weight: 600; font-size: 15px; margin: 0; }
.panel p { margin: 0; }
section { display: flex; flex-direction: column; gap: 8px; }
.lead { margin-top: 6px !important; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--f-data); font-size: 13px; font-variant-numeric: tabular-nums; }
.figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fig { border-top: 2px solid var(--ink); padding-top: 6px; min-width: 0; }
.fig b { display: block; font-family: var(--f-display); font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fig span { font-size: 12px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 10px; }
.warn { font-size: 13px; border-left: 2px solid var(--warn); padding-left: 10px; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.back { align-self: flex-start; font-size: 13px; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.pill { display: inline-block; font-family: var(--f-display); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--rule); }
.pill.ok { border-color: var(--good); color: var(--good); } .pill.leer { border-color: var(--bad); color: var(--bad); } .pill.ich { border-color: var(--accent); color: var(--accent); }

/* Tabellen */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-family: var(--f-display); font-weight: 600; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 4px 6px 4px 0; border-bottom: 1px solid var(--rule); }
.tbl td { padding: 6px 6px 6px 0; border-bottom: 1px dashed var(--rule); vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--f-data); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.rowlink { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font-weight: 600; }

/* Formulare */
form.f { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
form.f.inline { display: flex; flex-wrap: wrap; padding: 0; border: 0; background: none; }
form.f .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  width: 100%; box-sizing: border-box; padding: 7px 9px; border-radius: 5px; border: 1px solid var(--rule); background: var(--panel); font-size: 15px; min-width: 0; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 5px; border: 1px solid var(--rule); background: var(--panel); cursor: pointer; font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: 0.02em; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn.wrap { white-space: normal; text-align: left; justify-content: flex-start; max-width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
form.f label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
form.f label.check input { width: auto; margin: 0; }
.choice { display: grid; gap: 6px; }
.choice label { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); padding: 8px 10px; border: 1px solid var(--rule); border-radius: 5px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--accent); }
.choice small { color: var(--muted); margin-left: auto; font-family: var(--f-data); font-size: 12px; }
.card { border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.card header { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.feed { display: flex; flex-direction: column; gap: 0; }
.feed div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--rule); font-size: 14px; }
.feed time { font-family: var(--f-data); font-size: 12px; color: var(--muted); }
.feed .neu { font-weight: 600; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.spark { width: 100%; height: 54px; display: block; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; }
.kpi b { font-family: var(--f-display); font-size: 19px; font-variant-numeric: tabular-nums; }
.kpi .spark { grid-column: 1 / -1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); box-sizing: border-box; padding: 10px 14px; border-radius: 6px;
  background: var(--ink); color: var(--paper); font-size: 14px; z-index: 50; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.toast.err { background: var(--bad); color: #fff; }
.sheet-handle { display: none; }

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .top { padding: 6px 16px; gap: 4px 10px; }
  .tabs { margin-left: 0; order: 5; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tabs button { font-size: 14px; padding: 5px 8px; flex: none; }
  .money { margin-left: auto; font-size: 14px; }
  .panel { max-height: 48vh; border-left: 0; border-top: 1px solid var(--rule); padding: 8px 16px 20px; }
  .panel.collapsed { max-height: 56px; overflow: hidden; }
  .sheet-handle { display: block; margin: 0 auto 8px; width: 44px; height: 5px; border-radius: 3px; background: var(--rule); border: 0; padding: 0; cursor: pointer; }
  .search { max-width: none; }
  .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
