/* ===================================================================
   Tales from the Void – „Der Faden“
   Eine Spalte Text, in der Einrichtung und Geschichte dasselbe sind.
   Die Oberfläche tritt zurück, sobald erzählt wird.
   =================================================================== */

:root {
  --bg:        #08080A;
  --bg-thread: #0A0A0C;
  --rail:      #0C0C10;
  --surface:   #101014;

  --text:      #EDE7DC;
  --text-hi:   #F4EFE6;
  --muted:     rgba(237,231,220,.46);
  --faint:     rgba(237,231,220,.30);
  --line:      rgba(237,231,220,.10);
  --line-soft: rgba(237,231,220,.06);
  --fill:      rgba(237,231,220,.035);

  --gold:      #D9A85F;
  --gold-lit:  #F0CB8C;
  --gold-tint: rgba(217,168,95,.07);
  --gold-line: rgba(217,168,95,.45);

  --violet:    #8B7FC4;
  --violet-lit:#B7AEE4;
  --violet-tint: rgba(139,127,196,.08);

  --ok:        #7FB08A;
  --bad:       #D98974;
  --success:   #7FB08A;   /* Altnamen, die die Spiellogik noch verwendet */
  --danger:    #D98974;
  --accent:    #D9A85F;
  --accent2:   #F0CB8C;

  --font-prose: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-ui:    'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono:  'IBM Plex Mono', ui-monospace, monospace;

  --prose-size: 20px;
  --mood: rgba(140,120,190,.16);   /* Stimmungs-Schimmer über der Szene */
  --radius: 14px;
  --radius-lg: 22px;
}

/* Die Stimmung färbt nur noch das Licht über der Szene, nicht die Oberfläche */
body[data-mood="geheimnisvoll"] { --mood: rgba(140,120,190,.16); }
body[data-mood="duester"]       { --mood: rgba(120,70,80,.15); }
body[data-mood="unheimlich"]    { --mood: rgba(60,150,130,.13); }
body[data-mood="angespannt"]    { --mood: rgba(224,141,46,.13); }
body[data-mood="gefaehrlich"]   { --mood: rgba(227,59,59,.15); }
body[data-mood="ruhig"]         { --mood: rgba(69,166,196,.12); }
body[data-mood="hoffnungsvoll"] { --mood: rgba(108,194,87,.12); }
body[data-mood="freudig"]       { --mood: rgba(236,194,63,.14); }
body[data-mood="episch"]        { --mood: rgba(85,120,230,.15); }
body[data-mood="melancholisch"] { --mood: rgba(102,131,184,.13); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.in-thread { height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-lit); }
:focus-visible { outline: 2px solid var(--gold-line); outline-offset: 2px; border-radius: 6px; }

