/* =========================================================================
   css/style.css — „Nur noch kurz kündigen“
   Die gesamte Browserfläche IST die Szene. Creme/Petrol/Pflaume/Koralle.
   ========================================================================= */

:root {
  --creme: #f4ecd8;
  --creme-2: #efe4c9;
  --petrol: #2f6f6b;
  --petrol-2: #3d8a84;
  --pflaume: #6d4a6f;
  --pflaume-2: #8a5f8a;
  --koralle: #e2694f;
  --koralle-2: #ef8a6f;
  --tinte: #241f2b;
  --tinte-2: #3a3342;
  --papier: #fbf6ea;
  --linie: #241f2b;
  --ok: #2f6f6b;
  --warn: #b06a3a;
  --focus: #e2694f;
  --shadow: rgba(36, 31, 43, 0.28);
  --radius: 4px;
  --hud-h: 48px;
  --dialog-h: clamp(150px, 24vh, 230px);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --t: 180ms;
  --spk-mira: #2f6f6a;
  --spk-plus: #6b3a5c;
  --spk-rolf: #4f7a3a;
  --spk-alex: #d9644a;
  --spk-mara: #2d4a7a;
  --spk-other: #5a5364;
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--petrol) var(--creme-2); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--creme-2); }
::-webkit-scrollbar-thumb { background: var(--petrol); border: 2px solid var(--creme-2); }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--creme);
  color: var(--tinte);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Robuste 100vh-Rückfallebene + 100dvh */
html { height: 100vh; height: 100dvh; }
body { height: 100vh; height: 100dvh; }

button { font-family: var(--font-ui); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 2px solid var(--tinte);
  background: var(--papier);
  color: var(--tinte);
  padding: 10px 16px;
  min-height: 44px;
  min-width: 44px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--tinte);
  transition: transform var(--t) ease, box-shadow var(--t) ease, background var(--t) ease;
  line-height: 1.1;
}
.btn:hover { background: var(--creme-2); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--tinte); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: 2px 2px 0 var(--tinte); }
.btn-primary { background: var(--koralle); color: #fff8f2; border-color: var(--tinte); }
.btn-primary:hover { background: var(--koralle-2); }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: rgba(36,31,43,0.06); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- Startansicht ---------- */
.start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  background: url("../assets/art/empfang.png") center / cover no-repeat var(--creme);
  z-index: 50;
  padding: clamp(16px, 4vw, 48px);
  overflow: hidden;
}
/* Drei freigestellte Figuren, unten verankert, leicht überlappend */
.start-figures {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(72vh, 640px);
  pointer-events: none;
  z-index: 1;
}
.start-figure {
  position: absolute;
  bottom: -2vh;
  height: 100%;
  width: auto;
  object-fit: contain;
  object-position: bottom center;
  user-select: none;
  -webkit-user-drag: none;
}
.start-figure-alex { left: 40%; transform: rotate(-1.5deg); z-index: 1; }
.start-figure-mira { left: 58%; height: 114%; z-index: 2; }
.start-figure-rolf { left: 78%; transform: rotate(1.5deg); z-index: 1; }
.start-inner {
  position: relative;
  z-index: 2;
  width: min(560px, 100%);
  max-width: 560px;
  text-align: left;
  background: var(--papier);
  border: 3px solid var(--tinte);
  border-radius: 2px;
  box-shadow: 6px 6px 0 var(--tinte);
  padding: clamp(20px, 3vw, 32px) clamp(20px, 3vw, 32px);
}
.start-title {
  display: inline-block;
  font-size: clamp(30px, 5.2vw, 52px);
  margin: 0 0 10px;
  line-height: 1.02;
  letter-spacing: -0.015em;
  background: var(--creme);
  border: 3px solid var(--tinte);
  border-radius: 3px;
  box-shadow: 5px 5px 0 var(--tinte);
  padding: 6px 16px;
  transform: rotate(-2deg);
}
.start-sub {
  font-size: 17px;
  color: var(--tinte-2);
  margin: 0 0 22px;
}
.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}
.start-note {
  min-height: 1.2em;
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--warn);
}

/* ---------- Spielfläche ---------- */
.game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--creme);
}

/* Bühne: bildfüllend, Dialog überlagert unten */
.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--creme);
}
.stage-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Hotspot-Ebene: deckt exakt die sichtbare Bühne ab.
   Die Koordinaten werden in JS über denselben object-fit-Ausgleich
   transformiert (siehe js/ui.js -> projectPoint). */
