/* =========================================================
   Wortwirbel – Karoblock & Würfel
   Hell: Karopapier mit Bleistift. Dunkel: Schiefertafel mit Kreide.
   Das Würfelbrett ist der Held, alles andere bleibt ruhig.
   ========================================================= */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo.woff2") format("woff2-variations"), url("/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Grundschrift";
  src: url("/fonts/grundschrift.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fdfeff;
  --paper-veil: rgba(253, 254, 255, 0.9);
  --grid: #dbe5f0;
  --margin: #ec5a63;
  --ink: #2d3137;
  --ink-soft: #59616c;
  --ink-faint: #8a93a0;
  --line: #2d3137;
  --line-soft: #c9d3de;
  --tray: #2347c5;
  --tray-hi: #3b62e3;
  --tray-lo: #15308f;
  --die: #fbfbf8;
  --die-shade: #ecebe5;
  --die-side: #cfccc2;
  --die-ink: #1f2125;
  --ok: #2b9a47;
  --warn: #d9800a;
  --bad: #dc3232;
  --p0: #e03131; --p1: #e8890c; --p2: #2f9e44; --p3: #7048e8; --p4: #0b7fab;
  --p0-ink: #c42727; --p1-ink: #a85a00; --p2-ink: #237a35; --p3-ink: #5a36cc; --p4-ink: #076887;
  --font-ui: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Grundschrift", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --cell: 20px;
  --topbar-h: 56px;
  --shadow-plastic: 0 3px 0 var(--tray-lo), 0 8px 18px -10px rgba(21, 48, 143, 0.7);
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1f2a27;
    --paper-veil: rgba(31, 42, 39, 0.92);
    --grid: rgba(226, 238, 232, 0.075);
    --margin: rgba(255, 128, 128, 0.55);
    --ink: #e8eee9;
    --ink-soft: #b5c1bb;
    --ink-faint: #82918a;
    --line: #dfe7e2;
    --line-soft: rgba(226, 238, 232, 0.18);
    --tray: #2443b8;
    --tray-hi: #3558d6;
    --tray-lo: #0f2270;
    --p0: #ff6b6b; --p1: #ffa94d; --p2: #51cf66; --p3: #9775fa; --p4: #3bc9db;
    --p0-ink: #ff8787; --p1-ink: #ffc078; --p2-ink: #69db7c; --p3-ink: #b197fc; --p4-ink: #66d9e8;
    --ok: #51cf66; --warn: #ffa94d; --bad: #ff6b6b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1f2a27;
  --paper-veil: rgba(31, 42, 39, 0.92);
  --grid: rgba(226, 238, 232, 0.075);
  --margin: rgba(255, 128, 128, 0.55);
  --ink: #e8eee9;
  --ink-soft: #b5c1bb;
  --ink-faint: #82918a;
  --line: #dfe7e2;
  --line-soft: rgba(226, 238, 232, 0.18);
  --tray: #2443b8;
  --tray-hi: #3558d6;
  --tray-lo: #0f2270;
  --p0: #ff6b6b; --p1: #ffa94d; --p2: #51cf66; --p3: #9775fa; --p4: #3bc9db;
  --p0-ink: #ff8787; --p1-ink: #ffc078; --p2-ink: #69db7c; --p3-ink: #b197fc; --p4-ink: #66d9e8;
  --ok: #51cf66; --warn: #ffa94d; --bad: #ff6b6b;
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  display: grid;
  grid-template-rows: auto 1fr;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h2 { font-size: 1.5625rem; font-weight: 750; font-stretch: 112%; letter-spacing: -0.01em; }
h3 { font-size: 1.25rem; font-weight: 700; }
:focus-visible { outline: 3px solid var(--tray-hi); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
[hidden] { display: none !important; }

.hint { margin: 0; font-size: 0.875rem; color: var(--ink-soft); }
.kicker { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--ink-soft); }
.hand { font-family: var(--font-hand); }

/* ---------- Kopfleiste ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  background: var(--paper-veil);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 2px dashed var(--line-soft); /* Perforation des Blocks */
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-die {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--die); color: var(--die-ink);
  font-weight: 850; font-stretch: 120%; font-size: 17px;
  box-shadow: 0 2px 0 var(--die-side), 0 0 0 2px var(--tray);
  transform: rotate(-6deg);
}
.brand-name { font-weight: 800; font-stretch: 118%; font-size: 1.15rem; letter-spacing: -0.01em; }
.topbar-mid { display: flex; gap: 8px; justify-content: center; min-width: 0; }
.topbar-actions { display: flex; gap: 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-size: 0.875rem; font-weight: 550;
  white-space: nowrap;
}
.chip b { font-weight: 800; font-stretch: 120%; letter-spacing: 0.06em; }
.chip-quiet { border-color: var(--line-soft); color: var(--ink-soft); }
.chip-warn { border-color: var(--warn); color: var(--warn); font-weight: 650; }
.chip-warn:hover { background: color-mix(in srgb, var(--warn) 10%, var(--paper)); }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--ink);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .slash { opacity: 0; }
.icon-btn[aria-pressed="false"] { color: var(--ink-faint); }
.icon-btn[aria-pressed="false"] .slash { opacity: 1; }
.icon-btn[aria-pressed="false"] .wave { opacity: 0; }
.icon-btn-quiet { color: var(--ink-soft); }

