/* Eiland – Oberfläche */
:root {
  --bg: #0a141d;
  --panel: #0f1c27;
  --panel-2: #142633;
  --line: #22384a;
  --ink: #ece3cd;
  --mute: #8ea2ad;
  --dim: #5f7482;
  --amber: #e8ad4e;
  --amber-deep: #b9792a;
  --sea: #103a68;
  --good: #8fcf7a;
  --bad: #e98a6a;
  --rabbit: #f1e7d0;
  --deer: #d19a5b;
  --fox: #f08035;
  --wolf: #9db4cc;
  --grass: #86c060;
  --forest: #3f9a62;
  --water: #5ab6e0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#app {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: minmax(0, 1fr) 344px;
  grid-template-rows: 50px minmax(0, 1fr);
}

/* ---------- Kopfzeile ---------- */
#topbar {
  grid-column: 1 / 3;
  display: flex; align-items: center; gap: 20px;
  padding: 0 16px;
  background: linear-gradient(#12222f, #0e1a25);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand-mark {
  font: 600 21px/1 var(--serif); letter-spacing: 0.24em; text-transform: uppercase; color: var(--amber);
}
.brand-sub { font: italic 13px/1 var(--serif); color: var(--mute); white-space: nowrap; }
.clock { margin-left: auto; display: flex; align-items: baseline; gap: 12px; font-variant-numeric: tabular-nums; }
#date { font: 600 15px/1 var(--serif); letter-spacing: 0.04em; }
.weather { color: var(--mute); font-size: 12px; min-width: 96px; }
.controls { display: flex; align-items: center; gap: 8px; }
.speed { display: flex; }
.speed .ctl { border-radius: 0; margin-left: -1px; min-width: 40px; }
.speed .ctl:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.speed .ctl:last-child { border-radius: 0 6px 6px 0; }
.ctl {
  height: 30px; padding: 0 11px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  font-variant-numeric: tabular-nums; transition: background 0.12s, border-color 0.12s;
}
.ctl:hover { background: #1b3243; border-color: #35546b; }
.ctl.active { background: var(--amber); border-color: var(--amber); color: #1c1407; font-weight: 600; position: relative; z-index: 1; }
.ctl-icon { width: 32px; padding: 0; display: grid; place-items: center; font-weight: 700; }
.ctl-icon svg { width: 14px; height: 14px; fill: currentColor; }
#btn-pause.paused { background: var(--amber); border-color: var(--amber); color: #1c1407; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Karte ---------- */
#stage { position: relative; overflow: hidden; background: var(--sea); min-height: 0; }
#map { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
#map.tool-observe { cursor: crosshair; }
#map.tool-power { cursor: none; }
#map.panning { cursor: grabbing; }
#viewctl { position: absolute; top: 12px; right: 12px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.zoom-row { display: flex; align-items: center; gap: 5px; padding: 5px; border-radius: 10px; background: rgba(10,20,29,0.86); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
.zoom-row .ctl { height: 28px; }
.zoom-row .ctl-icon { width: 28px; font-size: 17px; line-height: 1; }
.zoom-row .ctl:disabled { opacity: 0.4; cursor: default; }
#zoom-label { min-width: 40px; text-align: center; font: 600 13px/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--amber); }
#minimap { width: 168px; height: 112px; border-radius: 8px; border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0,0,0,0.4); cursor: pointer; touch-action: none; background: var(--sea); }
#veil { position: absolute; inset: 0; pointer-events: none; }
#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 52%, rgba(3,10,20,0.5) 100%);
}
#paused-badge {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  padding: 5px 16px; border-radius: 999px; pointer-events: none;
  background: rgba(10,20,29,0.78); border: 1px solid var(--amber-deep); color: var(--amber);
  font: 600 12px/1.3 var(--serif); letter-spacing: 0.2em; text-transform: uppercase;
}
#tooltip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 250px;
  padding: 7px 10px; border-radius: 7px;
  background: rgba(9,18,26,0.92); border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4); font-size: 12px; line-height: 1.45;
}
#tooltip b { color: var(--amber); font-weight: 600; }
#tooltip .tt-sub { color: var(--mute); }
#inspect {
  position: absolute; top: 14px; left: 14px; width: 232px; z-index: 4;
  padding: 11px 13px 12px; border-radius: 10px;
  background: rgba(11,21,30,0.9); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#inspect h3 { margin: 0 0 1px; font: 600 16px/1.2 var(--serif); display: flex; align-items: center; gap: 8px; }
