:root {
  --bg: #0b0d12;
  --flaeche: #151922;
  --flaeche-hoch: #1e2430;
  --rand: #2b3342;
  --text: #e7ebf2;
  --gedaempft: #8e98ab;
  --akzent: #7fd4c1;
  --gut: #6ddba0;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Kopf ---------- */

#hud {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--rand);
  background: var(--flaeche);
}
.hud-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#hud-name { font-weight: 650; letter-spacing: .2px; }
#hud-ziel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.balken {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: #0a0d13;
  overflow: hidden;
  border: 1px solid var(--rand);
}
.balken > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--akzent);
  transition: width .18s linear;
}
.balken.fertig > i { background: var(--gut); }
#ziel-text { font-size: 12px; color: var(--gedaempft); white-space: nowrap; }

/* ---------- Bühne ---------- */

#buehne { position: relative; overflow: hidden; }
.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.view.scroll {
  display: block;
  overflow-y: auto;
  padding: 14px 16px 20px;
  -webkit-overflow-scrolling: touch;
}
/* Muss hinter .view.scroll stehen: gleiche Spezifitaet, die spaetere Regel
   gewinnt. Andernfalls bleibt die Aufgabenliste ueber allem liegen. */
.view[hidden] { display: none; }

/* ---------- Saugen ---------- */

#cam-rahmen {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #05070b;
  overflow: hidden;
}
#cam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #05070b;
}
#cam-aus {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  background: radial-gradient(120% 80% at 50% 30%, #1a2130 0%, #0b0d12 70%);
}
#cam-aus[hidden] { display: none; }
#cam-hinweis { margin: 0; color: var(--gedaempft); max-width: 22em; }

#fadenkreuz {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}
#fadenkreuz[hidden] { display: none; }
#fadenkreuz > span {
  width: 26vmin;
  height: 26vmin;
  max-width: 160px;
  max-height: 160px;
  border: 2px solid rgba(255,255,255,.85);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(3,5,9,.42), inset 0 0 18px rgba(0,0,0,.35);
}

#probe {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--flaeche);
  border-top: 1px solid var(--rand);
}
#probe-klecks {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #333a48;
  border: 1px solid var(--rand);
  flex: none;
}
#probe-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
#probe-name { font-size: 16px; }
#probe-sub { font-size: 12px; color: var(--gedaempft); }

/* ---------- Bauen ---------- */

#view-bauen {
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: #05070b;
}
#welt {
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  border-radius: 6px;
  border: 1px solid var(--rand);
}

/* ---------- Tank ---------- */

#tank {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px 8px 6px;
  background: var(--flaeche);
  border-top: 1px solid var(--rand);
}
.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px 5px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--flaeche-hoch);
  color: var(--gedaempft);
  font: inherit;
  font-size: 9.5px;
  cursor: pointer;
}
.slot.an {
  border-color: var(--akzent);
  color: var(--text);
  background: #232c39;
}
.slot.leer { opacity: .45; }
.slot .klecks {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.18);
}
.slot .balken { width: 100%; height: 3px; }
.slot .zahl { font-variant-numeric: tabular-nums; }

/* ---------- Tabs ---------- */

#tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--flaeche);
  border-top: 1px solid var(--rand);
}
#tabs button {
  padding: 12px 4px calc(12px + env(safe-area-inset-bottom) * 0.35);
  background: none;
  border: 0;
  border-top: 2px solid transparent;
  color: var(--gedaempft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#tabs button.an { color: var(--text); border-top-color: var(--akzent); }

/* ---------- Knöpfe ---------- */

button.gross {
  margin: 0 14px 12px;
  padding: 15px 18px;
  border-radius: 14px;
  border: 1px solid var(--rand);
  background: var(--flaeche-hoch);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#cam-aus button.gross { margin: 0; }
button.saugen { background: #24404a; border-color: #35606d; touch-action: none; }
button.saugen:disabled { opacity: .4; }
button.saugen.aktiv { background: var(--akzent); color: #06231d; border-color: var(--akzent); }
.mini {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--rand);
  background: var(--flaeche-hoch);
  color: var(--gedaempft);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* ---------- Aufgaben ---------- */

#view-aufgaben h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--gedaempft);
  margin: 18px 0 8px;
}
#view-aufgaben h2:first-child { margin-top: 0; }
#level-liste, #legende { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#level-liste li button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--rand);
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
#level-liste li button.an { border-color: var(--akzent); background: #1b2530; }
#level-liste .titel { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
#level-liste .haken { color: var(--gut); }
#level-liste .brief, #level-liste .tipp { display: block; font-size: 12.5px; color: var(--gedaempft); margin-top: 3px; }
#level-liste .tipp { color: #6f7a8d; font-style: italic; }
#legende li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
}
#legende .klecks { width: 22px; height: 22px; border-radius: 6px; flex: none; }
#legende b { font-size: 13px; }
#legende span { display: block; font-size: 12px; color: var(--gedaempft); }

.klein { font-size: 12px; color: var(--gedaempft); }
.fuss { margin-top: 22px; text-align: center; }
#ersatz-box { color: var(--gedaempft); font-size: 13px; }
#ersatz-box summary { cursor: pointer; }
.ersatz-zeile { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 6px; }
.ersatz-zeile input[type=color] { width: 46px; height: 34px; padding: 0; border: 1px solid var(--rand); border-radius: 8px; background: none; }
.ersatz-zeile button { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--rand); background: var(--flaeche-hoch); color: var(--text); font: inherit; cursor: pointer; }

/* ---------- Overlays ---------- */

#intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 8, 12, .92);
  backdrop-filter: blur(6px);
}
#intro[hidden] { display: none; }
#intro .karte {
  max-width: 24em;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 18px;
  padding: 22px 20px 8px;
}
#intro h1 { margin: 0 0 6px; font-size: 22px; }
#intro ol { padding-left: 20px; margin: 12px 0; }
#intro li { margin-bottom: 6px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 16px;
  border-radius: 999px;
  background: #222c38;
  border: 1px solid var(--rand);
  font-size: 13px;
  max-width: 88vw;
  text-align: center;
  pointer-events: none;
}
#toast[hidden] { display: none; }
#toast.gut { background: #1d3d2c; border-color: #2f6a4b; }