/* ===== Formularelemente ===== */
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: 400 14px/1.45 var(--font-ui);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold-line);
  box-shadow: 0 0 0 3px rgba(217,168,95,.12);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 55%, calc(100% - 14px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
label.fld, .fld {
  display: block; margin: 14px 0 6px;
  font: 400 12.5px/1.3 var(--font-ui); color: var(--muted);
}
.mono-label {
  display: block; margin-top: 18px;
  font: 500 9.5px/1 var(--font-mono);
  letter-spacing: .2em; text-transform: uppercase; color: var(--faint);
}
.note { font: 400 11.5px/1.55 var(--font-ui); color: var(--muted); text-wrap: pretty; }
.hint { font: 400 12.5px/1.6 var(--font-ui); color: var(--muted); text-wrap: pretty; }
.hint b, .note b { color: var(--text); font-weight: 500; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 12px 0; font-size: 13.5px; color: var(--muted); }
.check-row input { width: auto; }
.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-row input[type=range] { flex: 1; accent-color: var(--gold); }

/* ===== Knöpfe ===== */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 20px; border: 0; border-radius: var(--radius);
  background: var(--gold); color: #14100A;
  font: 500 15px/1 var(--font-ui); cursor: pointer;
  transition: background .18s, transform .12s, opacity .18s;
}
.primary-btn:hover:not(:disabled) { background: var(--gold-lit); }
.primary-btn:active:not(:disabled) { transform: translateY(1px); }
.primary-btn:disabled { opacity: .35; cursor: not-allowed; }
.primary-btn .orn { opacity: .55; }
.primary-btn.tiny { padding: 10px 13px; gap: 0; }
.vio-btn { background: var(--violet); color: #0D0B14; }
.vio-btn:hover:not(:disabled) { background: var(--violet-lit); }
.ghost-btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: transparent; color: var(--muted);
  font: 400 13.5px/1 var(--font-ui); cursor: pointer;
  transition: border-color .18s, color .18s, background .18s;
}
.ghost-btn:hover, .icon-btn:hover { border-color: var(--gold-line); color: var(--gold-lit); }
.icon-btn.active { border-color: var(--gold-line); color: var(--gold-lit); }
.danger-btn {
  width: 100%; padding: 12px; border: 1px solid rgba(180,84,63,.4); border-radius: 12px;
  background: transparent; color: var(--bad); font: 400 13px/1 var(--font-ui); cursor: pointer;
  transition: border-color .18s;
}
.danger-btn:hover { border-color: rgba(180,84,63,.85); }
.vio { color: var(--violet-lit); }
.colophon-link {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: 400 11.5px/1 var(--font-ui); color: var(--faint);
}
.colophon-link:hover { color: var(--gold-lit); }

/* ===================================================================
   Auftakt
   =================================================================== */
#introHero {
  position: relative; min-height: 100dvh;
  display: flex; align-items: center;
  padding: 48px 26px;
  background: radial-gradient(120% 90% at 18% 0%, #15121B 0%, #08080A 62%);
  overflow: hidden;
}
.intro-halo {
  position: absolute; top: 50%; left: 66%;
  width: 460px; height: 460px; margin: -230px 0 0 -230px;
  border-radius: 50%;
  border: 1px solid rgba(217,168,95,.16);
  background: radial-gradient(circle, rgba(217,168,95,.16) 0%, rgba(217,168,95,0) 68%);
  animation: emb 6s ease-in-out infinite;
  pointer-events: none;
}
.intro-inner {
  position: relative; z-index: 1;
  max-width: 620px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 22px;
  animation: fadeIn .8s ease both;
}
.intro-kicker {
  font: 500 10px/1 var(--font-mono);
  letter-spacing: .28em; text-transform: uppercase; color: rgba(217,168,95,.8);
}
.intro-title {
  font: 400 clamp(52px, 11vw, 80px)/.94 var(--font-prose);
  letter-spacing: -.025em; color: var(--text-hi); font-weight: 400;
}
.intro-title em { font-style: normal; color: var(--gold); }
.intro-sub {
  max-width: 32ch;
  font: 400 clamp(17px, 2.4vw, 19px)/1.6 var(--font-prose);
  color: rgba(237,231,220,.66); text-wrap: pretty;
}
.intro-actions { display: flex; flex-wrap: wrap; gap: 11px; padding-top: 6px; }
.intro-actions .primary-btn { box-shadow: 0 16px 44px rgba(217,168,95,.2); }
.intro-meta, .intro-links {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  font: 400 11.5px/1 var(--font-ui); color: var(--faint);
}

/* ===================================================================
   Rahmen: Kopf, Faden, Runde
   =================================================================== */
#app { height: 100%; display: flex; flex-direction: column; background: var(--bg-thread); }

