/* Pool: the page around the table. The table itself is a WebGL canvas that fills the window (pool-view.js); the cue's
   pad styles itself (pool-input.js). Calm (html.calm) is the visitor's own choice: no media query switches anything off. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/inter-latin.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 600 700; font-display: swap; src: url('/fonts/sora-latin.woff2') format('woff2'); }
:root {
  color-scheme: dark;
  --bg: #0d0a10; --surface: #15121d; --surface-2: #1c1827; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #f2f0f8; --muted: #a8a4b9; --dim: #716d82;
  --purple: #a335ee; --pink: #e268a8; --gold: #e5cc80; --red: #ff5d6c; --green: #5cf2a6; --blue: #6fb5ff;
  --display: Sora, Inter, system-ui, sans-serif; --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2,.7,.2,1); --pop: cubic-bezier(.3,1.6,.5,1);
  --top: 64px; --bar: 58px;
  /* the HUD's glass: every panel over the room is cut from the same sheet */
  --glass: rgba(14,11,20,.56); --glass-2: rgba(24,19,33,.62); --glass-line: rgba(255,255,255,.11); --glass-hi: inset 0 1px 0 rgba(255,255,255,.09);
  --glass-shadow: 0 16px 40px -16px rgba(0,0,0,.9); --blur: blur(16px) saturate(1.4);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { color: var(--text); font: 15px/1.5 var(--font); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; border-radius: 8px; }
.ic { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--pink); color: #fff; font-weight: 600; }
.skip:focus { top: 12px; }
.nojs { position: fixed; inset: 40% 0 auto; text-align: center; }