.hotspots {
  position: absolute;
  inset: 0;
  z-index: 5;
}
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hotspot .dot {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(251,246,234,0.92);
  border: 2px solid var(--tinte);
  box-shadow: 0 0 0 3px rgba(226,105,79,0.55);
  transition: transform var(--t) ease;
}
.hotspot .dot::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid var(--koralle);
  animation: hotspot-pulse 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes hotspot-pulse {
  0%   { transform: scale(0.55); opacity: 0.95; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
.hotspot:hover .dot,
.hotspot:focus-visible .dot {
  transform: scale(1.25);
}
.hotspot .label {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--papier);
  color: var(--tinte);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 5px 10px;
  border: 2px solid var(--tinte);
  border-radius: 3px;
  box-shadow: 2px 2px 0 var(--tinte);
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
}

/* Laptop-Bildschirm in der Szene „zuhause": perspektivisch auf die
   Bildschirmfläche des Raumbilds gelegt (matrix3d aus js/ui.js).
   Zeigt den aktuellen Nachrichtenstand; fängt keine Klicks ab. */
.laptop-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 420px;
  height: 300px;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 3;
  background: var(--petrol);
  color: var(--creme);
  border: 2px solid var(--tinte);
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(36,31,43,0.55);
  font-family: var(--font-ui);
  font-size: 10px;
  line-height: 1.35;
  padding: 6px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.laptop-screen .lp-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 20px;
  border-bottom: 1px solid rgba(244,236,216,0.4);
  padding-bottom: 3px;
}
.laptop-screen .lp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--koralle);
  animation: lp-blink 1.1s steps(2, start) infinite;
  flex: 0 0 auto;
}
@keyframes lp-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}
.laptop-screen .lp-sub { font-size: 22px; opacity: 0.85; }
.laptop-screen .lp-body { font-size: 22px; overflow: hidden; }
.laptop-screen .lp-red { color: #ffb3a3; font-weight: 700; }
.laptop-screen .lp-ok { color: #bfe8d9; font-weight: 700; }

/* Freigestelltes Figuren-Sprite: ohne Rahmen/Hintergrund, unten verankert,
   hinter der Dialogbox. Kurze Einblendung bei jedem Bildwechsel. */
.portrait {
  position: absolute;
  left: 62%;
  bottom: 10vh;
  transform: translateX(-50%);
  height: min(62vh, calc(100dvh - var(--hud-h) - 10vh));
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
}
.portrait.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.portrait-img {
  height: 100%;
  width: auto;
  display: block;
  object-fit: contain;
  object-position: bottom center;
}

/* ---------- HUD oben (schwebt über der Bühne) ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: transparent;
  border-bottom: none;
}
.hud-place {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  color: var(--tinte);
  letter-spacing: 0.01em;
  background: rgba(250,244,230,0.93);
  border: 2px solid var(--tinte);
  border-radius: 3px;
  box-shadow: 3px 3px 0 var(--tinte);
  padding: 5px 12px;
}
.hud-right { display: flex; gap: 8px; }
.hud-btn {
  appearance: none;
  border: 2px solid var(--tinte);
  background: rgba(250,244,230,0.93);
  color: var(--tinte);
  min-height: 34px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--tinte);
  transition: background var(--t) ease, transform var(--t) ease, box-shadow var(--t) ease;
}
.hud-btn:hover { background: var(--creme-2); }
.hud-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--tinte); }
.hud-btn[aria-pressed="true"] { background: var(--petrol); color: #fff; }
.hud-label { line-height: 1; }

/* ---------- Dialogbox: Overlay IM Bild, unten zentriert ---------- */
.dialog {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 15;
  width: min(1100px, calc(100% - 32px));
  max-height: 62dvh;
  background: rgba(250,244,230,0.97);
  border: 3px solid var(--tinte);
  border-radius: 6px;
  box-shadow: 8px 8px 0 var(--tinte);
  display: flex;
  flex-direction: column;
  padding: 14px 22px 12px;
  gap: 8px;
  cursor: pointer;
}
.dialog-head {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 2px;
}
.dialog-speaker {
  display: inline-block;
  background: var(--spk-other);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 3px 3px 0 0;
  border: 2px solid var(--tinte);
  border-bottom: none;
  margin-top: -22px;
  flex: 0 0 auto;
}
/* Sprecher-Reiter: Farbe je data-speaker (MIRA/Alex Plus/Rolf/Alex/Mara) */
.dialog[data-speaker="MIRA"] .dialog-speaker { background: var(--spk-mira); }
.dialog[data-speaker="Alex Plus"] .dialog-speaker { background: var(--spk-plus); }
.dialog[data-speaker="Rolf"] .dialog-speaker { background: var(--spk-rolf); }
.dialog[data-speaker="Alex"] .dialog-speaker { background: var(--spk-alex); }
.dialog[data-speaker="Mara"] .dialog-speaker { background: var(--spk-mara); }
.dialog[data-speaker="Erzähler"] .dialog-speaker,
.dialog[data-speaker="System"] .dialog-speaker,
.dialog[data-speaker="Gesendete Nachricht"] .dialog-speaker { display: none; }
.dialog[data-speaker="Erzähler"] .dialog-text { font-style: italic; }
.dialog-speaker:empty { display: none; }
.dialog-head-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-replay {
  appearance: none;
  border: 2px solid var(--tinte);
  background: var(--creme-2);
  color: var(--tinte);
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.btn-replay:hover { background: var(--koralle-2); color: #fff; }
.dialog-advance {
  color: var(--tinte);
  font-size: 14px;
  line-height: 1;
  animation: dialog-blink 1.1s steps(2, start) infinite;
}
@keyframes dialog-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}
.dialog-text {
  margin: 0;
  font-size: clamp(1.1rem, 1.55vw, 1.5rem);
  line-height: 1.45;
  color: var(--tinte);
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: -2px;
}
.dialog-actions .btn {
  font-size: 13px;
  padding: 5px 12px;
  min-height: 30px;
  box-shadow: 1px 1px 0 var(--tinte);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dialog-h) + 14px);
  transform: translateX(-50%) translateY(8px);
  background: var(--tinte);
  color: var(--papier);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 3px;
  box-shadow: 0 8px 24px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) ease, transform var(--t) ease;
  z-index: 40;
  max-width: min(90vw, 520px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Overlays (native dialog) ---------- */
.overlay {
  border: 3px solid var(--tinte);
  border-radius: 6px;
  box-shadow: 8px 8px 0 var(--tinte);
  background: var(--papier);
  color: var(--tinte);
  padding: 0;
  width: min(92vw, 720px);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.overlay::backdrop {
  background: rgba(36,31,43,0.55);
  backdrop-filter: blur(2px);
}
.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
  border-bottom: 2px solid rgba(36,31,43,0.14);
}
.overlay-title {
  margin: 0;
  font-size: clamp(19px, 2.2vw, 24px);
  line-height: 1.15;
}
.overlay-source {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--tinte-2);
  font-family: var(--font-ui);
}
.overlay-close {
  appearance: none;
  border: 2px solid var(--tinte);
  background: var(--creme-2);
  color: var(--tinte);
  width: 44px;
  height: 44px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  flex: 0 0 auto;
}
.overlay-close:hover { background: var(--koralle); color: #fff; }
.overlay-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px 18px;
  border-top: 2px solid rgba(36,31,43,0.14);
  justify-content: flex-end;
}

/* Dokument */
.doc-body {
  padding: 14px 18px;
  overflow-y: auto;
  max-height: 52vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.doc-passage {
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-left: 6px solid var(--petrol);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.5;
}
.doc-passage .doc-passage-id {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--tinte-2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Formular */
.form-body {
  padding: 14px 18px;
  overflow-y: auto;
  max-height: 52vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background var(--t) ease, border-color var(--t) ease;
}
.form-option:hover { background: var(--creme-2); }
.form-option.selected { border-color: var(--koralle); background: #fbe6dd; }
.form-option input { width: 20px; height: 20px; accent-color: var(--koralle); }
.form-option label { font-size: 16px; cursor: pointer; }

/* Challenge: Kreuzverhör */
.overlay-challenge { width: min(94vw, 1100px); max-height: min(88vh, 760px); }
.overlay-challenge::backdrop { background: rgba(36,31,43,0.42); backdrop-filter: none; }
.ch-frame { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.ch-frame > .overlay-head, .ch-feedback, .ch-hint, .ch-frame > .overlay-foot,
.ch-frame > .overlay-tools { flex-shrink: 0; }
.ch-head { padding-bottom: 6px; }
.ch-kicker {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--tinte);
}
.ch-round {
  margin: 6px 0 0;
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--petrol);
  color: #fff;
  border: 2px solid var(--tinte);
  border-radius: 3px;
  padding: 3px 10px;
}
.ch-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  padding: 14px 18px;
  min-height: 0;
  flex: 1 1 auto;
}
.ch-col { overflow-y: auto; min-height: 0; max-height: none; padding: 3px; scrollbar-gutter: stable; }
.ch-col-title {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--papier);
  padding: 4px 0 8px;
  margin: 0 0 8px;
  font-size: 14px;
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tinte-2);
}
.ch-list { display: flex; flex-direction: column; gap: 10px; }
/* Behauptungen als Sprechblasen (Creme, Tintenkontur, Zipfel) */
.ch-statement {
  position: relative;
  border: 2px solid var(--tinte);
  background: var(--creme);
  border-radius: 10px 10px 10px 2px;
  padding: 12px 16px;
  font-size: 17px;
  line-height: 1.4;
  cursor: pointer;
  transition: background var(--t) ease, border-color var(--t) ease;
  text-align: left;
  width: 100%;
  font-family: var(--font);
}
.ch-statement::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 16px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 10px solid var(--tinte);
}
.ch-statement::after {
  content: "";
  position: absolute;
  left: -7px;
  top: 18px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid var(--creme);
}
.ch-statement:hover { background: var(--creme-2); }
.ch-statement.selected {
  border-color: var(--koralle);
  background: #fbe6dd;
  box-shadow: 2px 2px 0 var(--koralle);
}
.ch-statement.selected::after { border-right-color: #fbe6dd; }
/* Beweiskarten: Titel-Reiter + Passagen */
.ch-card {
  border: 2px solid var(--tinte);
  background: var(--creme);
  border-radius: 4px;
  overflow: hidden;
}
.ch-card-tab {
  display: inline-block;
  background: var(--tinte);
  color: var(--papier);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 12px;
  margin: 8px 8px 0;
  border-radius: 3px 3px 0 0;
  border: 2px solid var(--tinte);
  border-bottom: none;
}
.ch-card-passages { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.ch-passage {
  border: 2px solid var(--tinte);
  background: var(--papier);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.4;
  cursor: pointer;
  transition: background var(--t) ease, border-color var(--t) ease;
  text-align: left;
  width: 100%;
  font-family: var(--font);
}
.ch-passage:hover { background: var(--creme-2); }
.ch-passage.selected {
  border-color: var(--koralle);
  background: #fbe6dd;
  box-shadow: 2px 2px 0 var(--koralle);
}
.ch-hint {
  margin: 0 18px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--tinte-2);
  background: var(--creme-2);
  border: 2px solid var(--tinte);
  border-radius: 4px;
}
.ch-feedback {
  margin: 10px 18px 0;
  padding: 10px 14px;
  border-radius: 4px;
  background: #f3e2d3;
  border: 2px solid var(--warn);
  font-size: 15px;
  line-height: 1.45;
  min-height: 1.2em;
}
.ch-feedback:empty { display: none; }
/* Falscher Beweis: Overlay wackelt kurz */
@keyframes ch-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.ch-frame.shake { animation: ch-shake 300ms ease; }
/* Stempel „EINSPRUCH!" über dem ganzen Bildschirm */
.stamp-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stamp {
  font-family: var(--font-ui);
  font-size: clamp(56px, 12vw, 150px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--koralle);
  border: 8px solid var(--koralle);
  border-radius: 10px;
  padding: 10px 34px;
  transform: rotate(-12deg) scale(1.6);
  box-shadow: 0 0 0 4px rgba(36,31,43,0.9) inset, 0 14px 40px rgba(36,31,43,0.35);
  background: rgba(251,246,234,0.88);
  animation: stamp-in 1100ms cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}
@keyframes stamp-in {
  0%   { opacity: 0; transform: rotate(-12deg) scale(1.6); }
  55%  { opacity: 1; transform: rotate(-12deg) scale(1.0); }
  70%  { transform: rotate(-10deg) scale(1.0); }
  82%  { transform: rotate(-13deg) scale(1.0); }
  100% { opacity: 1; transform: rotate(-12deg) scale(1.0); }
}

/* Diagnose */
.overlay-diagnostic { width: min(94vw, 1000px); max-height: 92dvh; }
.diag-frame { display: grid; grid-template-columns: 1fr 1fr; }
.diag-frame > .overlay-head, .diag-results, .diag-frame > .overlay-foot,
.diag-frame > .overlay-tools, .diag-frame > .overlay-notice { grid-column: 1 / -1; }
.diag-controls, .diag-tests {
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diag-controls { border-bottom: 2px solid rgba(36,31,43,0.12); }
.diag-tests { border-bottom: 2px solid rgba(36,31,43,0.12); }
.diag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  padding: 10px 12px;
}
.diag-row .diag-label { font-size: 16px; font-weight: 600; }
.diag-row .diag-desc { font-size: 13px; color: var(--tinte-2); margin-top: 2px; font-family: var(--font-ui); }
.switch {
  appearance: none;
  border: 2px solid var(--tinte);
  background: var(--creme-2);
  width: 58px;
  height: 44px;
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background var(--t) ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tinte);
  transition: transform var(--t) ease;
}
.switch[aria-checked="true"] { background: var(--petrol); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch[aria-checked="true"]::after { transform: translateX(26px); background: #fff; }
.diag-status {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  border: 2px solid var(--tinte);
}
.diag-status.on { background: var(--petrol); color: #fff; }
.diag-status.off { background: var(--creme-2); color: var(--tinte); }
.diag-results {
  padding: 12px 18px;
  overflow-y: auto;
  max-height: 32vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.diag-result {
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-left: 6px solid var(--petrol);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.45;
}
.diag-result .diag-result-head {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--tinte-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

/* Choice: Gesprächsentscheidung am unteren Bildschirmbereich,
   ohne dunkles/verwischtes Backdrop. Raum und Figur bleiben sichtbar. */
.overlay-choice {
  position: fixed;
  left: 50%;
  right: auto;
  top: auto;
  bottom: 0;
  transform: translateX(-50%);
  width: min(1100px, 96vw);
  max-height: 42vh;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -10px 30px var(--shadow);
}
.overlay-choice::backdrop {
  background: transparent;
  backdrop-filter: none;
}
.overlay-choice .overlay-head {
  padding: 10px 16px 8px;
}
.overlay-choice .overlay-title { font-size: clamp(17px, 1.8vw, 20px); }
.overlay-choice .overlay-source { font-size: 13px; margin-top: 2px; }
.choice-options {
  padding: 10px 16px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  overflow-y: auto;
  max-height: calc(42vh - 70px);
}
.choice-option {
  border: 2px solid var(--tinte);
  background: var(--creme);
  border-radius: 4px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: var(--font);
  transition: background var(--t) ease, transform var(--t) ease;
}
.choice-option:hover { background: var(--creme-2); transform: translateX(2px); }
.choice-option .choice-label { font-size: 15px; font-weight: 700; }
.choice-option .choice-desc { font-size: 13px; color: var(--tinte-2); margin-top: 4px; line-height: 1.35; }

/* Transfer */
.tr-status {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tr-step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
}
.tr-step .tr-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--creme-2); border: 2px solid var(--tinte); flex: 0 0 auto;
}
.tr-step.done .tr-dot { background: var(--petrol); }
.tr-step.active .tr-dot { background: var(--koralle); }
.tr-actions { padding: 0 18px 14px; display: flex; flex-wrap: wrap; gap: 10px; }

/* Nachricht */
.msg-body {
  padding: 14px 18px;
  overflow-y: auto;
  max-height: 56vh;
}
.msg-text {
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* Ende */
.done-frame { text-align: center; padding: 10px 18px 0; }
.done-text {
  font-size: 17px;
  line-height: 1.5;
  color: var(--tinte-2);
  margin: 10px auto 18px;
  max-width: 46ch;
}

/* Notizen */
.notes-frame { display: flex; flex-direction: column; max-height: calc(min(86vh, 720px) - 6px); }
.notes-frame > .overlay-head, .notes-frame > .overlay-foot { flex-shrink: 0; }
.notes-body {
  padding: 14px 18px;
  overflow-y: auto;
  max-height: 60vh;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.notes-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tinte-2);
}
.notes-list { display: flex; flex-direction: column; gap: 6px; }
.notes-item {
  background: var(--creme);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 15px;
  line-height: 1.4;
}
.notes-empty { font-size: 14px; color: var(--tinte-2); font-style: italic; }

/* Menü */
.menu-list {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.menu-list .btn { text-align: left; }

/* Bestätigung */
.confirm-frame { padding: 6px 18px 0; }
.confirm-text {
  font-size: 16px;
  line-height: 1.5;
  margin: 10px 0 16px;
  color: var(--tinte);
}

/* Credits */
.credits-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.credits-body p { margin: 0; font-size: 15px; line-height: 1.5; }
.credits-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--creme-2); padding: 1px 5px; border-radius: 3px; }

/* ---------- Schmale Displays / kleine Höhe ---------- */
@media (max-width: 768px) {
  :root { --dialog-h: clamp(140px, 30vh, 200px); }
  .ch-cols { display: block; overflow-y: auto; min-height: 100px; }
  .ch-col { max-height: none; overflow: visible; }
  .start-figures { height: 52vh; }
  .start-figure-mira { height: 100%; }
  .laptop-screen { display: none; }
  .ch-col + .ch-col { margin-top: 12px; }
  .ch-frame { max-height: calc(100dvh - 22px); }
  .diag-frame { display: flex; flex-direction: column; }
  .diag-results { max-height: none; overflow: visible; }
  .diag-frame > .overlay-foot { position: sticky; bottom: 61px; z-index: 2; background: var(--papier); }
  .diag-frame > .overlay-foot:empty { display: none; }
  .diag-frame > .overlay-tools { position: sticky; bottom: 0; z-index: 2; background: var(--papier); }
  .diag-row { flex-wrap: wrap; }
  .diag-row > div:first-child { flex: 1 1 100%; }
  .diag-status { margin-right: auto; }
  .portrait {
    left: 62%;
    height: 48vh;
    bottom: 8vh;
  }
  .hud { padding: 0 8px; }
  .hud-place { font-size: 12px; padding: 4px 9px; }
  .hud-btn { min-height: 32px; padding: 5px 10px; font-size: 12px; }
  .dialog {
    width: calc(100% - 16px);
    bottom: 8px;
    padding: 12px 12px 10px;
  }
  .dialog-text { font-size: 17px; }
  .overlay { width: calc(100vw - 16px); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .overlay-choice { width: 96vw; }
}
@media (max-width: 700px) {
  .start-figure-alex, .start-figure-rolf { display: none; }
  .start-figure-mira { left: 50%; transform: translateX(-50%); }
}
@media (max-width: 420px) {
  :root { --dialog-h: clamp(130px, 34vh, 180px); }
  .start-screen { align-items: flex-end; justify-content: center; padding: 16px; }
  .start-inner { padding: 24px 18px; }
  .start-actions { flex-direction: column; }
  .start-actions .btn { width: 100%; }
  .dialog-actions { gap: 8px; }
  .dialog-actions .btn { font-size: 13px; padding: 5px 10px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  :root { --dialog-h: clamp(120px, 26vh, 160px); --hud-h: 44px; }
  .dialog-text { font-size: 16px; }
  .portrait { height: 42vh; bottom: 6vh; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .btn:active { transform: none; }
}

/* Mobile: responsive Spielaktionen für abgeschnittene Ziele.
   Von der UI als .scene-actions-mobile erzeugt; Basisstil hier. */
.scene-actions-mobile {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: var(--papier);
  border-top: 2px solid var(--tinte);
  max-height: 25dvh;
  overflow-y: auto;
  flex-shrink: 0;
}
.scene-actions-mobile .btn {
  flex: 0 1 auto;
  min-height: 44px;
  font-size: 14px;
  padding: 8px 10px;
}

/* Integration: author display rules must respect native hidden. */
[hidden] { display: none !important; }

/* Secondary controls remain reachable while a native dialog is open. */
.overlay-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 18px;
  border-top: 1px solid rgba(36,31,43,.18);
}
.overlay-tools .btn { font-size: 14px; box-shadow: none; }
.overlay-notice { margin: 0; padding: 10px 18px; color: var(--tinte); background: var(--creme-2); }

/* ---------- P5a: Wartungsterminal ---------- */
#dlg-diagnostic .diag-frame,
#dlg-transfer .tr-frame {
  border: 14px solid var(--petrol);
  border-radius: 18px;
  box-shadow: 0 0 0 3px var(--tinte), 6px 6px 0 var(--tinte);
  background-color: #10302d;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 4px);
  color: #d8f3e6;
  font-family: ui-monospace, "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
}
#dlg-diagnostic .diag-frame {
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
#dlg-diagnostic .overlay-head,
#dlg-diagnostic .diag-controls,
#dlg-diagnostic .diag-tests,
#dlg-diagnostic .overlay-foot {
  flex-shrink: 0;
}
#dlg-diagnostic .diag-frame *,
#dlg-transfer .tr-frame * {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}
#dlg-diagnostic .overlay-head,
#dlg-transfer .overlay-head {
  background: transparent;
  border-bottom: 1px dashed #2f6f6a;
  padding: 14px 18px 12px;
}
#dlg-diagnostic .overlay-title,
#dlg-transfer .overlay-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ff0cf;
  font-size: 20px;
  margin: 18px 0 8px;
}
#dlg-diagnostic .overlay-title::before,
#dlg-transfer .overlay-title::before {
  content: "NEBENBEI · WARTUNG";
  display: block;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--koralle);
  margin-bottom: 6px;
}
#dlg-diagnostic .overlay-source,
#dlg-transfer .overlay-source {
  color: #bfe3d4;
}
#dlg-diagnostic .diag-controls,
#dlg-diagnostic .diag-tests,
#dlg-diagnostic .diag-results,
#dlg-transfer .tr-status,
#dlg-transfer .tr-actions {
  background: transparent;
  border-color: #2f6f6a;
  padding: 12px 18px;
}
#dlg-diagnostic .diag-results {
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  max-height: 26vh;
}
#dlg-diagnostic .diag-row,
#dlg-transfer .tr-step {
  background: transparent;
  border-bottom: 1px dashed #2f6f6a;
  color: #d8f3e6;
  padding: 10px 0;
}
#dlg-diagnostic .diag-row:last-child,
#dlg-transfer .tr-step:last-child {
  border-bottom: none;
}
#dlg-diagnostic .diag-label,
#dlg-transfer .tr-step {
  color: #d8f3e6;
}
#dlg-diagnostic .diag-desc {
  color: #9cc9b9;
}
#dlg-diagnostic .diag-status {
  color: #9ff0cf;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
}
#dlg-diagnostic .diag-status.off {
  background: #3a2a33;
  color: #ffb3a3;
}
#dlg-diagnostic .diag-status.on {
  background: #1f6f55;
  color: #e8fff4;
}
#dlg-diagnostic .switch,
#dlg-diagnostic .diag-tests .btn,
#dlg-transfer .tr-actions .btn,
#dlg-diagnostic .btn,
#dlg-transfer .btn {
  background: #1d4d48;
  border: 2px solid #9ff0cf;
  color: #e8fff4;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 0 #0a1f1d;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
