:root {
  --bg: #f3eee4;
  --ink: #1c2420;
  --ink-2: #5a645e;
  --ink-3: #8d958f;
  --line: #dcd3c2;
  --card: #fffcf6;
  --accent: #b8323f;
  --gold: #d9a53a;
  --gold-soft: #f4e4bd;
  --good: #2f8f5b;
  --shadow: 0 1px 2px rgb(30 25 15 / .08), 0 8px 24px rgb(30 25 15 / .09);
  --radius: 14px;
  /* Brett */
  --board: #1f6b5a; --board-edge: #174f43;
  --sq: #e9e1cd; --sq-line: #c9bda2; --sq-ink: #6f6450;
  --tw: #d4473f; --dw: #ef9fa0; --tl: #3a6fbf; --dl: #a9cbe9;
  --tw-ink: #fff; --dw-ink: #7a2328; --tl-ink: #fff; --dl-ink: #1f3f63;
  /* Steine */
  --tile: #f3e2bf; --tile-2: #e4c98f; --tile-edge: #b98d4c; --tile-ink: #2b2118;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1714; --ink: #e9eeea; --ink-2: #a3aea7; --ink-3: #6c7770; --line: #24332c; --card: #16211c;
    --accent: #ef5d6a; --gold: #e9b955; --gold-soft: #3a3119; --good: #5fcf8c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px rgb(0 0 0 / .35);
    --board: #123b32; --board-edge: #0b2721;
    --sq: #22342e; --sq-line: #132520; --sq-ink: #8da197;
    --tw: #a8343a; --dw: #6e3a42; --tl: #2b4f86; --dl: #2a4a63;
    --tw-ink: #ffe3e1; --dw-ink: #ffd1d3; --tl-ink: #dce9ff; --dl-ink: #cfe6fb;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1714; --ink: #e9eeea; --ink-2: #a3aea7; --ink-3: #6c7770; --line: #24332c; --card: #16211c;
  --accent: #ef5d6a; --gold: #e9b955; --gold-soft: #3a3119; --good: #5fcf8c;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px rgb(0 0 0 / .35);
  --board: #123b32; --board-edge: #0b2721;
  --sq: #22342e; --sq-line: #132520; --sq-ink: #8da197;
  --tw: #a8343a; --dw: #6e3a42; --tl: #2b4f86; --dl: #2a4a63;
  --tw-ink: #ffe3e1; --dw-ink: #ffd1d3; --tl-ink: #dce9ff; --dl-ink: #cfe6fb;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
a.btn { text-decoration: none; }

/* ---------- Kopf ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; display: block; }
.brand span { font: italic 800 1.5rem/1 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.code-badge {
  font: 700 .95rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .18em;
  padding: 7px 10px 7px 12px; border-radius: 999px; background: var(--gold-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); cursor: pointer;
}
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 24px; }

/* ---------- Buttons & Felder ---------- */
.btn {
  appearance: none; border-radius: 12px; padding: 10px 16px; cursor: pointer; font-weight: 650;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  transition: transform .08s, background .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.dark { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.dashed { border-style: dashed; background: transparent; margin-top: 10px; }
.btn.block { width: 100%; }
.field { display: grid; gap: 6px; }
.field label { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); min-height: 46px; }
.input:focus, .btn:focus-visible, .rack-slot:focus-visible { outline: 3px solid color-mix(in srgb, var(--gold) 65%, transparent); outline-offset: 2px; }
.input.code { text-transform: uppercase; letter-spacing: .4em; font: 700 1.4rem/1 ui-monospace, Menlo, monospace; text-align: center; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.good { color: var(--good); }
.bad { color: var(--accent); }
.err { color: var(--accent); font-size: .9rem; min-height: 1.2em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.card p { margin: 0 0 14px; }
.card form { display: grid; gap: 12px; }
.cards { display: grid; gap: 14px; align-content: start; }
.tag { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--ink); white-space: nowrap; }
.tag.bot { background: color-mix(in srgb, #3b5bdb 18%, transparent); }
.tag.hr { background: var(--accent); color: #fff; font-size: .62rem; padding: 2px 6px; }
.spacer { flex: 1; }
.link-btn { background: none; border: 0; color: var(--ink-2); cursor: pointer; text-decoration: underline; padding: 4px; }
.rules-card summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.rules-card summary::-webkit-details-marker { display: none; }
.rules-card summary::after { content: "＋"; color: var(--ink-3); font-weight: 700; }
.rules-card[open] summary::after { content: "−"; }
.rules-card summary h2 { margin: 0; }
.rules { margin: 12px 0 0; padding-left: 1.1em; display: grid; gap: 6px; font-size: .92rem; color: var(--ink-2); }
.rules b { color: var(--ink); }

/* ---------- Stein ---------- */
.tile {
  --t: 44px;
  width: var(--t); height: var(--t); position: relative; display: inline-grid; place-items: center; flex: none;
  border-radius: calc(var(--t) * .14); color: var(--tile-ink);
  background: linear-gradient(155deg, var(--tile) 45%, var(--tile-2));
  box-shadow: inset 0 calc(var(--t) * -.07) 0 color-mix(in srgb, var(--tile-edge) 70%, transparent), 0 0 0 1px color-mix(in srgb, var(--tile-edge) 75%, transparent), 0 2px 4px rgb(40 25 5 / .25);
  user-select: none; -webkit-user-select: none; touch-action: none;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
.tile b { font-size: calc(var(--t) * .56); font-weight: 700; line-height: 1; margin-top: calc(var(--t) * -.06); }
.tile i { position: absolute; right: calc(var(--t) * .09); bottom: calc(var(--t) * .1); font-style: normal; font-weight: 700; font-size: calc(var(--t) * .24); line-height: 1; font-family: ui-sans-serif, system-ui, sans-serif; }
.tile.blank b { color: color-mix(in srgb, var(--tile-ink) 45%, #c0392b); font-style: italic; }
.tile.blank:not(:has(b:not(:empty))) { background: linear-gradient(155deg, color-mix(in srgb, var(--tile) 85%, #fff) 45%, var(--tile)); }
/* Unbenutzter Blanko: deutlich als Joker erkennbar (Stern + „Blanko“) */
.tile.blank:not(:has(b:not(:empty)))::before { content: "★"; font-size: calc(var(--t) * .4); line-height: 1; color: color-mix(in srgb, var(--tile-ink) 35%, transparent); margin-top: calc(var(--t) * -.12); }
.tile.blank:not(:has(b:not(:empty)))::after { content: "Blanko"; position: absolute; bottom: calc(var(--t) * .1); left: 0; right: 0; text-align: center; font: 700 calc(var(--t) * .16)/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .02em; color: color-mix(in srgb, var(--tile-ink) 55%, transparent); }
.tile.blank:not(:has(b:not(:empty))) b { display: none; }
.tile.md { --t: 52px; }
.tile.xs { --t: 18px; border-radius: 3px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--tile-edge) 75%, transparent); }
.tile.xs i { display: none; }
.tile.xs b { margin: 0; }

/* ---------- Startseite ---------- */
.hero { display: grid; gap: 28px; padding: 16px 0 8px; grid-template-columns: 1.1fr 1fr; align-items: center; }
.hero h1 { font: italic 800 clamp(2.3rem, 6vw, 4rem)/.98 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; margin: 18px 0 14px; letter-spacing: -.01em; }
.hero h1 em { color: var(--accent); }
.hero p.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 31rem; margin: 0; }
.hero-word { display: flex; gap: clamp(3px, 1vw, 8px); flex-wrap: wrap; }
.hero-slot { animation: drop .55s cubic-bezier(.2, .9, .3, 1.3) both; animation-delay: calc(var(--k) * 70ms); }
.hero-slot:nth-child(odd) .tile { transform: rotate(-3deg); }
.hero-slot:nth-child(3n) .tile { transform: rotate(2.5deg) translateY(3px); }
.hero-slot .tile { --t: clamp(34px, 8.6vw, 58px); }
@keyframes drop { 0% { transform: translateY(-40px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.home-level { width: 100%; }
.home-level button { flex: 1 1 0; padding: 9px 4px; min-width: 0; }

/* ---------- Lobby ---------- */
.lobby { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; padding-top: 8px; align-items: start; }
.share-code { display: flex; justify-content: center; gap: 8px; padding: 16px 0 14px; }
.player-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.player-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.player-list .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .9rem; flex: none; position: relative; line-height: 1; }
.avatar.sm { width: 22px; height: 22px; font-size: .7rem; }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); border: 2px solid var(--card); }
.avatar .dot.on { background: #3ccf6e; }
.opt-head { margin: 18px 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); margin: 8px 0 0; cursor: pointer; }
.opt.ro, .opt.seg-opt { cursor: default; }
.opt.seg-opt { align-items: center; }
.opt.seg-opt > span { flex: 1; }
.opt input { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 2px; flex: none; }
.opt small { display: block; color: var(--ink-2); font-weight: 400; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--card); padding: 8px 14px; font-weight: 700; cursor: pointer; min-width: 48px; }
.seg button.on { background: var(--accent); color: #fff; }
.seg.sm button { padding: 6px 10px; min-width: 0; font-size: .82rem; }
.player-list li.has-level { flex-wrap: wrap; }
.bot-level { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-left: 42px; }
.bot-invite { margin-top: 12px; }
.bot-invite + .btn { margin-top: 8px; }
.reclaim-box { display: grid; gap: 6px; margin-top: 12px; padding: 12px; border-radius: 12px; border: 1px dashed currentColor; text-align: left; }
.reclaim-box .small { opacity: .8; }
.reclaim-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn.reclaim { min-height: 40px; padding: 6px 12px 6px 8px; }

/* ---------- Spiel ---------- */
.game {
  display: grid; gap: 12px 22px; align-items: start;
  grid-template-columns: minmax(0, 660px) minmax(280px, 1fr);
  grid-template-areas: "players players" "board side";
}
.players { grid-area: players; display: flex; gap: 8px; flex-wrap: wrap; }
.pl {
  position: relative; flex: 1 1 140px; display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 8px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line);
}
.pl.cur { box-shadow: inset 0 0 0 2px var(--gold); }
.pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.pl-name small { display: block; font-weight: 500; font-size: .72rem; color: var(--ink-3); line-height: 1.1; }
.pl-score { font: 800 1.25rem/1 ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.pl-rack { position: absolute; left: 12px; right: 12px; bottom: 3px; display: flex; gap: 2px; justify-content: center; }
.pl-rack i { width: 7px; height: 3px; border-radius: 1px; background: color-mix(in srgb, var(--tile-edge) 60%, transparent); }
.think { position: absolute; right: 8px; top: 5px; display: flex; gap: 2px; }
.think i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; }
.think i:nth-child(2) { animation-delay: .2s; } .think i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

.board-wrap { grid-area: board; }
.board {
  container-type: inline-size;
  display: grid; grid-template-columns: repeat(15, 1fr); gap: 2px; padding: 6px;
  aspect-ratio: 1; width: 100%; border-radius: 12px; background: var(--board);
  box-shadow: inset 0 0 0 3px var(--board-edge), var(--shadow);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.cell {
  position: relative; aspect-ratio: 1; border-radius: 3px; background: var(--sq);
  display: grid; place-items: center; cursor: pointer; overflow: visible;
  box-shadow: inset 0 0 0 .5px var(--sq-line);
}
.cell .pm { font: 700 2.05cqw/1 ui-sans-serif, system-ui, sans-serif; color: var(--sq-ink); text-align: center; letter-spacing: -.02em; pointer-events: none; }
.cell.tw { background: var(--tw); } .cell.tw .pm { color: var(--tw-ink); }
.cell.dw { background: var(--dw); } .cell.dw .pm { color: var(--dw-ink); }
.cell.tl { background: var(--tl); } .cell.tl .pm { color: var(--tl-ink); }
.cell.dl { background: var(--dl); } .cell.dl .pm { color: var(--dl-ink); }
.cell.star .pm { font-size: 4.2cqw; }
.cell .tile { --t: 100%; width: 100%; height: 100%; border-radius: 3px; box-shadow: inset 0 -1.5px 0 color-mix(in srgb, var(--tile-edge) 70%, transparent), 0 0 0 .5px var(--tile-edge); }
.cell .tile b { font-size: 3.9cqw; margin-top: -.3cqw; }
.cell .tile i { font-size: 1.55cqw; right: .45cqw; bottom: .4cqw; }
.cell .tile.fresh { box-shadow: inset 0 -1.5px 0 color-mix(in srgb, var(--tile-edge) 70%, transparent), 0 0 0 2px var(--gold); }
.cell .tile.pop { animation: pop .45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
.cell .tile.staged { background: linear-gradient(155deg, #fff4d6 45%, #f2d692); box-shadow: 0 0 0 2px var(--accent), 0 3px 6px rgb(0 0 0 / .25); z-index: 2; cursor: grab; }
.cell.cursor { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.cursor::after {
  content: ""; position: absolute; width: 0; height: 0; border: .9cqw solid transparent;
  pointer-events: none;
}
.cell.cursor.right::after { right: -.2cqw; border-left-color: var(--accent); }
.cell.cursor.down::after { bottom: -.2cqw; border-top-color: var(--accent); }
.cell.drop { box-shadow: inset 0 0 0 3px var(--gold); }
.my-turn .cell:not(:has(.tile)):hover { filter: brightness(1.06); }

.side { grid-area: side; display: grid; gap: 12px; align-content: start; }
.statusbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status { font-weight: 700; }
.status.mine { color: var(--accent); }
.bag {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); font-size: .85rem; color: var(--ink-2);
}
.bag b { color: var(--ink); font-size: 1rem; }

.rack {
  display: flex; gap: 6px; justify-content: center; padding: 10px 8px 12px; border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tile-edge) 35%, var(--card)), color-mix(in srgb, var(--tile-edge) 55%, var(--card)));
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--tile-edge) 70%, #000 10%), var(--shadow);
  min-height: 70px;
}
.rack.drop { outline: 3px solid var(--gold); }
.rack-slot { appearance: none; border: 0; padding: 0; background: none; cursor: grab; border-radius: 8px; touch-action: none; }
.rack-slot.drop { outline: 2px dashed var(--gold); outline-offset: 2px; }
.rack .tile { --t: clamp(36px, 11.5vw, 52px); transition: transform .12s, opacity .15s; }
.rack .tile.used { opacity: .18; transform: scale(.85); }
.rack .tile.sel { transform: translateY(-8px); box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--tile-edge) 70%, transparent), 0 0 0 3px var(--accent), 0 8px 14px rgb(40 25 5 / .3); }
.rack .tile.swap-sel { transform: translateY(-8px) rotate(-4deg); box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--tile-edge) 70%, transparent), 0 0 0 3px #3b5bdb; }
.rack.swapping .tile:not(.swap-sel) { opacity: .7; }
.tile.lifted { opacity: .25; }
.tile.ghost.snap { opacity: .92; box-shadow: 0 0 0 2px var(--gold), 0 6px 14px rgb(0 0 0 / .35); border-radius: 3px; }
.cell .tile.staged.stray { box-shadow: 0 0 0 2.5px #e03131, 0 3px 6px rgb(0 0 0 / .25); animation: stray 1.1s ease-in-out infinite; }
@keyframes stray { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, #e03131 45%, transparent), 0 3px 6px rgb(0 0 0 / .25); } }
.tile.ghost { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; transition: width .08s, height .08s; box-shadow: 0 0 0 1px var(--tile-edge), 0 14px 24px rgb(0 0 0 / .35); }
.cell .tile.ghost b, .tile.ghost b { font-size: calc(var(--t) * .56); }

.preview { min-height: 2.4em; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .92rem; }
.preview .w { display: inline-flex; align-items: baseline; gap: 4px; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--good) 15%, transparent); font-weight: 700; letter-spacing: .04em; }
.preview .w small { font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.preview .w.unknown { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); text-decoration: wavy underline; text-underline-offset: 3px; }
.preview .total { margin-left: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 auto; }
.actions .play { flex: 2 1 100%; font-size: 1.05rem; }
.actions .play .pts { background: rgb(255 255 255 / .22); padding: 1px 8px; border-radius: 999px; }
.mini-card { padding: 14px 16px; }
.mini-card h3 { margin: 0 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow: auto; font-size: .9rem; }
.hist li { display: flex; align-items: center; gap: 8px; }
.hist .dotc { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hist .who { font-weight: 650; flex: none; max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hist .what b { letter-spacing: .03em; }
.hist .sc { font-variant-numeric: tabular-nums; font-weight: 700; }
.lookup { display: flex !important; gap: 8px; }
.lookup .input { min-height: 42px; padding: 8px 12px; text-transform: uppercase; }
.lookup-res { font-size: .9rem; margin-top: 6px; min-height: 1.3em; }

/* ---------- Dialoge ---------- */
.modal, .overlay {
  position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 65%, transparent); backdrop-filter: blur(6px); animation: fade .25s ease-out;
}
.modal { z-index: 65; }
@keyframes fade { from { opacity: 0; } }
.modal-box, .overlay-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  padding: 20px; width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
}
.modal-box h2, .overlay-box h2 { margin: 0 0 6px; }
.modal-box .row, .overlay-box .row { display: flex; gap: 8px; margin-top: 12px; }
.modal-box .row .btn, .overlay-box .row .btn { flex: 1; }
.letters { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 12px 0; }
.letters button { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; }
.letters .tile { --t: 46px; }
.bag-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px 6px; margin: 12px 0 14px; }
.bag-grid .bg { display: grid; justify-items: center; gap: 2px; font-size: .82rem; font-weight: 700; color: var(--ink-2); }
.bag-grid .bg .tile { --t: 36px; }
.bag-grid .bg.gone { opacity: .3; }
.ranking { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 6px; }
.ranking li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--bg); }
.ranking li.win { box-shadow: inset 0 0 0 2px var(--gold); }
.ranking .rk { width: 1.4em; font-weight: 800; color: var(--ink-3); }
.ranking .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.ranking .nm small { display: block; font-weight: 500; font-size: .72rem; color: var(--ink-3); }
.ranking .rest { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ranking .restl { font: 700 .78rem/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; padding: 3px 6px; border-radius: 5px; background: var(--tile); color: var(--tile-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 8.5em; }
.ranking .rest small { margin-left: 4px; font-weight: 700; }
.ranking b { min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.best { margin: 0 0 4px; color: var(--ink-2); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
.toast {
  position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 90;
  box-shadow: var(--shadow); max-width: calc(100% - 32px); font-weight: 600; text-align: center;
}

/* ---------- Responsiv ---------- */
@media (max-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr); grid-template-areas: "players" "board" "side"; gap: 10px; }
  .board-wrap { margin: 0 -10px; }
  .board { padding: 4px; gap: 1.5px; border-radius: 8px; }
  .side { max-width: 640px; width: 100%; margin: 0 auto; }
}
@media (max-width: 860px) { .hero, .lobby { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
  main { padding: 0 12px 20px; }
  .topbar { padding: 8px 12px; }
  .pl { flex-basis: calc(50% - 4px); padding: 6px 10px; }
  .pl-score { font-size: 1.05rem; }
  .rack { gap: 4px; padding: 8px 6px 11px; }
  .actions .btn { flex: 1 1 0; min-width: 0; padding: 8px 6px; font-size: .9rem; }
  .actions .play { flex-basis: 100%; }
  .bot-invite, .bot-level { flex-wrap: wrap; }
  .bot-invite .seg, .bot-level .seg { flex: 1 1 100%; min-width: 0; }
  .bot-invite .seg button, .bot-level .seg button { flex: 1 1 auto; min-width: 0; padding: 7px 5px; font-size: .8rem; line-height: 1.15; }
  .bot-level { padding-left: 0; }
  .letters { grid-template-columns: repeat(5, 1fr); }
  .letters .tile { --t: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
