:root {
  --nacht: #14101c;
  --nacht-2: #1e1829;
  --nacht-3: #2a2238;
  --linie: rgba(244, 237, 224, 0.14);
  --papier: #f4ede0;
  --tinte: #1d1724;
  --tinte-2: #5c5366;
  --hell: #f4ede0;
  --hell-2: rgba(244, 237, 224, 0.68);
  --gold: #d8a93b;
  --ja: #3fae7a;
  --nein: #d4553f;
  --narr: #e08a33;
  --presse: #b4aea3;
  --matilde: #3fa898;
  --gefahr: #e0563f;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --anzeige: Georgia, "Times New Roman", serif;
  --rund: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--nacht); color: var(--hell); font-family: var(--schrift); -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#spiel {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* Kopf mit Balken */
.kopf { padding: 10px 16px 6px; }
.balken { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.balken-eintrag { position: relative; }
.balken-name { font-size: 11px; letter-spacing: 0.04em; color: var(--hell-2); text-transform: uppercase; }
.balken-spur { height: 7px; border-radius: 4px; background: var(--nacht-3); overflow: hidden; margin-top: 3px; }
.balken-fuellung { height: 100%; width: 45%; background: var(--gold); border-radius: 4px; transition: width 0.7s cubic-bezier(.2,.8,.2,1), background-color 0.4s; }
.balken-eintrag.knapp .balken-fuellung { background: var(--gefahr); }
.balken-eintrag.knapp .balken-name { color: var(--gefahr); }
.balken-delta { position: absolute; right: 0; top: -2px; font-size: 12px; font-weight: 600; opacity: 0; transition: opacity 0.3s, transform 0.6s; }
.balken-delta.zeigen { opacity: 1; transform: translateY(-3px); }
.balken-delta.plus { color: var(--ja); }
.balken-delta.minus { color: var(--nein); }
.status { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--hell-2); }
.zeit { display: flex; gap: 5px; align-items: center; }
.zeit i { width: 9px; height: 9px; border-radius: 50%; background: var(--matilde); display: inline-block; }
.zeit i.weg { background: transparent; border: 1px solid var(--linie); }

/* Bühne */
.buehne { position: relative; flex: 1 1 40%; min-height: 190px; overflow: hidden; }
.buehne canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.blase {
  z-index: 2;
  position: absolute; left: 12px; right: 12px; bottom: 10px;
  background: rgba(20, 16, 28, 0.86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--linie); border-left: 4px solid var(--narr); border-radius: 0 var(--rund) var(--rund) 0;
  padding: 10px 14px; animation: rein 0.25s ease-out;
}
.blase.presse { border-left-color: var(--presse); }
.blase.matilde { border-left-color: var(--matilde); }
.blase.gross .blase-text { font-family: var(--anzeige); font-weight: 700; letter-spacing: 0.01em; }
.blase-name { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--hell-2); }
.blase-text { margin: 4px 0 0; font-size: 16px; line-height: 1.4; }
@keyframes rein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Karte */
.tisch { padding: 8px 16px 14px; }
.karte {
  position: relative; background: var(--papier); color: var(--tinte); border-radius: var(--rund);
  padding: 18px 18px 22px; min-height: 132px; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1), opacity 0.3s; outline: none;
}
.karte:focus-visible { box-shadow: 0 0 0 3px var(--gold); }
.karte.zieht { transition: none; }
.karte.neu { animation: kartenrein 0.35s cubic-bezier(.2,.8,.2,1); }
@keyframes kartenrein { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; transform: none; } }
.karte-dach { margin: 0; font-size: 12px; color: var(--tinte-2); letter-spacing: 0.03em; }
.karte-frage { margin: 8px 0 0; font-family: var(--anzeige); font-size: 23px; line-height: 1.25; font-weight: 700; }
.karte-stempel {
  position: absolute; top: 14px; font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border: 2px solid; border-radius: 6px; opacity: 0; transition: opacity 0.1s;
}
.karte-stempel.ja { right: 14px; color: var(--ja); transform: rotate(8deg); }
.karte-stempel.nein { left: 14px; color: var(--nein); transform: rotate(-8deg); }