#dlg-diagnostic .switch:hover,
#dlg-diagnostic .diag-tests .btn:hover,
#dlg-transfer .tr-actions .btn:hover,
#dlg-diagnostic .btn:hover,
#dlg-transfer .btn:hover {
  background: #27655f;
}
#dlg-diagnostic .switch:focus-visible,
#dlg-diagnostic .diag-tests .btn:focus-visible,
#dlg-transfer .tr-actions .btn:focus-visible,
#dlg-diagnostic .btn:focus-visible,
#dlg-transfer .btn:focus-visible {
  outline: 3px solid var(--koralle);
  outline-offset: 2px;
}
#dlg-diagnostic .btn-primary,
#dlg-transfer .btn-primary {
  background: var(--koralle);
  color: var(--tinte);
  border-color: #ffd7c9;
}
#dlg-diagnostic .btn-primary:hover,
#dlg-transfer .btn-primary:hover {
  background: #f4917a;
}
#dlg-diagnostic .diag-result {
  background: transparent;
  border: 1px dashed #2f6f6a;
  color: #d8f3e6;
  padding: 10px 12px;
  margin-bottom: 8px;
}
#dlg-diagnostic .diag-result::before {
  content: "> ";
  color: #9ff0cf;
}
#dlg-diagnostic .diag-result-head {
  color: #9ff0cf;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
}
#dlg-diagnostic .diag-result:last-child {
  animation: p5a-blink 600ms ease-out;
}
@keyframes p5a-blink {
  0% { background: #2f6f6a; }
  100% { background: transparent; }
}
#dlg-transfer .tr-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #555;
  border: 2px solid #9ff0cf;
  margin-right: 10px;
  vertical-align: middle;
}
#dlg-transfer .tr-step.done .tr-dot {
  background: #6fe3a8;
  box-shadow: 0 0 8px rgba(111,227,168,0.7);
}
#dlg-diagnostic .overlay-foot,
#dlg-transfer .overlay-foot {
  background: transparent;
  border-top: 1px dashed #2f6f6a;
  padding: 12px 18px;
}
#dlg-diagnostic .overlay-foot .btn,
#dlg-transfer .overlay-foot .btn {
  background: #1d4d48;
  border: 2px solid #9ff0cf;
  color: #e8fff4;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 0 #0a1f1d;
}
@media (max-width: 700px) {
  #dlg-diagnostic .diag-frame,
  #dlg-transfer .tr-frame {
    border-width: 8px;
    border-radius: 12px;
    box-shadow: 0 0 0 2px var(--tinte), 4px 4px 0 var(--tinte);
  }
}

