/* =========================================================================
   ENERGY IMPERIUM – style.css
   Düster-futuristisch, mobile-first. Touch-Ziele ≥ 48 px.
   Gestaltungsidee: Jeder Energiesektor hat eine Signalfarbe (fossil = Bernstein,
   erneuerbar = Mint, nuklear = Violett), die Karten, Balken und Preise färbt.
   Systemschriften, damit die App offline ohne Webfont-Ladung startet.
   ========================================================================= */

:root {
  --bg: #070b10;
  --surface: #0f1720;
  --surface-2: #16212c;
  --line: #22313f;
  --text: #d6e2ea;
  --muted: #7f93a4;
  --cyan: #37c8ff;
  --fossil: #ff8a3d;
  --renew: #2ee6a6;
  --nuclear: #b58cff;
  --danger: #ff4d6a;
  --touch: 48px;
  --radius: 8px;
  --font: "Bahnschrift", "Segoe UI Variable Text", "Roboto Condensed", "Roboto", system-ui, sans-serif;
  --mono: ui-monospace, "Roboto Mono", "SF Mono", Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.4; overscroll-behavior: none; }
body { padding-top: var(--safe-top); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .01em; }
h3 { font-size: 1.05rem; margin-bottom: .5rem; }
small { color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: .9rem; margin: .25rem 0 .75rem; }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding: .75rem .75rem calc(88px + var(--safe-bottom)); }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- HUD ---------- */
#hud {
  position: sticky; top: var(--safe-top); z-index: 20;
  background: linear-gradient(#0b1219, #0b1219ee); border-bottom: 1px solid var(--line);
  padding: .4rem .75rem .5rem;
}
.hud-top { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.hud-round { font-weight: 700; color: var(--cyan); }
.icon-btn { width: var(--touch); height: 40px; background: transparent; border: 1px solid var(--line); border-radius: var(--radius); font-size: 1.2rem; }
.hud-stats { display: grid; grid-template-columns: 1fr 1fr 1.2fr .9fr; gap: .5rem; align-items: end; }
.stat small { display: block; font-size: .72rem; }
.stat b { font-size: 1.05rem; text-shadow: 0 0 12px rgba(55,200,255,.35); }
.esg-track { display: block; height: 8px; margin-top: .3rem; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
#hud-esg-fill { display: block; height: 100%; width: 50%; transition: width .4s; background: var(--renew); }
#hud-esg-fill[data-level="mid"] { background: #e8c547; }
#hud-esg-fill[data-level="low"] { background: var(--danger); }
.pips { display: flex; gap: 5px; height: 20px; align-items: center; }
.pip { width: 14px; height: 14px; border: 2px solid var(--muted); transform: rotate(45deg); }
.pip.on { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

/* ---------- Panels (abgeschrägte Ecke = Cyber-Look) ---------- */
.panel {
  --sec: var(--cyan);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--sec);
  border-radius: var(--radius); padding: .85rem; margin-bottom: .75rem;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}
.panel h3 { color: var(--sec); }
details.panel summary { min-height: var(--touch); display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.rules ul { margin: .25rem 0 0; padding-left: 1.1rem; color: var(--muted); }
.rules li { margin-bottom: .4rem; }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--touch); padding: .55rem .9rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; cursor: pointer;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .08s, border-color .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: default; }
.btn small { font-weight: 400; font-size: .72rem; }
.btn.primary { background: var(--cyan); color: #04121a; border-color: var(--cyan); }
.btn.danger { background: #2a1119; border-color: #5a2231; color: #ff8fa1; }
.btn.danger small { color: #c37080; }
.btn.big { width: 100%; min-height: 56px; margin-top: .6rem; font-size: 1.05rem; }
.btn.mg { width: 100%; margin-top: .6rem; border-color: var(--sec); color: var(--sec); flex-direction: row; }
.link { background: none; border: 0; color: var(--cyan); text-decoration: underline; min-height: var(--touch); padding: 0 .25rem; cursor: pointer; }
.btn:focus-visible, .chip:focus-visible, .region:focus-visible, .link:focus-visible, #nav button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.row > .btn { flex: 1; }
.stack { display: grid; gap: .5rem; }

/* ---------- Menü ---------- */
.title-block { padding: 1.4rem .25rem 1rem; }
.title-block h1 { font-size: 2.4rem; line-height: 1; color: var(--text); text-shadow: 0 0 24px rgba(55,200,255,.45); }
.title-block p { color: var(--muted); max-width: 32ch; margin: .6rem 0 0; }
.field { display: block; color: var(--muted); font-size: .85rem; margin-bottom: .7rem; }
.field input, .field select { display: block; width: 100%; min-height: var(--touch); margin-top: .25rem; padding: 0 .7rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.slot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.slot small { display: block; }

/* ---------- Karte ---------- */
.ranking { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: 2px; }
.ranking li { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; background: var(--surface); border-radius: 6px; }
.ranking li .num { margin-left: auto; }
.ranking li.me { outline: 1px solid var(--cyan); }
.ranking li.dead { opacity: .5; text-decoration: line-through; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.region-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: .75rem; }
.region { min-height: 92px; align-content: start; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; display: grid; gap: 2px; cursor: pointer; position: relative; }
.region.sel { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan), 0 0 18px rgba(55,200,255,.15); }
.r-icon { font-size: 1.5rem; }
.r-name { font-weight: 700; }
.r-meta { color: var(--muted); font-size: .78rem; }
.dots { display: flex; gap: 4px; }
.pot-list, .energy-list, .market-list, .events, .loglist, .report { list-style: none; margin: 0; padding: 0; }
.pot-list li { display: grid; grid-template-columns: 8.5rem 1fr 3rem; gap: .5rem; align-items: center; min-height: 32px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; }
.pot-list .num { text-align: right; }

/* ---------- Ereignisse / Log ---------- */
.ev { display: grid; gap: 2px; padding: .5rem .6rem; margin-bottom: .4rem; border-left: 3px solid var(--line); background: var(--surface-2); border-radius: 4px; }
.ev.bad { border-color: var(--danger); }
.ev.good { border-color: var(--renew); }
.ev span { color: var(--muted); font-size: .88rem; }
.log { padding: .3rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.log.sabotage { color: #ff8fa1; }
.log.bad { color: #ffb08a; }
.log.good { color: #8df2c9; }
.log .num { color: var(--muted); margin-right: .3rem; }

/* ---------- Manager / Sabotage ---------- */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: none; }
.chip { flex: none; min-height: var(--touch); padding: 0 .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.chip.sel { border-color: var(--cyan); color: var(--cyan); }
.energy-row { --sec: var(--cyan); padding: .6rem 0 .6rem .6rem; border-bottom: 1px solid var(--line); border-left: 3px solid var(--sec); margin-bottom: .4rem; background: linear-gradient(90deg, color-mix(in srgb, var(--sec) 8%, transparent), transparent 60%); }
.e-head { display: flex; align-items: center; gap: .5rem; }
.e-head .lvl { margin-left: auto; margin-right: .5rem; font-family: var(--mono); color: var(--sec); }
.e-sub { color: var(--muted); font-size: .8rem; margin: .15rem 0 .4rem; }
.e-act { display: flex; }
.e-act .btn { flex: 1; flex-direction: row; }
.tag { padding: 2px 8px; border-radius: 10px; background: var(--surface-2); font-size: .75rem; color: var(--muted); }
.tag.bad { background: #3a1620; color: #ff8fa1; }
.sab-methods { display: grid; gap: .4rem; margin-top: .4rem; padding-right: .6rem; }
.sab-methods .btn { flex-direction: column; }

/* ---------- Börse ---------- */
.mkt-row { --sec: var(--cyan); padding: .6rem 0 .6rem .6rem; border-left: 3px solid var(--sec); border-bottom: 1px solid var(--line); margin-bottom: .4rem; }
.m-head { display: grid; grid-template-columns: 1fr auto auto auto; gap: .6rem; align-items: center; }
.price { font-size: 1.05rem; color: var(--sec); }
.delta.up { color: var(--renew); } .delta.down { color: var(--danger); }
.spark { display: block; }
.m-sub { color: var(--muted); font-size: .8rem; margin: .15rem 0 .4rem; }
.m-act { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; padding-right: .6rem; }

/* ---------- Bericht ---------- */
.report li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.report span { color: var(--muted); }

/* ---------- Navigation ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-width: 720px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #0b1219f2; border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom);
}
#nav button { min-height: 64px; background: none; border: 0; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 2px; font-size: .72rem; cursor: pointer; }
#nav button span { font-size: 1.35rem; line-height: 1; }
#nav button.active { color: var(--cyan); box-shadow: inset 0 2px 0 var(--cyan); }
#nav button.end { color: #04121a; background: var(--cyan); font-weight: 700; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(3,6,9,.86); display: grid; place-items: center; padding: 1rem; padding-top: calc(1rem + var(--safe-top)); padding-bottom: calc(1rem + var(--safe-bottom)); overflow-y: auto; }
.dialog, .mg { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.dialog h2, .mg h2 { margin-bottom: .6rem; color: var(--cyan); }
#modal-body p { margin: 0 0 .5rem; }
#mg-canvas { display: block; width: 100%; height: 260px; border-radius: var(--radius); border: 1px solid var(--line); touch-action: none; }
.mg-control { display: block; margin-top: .8rem; color: var(--muted); font-size: .85rem; }
#mg-slider { width: 100%; height: 56px; margin: .25rem 0 0; accent-color: var(--cyan); touch-action: pan-x; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translate(-50%, 20px); z-index: 60; max-width: 90vw; padding: .65rem 1rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { border-color: var(--renew); }
#toast.err { border-color: var(--danger); color: #ff8fa1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 560px) { .region-grid { grid-template-columns: repeat(3, 1fr); } }
