:root {
  --ink: #2a1f2e;
  --sand: #ffe8c2;
  --sand-2: #f6d7a3;
  --coral: #ff7a59;
  --coral-d: #e85a3a;
  --sea: #2ec4b6;
  --sea-d: #1d9e93;
  --night: #1c1226;
  --glass: rgba(28, 18, 38, 0.62);
  --glass-line: rgba(255, 232, 194, 0.18);
  --font: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f2a27c; color: var(--sand); font-family: var(--font); }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

/* ---------- startscherm ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 10;
  background: linear-gradient(180deg, rgba(42,37,96,0.35), rgba(242,162,124,0.1) 60%, rgba(28,18,38,0.35)); }
.lobby-card { width: min(440px, 100%); background: var(--glass); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--glass-line); border-radius: 28px; padding: 26px 24px 18px; box-shadow: 0 30px 80px rgba(28,18,38,0.45); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo h1 { margin: 0; font-size: 44px; line-height: 1; font-weight: 800; color: var(--coral); letter-spacing: -0.5px; }
.logo h1 b { color: var(--sea); }
.sun { width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 40%, #ffe08a, #ff9a52 60%, #ff6b6b); box-shadow: 0 0 30px #ffb060; }
.tag { margin: 10px 0 18px; opacity: 0.9; line-height: 1.35; }
.field { display: block; font-weight: 600; font-size: 15px; margin: 0 0 14px; }
.field input:not([type=radio]) { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: 600 18px var(--font);
  color: var(--ink); background: var(--sand); border: 2px solid transparent; border-radius: 14px; outline: none; }
.field input:focus { border-color: var(--sea); }
#code { text-transform: uppercase; letter-spacing: 8px; text-align: center; font-size: 26px !important; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(255,232,194,0.1); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.tab { padding: 9px; border-radius: 11px; font-weight: 700; opacity: 0.75; }
.tab.active { background: var(--sand); color: var(--ink); opacity: 1; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--glass-line); background: rgba(255,232,194,0.06); }
.seg b { display: block; font-size: 17px; }
.seg small { opacity: 0.75; font-weight: 500; }
.seg input:checked + span { border-color: var(--sea); background: rgba(46,196,182,0.18); }
.seg input:focus-visible + span { outline: 2px solid var(--sand); }
.stepper { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; background: rgba(255,232,194,0.08); border-radius: 14px; padding: 4px; }
.stepper button { width: 42px; height: 42px; border-radius: 11px; background: var(--sand); color: var(--ink); font-size: 24px; font-weight: 800; }
.stepper output { min-width: 44px; text-align: center; font-size: 22px; font-weight: 800; }
.btn { display: block; width: 100%; padding: 13px 16px; border-radius: 16px; font-weight: 800; font-size: 19px;
  background: rgba(255,232,194,0.14); transition: transform .12s, filter .12s; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, var(--coral), var(--coral-d)); color: #fff; box-shadow: 0 6px 0 #b8432a; }
.btn.primary:active { box-shadow: 0 2px 0 #b8432a; transform: translateY(4px); }
.btn.small { display: inline-block; width: auto; padding: 7px 14px; font-size: 15px; box-shadow: none; }
.btn.public { margin-bottom: 14px; padding: 14px 16px; text-align: left; color: #06302c;
  background: linear-gradient(180deg, #3fd6c8, var(--sea-d)); box-shadow: 0 6px 0 #137a71; }
.btn.public:active { box-shadow: 0 2px 0 #137a71; transform: translateY(4px); }
.pub-main { display: block; font-size: 20px; }
.pub-sub { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; opacity: 0.85; }
.live { width: 9px; height: 9px; border-radius: 50%; background: #ff5a46; box-shadow: 0 0 0 0 rgba(255,90,70,0.6); animation: live 1.6s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(255,90,70,0); } 100% { box-shadow: 0 0 0 0 rgba(255,90,70,0); } }
.or { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; font-size: 13px; opacity: 0.7; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--glass-line); }
.err { min-height: 1.3em; color: #ffb4a3; margin: 10px 0 0; font-weight: 600; }
.hint { font-size: 13px; opacity: 0.7; margin: 4px 0 0; }

/* ---------- spelscherm ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.topbar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.chip { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--glass-line);
  padding: 7px 14px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.chip b { letter-spacing: 2px; color: #fff; }
.chip.stage { background: rgba(46,196,182,0.8); color: #06302c; font-weight: 800; }
.chip.stage:empty { display: none; }
.tools { margin-left: auto; display: flex; gap: 6px; }
.icon { min-width: 42px; height: 42px; padding: 0 10px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 19px; display: inline-flex; align-items: center; gap: 6px; }
.icon span { font-size: 15px; font-weight: 800; }
.icon.off { opacity: 0.45; }
#vrBtn { background: linear-gradient(180deg, var(--sea), var(--sea-d)); color: #06302c; }

#players { position: absolute; top: 64px; right: 12px; width: 210px; display: flex; flex-direction: column; gap: 6px; }
.pl { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-weight: 600; font-size: 15px; transition: background .3s; }
.pl i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.pl .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .tg { font-size: 13px; opacity: 0.85; white-space: nowrap; }
.pl.me { border-color: var(--sea); }
.pl.hot { background: rgba(255,122,89,0.85); color: #fff; }
.pl.hot .tg { opacity: 1; font-weight: 800; }

#phase { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); text-align: center; background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-line); border-radius: 22px; padding: 14px 22px; max-width: calc(100% - 32px); }
#phaseText { font-size: 22px; font-weight: 700; }
#phaseText big { display: block; font-size: 44px; font-weight: 800; color: #fff; line-height: 1.1; }
#hostBar { margin-top: 10px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

#dock { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 26px; background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--glass-line); box-shadow: 0 20px 60px rgba(28,18,38,0.35); max-width: calc(100% - 24px); }
#ballRow { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#recent { display: flex; gap: 4px; }
.ball { --c: #ccc; width: 34px; height: 34px; border-radius: 50%; background: var(--c); display: grid; place-items: center; flex: none;
  box-shadow: inset -3px -4px 0 rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.25); }
.ball span { width: 70%; height: 70%; border-radius: 50%; background: #fffaf0; color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; line-height: 1; }
.ball.big { width: 96px; height: 96px; }
.ball.big span { font-size: 34px; flex-direction: column; }
.ball.big span small { font-size: 15px; display: block; margin-bottom: -4px; }
.ball.big.empty { --c: rgba(255,232,194,0.15); box-shadow: none; }
.ball.big.empty span { background: transparent; color: var(--sand); font-size: 30px; }
.ball.pop { animation: pop .55s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(0.3) rotate(-90deg); } to { transform: none; } }

#card { display: grid; gap: 5px; user-select: none; }
#card.v75 { grid-template-columns: repeat(5, 54px); }
#card.v90 { grid-template-columns: repeat(9, 46px); }
.hd { height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #fff; }
.cell { position: relative; height: 50px; border-radius: 12px; background: var(--sand); color: var(--ink); display: grid; place-items: center;
  font-weight: 800; font-size: 22px; transition: transform .1s; }
.v90 .cell { height: 54px; font-size: 20px; }
.cell.empty { background: rgba(255,232,194,0.1); }
.cell.num:active { transform: scale(0.92); }
.cell.free { font-size: 26px; }
.cell.mark::after { content: ""; position: absolute; inset: 12%; border-radius: 50%; background: rgba(255,90,70,0.6); animation: daub .25s ease-out; }
.cell.last { box-shadow: 0 0 0 3px #ffe08a; }
.cell.shake { animation: shake .3s; }
@keyframes daub { from { transform: scale(1.6); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

#actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: 190px; }
.bingo { padding: 18px 10px; border-radius: 22px; font-size: 36px; font-weight: 800; color: #fff; letter-spacing: 1px;
  background: linear-gradient(180deg, var(--sea), var(--sea-d)); box-shadow: 0 7px 0 #137a71; transition: transform .1s; }
.bingo:active { transform: translateY(5px); box-shadow: 0 2px 0 #137a71; }
.bingo.ready { background: linear-gradient(180deg, #ff9068, var(--coral-d)); box-shadow: 0 7px 0 #b8432a; animation: pulse 0.9s infinite; }
.bingo.locked { filter: grayscale(0.8); opacity: 0.7; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--sea); }
#emotes { display: flex; justify-content: space-between; }
#emotes button { font-size: 22px; width: 30px; height: 34px; border-radius: 10px; }
#emotes button:hover { background: rgba(255,232,194,0.15); }

.sheet { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 32px)); max-height: 80vh; overflow: auto;
  background: rgba(28,18,38,0.92); border: 1px solid var(--glass-line); border-radius: 24px; padding: 14px 16px 18px; z-index: 6; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 20px; }
#numGrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
#numGrid.v75 { grid-template-columns: repeat(15, 1fr); }
#numGrid div { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: rgba(255,232,194,0.08); opacity: 0.5; }
#numGrid div.on { background: var(--c); color: var(--ink); opacity: 1; box-shadow: inset 0 0 0 4px rgba(255,250,240,0.6); }
#numGrid div.last { outline: 3px solid #ffe08a; }

#toasts { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 20; pointer-events: none; width: calc(100% - 32px); }
.toast { background: rgba(28,18,38,0.88); color: var(--sand); border: 1px solid var(--glass-line); padding: 9px 18px; border-radius: 999px; font-weight: 700;
  font-size: 17px; animation: tin .35s cubic-bezier(.2,1.4,.4,1), tout .4s ease-in forwards; animation-delay: 0s, var(--d, 3s); text-align: center; }
.toast.big { font-size: 28px; padding: 14px 28px; border-radius: 26px; background: linear-gradient(180deg, var(--coral), var(--coral-d)); color: #fff; }
.toast.good { background: linear-gradient(180deg, var(--sea), var(--sea-d)); color: #06302c; }
@keyframes tin { from { transform: translateY(-20px) scale(0.8); opacity: 0; } }
@keyframes tout { to { transform: translateY(-10px); opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------- telefoon ---------- */
@media (max-width: 860px) {
  #players { top: auto; bottom: calc(var(--dock-h, 330px) + 24px); right: auto; left: 12px; width: auto; max-width: calc(100% - 24px);
    flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .pl { padding: 1px 8px; font-size: 12px; gap: 4px; border-radius: 10px; }
  .pl i { width: 8px; height: 8px; }
  .pl .nm { max-width: 64px; }
  .pl .tg { font-size: 11px; }
  #dock { left: 8px; right: 8px; transform: none; flex-direction: column; gap: 8px; padding: 10px; border-radius: 22px; max-width: none; bottom: max(8px, env(safe-area-inset-bottom)); }
  #ballRow { flex-direction: row; width: 100%; justify-content: flex-start; gap: 10px; }
  .ball.big { width: 64px; height: 64px; }
  .ball.big span { font-size: 24px; }
  .ball.big span small { font-size: 11px; }
  #cardWrap { width: 100%; }
  #card.v75 { grid-template-columns: repeat(5, 1fr); }
  #card.v90 { grid-template-columns: repeat(9, 1fr); gap: 3px; }
  .cell { height: 44px; font-size: 20px; }
  .v90 .cell { height: 46px; font-size: 17px; border-radius: 9px; }
  .hd { height: 28px; font-size: 18px; }
  #actions { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .bingo { flex: 1 1 100%; padding: 12px; font-size: 30px; order: -1; }
  .toggle { flex: 1; font-size: 13px; }
  #emotes { gap: 2px; }
  #emotes button { width: 34px; }
  .topbar { left: 8px; right: 8px; gap: 6px; }
  .chip { padding: 6px 10px; font-size: 14px; }
  .icon { min-width: 38px; height: 38px; padding: 0 8px; font-size: 17px; }
  .icon span { display: none; }
  #phase { top: 22%; }
  #phaseText big { font-size: 34px; }
}
@media (max-width: 420px) {
  .chip.stage { position: absolute; top: 46px; left: 0; }
  .tools { gap: 4px; }
}