/* ---------- P5b: Fenster, Papier, Endkarte ---------- */

/* 1) #dlg-form und #dlg-message: Fenster eines Retro-Mailprogramms auf Alex' Laptop */
#dlg-form .form-frame,
#dlg-message .msg-frame {
  display: flex;
  flex-direction: column;
  max-height: calc(min(86vh, 720px) - 6px);
  background: var(--creme);
  border: 3px solid var(--tinte);
  border-radius: 6px;
  box-shadow: 6px 6px 0 var(--tinte);
  overflow: hidden;
}

#dlg-form .overlay-head,
#dlg-message .overlay-head {
  position: relative;
  align-items: center;
  padding: 12px 18px 12px 58px;
  background: var(--petrol);
  color: var(--creme);
  border-bottom: 3px solid var(--tinte);
}

/* Drei kleine Fensterknöpfe (Koralle, Creme, Pflaume) links in der Titelleiste */
#dlg-form .overlay-head::before,
#dlg-message .overlay-head::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--koralle);
  box-shadow:
    17px 0 0 var(--creme),
    34px 0 0 var(--pflaume);
}

#dlg-form .overlay-title,
#dlg-message .overlay-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  color: var(--creme);
}

#dlg-form .overlay-source {
  margin: 3px 0 0;
  font-size: 13px;
  color: rgba(244, 236, 216, 0.82);
}