/* ---------- the table ---------- */
.stage { position: fixed; inset: 0; z-index: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage canvas.gl { display: block; }
.s-play .stage { cursor: crosshair; }
.no-gl { position: absolute; inset: 40% 10% auto; text-align: center; color: var(--muted); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 30; pointer-events: none; }
.pops { position: fixed; inset: 0; z-index: 12; pointer-events: none; overflow: hidden; }
.pop { position: absolute; translate: -50% -50%; font: 800 15px var(--display); color: #fff; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--c, #e268a8); box-shadow: 0 6px 18px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.3); animation: pop-rise 1.25s var(--ease) both; }
.pop.ball { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%; font-size: 13px; color: #111;
  background: radial-gradient(circle at 50% 50%, #fff 0 38%, var(--c) 40%); }
.pop.ball.stripe { background: radial-gradient(circle at 50% 50%, #fff 0 38%, transparent 40%), linear-gradient(180deg, #f4f1e8 0 22%, var(--c) 22% 78%, #f4f1e8 78%); }
.pop.ball.eight { color: #111; background: radial-gradient(circle at 50% 50%, #fff 0 38%, #121212 40%); }
.pop.big { font-size: 26px; padding: 6px 16px; }
.pop.bad { --c: #ff5d6c; }
.pop.banner { font-size: clamp(28px, 6vw, 54px); padding: 8px 26px; letter-spacing: -.01em; background: linear-gradient(135deg, #b23ef0, #e0659d); animation-duration: 1.3s; }
@keyframes pop-rise { 0% { opacity: 0; transform: translateY(8px) scale(.5); } 18% { opacity: 1; transform: translateY(-6px) scale(1.12); } 30% { transform: translateY(-10px) scale(1); } 100% { opacity: 0; transform: translateY(-70px) scale(.95); } }
html.calm .pop { animation: pop-fade 1.2s linear both; }
@keyframes pop-fade { 0% { opacity: 0; } 15% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
/* a word slammed over the table: Nice!, BOOM!, Ouch */
.stamp { position: absolute; left: 50%; top: calc(var(--top) + var(--bar) + 118px); translate: -50% -50%; font: 800 clamp(26px, 4.6vw, 44px)/1 var(--display); letter-spacing: -.01em; color: #fff; padding: 8px 24px; border-radius: 16px; white-space: nowrap; rotate: -5deg;
  background: linear-gradient(135deg, #b23ef0, #e0659d); box-shadow: 0 18px 40px -10px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.3); animation: stamp-in 1.2s var(--ease) both; }
.stamp.good { background: linear-gradient(135deg, #17a96c, #5cf2a6); color: #052a19; }
.stamp.bad { background: linear-gradient(135deg, #ff4d60, #ff8a5c); rotate: 4deg; }
.stamp.boom { font-size: clamp(34px, 6.4vw, 62px); background: linear-gradient(135deg, #f2b84a, #ffe08a); color: #2a1c05; }
@keyframes stamp-in { 0% { opacity: 0; transform: scale(2); } 12% { opacity: 1; transform: scale(.94); } 20% { transform: scale(1.05); } 28%, 70% { transform: scale(1); opacity: 1; } 100% { opacity: 0; transform: scale(.9) translateY(-24px); } }
html.calm .stamp { animation: pop-fade 1.2s linear both; rotate: 0deg; }

/* ---------- header (the site's) ---------- */
.top { position: fixed; left: 0; right: 0; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: var(--top); padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(13,10,16,.72), rgba(13,10,16,.3) 70%, rgba(13,10,16,0)); pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 17px var(--display); letter-spacing: -.01em; white-space: nowrap; }
.brand img { width: 32px; height: 32px; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 8px 24px -10px rgba(226,104,168,.8); }
.crumb { color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.crumb b { color: var(--text); font-weight: 600; }
.crumb .sep { color: var(--dim); margin: 0 10px 0 2px; }
.top-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 13px; border: 0; background: var(--glass); color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: color .15s, background .15s, box-shadow .15s;
  box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi), 0 8px 20px -10px rgba(0,0,0,.8); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.icon-btn:hover { color: var(--text); background: var(--glass-2); }
.icon-btn .ic { width: 20px; height: 20px; }
.icon-btn .off { display: none; }
.icon-btn[aria-pressed="true"] .on { display: none; }
.icon-btn[aria-pressed="true"] .off { display: block; }
.icon-btn[aria-pressed="true"] { color: var(--pink); border-color: rgba(226,104,168,.4); }
body:not(.s-play) .in-game { display: none; }
@media (max-width: 600px) { :root { --top: 52px; } .crumb { display: none; } .brand span { display: none; } .icon-btn { width: 38px; height: 38px; } }

/* ---------- the game's bar ---------- */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.players { position: absolute; left: 50%; top: calc(var(--top) + 2px); translate: -50% 0; display: flex; align-items: center; gap: 10px; width: min(760px, calc(100% - 24px)); }
.pvs { font: 700 12px var(--display); color: var(--dim); letter-spacing: .1em; text-transform: uppercase; flex: none; }
.pcard { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 8px; border-radius: 18px; height: var(--bar);
  background: var(--glass); box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi), var(--glass-shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  transition: box-shadow .3s, background .3s, opacity .3s; opacity: .78; position: relative; }
.pcard#p1 { flex-direction: row-reverse; text-align: right; padding: 7px 8px 7px 12px; }
.pcard.active { opacity: 1; background: linear-gradient(135deg, rgba(163,53,238,.18), rgba(14,11,20,.6) 55%); box-shadow: 0 0 0 1.5px var(--pink), var(--glass-hi), 0 0 28px -6px rgba(226,104,168,.7), var(--glass-shadow); }
html:not(.calm) .pcard.active { animation: active-glow 2.4s ease-in-out infinite; }
@keyframes active-glow { 0%, 100% { box-shadow: 0 0 0 1.5px var(--pink), var(--glass-hi), 0 0 22px -6px rgba(226,104,168,.6), var(--glass-shadow); } 50% { box-shadow: 0 0 0 1.5px #f08cc2, var(--glass-hi), 0 0 36px -2px rgba(226,104,168,.8), var(--glass-shadow); } }
/* the avatar, with the turn ring round it: full while it is your turn, and the shot clock's countdown when that is on */
.pav-wrap { position: relative; width: 44px; height: 44px; flex: none; }
.pav { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 700 18px var(--display); color: #fff; overflow: hidden;
  background: linear-gradient(135deg, var(--purple), var(--pink)); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.pcard#p1 .pav { background: linear-gradient(135deg, #2f7de0, #33c0b5); }
.pav.bot { background: linear-gradient(160deg, #3a3550, #1e1a2c); }
.pring { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); transform: rotate(-90deg); opacity: 0; transition: opacity .3s; }
.pring circle { fill: none; stroke-width: 3.2; }
.pring-bg { stroke: rgba(255,255,255,.1); }
.pring-fg { stroke: var(--pink); stroke-linecap: round; stroke-dasharray: 138.23; stroke-dashoffset: 0; transition: stroke .3s; }
.pcard#p1 .pring-fg { stroke: #4fc3e0; }
.pcard.active .pring { opacity: 1; }
.pcard.hurry .pring-fg { stroke: var(--red) !important; }
html:not(.calm) .pcard.hurry .pav-wrap { animation: hurry .9s ease-in-out infinite; }
@keyframes hurry { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
/* the bot's face: a round robot with a mood (data-mood on .pav) */
.face { width: 100%; height: 100%; display: block; }
.face .f-head { fill: #eef1f7; }
.face .f-cheek { fill: #ffb3c7; opacity: .7; }
.face .f-ant { stroke: #c9cfdb; stroke-width: 2.2; stroke-linecap: round; } .face .f-bulb { fill: var(--pink); }
.face .f-blink { transform-box: fill-box; transform-origin: center; }
.face .f-eyes { transition: transform .25s; }
.face .f-eye { fill: #1b1b22; transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.face .f-brow { stroke: #1b1b22; stroke-width: 2.2; stroke-linecap: round; fill: none; transition: transform .25s; transform-box: fill-box; transform-origin: center; }
.face .f-mouth { display: none; stroke: #1b1b22; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.face .m-grin { fill: #1b1b22; }
.face .m-o { fill: #1b1b22; }
.pav[data-mood="idle"] .m-smile, .pav[data-mood="happy"] .m-smile, .pav[data-mood="think"] .m-flat, .pav[data-mood="grin"] .m-grin, .pav[data-mood="win"] .m-grin,
.pav[data-mood="sad"] .m-frown, .pav[data-mood="lose"] .m-frown, .pav[data-mood="ouch"] .m-o, .pav[data-mood="wow"] .m-o { display: block; }
.pav[data-mood="happy"] .f-brow, .pav[data-mood="grin"] .f-brow, .pav[data-mood="wow"] .f-brow { transform: translateY(-1.6px); }
.pav[data-mood="think"] .f-eyes { transform: translate(2.4px, -2.4px); }
.pav[data-mood="think"] .f-brow.r { transform: translateY(-2px) rotate(-8deg); }
.pav[data-mood="sad"] .f-brow.l, .pav[data-mood="lose"] .f-brow.l { transform: rotate(-16deg) translateY(.6px); }
.pav[data-mood="sad"] .f-brow.r, .pav[data-mood="lose"] .f-brow.r { transform: rotate(16deg) translateY(.6px); }
.pav[data-mood="ouch"] .f-eye { transform: scaleY(.22); }
.pav[data-mood="ouch"] .f-brow.l { transform: rotate(12deg); } .pav[data-mood="ouch"] .f-brow.r { transform: rotate(-12deg); }
.pav[data-mood="wow"] .f-eye { transform: scale(1.3); }
.pav[data-mood="win"] .f-eye { transform: scaleY(.3) translateY(-2px); }
.pav[data-mood="win"] .f-cheek, .pav[data-mood="happy"] .f-cheek, .pav[data-mood="grin"] .f-cheek { opacity: 1; }
html:not(.calm) .pav[data-mood="idle"] .f-blink, html:not(.calm) .pav[data-mood="think"] .f-blink { animation: blink 4.6s ease-in-out infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
html:not(.calm) .pav[data-mood="think"] { animation: think-wobble 1.4s ease-in-out infinite; }
@keyframes think-wobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
.ptext { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pname { font: 700 15px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pgroup { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.pgroup.solids { color: #ffd36b; } .pgroup.stripes { color: #9fd0ff; } .pgroup.eight { color: #fff; }
/* the balls still to pot: little numbered balls, the potted ones faded */
.pballs { display: flex; gap: 3px; margin-left: auto; flex-wrap: nowrap; }
.pcard#p1 .pballs { margin-left: 0; margin-right: auto; flex-direction: row-reverse; }
.mb { width: 19px; height: 19px; border-radius: 50%; flex: none; position: relative; display: grid; place-items: center; font: 800 9px/1 var(--display); color: #141418; letter-spacing: -.04em;
  background: radial-gradient(circle at 50% 50%, #f8f5ee 0 33%, var(--c) 35%); box-shadow: inset -2px -2px 3px rgba(0,0,0,.35), inset 1px 1px 2px rgba(255,255,255,.4), 0 1px 2px rgba(0,0,0,.45); transition: opacity .3s, transform .3s; }
.mb.stripe { background: radial-gradient(circle at 50% 50%, #f8f5ee 0 33%, transparent 35%), linear-gradient(180deg, #f4f1e8 0 22%, var(--c) 22% 78%, #f4f1e8 78%); }
.mb.gone { opacity: .14; transform: scale(.78); }
.mb.eight { background: radial-gradient(circle at 50% 50%, #f8f5ee 0 33%, #161618 35%); box-shadow: inset -2px -2px 3px rgba(0,0,0,.5), inset 1px 1px 2px rgba(255,255,255,.3), 0 0 0 1.5px rgba(255,255,255,.45); }
html:not(.calm) .mb.just { animation: mb-pop .6s var(--pop) both; }
@keyframes mb-pop { 0% { transform: scale(1.5); opacity: 1; } 100% { transform: scale(.78); opacity: .14; } }
.ptag { position: absolute; left: 50%; bottom: -9px; translate: -50% 0; font: 700 10px var(--font); letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--pink); color: #fff; opacity: 0; transition: opacity .2s; }
.pcard.active .ptag { opacity: 1; }
.ptag.hand { background: var(--green); color: #07261a; }
.single .pvs, .single #p1 { display: none; }
.single .players { width: min(420px, calc(100% - 24px)); }

.toast { position: absolute; left: 50%; top: calc(var(--top) + var(--bar) + 20px); translate: -50% 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 10px 18px 11px; border-radius: 18px; max-width: min(560px, calc(100% - 32px)); background: var(--glass-2); box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi), var(--glass-shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); opacity: 0; transform: translateY(-6px) scale(.96); transition: opacity .25s, transform .25s var(--ease); }
.toast.show { opacity: 1; transform: none; }
html:not(.calm) .toast.show.bounce { animation: toast-in .5s var(--pop) both; }
@keyframes toast-in { 0% { opacity: 0; transform: translateY(-12px) scale(.85); } 100% { opacity: 1; transform: none; } }
.toast b { font: 700 17px/1.25 var(--display); }
.toast span { font-size: 13px; color: var(--muted); font-weight: 500; }
.toast.foul { box-shadow: 0 0 0 1.5px rgba(255,93,108,.7), var(--glass-hi), var(--glass-shadow); }
.toast.foul b { color: #ff8a96; }
.toast.good { box-shadow: 0 0 0 1.5px rgba(92,242,166,.55), var(--glass-hi), var(--glass-shadow); }
.toast.win b { font-size: 22px; background: linear-gradient(90deg, var(--gold), #fff, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hint { position: absolute; left: 50%; bottom: 84px; translate: -50% 0; margin: 0; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap;
  background: var(--glass); box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }

/* the cue's pieces: power beside the table on the right, spin and fine aim in one glass dock at the bottom left */
.dock-power { position: absolute; right: max(14px, env(safe-area-inset-right)); top: 50%; translate: 0 -38%; pointer-events: auto; }
.dock-low { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 14px; pointer-events: auto;
  padding: 26px 14px 12px 12px; border-radius: 24px; background: var(--glass); box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi), var(--glass-shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.dock-fine { width: 220px; }
.dock-fine .cue-pad, .dock-fine .cp-fine { width: 100%; }
.cp-off { opacity: .35; pointer-events: none !important; transition: opacity .2s; }
.cp-off * { pointer-events: none !important; }
@media (max-width: 600px) {
  :root { --bar: 50px; }
  .players { gap: 6px; width: calc(100% - 16px); }
  .pvs { display: none; }
  .pcard { padding: 5px 8px 5px 6px; gap: 7px; border-radius: 14px; }
  .pcard#p1 { padding: 5px 6px 5px 8px; }
  .pav-wrap, .pav { width: 34px; height: 34px; } .pav { font-size: 14px; }
  .pring { inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); } .pring circle { stroke-width: 3.6; }
  .pname { font-size: 13px; }
  .pgroup { font-size: 11px; }
  .pballs { display: grid; grid-template-columns: repeat(4, 11px); gap: 2px; }
  .mb { width: 11px; height: 11px; font-size: 0; }
  .stamp { top: calc(var(--top) + var(--bar) + 100px); }
  .toast { top: calc(var(--top) + var(--bar) + 14px); padding: 8px 14px; }
  .toast b { font-size: 15px; } .toast span { font-size: 12px; }
  .dock-power { right: 8px; }
  .dock-power .cp-power { width: 46px; height: 196px; }
  .dock-low { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); gap: 16px; padding: 22px 12px 10px 10px; border-radius: 22px; }
  .dock-fine { flex: 1; width: auto; }
  .hint { bottom: 82px; font-size: 12px; }
}

/* an upright phone: the power bar lies on the right-hand rail (placed by the script), thin and see-through until touched */
.compact .dock-power { translate: none; top: 0; right: auto; }
.compact .dock-power .cp-power { width: var(--pw, 34px); height: var(--ph, 180px); border-radius: 12px; background: rgba(14,11,20,.5); }
.compact .dock-power .cp-power .cp-track { left: 5px; right: 5px; }
.compact .dock-power .cp-power .cp-stick { width: 8px; margin-left: -4px; }
.compact .dock-power .cp-power span { font-size: 9px; letter-spacing: .02em; }
.compact .hint { top: calc(var(--top) + var(--bar) + 12px); bottom: auto; }
/* an upright phone: the words for a shot lie over the players' strip, and a stamp over the controls at the near end, so
   nothing covers the far end of the table, where the balls are after a break */
.compact .toast { top: calc(var(--top) + 2px); min-height: var(--bar); justify-content: center; z-index: 12; }
.compact .stamp { top: auto; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 40px); translate: -50% 0; }
@media (max-height: 520px) and (orientation: landscape) {
  :root { --top: 46px; --bar: 42px; }
  .brand span { display: none; }
  .pav-wrap, .pav { width: 30px; height: 30px; } .pav { font-size: 13px; }
  .pring { inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); }
  .pcard { padding: 4px 10px 4px 6px; }
  .toast { top: calc(var(--top) + var(--bar) + 10px); padding: 6px 12px; }
  .toast b { font-size: 14px; } .toast span { font-size: 12px; }
  /* the spin ball and an upright fine-aim wheel in one column at the left edge, the power bar at the right one */
  .dock-low { flex-direction: column-reverse; align-items: center; top: calc(var(--top) + 6px); bottom: max(8px, env(safe-area-inset-bottom)); left: max(8px, env(safe-area-inset-left));
    padding: 12px 8px 10px; gap: 24px; border-radius: 20px; }
  .dock-fine { width: 44px; flex: 1; min-height: 0; }
  .dock-fine .cue-pad, .dock-fine .cp-fine { width: 44px; min-width: 0; height: 100%; }
  .dock-power .cp-power { height: 150px; }
  .hint { display: none; }
  .crumb { display: none; }
  .players { top: 2px; left: 64px; right: 252px; width: auto; translate: none; gap: 6px; }
  .pvs { display: none; }
  .pballs { display: grid; grid-template-columns: repeat(4, 10px); gap: 2px; } .mb { width: 10px; height: 10px; font-size: 0; }
  .toast { top: calc(var(--top) + 4px); }
}

/* ---------- start and end cards ---------- */
.screen { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: calc(var(--top) + 8px) 16px 16px; overflow-y: auto; }
.screen::before { content: ""; position: fixed; inset: 0; background: radial-gradient(120% 90% at 50% 40%, rgba(13,10,16,.05), rgba(13,10,16,.55)); pointer-events: none; }
/* a wide screen: the start card stands to the left and the room is the view (the script frames the table in the rest) */
@media (min-width: 1100px) and (min-height: 600px) {
  .menu { place-items: center start; padding-left: max(48px, 5vw); }
  .menu::before { background: linear-gradient(90deg, rgba(13,10,16,.6), rgba(13,10,16,.2) 45%, rgba(13,10,16,.1)); }
}
.card { position: relative; width: min(520px, 100%); padding: 24px 24px 20px; border-radius: 26px; background: rgba(16,12,22,.66); box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi), 0 30px 80px -20px rgba(0,0,0,.95);
  backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4); }
html:not(.calm) .card { animation: card-in .5s var(--ease) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.logo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.logo-ball { width: 62px; height: 62px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 28%, #6a6a6a, #151515 45%, #050505); box-shadow: 0 10px 26px rgba(0,0,0,.6), inset -4px -6px 10px rgba(0,0,0,.5); position: relative; }
.logo-ball::after { content: ""; position: absolute; left: 22%; top: 14%; width: 26%; height: 16%; border-radius: 50%; background: rgba(255,255,255,.55); filter: blur(2px); rotate: -25deg; }
.logo-ball i { width: 46%; height: 46%; border-radius: 50%; background: #f7f4ec; color: #111; display: grid; place-items: center; font: 800 16px var(--display); font-style: normal; }
html:not(.calm) .logo-ball { animation: ball-wobble 4s ease-in-out infinite; }
@keyframes ball-wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(10deg); } }
.logo-ball.big { width: 84px; height: 84px; margin: 0 auto 8px; }
.logo-ball.big i { font-size: 20px; }
.logo { margin: 0; font: 800 40px/1 var(--display); letter-spacing: -.03em; background: linear-gradient(90deg, #fff, #f3c6df 50%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode span { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 12px 6px 10px; border-radius: 16px; cursor: pointer; height: 100%;
  background: rgba(255,255,255,.03); box-shadow: inset 0 0 0 1px var(--line-2); transition: background .15s, box-shadow .15s, transform .15s var(--ease); }
.mode span:hover { background: rgba(255,255,255,.06); }
.mode input:checked + span { background: linear-gradient(160deg, rgba(163,53,238,.22), rgba(226,104,168,.16)); box-shadow: inset 0 0 0 2px var(--pink); }
.mode input:focus-visible + span { outline: 2px solid var(--pink); outline-offset: 2px; }
.mode .mic { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--pink); margin-bottom: 4px; }
.mode b { font: 700 14px/1.2 var(--display); }
.mode small { color: var(--muted); font-size: 12px; }
.opts { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.opt-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.opt-row > .lbl { width: 54px; color: var(--muted); font-size: 13px; font-weight: 600; }
.names { gap: 10px; }
.name { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 4px; }
.name .lbl { color: var(--muted); font-size: 12px; font-weight: 600; }
.name input { width: 100%; padding: 10px 12px; border-radius: 12px; border: 0; background: rgba(255,255,255,.05); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--text); font: 600 15px var(--font); }
.name input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--pink); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255,255,255,.04); box-shadow: inset 0 0 0 1px var(--line-2); flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); transition: background .15s, color .15s; }
.seg input:checked + span { background: linear-gradient(135deg, #8f3be0, #d04aa6); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--pink); outline-offset: 1px; }
.felts { display: flex; gap: 8px; flex-wrap: wrap; }
.felt input { position: absolute; opacity: 0; pointer-events: none; }
.felt span { display: block; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), inset 0 -8px 14px rgba(0,0,0,.3); transition: transform .15s var(--ease), box-shadow .15s; }
.felt input:checked + span { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--pink), inset 0 -8px 14px rgba(0,0,0,.3); transform: scale(1.06); }
.felt input:focus-visible + span { outline: 2px solid var(--pink); outline-offset: 4px; }
.play { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 14px 24px; border: 0; border-radius: 16px; cursor: pointer; font: 700 18px var(--display); color: #fff;
  background: linear-gradient(135deg, #b23ef0, #d04aa6 60%, #e0659d); box-shadow: 0 14px 34px -12px rgba(214,71,170,.95), inset 0 1px 0 rgba(255,255,255,.2); transition: transform .15s var(--ease), filter .15s; }
.play:hover { filter: brightness(1.08); transform: translateY(-1px); }
.play:active { transform: scale(.98); }
.play-icon svg { width: 18px; height: 18px; display: block; }
.ghost-btn { width: 100%; padding: 12px 20px; border: 0; border-radius: 14px; cursor: pointer; font: 600 15px var(--font); color: var(--text); background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 1px var(--line-2); }
.ghost-btn:hover { background: rgba(255,255,255,.1); }
.link-btn { border: 0; background: none; padding: 0; color: var(--pink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.menu-foot { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
/* an upright phone: the start card sits at the bottom, the room (the far end of the table under its lamp, the sign) above it */
@media (max-width: 600px) and (orientation: portrait) {
  .menu { place-items: end center; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .menu::before { background: linear-gradient(180deg, rgba(13,10,16,.1), rgba(13,10,16,.2) 40%, rgba(13,10,16,.6)); }
}
/* a sideways phone (any short, wide screen): the start card in two columns, so "Rack 'em" is in sight without scrolling */
@media (max-height: 520px) and (orientation: landscape) {
  .menu.screen { padding-top: calc(var(--top) + 4px); padding-bottom: 8px; }
  .menu-card { width: min(780px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); column-gap: 18px; padding: 14px 18px 12px; }
  .menu-card .logo-row { grid-column: 1; grid-row: 1; margin-bottom: 10px; gap: 12px; }
  .menu-card .logo { font-size: 28px; }
  .menu-card .logo-ball { width: 42px; height: 42px; }
  .menu-card .tagline { font-size: 12px; }
  .menu-card .modes { grid-column: 1; grid-row: 2 / span 2; align-self: start; margin-bottom: 0; }
  .menu-card .opts { grid-column: 2; grid-row: 1 / span 2; margin-bottom: 10px; gap: 8px; }
  .menu-card .play { grid-column: 2; grid-row: 3; padding: 11px 20px; }
  .menu-card .menu-foot { grid-column: 1 / -1; grid-row: 4; margin-top: 8px; }
}
@media (max-width: 460px) {
  .card { padding: 18px 16px 16px; border-radius: 20px; }
  .logo { font-size: 32px; } .logo-ball { width: 50px; height: 50px; }
  .mode span { padding: 10px 4px 8px; } .mode b { font-size: 13px; } .mode small { font-size: 11px; }
}

.over-card { text-align: center; }
.over-title { margin: 4px 0 6px; font: 800 30px/1.15 var(--display); background: linear-gradient(90deg, var(--gold), #fff 50%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.over-text { margin: 0 0 14px; color: var(--muted); }
.over-stats { list-style: none; margin: 0 0 18px; padding: 0; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.over-stats li { padding: 6px 12px; border-radius: 12px; background: rgba(255,255,255,.05); font-size: 13px; color: var(--muted); }
.over-stats b { color: var(--text); }
.over-row { display: flex; flex-direction: column; gap: 8px; }

/* ---------- dialogs ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(6,5,10,.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dlg { position: relative; width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 22px 22px 20px; border-radius: 24px; background: rgba(21,17,29,.9); box-shadow: 0 0 0 1px var(--glass-line), var(--glass-hi), 0 30px 80px -20px rgba(0,0,0,.95);
  backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3); }
.dlg.wide { width: min(640px, 100%); }
.dlg.small { width: min(340px, 100%); }
.dlg-title { margin: 0 0 14px; font: 700 20px var(--display); }
.close-x { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.05); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.close-x:hover { color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.settings-body { display: flex; flex-direction: column; gap: 18px; }
.row-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.lbl2 { font-weight: 700; font-size: 14px; }
.row-note { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: rgba(255,255,255,.12); position: relative; flex: none; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch input:checked + .track { background: linear-gradient(135deg, #8f3be0, #d04aa6); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--pink); outline-offset: 2px; }
.switch-text { font-weight: 600; font-size: 14px; display: flex; flex-direction: column; }
.switch-text small { color: var(--muted); font-weight: 500; font-size: 12px; }
.help section + section { margin-top: 14px; }
.help h3 { margin: 0 0 6px; font: 700 15px var(--display); color: var(--pink); }
.help p { margin: 0 0 8px; color: #d7d3e4; font-size: 14px; }