header {
  flex: none;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.hd-chapter { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hd-kind {
  font: 500 9.5px/1 var(--font-mono);
  letter-spacing: .2em; text-transform: uppercase; color: var(--faint);
}
.hd-name {
  font: 400 20px/1.15 var(--font-prose); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr-btns { display: flex; gap: 6px; flex: none; }
.hdr-btns .icon-btn { padding: 9px 12px; }
@media (max-width: 620px) { .btn-lbl { display: none; } .hdr-btns .icon-btn { padding: 9px 11px; } }

#gameScreen {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 292px minmax(0, 1fr);
}

/* --- Die Runde (Schiene links) --- */
#sidebar {
  order: -1;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 20px 26px;
  border-right: 1px solid var(--line-soft);
  background: var(--rail);
  overflow: auto;
}
#sidebar .sb-close { display: none; }
.rail-block { display: flex; flex-direction: column; gap: 10px; }
.rail-block h3 {
  font: 500 9.5px/1 var(--font-mono);
  letter-spacing: .2em; text-transform: uppercase; color: var(--faint); font-weight: 500;
}
.rail-cta {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 13px 14px; border-radius: 12px;
  border: 1px solid rgba(139,127,196,.3); background: var(--violet-tint);
  color: var(--text); cursor: pointer; transition: border-color .18s;
}
.rail-cta:hover { border-color: rgba(139,127,196,.65); }
.rail-cta b { font: 500 12.5px/1.3 var(--font-ui); color: var(--violet-lit); }
.rail-cta span { font: 400 11.5px/1.45 var(--font-ui); color: var(--muted); }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.usage-tile {
  display: flex; flex-direction: column; gap: 3px;
  padding: 11px; border-radius: 11px; background: var(--fill);
}
.usage-tile span { font: 400 10.5px/1 var(--font-ui); color: var(--faint); }
.usage-tile b { font: 500 16px/1 var(--font-mono); color: var(--text); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.rail-links { display: flex; gap: 14px; }
#sidebarScrim { display: none; }

/* Mitglieder & Begegnungen */
.party-member {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 11px; background: var(--fill);
  transition: box-shadow .25s;
}
.party-member.active { box-shadow: inset 0 0 0 1px var(--gold-line); }
.party-member.out { opacity: .45; }
.party-member svg { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.pm-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pm-info b { font: 500 14.5px/1.2 var(--font-prose); color: var(--text); }
.pm-info span { font: 400 10.5px/1 var(--font-mono); color: var(--muted); }
.pm-hp { height: 4px; border-radius: 3px; background: rgba(237,231,220,.08); overflow: hidden; margin-top: 3px; }
.pm-hp div { height: 100%; background: var(--gold); transition: width .4s ease; }
.party-member.voter .voter-dot {
  width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(139,127,196,.14); color: var(--violet-lit); font-size: 12px;
}
.gv-tally { margin-bottom: 4px; }
.char-card { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.char-card svg { width: 38px; height: 38px; border-radius: 9px; flex: none; }
.ci { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ci b { font: 500 14.5px/1.25 var(--font-prose); color: var(--text); }
.ci span { font: 400 11.5px/1.4 var(--font-ui); color: var(--muted); }
.mp-code {
  font: 500 21px/1 var(--font-mono); letter-spacing: .2em; color: var(--violet-lit);
  padding: 6px 0 10px;
}
.qr-mini { max-width: 132px; margin-top: 6px; padding: 8px; border-radius: 10px; background: #EDE7DC; }
.qr-mini svg, .qr-card svg { width: 100%; height: auto; display: block; }

/* --- Der Faden --- */
#storyCol { display: flex; flex-direction: column; min-height: 0; position: relative; }
#story {
  flex: 1; min-height: 0; overflow: auto;
  padding: 26px 30px 30px;
  display: flex; flex-direction: column; gap: 26px;
  scroll-behavior: smooth;
}
#storyCol::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 220px;
  background: radial-gradient(90% 100% at 50% 0%, var(--mood) 0%, rgba(10,10,12,0) 72%);
  pointer-events: none; transition: background .8s ease; z-index: 0;
}
.beat { position: relative; z-index: 1; max-width: 660px; width: 100%; margin: 0 auto; animation: fadeUp .5s ease both; }

/* Erzählung */
.fragment {
  font: 400 var(--prose-size)/1.66 var(--font-prose);
  letter-spacing: .004em; color: rgba(240,234,223,.94);
  text-wrap: pretty; white-space: pre-wrap;
}
.fragment.opening::first-letter {
  float: left; margin: .16em .09em 0 0;
  font-size: 3.4em; line-height: .72; color: var(--gold);
}
.fragment .rv { opacity: .22; transition: opacity .28s ease; }
.fragment .rv.on { opacity: 1; }

/* Erzähler-Fragen */
.beat-plain .prose {
  font: 400 var(--prose-size)/1.62 var(--font-prose);
  color: rgba(240,234,223,.94); text-wrap: pretty;
}
.beat-plain .prose.muted-prose { color: var(--muted); }
.ask-q {
  font: italic 400 var(--prose-size)/1.55 var(--font-prose);
  color: rgba(217,168,95,.92); text-wrap: pretty;
}
.beat-ask, .beat-chips, .beat-form { display: flex; flex-direction: column; gap: 13px; }
.ask-opts { display: flex; flex-wrap: wrap; gap: 9px; }
.ask-opt {
  flex: 1 1 280px;
  display: flex; align-items: flex-start; gap: 13px; text-align: left;
  padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(237,231,220,.028); color: var(--text); cursor: pointer;
  transition: border-color .18s, background .18s, transform .12s;
}
.ask-opt:hover { border-color: var(--gold-line); background: var(--gold-tint); }
.ask-opt:active { transform: translateY(1px); }
.ao-icon {
  flex: none; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(217,168,95,.12);
  font-size: 13px; color: var(--gold);
}
.ao-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ao-txt b { font: 500 14.5px/1.25 var(--font-ui); color: var(--text); }
.ao-txt small { font: 400 12.5px/1.45 var(--font-ui); color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 10px 15px; border: 1px solid rgba(237,231,220,.13); border-radius: 99px;
  background: rgba(237,231,220,.03); color: rgba(237,231,220,.78);
  font: 400 13.5px/1 var(--font-ui); cursor: pointer;
  transition: border-color .16s, color .16s, background .16s;
}
.chip:hover { border-color: var(--gold-line); color: var(--gold-lit); background: var(--gold-tint); }
.chip-note { font: 400 11.5px/1.5 var(--font-ui); color: var(--faint); }

/* Antwort der Runde */
.beat-you {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 9px;
  font: 400 15px/1.45 var(--font-ui); color: rgba(237,231,220,.8); text-align: right;
}
.beat-you .you-mark { flex: none; font-size: 10px; color: var(--gold); }
.beat-anchor { display: none; }
/* Solange die Geschichte noch nicht läuft, lässt sich jede Antwort ändern */
.beat-you.editable { cursor: pointer; }
.beat-you.editable span:first-child {
  border-bottom: 1px dashed rgba(237,231,220,.22);
  transition: color .16s, border-color .16s;
}
.beat-you.editable:hover span:first-child { color: var(--gold-lit); border-color: var(--gold-line); }
.beat-you b { color: var(--text); font-weight: 500; }
.beat-you em { color: var(--faint); font-style: italic; }

/* Quittung einer Probe */
.beat-roll { display: flex; align-items: center; gap: 11px; }
.roll-badge {
  padding: 9px 12px; border-radius: 10px; background: var(--fill);
  font: 500 11.5px/1 var(--font-mono); letter-spacing: .08em;
}
.roll-badge.ok { color: var(--ok); }
.roll-badge.bad { color: var(--bad); }
.roll-text { font: 400 11.5px/1.4 var(--font-mono); color: var(--muted); }

/* Zäsur */
.beat-orn { display: flex; align-items: center; gap: 14px; padding: 4px 0; }
.orn-line { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(237,231,220,0), rgba(237,231,220,.16)); }
.orn-line:last-child { background: linear-gradient(90deg, rgba(237,231,220,.16), rgba(237,231,220,0)); }
.orn-glyph { font: 400 13px/1 var(--font-prose); color: rgba(217,168,95,.7); }

.beat-warn {
  padding: 14px 16px; border: 1px solid rgba(180,84,63,.4); border-radius: var(--radius);
  background: rgba(180,84,63,.07); font: 400 13.5px/1.55 var(--font-ui); color: var(--text);
}
#endBanner {
  padding: 22px 20px; border-radius: var(--radius-lg);
  border: 1px solid var(--gold-line); background: var(--gold-tint);
  text-align: center; font: 400 18px/1.5 var(--font-prose); color: var(--text-hi);
}
#endBanner .primary-btn { margin-top: 16px; }

/* Einrichtungsblöcke im Faden */
.beat-form .field-row { max-width: 460px; }
.beat-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.beat.done .ask-q { color: var(--muted); }
.field-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 14px; border: 1px solid var(--line); border-radius: 13px;
}
.field-row input { border: 0; background: none; padding: 4px 0; border-radius: 0; }
.field-row input:focus { box-shadow: none; }
.fld-tag { flex: none; font: 400 11.5px/1 var(--font-mono); color: var(--faint); letter-spacing: .1em; }
#joinCode { text-transform: uppercase; letter-spacing: .22em; font-family: var(--font-mono); }

/* Heldenkarten */
.player-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 16px; background: rgba(237,231,220,.028);
}
.pc-head { display: flex; align-items: center; gap: 12px; }
.pc-head input {
  flex: 1; border: 0; background: none; padding: 2px 0; border-radius: 0;
  font: 400 17px/1.2 var(--font-prose); color: var(--text);
}
/* Das Namensfeld muss als Feld lesbar sein – solange es leer ist, ruft es golden */
.pc-head input { border-bottom: 1px dashed rgba(237,231,220,.2); }
.pc-head input:placeholder-shown { border-bottom-color: var(--gold-line); }
.pc-head input:focus { box-shadow: none; border-bottom-color: var(--gold); }
.blocker { font: 400 12.5px/1.5 var(--font-ui); color: var(--gold); }
.blocker:empty { display: none; }
.pc-left { flex: none; font: 500 10.5px/1 var(--font-mono); letter-spacing: .08em; color: var(--gold); }
.pc-left.done { color: var(--faint); }
.attr-alloc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.alloc-box { display: flex; align-items: center; gap: 10px; }
.alloc-box .nm { flex: none; width: 62px; font: 400 12px/1 var(--font-ui); color: var(--muted); }
.pips { flex: 1; display: flex; gap: 3px; }
.pips i { flex: 1; height: 5px; border-radius: 3px; background: rgba(237,231,220,.09); }
.pips i.on { background: var(--gold); }
.alloc-ctrl { flex: none; display: flex; align-items: center; gap: 7px; }
.alloc-ctrl button {
  width: 22px; height: 22px; border: 1px solid rgba(237,231,220,.14); border-radius: 6px;
  background: none; color: rgba(237,231,220,.7); font: 400 12px/1 var(--font-ui); cursor: pointer;
}
.alloc-ctrl button:hover { border-color: var(--gold-line); color: var(--gold-lit); }
.alloc-ctrl .val { width: 10px; text-align: center; font: 500 12px/1 var(--font-mono); color: var(--text); }

