:root {
  --bg: #e9efee; --bg2: #dfe8e6; --panel: #f8fbfa; --fg: #12262a; --muted: #57707a; --line: #cbd8d6;
  --tray: #17403f; --tray2: #0f2e2d; --die: #f5f0e1; --die-edge: #cfc6aa; --die-fg: #15262b;
  --sel: #f2b134; --sel-fg: #231800; --sel-edge: #b57f10;
  --good: #1c7f47; --bad: #b8402d; --accent: #1d6c75; --accent-fg: #fff;
  --p0: #2f5fc4; --p1: #e0861f; --p2: #2e9a5a; --p3: #c2417a; --p4: #7b52c9; --p5: #148a96; --p6: #b3542c; --p7: #6b7a2a;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 6px 20px rgb(16 40 44 / .07);
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, sans-serif;
  --font-tile: 'Lexend', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1618; --bg2: #0f1d20; --panel: #132326; --fg: #e2eeed; --muted: #8aa7ab; --line: #24403f;
    --tray: #0d2e2d; --tray2: #071a1a; --die: #ebe5d2; --die-edge: #a49c83;
    --good: #4cc27f; --bad: #ff8d79; --accent: #5cc0c8; --accent-fg: #06191b;
    --p0: #86a8ff; --p1: #f2a64a; --p2: #5fd08f; --p3: #f07bb0; --p4: #b195ff; --p5: #4fd0dc; --p6: #f08a5d; --p7: #c3d26a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100dvh; color: var(--fg);
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg2), var(--bg));
  font: 16px/1.45 var(--font-body);
  padding: 16px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
.wrap { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-weight: 800; font-size: 2.2rem; letter-spacing: -.02em; }
h2 { font-weight: 700; font-size: 1.35rem; }
h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: var(--font-body); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; text-decoration: none; color: inherit; }
.logo i { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 28px; height: 28px; padding: 3px; background: var(--tray); border-radius: 7px; }
.logo i b { background: var(--die); border-radius: 3px; }
.logo i b:nth-child(2) { background: var(--sel); }
.user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }

label.f { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .92rem; }
input, select {
  font: inherit; font-weight: 400; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
input.code { font-family: var(--font-tile); font-size: 1.3rem; letter-spacing: .3em; text-transform: uppercase; text-align: center; }

button {
  font: inherit; font-weight: 700; color: var(--fg); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 16px; cursor: pointer; transition: transform .08s, background .15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.big { padding: 15px; font-size: 1.1rem; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--fg); box-shadow: var(--shadow); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 0; background: none; padding: 8px 4px; margin-right: 14px; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--fg); border-color: var(--accent); }

.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }

/* Spieler */
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); flex: none; }
.players { display: flex; flex-direction: column; gap: 2px; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.player:last-child { border-bottom: 0; }
.player .name { flex: 1; font-weight: 600; }
.player.off .name { color: var(--muted); }
.badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--pc); color: #fff; font-weight: 800; font-size: .9rem; flex: none; }