.knoepfe { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 12px; }
.knopf {
  border: 1px solid var(--linie); background: var(--nacht-2); color: var(--hell); border-radius: 12px;
  padding: 13px 12px; font-weight: 600; font-size: 15px; transition: transform 0.08s, background 0.2s, opacity 0.2s;
}
.knopf:active { transform: scale(0.97); }
.knopf:disabled { opacity: 0.4; cursor: default; }
.knoepfe .knopf { white-space: nowrap; font-size: 14px; padding: 13px 8px; }
.knopf.ja { border-color: rgba(63, 174, 122, 0.55); color: #8fe0b8; }
.knopf.nein { border-color: rgba(212, 85, 63, 0.55); color: #f2a593; }
.knopf.matilde { border-color: rgba(63, 168, 152, 0.55); color: #9fe1d4; font-size: 13px; padding-inline: 10px; }
.knopf.haupt { background: var(--gold); color: var(--tinte); border-color: var(--gold); width: 100%; font-size: 16px; padding: 15px; }

/* Meldung */
.meldung {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 30; max-width: 88%;
  background: var(--papier); color: var(--tinte); border-radius: 12px; padding: 12px 16px; font-weight: 600;
  text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.45); animation: rein 0.25s ease-out;
}
.meldung.gericht { border-top: 4px solid var(--nein); }

/* Ebenen (Intro, Los, Ende, Matilde) */
.ebene { position: fixed; inset: 0; z-index: 20; background: rgba(14, 10, 20, 0.97); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 24px 16px; }
.ebene.unten { align-items: flex-end; background: rgba(14, 10, 20, 0.6); padding: 0; }
.ebene-inhalt { width: 100%; max-width: 480px; margin: auto; animation: rein 0.3s ease-out; }

.intro-inhalt { text-align: center; }
.intro-zeile { margin: 0; font-size: 18px; color: var(--hell-2); }
.intro-zeile.gross { font-size: 22px; color: var(--hell); font-weight: 600; margin-top: 2px; }
.titel { font-family: var(--anzeige); font-size: 30px; line-height: 1.15; margin: 26px 0 14px; font-weight: 400; }
.titel span { display: block; font-size: 46px; font-weight: 700; color: var(--gold); letter-spacing: 0.01em; }
.intro-regeln { color: var(--hell-2); line-height: 1.55; margin: 0 0 22px; }
.koeder { font-family: var(--anzeige); font-style: italic; color: var(--gold); margin: -8px 0 20px; }
.kleingedruckt { font-size: 12px; color: var(--hell-2); line-height: 1.5; margin-top: 16px; }

.blatt { background: var(--papier); color: var(--tinte); border-radius: 20px 20px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 86dvh; overflow-y: auto; max-width: 560px; }
.blatt-wer { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: #2f8f83; font-weight: 700; }
.blatt-fakt { font-size: 17px; line-height: 1.5; margin: 10px 0 16px; }
.blatt-titel { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tinte-2); font-weight: 700; }
.blatt-klein { margin: 6px 0 16px; line-height: 1.5; }
.blatt-quellen { margin: 6px 0 20px; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--tinte-2); }

.los-inhalt { text-align: center; }
.los-dach { color: var(--hell-2); margin: 0; }
.los-wer { font-family: var(--anzeige); font-size: 28px; margin: 12px 0 6px; line-height: 1.2; min-height: 34px; }
.los-wer.wirbelt { color: var(--hell-2); }
.los-detail { color: var(--hell-2); margin: 0 0 18px; }
.los-zeilen { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; }
.los-zeilen li { background: var(--nacht-2); border: 1px solid var(--linie); border-radius: 12px; padding: 10px 12px 10px 40px; margin-bottom: 8px; position: relative; line-height: 1.4; opacity: 0; animation: rein 0.3s ease-out forwards; }
.los-zeilen li::before { position: absolute; left: 13px; top: 10px; font-weight: 800; }
.los-zeilen li.plus::before { content: "+"; color: var(--ja); }
.los-zeilen li.minus::before { content: "−"; color: var(--nein); }
.los-zeilen li.null::before { content: "·"; color: var(--hell-2); }
.los-zeilen small { display: block; color: var(--hell-2); font-size: 12px; margin-bottom: 2px; }
.los-fazit { font-family: var(--anzeige); font-size: 20px; margin: 4px 0 20px; }

.ende-inhalt { text-align: center; }
.ende-dach { color: var(--hell-2); margin: 0; }
.ende-titel { font-family: var(--anzeige); font-size: 30px; margin: 8px 0 8px; color: var(--gold); }
.ende-text { color: var(--hell-2); line-height: 1.5; margin: 0 0 18px; }
.ende-zahlen { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; }
.ende-zahlen li { padding: 10px 0; border-bottom: 1px solid var(--linie); line-height: 1.45; }
.ende-zahlen li strong { color: var(--gold); }
.profil { background: var(--nacht-2); border: 1px dashed rgba(216, 169, 59, 0.5); border-radius: var(--rund); padding: 14px; text-align: left; margin-bottom: 18px; transition: opacity 0.5s; }
.profil-titel { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold); font-weight: 700; }
.profil-text { font-size: 17px; margin: 8px 0; }
.profil-hinweis { font-size: 13px; color: var(--hell-2); line-height: 1.5; margin: 0 0 12px; }
.profil.geloescht .profil-text { text-decoration: line-through; color: var(--hell-2); }
.ende-knoepfe { display: grid; gap: 10px; }
.belege { display: inline-block; margin-top: 18px; color: #9fe1d4; font-size: 14px; }
.ohne-js { text-align: center; padding: 40px; }

@media (min-height: 760px) { .karte-frage { font-size: 26px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