/* Lobby */
.lobby-card {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 16px; border-radius: var(--radius-lg); background: var(--violet-tint);
}
.qr-card { flex: none; width: 150px; padding: 10px; border-radius: 12px; background: #EDE7DC; }
.lobby-info { flex: 1; min-width: 220px; }

/* ===== Der Erzähler schreibt =====
   Die Feder legt sich als ganzflächiges Blatt über die Szene: Warten ist ein
   Moment der Geschichte, kein Ladebalken. Die Spiellogik schaltet nur
   style="display:block" – die Darstellung macht daraus das Overlay. */
#thinking { display: none; }
#thinking[style*="block"] {
  display: flex !important;
  position: fixed; inset: 0; z-index: 55;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 40px;
  background: radial-gradient(70% 55% at 50% 45%, rgba(27,22,32,.92) 0%, rgba(8,8,10,.94) 78%);
  backdrop-filter: blur(7px);
  animation: fadeIn .4s ease both;
}
#thinking .quill {
  width: 52px; height: 52px; color: var(--gold);
  filter: drop-shadow(0 0 14px rgba(217,168,95,.45));
}
#thinking .quill svg {
  width: 100%; height: 100%; transform-origin: 20% 92%;
  animation: quillWrite 1.7s cubic-bezier(.45,0,.2,1) infinite;
}
#thinking .ink-line {
  width: 150px; height: 2px; border-radius: 2px;
  background: rgba(217,168,95,.18); overflow: hidden;
}
#thinking .ink-line::after {
  content: ''; display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-lit));
  transform: scaleX(0); transform-origin: left;
  animation: inkDraw 1.7s cubic-bezier(.45,0,.2,1) infinite;
}
#thinkingText {
  min-height: 1.3em; max-width: 26ch; text-align: center;
  font: italic 400 clamp(18px, 3.4vw, 23px)/1.4 var(--font-prose);
  color: var(--gold-lit); text-wrap: pretty;
}

