:root {
  --bg: rgba(22, 26, 36, 0.88);
  --bg-solid: #171b25;
  --bg2: rgba(255, 255, 255, 0.06);
  --bg3: rgba(255, 255, 255, 0.11);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f3efe6;
  --muted: #a9a49a;
  --accent: #ffb347;
  --accent-ink: #2a1a00;
  --good: #4cd182;
  --bad: #ff6b5e;
  --warn: #ffd166;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --display: "Georgia", "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1630; color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
canvas#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
[hidden] { display: none !important; }

/* Labels über der 3D-Szene */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.map-label { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap; background: var(--bg); border: 1px solid var(--line); color: var(--text); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(6px); }
.map-label .stars { color: var(--accent); margin-left: 4px; letter-spacing: -1px; }
.fx-label { position: absolute; left: 0; top: 0; color: #7dff9e; font-weight: 800; font-size: 13px; text-shadow: 0 1px 3px #000a; white-space: nowrap; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-left, .hud-mid, .hud-right { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; backdrop-filter: blur(10px); }
.chain { display: flex; flex-direction: column; line-height: 1.1; }
.chain span { font-family: var(--display); font-size: 17px; font-weight: 700; }
.chain small { color: var(--muted); font-size: 11px; }
.money { font-size: 19px; font-weight: 800; color: var(--good); font-variant-numeric: tabular-nums; }
.money.neg { color: var(--bad); }
.clock { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.clock b { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }
.speed { display: flex; gap: 2px; background: var(--bg2); border-radius: 10px; padding: 2px; }
.speed button { background: none; border: 0; padding: 5px 8px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.speed button.on { background: var(--accent); color: var(--accent-ink); }
.save-status { font-size: 11px; color: var(--muted); min-width: 60px; text-align: right; }
.icon-btn { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: var(--bg3); }

/* Dock unten */
#dock { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 6px; backdrop-filter: blur(10px); }
#dock button { display: flex; flex-direction: column; align-items: center; gap: 1px; background: none; border: 0; border-radius: 12px; padding: 6px 12px; font-size: 11px; color: var(--muted); }
#dock button span { font-size: 20px; }
#dock button:hover, #dock button.on { background: var(--bg3); color: var(--text); }
#camctl { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 5px; }
#camctl button { width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--bg2); font-size: 18px; }
#camctl button:hover { background: var(--bg3); }

/* Seitenpanel */
#panel { position: fixed; top: calc(66px + env(safe-area-inset-top)); left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); width: min(420px, calc(100vw - 24px)); display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px); box-shadow: 0 20px 50px #0007; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px 16px; }
.panel-head h2 { margin: 0; font-family: var(--display); font-size: 20px; }
.panel-body { overflow-y: auto; padding: 4px 16px 16px; flex: 1; scrollbar-width: thin; }
.tabs { display: flex; gap: 4px; margin: 4px 0 12px; background: var(--bg2); border-radius: 12px; padding: 3px; }
.tabs button { flex: 1; background: none; border: 0; border-radius: 9px; padding: 7px 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--bg3); color: var(--text); }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 8px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 9px 11px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.bar { height: 7px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.btn { background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: 13px; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,0.18); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: rgba(255,107,94,0.15); color: #ffb3ab; border-color: rgba(255,107,94,0.35); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; padding: 11px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select { background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); }
select option { background: var(--bg-solid); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.concepts { display: grid; gap: 6px; }
.concept { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; background: var(--bg2); border: 2px solid transparent; border-radius: 12px; padding: 8px 10px; text-align: left; }
.concept.on { border-color: var(--accent); background: rgba(255,179,71,0.1); }
.concept .ic { font-size: 22px; }
.concept .nm { font-weight: 700; font-size: 14px; }
.concept .sub { font-size: 11px; color: var(--muted); }
.fit { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; }
.fit.f3 { background: rgba(76,209,130,0.18); color: var(--good); }
.fit.f2 { background: rgba(255,209,102,0.16); color: var(--warn); }
.fit.f1 { background: rgba(255,107,94,0.16); color: var(--bad); }
.levels { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 6px 0; }
.levels button { height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg2); font-size: 12px; font-weight: 700; color: var(--muted); padding: 0; }
.levels button.cur { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.levels button.below { background: rgba(255,179,71,0.25); color: var(--text); }
.levels button.sel { outline: 2px solid #fff; }
.statbars { display: grid; grid-template-columns: 64px 1fr 22px; gap: 4px 8px; align-items: center; font-size: 11px; color: var(--muted); }
.staff-card { background: var(--bg2); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.staff-card .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--bg3); color: var(--muted); }
.badge.on { background: rgba(76,209,130,0.18); color: var(--good); }
table.fin { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.fin td, table.fin th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.fin td:first-child, table.fin th:first-child { text-align: left; color: var(--muted); }
table.fin tr.total td { font-weight: 800; color: var(--text); border-bottom: 0; }
canvas.chart { width: 100%; height: 150px; display: block; background: var(--bg2); border-radius: 12px; }
.news { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.news b { color: var(--muted); font-weight: 600; margin-right: 6px; }
.hint { background: rgba(255,179,71,0.1); border: 1px solid rgba(255,179,71,0.3); color: #ffd8a1; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 8px 0; }

/* Overlay / Startbildschirm */
#overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 700px at 30% 10%, #3a2b20cc, #0b0f1cee 60%), #0b0f1c; overflow-y: auto; }
#overlay.ingame { background: rgba(8,10,16,0.6); backdrop-filter: blur(4px); }
.card { width: min(460px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 22px; padding: 26px; box-shadow: 0 30px 80px #000a; backdrop-filter: blur(16px); }
.logo { text-align: center; margin-bottom: 18px; }
.logo .big { font-size: 52px; line-height: 1; }
.logo h1 { font-family: var(--display); font-size: 32px; margin: 8px 0 2px; letter-spacing: -0.01em; }
.logo p { color: var(--muted); margin: 0; font-size: 14px; }
.menu { display: grid; gap: 8px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.diffs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.diffs button { background: var(--bg2); border: 2px solid transparent; border-radius: 12px; padding: 10px 6px; text-align: center; }
.diffs button.on { border-color: var(--accent); background: rgba(255,179,71,0.1); }
.diffs b { display: block; font-size: 14px; }
.diffs small { color: var(--muted); font-size: 11px; }
.soon { opacity: 0.5; }

#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); background: var(--bg-solid); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: 0.25s; pointer-events: none; z-index: 50; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  #hud { flex-wrap: wrap; padding: calc(6px + env(safe-area-inset-top)) 6px 6px; gap: 6px; }
  .hud-left, .hud-mid, .hud-right { padding: 5px 8px; gap: 8px; }
  .chain small { display: none; }
  .chain span { font-size: 14px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .money { font-size: 15px; }
  .clock b { font-size: 15px; }
  .hud-right { order: 3; width: 100%; justify-content: center; }
  .save-status { display: none; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 62vh; border-radius: 20px 20px 0 0; }
  #dock { bottom: calc(8px + env(safe-area-inset-bottom)); left: 8px; transform: none; }
  #dock button { padding: 5px 8px; }
  #camctl { bottom: calc(8px + env(safe-area-inset-bottom)); right: 8px; grid-template-columns: 1fr; }
  #camctl button { width: 34px; height: 34px; }
}

.map-city { cursor: pointer; }
.map-city:hover circle:last-of-type, .map-city:focus-visible circle:last-of-type { stroke: #ffb347; }
.map-city:focus { outline: none; }

.map-label.rival { background: rgba(40, 30, 30, 0.82); font-weight: 500; }
.owner-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; box-shadow: 0 0 0 1.5px rgba(255,255,255,0.7); }
.lb-table td.num, .lb-table th.num { text-align: right; }
.lb-table tr.mine td { color: var(--accent); font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.online-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 4px; }

.confirm-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(8,10,16,0.55); backdrop-filter: blur(3px); }
.card.confirm { width: min(380px, 100%); padding: 20px; }
.card.confirm p { margin: 0 0 16px; line-height: 1.5; }
details summary { color: var(--muted); }
@media (max-width: 520px) {
  #dock { gap: 2px; padding: 4px; }
  #dock button { font-size: 0; padding: 7px 8px; }
  #dock button span { font-size: 20px; }
}
.lb-table td:nth-child(2), .lb-table th:nth-child(2) { text-align: left; }

/* Schmale Bildschirme: nichts darf über den Rand ragen */
.grid2 > * { min-width: 0; }
.field input, .field select { min-width: 0; max-width: 100%; box-sizing: border-box; }
.card { box-sizing: border-box; max-width: 100%; }
@media (max-width: 480px) { .row { flex-wrap: wrap; } .card { padding: 20px 16px; } }
a.btn { display: block; text-align: center; text-decoration: none; color: inherit; box-sizing: border-box; }
