:root {
  --k: #e8674f; --t: #2bb3a6; --s: #efb82e; --v: #8f66c9; --l: #74b649;
  --ink: #2b2622; --paper: #fffdf5; --desk: #d9c7a5; --line: #cbbd9f;
  --cell: min(42px, calc((100vw - 34px) / 15));
  --hand: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Trebuchet MS", system-ui, sans-serif; color: var(--ink);
  background: var(--desk);
  background-image: radial-gradient(circle at 20% 10%, rgba(255,255,255,.35), transparent 40%),
    repeating-linear-gradient(115deg, rgba(0,0,0,.025) 0 2px, transparent 2px 9px);
  min-height: 100vh;
}
.hidden { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
h1 { margin: 0; font-family: var(--hand); font-size: 26px; letter-spacing: .5px; }
.logo-x { color: var(--k); }
.amp { color: var(--t); }
.players { display: flex; gap: 10px; flex-wrap: wrap; }
.pl { background: var(--paper); border-radius: 20px; padding: 5px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.2); font-size: 14px; display: flex; gap: 6px; align-items: center; }
.pl.turn { outline: 3px solid var(--k); }
.pl .dot { width: 9px; height: 9px; border-radius: 50%; background: #aaa; }
.pl .dot.on { background: #3ca33c; }
.pl b { font-size: 16px; }
main { max-width: 1060px; margin: 0 auto; padding: 0 10px 40px; }
.card { background: var(--paper); max-width: 420px; margin: 30px auto; padding: 22px 26px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.card h2 { font-family: var(--hand); margin-top: 0; }
.card label { display: block; margin: 12px 0 6px; font-weight: bold; }
.card input { display: block; width: 100%; margin-top: 4px; padding: 9px; font-size: 16px; border: 2px solid var(--line); border-radius: 6px; font-family: inherit; }
.card hr { border: none; border-top: 2px dashed var(--line); margin: 20px 0 6px; }
.btn { font: inherit; font-weight: bold; padding: 9px 16px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; cursor: pointer; margin-top: 8px; }
.btn.primary { background: var(--ink); color: #fff; }
.btn:disabled { opacity: .35; cursor: default; }
.btn.small { padding: 4px 10px; margin: 0; font-size: 13px; }
.status { background: var(--paper); border-left: 6px solid var(--k); padding: 10px 14px; border-radius: 4px; margin: 6px 0 10px; font-size: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.status.mine { border-left-color: var(--l); font-weight: bold; }
.invite { background: #fff7d6; padding: 10px 14px; border-radius: 4px; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.invite code { background: #fff; padding: 4px 8px; border-radius: 4px; word-break: break-all; }

/* Würfel */
.tray-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; background: #3f6b4f;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 6px 6px;
  border-radius: 10px; padding: 12px 14px; box-shadow: inset 0 2px 8px rgba(0,0,0,.4); margin-bottom: 12px; }
.tray { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tray .sep { width: 2px; height: 46px; background: rgba(255,255,255,.25); margin: 0 4px; }
.die { width: 52px; height: 52px; border-radius: 10px; position: relative; cursor: pointer; border: none; padding: 0;
  box-shadow: 0 3px 0 rgba(0,0,0,.35), inset 0 -3px 0 rgba(0,0,0,.12); transition: transform .12s; }
.die:disabled { cursor: default; }
.die.sel { transform: translateY(-5px) scale(1.06); outline: 4px solid #fff; outline-offset: 2px; }
.die.taken { opacity: .3; }
.die.taken::after { content: "✗"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; color: #fff; text-shadow: 0 0 3px #000; }
.die.num { background: #fbfaf4; }
.die .pip { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); }
.die .q { position: absolute; inset: 0; display: grid; place-items: center; font-size: 32px; font-weight: 900; font-family: var(--hand); }
.die.cj { background: conic-gradient(var(--k) 0 72deg, var(--s) 0 144deg, var(--l) 0 216deg, var(--t) 0 288deg, var(--v) 0); }
.die.cj .q { color: #fff; text-shadow: 0 0 4px #000; }
.joker-pick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: #fff; font-size: 14px; }
.joker-pick:empty { display: none; }
.jp { width: 32px; height: 32px; border-radius: 7px; border: 2px solid #fff; cursor: pointer; font-weight: bold; font-size: 16px; }
.jp.sel { outline: 3px solid #fff; outline-offset: 2px; transform: scale(1.1); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.actions .btn { margin: 0; }
.sel-info { color: #fff; font-size: 14px; min-width: 120px; }

/* Spielblatt */
.sheet { background: var(--paper); border-radius: 4px; padding: 12px 12px 10px; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  display: inline-flex; gap: 14px; flex-wrap: wrap; position: relative; max-width: 100%;
  background-image: linear-gradient(rgba(203,189,159,.25) 1px, transparent 1px); background-size: 100% 18px; }
.sheet .main { display: grid; grid-template-columns: repeat(15, var(--cell)); }
.sheet .hd { height: calc(var(--cell) * .62); display: grid; place-items: center; font-weight: bold; font-family: var(--hand); font-size: calc(var(--cell) * .42); }
.sheet .hd.start { color: #fff; background: var(--ink); border-radius: 6px 6px 0 0; }
.cell { width: var(--cell); height: var(--cell); position: relative; cursor: default; }
.cell .bg { position: absolute; inset: 0; }
.cell.k .bg { background: var(--k); } .cell.t .bg { background: var(--t); } .cell.s .bg { background: var(--s); }
.cell.v .bg { background: var(--v); } .cell.l .bg { background: var(--l); }
.cell.startcol::before { content: ""; position: absolute; inset: 0; border-left: 2px dashed rgba(0,0,0,.35); border-right: 2px dashed rgba(0,0,0,.35); z-index: 1; pointer-events: none; }
.cell .star { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.95); font-size: calc(var(--cell) * .6); line-height: 1; text-shadow: 0 0 2px rgba(0,0,0,.25); z-index: 1; }
.cell svg.x { position: absolute; inset: 6%; width: 88%; height: 88%; z-index: 2; pointer-events: none; }
.cell.click { cursor: pointer; }
.cell.click:hover .bg { filter: brightness(1.12); }
.cell.pick .bg { filter: brightness(1.25) saturate(.7); }
.cell.pick::after { content: ""; position: absolute; inset: 14%; border: 3px solid var(--ink); border-radius: 50%; z-index: 3; }
.cell.bad.pick::after { border-color: #c00; border-style: dashed; }
.cell.lastmove svg.x path { stroke: #1d3fa8; }
.cell.marked .bg { filter: saturate(.55) brightness(.95); }

.bonus { display: grid; grid-template-columns: repeat(15, var(--cell)); margin-top: 6px; }
.bonus div { height: calc(var(--cell) * .7); display: grid; place-items: center; font-family: var(--hand); font-weight: bold; font-size: calc(var(--cell) * .38); position: relative; }
.bonus .first { border-top: 2px solid var(--ink); }
.bonus .later { color: #7a6f60; }
.ring::after { content: ""; position: absolute; inset: 8% 14%; border: 2.5px solid #1d3fa8; border-radius: 50%; }
.strike { text-decoration: line-through; text-decoration-thickness: 2px; color: #b5a991 !important; }

.side { display: flex; flex-direction: column; gap: 10px; min-width: 150px; font-size: 13px; }
.side h4 { margin: 0 0 4px; font-family: var(--hand); font-size: 15px; }
.cbonus { display: grid; grid-template-columns: 24px 32px 32px; gap: 3px; align-items: center; }
.cbonus .sw { width: 20px; height: 20px; border-radius: 5px; }
.cbonus span { text-align: center; font-family: var(--hand); font-weight: bold; position: relative; height: 24px; line-height: 24px; }
.jokers { display: grid; grid-template-columns: repeat(4, 26px); gap: 4px; }
.jk { width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-family: var(--hand); position: relative; background: #fff; }
.jk svg.x { position: absolute; inset: -2px; width: 28px; height: 28px; }
.score { border: 2px solid var(--ink); border-radius: 6px; padding: 6px 8px; background: #fff; }
.score div { display: flex; justify-content: space-between; }
.score .tot { border-top: 2px solid var(--ink); margin-top: 3px; padding-top: 3px; font-weight: bold; font-size: 16px; }

/* Gegner kleiner */
.lower { display: grid; grid-template-columns: 1fr 300px; gap: 20px; margin-top: 20px; }
.lower h3 { font-family: var(--hand); margin: 0 0 8px; }
#oppSheet .sheet { --cell: min(26px, calc((100vw - 34px) / 15)); }
#oppSheet .side { min-width: 130px; font-size: 12px; }
.log { list-style: none; padding: 10px 12px; margin: 0; background: var(--paper); border-radius: 4px; font-size: 13px; max-height: 260px; overflow: auto; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.log li { padding: 3px 0; border-bottom: 1px dotted var(--line); }
.rules { background: var(--paper); border-radius: 4px; padding: 8px 12px; margin-top: 12px; font-size: 13px; }
.rules summary { cursor: pointer; font-weight: bold; }
.rules ul { padding-left: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: #b3261e; color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok { background: #2d6a3e; }

.over-banner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 5; }
.over-banner span { background: rgba(43,38,34,.88); color: #fff; padding: 12px 22px; border-radius: 10px; font-family: var(--hand); font-size: 26px; transform: rotate(-4deg); }

@media (max-width: 820px) {
  .lower { grid-template-columns: 1fr; }
  .actions { margin-left: 0; }
  .die { width: 44px; height: 44px; }
  .side { flex-direction: row; flex-wrap: wrap; gap: 14px; width: 100%; }
}
