:root {
  --felt: #14362a;
  --felt-2: #1c4a39;
  --paper: #fbf7ec;
  --ink: #1f2420;
  --line: #d9d2bf;
  --muted: #6d7268;
  --accent: #c8432b;
  --accent-ink: #fff;
  --mine: #fff3c9;
  --pick: #ffd75e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--felt); color: var(--ink);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; border-radius: 10px; padding: 10px 14px;
  background: #e9e3d2; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- Lobby ---------- */
#lobby { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--paper); border-radius: 18px; padding: 28px 24px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); text-align: center; }
.card h1 { margin: 12px 0 6px; font-size: 26px; }
.card p { margin: 0 0 18px; color: var(--muted); }
.card label { display: block; text-align: left; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.card input { width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; margin-bottom: 14px; }
.card button { width: 100%; padding: 14px; font-size: 17px; }
.card button.link { background: none; color: var(--felt-2); font-size: 14px; padding: 0 0 16px; text-align: left; }
.card #names input { margin-bottom: 8px; }
.card .hint { font-size: 13px; margin: 12px 0 0; }
.card .error { color: var(--accent); margin: 12px 0 0; font-weight: 600; }
.logo { display: flex; justify-content: center; }

/* ---------- Würfel ---------- */
.die { --s: 46px; width: var(--s); height: var(--s); border-radius: 22%; background: #fff;
  border: 1px solid #cfc8b4; box-shadow: 0 2px 0 #cfc8b4; display: grid; flex: none;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: calc(var(--s) * .13); }
.die.big { --s: 64px; }
.die i { width: 72%; height: 72%; border-radius: 50%; background: #1c1c1c; place-self: center; visibility: hidden; }
.die[data-v="1"] i:nth-child(5),
.die[data-v="2"] i:nth-child(1), .die[data-v="2"] i:nth-child(9),
.die[data-v="3"] i:nth-child(1), .die[data-v="3"] i:nth-child(5), .die[data-v="3"] i:nth-child(9),
.die[data-v="4"] i:nth-child(1), .die[data-v="4"] i:nth-child(3), .die[data-v="4"] i:nth-child(7), .die[data-v="4"] i:nth-child(9),
.die[data-v="5"] i:nth-child(1), .die[data-v="5"] i:nth-child(3), .die[data-v="5"] i:nth-child(5), .die[data-v="5"] i:nth-child(7), .die[data-v="5"] i:nth-child(9),
.die[data-v="6"] i:nth-child(1), .die[data-v="6"] i:nth-child(3), .die[data-v="6"] i:nth-child(4), .die[data-v="6"] i:nth-child(6), .die[data-v="6"] i:nth-child(7), .die[data-v="6"] i:nth-child(9)
{ visibility: visible; }
.die.empty { background: transparent; border: 2px dashed rgba(0,0,0,.2); box-shadow: none; }

/* ---------- Spiel ---------- */
#game { height: 100%; display: flex; flex-direction: column; }
#stage { position: relative; background: #000; flex: none; height: 36vh; min-height: 200px; overflow: hidden; }
#mainSlot { position: absolute; inset: 0; }
#mainSlot video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
#thumbs { position: absolute; right: 10px; top: calc(10px + env(safe-area-inset-top)); display: flex;
  flex-direction: column; gap: 6px; width: 24%; max-width: 160px; z-index: 2; }
#thumbs video { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.7); background: #222; display: block; }
#thumbs video.turn { border-color: var(--pick); }
#mainName { position: absolute; left: 10px; top: calc(10px + env(safe-area-inset-top)); color: #fff; font-size: 13px;
  background: rgba(0,0,0,.55); padding: 4px 10px; border-radius: 999px; z-index: 2; }
#mainName:empty { display: none; }
#stageMsg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: #e8efe9; padding: 20px 30% 20px 20px; pointer-events: none; font-size: 15px; }
#unmuteHint { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: var(--accent); color: #fff; font-weight: 600; }
#controls { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
#controls button { background: rgba(0,0,0,.55); color: #fff; font-size: 13px; padding: 8px 10px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#controls button.off { background: var(--accent); }

#panel { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--paper);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
#turnBar { font-weight: 600; text-align: center; padding: 8px; border-radius: 10px; background: #ece6d4; }
#turnBar.me { background: var(--pick); }
#turnBar.over { background: var(--felt); color: #fff; }

#diceArea { display: flex; flex-direction: column; gap: 8px; align-items: center; }
#diceRow { display: flex; gap: 8px; justify-content: center; }
#diceRow .die { cursor: pointer; }
#numpad { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#numpad button { padding: 4px; background: transparent; }
#numpad .die { --s: 40px; }
#numpad button.clear { font-size: 13px; background: #e9e3d2; padding: 0 12px; }
#diceArea.watch #numpad { display: none; }
#diceArea.watch #diceRow .die { cursor: default; }

#sheet { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: #fff;
  border-radius: 10px; overflow: hidden; }
#sheet th, #sheet td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: center; }
#sheet th:first-child, #sheet td:first-child { text-align: left; }
#sheet thead th { background: var(--felt-2); color: #fff; font-size: 14px; max-width: 30vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet thead th.turn { background: var(--accent); }
#sheet thead th .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #8b8; margin-right: 5px; vertical-align: middle; }
#sheet thead th .dot.off { background: #999; }
#sheet td.cell { width: 26%; font-weight: 600; }
#sheet.many { font-size: 14px; table-layout: fixed; }
#sheet.many th, #sheet.many td { padding: 7px 3px; }
#sheet.many th:first-child, #sheet.many td:first-child { width: 31%; padding-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet.many td.cell { width: auto; }
#sheet.many thead th { font-size: 12px; }
#sheet.many thead th .dot { margin-right: 3px; }
#sheet td.mine { background: var(--mine); }
#sheet td.open { cursor: pointer; }
#sheet td.preview { color: #a3894a; font-weight: 400; }
#sheet td.picked { background: var(--pick); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); }
#sheet td.lastEntry { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
#sheet tr.sum td { background: #f1ecdd; font-size: 14px; color: var(--muted); }
#sheet tr.total td { background: var(--felt-2); color: #fff; font-weight: 700; font-size: 17px; border-bottom: 0; }

#actions { display: flex; flex-direction: column; gap: 8px; position: sticky; bottom: 0;
  background: var(--paper); padding-top: 8px; margin-top: auto; box-shadow: 0 -8px 8px -8px rgba(0,0,0,.15); }
#scoreBtn { padding: 14px; font-size: 17px; }
#actions .row { display: flex; gap: 8px; }
#actions .row button { flex: 1; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20,20,20,.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: 90vw; text-align: center; z-index: 10; }

/* Querformat / iPad: Video links, Block rechts */
@media (min-width: 760px) and (orientation: landscape) {
  #game { flex-direction: row; }
  #stage { flex: 1; height: 100%; }
  #panel { flex: none; width: 400px; padding-top: calc(10px + env(safe-area-inset-top)); }
  #sheet thead th { max-width: 110px; }
}