#dlg-form .overlay-close,
#dlg-message .overlay-close {
  background: var(--creme);
  color: var(--tinte);
  border-color: var(--tinte);
}

/* Radiooptionen als große klickbare Zeilen */
#dlg-form .form-body,
#dlg-message .msg-body {
  padding: 16px 18px;
  flex: 1 1 auto;
  min-height: 0;
}

#dlg-form .form-option {
  padding: 14px 16px;
  background: var(--papier);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
}
#dlg-form .form-option:hover { background: var(--creme-2); }
#dlg-form .form-option.selected {
  border-color: var(--koralle);
  background: #fbe6dd;
}
#dlg-form .form-option input {
  width: 22px;
  height: 22px;
  accent-color: var(--koralle);
  flex: 0 0 auto;
}
#dlg-form .form-option span { font-size: 16px; }

#dlg-message .msg-text {
  background: var(--papier);
  border: 2px solid var(--tinte);
  border-radius: 4px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}

#dlg-form .overlay-foot,
#dlg-message .overlay-foot {
  padding: 14px 18px 18px;
  border-top: 2px solid rgba(36, 31, 43, 0.14);
  background: var(--creme);
}

#dlg-form .btn-primary,
#dlg-message .btn-primary {
  background: var(--koralle);
  color: var(--tinte);
  border: 2px solid var(--tinte);
  box-shadow: 2px 2px 0 var(--tinte);
}
#dlg-form .btn-primary:hover,
#dlg-message .btn-primary:hover { background: var(--koralle-2); }

