/* Einsatzanzeige im Stil eines Feldgeräts: dunkles Panel, Bernstein als Signalfarbe */
:root {
  --ground: #0f1310;
  --panel: rgba(16, 21, 17, 0.8);
  --panel-solid: #161c17;
  --line: rgba(220, 230, 210, 0.14);
  --fg: #e7e9e0;
  --muted: #a3a99b;
  --amber: #e8b04a;
  --amber-hi: #ffd37a;
  --p2: #6fd3ff;
  --ok: #7bc47f;
  --warn: #e8b04a;
  --danger: #e5604f;
  --font-display: 'Saira Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#game { position: fixed; inset: 0; display: block; }
body.playing #game { cursor: none; }

#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
#hurt {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200, 40, 30, 0.85) 100%);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  backdrop-filter: blur(4px);
}
.hud-tl {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: max(14px, env(safe-area-inset-left, 0px));
  padding: 10px 14px 12px;
  min-width: 220px; max-width: 290px;
}
.hud-level { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.hud-level-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#hud-level {
  font-family: var(--font-display); font-weight: 800; font-size: 22px;
  letter-spacing: 0.06em; text-transform: uppercase; line-height: 1;
}
#hud-op { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
#hud-obj-count { display: none; color: var(--amber-hi); font-size: 11px; }
.hud-btn {
  pointer-events: auto; cursor: pointer;
  font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: 0.1em;
  color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 3px;
  padding: 3px 9px;
}
.hud-btn:hover, .hud-btn:focus-visible { border-color: var(--amber); color: var(--amber-hi); outline: none; }
#hud-objectives { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#hud-objectives li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
#hud-objectives li::before {
  content: ''; width: 9px; height: 9px; flex: none;
  border: 1.5px solid var(--amber); border-radius: 1px;
}
#hud-objectives li.done { color: var(--muted); text-decoration: line-through; }
#hud-objectives li.done::before { background: var(--amber); }
#hud-objectives li.exit { color: var(--muted); margin-top: 4px; }
#hud-objectives li.exit::before { border-color: var(--muted); border-radius: 50%; }
#hud-objectives li.exit.open { color: var(--ok); }
#hud-objectives li.exit.open::before { border-color: var(--ok); background: var(--ok); }

