/*
 * Crystal Worlds – Gestaltung „Kristallfenster“:
 *   Spiel:      dunkle, leicht durchscheinende Fenster mit hellem Kristallrahmen (Tönung nach Bedeutung),
 *               Karte im Vollbild, Fenster nur bei Bedarf, Zeigefinger-Cursor wie bei Fire Emblem.
 *   Geschichte: Pergament mit Schriftrolle (Erzähler, Kristall, Kapiteltafeln).
 * Texturen kommen aus js/ui-art.js (CSS-Variablen --win, --win-p …, --frame, --tile, --roll, --hand).
 * Schriften: Silkscreen Bold (Überschriften, eng gesetzt), Tiny5 (Fenster), Fine Fantasy (Erzählung, Dialoge).
 */
@font-face { font-family: 'Silkscreen'; src: url('../fonts/Silkscreen-Bold.ttf') format('truetype'); font-weight: 700; font-display: block; }
@font-face { font-family: 'Tiny5'; src: url('../fonts/Tiny5-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Fine Fantasy'; src: url('../fonts/TinyRPG-FineFantasyStrategies.ttf') format('truetype'); font-display: block; }

:root {
  --head: 'Silkscreen', sans-serif;
  --head-ls: -3px;          /* Silkscreen eng gesetzt */
  --ui: 'Tiny5', monospace;
  --story: 'Fine Fantasy', serif;
  --text: #f0f4ff;
  --dim: #a8b8e8;
  --gold: #ffe08a;
  --up: #8af07a;
  --down: #ff8a8a;
  --purple: #e0b0ff;
  --cyan: #8ad4ff;
  --wild: #ffd070;
  /* ältere Namen, die noch im Code vorkommen */
  --yellow: var(--gold);
  --red: #ff8a8a;
  --green: #8af07a;
  /* Fenstergrund je Tönung */
  --bg-v: linear-gradient(rgba(54, 44, 120, 0.94), rgba(22, 18, 62, 0.94));
  --bg-p: linear-gradient(rgba(42, 60, 136, 0.94), rgba(16, 24, 70, 0.94));
  --bg-e: linear-gradient(rgba(110, 34, 54, 0.94), rgba(52, 14, 30, 0.94));
  --bg-w: linear-gradient(rgba(104, 74, 20, 0.94), rgba(50, 34, 8, 0.94));
  --bg-g: linear-gradient(rgba(40, 96, 48, 0.94), rgba(14, 44, 22, 0.94));
  --bg-c: linear-gradient(rgba(96, 36, 120, 0.94), rgba(44, 14, 62, 0.94));
}

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

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% 30%, #1c1840 0%, #0c0a1a 70%) #0c0a1a;
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 20px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  image-rendering: pixelated;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

h1, h2, h3, .head, .name { font-family: var(--head); font-weight: 700; letter-spacing: var(--head-ls); }

/* ---------- Kristallfenster ---------- */
.win, #unitMenu, #toast, .card, .bag-item, .btn {
  border: 12px solid transparent;
  border-image: var(--win) 6 / 12px stretch;
  background: var(--bg-v);
  background-clip: border-box;
  background-origin: border-box;
  border-radius: 6px;
  color: var(--text);
  text-shadow: 1px 1px 0 #06081c;
}
.win { padding: 0 4px; }
.win.p { border-image: var(--win-p) 6 / 12px stretch; background: var(--bg-p); }
.win.e { border-image: var(--win-e) 6 / 12px stretch; background: var(--bg-e); }
.win.w { border-image: var(--win-w) 6 / 12px stretch; background: var(--bg-w); }
.win.g { border-image: var(--win-g) 6 / 12px stretch; background: var(--bg-g); }
.win.c { border-image: var(--win-c) 6 / 12px stretch; background: var(--bg-c); }

/* ---------- über der Karte: Beschriftung und Menüknopf ---------- */
.hud-chip {
  position: absolute; left: 6px; top: 6px; z-index: 4;
  display: flex; flex-direction: column; padding: 0 6px; max-width: 70%;
  pointer-events: none;
}
.hud-chip.away { display: none; }
#hudMap { font-family: var(--head); font-weight: 700; letter-spacing: var(--head-ls); font-size: 18px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hudTurn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small { color: var(--dim); }
.menu-btn { position: absolute; right: 6px; top: 6px; z-index: 7; min-width: 48px; }