/* 2) #dlg-document: ausgedrucktes Blatt Papier */
#dlg-document .doc-frame {
  background-color: #fbf6ea;
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0 27px,
    rgba(36, 31, 43, 0.05) 27px 28px
  );
  border: 2px solid var(--tinte);
  border-radius: 3px;
  box-shadow: 8px 10px 0 rgba(36, 31, 43, 0.35);
  transform: rotate(-0.8deg);
}

#dlg-document .overlay-head {
  padding: 22px 26px 12px;
  border-bottom: 1px solid rgba(36, 31, 43, 0.35);
}

#dlg-document .overlay-title {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.1;
  color: var(--tinte);
}

#dlg-document .overlay-source {
  margin: 6px 0 0;
  font-size: 14px;
  font-style: italic;
  color: var(--tinte-2);
}

#dlg-document .overlay-close {
  background: var(--papier);
  border-color: var(--tinte);
}

#dlg-document .doc-body {
  padding: 18px 26px;
  max-height: 56vh;
}

/* Passagen: ohne Kästchen-Optik, nur Abstand + feine Linie links in Koralle */
#dlg-document .doc-passage {
  background: transparent;
  border: none;
  border-radius: 0;
  border-left: 2px solid var(--koralle);
  padding: 2px 0 2px 16px;
  margin: 0 0 18px;
}
#dlg-document .doc-passage p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--tinte);
}
#dlg-document .doc-passage:last-child { margin-bottom: 0; }

