:root {
  --bg: #11151b;
  --panel: #1a2129;
  --panel-2: #222b35;
  --panel-3: #2a3541;
  --line: #34414f;
  --text: #e8e3d8;
  --muted: #98a2ad;
  --accent: #e0a536;
  --accent-2: #f2c063;
  --good: #6cc070;
  --bad: #e2645d;
  --warn: #e0a536;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 .6em; }
small, .muted { color: var(--muted); }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; overflow: auto; }
.screen.center { display: grid; place-items: center; padding: 16px; }
.loading { font-size: 20px; color: var(--muted); }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #33404e; border-color: #4a5a6b; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #1a1408; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { border-color: #6b3633; color: #f0b1ac; }
.btn.danger:hover:not(:disabled) { background: #4a2725; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.tiny { padding: 2px 7px; font-size: 12px; border-radius: 6px; }
.btn.active { border-color: var(--accent); color: var(--accent-2); }

/* --- Login -------------------------------------------------------------- */
.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.auth-card h1 { text-align: center; font-size: 30px; }
.tagline { text-align: center; color: var(--muted); margin-bottom: 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.tabs button.active { border-color: var(--accent); color: var(--accent-2); }
#auth-form { display: grid; gap: 12px; }
#auth-form label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.error { color: var(--bad); min-height: 1.4em; margin: 0; }

/* --- Startauswahl ------------------------------------------------------- */
.start-wrap { max-width: 1100px; margin: 0 auto; padding: 40px 16px; }
.start-wrap h1 { font-size: 30px; }
.city-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.city-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.city-card .big { font-size: 40px; line-height: 1; }
.city-card .type { color: var(--accent-2); font-weight: 600; }
.city-card .fact { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.city-card .rumor { font-style: italic; color: #cfc6b4; flex: 1; }
.city-card .btn { margin-top: auto; }

/* --- Spielbildschirm ---------------------------------------------------- */
#screen-game { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px; height: 54px; flex: none;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.city-tabs { display: flex; gap: 4px; overflow-x: auto; min-width: 0; }
.city-tabs button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  cursor: pointer; white-space: nowrap;
}
.city-tabs button.active { border-color: var(--accent); color: var(--accent-2); }
.stats { display: flex; gap: 14px; font-weight: 600; white-space: nowrap; margin-left: auto; }
.menu { display: flex; gap: 4px; }
.menu button {
  background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; cursor: pointer;
  display: flex; gap: 5px; align-items: center;
}
.menu button:hover { background: var(--panel-2); border-color: var(--line); }
.menu button .badge { background: var(--accent); color: #1a1408; border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.user { display: flex; gap: 8px; align-items: center; color: var(--muted); white-space: nowrap; }

.visit-banner {
  background: #2c3f55; border-bottom: 1px solid #3f5878; padding: 8px 14px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}

.game-main { flex: 1; display: grid; grid-template-columns: 300px 1fr 350px; min-height: 0; }
.sidebar { background: var(--panel); overflow-y: auto; padding: 14px; min-height: 0; }
.sidebar.left { border-right: 1px solid var(--line); }
.sidebar.right { border-left: 1px solid var(--line); }
.map-wrap { position: relative; min-width: 0; min-height: 0; background: #16202b; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
.map-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(17,21,27,.75); color: var(--muted); font-size: 12px; padding: 4px 10px; border-radius: 12px;
  pointer-events: none; white-space: nowrap;
}

.section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.section:first-child { padding-top: 0; }
.section:last-child { border-bottom: 0; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; }
.row > span:first-child { color: var(--muted); }

.bar { height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; flex: 1; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--good); border-radius: 4px; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.bar-row { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.bar-row b { min-width: 38px; text-align: right; font-size: 12px; }

.rumor-box { background: var(--panel-2); border-radius: var(--radius); padding: 10px 12px; }
.rumor-box p { font-style: italic; color: #d5cdbb; margin-bottom: 8px; }
.rumor-box.confirmed { border: 1px solid #3f6b42; }
.confirmed-text { color: var(--good); font-weight: 600; }

.notice { background: #3a2f17; border: 1px solid #6b5420; color: #f0d79a; border-radius: 8px; padding: 7px 10px; margin-top: 8px; font-size: 13px; }
.notice.bad { background: #3b1f1d; border-color: #6b3633; color: #f0b1ac; }
.notice.good { background: #1d3320; border-color: #3f6b42; color: #b6e3b8; }

.inv { list-style: none; margin: 0; padding: 0; }
.inv li { display: grid; grid-template-columns: 24px 1fr auto 74px; gap: 6px; align-items: center; padding: 3px 0; }
.inv .ic { font-size: 16px; text-align: center; }
.inv .qty { font-variant-numeric: tabular-nums; font-weight: 600; }
.inv .qty.full { color: var(--bad); }
.rate { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.rate.pos { color: var(--good); }
.rate.neg { color: var(--bad); }

/* Detailpanel */
.bheader { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bheader .bicon { font-size: 34px; line-height: 1; }
.lvl { font-size: 12px; background: var(--panel-3); border-radius: 6px; padding: 2px 7px; color: var(--accent-2); }
.desc { color: var(--muted); }
.worker-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.worker-row .wname { flex: 1; }
.worker-row .wname small { display: block; }
.worker-row .count { min-width: 44px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.recipes { display: grid; gap: 6px; }
.recipe {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.recipe:hover { border-color: #4a5a6b; }
.recipe.active { border-color: var(--accent); background: #2e2a1e; }
.recipe .rname { font-weight: 600; }
.recipe .rio { font-size: 12px; color: var(--muted); }
.cost { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.missing, .cost .missing { color: var(--bad); }
.card.locked { opacity: .6; }
.build-list { display: grid; gap: 8px; }
.build-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; }
.build-item .top { display: flex; gap: 8px; align-items: center; }
.build-item .top .bicon { font-size: 24px; }
.build-item .top b { flex: 1; }
.build-item p { margin: 0; font-size: 12.5px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.steps { margin: 0; padding-left: 20px; color: #cfc8b9; }
.steps li { margin-bottom: 5px; }
.catalog { display: grid; gap: 4px; font-size: 13px; }
.catalog div { display: flex; gap: 8px; }
.catalog span:first-child { width: 22px; text-align: center; }

/* --- Modal -------------------------------------------------------------- */
.modal { position: fixed; inset: 0; background: rgba(5,8,12,.65); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-close { position: absolute; top: 12px; right: 12px; background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding-right: 30px; }
.modal-head h2 { margin: 0; flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.btn-group { display: inline-flex; gap: 3px; }
tr.tier-head td { background: var(--panel-2); font-size: 12px; color: var(--accent-2); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }

.cards { display: grid; gap: 10px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.card .big { font-size: 28px; }
.card .grow { flex: 1; min-width: 200px; }
.card.owned { border-color: #6b5420; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; background: var(--panel-2); border-radius: 12px; padding: 12px; }
.form-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

.world-svg { width: 100%; max-height: 420px; background: #1e2a22; border-radius: 12px; display: block; margin-bottom: 14px; }
.world-svg text { font-family: var(--font); }
.world-svg .city { cursor: pointer; }

.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.log-list time { color: var(--muted); font-size: 12px; min-width: 92px; }
.log-list .good { color: #b6e3b8; }
.log-list .warn { color: #f0d79a; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; margin: 12px 0; }

/* --- Toasts ------------------------------------------------------------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--panel-3); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 9px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: toast-in .18s ease-out;
}
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Kleine Bildschirme ------------------------------------------------- */
@media (max-width: 1100px) {
  .menu button span, .brand span { display: none; }
  .game-main { grid-template-columns: 260px 1fr 300px; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  #screen-game { position: static; min-height: 100%; overflow: visible; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .stats { margin-left: 0; }
  .game-main { display: flex; flex-direction: column; }
  .map-wrap { height: 60vh; flex: none; order: -1; }
  .sidebar { overflow: visible; border: 0 !important; border-top: 1px solid var(--line) !important; }
}