.menu {
  position: absolute; right: 12px; top: calc(var(--topbar-h) + 6px);
  width: min(300px, calc(100vw - 24px));
  padding: 14px;
  display: grid; gap: 12px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.35);
}
.menu-row { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 10px; font-size: 0.9375rem; }
.menu-row input[type="range"] { width: 100%; accent-color: var(--tray); }
.menu-link { text-align: left; border: 0; background: none; padding: 6px 0; font-weight: 600; color: var(--ink); }
.menu-link:hover { text-decoration: underline; }
.menu-danger { color: var(--bad); }

/* ---------- Bildschirme ---------- */
main { position: relative; min-height: 0; }
.screen { display: none; }
body[data-screen="start"] #screen-start,
body[data-screen="lobby"] #screen-lobby,
body[data-screen="game"] #screen-game,
body[data-screen="review"] #screen-review,
body[data-screen="scores"] #screen-scores,
body[data-screen="final"] #screen-final { display: block; animation: screen-in 220ms var(--ease-out); }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Bausteine ---------- */
.card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.sheet {
  background-color: var(--paper);
  /* roter Rand des Karoblocks */
  background-image: linear-gradient(90deg, transparent 47px, var(--margin) 47px, var(--margin) 49px, transparent 49px);
  border: 1.5px solid var(--line-soft);
  border-radius: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-weight: 650; font-size: 1rem;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 120ms ease;
  touch-action: manipulation;
  user-select: none;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 5%, var(--paper)); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary {
  border: 0;
  color: #fff;
  background: var(--tray);
  box-shadow: var(--shadow-plastic);
}
.btn-primary:hover { background: var(--tray-hi); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tray-lo); }
.btn-primary[aria-pressed="true"] { background: var(--ok); box-shadow: 0 3px 0 color-mix(in srgb, var(--ok) 60%, #000); }
.btn-ghost { border-color: var(--line-soft); }
.btn-big { min-height: 52px; font-size: 1.125rem; padding: 0 24px; font-weight: 750; font-stretch: 108%; }
.btn-text { border: 0; background: none; color: var(--ink-soft); text-decoration: underline; padding: 6px; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-size: 1.125rem;
}
.input::placeholder { color: var(--ink-faint); }
.input-hand { font-family: var(--font-hand); font-size: 1.25rem; padding-top: 10px; }
.input-code { width: 6.5em; text-transform: uppercase; font-weight: 800; font-stretch: 120%; letter-spacing: 0.18em; text-align: center; }

.field { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field-label { font-weight: 650; font-size: 0.9375rem; padding: 0; }

.seg {
  display: inline-flex; flex-wrap: wrap;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--paper);
}
.seg button {
  min-height: 38px; min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-left: 1.5px solid var(--line-soft);
  background: transparent;
  font-weight: 600; font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--tray); color: #fff; }
.seg button:disabled { cursor: default; }
.seg button:disabled:not([aria-checked="true"]) { color: var(--ink-faint); }
.seg-small button { min-height: 32px; min-width: 0; padding: 0 9px; font-size: 0.8125rem; }

/* Spielerfarben */
[data-slot="0"] { --pc: var(--p0); --pc-ink: var(--p0-ink); }
[data-slot="1"] { --pc: var(--p1); --pc-ink: var(--p1-ink); }
[data-slot="2"] { --pc: var(--p2); --pc-ink: var(--p2-ink); }
[data-slot="3"] { --pc: var(--p3); --pc-ink: var(--p3-ink); }
[data-slot="4"] { --pc: var(--p4); --pc-ink: var(--p4-ink); }
.board-wrap[data-slot=""] { --pc: var(--ink); } /* Wörter ohne Finder (Übersehen) in Bleistift */

.avatar {
  position: relative;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pc, var(--ink-faint)) 16%, var(--paper));
  box-shadow: inset 0 0 0 2.5px var(--pc, var(--ink-faint));
  font-size: 20px; line-height: 1;
}
.avatar.is-off { filter: grayscale(1); opacity: 0.5; }
.avatar.bump { animation: bump 380ms var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.22); } }

/* =========================================================
   Würfel & Brett
   ========================================================= */
