/* Pixelschrift liegt mit bei (SIL OFL, siehe fonts/OFL.txt) -- die App
   braucht zum Start nichts aus dem Netz. Pfad relativ zu /assets/. */
@font-face {
  font-family: "Zaubersturm Pixel";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/zaubersturm-pixel.woff2) format("woff2");
}

:root {
  --bg: #140f24;
  --panel: #231a3d;
  --panel-rand: #5b43a8;
  --text: #f1ecff;
  --leise: #a99bd6;
  --gold: #ffd34d;
  --xp: #4fc3ff;
  --rot: #ff4d6a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Zaubersturm Pixel", ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#screen {
  position: fixed;
  left: 0;
  top: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--panel);
  border: 3px solid var(--panel-rand);
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #0008;
  touch-action: manipulation;
}
button:hover, button:focus-visible { border-color: var(--gold); outline: none; }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #0008; }
button.big { font-size: 16px; padding: 16px 28px; background: #4a2f9a; }
/* Akzent-Grossbuchstaben (fr/es) ragen 3 Pixel der Schrift (0,375 em) ueber die Zelle. Bei
   Zeilenhoehe "normal" (1 em) traefe der Akzent einer zweiten Knopfzeile die Zeile darueber;
   1,5 laesst Platz. Deutsch und Englisch behalten "normal" (Deutsch pixelgleich). */
:lang(fr) button, :lang(es) button { line-height: 1.5; }
/* Dasselbe fuer zweizeilige Titel (h1 1,25) und fuer Felder, die mit overflow kappen (Inhaltsbox
   1 em, der Akzent laege darueber und wuerde abgeschnitten): oben Platz schaffen, nur fr/es. */
:lang(fr) h1, :lang(es) h1 { line-height: 1.4; }
/* Polster und Gegen-Rand: das Feld kappt erst hoeher, die Zeile bleibt, wo sie war. */
:lang(fr) .stufen-name, :lang(es) .stufen-name { padding-top: 0.375em; margin-top: -0.375em; }
/* Die Kachel kappt an ihrem 3-px-Rahmen: der Name rueckt 1 px tiefer, damit der Akzent darunter bleibt. */
:lang(fr) .figur-kachel .name, :lang(es) .figur-kachel .name { top: 2px; padding-top: 3px; }

/* Eingabefelder sehen aus wie in den Knopf-Rahmen eingelassen: gleiche
   Schrift, gleicher Pixelrahmen, nur vertieft statt erhaben. */
input[type="text"] {
  font-family: inherit;
  font-size: 16px; /* unter 16px zoomt iOS beim Antippen hinein */
  width: 12em;
  max-width: 100%;
  padding: 12px;
  color: var(--text);
  background: #0b0814;
  border: 3px solid var(--panel-rand);
  border-radius: 0;
  box-shadow: inset 0 4px 0 #0008;
  caret-color: var(--gold);
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
}
input[type="text"]::placeholder { color: var(--leise); opacity: 0.7; }
input[type="text"]:hover { border-color: #7a5fd0; }
input[type="text"]:focus { outline: none; border-color: var(--gold); }
input[type="text"].code-feld { width: 6.5em; text-align: center; letter-spacing: 0.15em; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
/* Kopfband: Statusleiste/Notch und XP-Leiste auf dunklem Grund, darunter
   laeuft es hinter der Anzeigezeile weich ins Spielfeld aus. */
#hud::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(env(safe-area-inset-top) + 12px + 48px);
  background: linear-gradient(to bottom,
    #140f24f2 0, #140f24f2 calc(env(safe-area-inset-top) + 12px),
    #140f2499 calc(env(safe-area-inset-top) + 30px), #140f2400 100%);
  z-index: -1;
}
#xpbar {
  height: 10px;
  background: #0009;
  border-bottom: 2px solid #000;
}
#xpfill {
  height: 100%;
  width: 0;
  background: var(--xp);
  box-shadow: inset 0 -3px 0 #1f6fb0;
}
#hudrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 11px;
  text-shadow: 2px 2px 0 #000;
}
#hud-time { font-size: 14px; }
#hud-kills-icon { width: 12px; height: 12px; image-rendering: pixelated; vertical-align: -1px; }
#btn-pause {
  pointer-events: auto;
  font-size: 10px;
  padding: 8px 10px;
  min-width: 40px;
  min-height: 36px;
}
#hud-items {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 0 10px;
  max-width: 60%;
}
#hud-items img, #pause-items img, .card img {
  image-rendering: pixelated;
  width: 20px;
  height: 20px;
  background: #0007;
  border: 1px solid #000;
}
#banner {
  position: absolute;
  top: 28%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
  line-height: 1.8;
  padding: 0 12px;
}

/* ---------- Bildschirme ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Kein justify-content: center -- ist der Inhalt hoeher als der Schirm,
     ragt er sonst oben hinaus und laesst sich nicht mehr hinscrollen. Die
     Platzhalter vor und nach dem Inhalt (unten) zentrieren genauso, solange
     Platz ist. */
  justify-content: flex-start;
  gap: 14px;
  /* Statusleiste, Notch und Home-Leiste freihalten (App ganzflaechig, viewport-fit=cover). */
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  text-align: center;
  background: #140f24cc;
  overflow-y: auto;
}
#scr-title { background: radial-gradient(circle at 50% 40%, #2c1f55 0%, #140f24 70%); }
h1 {
  margin: 0;
  font-size: clamp(28px, 9vw, 56px);
  line-height: 1.25;
  color: var(--gold);
  text-shadow: 4px 4px 0 #6a2fb8, 8px 8px 0 #000;
}
h2 {
  margin: 0;
  font-size: 20px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
}
p { margin: 0; font-size: 11px; line-height: 1.8; max-width: 34em; }
p.small { font-size: 9px; }
p.dim { color: var(--leise); }
#title-wizard {
  width: 72px;
  height: 96px;
  image-rendering: pixelated;
  animation: schweben 1.6s ease-in-out infinite;
}
@keyframes schweben {
  50% { transform: translateY(-6px); }
}

#cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, 100%);
}
.card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: center;
  text-align: left;
  padding: 12px;
  line-height: 1.6;
}
.card img { width: 48px; height: 48px; grid-row: span 2; }
.card .name { font-size: 11px; color: var(--gold); }
.card .name small { color: var(--xp); font-size: 9px; margin-left: 6px; }
.card .desc { font-size: 9px; color: var(--text); }
.card .taste { color: var(--leise); font-size: 8px; margin-right: 6px; }