#dlg-document .overlay-foot {
  padding: 14px 26px 20px;
  border-top: 1px solid rgba(36, 31, 43, 0.22);
}

/* 3) #dlg-done: letzte Seite eines Comics */
#dlg-done .done-frame {
  text-align: center;
  padding: 28px 22px 0;
}

#dlg-done .overlay-title {
  display: inline-block;
  margin: 0 auto 20px;
  padding: 14px 30px;
  font-family: var(--font);
  font-size: clamp(34px, 5vw, 42px);
  line-height: 1.05;
  color: var(--tinte);
  background: var(--creme);
  border: 3px solid var(--tinte);
  border-radius: 6px;
  box-shadow: 5px 5px 0 var(--koralle);
  transform: rotate(-2deg);
}

#dlg-done .done-text {
  font-size: 18px;
  line-height: 1.55;
  color: var(--tinte-2);
  margin: 0 auto 22px;
  max-width: 46ch;
}

#dlg-done .overlay-foot {
  justify-content: center;
  padding: 0 18px 22px;
  border-top: none;
}

/* 4) Lesbarkeit: Fokus sichtbar, ≥16px im Inhalt */
#dlg-form .form-option:focus-visible,
#dlg-form .form-option input:focus-visible,
#dlg-message .msg-text:focus-visible,
#dlg-document .doc-passage:focus-visible {
  outline: 3px solid var(--koralle);
  outline-offset: 2px;
}
#dlg-form .overlay-close:focus-visible,
#dlg-message .overlay-close:focus-visible,
#dlg-document .overlay-close:focus-visible,
#dlg-form .btn:focus-visible,
#dlg-message .btn:focus-visible,
#dlg-document .btn:focus-visible,
#dlg-done .btn:focus-visible {
  outline: 3px solid var(--koralle);
  outline-offset: 2px;
}

/* Auf ≤700px: Drehungen weglassen */
@media (max-width: 700px) {
  #dlg-document .doc-frame { transform: none; }
  #dlg-done .overlay-title { transform: none; }
}

/* P6a: Dokumente als Reiter im Kreuzverhör */
.ch-doc-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin-bottom: 6px; position: sticky; top: 0; z-index: 2; background: var(--creme); padding: 4px 0 8px; }
.ch-doc-tab {
  border: 2px solid var(--tinte);
  background: var(--creme);
  color: var(--tinte);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}