/* ---------- Spielfeld ---------- */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#map { image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }

/* Phasenwechsel als leuchtendes Band */
#banner {
  position: absolute; left: 0; right: 0; top: 42%;
  z-index: 8;
  text-align: center;
  font-family: var(--head); font-weight: 700; letter-spacing: -4px;
  font-size: 27px; line-height: 44px;
  color: #f0f8ff; text-shadow: 2px 2px 0 #06102c;
  background: linear-gradient(90deg, transparent, var(--band, rgba(40, 90, 200, 0.95)) 15%, var(--band, rgba(40, 90, 200, 0.95)) 85%, transparent);
  border-top: 2px solid #bfe4ff; border-bottom: 2px solid #bfe4ff;
  animation: banner 1.1s ease-out forwards;
  pointer-events: none;
}
#banner.player { --band: rgba(40, 90, 200, 0.95); }
#banner.enemy { --band: rgba(170, 40, 60, 0.95); border-color: #ffd0d8; }
#banner.wild { --band: rgba(160, 110, 20, 0.95); border-color: #fff0c0; }
#banner.coop { --band: rgba(120, 50, 170, 0.95); border-color: #f0d0ff; }
@keyframes banner {
  0% { transform: translateX(100%); }
  20%, 80% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

#toast {
  position: absolute; left: 8px; right: 8px; top: 8px; z-index: 9;
  padding: 0 4px;
  text-align: center;
  border-image: var(--win-w) 6 / 12px stretch; background: var(--bg-w);
  pointer-events: none;
}

/* Aktions- und Kartenmenü: Kristallfenster mit Zeigefinger */
#unitMenu {
  position: absolute; z-index: 6;
  display: flex; flex-direction: column;
  padding: 0 2px;
  min-width: 124px;
  border-image: var(--win-p) 6 / 12px stretch; background: var(--bg-p);
}
#unitMenu .btn {
  border: 0; border-image: none; background: none; border-radius: 0; min-height: 0;
  padding: 2px 6px 2px 28px; justify-content: flex-start; text-align: left; position: relative; white-space: nowrap;
}
#unitMenu .btn::before { content: ''; position: absolute; left: -6px; top: 0; width: 32px; height: 24px; }
#unitMenu:not(:hover) .btn:first-child::before, #unitMenu .btn:hover::before, #unitMenu .btn:active::before {
  background: var(--hand) center / 32px 24px; image-rendering: pixelated; animation: point 0.8s steps(2) infinite;
}
#unitMenu .btn:disabled::before { background: none !important; }
@keyframes point { 50% { transform: translateX(3px); } }
#unitMenu .btn.go { color: var(--up); }
#unitMenu .btn.coop { color: var(--purple); }
#unitMenu .btn.danger { color: var(--down); }
#unitMenu .btn.alt { color: var(--dim); }
#unitMenu .btn:disabled { color: #6a74a0; opacity: 1; filter: none; }

/* ---------- schwebende Anzeige (Figurenfenster, Vorschau, Hinweise) ---------- */
#panel {
  position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
}
#panel.top { top: 6px; bottom: auto; right: 62px; }   /* rechts oben bleibt der ≡-Knopf frei */
.unit-card .more { display: none; }
#panel.detail .unit-card .more { display: block; }
#panel .win, #panel .btn { pointer-events: auto; }
#info:empty { display: none; }
#actions { display: flex; flex-wrap: wrap; gap: 4px; }
#actions:empty { display: none; }
#actions .btn { flex: 1 1 30%; min-height: 40px; padding: 0 2px; }

