/* ─── Schriften (lokal eingebunden) ───────────────────────────────────────── */
@font-face { font-family: 'Stencil'; src: url(fonts/anton-400.woff2) format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Stencil'; src: url(fonts/anton-400.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url(fonts/barlow-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url(fonts/barlow-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url(fonts/barlow-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

/* ─── Farben & Maße ───────────────────────────────────────────────────────── */
:root {
  --night: #14213b;      /* Einsatztisch */
  --night-2: #1c2c4b;    /* Flächen */
  --night-3: #273a5f;    /* Linien, Hover */
  --chalk: #eef1f6;      /* Text auf dunkel */
  --fog: #9aa8c3;        /* Nebentext */
  --paper: #e6e9df;      /* Wortkarte: kühler Karteikarton */
  --paper-edge: #c9cfbf;
  --ink: #1d2433;        /* Schrift auf Karte */
  --red: #d3343f;
  --red-deep: #a8222d;
  --blue: #2e6be6;
  --blue-deep: #1c4fb8;
  --neutral: #c2ad86;    /* Zivilist: Khaki */
  --neutral-deep: #9c875f;
  --assassin: #000;
  --radius: 10px;
  --gap: clamp(5px, 1.4vw, 10px);
  --sans: 'Barlow', system-ui, sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --stencil: 'Stencil', 'Barlow Condensed', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--night);
  background-image: radial-gradient(120% 80% at 50% -10%, #20335a 0%, var(--night) 60%);
  background-attachment: fixed;
  color: var(--chalk);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
code { font-size: .9em; background: var(--night-3); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--fog); }
.small { font-size: .875rem; }
.error { color: #ff9aa0; min-height: 1.4em; font-size: .9rem; }

.wordmark {
  font-family: var(--stencil); font-weight: 900; letter-spacing: .01em;
  font-size: 2rem; line-height: 1; color: var(--chalk);
}
.wordmark.big { font-size: clamp(4rem, 19vw, 9rem); letter-spacing: -.01em; }
.boot { min-height: 100vh; display: grid; place-items: center; opacity: .6; }

/* ─── Buttons & Felder ────────────────────────────────────────────────────── */
.btn {
  appearance: none; border: 1.5px solid var(--night-3); background: var(--night-2);
  border-radius: 999px; padding: .7em 1.25em; font-weight: 600; line-height: 1.1;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { border-color: var(--fog); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: #fff; border-color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: .45em .9em; font-size: .875rem; }
.btn.wide { width: 100%; }
.btn.big { padding: 1em 1.4em; font-size: 1.125rem; }
.link { background: none; border: 0; color: var(--fog); text-decoration: underline; text-underline-offset: 3px; padding: .5em; }
.link:hover { color: var(--chalk); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--night-3); background: var(--night-2);
  display: inline-grid; place-items: center; font-weight: 600; padding: 0;
}

.field { display: grid; gap: .35rem; }
.field span, .emoji-pick legend, .join label, .clue-form label span { font-weight: 600; font-size: .9rem; color: var(--fog); }
input, select {
  background: var(--night); border: 1.5px solid var(--night-3); border-radius: 8px;
  padding: .7em .85em; width: 100%; min-width: 0;
}
input:focus, select:focus { border-color: var(--fog); outline: none; }

.avatar { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; font-size: 1.3rem; border-radius: 50%; background: var(--night-3); flex: none; }
.avatar.sm { width: 1.7rem; height: 1.7rem; font-size: 1rem; }
.avatar-btn .avatar { width: 100%; height: 100%; background: none; }

.emoji-pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-pick legend { margin-bottom: .4rem; }
.emoji-pick label { position: relative; }
.emoji-pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.emoji-pick span { display: grid; place-items: center; aspect-ratio: 1; font-size: 1.35rem; border-radius: 10px; border: 1.5px solid transparent; background: var(--night); }
.emoji-pick input:checked + span { border-color: var(--paper); background: var(--night-3); }
.emoji-pick input:focus-visible + span { outline: 3px solid #ffd166; }

/* ─── Start- und Profilseite ──────────────────────────────────────────────── */
.screen { min-height: 100vh; padding: max(24px, env(safe-area-inset-top)) 20px 40px; margin: 0 auto; }
.screen.narrow { max-width: 460px; display: grid; gap: 20px; align-content: start; padding-top: 48px; }
.panel { background: var(--night-2); border: 1px solid var(--night-3); border-radius: 16px; padding: 22px; display: grid; gap: 16px; }
.panel h2 { font-family: var(--cond); font-weight: 700; font-size: 1.75rem; }

.home { max-width: 560px; display: grid; gap: 28px; align-content: start; padding-top: clamp(32px, 9vh, 96px); }
.home-head { display: grid; gap: 14px; }
.lede { font-size: 1.15rem; color: var(--fog); max-width: 34ch; }
.me-chip {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--night-2); border: 1px solid var(--night-3); border-radius: 14px; padding: 12px 14px;
}
.me-text { display: grid; flex: 1; line-height: 1.25; }
.me-text small { color: var(--fog); }
.me-edit { color: var(--fog); font-size: .875rem; }
.home-actions { display: grid; gap: 22px; }
.join { display: grid; gap: .4rem; }
.join-row { display: flex; gap: 8px; }
.join-row input { font-family: var(--stencil); font-weight: 700; font-size: 1.5rem; letter-spacing: .25em; text-transform: uppercase; padding: .35em .6em; }
.join-row .btn { flex: none; }
.home > .link { justify-self: start; padding-left: 0; }
.local-note { font-size: .875rem; color: var(--fog); border-left: 3px solid var(--neutral); padding: 4px 0 4px 12px; }

/* ─── Raum: Kopfleiste ────────────────────────────────────────────────────── */
.room { max-width: 1240px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) clamp(10px, 2.5vw, 28px) 32px; }
.bar { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.bar-brand { font-family: var(--stencil); font-weight: 900; font-size: 1.35rem; background: none; border: 0; padding: 0; color: var(--chalk); }
.room-code {
  margin-left: auto; display: flex; align-items: baseline; gap: 8px;
  background: none; border: 1.5px dashed var(--night-3); border-radius: 10px; padding: 4px 12px;
}
.room-code small { color: var(--fog); font-size: .8rem; }
.room-code b { font-family: var(--stencil); font-weight: 900; font-size: 1.4rem; letter-spacing: .14em; }
.bar-actions { display: flex; gap: 8px; }
.banner { background: var(--night-2); border: 1px solid var(--night-3); border-radius: 10px; padding: 8px 12px; font-size: .875rem; color: var(--fog); margin-bottom: 10px; }
.banner.warn { border-color: #b98a1a; color: #ffd98a; }

/* ─── Punktestand ─────────────────────────────────────────────────────────── */
.score { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 12px; }
.tally {
  display: grid; justify-items: center; min-width: 68px; padding: 6px 12px 7px; border-radius: 12px;
  border: 2px solid transparent; transition: border-color .2s, background .2s;
}
.tally .num { font-family: var(--stencil); font-weight: 900; font-size: 2.4rem; line-height: .95; }
.tally .lbl { font-size: .8rem; font-weight: 600; opacity: .85; }
.tally.hide { visibility: hidden; }
.tally.t-red { color: #ff7b84; }
.tally.t-blue { color: #84aaff; }
.tally.active.t-red { background: var(--red); color: #fff; }
.tally.active.t-blue { background: var(--blue); color: #fff; }
.turn { display: grid; justify-items: center; text-align: center; line-height: 1.2; }
.turn b { font-family: var(--cond); font-weight: 700; font-size: clamp(1.3rem, 4.5vw, 1.8rem); }
.turn small { color: var(--fog); font-size: .9rem; }
.t-red > b, b.t-red { color: #ff7b84; }
.t-blue > b, b.t-blue { color: #84aaff; }

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.room-main { display: grid; gap: 18px; }
.stage { display: grid; gap: 14px; align-content: start; }
@media (min-width: 980px) {
  .room-main { grid-template-columns: minmax(0, 1fr) 290px; align-items: start; }
  .side { position: sticky; top: 16px; }
}

/* ─── Spielfeld ───────────────────────────────────────────────────────────── */
.board { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: var(--gap); }
.board.size-6, .board.size-7 { gap: clamp(4px, 1vw, 8px); }
.card {
  container-type: inline-size;
  position: relative; aspect-ratio: 1.3; border: 0; padding: 0 3px; overflow: hidden;
  border-radius: clamp(5px, 1.2vw, 10px);
  background: var(--paper);
  background-image: linear-gradient(180deg, transparent 62%, rgba(0, 0, 0, .05) 62%, rgba(0, 0, 0, .05) 64%, transparent 64%);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--paper-edge), 0 3px 10px rgba(0, 0, 0, .25);
  display: grid; place-items: center;
  transition: transform .12s ease, box-shadow .12s ease, opacity .2s;
  cursor: default;
}
.card .w {
  font-family: var(--cond); font-weight: 700; text-transform: uppercase; letter-spacing: .01em; line-height: 1;
  font-size: min(20cqi, calc(178cqi / var(--len)), 26px);
  max-width: 100%; overflow-wrap: anywhere; text-align: center;
}
.card .w.wrap { overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; line-height: .95; }
.size-6 .card .w { font-size: min(22cqi, calc(185cqi / var(--len)), 24px); }
.size-7 .card .w { font-size: min(25cqi, calc(190cqi / var(--len)), 22px); }
.board.guessing .card.can { cursor: pointer; }
.board.guessing .card.can:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--paper-edge), 0 8px 16px rgba(0, 0, 0, .3); }
.card.sel { outline: 3px solid #ffd166; outline-offset: 2px; transform: translateY(-2px); }
.card .confirm {
  position: absolute; bottom: 0; left: 0; right: 0; background: #ffd166; color: var(--ink);
  font-size: min(12cqi, 12px); font-weight: 700; padding: 2px 0; text-align: center;
}
/* Markierungen: für alle sichtbar */
.card.marked { outline: 3px solid #ffd166; outline-offset: 1px; transform: translateY(-2px); }
.card.marked.mine { outline-width: 4px; }
.card .marks {
  position: absolute; top: 2px; left: 2px; display: flex; flex-wrap: wrap; gap: 1px;
  font-size: min(15cqi, 17px); line-height: 1; max-width: calc(100% - 4px);
}
.card .marks i { font-style: normal; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.card .order {
  position: absolute; top: 2px; right: 2px; min-width: 1.5em; height: 1.5em; border-radius: 999px;
  display: grid; place-items: center; background: #ffd166; color: var(--ink);
  font: 700 min(13cqi, 13px)/1 var(--sans); padding: 0 .3em;
}
.size-7 .card .marks, .size-7 .card .order { font-size: min(18cqi, 12px); }
.card.pending { animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .55; } }

/* Ansicht des Chefs: verdeckte Karten mit Farbmarkierung */
.board.spy .card.key { box-shadow: inset 0 -7px 0 var(--k), 0 2px 0 var(--paper-edge), 0 3px 10px rgba(0, 0, 0, .25); }
.board.spy .card.k-red { --k: var(--red); background-color: #f1d9d8; }
.board.spy .card.k-blue { --k: var(--blue); background-color: #d6e0f4; }
.board.spy .card.k-neutral { --k: var(--neutral); }
.board.spy .card.k-assassin { --k: #000; background: #2a2a2a; color: var(--paper); }

/* Aufgedeckte Karten mit Stempel */
.card.rev { color: rgba(255, 255, 255, .55); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); }
.card.rev .w { font-size: min(13cqi, calc(120cqi / var(--len)), 15px); align-self: end; margin-bottom: 7cqi; }
.card.c-red { background: var(--red); }
.card.c-blue { background: var(--blue); }
.card.c-neutral { background: var(--neutral); color: rgba(40, 30, 10, .5); }
.card.c-assassin { background: var(--assassin); color: rgba(255, 255, 255, .45); }
.stamp {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -62%) rotate(-9deg);
  font-family: var(--stencil); font-weight: 900; text-transform: uppercase; letter-spacing: .04em; line-height: 1;
  font-size: min(21cqi, 30px); padding: .14em .3em .1em;
  border: max(2px, 1.6cqi) solid currentColor; border-radius: 4px;
  color: rgba(255, 255, 255, .92);
  white-space: nowrap;
}
.c-neutral .stamp { color: rgba(48, 36, 12, .78); }
.c-assassin .stamp { color: #ff4b55; font-size: min(14cqi, 20px); }
.card.just .stamp { animation: stamp .42s cubic-bezier(.2, 1.6, .4, 1) both; }
.card.just { animation: thud .42s ease-out both; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -62%) rotate(-20deg) scale(2.2); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, -62%) rotate(-9deg) scale(1); }
}
@keyframes thud { 0%, 30% { transform: scale(1); } 45% { transform: scale(.94); } 100% { transform: scale(1); } }
/* Am Ende: noch verdeckte Karten leicht zurücknehmen */
.board.spy .card.key:not(.rev) { opacity: .9; }

/* ─── Aktionsbereich ──────────────────────────────────────────────────────── */
.action { display: grid; gap: 10px; justify-items: center; text-align: center; min-height: 64px; }
.act-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.hint { color: var(--fog); font-size: .95rem; max-width: 52ch; }
.hint.error { color: #ff9aa0; }
.waiting { color: var(--fog); font-size: 1.05rem; padding: 10px 0; }
.clue-form { display: grid; grid-template-columns: 1fr 88px; gap: 10px; width: min(100%, 520px); text-align: left; }
.clue-form label { display: grid; gap: .3rem; }
.clue-form input { font-family: var(--cond); font-weight: 700; font-size: 1.4rem; text-transform: uppercase; padding: .35em .6em; }
.clue-form select { font-family: var(--stencil); font-weight: 900; font-size: 1.4rem; padding: .3em .5em; }
.clue-form .btn { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .clue-form { grid-template-columns: 1fr 88px auto; align-items: end; }
  .clue-form .btn { grid-column: auto; padding-block: .95em; }
}
.clue-show { display: inline-flex; align-items: stretch; border-radius: 12px; overflow: hidden; box-shadow: 0 3px 12px rgba(0, 0, 0, .3); }
.clue-show .clue-w { background: var(--paper); color: var(--ink); font-family: var(--cond); font-weight: 700; font-size: clamp(1.6rem, 6vw, 2.2rem); padding: .2em .6em; text-transform: uppercase; }
.clue-show .clue-n { font-family: var(--stencil); font-weight: 900; font-size: clamp(1.6rem, 6vw, 2.2rem); padding: .2em .5em; color: #fff; display: grid; place-items: center; }
.clue-show.t-red .clue-n { background: var(--red); }
.clue-show.t-blue .clue-n { background: var(--blue); }

/* ─── Lobby ───────────────────────────────────────────────────────────────── */
.lobby { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .lobby { grid-template-columns: 1fr 1fr; } }
.team-col { border-radius: 16px; padding: 16px; display: grid; gap: 14px; align-content: start; border: 2px solid; }
.team-col.t-red { border-color: var(--red); background: linear-gradient(180deg, rgba(211, 52, 63, .16), rgba(211, 52, 63, .04)); }
.team-col.t-blue { border-color: var(--blue); background: linear-gradient(180deg, rgba(46, 107, 230, .16), rgba(46, 107, 230, .04)); }
.team-col h3 { font-family: var(--stencil); font-weight: 900; font-size: 1.7rem; }
.team-col.t-red h3 { color: #ff7b84; }
.team-col.t-blue h3 { color: #84aaff; }
.slot { display: grid; gap: 6px; justify-items: start; }
.slot-lbl { font-size: .85rem; font-weight: 600; color: var(--fog); }
.empty { color: var(--fog); font-style: italic; font-size: .9rem; }
.loose { grid-column: 1 / -1; color: var(--fog); font-size: .9rem; }
.p-row { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.p-row.off { opacity: .45; }
.p-row em { color: var(--fog); font-style: normal; font-size: .85em; }
.p-off { font-size: .75rem; color: var(--fog); }
.p-name { font-weight: 500; }

/* ─── Bedenkzeit-Countdown ─────────────────────────────────────────────── */
.timer { display: flex; align-items: center; gap: 12px; width: min(100%, 520px); }
.timer-track { flex: 1; height: 8px; border-radius: 999px; background: var(--night-3); overflow: hidden; }
.timer-fill { display: block; height: 100%; width: 100%; transform-origin: left center; transition: transform .25s linear; border-radius: inherit; }
.timer.t-red .timer-fill { background: var(--red); }
.timer.t-blue .timer-fill { background: var(--blue); }
.timer-num {
  font-family: var(--stencil); font-weight: 900; font-size: 1.9rem; line-height: 1; min-width: 3.2ch; text-align: right;
  font-variant-numeric: tabular-nums;
}
.timer.low .timer-num { color: #ffd166; animation: tick 1s steps(1) infinite; }
.timer.low .timer-fill { background: #ffd166; }
.timer.done .timer-num { color: #ff7b84; animation: none; }
@keyframes tick { 50% { opacity: .45; } }

/* Nächste Karte in der Aufdeck-Reihe */
.card.next { animation: nextup .9s ease-in-out infinite alternate; }
@keyframes nextup { to { outline-color: #fff; transform: translateY(-4px); } }

/* ─── Einstellungen in der Lobby ─────────────────────────────────────────── */
.settings {
  grid-column: 1 / -1; background: var(--night-2); border: 1px solid var(--night-3); border-radius: 16px;
  padding: 14px 16px; display: grid; gap: 10px;
}
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.set-lbl { font-weight: 600; }
.set-note { color: var(--fog); font-size: .875rem; margin-top: -4px; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--night); border: 1.5px solid var(--night-3); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: none; border-radius: 999px; padding: .45em .95em;
  font-family: var(--stencil); font-weight: 700; font-size: 1.05rem; letter-spacing: .04em; color: var(--fog);
}
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.switch {
  width: 52px; height: 30px; border-radius: 999px; border: 1.5px solid var(--night-3); background: var(--night);
  position: relative; padding: 0; flex: none; transition: background .15s;
}
.switch span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--fog); transition: transform .15s, background .15s; }
.switch[aria-checked="true"] { background: #2f7d4f; border-color: #2f7d4f; }
.switch[aria-checked="true"] span { transform: translateX(22px); background: #fff; }

/* ─── Seitenleiste ────────────────────────────────────────────────────────── */
.side { display: grid; gap: 14px; }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pl { background: var(--night-2); border-radius: 12px; padding: 10px 12px; border-top: 4px solid; display: grid; gap: 4px; align-content: start; }
.pl.t-red { border-color: var(--red); }
.pl.t-blue { border-color: var(--blue); }
.pl h3 { font-family: var(--cond); font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.pl .p-row { font-size: .92rem; min-width: 0; }
.pl .p-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.badge { font-size: .72rem; font-weight: 600; background: var(--paper); color: var(--ink); border-radius: 999px; padding: 1px 7px; flex: none; }
.log { background: var(--night-2); border-radius: 12px; padding: 10px 12px; }
.log summary { font-family: var(--cond); font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.log ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow: auto; font-size: .9rem; }
.log li { border-left: 3px solid var(--night-3); padding-left: 8px; line-height: 1.35; }
.log li.t-red { border-color: var(--red); }
.log li.t-blue { border-color: var(--blue); }
.lg-who { color: var(--fog); }
.lg-res { font-size: .78rem; font-weight: 600; border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.lg-res.c-red { background: var(--red); color: #fff; }
.lg-res.c-blue { background: var(--blue); color: #fff; }
.lg-res.c-neutral { background: var(--neutral); color: var(--ink); }
.lg-res.c-assassin { background: #000; color: #ff4b55; }

/* ─── Overlays ────────────────────────────────────────────────────────────── */
#sheet-root { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#sheet-root.open { pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: rgba(5, 10, 20, .6); animation: fade .2s; }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 520px); max-height: 92vh; overflow: auto;
  background: var(--night-2); border: 1px solid var(--night-3); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 18px 20px max(24px, env(safe-area-inset-bottom));
  animation: rise .25s cubic-bezier(.2, .9, .3, 1);
}
@media (min-width: 640px) { .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 20px; border-bottom: 1px solid var(--night-3); animation: fade .2s; } }
.sheet header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet h2 { font-family: var(--cond); font-weight: 700; font-size: 1.6rem; }
.sheet-body, .sheet-body form { display: grid; gap: 16px; }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: min(240px, 70vw); justify-self: center; }
.qr svg { display: block; width: 100%; height: auto; }
.share-row { display: flex; gap: 8px; }
.share-row input { font-size: .85rem; }
.code-inline { font-family: var(--stencil); font-weight: 900; letter-spacing: .12em; font-size: 1.1em; }
.rules { display: grid; gap: 10px; }
.rules h3 { font-family: var(--cond); font-weight: 700; font-size: 1.2rem; margin-top: 6px; }
.rules ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%);
  background: var(--paper); color: var(--ink); font-weight: 600; padding: 10px 16px; border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4); transition: transform .25s cubic-bezier(.2, .9, .3, 1), opacity .25s, visibility .25s;
  z-index: 30; max-width: calc(100% - 32px); text-align: center; opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translate(-50%, 100%); } }

/* Kleine Handys */
@media (max-width: 420px) {
  .room-code small { display: none; }
  .bar { gap: 8px; }
  .tally { min-width: 54px; padding: 4px 8px; }
  .tally .num { font-size: 2rem; }
  .card { aspect-ratio: 1.12; }
}
/* Laptop & großes Tablet quer: Spielfeld passt in die Bildschirmhöhe */
@media (min-width: 980px) {
  .players { grid-template-columns: 1fr; }
  .stage { width: 100%; max-width: min(100%, calc((100vh - 270px) * 3.1)); justify-self: center; }
  .card { aspect-ratio: 1.6; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ─── Startseite: angedeutetes Spielfeld im Hintergrund ───────────────────── */
.home, .screen.narrow { position: relative; z-index: 1; }
body::before {
  content: ""; position: fixed; z-index: 0; pointer-events: none;
  inset: -6% -18% auto auto; width: min(760px, 135vw); aspect-ratio: 5 / 3.4;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500 340'%3E%3Cg%3E%3Crect x='4' y='4' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='104' y='4' width='92' height='60' rx='8' fill='%23d3343f'/%3E%3Crect x='204' y='4' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='304' y='4' width='92' height='60' rx='8' fill='%232e6be6'/%3E%3Crect x='404' y='4' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='4' y='72' width='92' height='60' rx='8' fill='%232e6be6'/%3E%3Crect x='104' y='72' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='204' y='72' width='92' height='60' rx='8' fill='%23c2ad86'/%3E%3Crect x='304' y='72' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='404' y='72' width='92' height='60' rx='8' fill='%23d3343f'/%3E%3Crect x='4' y='140' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='104' y='140' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='204' y='140' width='92' height='60' rx='8' fill='%23d3343f'/%3E%3Crect x='304' y='140' width='92' height='60' rx='8' fill='%23000'/%3E%3Crect x='404' y='140' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='4' y='208' width='92' height='60' rx='8' fill='%23c2ad86'/%3E%3Crect x='104' y='208' width='92' height='60' rx='8' fill='%232e6be6'/%3E%3Crect x='204' y='208' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='304' y='208' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='404' y='208' width='92' height='60' rx='8' fill='%232e6be6'/%3E%3Crect x='4' y='276' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='104' y='276' width='92' height='60' rx='8' fill='%23d3343f'/%3E%3Crect x='204' y='276' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3Crect x='304' y='276' width='92' height='60' rx='8' fill='%23c2ad86'/%3E%3Crect x='404' y='276' width='92' height='60' rx='8' fill='%23e6e9df'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  transform: rotate(-9deg); opacity: 0; transition: opacity .3s;
  -webkit-mask-image: linear-gradient(200deg, #000 30%, transparent 85%); mask-image: linear-gradient(200deg, #000 30%, transparent 85%);
}
body.on-home::before { opacity: .34; }
#app { position: relative; z-index: 1; }

/* Kopfzeile tiefer (iPhone-Erreichbarkeit) */
.room { padding-top: calc(env(safe-area-inset-top, 0px) + 22px); }