#pause-items, #over-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 420px;
  font-size: 10px;
  line-height: 2;
}
#pause-items div { display: flex; align-items: center; gap: 6px; }
#over-stats { flex-direction: column; }
#over-stats .rekord { color: var(--gold); }

/* ---------- Boss, Figurenwahl, Entwicklungen ---------- */

#hud-time.nacht { color: #e07bff; }
#bossbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 64px);
  width: min(360px, 80%);
  text-align: center;
  font-size: 9px;
  color: #ffb3c1;
  text-shadow: 2px 2px 0 #000;
}
/* Langer Name ueber der Zauberleiste (game.js bossNameAusweichen); Deutsch bleibt, wie es war. */
html:not(:lang(de)) #bossbar.tief { top: calc(env(safe-area-inset-top) + 112px); }
#bosshp {
  margin-top: 4px;
  height: 8px;
  background: #000a;
  border: 2px solid #000;
}
#bossfill {
  height: 100%;
  width: 100%;
  background: var(--rot);
  box-shadow: inset 0 -2px 0 #9c1f33;
}

#chars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(640px, 100%);
}
@media (max-width: 560px) {
  #chars { grid-template-columns: minmax(0, 1fr); }
}
.card.figur img:first-child { width: 48px; height: 64px; background: none; border: 0; }
.card .desc img.mini { width: 12px; height: 12px; vertical-align: -2px; }
.card .rek { color: var(--gold); margin-top: 6px; }
.card.evo {
  border-color: var(--gold);
  background: #3b2463;
  animation: gluehen 0.9s ease-in-out infinite alternate;
}
.card.evo .name small { color: var(--gold); }
@keyframes gluehen {
  to { box-shadow: 0 0 18px #ffd34d88, 0 4px 0 #0008; }
}
#pause-evo {
  font-size: 8px;
  line-height: 2;
  color: var(--leise);
  max-width: 460px;
}
#pause-evo .bereit { color: var(--gold); }

/* ---------- Zwei Reihen: oben Zauber, unten Gegenstaende ---------- */

#hud-items { flex-direction: column; gap: 3px; flex-wrap: nowrap; }
.reihe { display: flex; gap: 3px; flex-wrap: wrap; justify-content: inherit; }
.leer {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 1px dashed #ffffff33;
  background: #0004;
}
#pause-items { flex-direction: column; align-items: center; gap: 4px; }
#pause-items .reihe { justify-content: center; gap: 8px; }
#pause-items .platz { display: flex; align-items: center; gap: 4px; }
.reihen-titel { font-size: 8px; color: var(--leise); margin-top: 6px; }

/* ---------- Gesperrtes, Karten, Mysterien ---------- */