.hud-tr {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
}
#minimap {
  width: 168px; height: 120px;
  border: 1px solid var(--line); border-radius: 4px;
  image-rendering: pixelated;
  background: var(--panel-solid);
}
.hud-stats { display: grid; grid-template-columns: 1fr 1fr; padding: 6px 10px; gap: 8px; }
.hud-stats div { display: flex; flex-direction: column; }
.hud-stats span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.hud-stats b { font-family: var(--font-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Spielerpanels unten: P1 links, P2 rechts */
#hud-players {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  left: max(14px, env(safe-area-inset-left, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
}
.pp { padding: 9px 12px 10px; width: 340px; display: grid; gap: 6px; }
.pp.dead { opacity: 0.55; }
.pp-head { display: flex; align-items: center; gap: 8px; }
.pp-head b { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.03em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-head .kits { color: var(--muted); font-size: 11px; }
.tag {
  font-family: var(--font-display); font-weight: 800; font-size: 12px; letter-spacing: 0.06em;
  padding: 1px 6px; border-radius: 2px; color: #14120a; background: var(--amber-hi);
}
.tag.p1 { background: var(--p2); }
.bar { display: grid; grid-template-columns: 74px 1fr 48px; align-items: center; gap: 8px; }
.bar label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.bar b { font-family: var(--font-display); font-size: 19px; text-align: right; font-variant-numeric: tabular-nums; line-height: 1; }
.bar span { font-size: 10px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.track { height: 9px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden; }
.bar.small .track { height: 4px; }
.fill { height: 100%; width: 100%; background: var(--ok); transition: background 0.3s; }
.fill.low { background: var(--danger); animation: blink 0.7s steps(2) infinite; }
.fill.reload { background: var(--muted); }
.fill.reload.ready { background: var(--amber); }
.fill.heat { background: var(--amber); width: 0; }
.fill.heat.over { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.45; } }

.slots { display: flex; gap: 5px; }
.slot {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 3px;
  padding: 4px 7px 4px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px;
}
.slot kbd {
  grid-row: span 2; align-self: center;
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 3px; padding: 0 4px;
}
.slot .wname { font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .ammo { font-family: var(--font-display); font-size: 18px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.slot.active { border-color: var(--amber); }
.slot.active .wname, .slot.active kbd { color: var(--amber-hi); border-color: var(--amber); }
.slot.empty .ammo { color: var(--danger); }

.mods { display: grid; gap: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 1px 5px; border-radius: 2px; border: 1px solid;
}
.chip.ok { color: var(--muted); border-color: var(--line); }
.chip.dmg { color: var(--warn); border-color: var(--warn); }
.chip.off { color: #1b0f0c; background: var(--danger); border-color: var(--danger); }
.crewrow { display: flex; gap: 4px; }
.crew {
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
  min-width: 22px; text-align: center; padding: 1px 4px; border-radius: 2px;
}
.crew.ok { background: rgba(123, 196, 127, 0.2); color: var(--ok); }
.crew.off { background: rgba(229, 96, 79, 0.25); color: var(--danger); text-decoration: line-through; }

#toast {
  position: absolute; left: 50%; top: max(18px, env(safe-area-inset-top, 0px));
  transform: translate(-50%, -12px);
  max-width: min(560px, calc(100vw - 520px));
  background: var(--panel); border: 1px solid var(--amber); border-radius: 4px;
  padding: 9px 16px; text-align: center;
  font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: 0.03em;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Touch ---------- */
#touch { display: none; }
body.touch.playing #touch { display: block; }
.stick-zone {
  position: fixed; bottom: 0; top: 35%;
  touch-action: none;
}
#touch-left { left: 0; width: 40%; }
#touch-right { right: 0; width: 36%; bottom: 120px; }
.stick-zone .base {
  position: absolute; left: 90px; top: 55%;
  width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18); background: rgba(16, 21, 17, 0.25);
  pointer-events: none;
}
#touch-right .base { left: auto; right: 30px; margin: -60px 0 0 0; }
.stick-zone.on .base { border-color: rgba(255, 211, 122, 0.6); }
#touch-right.on .base { right: auto; margin: -60px 0 0 -60px; }
.knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; background: rgba(255, 211, 122, 0.45); border: 2px solid rgba(255, 211, 122, 0.8);
}
.stick-label {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 255, 255, 0.35); pointer-events: none;
}
.tbtns {
  position: fixed; right: max(12px, env(safe-area-inset-right, 0px)); bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: repeat(2, 62px); gap: 8px;
}
.tbtn {
  height: 50px; border-radius: 8px; touch-action: none;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--fg); background: rgba(16, 21, 17, 0.6); border: 1px solid rgba(255, 255, 255, 0.25);
}
.tbtn.big { grid-column: span 2; height: 58px; background: rgba(232, 176, 74, 0.35); border-color: var(--amber); }
.tbtn.on { background: rgba(232, 176, 74, 0.7); color: #14120a; }
body.touch.playing #hud-players { bottom: auto; top: 96px; right: auto; flex-direction: column; align-items: flex-start; }
body.touch.playing .pp { width: 230px; padding: 6px 9px; gap: 4px; }
body.touch.playing .pp .bar.small:nth-of-type(4) { display: none; }
body.touch.playing #hud-objectives { display: none; }
body.touch.playing #hud-obj-count { display: block; }
body.touch.playing .hud-level { margin-bottom: 0; }
body.touch.playing #toast { top: auto; bottom: 46%; }
.stick-label { bottom: auto; top: 10px; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding-block: 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, rgba(10, 13, 11, 0.35), rgba(10, 13, 11, 0.72));
  overflow-y: auto;
  touch-action: pan-y;
}
.card {
  background: rgba(16, 21, 17, 0.88);
  border: 1px solid var(--line);
  border-top: 3px solid var(--amber);
  border-radius: 4px;
  padding: 28px 32px 26px;
  backdrop-filter: blur(6px);
  width: 100%;
}
.menu-card { max-width: 640px; }
.small-card { max-width: 460px; }
.wide-card { max-width: 980px; }
.eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber);
}
h1, h2, h3 {
  font-family: var(--font-display); font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.02em; margin: 0; line-height: 0.92; text-wrap: balance;
}
h1 { font-size: clamp(48px, 10vw, 86px); }
h2 { font-size: 40px; }
h3 { font-size: 17px; letter-spacing: 0.05em; line-height: 1.1; }
h3 small { font-family: var(--font-mono); font-weight: 400; font-size: 11px; text-transform: none; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.lead { color: var(--muted); line-height: 1.6; margin: 14px 0 20px; max-width: 64ch; }
.lead b.supply { color: var(--amber-hi); font-family: var(--font-display); font-size: 18px; }
.btn {
  pointer-events: auto;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 3px;
  padding: 10px 20px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--amber); color: var(--amber-hi); }