/* ===== Was tut ihr? – die Handlungsleiste ===== */
#choices:empty { display: none; }
#choices {
  flex: none; padding: 14px 30px 22px;
  border-top: 1px solid var(--line-soft); background: #0B0B0F;
  max-height: 54dvh; overflow: auto;
  animation: slideUp .35s ease both;
}
.turn-banner {
  max-width: 660px; margin: 0 auto 8px;
  font: 500 10.5px/1.4 var(--font-mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
}
.turn-banner:empty { display: none; }
.decide-card {
  max-width: 660px; margin: 0 auto 10px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--fill);
}
.decide-card.locked { opacity: .62; }
.decide-head { display: flex; align-items: center; gap: 10px; }
.decide-head svg { width: 26px; height: 26px; border-radius: 7px; flex: none; }
.decide-head b { font: 500 15px/1.2 var(--font-prose); color: var(--text); flex: 1; }
.decide-status { font: 400 10.5px/1 var(--font-mono); color: var(--faint); }
.decide-locked { font: 400 14px/1.45 var(--font-prose); color: var(--muted); }
.choice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px;
  background: rgba(237,231,220,.03); color: var(--text); text-align: left; cursor: pointer;
  font: 400 15px/1.35 var(--font-prose);
  transition: border-color .18s, background .18s, transform .12s;
}
.choice + .choice { margin-top: 8px; }
.choice:hover { border-color: var(--gold-line); background: var(--gold-tint); }
.choice:active { transform: translateY(1px); }
.choice .tag {
  flex: none; text-align: right;
  font: 500 10px/1.35 var(--font-mono); letter-spacing: .06em; color: var(--violet-lit);
}
.free-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px 8px 14px; border: 1px solid var(--line-soft); border-radius: 13px;
  max-width: 660px; margin: 8px auto 0;
}
.free-row input { border: 0; background: none; padding: 4px 0; }
.free-row input:focus { box-shadow: none; }
.free-row .icon-btn { flex: none; padding: 8px 11px; }
.mic-btn.recording { border-color: var(--bad); color: var(--bad); animation: emb 1.4s ease-in-out infinite; }