.ch-doc-tab:hover { background: var(--creme-2); }
.ch-doc-tab.active {
  background: var(--tinte);
  color: var(--creme);
}
.ch-doc-tab:focus-visible {
  outline: 3px solid var(--koralle);
  outline-offset: 2px;
}
#dlg-challenge .overlay-title { font-size: 20px; margin: 2px 0; }
#dlg-challenge .overlay-tools { padding-top: 4px; padding-bottom: 4px; }
#dlg-challenge .overlay-foot { padding-top: 8px; padding-bottom: 8px; }
.ch-selection { margin: 0 18px; padding: 8px 12px; border: 2px dashed var(--tinte); border-radius: 4px; font-size: 15px; background: var(--papier); }

.ch-feedback.flash { animation: ch-flash 600ms ease; }
@keyframes ch-flash { 0% { background: #f7c9bb; } 100% { background: inherit; } }

/* P11 · Wartungsterminal (Diagnose): unübersehbarer Weiter-Schritt */
#dlg-diagnostic .diag-continue { display:block; width:100%; margin:10px 0; font-size:18px; background: var(--koralle); color: var(--tinte); border:3px solid var(--tinte); animation: diag-pulse 1.4s ease-in-out infinite; }
@keyframes diag-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(233,106,80,0.7); } 50% { box-shadow: 0 0 0 8px rgba(233,106,80,0); } }
#dlg-diagnostic .diag-done { color:#9ff0cf; font-weight:700; }

/* P12 · Wartungsterminal zweispaltig: Testergebnisse immer sichtbar */
@media (min-width: 900px) {
  #dlg-diagnostic .diag-frame {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    column-gap: 16px;
    max-height: calc(100vh - 24px);
  }
  #dlg-diagnostic .diag-frame > .overlay-head {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  #dlg-diagnostic .diag-controls {
    grid-column: 1;
    grid-row: 2;
    overflow-y: auto;
    min-height: 0;
  }
  #dlg-diagnostic .diag-tests {
    grid-column: 1;
    grid-row: 3;
  }
  #dlg-diagnostic .diag-results {
    grid-column: 2;
    grid-row: 2 / 4;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
  }
  #dlg-diagnostic .diag-frame > .overlay-foot,
  #dlg-diagnostic .diag-frame > .overlay-tools {
    grid-column: 1 / -1;
  }
}

/* P13 · Wartungsterminal: je Einstellung eine Karte mit Schalter, Test und Vorher/Nachher */
#dlg-diagnostic .diag-pair { border: 2px solid #2f6f6a; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: rgba(0,0,0,0.12); }
#dlg-diagnostic .diag-pair-head { display:flex; align-items:center; gap:10px; justify-content:space-between; font-size:16px; font-weight:700; }
#dlg-diagnostic .diag-pair-test { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:8px; }
#dlg-diagnostic .diag-compare { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:8px; }
#dlg-diagnostic .diag-cmp { border:1px dashed #2f6f6a; padding:6px 8px; font-size:14px; min-height:44px; }
#dlg-diagnostic .diag-cmp strong { display:block; font-size:12px; color:#9ff0cf; letter-spacing:0.05em; }
#dlg-diagnostic .diag-tests[hidden] { display:none !important; }
@media (min-width: 900px) {
  #dlg-diagnostic .diag-frame { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}

/* P14 · Wartungsterminal: beide Karten nebeneinander */
@media (min-width: 900px) {
  #dlg-diagnostic .diag-frame { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  #dlg-diagnostic .diag-controls { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; overflow-y: auto; }
  #dlg-diagnostic .diag-controls .diag-continue { grid-column: 1 / -1; }
  #dlg-diagnostic .diag-pair { margin-bottom: 0; }
  #dlg-diagnostic .diag-results { display: none; }
  #dlg-diagnostic .diag-tests { display: none; }
  #dlg-diagnostic .diag-frame > .overlay-foot, #dlg-diagnostic .diag-frame > .overlay-tools { grid-column: 1; }
}

/* P18 · Schmale Bildschirme (Smartphone, 390×844): Kreuzverhör und Wartungsterminal reparieren.
   Auf schmalen Bildschirmen scrollt der ganze Dialog, nicht innere Spalten. */
@media (max-width: 899px) {
  #dlg-challenge, #dlg-diagnostic { overflow-y: auto; max-height: 100vh; }
  #dlg-challenge .ch-frame { max-height: none; }
  #dlg-challenge .ch-cols { display: block; overflow: visible; flex: none; min-height: 0; }
  #dlg-challenge .ch-col { max-height: none; overflow: visible; }
  #dlg-diagnostic .diag-frame { display: block; max-height: none; height: auto; overflow: visible; }
  #dlg-diagnostic .diag-controls { display: block; overflow: visible; max-height: none; }
  #dlg-diagnostic .diag-results { max-height: none; overflow: visible; }
  #dlg-diagnostic .diag-pair-head { flex-wrap: wrap; }
  #dlg-diagnostic .diag-compare { grid-template-columns: 1fr; }
}

/* P19 · Kreuzverhör: MIRA-Sprecherbadge in der Feedback-Zeile */
.ch-feedback .ch-who { display:inline-block; background:#2f6f6a; color:#fff; font-size:12px; letter-spacing:0.05em; padding:2px 8px; border-radius:3px; margin-right:6px; }