.btn:focus-visible, .seg button:focus-visible, .tank-card:focus-visible { outline: 2px solid var(--amber-hi); outline-offset: 2px; }
.btn.primary { background: var(--amber); color: #1b1608; border-color: var(--amber); }
.btn.primary:hover { background: var(--amber-hi); color: #1b1608; }
.btn.small { font-size: 14px; padding: 6px 12px; }
.btn:disabled { opacity: 0.4; cursor: default; border-color: var(--line); color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.best { color: var(--amber-hi); margin: 12px 0 0; min-height: 1em; }
.controls { margin: 22px 0 0; display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 16px; }
.controls div, .stats div { display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 12px; }
.controls dt { color: var(--amber-hi); }
.controls dd, .stats dd { margin: 0; }
.controls dd { color: var(--muted); }
.stats { margin: 0; display: grid; gap: 6px; }
.stats div { grid-template-columns: 1fr auto; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.stats dt { color: var(--muted); }
.stats dd { font-family: var(--font-display); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats div:last-child dd { color: var(--amber-hi); font-size: 22px; }

/* Einsatzplanung */
.setup-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin: 20px 0 22px; }
.opt { display: grid; gap: 8px; align-content: start; }
.opt p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button {
  flex: 1; cursor: pointer; padding: 8px 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); background: transparent; border: 0;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--amber); color: #1b1608; }
.pick { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; display: grid; gap: 10px; }
.tank-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tank-card {
  cursor: pointer; text-align: left; color: var(--fg);
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 8px 8px; display: grid; gap: 3px; font-family: var(--font-mono);
}
.tank-card:hover { border-color: rgba(232, 176, 74, 0.6); }
.tank-card.on { border-color: var(--amber); background: rgba(232, 176, 74, 0.1); }
.tprev { width: 100%; height: 64px; display: block; }
.tank-grid.compact .tprev { height: 48px; }
.tname { font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 1; }
.tmeta { font-size: 10px; color: var(--muted); }
.tbars { display: grid; gap: 3px; margin-top: 4px; }
.tb { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 4px; font-size: 9px; color: var(--muted); }
.tb i { font-style: normal; }
.tb b { height: 4px; background: var(--amber); border-radius: 1px; }
.tdesc { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.tdesc b { color: var(--fg); font-weight: 600; }

/* Werkstatt */
.upgrades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.upg {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px 9px 12px;
}
.upg b { display: block; font-family: var(--font-display); font-size: 16px; letter-spacing: 0.03em; }
.upg span { font-size: 11px; color: var(--muted); }
.pips { display: flex; gap: 3px; }
.pips i { width: 10px; height: 10px; border: 1px solid var(--amber); border-radius: 1px; }
.pips i.on { background: var(--amber); }

@media (max-width: 900px) {
  .setup-opts { grid-template-columns: 1fr; }
  .tank-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upgrades { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .card { padding: 22px 18px 20px; }
  .hud-tl { max-width: 190px; min-width: 0; padding: 8px 10px; }
  #hud-objectives li { font-size: 11px; }
  .pp { width: 240px; }
  #minimap { width: 126px; height: 90px; }
  .controls div { grid-template-columns: 1fr; gap: 0; }
  #toast { max-width: calc(100vw - 32px); top: 150px; font-size: 15px; }
  #hud-players { flex-direction: column; align-items: flex-start; }
  body.touch.playing #hud-players { top: 172px; }
}
@media (max-width: 460px) {
  .tank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .fill.low { animation: none; }
  #toast { transition: none; }
}