/* Gruppen-Abstimmung */
.group-vote { max-width: 660px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.gv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.gv-head b { font: 500 17px/1.2 var(--font-prose); color: var(--text); }
.gv-count { font: 400 10.5px/1 var(--font-mono); color: var(--violet-lit); }
.group-choice { position: relative; overflow: hidden; margin-top: 8px; }
.group-choice.chosen { border-color: rgba(139,127,196,.65); }
.gc-bar {
  position: absolute; inset: 0 auto 0 0; z-index: 0;
  background: rgba(139,127,196,.22); transition: width .45s ease;
}
.gc-text, .gc-votes { position: relative; z-index: 1; }
.gc-votes { font: 500 11px/1 var(--font-mono); color: var(--muted); }
.free-vote { cursor: default; }
.gv-hint { margin-top: 2px; }

/* ===================================================================
   Blätter (Sheets)
   =================================================================== */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6,6,9,.72); backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .22s ease;
}
.sheet-scrim.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 61; left: 50%; top: 50%;
  width: min(560px, calc(100vw - 32px)); max-height: 86dvh;
  transform: translate(-50%, -46%);
  opacity: 0; transition: opacity .22s ease, transform .28s cubic-bezier(.2,.9,.3,1);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.sheet.open { opacity: 1; transform: translate(-50%, -50%); }