.roomcode { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.roomcode .code { font-family: var(--font-tile); font-weight: 700; font-size: 2rem; letter-spacing: .25em; }

/* Spielansicht */
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.time { font-family: var(--font-tile); font-weight: 700; font-size: 1.9rem; font-variant-numeric: tabular-nums; text-align: center; }
.time.low { color: var(--bad); animation: pulse 1s infinite; }
.hud .pts { text-align: right; font-weight: 800; font-size: 1.3rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hud .pts small { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); }
.ticker { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.ticker .t { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ticker .t b { font-weight: 800; }
.ticker .t.lead { border-color: var(--sel); }

.current { min-height: 2.8rem; display: flex; align-items: center; justify-content: center; text-align: center; }
.current .word { font-family: var(--font-tile); font-weight: 700; font-size: 1.7rem; letter-spacing: .08em; text-transform: uppercase; }
.current .msg { font-weight: 700; animation: pop .25s ease-out; }
.current .ok { color: var(--good); } .current .no { color: var(--bad); } .current .hint { color: var(--muted); font-weight: 400; }

.boardbox { position: relative; }
.board {
  position: relative; display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 9px; padding: 11px; aspect-ratio: 1; width: 100%;
  background: linear-gradient(160deg, var(--tray), var(--tray2)); border-radius: 20px;
  box-shadow: inset 0 2px 8px rgb(0 0 0 / .35), var(--shadow);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.die {
  display: grid; place-items: center; background: var(--die); color: var(--die-fg); border-radius: 14px;
  box-shadow: 0 4px 0 var(--die-edge), 0 6px 10px rgb(0 0 0 / .25);
  font: 700 clamp(1.7rem, 10vw, 2.8rem) var(--font-tile); transition: transform .08s, background .08s, box-shadow .08s;
}
.die.sel { background: var(--sel); color: var(--sel-fg); transform: translateY(3px); box-shadow: 0 1px 0 var(--sel-edge); }
.die.roll { animation: roll .5s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i) * 25ms); }
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board svg polyline { fill: none; stroke: var(--sel); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.board.covered .die { color: transparent; }
.cover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-radius: 20px; background: color-mix(in srgb, var(--tray2) 82%, transparent); color: #fff; text-align: center; padding: 16px;
  backdrop-filter: blur(3px);
}
.cover .count { font: 800 5rem/1 var(--font-display); animation: pop .4s ease-out; }

.found { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: .93rem; }
.chip small { opacity: .7; margin-left: 4px; font-weight: 400; }
.chip.new { animation: pop .3s ease-out; }
.chip.mine { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip.shared { background: var(--good); border-color: var(--good); color: var(--bg); }
.chip.other { background: color-mix(in srgb, var(--p1) 22%, var(--panel)); border-color: var(--p1); }
.chip.none { color: var(--muted); }
.chip.void { text-decoration: line-through; }

/* Ergebnis */
.podium { display: flex; flex-direction: column; gap: 8px; }
.rank { display: grid; grid-template-columns: 2rem 32px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.rank.first { background: color-mix(in srgb, var(--sel) 20%, var(--panel)); border: 1px solid var(--sel); }
.rank .pos { font: 800 1.2rem var(--font-display); text-align: center; }
.rank .sc { font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; text-align: right; }
.rank .sc small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.mini { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 3px; width: 92px; padding: 4px; background: var(--tray); border-radius: 8px; }
.mini span { aspect-ratio: 1; display: grid; place-items: center; background: var(--die); color: var(--die-fg); border-radius: 4px; font: 700 .7rem var(--font-tile); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font: 800 1.5rem var(--font-display); }
.stat span { font-size: .8rem; color: var(--muted); }
.hist { display: flex; flex-direction: column; }
.hist div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.hist div:last-child { border-bottom: 0; }

details summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.unkrow { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.unkrow button { padding: 6px 12px; font-size: .88rem; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); animation: pop .2s ease-out; z-index: 10; }

@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes roll { from { transform: rotate(-25deg) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* Admin */
.user a { color: var(--accent); font-weight: 700; text-decoration: none; }
.admin-list { display: flex; flex-direction: column; }
.admin-user { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.admin-user:last-child { border-bottom: 0; }
.admin-user.off b { color: var(--muted); text-decoration: line-through; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-actions button { padding: 6px 10px; font-size: .85rem; font-weight: 600; }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 0 1 auto; padding: 6px 10px; }
.chip .finders { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: middle; }
.chip .finders i { width: 8px; height: 8px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 0 1.5px var(--panel); }
.cover-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.guest-add { display: flex; gap: 8px; }
.guest-add input { flex: 1; }
.hud .who { font-weight: 800; color: var(--fg); font-size: .95rem; }
.ticker .t .st { color: var(--muted); }
.card.daily { background: linear-gradient(135deg, color-mix(in srgb, var(--sel) 22%, var(--panel)), var(--panel)); border-color: var(--sel); }

.board.big { gap: 6px; }
.board.big .die { font-size: clamp(1.3rem, 8vw, 2.2rem); border-radius: 11px; }
button.chip { font: inherit; font-weight: 600; font-size: .93rem; padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.sheet-back { position: fixed; inset: 0; background: rgb(0 0 0 / .35); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade .15s; }
.sheet { background: var(--panel); color: var(--fg); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 20px max(18px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; max-height: 75dvh; overflow: auto; animation: up .2s ease-out; }
.meanings { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.sheet a { color: var(--accent); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 6px; border-top: 1px solid var(--line); }
.controls button { padding: 8px 14px; font-size: .9rem; font-weight: 600; }
