/* Host / TV screen.
   --u is "one design pixel" for a 1920x1080 TV. It grows on bigger screens
   (1440p, unscaled 4K) so the whole stage scales up instead of shrinking. */
:root { --u: max(1px, min(100vw / 1920, 100vh / 1080)); }
body { height: 100vh; overflow: hidden; }
.eyebrow { font-size: clamp(calc(11 * var(--u, 1px)), .85vw, calc(15 * var(--u, 1px))); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.wordmark { font-size: clamp(calc(48 * var(--u, 1px)), 6vw, calc(110 * var(--u, 1px))); line-height: .9; text-shadow: calc(4 * var(--u, 1px)) calc(4 * var(--u, 1px)) 0 var(--ink), calc(7 * var(--u, 1px)) calc(7 * var(--u, 1px)) 0 var(--robe); }
.wordmark span { color: var(--accent); display: block; }
.accent { color: var(--accent); }
.btn.big { font-size: clamp(calc(18 * var(--u, 1px)), 1.5vw, calc(28 * var(--u, 1px))); padding: calc(18 * var(--u, 1px)) calc(34 * var(--u, 1px)); }

/* ---------- splash */
.splash { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; background: radial-gradient(circle at 50% 40%, #2b2366, var(--bg-deep) 70%); }
.splash-inner { display: grid; justify-items: center; gap: calc(18 * var(--u, 1px)); text-align: center; }
.splash-logo { width: min(70vw, calc(820 * var(--u, 1px))); filter: drop-shadow(0 calc(12 * var(--u, 1px)) calc(30 * var(--u, 1px)) #000a); animation: logoIn 1.1s cubic-bezier(.2, 1.6, .4, 1) both; }
.splash-scroggy { height: 34vh; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 calc(10 * var(--u, 1px)) calc(30 * var(--u, 1px)) #c1a3f555); }
.splash .hint { color: var(--muted); }
@keyframes logoIn { from { transform: scale(.3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-14px) rotate(1.5deg); } }

/* ---------- top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: calc(64 * var(--u, 1px)); z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 0 calc(24 * var(--u, 1px)); border-bottom: calc(1 * var(--u, 1px)) solid var(--line); background: #100f14cc; backdrop-filter: blur(calc(8 * var(--u, 1px))); }
.brand { display: inline-flex; gap: calc(10 * var(--u, 1px)); align-items: center; font-family: var(--display); font-size: calc(26 * var(--u, 1px)); }
.brand > .star { color: var(--accent); width: calc(26 * var(--u, 1px)); height: calc(26 * var(--u, 1px)); animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.top-mid { display: flex; gap: calc(10 * var(--u, 1px)); }
.pill { border: calc(1 * var(--u, 1px)) solid var(--line); border-radius: calc(999 * var(--u, 1px)); padding: calc(6 * var(--u, 1px)) calc(14 * var(--u, 1px)); font-size: calc(14 * var(--u, 1px)); color: var(--muted); }
.pill b { color: var(--accent); letter-spacing: .08em; }
.top-controls { display: flex; gap: calc(8 * var(--u, 1px)); }
.icon-btn { width: calc(42 * var(--u, 1px)); height: calc(42 * var(--u, 1px)); border-radius: calc(10 * var(--u, 1px)); border: calc(1 * var(--u, 1px)) solid var(--line); background: var(--surface); color: var(--paper); font-size: calc(18 * var(--u, 1px)); }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.off { opacity: .4; text-decoration: line-through; }

/* ---------- lobby */
.lobby { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 3vw; padding: 4vh 4vw 4vh; }
.join-panel { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3vh; }
.lobby-logo { width: min(100%, calc(640 * var(--u, 1px))); filter: drop-shadow(0 calc(10 * var(--u, 1px)) calc(24 * var(--u, 1px)) #000a); animation: logoIn 1s cubic-bezier(.2, 1.6, .4, 1) both, bob 5s 1s ease-in-out infinite; }
.join-how { display: grid; gap: calc(8 * var(--u, 1px)); }
.join-url { font-size: clamp(calc(22 * var(--u, 1px)), 2.4vw, calc(44 * var(--u, 1px))); font-weight: 800; color: var(--paper); margin-bottom: calc(10 * var(--u, 1px)); }
.room-code { display: flex; gap: calc(14 * var(--u, 1px)); }
.room-code span {
  display: grid; place-items: center; width: clamp(calc(64 * var(--u, 1px)), 6.5vw, calc(128 * var(--u, 1px))); aspect-ratio: 1; font-family: var(--display);
  font-size: clamp(calc(44 * var(--u, 1px)), 5vw, calc(96 * var(--u, 1px))); color: var(--ink); background: var(--accent); border: calc(4 * var(--u, 1px)) solid var(--ink);
  border-radius: calc(18 * var(--u, 1px)); box-shadow: 0 calc(8 * var(--u, 1px)) 0 var(--ink), 0 calc(14 * var(--u, 1px)) calc(30 * var(--u, 1px)) #000a; animation: tileBounce 2.4s ease-in-out infinite;
}
.room-code span:nth-child(2) { animation-delay: .15s; background: var(--cosmic); }
.room-code span:nth-child(3) { animation-delay: .3s; background: var(--gold); }
.room-code span:nth-child(4) { animation-delay: .45s; background: var(--ball-o); }
@keyframes tileBounce { 0%, 70%, 100% { transform: translateY(0) rotate(0); } 80% { transform: translateY(-16px) rotate(-4deg); } 90% { transform: translateY(0) rotate(3deg); } }
.qr-wrap { display: flex; align-items: center; gap: calc(16 * var(--u, 1px)); color: var(--muted); font-weight: 700; }
.qr-wrap img { width: clamp(calc(110 * var(--u, 1px)), 10vw, calc(190 * var(--u, 1px))); border-radius: calc(12 * var(--u, 1px)); border: calc(4 * var(--u, 1px)) solid var(--paper); background: var(--paper); }

.players-panel { display: flex; flex-direction: column; min-height: 0; background: #1d1c26cc; border: calc(1 * var(--u, 1px)) solid var(--line); border-radius: calc(22 * var(--u, 1px)); padding: calc(26 * var(--u, 1px)); box-shadow: var(--shadow); }
.players-head h2 { font-size: clamp(calc(26 * var(--u, 1px)), 2.4vw, calc(44 * var(--u, 1px))); display: flex; align-items: center; gap: calc(14 * var(--u, 1px)); }
.count { font-family: var(--body); font-weight: 800; font-size: .6em; background: var(--accent); color: var(--ink); border-radius: calc(999 * var(--u, 1px)); padding: calc(2 * var(--u, 1px)) calc(14 * var(--u, 1px)); }
.lobby-players { flex: 1; min-height: 0; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: calc(22 * var(--u, 1px)); padding: calc(22 * var(--u, 1px)) calc(4 * var(--u, 1px)); }
.lobby-players .empty { color: var(--muted); font-size: calc(20 * var(--u, 1px)); margin: auto; text-align: center; }
.lp { display: grid; justify-items: center; gap: calc(8 * var(--u, 1px)); width: calc(120 * var(--u, 1px)); animation: popIn .7s cubic-bezier(.2, 1.8, .4, 1) both; }
.lp .avatar { animation: idleWiggle 3s ease-in-out infinite; animation-delay: var(--wd, 0s); }
.lp .nm { font-weight: 800; font-size: calc(17 * var(--u, 1px)); text-align: center; max-width: calc(120 * var(--u, 1px)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp .av-name { font-size: calc(12 * var(--u, 1px)); color: var(--muted); margin-top: -6px; }
.lp.away { opacity: .4; filter: grayscale(1); }
@keyframes popIn { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes idleWiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-4px); } }

.settings { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "pat start" "spd start"; gap: calc(14 * var(--u, 1px)) calc(26 * var(--u, 1px)); align-items: center; padding-top: calc(18 * var(--u, 1px)); border-top: calc(1 * var(--u, 1px)) solid var(--line); }
.settings .setting:first-child { grid-area: pat; }
.settings .setting:nth-child(2) { grid-area: spd; }
#btnStart { grid-area: start; }
.chips { display: flex; flex-wrap: wrap; gap: calc(8 * var(--u, 1px)); margin-top: calc(8 * var(--u, 1px)); }
.chip { border: calc(2 * var(--u, 1px)) solid var(--line); background: transparent; color: var(--paper); border-radius: calc(999 * var(--u, 1px)); padding: calc(7 * var(--u, 1px)) calc(14 * var(--u, 1px)); font-weight: 700; font-size: calc(14 * var(--u, 1px)); }
.chip.on { background: var(--cosmic); color: var(--ink); border-color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--accent); margin-top: calc(8 * var(--u, 1px)); }

/* ---------- game */
.game { position: fixed; inset: calc(64 * var(--u, 1px)) 0 0 0; display: grid; grid-template-columns: minmax(calc(260 * var(--u, 1px)), 24vw) minmax(0, 1fr) minmax(calc(240 * var(--u, 1px)), 21vw); gap: 2vw; padding: 2.5vh 2vw 2vh; }
.machine-col { display: flex; flex-direction: column; align-items: center; gap: 2vh; min-height: 0; }
.machine { position: relative; display: grid; justify-items: center; width: 100%; }
.cage { width: min(21vw, 34vh); aspect-ratio: 1; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 35% 30%, #ffffff22, #ffffff05 55%, #0000 70%), radial-gradient(circle, #2b236699, #100f14ee);
  border: calc(6 * var(--u, 1px)) solid var(--gold); box-shadow: 0 0 0 calc(6 * var(--u, 1px)) var(--ink), 0 0 calc(60 * var(--u, 1px)) #c1a3f544, inset 0 0 calc(40 * var(--u, 1px)) #000c; overflow: hidden; }
.cage canvas { width: 100%; height: 100%; display: block; }
.cage::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: repeating-conic-gradient(from 0deg, #f2d38a33 0 2deg, transparent 2deg 30deg); animation: spin 6s linear infinite; }
.cage.spinning::after { animation-duration: .6s; }
.chute { width: calc(60 * var(--u, 1px)); height: calc(26 * var(--u, 1px)); background: var(--gold); border: calc(4 * var(--u, 1px)) solid var(--ink); border-top: 0; border-radius: 0 0 calc(14 * var(--u, 1px)) calc(14 * var(--u, 1px)); margin-top: -4px; }
.current { height: min(16vw, 26vh); display: grid; place-items: center; margin-top: 1vh; }
.current-ball .ball { --size: min(16vw, 26vh); }
.current-ball .ball.drop { animation: ballDrop 1.1s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes ballDrop {
  0% { transform: translateY(-30vh) scale(.2) rotate(-540deg); opacity: 0; }
  55% { transform: translateY(0) scale(1.15) rotate(0); opacity: 1; }
  70% { transform: scale(.92, 1.08); }
  85% { transform: scale(1.04, .96); }
  100% { transform: none; }
}
.current-ball .ball.glow { box-shadow: inset -6px -8px calc(14 * var(--u, 1px)) #0006, 0 0 0 calc(6 * var(--u, 1px)) var(--ink), 0 0 calc(70 * var(--u, 1px)) var(--c); }
.recent { width: 100%; text-align: center; }
.recent-balls { display: flex; justify-content: center; gap: calc(10 * var(--u, 1px)); margin-top: calc(10 * var(--u, 1px)); min-height: calc(64 * var(--u, 1px)); }
.recent-balls .ball { --size: clamp(calc(44 * var(--u, 1px)), 3.4vw, calc(66 * var(--u, 1px))); animation: slideIn .5s ease both; }
.recent-balls .ball:nth-child(n+2) { opacity: .75; }
@keyframes slideIn { from { transform: translateX(-40px) scale(.5); opacity: 0; } }

.board-col { display: flex; flex-direction: column; gap: 2vh; min-height: 0; }
.board { flex: 1; display: grid; grid-template-columns: auto repeat(15, 1fr); grid-template-rows: repeat(5, 1fr); gap: .5vw; min-height: 0; }
.board .row-letter { display: grid; place-items: center; font-family: var(--display); font-size: clamp(calc(28 * var(--u, 1px)), 3.2vw, calc(64 * var(--u, 1px))); width: clamp(calc(48 * var(--u, 1px)), 4vw, calc(80 * var(--u, 1px))); border-radius: calc(12 * var(--u, 1px)); color: var(--ink); border: calc(3 * var(--u, 1px)) solid var(--ink); }
.board .row-letter.B { background: var(--ball-b); } .board .row-letter.I { background: var(--ball-i); }
.board .row-letter.N { background: var(--paper); } .board .row-letter.G { background: var(--ball-g); } .board .row-letter.O { background: var(--ball-o); }
.board .cell { display: grid; place-items: center; border-radius: 50%; aspect-ratio: 1; max-height: 100%; margin: auto; width: 100%;
  background: var(--surface); border: calc(2 * var(--u, 1px)) solid var(--line); color: #6b6d63; font-weight: 800; font-size: clamp(calc(14 * var(--u, 1px)), 1.45vw, calc(30 * var(--u, 1px))); transition: background .4s, color .4s; }
.board .cell.on { background: var(--c); color: var(--ink); border-color: var(--ink); box-shadow: 0 0 0 calc(2 * var(--u, 1px)) var(--ink), 0 calc(4 * var(--u, 1px)) calc(10 * var(--u, 1px)) #0008; }
.board .cell.fresh { animation: cellFlash 1.6s ease both; }
@keyframes cellFlash { 0% { transform: scale(2.2); box-shadow: 0 0 calc(60 * var(--u, 1px)) var(--c); } 40% { transform: scale(.9); } 100% { transform: none; } }

.pattern-demo { display: flex; align-items: center; gap: calc(18 * var(--u, 1px)); }
.pattern-name { font-family: var(--display); font-size: clamp(calc(22 * var(--u, 1px)), 2vw, calc(36 * var(--u, 1px))); color: var(--accent); }

.mini-card { display: grid; grid-template-columns: repeat(5, 1fr); gap: calc(3 * var(--u, 1px)); width: calc(90 * var(--u, 1px)); padding: calc(5 * var(--u, 1px)); background: var(--paper); border-radius: calc(8 * var(--u, 1px)); border: calc(3 * var(--u, 1px)) solid var(--ink); }
.mini-card i { aspect-ratio: 1; border-radius: calc(3 * var(--u, 1px)); background: #d8d8cc; }
.mini-card i.on { background: var(--robe); animation: demoPulse 1.6s ease-in-out infinite; }
@keyframes demoPulse { 50% { background: var(--cosmic); } }
.mini-card.big { width: clamp(calc(220 * var(--u, 1px)), 20vw, calc(360 * var(--u, 1px))); gap: calc(6 * var(--u, 1px)); padding: calc(10 * var(--u, 1px)); }
.mini-card.big i { display: grid; place-items: center; font-weight: 800; color: var(--ink); font-size: clamp(calc(14 * var(--u, 1px)), 1.3vw, calc(24 * var(--u, 1px))); }
.mini-card.big i.hit { background: #c1a3f588; }
.mini-card.big i.on { background: var(--accent); animation: winCell .7s ease-in-out infinite alternate; }
@keyframes winCell { to { transform: scale(1.1); box-shadow: 0 0 calc(16 * var(--u, 1px)) var(--accent); } }

.players-col { min-height: 0; display: flex; flex-direction: column; gap: calc(12 * var(--u, 1px)); padding-bottom: 32vh; }
.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: calc(10 * var(--u, 1px)); overflow: hidden; }
.leaderboard li { display: flex; align-items: center; gap: calc(12 * var(--u, 1px)); background: var(--surface); border: calc(1 * var(--u, 1px)) solid var(--line); border-radius: calc(14 * var(--u, 1px)); padding: calc(8 * var(--u, 1px)) calc(12 * var(--u, 1px)); transition: transform .5s, background .3s; }
.leaderboard li.hot { border-color: var(--accent); background: #2f3320; animation: hotPulse 1s ease-in-out infinite; }
@keyframes hotPulse { 50% { box-shadow: 0 0 calc(24 * var(--u, 1px)) #d5ed5866; } }
.leaderboard .who { flex: 1; min-width: 0; }
.leaderboard .nm { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaderboard .need { font-size: calc(13 * var(--u, 1px)); color: var(--muted); }
.leaderboard .meter { height: calc(6 * var(--u, 1px)); background: #0006; border-radius: calc(9 * var(--u, 1px)); overflow: hidden; margin-top: calc(5 * var(--u, 1px)); }
.leaderboard .meter b { display: block; height: 100%; background: linear-gradient(90deg, var(--cosmic), var(--accent)); transition: width .6s; }
.leaderboard .badge { font-weight: 800; font-size: calc(12 * var(--u, 1px)); background: var(--accent); color: var(--ink); border-radius: calc(999 * var(--u, 1px)); padding: calc(3 * var(--u, 1px)) calc(9 * var(--u, 1px)); white-space: nowrap; }

/* ---------- Scroggy on stage */
.scroggy { position: fixed; right: 1.5vw; bottom: 0; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.scroggy img { height: 30vh; filter: drop-shadow(0 calc(10 * var(--u, 1px)) calc(30 * var(--u, 1px)) #000c); transform-origin: bottom center; animation: bob 3.2s ease-in-out infinite; }
.scroggy.talking img { animation: talk .28s ease-in-out infinite alternate; }
@keyframes talk { from { transform: rotate(-2deg) scale(1, 1); } to { transform: rotate(2deg) scale(1.02, .98) translateY(-6px); } }
.scroggy .speech { max-width: 26vw; font-size: clamp(calc(14 * var(--u, 1px)), 1.15vw, calc(22 * var(--u, 1px))); margin-bottom: -2vh; margin-right: 8vw; animation: popIn .4s cubic-bezier(.2, 1.8, .4, 1) both; }
.scroggy .speech::after { content: ''; position: absolute; right: calc(30 * var(--u, 1px)); bottom: -18px; border: calc(10 * var(--u, 1px)) solid transparent; border-top-color: var(--ink); border-top-width: calc(16 * var(--u, 1px)); }
body.in-lobby .scroggy img { height: 26vh; }
body.in-lobby .scroggy { right: 2vw; }

/* ---------- winner */
.winner { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: #100f14ee; overflow: hidden; }
.winner-rays { position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg, #4b3fa655 0 10deg, transparent 10deg 20deg); animation: spin 18s linear infinite; }
.winner-inner { position: relative; display: grid; justify-items: center; gap: 3vh; }
.bingo-word { display: flex; gap: .05em; font-size: clamp(calc(90 * var(--u, 1px)), 13vw, calc(260 * var(--u, 1px))); line-height: 1; }
.bingo-word span { display: inline-block; text-shadow: calc(6 * var(--u, 1px)) calc(6 * var(--u, 1px)) 0 var(--ink), calc(12 * var(--u, 1px)) calc(12 * var(--u, 1px)) 0 var(--robe); animation: letterJump 1s cubic-bezier(.2, 1.8, .4, 1) both, letterBob 1.4s ease-in-out infinite; }
.bingo-word span:nth-child(1) { color: var(--ball-b); } .bingo-word span:nth-child(2) { color: var(--ball-i); }
.bingo-word span:nth-child(3) { color: var(--paper); } .bingo-word span:nth-child(4) { color: var(--ball-g); }
.bingo-word span:nth-child(5) { color: var(--ball-o); } .bingo-word span:nth-child(6) { color: var(--accent); }
@keyframes letterJump { from { transform: translateY(-80vh) rotate(-60deg); } }
@keyframes letterBob { 50% { transform: translateY(-18px) rotate(4deg); } }
.winner-row { display: flex; align-items: center; gap: 4vw; }
.winner-scroggy { height: 40vh; animation: bob 1.2s ease-in-out infinite; filter: drop-shadow(0 calc(10 * var(--u, 1px)) calc(30 * var(--u, 1px)) #000c); }
.winner-who { display: grid; justify-items: center; gap: calc(12 * var(--u, 1px)); }
.winner-who .avatar { animation: winnerSpin 1.2s cubic-bezier(.2, 1.4, .4, 1) both, idleWiggle 1s 1.2s ease-in-out infinite; }
@keyframes winnerSpin { from { transform: scale(0) rotate(-720deg); } }
.winner-name { font-family: var(--display); font-size: clamp(calc(36 * var(--u, 1px)), 4vw, calc(80 * var(--u, 1px))); color: var(--accent); text-shadow: calc(4 * var(--u, 1px)) calc(4 * var(--u, 1px)) 0 var(--ink); }
.winner-sub { color: var(--muted); font-size: calc(20 * var(--u, 1px)); }
.winner-actions { display: flex; gap: calc(16 * var(--u, 1px)); }

/* ---------- toasts */
.toasts { position: fixed; left: calc(24 * var(--u, 1px)); bottom: calc(24 * var(--u, 1px)); z-index: 40; display: flex; flex-direction: column-reverse; gap: calc(10 * var(--u, 1px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: calc(12 * var(--u, 1px)); background: var(--paper); color: var(--ink); border: calc(3 * var(--u, 1px)) solid var(--ink); border-radius: calc(16 * var(--u, 1px)); padding: calc(8 * var(--u, 1px)) calc(18 * var(--u, 1px)) calc(8 * var(--u, 1px)) calc(8 * var(--u, 1px)); font-weight: 800; box-shadow: calc(5 * var(--u, 1px)) calc(5 * var(--u, 1px)) 0 var(--ink); animation: toastIn .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.toast.bad { background: var(--danger); }
.toast.out { animation: toastOut .4s ease both; }
@keyframes toastIn { from { transform: translateX(-120%); } }
@keyframes toastOut { to { transform: translateX(-120%); opacity: 0; } }
.shake { animation: shake .5s; }
@keyframes shake { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(calc(12 * var(--u, 1px))); } }

/* lobby: keep Scroggy clear of the start button */
.lobby { padding-right: 17vw; }
.room-code { margin-top: calc(18 * var(--u, 1px)); }
body.in-lobby .scroggy .speech { margin-right: 2vw; max-width: 22vw; }

/* ---------- dunce corner (sits beside "To win") */
.dunce-corner { margin-left: auto; display: flex; align-items: flex-end; gap: calc(14 * var(--u, 1px)); background: #3a1d22cc; border: calc(2 * var(--u, 1px)) dashed var(--danger); border-radius: calc(16 * var(--u, 1px)); padding: calc(6 * var(--u, 1px)) calc(14 * var(--u, 1px)) calc(8 * var(--u, 1px)); max-width: 58%; animation: popIn .5s cubic-bezier(.2, 1.8, .4, 1) both; }
.dunce-head { font-family: var(--display); font-size: clamp(calc(20 * var(--u, 1px)), 1.6vw, calc(30 * var(--u, 1px))); line-height: 1; color: var(--danger); text-shadow: calc(2 * var(--u, 1px)) calc(2 * var(--u, 1px)) 0 var(--ink); align-self: center; width: min-content; }
.dunce-list { display: flex; gap: calc(10 * var(--u, 1px)); overflow: hidden; }
.dunce-kid { display: grid; justify-items: center; width: calc(74 * var(--u, 1px)); animation: popIn .6s cubic-bezier(.2, 1.8, .4, 1) both; }
.dk-av { position: relative; padding-top: calc(34 * var(--u, 1px)); }
.dk-av .avatar { filter: grayscale(.4); animation: sulk 2.4s ease-in-out infinite; }
@keyframes sulk { 50% { transform: rotate(-6deg) translateY(calc(3 * var(--u, 1px))); } }
.dk-av .dunce-cap { position: absolute; left: 50%; top: 0; width: calc(50 * var(--u, 1px)); transform: translateX(-50%) rotate(-10deg); filter: drop-shadow(0 calc(3 * var(--u, 1px)) calc(4 * var(--u, 1px)) #0008); animation: capWob 2.4s ease-in-out infinite; }
@keyframes capWob { 50% { transform: translateX(-50%) rotate(6deg); } }
.dk-av .avatar { --size: calc(56 * var(--u, 1px)) !important; }
.dk-name { font-weight: 800; font-size: calc(13 * var(--u, 1px)); max-width: calc(74 * var(--u, 1px)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-left { font-size: calc(11 * var(--u, 1px)); color: var(--muted); white-space: nowrap; }

/* ---------- prize on the winner screen */
.win-prize { display: flex; align-items: center; gap: calc(18 * var(--u, 1px)); background: var(--paper); color: var(--ink); border: calc(4 * var(--u, 1px)) solid var(--ink); border-radius: calc(18 * var(--u, 1px)); padding: calc(10 * var(--u, 1px)) calc(22 * var(--u, 1px)) calc(10 * var(--u, 1px)) calc(10 * var(--u, 1px)); box-shadow: 0 calc(8 * var(--u, 1px)) 0 var(--ink), 0 0 calc(50 * var(--u, 1px)) #d5ed5855; animation: popIn .8s 1s cubic-bezier(.2, 1.8, .4, 1) both; }
.win-prize img { width: clamp(calc(150 * var(--u, 1px)), 12vw, calc(230 * var(--u, 1px))); aspect-ratio: 16 / 10; object-fit: cover; border-radius: calc(10 * var(--u, 1px)); border: calc(3 * var(--u, 1px)) solid var(--ink); }
.win-prize .eyebrow { color: var(--robe); }
.win-prize p { font-family: var(--display); font-size: clamp(calc(22 * var(--u, 1px)), 2vw, calc(38 * var(--u, 1px))); line-height: 1.05; }
.win-prize span:last-child { font-weight: 700; color: #555; }
.winner-inner { gap: 2.2vh; }
.winner-scroggy { height: 34vh; }

/* ---------- per-ball call window: 3 calls + countdown to next ball */
.next-timer { width: min(16vw, 26vh); display: grid; justify-items: center; gap: calc(6 * var(--u, 1px)); margin-top: 1.2vh; }
.next-timer .calls { display: flex; gap: calc(8 * var(--u, 1px)); }
.next-timer .calls i { width: calc(14 * var(--u, 1px)); height: calc(14 * var(--u, 1px)); border-radius: 50%; border: calc(2 * var(--u, 1px)) solid var(--accent); transition: background .3s, transform .3s; }
.next-timer .calls i.on { background: var(--accent); transform: scale(1.15); }
.next-timer .bar { width: 100%; height: calc(8 * var(--u, 1px)); border-radius: calc(99 * var(--u, 1px)); background: #0007; border: calc(1 * var(--u, 1px)) solid var(--line); overflow: hidden; }
.next-timer .bar b { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cosmic), var(--accent)); transition: width .2s linear; }
.next-label { font-size: calc(13 * var(--u, 1px)); font-weight: 700; color: var(--muted); }

/* ---------- pause */
.pause-btn { display: inline-flex; align-items: center; gap: calc(8 * var(--u, 1px)); height: calc(42 * var(--u, 1px)); padding: 0 calc(16 * var(--u, 1px)); border-radius: calc(10 * var(--u, 1px)); border: calc(2 * var(--u, 1px)) solid var(--accent); background: transparent; color: var(--accent); font-weight: 800; font-size: calc(15 * var(--u, 1px)); }
.pause-btn:hover { background: var(--accent); color: var(--ink); }
.pause-btn.is-paused { background: var(--accent); color: var(--ink); animation: hotPulse 1.2s ease-in-out infinite; }
.pause-btn:disabled { opacity: .35; pointer-events: none; }
.paused { position: fixed; inset: calc(64 * var(--u, 1px)) 0 0 0; z-index: 25; display: grid; place-items: center; background: #100f14b8; backdrop-filter: blur(calc(6 * var(--u, 1px))); }
.paused-card { display: grid; justify-items: center; gap: calc(12 * var(--u, 1px)); text-align: center; background: var(--surface-2); border: calc(3 * var(--u, 1px)) solid var(--accent); border-radius: calc(24 * var(--u, 1px)); padding: clamp(calc(24 * var(--u, 1px)), 4vh, calc(48 * var(--u, 1px))) clamp(calc(28 * var(--u, 1px)), 5vw, calc(72 * var(--u, 1px))); box-shadow: var(--shadow); animation: popIn .5s cubic-bezier(.2, 1.8, .4, 1) both; }
.paused-card h1 { font-size: clamp(calc(64 * var(--u, 1px)), 9vw, calc(160 * var(--u, 1px))); line-height: .9; color: var(--accent); text-shadow: calc(5 * var(--u, 1px)) calc(5 * var(--u, 1px)) 0 var(--ink), calc(9 * var(--u, 1px)) calc(9 * var(--u, 1px)) 0 var(--robe); }
.paused-sub { color: var(--muted); font-size: clamp(calc(14 * var(--u, 1px)), 1.2vw, calc(20 * var(--u, 1px))); }
.paused-hint { color: var(--muted); font-size: calc(13 * var(--u, 1px)); }

/* ======================================================================
   Responsive. Media-query thresholds stay in real px.
   ====================================================================== */

/* Winner screen always fits the height (1366x768, 1280x720 laptops). */
.bingo-word { font-size: min(13vw, 17vh); }
.winner-scroggy { height: min(34vh, calc(420 * var(--u, 1px))); }
.winner-who .avatar { --size: min(calc(220 * var(--u, 1px)), 24vh) !important; }
.mini-card.big { width: min(clamp(calc(220 * var(--u, 1px)), 20vw, calc(360 * var(--u, 1px))), 34vh); }
.win-prize img { width: min(clamp(calc(150 * var(--u, 1px)), 12vw, calc(230 * var(--u, 1px))), 18vh); }
.winner-inner { max-height: 100vh; padding: 1vh 0; }

/* Lobby: keep Scroggy's bubble in his own gutter. */
body.in-lobby .scroggy .speech { max-width: 15vw; margin-right: 0; }

/* Short landscape screens: shrink the machine column so nothing clips. */
@media (max-height: 760px) and (orientation: landscape) {
  .cage { width: min(19vw, 30vh); }
  .current { height: min(14vw, 22vh); }
  .current-ball .ball { --size: min(14vw, 22vh) !important; }
  .recent-balls .ball { --size: clamp(36px, 3vw, 52px) !important; }
}

/* Portrait tablets, phones, narrow windows: stack everything and scroll. */
@media (orientation: portrait), (max-width: 900px) {
  body { height: auto; min-height: 100vh; overflow-x: hidden; overflow-y: auto; }

  .topbar { position: sticky; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .brand { font-size: 22px; }
  .top-mid { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; gap: 6px; }
  .pill { font-size: 12px; padding: 4px 10px; }

  .lobby { position: relative; inset: auto; grid-template-columns: 1fr; gap: 24px; padding: 20px 16px 26vh; }
  .join-panel { align-items: center; text-align: center; gap: 16px; }
  .lobby-logo { width: min(90vw, 560px); }
  .join-how { justify-items: center; }
  .room-code span { width: clamp(56px, 17vw, 110px); font-size: clamp(38px, 12vw, 84px); }
  .qr-wrap { justify-content: center; }
  .qr-wrap img { width: clamp(110px, 30vw, 180px); }
  .players-panel { padding: 18px; }
  .players-head h2 { font-size: clamp(24px, 6vw, 36px); }
  .lobby-players { min-height: 160px; gap: 14px; justify-content: center; }
  .lp { width: 96px; }
  .lp .avatar { --size: 84px !important; }
  .settings { grid-template-columns: 1fr; grid-template-areas: "pat" "spd" "start"; }
  #btnStart { width: 100%; }
  body.in-lobby .scroggy .speech { max-width: 55vw; }

  .game { position: relative; inset: auto; grid-template-columns: 1fr; gap: 20px; padding: 16px 12px 30vh; }
  .machine-col { display: grid; grid-template-columns: 1fr 1fr; align-items: center; justify-items: center; gap: 12px; }
  .machine { grid-column: 1; }
  .cage { width: min(38vw, 260px); }
  .current { height: auto; margin-top: 8px; }
  .current-ball .ball { --size: min(30vw, 200px) !important; }
  .next-timer { width: min(38vw, 260px); }
  .recent { grid-column: 2; grid-row: 1; }
  .recent-balls { flex-wrap: wrap; }
  .recent-balls .ball { --size: clamp(40px, 10vw, 60px) !important; }
  .board-col { gap: 16px; }
  .board { flex: none; gap: 1vw; }
  .board .row-letter { width: 7vw; font-size: 6vw; border-radius: 8px; border-width: 2px; }
  .board .cell { font-size: 2.9vw; border-width: 1px; }
  .pattern-demo { flex-wrap: wrap; gap: 12px; }
  .dunce-corner { margin-left: 0; max-width: 100%; flex-wrap: wrap; }
  .players-col { padding-bottom: 0; }

  .scroggy img { height: 18vh; }
  .scroggy .speech { max-width: 62vw; margin-right: 6vw; font-size: 15px; }
  .paused { inset: 0; }
  .paused-card { margin: 16px; }

  .winner { place-items: start center; overflow-y: auto; padding: 16px 12px 24px; }
  .winner-inner { max-height: none; gap: 14px; }
  .bingo-word { font-size: 17vw; }
  .winner-row { flex-direction: column; gap: 14px; }
  .winner-scroggy { height: 20vh; }
  .winner-who .avatar { --size: 150px !important; }
  .mini-card.big { width: min(78vw, 320px); }
  .win-prize { flex-direction: column; text-align: center; padding: 12px; max-width: 92vw; }
  .win-prize img { width: min(70vw, 280px); }
  .winner-actions { flex-wrap: wrap; justify-content: center; }

  .splash-logo { width: 90vw; }
  .splash-scroggy { height: 28vh; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
}

/* Small-landscape lobby (iPad landscape, small laptops): stack lobby, keep game layout */
@media (max-width: 1100px) and (orientation: landscape) {
  body.in-lobby { height: auto; overflow-y: auto; }
  .lobby { position: relative; inset: auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); padding: 20px 20px 20px; gap: 20px; min-height: 100vh; }
  .lp { width: 96px; }
  .lp .avatar { --size: 80px !important; }
  .settings { grid-template-columns: 1fr; grid-template-areas: "pat" "spd" "start"; }
  #btnStart { width: 100%; }
  body.in-lobby .scroggy img { height: 18vh; }
  body.in-lobby .scroggy .speech { display: none; }
}
/* Portrait winner: room for the bouncing BINGO letters */
@media (orientation: portrait), (max-width: 900px) {
  .winner { padding-top: 40px; }
}
@media (orientation: portrait), (max-width: 900px) {
  .winner-inner { padding-top: 6vh; }
}

/* Leave a strip under Scroggy for the Scroggygames.com link */
.scroggy { bottom: calc(44 * var(--u, 1px)); }
.winner .home-link, body:has(.winner:not([hidden])) .home-link { z-index: 61; }
@media (orientation: portrait), (max-width: 900px) { .scroggy { bottom: 40px; } }

/* ---------- end-of-game vote (winner screen) */
.vote-panel { width: min(calc(760 * var(--u, 1px)), 92vw); background: #100f14e6; border: 2px solid var(--cosmic); border-radius: calc(18 * var(--u, 1px)); padding: calc(14 * var(--u, 1px)) calc(20 * var(--u, 1px)); display: grid; gap: calc(10 * var(--u, 1px)); animation: popIn .6s 1.2s cubic-bezier(.2, 1.8, .4, 1) both; }
.vote-title { font-family: var(--display); font-size: calc(26 * var(--u, 1px)); color: var(--paper); }
.vote-title b { font-family: var(--body); font-size: .7em; color: var(--accent); }
.vote-opt { display: grid; grid-template-columns: calc(230 * var(--u, 1px)) 1fr calc(40 * var(--u, 1px)); align-items: center; gap: calc(12 * var(--u, 1px)); font-weight: 800; font-size: calc(18 * var(--u, 1px)); }
.vote-opt small { font-weight: 500; color: var(--muted); font-size: .75em; }
.vote-opt em { font-style: normal; font-size: calc(26 * var(--u, 1px)); text-align: right; }
.vbar { height: calc(16 * var(--u, 1px)); border-radius: 99px; background: #ffffff14; overflow: hidden; }
.vbar b { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .4s cubic-bezier(.2, 1.4, .4, 1); }
.vote-opt.restart .vbar b { background: var(--accent); }
.vote-opt.blackout .vbar b { background: var(--cosmic); }
.vote-result { font-family: var(--display); font-size: calc(26 * var(--u, 1px)); color: var(--accent); text-align: center; animation: popIn .4s cubic-bezier(.2, 1.8, .4, 1) both; }
@media (orientation: portrait), (max-width: 900px) { .vote-opt { grid-template-columns: 1fr 30px; } .vote-opt .vbar { grid-column: 1 / -1; grid-row: 2; } .vote-title { font-size: 20px; } }

/* Winner screen with the vote panel: compact everything so it fits the TV */
.winner:has(.vote-panel:not([hidden])) .winner-inner { gap: 1.4vh; padding-top: 3vh; }
.winner:has(.vote-panel:not([hidden])) .bingo-word { font-size: min(9vw, 12vh); }
.winner:has(.vote-panel:not([hidden])) .winner-scroggy { height: min(26vh, calc(320 * var(--u, 1px))); }
.winner:has(.vote-panel:not([hidden])) .winner-who .avatar { --size: min(calc(170 * var(--u, 1px)), 18vh) !important; }
.winner:has(.vote-panel:not([hidden])) .winner-name { font-size: min(4vw, 6vh); }
.winner:has(.vote-panel:not([hidden])) .mini-card.big { width: min(clamp(calc(200 * var(--u, 1px)), 17vw, calc(300 * var(--u, 1px))), 27vh); }
.winner:has(.vote-panel:not([hidden])) .win-prize img { width: min(calc(150 * var(--u, 1px)), 12vh); }
.winner:has(.vote-panel:not([hidden])) .win-prize p { font-size: min(2vw, 3.6vh); }
@media (orientation: portrait), (max-width: 900px) {
  .winner:has(.vote-panel:not([hidden])) .bingo-word { font-size: 15vw; }
  .winner:has(.vote-panel:not([hidden])) .winner-scroggy { height: 16vh; }
}
@media (max-height: 820px) and (orientation: landscape) {
  .winner:has(.vote-panel:not([hidden])) .win-prize { display: none; }
  .winner:has(.vote-panel:not([hidden])) .winner-sub { display: none; }
  .winner:has(.vote-panel:not([hidden])) .bingo-word { font-size: min(8vw, 11vh); }
  .winner:has(.vote-panel:not([hidden])) .vote-panel { gap: 6px; padding: 10px 16px; }
}