.sheet-wide { width: min(920px, calc(100vw - 32px)); }
.sheet-body { max-height: 86dvh; overflow: auto; padding: 26px 26px 30px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.sheet-head h3 { font: 400 24px/1.15 var(--font-prose); color: var(--text); }
.sheet-head .note { margin-top: 6px; max-width: 46ch; }
.sheet-head .icon-btn { padding: 8px 12px; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.sheet-foot .hint { flex: 1 0 200px; }
.lbl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.lbl-row .mono-label { margin-top: 0; }
.lbl-row .icon-btn { padding: 8px 12px; font-size: 12px; }
.lbl-row .note { flex: 1; text-align: right; }

/* Szenario-Designer */
.scen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.scen-col { display: flex; flex-direction: column; }
.scen-col .note { margin: 4px 0 8px; }
.scen-demos { display: grid; gap: 8px; }
.scen-demo {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 12px 14px; text-align: left;
}
.scen-demo b { color: var(--gold-lit); font: 500 13.5px/1.3 var(--font-ui); }
.scen-demo small { font: 400 11.5px/1.45 var(--font-ui); color: var(--muted); white-space: normal; }
.toggle-row {
  position: relative;
  display: flex; align-items: flex-start; gap: 13px; cursor: pointer;
  padding: 15px; border: 1px solid var(--line); border-radius: 13px; margin-top: 10px;
  transition: border-color .2s, background .2s;
}
.toggle-row.on { border-color: rgba(180,84,63,.55); background: rgba(180,84,63,.08); }
.toggle-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  flex: none; position: relative; width: 38px; height: 22px; border-radius: 99px;
  background: rgba(237,231,220,.14); transition: background .2s;
}
.toggle-row.on .toggle-track { background: #B4543F; }
.toggle-knob {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text); transition: left .2s;
}
.toggle-row.on .toggle-knob { left: 19px; }
.toggle-txt { display: flex; flex-direction: column; gap: 4px; }
.toggle-txt b { font: 500 13.5px/1.2 var(--font-ui); color: var(--text); }
.toggle-row.on .toggle-txt b { color: var(--bad); }
.toggle-txt small { font: 400 11.5px/1.5 var(--font-ui); color: var(--muted); text-wrap: pretty; }
.npc-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; margin-bottom: 9px; border-radius: 13px; background: var(--fill);
}
.npc-head { display: flex; align-items: center; justify-content: space-between; }
.npc-head h4 { font: 500 9.5px/1 var(--font-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.npc-head .icon-btn { padding: 6px 10px; }
.npc-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.3fr); gap: 8px; }

/* ===================================================================
   Würfel, Pause, Countdown
   =================================================================== */
#diceOverlay {
  position: fixed; inset: 0; z-index: 70; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: 40px;
  background: radial-gradient(80% 60% at 50% 40%, #1B1620 0%, #08080A 78%);
  animation: fadeIn .25s ease both;
}
#diceOverlay.show { display: flex; }
.dice-kicker {
  font: 500 10px/1 var(--font-mono); letter-spacing: .26em;
  text-transform: uppercase; color: var(--muted);
}
#diceStage { width: min(300px, 74vw); height: min(300px, 74vw); }
#diceResult {
  max-width: 460px; text-align: center;
  font: 400 14px/1.7 var(--font-mono); color: var(--muted);
}
#diceResult b { color: var(--text); }
#diceResult .crit-s { color: var(--ok); }
#diceResult .crit-f { color: var(--bad); }
#diceContinue { display: none; }
#pauseOverlay {
  position: fixed; inset: 0; z-index: 65; display: none;
  align-items: center; justify-content: center;
  background: rgba(6,6,9,.8); backdrop-filter: blur(8px);
}
.pause-box {
  padding: 30px 34px; border-radius: var(--radius-lg);
  border: 1px solid var(--gold-line); background: var(--surface);
  text-align: center; font: 400 22px/1.4 var(--font-prose); color: var(--text);
}
.pause-box .p-icon { display: block; font-size: 20px; color: var(--gold); margin-bottom: 8px; }
#countdownOverlay {
  position: fixed; inset: 0; z-index: 64; display: none;
  align-items: center; justify-content: center; pointer-events: none;
}
#countdownOverlay span {
  font: 400 26vmin/1 var(--font-prose); color: rgba(217,168,95,.22);
  animation: countPulse 1s ease-out both;
}