#chars { width: min(760px, 100%); }
.card.gesperrt { opacity: 0.75; cursor: default; border-style: dashed; }
.card.gesperrt .name { color: var(--leise); }
.card.gesperrt .desc { color: var(--leise); font-style: italic; }
.card.gesperrt:hover { border-color: var(--panel-rand); }
.card.gesperrt:active { transform: none; }
#maps { display: flex; flex-direction: column; gap: 10px; width: min(460px, 100%); }
.card .probe {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  border: 3px solid;
  box-shadow: inset 0 0 0 3px #0003;
}
.quest:not(.kachel) { background: var(--panel); border: 3px solid var(--panel-rand); padding: 10px 12px; }
.quest.geloest { border-color: var(--gold); }
.quest-text { font-size: 10px; line-height: 1.7; }
.quest-balken { height: 6px; background: #0008; margin: 8px 0 6px; }
.quest-fuell { height: 100%; background: var(--xp); }
.quest.geloest .quest-fuell { background: var(--gold); }
.quest-lohn { font-size: 8px; color: var(--leise); }
.quest.geloest .quest-lohn { color: var(--gold); }
#over-neu { color: var(--gold); font-size: 11px; line-height: 2; text-align: center; }

/* Zwei unsichtbare Platzhalter statt Raender am ersten und letzten Kind:
   das letzte Kind kann ausgeblendet sein (die Werkzeugleiste beim Arkanum),
   dann griffe der Rand ins Leere und alles rutschte nach unten. */
.screen::before, .screen::after { content: ''; flex: 1 0 0; }

/* ---------- Gold, Laden, Werkzeuge beim Aufstieg, Arkana ---------- */

#hud-gold-icon { width: 12px; height: 12px; image-rendering: pixelated; vertical-align: -1px; }
.titel-knoepfe { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.card.ware .preis { color: var(--gold); margin-top: 6px; }
.card.ware.voll .preis { color: var(--leise); }
.card:disabled:not(.gesperrt) { opacity: 0.55; cursor: default; }
#card-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#card-tools button { font-size: 9px; padding: 10px 12px; }
#btn-banish.aktiv { border-color: var(--rot); color: #ffb3c1; }
#cards.bannen .card { border-color: var(--rot); }
.card.arkana { border-color: #e07bff; background: #2c1650; }
.card.arkana .name small { color: #e07bff; }
.card.arkana img { height: 58px; }
.screen button:focus-visible, .screen button.pad-fokus { border-color: var(--gold); box-shadow: 0 0 0 3px #ffd34d66, 0 4px 0 #0008; }

/* ---------- Bestiarium und Statistik ---------- */

.wesen.unbekannt .name { color: var(--leise); }
#stats { display: flex; flex-direction: column; gap: 6px; width: min(520px, 100%); }
.stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 9px;
  line-height: 1.6;
  padding: 8px 12px;
  background: var(--panel);
  border: 2px solid var(--panel-rand);
  text-align: left;
}
.stat span:last-child { color: var(--gold); text-align: right; }

/* ---------- Taegliche Herausforderung ---------- */

#btn-daily { border-color: var(--gold); }
#daily-fig { width: 64px; height: 88px; image-rendering: pixelated; }
#daily-text { font-size: 10px; line-height: 2; max-width: 520px; }
#daily-text div:last-child { color: var(--gold); }
#daily-hist { display: flex; flex-direction: column; gap: 6px; width: min(460px, 100%); }

/* ---------- Gemeinsame Bestenliste ---------- */

.name-zeile { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; justify-content: center; font-size: 9px; }
#daily-name { width: 12em; }
#daily-online { display: flex; flex-direction: column; gap: 6px; width: min(460px, 100%); font-size: 9px; line-height: 1.8; }
#daily-online .stat.ich { border-color: var(--gold); }
#over-online { color: var(--xp); }

/* ---------- Zauberbuch ---------- */

.buch-titel { font-size: 11px; color: var(--gold); margin-top: 8px; }

/* ---------- Zauberwerkstatt ---------- */

.werk-gruppe { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 560px; }
.werk-gruppe button { font-size: 9px; padding: 8px 10px; }
.werk-gruppe button.aktiv { border-color: var(--gold); background: #4a2f9a; }
.werk-vorschau { display: flex; gap: 12px; align-items: center; max-width: 520px; text-align: left; }
.werk-vorschau img { width: 48px; height: 48px; image-rendering: pixelated; flex: none; }
.werk-vorschau p { font-size: 9px; }
#werk-name, #werk-code { width: 14em; }
#werk-code { font-size: 12px; }
#werk-meldung { color: var(--gold); min-height: 1.8em; }

/* ---------- Zauberbuch als Nachschlagewerk ---------- */

#book-tabs button.aktiv { border-color: var(--gold); background: #4a2f9a; }

/* ---------- Runenknopf ---------- */

#btn-rune {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 64px;
  height: 64px;
  padding: 0;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 50%;
  background: #140f24cc;
}
#rune-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: #6a2fb8;
}
#btn-rune .rune-text { position: relative; font-size: 9px; }
#btn-rune.bereit { border-color: #e07bff; animation: gluehen 0.9s ease-in-out infinite alternate; }
#btn-rune.bereit #rune-fill { background: #b050e0; }
#btn-rune.zeichnen { border-color: var(--gold); }

/* ---------- Vertraute ---------- */

#familiars button { display: flex; align-items: center; gap: 4px; }
#familiars button.aktiv { border-color: var(--gold); background: #4a2f9a; }
#familiars img { width: 18px; height: 18px; image-rendering: pixelated; }

/* ---------- Tagebuch ---------- */

/* Tagebuch als Buch: eine Pergamentseite mit Lederrand und Bindung links, Blaettern darunter. */
#diary { display: flex; width: min(420px, 100%); flex: 1 1 auto; min-height: 280px; max-height: 560px; touch-action: pan-y; }
.buchseite { flex: 1; position: relative; display: flex; flex-direction: column; gap: 16px; padding: 26px 22px 22px 26px; text-align: left;
  background: linear-gradient(90deg, #d9c391 0, #f3e3c0 7%, #f3e3c0 93%, #e4cf9c 100%); color: #3b2a22;
  border: 6px solid #5e3517; box-shadow: inset 0 0 30px #a8642e66, 6px 6px 0 #000a; overflow-y: auto; }
.buchseite::before { content: ''; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 6px;
  background: repeating-linear-gradient(#a8642e 0 6px, #5e3517 6px 12px); }
.buchseite .kopf { text-align: center; font-size: 9px; color: #9c1f33; }
.buchseite p { font-size: 11px; line-height: 2; max-width: none; color: #3b2a22; }
.buchseite p { white-space: pre-line; }
.buchseite .buchbild { display: block; width: 100%; max-width: 360px; margin: auto auto 0; image-rendering: pixelated; border: 3px solid #3b2a22; box-shadow: 3px 3px 0 #a8642e66; }
.buchseite.runa-seite .buchbild { border-color: #3a4f7a; }
.buchseite.fehlt .buchbild { border-color: var(--panel-rand); border-style: dashed; opacity: 0.7; }
.buchseite .initial { float: left; font-size: 34px; line-height: 1; margin: 4px 8px 0 0; color: #9c1f33; text-shadow: 2px 2px 0 #a8642e66; }
.buchseite.fehlt { background: #2c2440; color: var(--leise); border-color: var(--panel-rand); border-style: dashed; box-shadow: 6px 6px 0 #000a; }
.buchseite.fehlt p, .buchseite.fehlt .kopf { color: var(--leise); }
.buchseite.fehlt::before { display: none; }
.buchseite.runa-seite { background: linear-gradient(90deg, #c9d6e8 0, #e6eefa 7%, #e6eefa 93%, #d3dff0 100%); border-color: #3a4f7a; }
.buchseite.runa-seite .kopf, .buchseite.runa-seite .initial { color: #3a4f7a; }
.buchseite.von-rechts { animation: blatt-rechts 0.2s ease-out; }
.buchseite.von-links { animation: blatt-links 0.2s ease-out; }
@keyframes blatt-rechts { from { transform: translateX(30px); opacity: 0; } }
@keyframes blatt-links { from { transform: translateX(-30px); opacity: 0; } }
.blaettern { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: min(420px, 100%); }
.blaettern button { font-size: 16px; padding: 8px 18px; }
#diary-punkte { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
#diary-punkte i { width: 6px; height: 6px; background: #a8642e; }
#diary-punkte i.leer { background: transparent; border: 1px solid var(--panel-rand); width: 4px; height: 4px; }
#diary-punkte i.runa { background: #6f8fc9; }
#diary-punkte i.an { background: var(--gold); outline: 1px solid var(--gold); outline-offset: 1px; }
#over-stats div:first-child:not(:only-child) { max-width: 34em; line-height: 1.8; }

/* ---------- Wanderhaendler, Pakte ---------- */

#trader { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); }
#trader .card:disabled { opacity: 0.45; }
#pacts-box { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 8px; }
#pacts-box p { max-width: 34em; }

#title-season { color: #ff9a3c; max-width: 34em; }

/* ---------- Zauberturm, Schmuck ---------- */

#tower-img { image-rendering: pixelated; }
#tower { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); }
#hats button img, #trails button img { height: 12px; vertical-align: middle; image-rendering: pixelated; }
.werk-gruppe button:disabled { opacity: 0.5; }

/* ---------- Spielmodi ---------- */

#modes-text { display: flex; flex-direction: column; gap: 6px; max-width: 34em; font-size: 10px; line-height: 1.8; text-align: center; }
#modes-list { display: flex; flex-direction: column; gap: 4px; width: min(420px, 100%); font-size: 10px; }
#modes-list .stat.ich { border-color: var(--gold); }

/* ---------- Duell, Freunde ---------- */

#duel-hud {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  width: min(360px, 80vw); padding: 6px 8px; background: #140f24cc; border: 2px solid #6a2fb8;
  font-size: 8px; display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.duel-kopf { display: flex; justify-content: space-between; color: #e07bff; }
#duel-bar { height: 6px; background: #0b0814; }
#duel-fill { height: 100%; width: 0; background: #e07bff; }
#duel-actions { display: flex; justify-content: space-between; gap: 4px; color: var(--leise); }
#duel-actions span.bereit { color: #ffffff; }
#duel-actions span { pointer-events: auto; cursor: pointer; padding: 6px 2px; }
#modes-extra { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#modes-list .stat button.klein { font-size: 8px; padding: 4px 6px; }
.quest.bereit { border-color: var(--xp); }
.quest.bereit .quest-lohn { color: var(--xp); }
#over-neu .dim { color: var(--leise); font-size: 9px; }

#btn-reset { font-size: 8px; padding: 6px 10px; opacity: 0.7; }
#btn-reset.warnung { border-color: #ff4d4d; color: #ff4d4d; opacity: 1; }

/* ---------- Runen ueben ---------- */

#runes-pad { width: min(320px, 80vw); height: min(320px, 80vw); border: 3px solid var(--panel-rand); touch-action: none; cursor: crosshair; background: #140f24; }
#runes-progress { display: flex; gap: 8px; }
.ueb-punkt { width: 14px; height: 14px; border: 2px solid #e07bff; }
.ueb-punkt.voll { background: #e07bff; }
#runes-text, #runes-msg { max-width: 30em; text-align: center; }

/* ---------- Runa, Zaehmen ---------- */

.runa { display: flex; align-items: flex-start; gap: 10px; max-width: 34em; }
.runa img { width: 48px; image-rendering: pixelated; }
.runa p { background: #efe6cf; color: #3b2a1a; border: 3px solid #a8642e; padding: 8px 10px; font-size: 9px; line-height: 1.8; margin: 0; position: relative; }
#tame-pad { width: min(540px, 92vw); aspect-ratio: 3 / 2; border: 3px solid var(--panel-rand); image-rendering: pixelated; touch-action: none; cursor: pointer; }
#tame-bar { width: min(360px, 80vw); height: 8px; background: #0b0814; border: 2px solid var(--panel-rand); }
#tame-fill { height: 100%; width: 0; background: #ff4d4d; }
#tame-text, #tame-msg { max-width: 34em; text-align: center; }

/* ---------- Startseite ---------- */

#scr-title { gap: 12px; }
#scr-title #title-wizard { width: 54px; height: 72px; }
.titel-satz { font-size: 10px; color: var(--text); max-width: 30em; }
#scr-title .big { min-width: min(280px, 90vw); }
.titel-modi { min-width: min(280px, 90vw); border-color: var(--gold); }
.titel-neu { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.titel-neu:not(:has(button:not([hidden]))) { display: none; }
.titel-neu button { border-color: var(--gold); color: var(--gold); animation: schweben 1.6s ease-in-out infinite; }
.titel-raster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(520px, 100%);
}
.titel-raster button { font-size: 9px; padding: 10px 6px; min-width: 0; }

.titel-recht { font-size: 8px; color: var(--leise); max-width: 100%; }
.titel-recht a { color: var(--leise); }
#sprache-wahl option { background: #140f24; color: var(--text); }
.titel-recht a:hover, .titel-recht a:focus-visible { color: var(--gold); outline: none; }
.titel-hilfe summary { cursor: pointer; font-size: 9px; color: var(--leise); list-style: none; }
.titel-hilfe summary::before { content: '+ '; }
.titel-hilfe[open] summary::before { content: '– '; }
.titel-hilfe p { margin-top: 6px; }
#title-season { font-size: 8px; }

/* ---------- Aufgabenbrett ---------- */

.brett { display: flex; flex-direction: column; gap: 6px; width: min(520px, 100%); text-align: left; }
.brett-zeile { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 6px 8px; border: 2px solid var(--panel-rand); background: #1c1533cc; }
.brett-zeile.myst { border-color: #6a2fb8; }
.brett-text { font-size: 9px; line-height: 1.6; }
.brett-lohn { font-size: 8px; color: var(--leise); grid-column: 1; }
.brett-balken { grid-column: 1; height: 4px; background: #0b0814; }
.brett-balken div { height: 100%; background: var(--xp); }
.brett-zeile.myst .brett-balken div { background: #e07bff; }
.brett-zahl { grid-column: 2; grid-row: 1 / span 3; align-self: center; font-size: 9px; color: var(--gold); }
.quest.verborgen .quest-text { color: var(--leise); }

/* ---------- Online ---------- */

#net-hint { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); padding: 10px 14px; background: #140f24dd; border: 2px solid var(--gold); color: var(--gold); font-size: 10px; pointer-events: none; }
.online-code { font-size: 28px; letter-spacing: 6px; color: var(--gold); text-shadow: 3px 3px 0 #000; }

.online-titel { margin-top: 12px; color: var(--gold); }
#modes-list .quest { width: 100%; }
#modes-list .stat.dim { color: var(--leise); }

.titel-zwei { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.titel-zwei .titel-modi { min-width: min(220px, 90vw); }
.titel-online { border-color: #e07bff; color: #e07bff; }
#online-text { display: flex; flex-direction: column; gap: 6px; max-width: 34em; font-size: 10px; line-height: 1.8; text-align: center; }
#online-extra { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#online-list { display: flex; flex-direction: column; gap: 4px; width: min(460px, 100%); font-size: 10px; }
#online-list .quest { width: 100%; }
#online-list .stat.dim { color: var(--leise); }

#signs { position: absolute; right: calc(12px + env(safe-area-inset-right)); bottom: calc(92px + env(safe-area-inset-bottom)); pointer-events: auto; display: flex; flex-direction: column; gap: 6px; }
#signs button { font-size: 8px; padding: 8px; min-width: 70px; }
#btn-sign-here { border-color: #5fe36b; color: #5fe36b; }
#btn-sign-help { border-color: #ff4d4d; color: #ff4d4d; }
#signs[hidden] { display: none; }
#net-ready { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: auto; padding: 16px 20px; background: #140f24ee; border: 2px solid var(--gold); text-align: center; min-width: 220px; }
#net-ready[hidden] { display: none; }
#net-ready p { color: var(--gold); margin: 0 0 10px; }
#net-ready-text { font-size: 10px; line-height: 1.8; margin-bottom: 12px; }
#net-ready-text .ok { color: #5fe36b; }
#btn-ready:disabled { opacity: 0.7; }
#net-ready .countdown { font-size: 48px; color: var(--gold); line-height: 1.2; }
#btn-ready[hidden] { display: none; }

/* ---------- Rueckblick einer Runde ---------- */
#over-chronik { width: min(460px, 100%); font-size: 9px; line-height: 1.8; text-align: left; }
#over-chronik summary { cursor: pointer; text-align: center; color: var(--gold); padding: 8px; border: 3px solid var(--panel-rand); background: var(--panel); list-style: none; }
#over-chronik summary::-webkit-details-marker { display: none; }
#over-chronik[open] summary { border-color: var(--gold); }
.chronik-liste { max-height: 40vh; overflow-y: auto; padding: 8px 10px; background: #0b0814; border: 3px solid var(--panel-rand); border-top: 0; }
.chronik-zeit { color: var(--leise); display: inline-block; min-width: 5.5em; }
.chronik-titel { color: var(--gold); margin: 10px 0 2px; }
.card.verderbt { border-color: #9c1030; background: #2a0f22; }
.card.verderbt .name { color: #ff6b85; }
.card.verderbt:hover, .card.verderbt:focus-visible { border-color: #ff3050; }
#scr-runa .runa { max-width: 36em; }
#scr-runa .runa img { width: 64px; }
#scr-runa .runa p { font-size: 10px; line-height: 2; text-align: left; }
#fork-box { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 34em; text-align: center; }
#btn-fork { font-size: 9px; padding: 8px 10px; }
#btn-fork.aktiv { border-color: var(--gold); background: #4a2f9a; }
.card .lage { color: var(--xp); margin-top: 4px; }
#trader-quest { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 34em; text-align: center; border: 3px dashed #a8642e; padding: 8px 10px; }
.card .meister { color: var(--gold); margin-top: 4px; }

/* ---------- Figurenwahl wie in Vampire Survivors ---------- */
#chars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: min(560px, 100%); }
.card.figur-kachel { position: relative; display: block; aspect-ratio: 1 / 1.1; padding: 0; overflow: hidden; }
.card.figur-kachel img { width: auto; height: auto; background: none; border: 0; padding: 0; grid-row: auto; }
.figur-kachel .name { position: absolute; left: 5px; top: 4px; right: 4px; font-size: 8px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.figur-kachel .taste { display: none; }
.card.figur-kachel .bild { position: absolute; left: 44%; bottom: 8%; transform: translateX(-50%); height: 60%; image-rendering: pixelated; }
.card.figur-kachel .waffe { position: absolute; right: 5%; bottom: 7%; width: 26%; image-rendering: pixelated; }
.figur-kachel.gewaehlt { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset, 0 4px 0 #0008; }
.figur-kachel.ungekauft .bild { filter: brightness(0); }
.figur-kachel.ungekauft .name { color: var(--leise); }
.figur-kachel.verborgen { opacity: 0.4; }
.figur-kachel.verborgen .bild { filter: brightness(0.15); }
.figur-kachel.gesperrt { border-style: solid; cursor: pointer; }
/* Die Auswahl klebt unten wie in Vampire Survivors: ohne Scrollen sichtbar. */
.char-unten { position: sticky; bottom: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(560px, 100%);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 85%, transparent); }
#char-detail { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 8px 10px; background: var(--panel); border: 3px solid var(--panel-rand); text-align: left; }
#char-detail .links { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; }
#char-detail img.bild { width: 56px; height: auto; image-rendering: pixelated; }
#char-detail img.waffe { width: 30px; height: auto; padding: 3px; background: #0b0814; border: 2px solid var(--panel-rand); image-rendering: pixelated; }
#char-detail .text { font-size: 9px; line-height: 1.7; display: flex; flex-direction: column; gap: 2px; }
#char-detail .name { color: var(--gold); font-size: 11px; }
#char-detail .meister { color: var(--gold); }
#char-detail .dim { color: var(--leise); font-style: italic; }
.char-gold { color: var(--gold); margin: 0; }
.char-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.char-knoepfe .big { padding: 12px 22px; font-size: 13px; }
#btn-char-ok { background: #2e8f3e; border-color: #5fd35f; }
#btn-char-buy { background: #8a6a1a; border-color: var(--gold); }
#btn-char-buy:disabled { opacity: 0.5; cursor: default; }
#code-input { width: 14em; text-transform: uppercase; }
#code-msg.ok { color: #5fe36b; }
#code-msg.fehler { color: var(--rot); }

/* ---------- Sterben: das Bild verschwimmt, dann kommt der Endbildschirm ---------- */
#screen { transition: filter 0.9s ease-out; }
#screen.sterben { filter: blur(3px) grayscale(0.75) brightness(0.55); }
#hud { transition: opacity 0.6s ease-out; }
#hud.sterben { opacity: 0; }
#scr-over:not([hidden]) { animation: endeEin 0.45s ease-out; }
@keyframes endeEin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#absturz { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); z-index: 99; width: min(360px, calc(100% - 32px));
  background: #140f24f2; border: 3px solid var(--rot); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; text-align: center; font-size: 10px; line-height: 1.7; }
#absturz .klein { color: var(--leise); font-size: 8px; overflow-wrap: anywhere; margin: 0; }
#absturz p { margin: 0; }
#weather-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#weather-pick button { font-size: 9px; padding: 6px 8px; }
#weather-pick button.aktiv { border-color: var(--gold); background: #4a2f9a; }
.turm-stock { display: flex; flex-direction: column; gap: 6px; width: min(560px, 100%); padding: 8px; border: 2px dashed #3f4252; }
.turm-stock.gebaut { border-style: solid; border-color: var(--panel-rand); }
.turm-kopf { font-size: 9px; color: var(--leise); }
.card.turm-raum.verworfen { opacity: 0.45; }
.turm-umbau { font-size: 8px; padding: 6px 8px; align-self: flex-end; }
#tower { display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, 100%); }
#tower-gift { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 12px; border: 3px dashed var(--gold); max-width: 34em; text-align: center; }
#tower-gift .gabe-inhalt { color: var(--gold); }
.turm-bewohner { font-size: 8px; color: var(--leise); font-style: italic; margin: 0; line-height: 1.7; }
.trophaeen-titel { align-self: flex-start; color: var(--gold); margin-top: 6px; }
.trophaeen { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 6px; width: min(560px, 100%); }
.trophaee { font-size: 8px; line-height: 1.6; padding: 8px; border: 2px solid #2c2440; color: var(--leise); background: #0b0814; display: flex; flex-direction: column; gap: 4px; }
.trophaee.teil { border-color: var(--panel-rand); color: var(--text); }
.trophaee.erreicht { border-color: var(--gold); color: var(--gold); background: #231a3d; }
.trophaee-balken { height: 4px; background: #231a3d; }
.trophaee-balken div { height: 100%; background: var(--gold); }

/* Online-Gast: die gewaehlte Figur als Kachel im Raum */
.gast-figur { display: block; width: 120px; margin: 10px auto; }

/* Schwebender Zurueck-Pfeil oben links in allen Menues */
#btn-pfeil-zurueck {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: calc(env(safe-area-inset-left) + 8px);
  z-index: 60;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  background: rgba(20, 12, 36, 0.9);
}
#btn-pfeil-zurueck[hidden] { display: none; }
/* Platz fuer den Pfeil: die Ueberschrift laeuft nicht darunter, sondern bricht um. */
.screen > h2:first-child { box-sizing: border-box; max-width: 100%; padding: 0 52px; text-align: center; }

/* Pause: Stufen je Zauber und Gegenstand */
#pause-items { width: min(100%, 26rem); align-items: stretch; }
#pause-items .reihen-titel { align-self: center; font-size: 10px; margin-top: 10px; }
#pause-items .stufen-zeile { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 3px 8px; background: #0006; border: 2px solid #3a2d5c; }
#pause-items .stufen-zeile img { width: 24px; height: 24px; }
.stufen-name { text-align: left; font-size: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stufen-stand { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.stufen-kaesten { display: flex; gap: 2px; }
.stufen-kaesten i { width: 6px; height: 6px; background: #2a2140; border: 1px solid #5a4a8a; }
.stufen-kaesten i.an { background: var(--gold); border-color: var(--gold); }
.stufen-text { font-size: 8px; color: var(--leise); white-space: nowrap; }
.stufen-text.voll { color: var(--gold); }
.stufen-leer { align-self: center; font-size: 9px; color: var(--leise); }

/* Plaetze: am Altar versiegelt (rot gekreuzt) und noch nicht gekauft (Schloss-grau) */
.leer.versiegelt { border: 1px solid #c83a3a99; background: repeating-linear-gradient(45deg, #c83a3a33 0 3px, transparent 3px 6px), #0006; }
.leer.zu { border: 1px solid #ffffff26; background: repeating-linear-gradient(0deg, #ffffff0d 0 2px, transparent 2px 5px), #0003; opacity: 0.7; }

/* Meldungsverlauf: am Desktop per Enter, am Handy in der Pause */
#meldungen {
  position: absolute;
  left: calc(env(safe-area-inset-left) + 10px);
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  width: min(26rem, calc(100% - 20px));
  max-height: 38vh;
  display: flex;
  flex-direction: column;
  background: rgba(14, 9, 26, 0.88);
  border: 2px solid #5a4a8a;
  z-index: 20;
}
#meldungen[hidden] { display: none; }
.meldungen-kopf { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; font-size: 10px; color: var(--gold); border-bottom: 2px solid #3a2d5c; }
.meldungen-kopf span { color: var(--leise); font-size: 8px; }
#meldungen-liste, #pause-meldungen-liste { overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 4px; }
.meldung { font-size: 9px; line-height: 1.6; text-align: left; }
.meldung-zeit { color: var(--gold); }
.meldung.leer-text { color: var(--leise); }
#meldungen-hinweis { position: absolute; left: calc(env(safe-area-inset-left) + 10px); bottom: calc(env(safe-area-inset-bottom) + 6px); font-size: 8px; color: #ffffff55; pointer-events: none; display: none; }
@media (hover: hover) and (pointer: fine) { #meldungen-hinweis { display: block; } }
#meldungen:not([hidden]) ~ #meldungen-hinweis { display: none; }
#pause-meldungen { width: min(100%, 26rem); margin: 8px 0; border: 2px solid #3a2d5c; background: #0006; }
#pause-meldungen summary { cursor: pointer; padding: 8px; font-size: 10px; color: var(--gold); }
#pause-meldungen-liste { max-height: 40vh; }

/* Aufgabenbrett: Erfuelltes wartet auf das Abholen */
.brett-zeile.fertig { border-color: var(--gold); background: #2a2010e6; animation: abholbar 1.6s ease-in-out infinite; }
@keyframes abholbar { 50% { box-shadow: 0 0 0 2px #ffd34d55; } }
.brett-zeile.fertig .brett-text { color: var(--gold); }
.brett-zeile .abholen, .quest .abholen { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 10px; padding: 8px 12px; background: #2e8f3e; border-color: #5fe36b; color: #fff; }
.quest .abholen { margin-top: 6px; }
.brett-zeile.abgeholt { border-color: #5fe36b; }
.brett-zeile.abgeholt .brett-text { color: #5fe36b; }
@media (prefers-reduced-motion: reduce) { .brett-zeile.fertig { animation: none; } }

/* Truhe als Spielautomat */
.walzen-buehne { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px; cursor: pointer; user-select: none; }
.walzen-truhe { width: 54px; height: auto; image-rendering: pixelated; animation: truhe-wackeln 0.35s ease-in-out infinite; }
@keyframes truhe-wackeln { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-2px); } }
.walzen { display: flex; gap: 10px; }
.walze { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; background: #0b0814; border: 3px solid var(--panel-rand); box-shadow: inset 0 6px 8px #000a, inset 0 -6px 8px #000a; }
.walze img { width: 40px; height: 40px; image-rendering: pixelated; filter: blur(0.4px); opacity: 0.85; }
.walze.steht { border-color: var(--gold); box-shadow: 0 0 0 2px #ffd34d55, 0 0 14px #ffd34d88; animation: walze-halt 0.3s ease-out; }
.walze.steht img { filter: none; opacity: 1; }
@keyframes walze-halt { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
.walzen-hinweis { font-size: 8px; color: var(--leise); }
.walzen-buehne.jackpot .walzen-truhe { animation-duration: 0.18s; filter: drop-shadow(0 0 6px #ffd34d); }
.walzen-buehne.spannung .walze:not(.steht) { border-color: #ff6a2a; animation: walze-zittern 0.12s linear infinite; }
@keyframes walze-zittern { 0%, 100% { transform: translateX(-1px); } 50% { transform: translateX(1px); } }
.walzen-buehne.gewonnen .walze { animation: walze-jubel 0.5s ease-in-out infinite alternate; }
@keyframes walze-jubel { to { box-shadow: 0 0 0 3px #ffd34d, 0 0 26px #ffd34d; } }
@media (prefers-reduced-motion: reduce) { .walzen-truhe, .walze, .walzen-buehne * { animation: none !important; } }
.walzen-spalte { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 96px; min-width: 0; }
.walze-name { width: 100%; font-size: 8px; line-height: 1.6; color: var(--gold); text-align: center; overflow-wrap: anywhere; hyphens: auto; animation: walze-halt 0.3s ease-out; }
.walze-stufe { color: var(--text, #f4f2ff); }

/* Tutorials */
#tipp { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 5, 18, 0.72); }
#tipp[hidden] { display: none; }
.tipp-karte { width: min(26rem, 100%); padding: 18px 16px 12px; background: #1c1533; border: 3px solid var(--gold); box-shadow: 0 6px 0 #000a; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.tipp-karte h2 { padding: 0; }
#tipp-text { font-size: 11px; line-height: 1.9; }
#tipp-punkte { font-size: 10px; color: var(--gold); letter-spacing: 4px; min-height: 1em; }
.tipp-knoepfe { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.tipp-aus { font-size: 8px; padding: 4px 8px; background: none; border: none; color: var(--leise); text-decoration: underline; min-height: 0; box-shadow: none; }
#coach { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 26px); width: min(30rem, calc(100% - 24px));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 8px; padding: 8px 10px;
  background: rgba(28, 21, 51, 0.94); border: 2px solid var(--gold); box-shadow: 0 4px 0 #000a; pointer-events: auto; }
#coach-text { grid-column: 1 / -1; grid-row: 1; }
#coach-schritt { grid-row: 2; }
.coach-knoepfe { grid-row: 2; display: flex; gap: 8px; }
#btn-coach-weiter { font-size: 10px; padding: 6px 14px; min-height: 0; background: #2e8f3e; border-color: #5fe36b; color: #fff; }
#btn-coach-weiter[hidden] { display: none; }
#coach.liest { box-shadow: 0 0 0 9999px rgba(8, 5, 18, 0.45), 0 4px 0 #000a; }
#coach[hidden] { display: none; }
#coach-schritt { font-size: 8px; color: var(--gold); }
#coach-text { font-size: 10px; line-height: 1.7; text-align: left; }
#btn-coach-weg { font-size: 8px; padding: 6px 8px; min-height: 0; }

/* ---------- Titel (1.1): Gewitterbuehne, Kopfzeile, Aufgabenleiste, Kachelraster ---------- */
#scr-title { gap: 10px; background: #140f24;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
           calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
#scr-title::before, #scr-title::after { display: none; }
#title-himmel { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#scr-title > :not(#title-himmel) { position: relative; z-index: 1; }
.titel-kopf, #scr-title .titel-zwei, .titel-aufgabe, .titel-dock { width: min(520px, 100%); }
.titel-kopf { display: flex; justify-content: space-between; align-items: center; }
.titel-kopf-rechts { display: flex; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 9px; line-height: 1; color: var(--gold);
  background: #140f24cc; border: 2px solid var(--panel-rand); padding: 6px 8px; box-shadow: none; min-height: 0; }
.chip:hover, .chip:focus-within, .chip:focus-visible { border-color: var(--gold); }
.chip-bild { width: 14px; height: 14px; image-rendering: pixelated; }
.sprach-chip { position: relative; cursor: pointer; }
/* Das echte Auswahlfeld liegt unsichtbar ueber dem Chip: ein Tipp oeffnet die Liste des Systems.
   16 px, sonst vergroessert iOS beim Antippen die Seite. */
#sprache-wahl { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer;
  -webkit-appearance: none; appearance: none; border: 0; margin: 0; }
#sprache-wahl option { background: #140f24; color: var(--text); }
#scr-title h1 { margin-top: 6px; }
.titel-luft { flex: 1 1 0; min-height: 4px; }
#scr-title #title-wizard { width: 60px; height: 80px; filter: drop-shadow(0 0 12px #9b6bff); }
#scr-title .titel-zwei { flex-wrap: nowrap; }
#scr-title .titel-zwei .titel-modi { flex: 1 1 0; min-width: 0; font-size: 9px; padding: 10px 4px; }
.titel-aufgabe { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px 8px; align-items: center;
  padding: 8px 10px; font-size: 9px; text-align: left; background: #1c1533e6; border: 2px solid #6a2fb8; box-shadow: 0 3px 0 #0008; }
.titel-aufgabe.fertig { border-color: var(--gold); }
.ta-bild { width: 16px; height: 16px; image-rendering: pixelated; grid-row: span 2; }
.ta-text { line-height: 1.5; }
.ta-zahl { color: var(--gold); white-space: nowrap; }
.ta-balken { grid-column: 2 / 4; height: 4px; background: #0b0814; }
.ta-balken i { display: block; height: 100%; background: var(--gold); }
.titel-dock { display: grid; grid-template-columns: repeat(var(--spalten, 4), minmax(0, 1fr)); gap: 6px; }
.kachel { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; min-width: 0;
  padding: 7px 2px 6px; font-size: 7px; line-height: 1.3; background: #1c1533e6; border: 2px solid var(--panel-rand);
  box-shadow: 0 3px 0 #0008; }
.kachel img { width: 24px; height: 24px; image-rendering: pixelated; }
.kachel span { max-width: 100%; overflow-wrap: anywhere; }
.kachel small { font-size: 7px; color: var(--gold); }
.kachel small:empty { display: none; }
.kachel.neu { border-color: var(--gold); }
:lang(fr) .kachel, :lang(es) .kachel { line-height: 1.5; }
#scr-title .titel-recht { margin-top: 2px; }
#scr-stats #title-best:empty { display: none; }

/* Niedrige Bildschirme (iPhone SE, 667 px): enger, damit nichts scrollt. */
@media (max-height: 720px) {
  #scr-title { gap: 7px; }
  #scr-title h1 { font-size: 30px; margin-top: 0; }
  #scr-title #title-wizard { width: 42px; height: 56px; }
  #scr-title .big { padding-top: 10px; padding-bottom: 10px; }
  #scr-title .titel-zwei .titel-modi { padding-top: 8px; padding-bottom: 8px; }
  .kachel { padding: 5px 2px 4px; }
}

/* ---------- Unterseiten (1.1): Kopfzeile, Raster, Karte von unten ---------- */
.kopfzeile { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; width: min(520px, 100%); }
.kopfzeile h2 { grid-column: 2; }
.kopfzeile .chip { grid-column: 3; justify-self: end; }
.raster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: min(520px, 100%); }
@media (min-width: 600px) { .raster { grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(760px, 100%); } }
.raster .kachel { font-size: 8px; padding: 8px 3px 7px; justify-content: center; min-height: 84px; }
.raster .kachel img { width: auto; height: 36px; max-width: 100%; object-fit: contain; }
.raster .kachel span { overflow-wrap: normal; word-break: normal; hyphens: auto; }
.raster .kachel.unbekannt { border-style: dashed; opacity: 0.7; }
.raster .kachel.voll { border-color: #2e8f3e; }
.raster .kachel.teuer { opacity: 0.6; }
.raster .kachel .preis { color: var(--gold); }
.raster .kachel.voll .preis { color: var(--leise); }
.kaestchen { display: inline-flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.kaestchen i { width: 6px; height: 6px; background: #2a2050; border: 1px solid var(--panel-rand); }
.kaestchen i.an { background: var(--gold); border-color: var(--gold); }
#karte-dunkel { position: fixed; inset: 0; z-index: 70; background: #000a; }
#karte { position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; margin: 0 auto; width: min(560px, 100%); max-height: 82vh;
  overflow-y: auto; box-sizing: border-box; background: #1c1533; border: 3px solid var(--gold); border-bottom: 0;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center; box-shadow: 0 -10px 30px #000c; animation: karte-auf 0.18s ease-out; }
@keyframes karte-auf { from { transform: translateY(40px); opacity: 0; } }
#karte-x { position: absolute; top: 6px; right: 6px; font-size: 16px; padding: 4px 10px; min-height: 0; box-shadow: none; }
#karte-inhalt { display: contents; }
.karte-bild { height: 96px; width: auto; max-width: 80%; image-rendering: pixelated; object-fit: contain; }
.karte-bild.symbol { height: 64px; }
.karte-titel { font-size: 16px; }
.karte-unter { font-size: 9px; color: var(--leise); }
.karte-text { font-size: 10px; line-height: 1.8; max-width: 34em; }
.karte-zeilen { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; width: 100%; font-size: 9px; text-align: left; }
.karte-zeilen span:nth-child(odd) { color: var(--leise); }
.karte-zeilen .wert { color: var(--gold); }
.karte-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.reiter-leiste { display: flex; gap: 6px; overflow-x: auto; width: min(520px, 100%); padding: 2px 2px 6px; flex-shrink: 0;
  scrollbar-width: none; }
.reiter-leiste::-webkit-scrollbar { display: none; }
.reiter-leiste button { flex: 0 0 auto; font-size: 9px; padding: 8px 10px; white-space: nowrap; }
.reiter-leiste button.aktiv { border-color: var(--gold); background: #4a2f9a; }
.raster .kachel { font-size: 7px; }
.raster .kachel span { -webkit-hyphens: auto; hyphens: auto; overflow-wrap: anywhere; }
/* Neue Unterseiten beginnen oben (statt mittig): Kopfzeile bleibt an ihrem Platz. */
.screen.seite-oben::before { flex: 0 0 0; }
.screen.seite-oben { padding-top: calc(10px + env(safe-area-inset-top)); }
.seite-oben .kopfzeile { min-height: 44px; }
/* Statistik als Heldenblatt */
.stat-gross { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.stat-kachel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; background: var(--panel); border: 3px solid var(--panel-rand); }
.stat-kachel img, .stat-liebling img { width: 24px; height: 24px; image-rendering: pixelated; }
.stat-kachel b { font-size: 15px; font-weight: normal; color: var(--gold); }
.stat-kachel span { font-size: 7px; color: var(--leise); line-height: 1.4; }
.stat-lieblinge { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
.stat-liebling { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px; background: var(--panel); border: 2px solid #6a2fb8; min-width: 0; }
.stat-liebling img { width: auto; height: 32px; }
.stat-liebling span { font-size: 7px; color: var(--leise); }
.stat-liebling b { font-size: 8px; font-weight: normal; color: var(--gold); line-height: 1.5; overflow-wrap: anywhere; }
.karte-liste { width: 100%; display: flex; flex-direction: column; gap: 4px; font-size: 8px; line-height: 1.6; text-align: left; color: var(--leise); }
#book { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(520px, 100%); }
#book .buch-titel { align-self: flex-start; }
/* Zauberturm: je Stockwerk eine Reihe Raumkacheln, Aktionen in der Karte. */
#tower-bild { position: relative; display: inline-block; line-height: 0; }
#tower-img { max-height: 40vh; width: auto; display: block; }
#tower-floors { position: absolute; inset: 0; }
/* Das Stockwerk ist schmal; der Knopf reicht ueber die ganze Bildbreite, damit er sich gut treffen laesst. */
.turm-stockwerk { position: absolute; left: 0; right: 0; margin: 0; padding: 0; min-height: 0; border: 0; background: transparent; box-shadow: none; cursor: pointer; }
.turm-stockwerk:hover, .turm-stockwerk:focus-visible { background: rgba(255, 211, 77, 0.18); outline: 2px solid var(--gold); outline-offset: -2px; }
.turm-stockwerk:active { background: rgba(255, 211, 77, 0.3); }
.turm-stockwerk.geht::after { content: ''; position: absolute; left: 27%; right: 27%; top: 0; bottom: 0; outline: 2px dashed var(--gold); outline-offset: -1px; animation: turm-glimmen 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes turm-glimmen { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .turm-stockwerk.geht::after { animation: none; } }
.turm-stock { gap: 4px; padding: 6px; width: min(520px, 100%); box-sizing: border-box; }
.turm-reihe { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.raster .kachel.turm-raum.geht { border-color: var(--gold); }
.raster .kachel.turm-raum.beschaedigt { border-color: #c83a3a; }
.raster .kachel.turm-raum.verworfen { opacity: 0.45; }
/* Mysterien als Raster: Siegel, Fortschritt als Mini-Balken. */
.mini-balken { display: block; width: 80%; height: 4px; background: #0b0814; }
.mini-balken i { display: block; height: 100%; background: var(--gold); }
.raster .kachel.quest.geloest { border-color: var(--gold); }
.raster .kachel.quest.abholbar { border-color: var(--gold); animation: schweben 1.6s ease-in-out infinite; }
#quests-stand { font-size: 8px; }
/* Tablet (iPad hoch und quer): Titel, neue Unterseiten und Karte groesser, sonst wirkt alles verloren. */
@media (min-width: 700px) and (min-height: 900px) {
  #scr-title > :not(#title-himmel), .screen.seite-oben > *, #karte { zoom: 1.5; }
}

/* Pause: Weiter gross, die drei Schalter in einer Reihe, Aufgeben klein und abgesetzt. */
#scr-pause #btn-resume { width: min(100%, 26rem); }
.pause-schalter { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: min(100%, 26rem); }
.pause-schalter button { min-width: 0; padding: 8px 4px; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
#scr-pause .pause-aufgeben { margin-top: 10px; padding: 6px 14px; font-size: 10px; opacity: 0.85; }