.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  container-type: inline-size;
}
.tray {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n, 4), 1fr);
  grid-template-rows: repeat(var(--n, 4), 1fr);
  gap: calc(100cqi * 0.11 / var(--n, 4));
  padding: calc(100cqi * 0.045);
  border-radius: calc(100cqi * 0.06);
  background:
    radial-gradient(120% 90% at 30% 15%, var(--tray-hi), var(--tray) 55%, var(--tray-lo));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    inset 0 -7px 0 rgba(0, 0, 0, 0.22),
    0 16px 34px -16px rgba(21, 48, 143, 0.75);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.die {
  --rot: 0deg;
  position: relative;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 19%;
  background: linear-gradient(155deg, #ffffff 0%, var(--die) 48%, var(--die-shade) 100%);
  box-shadow:
    0 calc(100cqi * 0.012) 0 var(--die-side),
    0 calc(100cqi * 0.02) calc(100cqi * 0.02) -2px rgba(0, 0, 0, 0.38),
    inset 0 -2px 0 rgba(0, 0, 0, 0.05);
  color: var(--die-ink);
  font-weight: 860;
  font-stretch: 116%;
  font-size: calc(100cqi * 0.5 / var(--n, 4));
  line-height: 1;
  transform: rotate(var(--rot));
  transition: transform 90ms ease, box-shadow 90ms ease, background-color 90ms ease;
  cursor: pointer;
  touch-action: none;
}
.die .glyph {
  display: block;
  /* eingeprägte Buchstaben */
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.95), 0 -1px 0 rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.die.is-double .glyph { font-size: 0.74em; letter-spacing: -0.03em; }
.die.is-sel {
  background: linear-gradient(155deg, #ffffff 0%, color-mix(in srgb, var(--pc, var(--tray)) 22%, var(--die)) 100%);
  box-shadow:
    0 calc(100cqi * 0.004) 0 var(--die-side),
    0 0 0 calc(100cqi * 0.009) var(--pc, var(--tray-hi)),
    0 2px 6px -2px rgba(0, 0, 0, 0.35);
  transform: rotate(var(--rot)) translateY(calc(100cqi * 0.007)) scale(0.95);
}
.die.is-last { box-shadow: 0 calc(100cqi * 0.004) 0 var(--die-side), 0 0 0 calc(100cqi * 0.013) var(--pc, var(--tray-hi)), 0 2px 6px -2px rgba(0, 0, 0, 0.35); }
.die.flash-ok { animation: die-ok 420ms var(--ease-spring); background: linear-gradient(155deg, #fff, color-mix(in srgb, var(--ok) 35%, var(--die))); }
.die.flash-warn { animation: die-shake 360ms ease; background: linear-gradient(155deg, #fff, color-mix(in srgb, var(--warn) 30%, var(--die))); }
.die.flash-bad { animation: die-shake 360ms ease; background: linear-gradient(155deg, #fff, color-mix(in srgb, var(--bad) 28%, var(--die))); }
.die.flash-dup { animation: die-shake 300ms ease; filter: saturate(0.4) brightness(0.96); }
/* Tastatur-Cursor: gestrichelter Rahmen in der Spielerfarbe */
.die.is-cursor::after {
  content: "";
  position: absolute; inset: -9%;
  border: calc(100cqi * 0.008 + 1px) dashed var(--pc, var(--tray-hi));
  border-radius: 24%;
  pointer-events: none;
  animation: cursor-pulse 900ms ease-in-out infinite alternate;
}
.tray .die.is-cursor { z-index: 1; }
@keyframes cursor-pulse { from { opacity: 1; } to { opacity: 0.45; } }
.die.hl { box-shadow: 0 calc(100cqi * 0.004) 0 var(--die-side), 0 0 0 calc(100cqi * 0.01) var(--pc, var(--tray-hi)); }
.die.hl-first { background: linear-gradient(155deg, #fff, color-mix(in srgb, var(--pc, var(--tray-hi)) 30%, var(--die))); }
@keyframes die-ok { 0% { transform: rotate(var(--rot)) scale(0.95); } 45% { transform: rotate(var(--rot)) scale(1.1) translateY(-3px); } 100% { transform: rotate(var(--rot)); } }
@keyframes die-shake {
  0%, 100% { transform: rotate(var(--rot)) translateX(0); }
  20% { transform: rotate(var(--rot)) translateX(-5%); }
  40% { transform: rotate(var(--rot)) translateX(5%); }
  60% { transform: rotate(var(--rot)) translateX(-3%); }
  80% { transform: rotate(var(--rot)) translateX(2%); }
}

/* Würfeln: rütteln, dann setzen */
.tray.is-rolling .die { animation: rattle 140ms linear infinite alternate; animation-delay: var(--d, 0ms); }
.tray.is-rolling .die .glyph { opacity: 0; }
@keyframes rattle {
  0% { transform: translate(-3%, 2%) rotate(calc(var(--rot) - 9deg)); }
  50% { transform: translate(3%, -3%) rotate(calc(var(--rot) + 7deg)); }
  100% { transform: translate(-1%, 3%) rotate(calc(var(--rot) - 4deg)); }
}
.tray.is-settling .die { animation: settle 520ms var(--ease-spring) both; animation-delay: var(--d, 0ms); }
@keyframes settle {
  0% { transform: translateY(-14%) rotate(calc(var(--rot) + 24deg)) scale(1.12); }
  100% { transform: rotate(var(--rot)); }
}
.tray.is-locked .die { cursor: default; }

.trail {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}
.trail polyline {
  fill: none;
  stroke: var(--pc, var(--tray-hi));
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}
.trail circle { fill: var(--pc, var(--tray-hi)); opacity: 0.7; }
/* Live-Auswahl der anderen: dünne Linie in ihrer Farbe, Zeichen am Pfadende */
.trail .ghost polyline { opacity: 0.85; }
.trail .ghost circle { opacity: 0.95; }
.trail .ghost .ghost-badge { fill: var(--paper); stroke-width: 2px; opacity: 1; }
.trail .ghost text { opacity: 1; }

.countdown {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  font-weight: 900; font-stretch: 125%;
  font-size: 34cqi;
  color: var(--tray);
  -webkit-text-stroke: 0.08em #fff;
  paint-order: stroke fill;
  text-shadow: 0 0.05em 0.12em rgba(10, 20, 60, 0.35);
}
.countdown span { animation: count-in 900ms var(--ease-out) both; }
@keyframes count-in { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(0.85); opacity: 0; } }

.board-small .die { cursor: default; }

/* =========================================================
   Start
   ========================================================= */
#screen-start { padding: 28px 16px 48px; }
.start-hero { display: grid; justify-items: center; gap: 18px; margin: 8px auto 26px; max-width: 720px; text-align: center; }
.title-tray {
  display: grid; gap: 10px; justify-items: center;
  padding: 18px 20px 20px;
  border-radius: 22px;
  background: radial-gradient(120% 90% at 30% 15%, var(--tray-hi), var(--tray) 55%, var(--tray-lo));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18), inset 0 -7px 0 rgba(0, 0, 0, 0.22), 0 18px 34px -16px rgba(21, 48, 143, 0.75);
  container-type: inline-size;
  width: min(100%, 560px);
}
.title-row { display: flex; gap: 2.2cqi; justify-content: center; }
.title-tray .die {
  width: 13.4cqi; height: 13.4cqi;
  font-size: 7.6cqi;
  box-shadow: 0 1.1cqi 0 var(--die-side), 0 1.6cqi 1.6cqi -2px rgba(0, 0, 0, 0.38);
}
.title-tray .die.is-sel { transform: rotate(var(--rot)) translateY(0.6cqi) scale(0.94); }
.title-tray.is-rolling .die { animation: rattle 130ms linear infinite alternate; }
.title-tray.is-settling .die { animation: settle 600ms var(--ease-spring) both; animation-delay: var(--d, 0ms); }
.tagline { margin: 0; max-width: 46ch; font-size: 1.125rem; color: var(--ink-soft); }
.tagline span { display: block; }

.start-card { width: min(100%, 520px); margin: 0 auto; display: grid; gap: 20px; }
.avatar-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.avatar-grid button {
  aspect-ratio: 1;
  min-width: 0; width: 100%; padding: 0;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-size: 22px; line-height: 1;
  display: grid; place-items: center;
  transition: transform 100ms ease;
}
.avatar-grid button:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.avatar-grid button[aria-checked="true"] { border-color: var(--tray); background: color-mix(in srgb, var(--tray) 12%, var(--paper)); transform: scale(1.06); }
.start-actions { display: grid; gap: 14px; }
.join-row { display: flex; gap: 8px; }
.join-row .input-code { flex: 1; }
.join-invite { display: grid; gap: 10px; text-align: center; }
.join-invite p { margin: 0; font-size: 1.0625rem; }
.join-invite b { font-weight: 800; font-stretch: 120%; letter-spacing: 0.08em; }

/* =========================================================
   Lobby
   ========================================================= */
#screen-lobby { padding: 24px 16px 40px; }
.lobby-grid {
  max-width: 1080px; margin: 0 auto;
  display: grid; gap: 20px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 880px) {
  .lobby-grid { grid-template-columns: 300px minmax(0, 1fr) minmax(0, 1.25fr); align-items: start; }
}
.lobby-code { display: grid; gap: 12px; justify-items: start; align-content: start; }
.code-dice { display: flex; gap: 10px; container-type: normal; }
.code-dice .die {
  width: 58px; height: 58px; font-size: 32px;
  box-shadow: 0 4px 0 var(--die-side), 0 6px 8px -2px rgba(0, 0, 0, 0.35), 0 0 0 2px var(--tray);
}
.lobby-players h2, .lobby-settings h2 { margin-bottom: 14px; }
.count { font-weight: 500; color: var(--ink-faint); font-stretch: 100%; font-size: 1rem; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.player-list li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  min-height: 52px; padding: 6px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.player-list li:last-child { border-bottom: 0; }
.player-list .pname { font-family: var(--font-hand); font-size: 1.25rem; color: var(--pc-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 4px; }
.player-list .tag { font-size: 0.8125rem; color: var(--ink-soft); }
.player-list .kick { border: 0; background: none; color: var(--ink-faint); font-size: 0.8125rem; text-decoration: underline; }
.player-list li.empty { color: var(--ink-faint); font-size: 0.9375rem; grid-template-columns: auto 1fr; }
.player-list li.empty .avatar { box-shadow: inset 0 0 0 2px var(--line-soft); background: transparent; }
.settings { display: grid; gap: 14px; margin-bottom: 20px; }
.setting .seg { display: flex; }
.setting .seg button { flex: 1 1 auto; }
.setting { display: grid; gap: 6px; }
.setting-label { font-weight: 650; font-size: 0.9375rem; }
#btn-start { width: 100%; }
#wait-host { margin-top: 10px; text-align: center; }

/* =========================================================
   Spiel
   ========================================================= */
#screen-game { padding: 12px 14px 24px; }
.game-grid {
  max-width: 1600px; margin: 0 auto;
  display: grid; gap: 12px 14px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "clock" "play" "lists";
}
.game-clock { grid-area: clock; display: flex; align-items: center; gap: 14px; }
.board-total { font-size: 0.8125rem; color: var(--ink-faint); white-space: nowrap; }
.play-zone { grid-area: play; display: grid; justify-items: center; gap: 10px; min-width: 0; }
.play-zone .board-wrap { width: min(100%, 560px, calc(100dvh - var(--topbar-h) - 240px)); min-width: min(100%, 280px); }

/* Geteilte Wortlisten: eigene zuerst, die anderen drumherum */
.plists { grid-area: lists; display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) and (max-width: 999px) { .plists { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.plist {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; max-height: 34vh;
  padding: 8px 10px 10px;
  border: 1.5px solid var(--line-soft);
  border-radius: 12px;
  background: var(--paper);
}
.plist.is-me { border-color: color-mix(in srgb, var(--pc) 55%, var(--line-soft)); }
.plist-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 6px; margin-bottom: 6px;
  border-bottom: 2px solid var(--pc);
}
.plist-head .avatar { width: 30px; height: 30px; font-size: 16px; }
.plist-head .pname { min-width: 0; padding-top: 3px; font-family: var(--font-hand); font-size: 1.15rem; color: var(--pc-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist-head .plive {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 800; font-stretch: 112%; font-size: 0.875rem; letter-spacing: 0.06em;
  color: var(--pc-ink); text-align: right;
}
.plist-head .plive:not(:empty)::after { content: "▍"; margin-left: 1px; animation: caret 900ms steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.plist-head .pscore { margin-left: auto; display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.plist-head .pscore b { font-weight: 850; font-stretch: 118%; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.plist-head .pscore small { font-size: 0.75rem; color: var(--ink-faint); }
.pwords {
  list-style: none; margin: 0; padding: 0;
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0 12px;
}
.pw { display: inline-flex; align-items: baseline; gap: 1px; padding: 0 3px; border-radius: 6px; font-family: var(--font-hand); font-size: 1.1rem; line-height: 1.65; color: var(--ink); }
.plist.is-me .pw { font-size: 1.22rem; }
.pw sup { font-family: var(--font-ui); font-size: 0.6875rem; font-weight: 650; color: var(--ink-faint); }
.pw.is-new { animation: pw-in 1400ms ease-out; }
.pw.is-new .w { animation: write 420ms steps(9, end) both; }
.pw.is-proposal .w { color: var(--warn); text-decoration: underline dashed 1.5px; text-underline-offset: 4px; }
.pw.is-proposal sup { color: var(--warn); }
.pw.is-pending { opacity: 0.65; }
.pw.flash { animation: pw-flash 1100ms ease-out; }
.pw .rm { border: 0; background: none; padding: 0 2px 0 4px; color: var(--ink-faint); font-family: var(--font-ui); font-size: 1rem; line-height: 1; }
.pwords .empty { color: var(--ink-faint); font-size: 0.875rem; padding-top: 2px; }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes pw-in { 0% { background: color-mix(in srgb, var(--pc) 30%, transparent); } 100% { background: transparent; } }
@keyframes pw-flash {
  0%, 55% { background: color-mix(in srgb, var(--pc) 32%, transparent); box-shadow: 0 0 0 2px var(--pc); }
  100% { background: transparent; box-shadow: 0 0 0 2px transparent; }
}

/* Breite Bildschirme: Brett in der Mitte, eigene Liste oben links */
@media (min-width: 1000px) {
  #screen-game { padding: 12px 16px 16px; }
  .game-grid {
    height: calc(100dvh - var(--topbar-h) - 28px);
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "l1 clock r1" "l1 play r1";
  }
  .game-grid[data-count="1"] { grid-template-areas: "l1 clock ." "l1 play ."; }
  .game-grid[data-count="3"] { grid-template-rows: auto 1fr 1fr; grid-template-areas: "l1 clock r1" "l1 play r1" "l2 play r1"; }
  .game-grid[data-count="4"] { grid-template-rows: auto 1fr 1fr; grid-template-areas: "l1 clock r1" "l1 play r1" "l2 play r2"; }
  .game-grid[data-count="5"] { grid-template-rows: auto 1fr 1fr 1fr; grid-template-areas: "l1 clock r1" "l1 play r1" "l2 play r2" "l3 play r2"; }
  .plists { display: contents; }
  .plist { max-height: none; }
  .plist[data-pos="l1"] { grid-area: l1; }
  .plist[data-pos="r1"] { grid-area: r1; }
  .plist[data-pos="l2"] { grid-area: l2; }
  .plist[data-pos="r2"] { grid-area: r2; }
  .plist[data-pos="l3"] { grid-area: l3; }
  .game-clock { flex-direction: column; align-items: stretch; gap: 4px; }
  .board-total { text-align: right; margin-top: -2px; }
  .play-zone { align-self: start; align-content: start; }
  .play-zone .board-wrap { width: min(calc(100vw - 2 * 240px - 80px), calc(100dvh - var(--topbar-h) - 230px), 660px); }
  .current-actions { min-height: 0; }
}
/* Mit Maus und echter Tastatur braucht es den Tastatur-Knopf nicht */
@media (pointer: fine) { #btn-keyboard { display: none; } }

/* Schmale Listen (Handy, Tablet): kompakter Kopf, kleinere Schrift */
@media (max-width: 999px) {
  .plist { padding: 6px 8px 8px; }
  .plist-head { gap: 6px; }
  .plist-head .avatar { width: 26px; height: 26px; font-size: 14px; }
  .plist-head .pname { font-size: 1.05rem; }
  .plist-head .pscore small { display: none; }
  .plist-head .pscore b { font-size: 1.1rem; }
  .pw, .plist.is-me .pw { font-size: 1rem; line-height: 1.55; }
  .pwords { gap: 0 8px; }
}

.clock { flex: 1; display: grid; gap: 6px; min-width: 120px; }
.clock-time {
  font-weight: 850; font-stretch: 125%;
  font-size: 2.6rem; line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.clock-bar { height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.clock-bar i { display: block; height: 100%; width: 100%; background: var(--tray); transform-origin: left center; border-radius: inherit; }
.clock.is-hurry .clock-time { color: var(--bad); }
.clock.is-hurry .clock-bar i { background: var(--bad); }
.clock.is-final .clock-time { animation: tick-pulse 1s steps(1) infinite; }
@keyframes tick-pulse { 0% { transform: scale(1.06); } 30% { transform: scale(1); } }

.current {
  min-height: 1.3em;
  font-weight: 860; font-stretch: 118%;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink);
}
.current.is-offboard { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 3px; }
.current.shake { animation: shake-x 360ms ease; }
.current .ghost { color: var(--ink-faint); font-weight: 500; font-size: 0.55em; letter-spacing: 0; font-stretch: 100%; }
@keyframes shake-x { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.current-actions { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.kbd-input {
  position: absolute; left: 50%; bottom: 0;
  width: 1px; height: 1px; opacity: 0; border: 0; padding: 0;
  pointer-events: none;
}

.stamp {
  position: fixed; left: 50%; top: 45%;
  z-index: 40;
  padding: 10px 26px;
  border: 5px solid var(--bad);
  border-radius: 12px;
  color: var(--bad);
  background: var(--paper);
  font-weight: 900; font-stretch: 125%;
  font-size: clamp(2rem, 8vw, 3.6rem);
  transform: translate(-50%, -50%) rotate(-8deg);
  opacity: 0; pointer-events: none;
}
.stamp.show { animation: stamp 1500ms var(--ease-out) both; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(2.2); }
  18% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
}

/* Punkte-Popup */
.pop-pts {
  position: fixed; z-index: 45;
  pointer-events: none;
  font-weight: 900; font-stretch: 125%;
  font-size: 1.6rem;
  color: var(--ok);
  text-shadow: 0 2px 0 var(--paper);
  animation: pop-pts 800ms var(--ease-out) forwards;
}
@keyframes pop-pts { 0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; } 20% { transform: translate(-50%, -14px) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -56px) scale(1); opacity: 0; } }

/* =========================================================
   Abgleich
   ========================================================= */
#screen-review, #screen-scores, #screen-final { padding: 16px 14px 96px; }
.review-grid { max-width: 1240px; margin: 0 auto; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .review-grid { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
  .review-side { position: sticky; top: calc(var(--topbar-h) + 16px); }
}
.review-side { display: grid; gap: 10px; justify-items: center; }
.board-small { width: min(100%, 300px); }
.review-side .board-small { width: min(100%, 260px); }
.review-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.review-timer { font-weight: 800; font-stretch: 120%; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

.disputes { display: grid; gap: 10px; margin-bottom: 16px; }
.disputes:empty { display: none; }
.dispute {
  display: grid; gap: 8px 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 12px 14px;
  border: 1.5px solid var(--warn);
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 7%, var(--paper));
}
.dispute.is-objection { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 6%, var(--paper)); }
.dispute .dw { font-family: var(--font-hand); font-size: 1.45rem; line-height: 1.3; cursor: pointer; }
.dispute .dmeta { font-size: 0.875rem; color: var(--ink-soft); }
.dispute .voters { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; }
.voter { position: relative; }
.voter .avatar { width: 30px; height: 30px; font-size: 16px; }
.voter .mark {
  position: absolute; right: -4px; bottom: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 900; color: #fff;
  background: var(--ink-faint);
}
.voter .mark.yes { background: var(--ok); }
.voter .mark.no { background: var(--bad); }
.vote-btns { display: flex; gap: 6px; }
.vote-btns .btn { min-height: 40px; padding: 0 14px; }
.vote-btns .btn[aria-pressed="true"].yes { background: var(--ok); color: #fff; border-color: var(--ok); }
.vote-btns .btn[aria-pressed="true"].no { background: var(--bad); color: #fff; border-color: var(--bad); }
.vote-fixed { font-size: 0.875rem; color: var(--ink-soft); }

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.col { padding: 10px 12px 12px; border-radius: 12px; border: 1.5px solid var(--line-soft); background: var(--paper); min-width: 0; }
.col-head { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 2px solid var(--pc); }
.col-head .pname { font-family: var(--font-hand); font-size: 1.15rem; color: var(--pc-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 3px; }
.col-head .meta { margin-left: auto; font-size: 0.8125rem; color: var(--ink-faint); white-space: nowrap; }
.col ul { list-style: none; margin: 0; padding: 0; }
.col li { position: relative; }
.rw {
  display: flex; align-items: baseline; gap: 6px; width: 100%;
  min-height: calc(var(--cell) * 1.8);
  padding: 2px 4px;
  border: 0; border-radius: 6px;
  background: none;
  text-align: left;
  font-family: var(--font-hand); font-size: 1.15rem;
  color: var(--pc-ink);
}
.rw:hover { background: color-mix(in srgb, var(--pc) 9%, transparent); }
.rw.is-active { background: color-mix(in srgb, var(--pc) 16%, transparent); }
.rw .t { position: relative; overflow-wrap: anywhere; }
.rw .tag { margin-left: auto; font-family: var(--font-ui); font-size: 0.75rem; color: var(--ink-faint); white-space: nowrap; }
.rw.is-dup .t, .rw.is-struck .t, .rw.is-rejected .t { color: var(--ink-faint); }
.rw.is-proposal .t { text-decoration: underline dashed 1.5px var(--warn); text-underline-offset: 5px; }
.rw.is-objected .t { text-decoration: underline wavy 1.5px var(--bad); text-underline-offset: 5px; }
/* Bleistift-Durchstreichung */
.rw .strike {
  position: absolute; left: -3px; top: 52%;
  width: calc(100% + 6px); height: 10px; transform: translateY(-50%);
  overflow: visible; pointer-events: none;
}
.rw .strike path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 220; stroke-dashoffset: 220; animation: strike 380ms ease-out forwards; animation-delay: var(--d, 0ms); }
.rw.is-struck .strike path, .rw.is-rejected .strike path { stroke: var(--bad); }
@keyframes strike { to { stroke-dashoffset: 0; } }
.object-btn {
  position: absolute; right: 0; top: 100%; z-index: 5;
  border: 1.5px solid var(--bad); border-radius: 999px;
  background: var(--paper); color: var(--bad);
  font-size: 0.8125rem; font-weight: 700;
  padding: 5px 12px;
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.4);
}
.col .none { color: var(--ink-faint); font-size: 0.875rem; padding: 6px 4px; }

.screen-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--paper-veil);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 2px dashed var(--line-soft);
}
.foot-info { margin-right: auto; font-size: 0.9375rem; color: var(--ink-soft); }
.emotes { display: flex; gap: 2px; }
.emotes button { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; font-size: 20px; line-height: 1; transition: transform 90ms ease; }
.emotes button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.emotes button:active { transform: scale(0.85); }
@media (max-width: 560px) {
  .screen-foot { flex-wrap: wrap; }
  .emotes { width: 100%; justify-content: center; }
  .foot-info { font-size: 0.8125rem; }
}
.float-emote {
  position: fixed; z-index: 60; pointer-events: none;
  font-size: 34px; line-height: 1;
  animation: float-emote 1700ms var(--ease-out) forwards;
}
@keyframes float-emote {
  0% { transform: translate(-50%, 0) scale(0.4); opacity: 0; }
  15% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -150px) scale(1); opacity: 0; }
}

/* =========================================================
   Wertung & Endstand
   ========================================================= */
.scores-grid { max-width: 1080px; margin: 0 auto; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .scores-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }
.scores-card h2 { margin-bottom: 14px; }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ranking li {
  display: grid;
  grid-template-columns: 26px auto minmax(0, 1fr) auto;
  grid-template-areas: "place av name total" "place av info total";
  align-items: center; column-gap: 12px;
  padding: 8px 4px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.ranking li:last-child { border-bottom: 0; }
.ranking .place { grid-area: place; font-weight: 850; font-stretch: 120%; color: var(--ink-faint); text-align: center; }
.ranking .avatar { grid-area: av; }
.ranking .pname { grid-area: name; font-family: var(--font-hand); font-size: 1.3rem; color: var(--pc-ink); padding-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .info { grid-area: info; font-size: 0.875rem; color: var(--ink-soft); }
.ranking .info .best { font-family: var(--font-hand); color: var(--ink); }
.ranking .total { grid-area: total; text-align: right; }
.ranking .total b { display: block; font-weight: 850; font-stretch: 122%; font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; }
.ranking .total small { font-size: 0.875rem; font-weight: 700; color: var(--ok); }
.ranking li.is-first .place { color: var(--tray); }
.found-info { margin: 14px 0 0; color: var(--ink-soft); }
.missed-zone { display: grid; gap: 12px; justify-items: center; }
.missed-zone h3 { justify-self: start; }
.missed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; justify-self: stretch; }
.missed-list button {
  border: 0; border-radius: 6px; background: none;
  padding: 2px 6px;
  font-family: var(--font-hand); font-size: 1.12rem; color: var(--ink-soft);
}
.missed-list button:hover, .missed-list button.is-active { background: color-mix(in srgb, var(--tray) 12%, transparent); color: var(--ink); }
.missed-list .len { font-family: var(--font-ui); font-size: 0.6875rem; color: var(--ink-faint); margin-left: 3px; }

.final-title { text-align: center; font-size: 2.4rem; font-stretch: 125%; font-weight: 850; margin: 8px 0 18px; }
.podium {
  display: grid; grid-template-columns: repeat(3, minmax(0, 150px)); justify-content: center; align-items: end;
  gap: 12px; margin: 0 auto 20px;
}
.podium .spot { display: grid; justify-items: center; gap: 8px; }
.podium .avatar { width: 58px; height: 58px; font-size: 30px; }
.podium .pname { font-family: var(--font-hand); font-size: 1.3rem; color: var(--pc-ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 4px; }
.podium .block {
  width: 100%;
  display: grid; place-items: center;
  border-radius: 14px 14px 6px 6px;
  background: radial-gradient(120% 90% at 30% 15%, var(--tray-hi), var(--tray) 55%, var(--tray-lo));
  color: #fff;
  font-weight: 900; font-stretch: 125%; font-size: 1.6rem;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2), inset 0 -6px 0 rgba(0, 0, 0, 0.2);
  transform-origin: bottom;
  animation: rise 700ms var(--ease-spring) both;
}
.podium .p1 .block { height: 150px; animation-delay: 500ms; }
.podium .p2 .block { height: 110px; animation-delay: 250ms; }
.podium .p3 .block { height: 80px; }
.podium .block small { display: block; font-size: 0.875rem; font-weight: 600; font-stretch: 100%; opacity: 0.85; text-align: center; }
@keyframes rise { from { transform: scaleY(0); } }
.final-rest { list-style: none; padding: 0; margin: 0 auto; max-width: 420px; display: grid; gap: 6px; }
.final-rest li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.final-rest .pname { font-family: var(--font-hand); font-size: 1.15rem; color: var(--pc-ink); flex: 1; padding-top: 3px; }
.final-rest b { font-weight: 800; font-stretch: 118%; }

/* Konfetti (Papierschnipsel) */
.confetti { position: fixed; top: -20px; z-index: 55; pointer-events: none; width: 10px; height: 14px; border-radius: 2px; animation: fall var(--t, 2400ms) cubic-bezier(0.3, 0.6, 0.5, 1) forwards; }
@keyframes fall { to { transform: translate(var(--dx, 0), 110vh) rotate(var(--r, 540deg)); } }

/* ---------- Dialog, Toast, Verbindung ---------- */
.dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 22px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(10, 18, 40, 0.45); }
.dialog h2 { margin-bottom: 12px; }
.rules-list { margin: 0 0 12px; padding-left: 1.3em; display: grid; gap: 8px; max-width: 70ch; }
.dialog .btn { margin-top: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 70;
  transform: translate(-50%, 20px);
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: 0.9375rem;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.conn {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + 8px); z-index: 80;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bad); color: #fff;
  font-weight: 650; font-size: 0.875rem;
}
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

@media (max-width: 899px) {
  .play-zone .current { order: -1; min-height: 1.25em; }
  .play-zone { gap: 6px; }
}
@media (max-width: 560px) {
  #screen-review, #screen-scores, #screen-final { padding-bottom: 150px; }
  .missed-zone .board-small { width: min(100%, 240px); }
}
@media (max-width: 520px) {
  :root { --topbar-h: 52px; }
  .topbar { gap: 8px; }
  .topbar-mid { justify-content: flex-start; overflow: hidden; }
  .topbar-mid .chip-quiet { display: none; }
  .chip { height: 30px; padding: 0 10px; font-size: 0.8125rem; }
  .brand-name { display: none; }
  .clock-time { font-size: 2.1rem; }
  .card { padding: 16px; }
  .avatar-grid { gap: 2px; }
  .avatar-grid button { font-size: 20px; }
  .code-dice .die { width: 52px; height: 52px; font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .tray.is-rolling .die .glyph { opacity: 1; }
}
.rw .strike.instant path { animation: none; stroke-dashoffset: 0; }