/* ===================================================================
   Impressum & Datenschutz
   =================================================================== */
.tome-dlg {
  width: min(760px, calc(100vw - 32px)); max-height: 86dvh; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); overflow: hidden;
}
.tome-dlg::backdrop { background: rgba(6,6,9,.72); backdrop-filter: blur(8px); }
.tome-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 22px; border-bottom: 1px solid var(--line-soft);
}
.tome-head h3 { font: 400 22px/1 var(--font-prose); }
.tome-body { max-height: calc(86dvh - 70px); overflow: auto; padding: 18px 22px 28px; }
.tome-body h4 { margin-top: 22px; font: 500 9.5px/1 var(--font-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.tome-body p { margin-top: 8px; font: 400 13.5px/1.7 var(--font-ui); color: rgba(237,231,220,.78); max-width: 72ch; text-wrap: pretty; }
.tome-body p.tome-lede { color: var(--muted); }
.tome-body a { text-decoration: underline; text-underline-offset: 3px; }

/* ===================================================================
   Bewegung
   =================================================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes emb { 0%,100% { opacity: .45; transform: scale(1); } 50% { opacity: .9; transform: scale(1.06); } }
@keyframes countPulse { 0% { transform: scale(1.3); opacity: 1; } 100% { transform: scale(.85); opacity: .35; } }
@keyframes quillWrite {
  0%   { transform: rotate(-9deg) translate(0, 0); }
  45%  { transform: rotate(5deg) translate(-4px, -3px); }
  55%  { transform: rotate(5deg) translate(-4px, -3px); }
  100% { transform: rotate(-9deg) translate(0, 0); }
}
@keyframes inkDraw {
  0%   { transform: scaleX(0); transform-origin: left; }
  45%  { transform: scaleX(1); transform-origin: left; }
  50%  { transform: scaleX(1); transform-origin: right; }
  95%  { transform: scaleX(0); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* ===================================================================
   Schmale Schirme: Runde und Blätter fahren von unten ein
   =================================================================== */
@media (max-width: 900px) {
  #gameScreen { grid-template-columns: minmax(0, 1fr); }
  #story { padding: 20px 18px 24px; }
  #choices { padding: 12px 18px 20px; }
  header { padding: 14px 16px 10px; }

  #sidebarScrim {
    display: block; position: fixed; inset: 0; z-index: 62;
    background: rgba(6,6,9,.7); backdrop-filter: blur(10px);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  body.rail-open #sidebarScrim { opacity: 1; pointer-events: auto; }
  #sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 63;
    max-height: 86dvh; border: 0; border-top: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(101%); transition: transform .3s cubic-bezier(.2,.9,.3,1);
    padding-bottom: 34px;
  }
  body.rail-open #sidebar { transform: none; }
  #sidebar .sb-close { display: inline-flex; align-self: flex-end; }
  .rail-foot { margin-top: 12px; }

  .sheet {
    top: auto; bottom: 0; left: 0; transform: translate(0, 101%);
    width: 100%; max-width: none; max-height: 90dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0;
  }
  .sheet.open { transform: none; }
  .sheet-body { max-height: 90dvh; padding: 22px 20px 40px; }
  .scen-grid { grid-template-columns: 1fr; gap: 18px; }
  .attr-alloc { grid-template-columns: 1fr; }
  .npc-row { grid-template-columns: 1fr; }
  .beat-actions .primary-btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #story { scroll-behavior: auto; }
  /* Ohne Bewegung bleibt die Tinte stehen, statt zu verschwinden */
  #thinking .ink-line::after { transform: scaleX(1); transform-origin: left; opacity: .6; }
}