#inspect h3 canvas { width: 30px; height: 22px; }
#inspect .ins-sub { color: var(--mute); margin-bottom: 8px; font-size: 12px; }
#inspect .ins-state { margin-top: 8px; font: italic 13px/1.3 var(--serif); color: var(--amber); }
#inspect .ins-close { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--dim); font-size: 16px; padding: 2px 4px; }
#inspect .ins-close:hover { color: var(--ink); }
#inspect .ins-stats { margin-top: 6px; color: var(--mute); font-size: 12px; }
#inspect .ins-actions { display: flex; gap: 6px; margin-top: 9px; }
#inspect .ins-actions .ctl { flex: 1; height: 28px; padding: 0 6px; font-size: 12px; }
#inspect .ins-actions .ctl:disabled { opacity: 0.4; cursor: default; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 34px; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; }
.bar-row span { color: var(--mute); }
.bar-row b { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: #0a141c; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04); }
.bar i { display: block; height: 100%; border-radius: 3px; transition: width 0.3s; }

#toast {
  position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 6; pointer-events: none;
  padding: 7px 16px; border-radius: 999px; white-space: nowrap;
  background: rgba(28,14,10,0.92); border: 1px solid #8a4a34; color: #f3c4ac; font-size: 13px;
}

/* ---------- Werkzeugleiste ---------- */
#dock {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: stretch; gap: 14px;
  padding: 9px 11px 9px 15px; border-radius: 14px;
  background: rgba(10,20,29,0.88); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45); backdrop-filter: blur(6px);
}
.energy { width: 156px; display: flex; flex-direction: column; justify-content: center; gap: 7px; }
.energy-label { display: flex; justify-content: space-between; align-items: baseline; }
.energy-label span { font: 600 10px/1 var(--serif); letter-spacing: 0.1em; text-transform: uppercase; color: var(--mute); }
.energy-label .lbl-short { display: none; }
.energy-label b { font: 600 17px/1 var(--serif); color: var(--amber); font-variant-numeric: tabular-nums; }
.energy-bar { position: relative; height: 10px; border-radius: 5px; background: #071018; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }
.energy-bar i { position: absolute; inset: 0 auto 0 0; width: 55%; border-radius: 5px; background: linear-gradient(90deg, var(--amber-deep), var(--amber) 70%, #ffe0a0); box-shadow: 0 0 10px rgba(232,173,78,0.5); }
.energy-bar em { position: absolute; top: 0; bottom: 0; right: auto; background: repeating-linear-gradient(135deg, rgba(10,16,24,0.75) 0 3px, rgba(10,16,24,0.25) 3px 6px); border-left: 1px solid rgba(255,255,255,0.5); }
.tools { display: flex; gap: 6px; }
.tool {
  position: relative; overflow: hidden;
  width: 74px; padding: 7px 2px 6px; border-radius: 9px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line);
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.tool svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool-name { font-size: 11.5px; }
.tool-cost { font-size: 10.5px; color: var(--mute); font-variant-numeric: tabular-nums; }
.tool:hover { background: #1b3243; border-color: #35546b; }
.tool:active { transform: translateY(1px); }
.tool.active { background: #2b2412; border-color: var(--amber); color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.tool.active .tool-cost { color: #c9a56a; }
.tool.poor { color: var(--dim); }
.tool.poor .tool-cost { color: #b0705a; }
.tool .cool { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(4,10,16,0.72); border-top: 1px solid rgba(232,173,78,0.6); pointer-events: none; }

/* ---------- Seitenleiste ---------- */
#sidebar {
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  background: var(--panel); border-left: 1px solid var(--line);
}
.panel { padding: 11px 14px 12px; border-bottom: 1px solid var(--line); }
.panel-grow { flex: 1 0 170px; min-height: 170px; display: flex; flex-direction: column; border-bottom: 0; padding-bottom: 0; }
.panel h2 {
  margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline;
  font: 600 11px/1 var(--serif); letter-spacing: 0.2em; text-transform: uppercase; color: var(--amber);
}
.h2-note { font: italic 11px/1 var(--serif); letter-spacing: 0; text-transform: none; color: var(--dim); }

.sp-row { cursor: pointer; border-radius: 6px; margin: 0 -6px; padding-left: 6px !important; padding-right: 6px !important; }
.sp-row:hover { background: var(--panel-2); }
.sp-row.tracked { background: #2b2412; box-shadow: inset 0 0 0 1px var(--amber-deep); }
.sp-row { display: grid; grid-template-columns: 34px 1fr auto 40px; align-items: center; gap: 8px; padding: 2px 0; }
.sp-row canvas { width: 34px; height: 24px; }
.sp-name { font-size: 13px; }
.sp-name small { display: block; color: var(--dim); font-size: 10.5px; line-height: 1.2; }
.sp-count { font: 600 18px/1 var(--serif); font-variant-numeric: tabular-nums; text-align: right; }
.sp-trend { font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; color: var(--dim); }
.sp-trend.up { color: var(--good); }
.sp-trend.down { color: var(--bad); }
.sp-row.gone .sp-name, .sp-row.gone .sp-count { color: var(--dim); }
.sp-row.gone canvas { opacity: 0.35; }

.meters .bar-row { grid-template-columns: 96px 1fr 44px; margin-top: 5px; }
.meters .bar-row:first-child { margin-top: 0; }
.meters .bar-row span { color: var(--ink); }
.meter-note { margin-top: 7px; color: var(--dim); font-size: 11px; }

#chart { display: block; width: 100%; height: 168px; }
.legend { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 6px; font-size: 11px; color: var(--mute); }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.legend i.area { height: 8px; opacity: 0.6; }

#chronicle {
  list-style: none; margin: 0 -14px; padding: 0 14px 12px; overflow-y: auto; flex: 1; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
#chronicle li {
  position: relative; padding: 5px 0 6px 15px; border-bottom: 1px solid rgba(34,56,74,0.5);
  font-size: 12.5px; line-height: 1.4; animation: slip 0.35s ease-out;
}
#chronicle li::before { content: ""; position: absolute; left: 1px; top: 11px; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
#chronicle li.ev-player::before { background: var(--amber); }
#chronicle li.ev-disaster::before { background: #e5553b; }
#chronicle li.ev-good::before { background: var(--good); }
#chronicle li.ev-bad::before { background: var(--bad); }
#chronicle li.ev-eco::before { background: var(--water); }
#chronicle time { display: block; font: italic 10.5px/1.3 var(--serif); color: var(--dim); }
@keyframes slip { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Begrüßung ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(5,11,18,0.72); backdrop-filter: blur(3px);
}
.card {
  width: min(560px, 100%); max-height: 100%; overflow: auto;
  padding: 28px 32px 26px; border-radius: 14px;
  background: linear-gradient(#14232f, #0e1a25); border: 1px solid #2e4a5f;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6); user-select: text;
}
.card-kicker { margin: 0; font: italic 14px/1 var(--serif); color: var(--mute); }
.card h1 { margin: 4px 0 12px; font: 600 40px/1 var(--serif); letter-spacing: 0.22em; text-transform: uppercase; color: var(--amber); }
.card-lead { margin: 0 0 14px; font: 15px/1.55 var(--serif); color: var(--ink); }
.card-list { margin: 0 0 14px; padding-left: 18px; color: #c9cfc8; font-size: 13.5px; line-height: 1.55; }
.card-list li { margin-bottom: 5px; }
.card-list b { color: var(--ink); font-weight: 600; }
.card-list em { color: var(--amber); font-style: normal; }
.card-keys { margin: 0 0 18px; color: var(--dim); font-size: 12px; }
.primary {
  height: 40px; padding: 0 26px; border-radius: 8px; border: 0;
  background: var(--amber); color: #1c1407; font: 600 15px/1 var(--serif); letter-spacing: 0.06em;
}
.primary:hover { background: #f4bf66; }

/* ---------- schmale Fenster ---------- */
@media (max-width: 980px) {
  #app { grid-template-columns: minmax(0, 1fr) 288px; }
  .brand-sub, .weather { display: none; }
  .tool { width: 62px; }
  .tool-name { font-size: 10.5px; }
  .energy { width: 84px; }
  .energy-label .lbl-long { display: none; }
  .energy-label .lbl-short { display: inline; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto calc(66.7vw + 92px) auto; height: auto; }
  #topbar { grid-column: 1; flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px; }
  .brand-mark { font-size: 17px; }
  .clock { margin-left: auto; }
  .controls { width: 100%; justify-content: space-between; gap: 6px; }
  .speed { flex: 1; }
  .speed .ctl { flex: 1; min-width: 0; padding: 0 4px; }
  #sidebar { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  #chronicle { max-height: 280px; }
  #dock { left: 6px; right: 6px; bottom: 6px; transform: none; gap: 8px; padding: 6px; }
  .energy { width: 50px; flex: none; }
  .energy-label .lbl-short { display: none; }
  .energy-label { justify-content: center; }
  .tools { flex: 1; gap: 4px; min-width: 0; }
  .tool { flex: 1; width: auto; min-width: 0; padding: 6px 0 5px; }
  .tool-name { display: none; }
  .tool-cost { font-size: 10px; }
  #inspect { width: 200px; top: 8px; left: 8px; }
  #viewctl { top: 8px; right: 8px; }
  #zoom-reset { display: none; }
  #minimap { width: 96px; height: 64px; }
  #toast { bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  #chronicle li { animation: none; }
}
