/* Selbst gehostete Schriften (OFL, siehe static/fonts/LICENSE.md) – DSGVO: keine Google-Fonts-Anfragen */
@font-face { font-family: "Bungee"; src: url("/static/fonts/bungee-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Rubik"; src: url("/static/fonts/rubik-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Rubik"; src: url("/static/fonts/rubik-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Rubik"; src: url("/static/fonts/rubik-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Rubik"; src: url("/static/fonts/rubik-800.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("/static/fonts/courier-prime-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("/static/fonts/courier-prime-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* Design „Polytox Launch“ (Design-Canvas „Drunk Ragdoll: Polytox Launch – GoToMPU“) */
  --bg: #0e0f2a;
  --bg-deep: #140c22;
  --panel: #221733;
  --panel-2: #2a1e45;
  --line: #4a4060;
  --text: #fff4dc;
  --muted: #bdb3d1;
  --gold: #ffd23f; /* Gelb, Haupt-Akzent */
  --pink: #ff3da5;
  --cyan: #2de2e6;
  --amber: #ffb020;
  --red: #e8392b;
  --stamp: #d7261e;
  --green: #1fa35b;
  --whatsapp: #25d366;
  --navy: #1b2f6b;
  --paper: #f8f5ee;
  --ink: #0e0f2a;
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bungee", Impact, "Arial Black", sans-serif;
  --mono: "Courier Prime", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #06061a;
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

/* Container: Handy vollflächig; Desktop: Hochformat-Karte, im Spiel Querformat-Bühne */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body[data-screen="game"] #app { max-width: none; }
/* Nur echte Desktops (Maus): Handys im Querformat bleiben vollflächig */
@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  body { display: grid; place-items: center; }
  #app {
    height: min(100dvh - 32px, 900px);
    width: calc(min(100dvh - 32px, 900px) * 9 / 16);
    border-radius: 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--line);
  }
  body[data-screen="game"] #app {
    width: min(100vw - 32px, (100dvh - 32px) * 16 / 9);
    height: min(100dvh - 32px, (100vw - 32px) * 9 / 16);
  }
}

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}
#screen-game { padding: 0; overflow: hidden; background: #000; }
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
#game:active { cursor: grabbing; }

/* --- Startbild (Key Visual) --- */
.title-screen { padding: 0; overflow: hidden; background: var(--bg); justify-content: space-between; }
.kv-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.kv-top, .kv-bottom { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
.kv-top { padding: 34px 16px 0; gap: 10px; }
.kv-title {
  margin: 0;
  font: 400 64px/0.95 var(--display);
  color: var(--gold);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink);
  transform: rotate(-3deg);
}
.kv-sub { margin: 0; font: 400 22px var(--display); color: var(--cyan); text-shadow: 0 0 14px rgba(45, 226, 230, 0.7); }
.kv-bottom { padding: 0 20px 16px; gap: 8px; }
.kv-bottom .btn { max-width: 340px; }
.kv-tag { margin: 4px 0 0; font-weight: 800; font-size: 14px; color: var(--text); text-shadow: 0 2px 0 var(--ink); }
.kv-brand { margin: 0; font: 400 14px var(--display); color: #fff; }

/* --- Start --- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 50px; height: 50px; flex: none; }
.brand h1 {
  margin: 0;
  font: 400 28px/1 var(--display);
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--pink);
}
.subtitle {
  margin: 4px 0 0;
  font: 400 13px var(--display);
  color: var(--cyan);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.card {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.hint-text { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.hero { display: flex; gap: 12px; align-items: center; }
.hero-img { width: 96px; height: 96px; border-radius: 14px; flex: none; background: var(--panel); border: 3px solid var(--gold); }
.hero-name { margin: 0; font: 400 17px/1.15 var(--display); color: #fff; overflow-wrap: anywhere; }
.hero-text { margin: 4px 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.hero-points { margin: 0; font-weight: 800; font-size: 14px; color: var(--gold); }
.label {
  display: block;
  margin: 0 0 8px;
  font: 400 14px var(--display);
  text-transform: uppercase;
  color: var(--gold);
}
.input {
  width: 100%;
  font: 500 17px var(--font);
  color: #fff;
  background: var(--panel-2);
  border: 3px solid var(--gold);
  border-radius: 12px;
  padding: 11px 14px;
}
.input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.level-map { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.level-card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 8px 12px;
  cursor: pointer;
}
.level-card:not(:disabled):hover { box-shadow: 0 0 0 3px var(--pink); }
.level-card:disabled { cursor: default; border-color: var(--line); background: var(--bg-deep); color: #9a90b0; }
.level-num {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--ink);
  color: var(--ink);
  font: 400 18px var(--display);
}
.level-card:disabled .level-num { background: var(--line); }
.level-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.level-title { font: 400 14px/1.1 var(--display); }
.level-lineup { font-size: 12px; color: var(--muted); }
.level-meta { font-size: 15px; letter-spacing: 1px; color: var(--gold); white-space: nowrap; }
.level-card:disabled .level-meta { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #9a90b0; }
.star-off { color: #5a4f72; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  font: 800 16px var(--font);
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s, filter 0.15s;
}
.btn svg { flex: none; }
.btn.icon-right { flex-direction: row-reverse; }
.btn:active { transform: translateY(3px); }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary {
  color: var(--ink);
  background: var(--gold);
  border: 4px solid var(--ink);
  box-shadow: 0 6px 0 var(--pink);
  font: 400 18px var(--display);
  letter-spacing: 0.02em;
}
.btn-whatsapp { color: #0b2a17; background: var(--whatsapp); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
.btn-outline { color: var(--gold); background: transparent; border: 3px solid var(--gold); font: 400 16px var(--display); }
.btn-ghost { color: var(--text); background: transparent; border: 3px solid var(--line); }
.btn-big { font-size: 21px; min-height: 60px; }

.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs button {
  flex: 1;
  min-height: 44px;
  font: 800 14px var(--font);
  color: var(--muted);
  background: transparent;
  border: 3px solid var(--line);
  border-radius: 99px;
  padding: 7px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); background: var(--gold); border-color: var(--ink); }
.board-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.board-list li { display: flex; gap: 8px; padding: 7px 2px; border-bottom: 1px dashed var(--line); }
.board-list li:last-child { border-bottom: 0; }
.board-list .rank { width: 28px; color: var(--gold); font-family: var(--display); }
.board-list .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .dist { font-weight: 800; color: #fff; }
.board-list .empty { color: var(--muted); justify-content: center; }

.disclaimer {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  font-size: 11.5px;
  line-height: 1.35;
  text-align: left;
  color: var(--text);
  background: var(--ink);
  border-top: 2px solid var(--line);
}
.warn-icon { display: inline-flex; flex: none; }
.warn-line { display: flex; gap: 6px; align-items: flex-start; }
@media (orientation: landscape) and (max-height: 500px) {
  body[data-screen="game"] .disclaimer { display: none; }
  .hud-box { padding: 4px 9px; }
  .erich-slot { width: 42px; height: 42px; }
}
body[data-screen="game"] .disclaimer { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); font-size: 10px; }

/* --- HUD --- */
.hud { position: absolute; inset: 0; pointer-events: none; padding: 10px; display: flex; flex-direction: column; }
.hud-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.hud-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(14, 15, 42, 0.78);
  border: 2px solid var(--text);
  border-radius: 12px;
  padding: 7px 11px;
}
.hud-level { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cyan); }
.hud-score-row { display: flex; align-items: center; gap: 8px; font: 400 22px var(--display); color: #fff; text-shadow: 2px 2px 0 var(--pink); }
.hud-targets { display: inline-flex; align-items: center; gap: 4px; font: 800 14px var(--font); color: var(--text); text-shadow: none; }
.hud-buttons { display: flex; gap: 6px; pointer-events: auto; }
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 3px solid var(--ink);
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
/* Hinweis: klein, oben unter dem HUD, blendet nach kurzer Zeit aus */
.hud-hint {
  align-self: center;
  max-width: min(92%, 520px);
  margin: 8px 0 0;
  padding: 5px 12px;
  border-radius: 99px;
  color: var(--ink);
  background: var(--amber);
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  font: 400 12px var(--display);
  text-align: center;
  opacity: 0.95;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.hud-hint.fade { opacity: 0; transform: translateY(-6px); }
.hud-queue { display: flex; gap: 8px; pointer-events: auto; margin-top: auto; }

.erich-slot {
  position: relative;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 12px;
  border: 3px solid var(--sub, #fff);
  background: var(--panel);
  overflow: visible;
  cursor: pointer;
}
.erich-slot img { width: 100%; height: 100%; border-radius: 9px; }
.erich-slot span {
  position: absolute;
  right: -8px;
  bottom: -8px;
  display: flex;
}
.erich-slot.current { box-shadow: 0 0 0 3px #fff; transform: scale(1.12); }
.erich-slot:disabled { cursor: default; }
.erich-slot:not(:disabled):hover { border-color: #fff; }

/* --- Overlays / Comic --- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(14, 15, 42, 0.72);
  overflow-y: auto;
}
.comic {
  width: min(100%, 460px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--text);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 6px 6px 0 var(--pink);
  animation: pop 0.25s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.comic-canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 42dvh;
  border: 4px solid var(--ink);
  border-radius: 12px;
  background: #ddd;
}
.comic-level { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: #6b5e80; }
.comic-canvas.small { aspect-ratio: 16 / 9; max-height: 26dvh; }
.bubble {
  position: relative;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 4px 4px 0 var(--ink);
}
.bubble::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 40px;
  border: 12px solid transparent;
  border-bottom-color: var(--ink);
  border-top: 0;
}
.speaker { margin: 0 0 4px; font: 800 11px var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: #6b5e80; }
.story[data-speaker="player"] .bubble { background: var(--gold); }
.story[data-speaker="player"] .speaker { color: var(--ink); }
.line { margin: 0; font-size: 16px; line-height: 1.4; font-weight: 600; min-height: 3.2em; }
.result h2, .pause h2 { margin: 0; text-align: center; font: 400 26px/1.05 var(--display); color: var(--ink); }
.result[data-won="true"] h2 { color: var(--ink); text-shadow: 3px 3px 0 var(--gold); }
.result[data-won="false"] h2 { color: var(--red); }
.result-badge { margin: 0; padding: 8px 12px; text-align: center; font: 400 14px var(--display); color: var(--text); background: var(--ink); border: 3px solid var(--gold); border-radius: 12px; }
.stars { display: flex; justify-content: center; gap: 10px; font-size: 44px; line-height: 1; }
.star { color: #cfc7d9; -webkit-text-stroke: 2px var(--ink); transition: transform 0.2s; }
.star.on { color: var(--gold); text-shadow: 3px 3px 0 var(--pink); animation: starpop 0.35s; }
@keyframes starpop { 50% { transform: scale(1.5) rotate(15deg); } }
.result-points { margin: 0; text-align: center; font: 400 20px var(--display); }
.actions { display: flex; flex-direction: column; gap: 8px; }
.pause { gap: 10px; }
.pause .btn-ghost, .result .btn-ghost { color: var(--ink); border-color: var(--ink); }

/* --- MPU-Akte --- */
.akte {
  position: relative;
  overflow: hidden;
  flex: none;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 6px;
  padding: 0 14px 12px;
  font-size: 13px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35);
  animation: akte-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes akte-in { from { transform: translateY(30px) rotate(-2deg); opacity: 0; } }
.akte-watermark { position: absolute; width: 70%; left: 15%; top: 32%; opacity: 0.06; pointer-events: none; }
.akte-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 8px;
  margin: 0 -14px;
  padding: 6px 14px;
  font: 700 11px var(--mono);
  color: var(--paper);
  background: var(--ink);
}
.akte-head { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px 0 6px; }
.akte-head-text { padding-right: 78px; }
.mugshot { width: 78px; height: 78px; flex: none; border: 2px solid var(--ink); background: #d9dde6; }
.akte-head-text { flex: 1; }
.akte-head h2 { margin: 0; font: 400 17px/1.1 var(--display); overflow-wrap: anywhere; hyphens: auto; }
.akte-date { margin: 4px 0 0; font-size: 11px; color: #555; }
.stamp {
  flex: none;
  font: 400 15px/1 var(--display);
  text-align: center;
  padding: 6px 9px;
}
.stamp-red {
  color: var(--stamp);
  background: transparent;
  border: 4px solid var(--stamp);
  border-radius: 8px;
  opacity: 0.9;
  position: absolute;
  right: -2px;
  top: 18px;
  transform: rotate(-12deg);
  visibility: hidden;
}
.akte.stamped .stamp-red { visibility: visible; animation: stamp 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes stamp { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } }
.akte-badge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 6px;
  padding: 10px 12px;
  background: #efe8d8;
  border-radius: 10px;
}
.seal-medal { display: flex; flex: none; }
.akte-badge-level { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: #6a5f4e; }
.akte-badge-title { margin: 2px 0 0; font: 400 17px/1.1 var(--display); }
.akte-grid {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  margin: 6px 0 10px;
  border-top: 1px solid var(--ink);
}
.akte-grid dt, .akte-grid dd { margin: 0; padding: 6px 0; border-bottom: 1px solid #cfc7b4; }
.akte-grid dt { font: 700 10px var(--mono); color: #666; padding-right: 10px; padding-top: 8px; }
.akte-grid dd { font: 700 13.5px/1.35 var(--mono); }
.akte-grid .status { color: var(--stamp); }
.akte-statement h3 { margin: 0 0 4px; font: 800 12px var(--font); letter-spacing: 0.06em; text-transform: uppercase; }
.akte-statement p { margin: 0 0 8px; line-height: 1.5; }
.akte-statement [data-field="stellungnahme"] { font: 400 14px/1.5 var(--mono); }
.signature-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.stamper { width: 110px; height: 120px; flex: none; }
.signature { text-align: right; font-weight: 800; }
.signature small { font-weight: 500; color: #666; }
.akte-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin: 6px 0 8px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  color: #fff;
  background: var(--green);
}
.akte-cta > div { flex: 1; }
.cta-title { margin: 0; font: 400 15px/1.15 var(--display); overflow-wrap: anywhere; }
.cta-url { margin: 4px 0 0; font-weight: 800; font-size: 15px; }
.qr { width: 84px; height: 84px; background: #fff; border-radius: 4px; padding: 3px; flex: none; }
.akte-footer { font-size: 10px; color: #555; border-top: 1px solid #cfc7b4; padding-top: 6px; }
.akte-footer p { margin: 2px 0; }
.powered { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--navy); }
.powered img { width: 18px; height: 18px; }
.rank-info { margin: 0; text-align: center; font-weight: 800; color: var(--gold); }
.cta-link { color: var(--muted); font-size: 13px; text-align: center; padding: 4px 0 8px; }

/* Querformat auf dem Handy: Comic-Fenster zweispaltig, damit alles sichtbar bleibt */
@media (orientation: landscape) and (max-height: 500px) {
  .overlay { padding: 8px; }
  .comic {
    width: min(100%, 780px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: dense;
    align-items: start;
    gap: 8px 12px;
  }
  .comic-canvas, .comic-canvas.small { grid-column: 1; grid-row: 1 / span 4; max-height: 78dvh; aspect-ratio: 4 / 3; }
  .comic > :not(.comic-canvas) { grid-column: 2; }
  .result h2 { font-size: 20px; }
  .stars { font-size: 32px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .actions .btn { padding: 10px; font-size: 14px; }
  .line { font-size: 14px; min-height: 0; }
  .pause { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