.row { display: flex; align-items: center; gap: 6px; }
.row.between { justify-content: space-between; }
.name { color: #fff; font-size: 18px; line-height: 22px; }
.hp { display: inline-block; width: 72px; height: 8px; background: #0a0c24; border: 2px solid #05061a; vertical-align: middle; box-sizing: content-box; }
.hp i { display: block; height: 100%; background: linear-gradient(#9cf070, #48a838); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 6px; color: var(--dim); }
.stats b { color: #fff; font-weight: normal; }
.elem { display: inline-block; padding: 0 3px; border: 2px solid #05061a; background: rgba(255, 255, 255, 0.12); font-size: 12px; line-height: 14px; vertical-align: middle; }
.side-player { color: var(--cyan); }
.side-enemy { color: #ff9aa8; }
.side-wild { color: var(--wild); }
.pix { image-rendering: pixelated; width: 32px; height: 32px; flex: none; }
.pix.s { width: 16px; height: 16px; }
.pix.ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.bond { display: inline-flex; gap: 3px; }
.pip { display: inline-block; width: 8px; height: 8px; border: 2px solid var(--purple); transform: rotate(45deg); }
.pip.on { background: var(--purple); }
.bond.evo { vertical-align: middle; margin: 0 2px; }
.bond.evo .pip { border-color: var(--gold); width: 9px; height: 9px; }
.bond.evo .pip.on { background: var(--gold); }
.hint, .sub, .dim { color: var(--dim); }
.up { color: var(--up); }
.down { color: var(--down); }
b { font-weight: normal; color: #fff; }

/* Kampfvorschau: zwei Fenster gegenüber */
.fc2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; }   /* je genau die Hälfte, auch bei langen Namen */
.fc2 > .win { min-width: 0; }
.fc2 .row { min-width: 0; }
.fc2 .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; font-size: 16px; }
.fc2 .hp { width: auto; min-width: 24px; }
.fc { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0 8px; align-items: center; }
.fc .l { text-align: left; } .fc .r { text-align: right; } .fc .m { color: var(--dim); text-align: center; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--ui); font-size: 16px; line-height: 20px;
  min-height: 44px; padding: 0 6px;
  cursor: pointer;
}
.btn:active { filter: brightness(1.3); transform: translateY(1px); }
.btn.hot { border-image: var(--win-p) 6 / 12px stretch; background: var(--bg-p); color: #fff; }
.btn.go { border-image: var(--win-g) 6 / 12px stretch; background: var(--bg-g); }
.btn.danger { border-image: var(--win-e) 6 / 12px stretch; background: var(--bg-e); }
.btn.coop { border-image: var(--win-c) 6 / 12px stretch; background: var(--bg-c); }
.btn.alt { color: #c8d0f0; }
.btn.mini { min-height: 40px; padding: 0 4px; }
.btn:disabled { opacity: 0.45; cursor: default; filter: grayscale(0.6); }

/* ---------- Bildschirme ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: calc(12px + env(safe-area-inset-top)) 10px calc(16px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 20%, #221c4c 0%, #0c0a1a 75%) #0c0a1a;
  overflow-y: auto;
  touch-action: pan-y;
}
.overlay[hidden], [hidden] { display: none !important; }
.overlay > .btn { min-width: 240px; }
.overlay.center { justify-content: center; }
.evolve { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; max-width: 440px; text-align: center; }
.evolve:empty { display: none; }
#screenScene.chapter { justify-content: center; background: rgba(6, 6, 20, 0.88); }
.overlay h2 { color: #cfe8ff; font-size: 27px; line-height: 32px; margin: 6px 0 0; text-align: center; letter-spacing: -4px; text-shadow: 3px 3px 0 #000; }
.overlay h3 { color: var(--gold); font-size: 18px; line-height: 22px; margin: 6px 0 0; align-self: flex-start; text-shadow: 2px 2px 0 #000; }

.logo { margin-top: 8vh; text-align: center; }
.logo h1 {
  font-size: 45px; line-height: 46px; letter-spacing: -6px;
  margin: 10px 0 0;
  color: #cfe8ff;
  text-shadow: 3px 3px 0 #3c78dc, 6px 6px 0 #14123a;
}
.gem { display: inline-block; width: 48px; height: 48px; background: var(--gem) center / 48px 48px; image-rendering: pixelated; animation: gem 2s ease-in-out infinite; }
@keyframes gem { 50% { transform: translateY(-4px); filter: brightness(1.25); } }
.tag { color: var(--dim); margin: 0 0 8px; }
/* Sprachumschalter auf dem Titel (wie bei Piplosion) */
.lang-switch { display: flex; gap: 8px; justify-content: center; margin: 8px 0 20px; }   /* unten mehr Abstand zur Copyright-Zeile */
.btn.lang { min-width: 56px; opacity: 0.6; }
.btn.lang[aria-pressed="true"] { opacity: 1; border-image: var(--win-w) 6 / 12px stretch; background: var(--bg-w); color: #fff; }   /* aktive Sprache: goldener Kristallrahmen */
.copyright, .version { color: var(--dim); text-align: center; margin: 0; }

.goal { color: var(--text); text-align: center; max-width: 400px; }
.cards { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 440px; }
.card { display: flex; align-items: center; gap: 8px; padding: 0 4px; text-align: left; font-family: var(--ui); font-size: 16px; line-height: 20px; }
button.card { cursor: pointer; }
.card .grow { flex: 1; min-width: 0; }
.card.sel { border-image: var(--win-p) 6 / 12px stretch; background: var(--bg-p); box-shadow: 0 0 0 2px var(--gold); }
.card.taken { filter: saturate(0.5) brightness(0.8); }
.card.off { filter: grayscale(0.7) brightness(0.65); }
.badge { flex: none; display: flex; flex-direction: column; align-items: center; min-width: 64px; font-size: 12px; line-height: 14px; text-align: center; }
.badge .pix { width: 32px; height: 32px; }
.badge.free { color: var(--up); }
.badge.mine { color: var(--gold); }
.badge.taken { color: #ffb070; }
.tabs { display: flex; gap: 4px; width: 100%; max-width: 440px; }
.tabs .btn { flex: 1; min-width: 0; padding: 0 2px; }
.bag { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; max-width: 440px; }
.bag .hint { grid-column: 1 / -1; margin: 4px 0; }
@media (max-width: 420px) { .bag { grid-template-columns: 1fr; } }   /* schmale Handys: einspaltig */
.bag-item { padding: 0 4px 2px; min-width: 0; }
.bag-item .sub { font-size: 14px; line-height: 16px; }
.bag-item .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bag-item .sub b { color: var(--text); }
.bag-item .badge { min-width: 0; flex-direction: row; gap: 2px; font-size: 12px; }
.bag-item .badge .pix { width: 16px; height: 16px; }
.slot { align-items: center; }
.slot-label { flex: none; width: 104px; overflow-wrap: anywhere; color: var(--gold); font-family: var(--head); font-weight: 700; letter-spacing: var(--head-ls); }
.stats.wide { grid-template-columns: repeat(3, 1fr); gap: 0 4px; }
.stats i { font-style: normal; font-size: 12px; margin-left: 2px; }
.dex { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 100%; max-width: 440px; }
.dex .card { flex-direction: column; gap: 0; text-align: center; padding: 0; }
.dex .unknown { filter: brightness(0.55); }
.dex .seen img { filter: brightness(0); }

.rules { padding-left: 20px; max-width: 440px; color: var(--text); }
.rules li { margin-bottom: 8px; }
.rules b { color: var(--gold); }
.dot { display: inline-block; width: 12px; height: 12px; vertical-align: middle; border: 2px solid #000; }
.dot.p { background: #4880f0; } .dot.e { background: #e04848; } .dot.w { background: #f0c830; }

/* ---------- Kristalle ---------- */
.crystals { display: inline-flex; gap: 2px; vertical-align: middle; padding: 0 4px; }
/* Kristalle im Stil des Logos (Texturen aus ui-art.js): --gs klein (10 px, doppelt), --g groß (24 px) */
.cr { display: inline-block; width: 20px; height: 20px; background: var(--gem-off-s) center / 100% 100% no-repeat; image-rendering: pixelated; vertical-align: middle; }
.cr.on { background-image: var(--gs); filter: drop-shadow(0 0 3px var(--el)); }
.cr.big { width: 48px; height: 48px; margin: 4px; flex: none; background-image: var(--g); }
.cr.huge { width: 96px; height: 96px; background-image: var(--g); animation: crystal 1.6s ease-in-out infinite; filter: drop-shadow(0 0 14px var(--el)); }
@keyframes crystal { 50% { transform: translateY(-6px); filter: brightness(1.2) drop-shadow(0 0 20px var(--el)); } }
#titleCrystals { margin: 0 0 14px; min-height: 14px; }   /* Abstand zum ersten Knopf */

/* Ko-Op-Szene: Streifen fährt auf, Figur und Monster gleiten herein, Blitz, Name */
#coopScene { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; pointer-events: none; background: rgba(6, 6, 20, 0.55); }
.cs-strip { position: relative; width: 100%; height: 200px; overflow: hidden; background: #0e0c24; border-top: 4px solid var(--el); border-bottom: 4px solid var(--el); }
.cs-rays { position: absolute; inset: -150%; background: repeating-conic-gradient(from 0deg, var(--el) 0deg 6deg, transparent 6deg 18deg); opacity: 0.25; }
.cs-hero, .cs-mon { position: absolute; bottom: 36px; width: 96px; height: 96px; image-rendering: pixelated; }
.cs-hero { left: 14%; }
.cs-mon { right: 12%; width: 112px; height: 112px; bottom: 30px; }
.cs-text { position: absolute; left: 0; right: 0; top: 8px; display: flex; flex-direction: column; align-items: center; text-shadow: 2px 2px 0 #000; }
.cs-tag { color: var(--el); letter-spacing: 2px; }
#csName { color: #fff8e0; font-family: var(--head); font-weight: 700; letter-spacing: -4px; font-size: 27px; line-height: 34px; }
.cs-who { position: absolute; top: 166px; color: var(--dim); }
#coopScene.play .cs-strip { animation: cs-strip 2.9s ease-out forwards; }
#coopScene.play .cs-rays { animation: cs-rays 2.9s linear forwards; }
#coopScene.play .cs-hero { animation: cs-hero 2.9s ease-out forwards; }
#coopScene.play .cs-mon { animation: cs-mon 2.9s ease-out forwards; }
#coopScene.play #csName { animation: cs-name 2.9s steps(1) forwards; }
@keyframes cs-strip { 0% { transform: scaleY(0); } 10%, 88% { transform: scaleY(1); filter: none; } 52% { filter: brightness(2.2); } 56% { filter: none; } 100% { transform: scaleY(0); } }
@keyframes cs-rays { from { transform: rotate(0deg); } to { transform: rotate(60deg); } }
@keyframes cs-hero { 0%, 8% { transform: translateX(-180%); } 25%, 85% { transform: translateX(0); } 100% { transform: translateX(-30%); opacity: 0; } }
@keyframes cs-mon {
  0%, 15% { transform: translateX(200%) scale(0.6); }
  35% { transform: translateX(0) scale(1.15); }
  42%, 48% { transform: translateX(0) scale(1); }
  52% { transform: translateX(-24px) scale(1.25); filter: brightness(3); }
  60%, 85% { transform: translateX(0) scale(1); filter: none; }
  100% { transform: translateX(30%); opacity: 0; }
}
@keyframes cs-name { 0%, 30% { opacity: 0; } 31%, 100% { opacity: 1; } }

/* ---------- Story-Szenen ---------- */
#screenScene {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 16px 8px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(6, 6, 20, 0.2), rgba(6, 6, 20, 0.8));
}
#btnSceneSkip { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 8px; }
#sceneCrystal { position: absolute; top: 30%; }

/* Dialog wie bei Fire Emblem: Porträtfenster, darunter das Textfenster */
#sceneDialog { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 4px; }
#sceneDialog.side-left { align-items: flex-start; }
#sceneDialog.side-right { align-items: flex-end; }
.portrait-win { width: 120px; height: 120px; padding: 0; }
.portrait-win img { width: 96px; height: 96px; image-rendering: pixelated; display: block; object-fit: contain; }
/* Detailfigur (32 × 48, dreifach): hochkantes Fenster */
.portrait-win.tall { width: 120px; height: 168px; }
.portrait-win.tall img { width: 96px; height: 144px; }
.say { width: 100%; min-height: 112px; padding: 0 6px 4px; position: relative; font-family: var(--story); font-size: 24px; line-height: 28px; }
#sceneName { font-family: var(--head); font-weight: 700; letter-spacing: var(--head-ls); font-size: 18px; line-height: 24px; color: var(--gold); }
#sceneName:empty { display: none; }
.scene-next { position: absolute; right: 6px; bottom: 2px; color: var(--gold); font-size: 12px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Erzählung und Kapiteltafel auf Pergament */
#sceneStory { width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.card-title {
  font-family: var(--head); font-weight: 700; letter-spacing: var(--head-ls); font-size: 18px; line-height: 24px;
  color: #f8e8c8; background: #8e2a1e; padding: 4px 12px; box-shadow: 3px 3px 0 #3a0c06; text-shadow: 2px 2px 0 #3a0c06; text-align: center;
}
.scene-wrap { position: relative; width: 100%; padding: 0 14px; }
.scene-wrap::before, .scene-wrap::after {
  content: ''; position: absolute; top: -6px; bottom: -6px; width: 22px;
  background: var(--roll) center / 100% 100%; image-rendering: pixelated; z-index: 1;
}
.scene-wrap::before { left: 0; }
.scene-wrap::after { right: 0; transform: scaleX(-1); }
.scene-wrap .scene-next {
  right: 30px; bottom: 8px; z-index: 2; width: 22px; height: 16px; font-size: 0;
  background: var(--arrow) center / 22px 16px no-repeat; image-rendering: pixelated;
  animation: nudge 0.8s steps(2) infinite;
}
@keyframes nudge { 50% { transform: translateY(3px); } }
.scene-box {
  min-height: 120px; padding: 0 8px 6px;
  border: 12px solid transparent; border-image: var(--frame) 8 / 12px round;
  background: var(--tile) repeat; background-size: 96px; background-clip: padding-box;
  color: #24150a; font-family: var(--story); font-size: 24px; line-height: 28px; text-shadow: none;
}

/* ---------------- Endszene (js/finale.js) ---------------- */
#screenFinale { position: fixed; left: 0; right: 0; top: 0; height: 100vh; height: 100dvh; z-index: 60;   /* dvh: ohne die Browserleiste */ background: #06041a; display: flex; flex-direction: column; align-items: center;
  overflow: hidden; transition: opacity .5s; }
#screenFinale.out { opacity: 0; }
#screenFinale canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; }   /* Größe setzt js/finale.js (ganzzahlig skaliert) */
#screenFinale .skip { position: absolute; top: 12px; right: 12px; z-index: 2; }
#screenFinale.text .skip { display: none; }
.finale-text { position: absolute; left: 16px; right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;   /* am unteren Rand; der Kristall nutzt den Platz darüber */ z-index: 1; text-align: center; font-family: var(--story);
  font-size: 24px; line-height: 28px; color: var(--text); text-shadow: 2px 2px 0 #06041a; }
.finale-text > * { opacity: 0; transform: translateY(8px); transition: opacity 1.2s, transform 1.2s; margin: 0 0 12px; }
#screenFinale.text .finale-text > * { opacity: 1; transform: none; }
#screenFinale.text .l2 { transition-delay: 1.4s; }
#screenFinale.text .l3 { transition-delay: 3s; }
#screenFinale.text .l4 { transition-delay: 4.2s; }
#screenFinale.text .l5 { transition-delay: 5.4s; }
.finale-text .l3 { font-family: var(--head); letter-spacing: var(--head-ls); font-size: 32px; line-height: 36px; color: var(--gold); margin-top: 8px; }
.finale-text .l4 { display: flex; align-items: center; justify-content: center; gap: 12px; font-family: var(--head); letter-spacing: var(--head-ls);
  font-size: 16px; line-height: 18px; text-align: left; }
.finale-text .l4 span { font-family: var(--ui); letter-spacing: 0; color: var(--dim); }
.finale-text .badge-tvir { width: 48px; height: 48px; image-rendering: pixelated; }
.finale-text .l5 { font-family: var(--ui); font-size: 16px; color: var(--dim); }
.finale-text .nowrap { white-space: nowrap; }
/* niedrige Bildschirme: Abspann etwas kleiner (setzt js/finale.js, wenn der Text sonst zu viel Höhe braucht) */
#screenFinale.compact .finale-text { font-size: 16px; line-height: 20px; }
#screenFinale.compact .finale-text > * { margin-bottom: 8px; }
#screenFinale.compact .finale-text .l3 { font-size: 24px; line-height: 28px; margin-top: 0; }
#screenFinale.compact .finale-text .l4 { font-size: 12px; line-height: 14px; }
#screenFinale.compact .finale-text .l4 span { font-size: 12px; }
#screenFinale.compact .finale-text .badge-tvir { width: 32px; height: 32px; }

/* ---------------- Vorspann: TVIR-Logo (js/splash.js, wie bei Piplosion) ---------------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #0b0a1e; cursor: pointer; touch-action: none;
}
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 0; opacity: 0; }
.splash canvas {
  width: min(52vw, 34vh, 256px); height: auto; aspect-ratio: 1;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.splash p { margin: 0; font-family: var(--head); font-weight: 700; text-align: center; visibility: hidden; }
.splash p.on { visibility: visible; }
.splash-t1 { margin-top: 1.6em !important; font-size: 16px; color: var(--gold); text-shadow: 2px 2px 0 #05040c; }
.splash-t2 { margin-top: 1em !important; font-size: 16px; color: var(--dim); letter-spacing: 0.4em; padding-left: 0.4em; }
