/* R-Pool HUD and controls. Every distance from the scale (4 8 12 16 20 24 32 48), times --hudz
   (1 on a phone, up to 1.5 on a big screen, never under the phone size). The bands around the
   table come from the fitted camera (--tt / --tbm / --tl / --tr, measured in controls-ui.js). */
:root { --ff: -apple-system, "SF Pro Display", "Helvetica Neue", Arial, sans-serif; --hudz: 1; --tt: 80px; --tbm: 80px; --tl: 0px; --tr: 0px; --rail-h: 40px; --z: var(--hudz);
  --gold: #f3c969; --ink: #f4efe6; --glass: rgba(18, 12, 9, .62); --glass-b: rgba(255, 236, 205, .14); }

#hud, #controls { position: absolute; inset: 0; pointer-events: none; z-index: 14; font-family: -apple-system, "SF Pro Display", "Helvetica Neue", Arial, sans-serif; color: var(--ink); }
body:not(.in-match) #hud, body:not(.in-match) #controls { display: none; }

/* ── plates ── */
#plates { position: absolute; display: flex; gap: calc(12px * var(--z)); }
.plate { display: flex; align-items: center; gap: calc(8px * var(--z)); padding: calc(8px * var(--z)) calc(12px * var(--z)) calc(8px * var(--z)) calc(8px * var(--z));
  /* a darker glass than the controls': the name and chips keep 4.5:1 over the busiest room behind them */
  background: linear-gradient(rgba(10, 7, 5, .42), rgba(10, 7, 5, .42)), var(--glass); border: 1px solid var(--glass-b); border-radius: calc(16px * var(--z));
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 8px 24px rgba(0,0,0,.35); min-width: 0; transition: border-color .25s, box-shadow .25s; }
.plate.turn { border-color: rgba(243, 201, 105, .55); box-shadow: 0 0 0 1px rgba(243,201,105,.25), 0 8px 24px rgba(0,0,0,.4); }
.pic { position: relative; flex: none; width: calc(48px * var(--z)); height: calc(48px * var(--z)); border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #5a3b26, #23150d); }
.pic svg { position: absolute; inset: calc(-4px * var(--z)); width: calc(56px * var(--z)); height: calc(56px * var(--z)); transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.1); stroke-width: 3; }
.ring { fill: none; stroke: var(--gold); stroke-width: 3.4; stroke-linecap: round; }
.plate:not(.turn) .ring { stroke: transparent; }
.plate.last5 .ring { stroke: #ff5b4a; }
.plate.last5 .pic { animation: beat 1s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.08); } 24% { transform: scale(1); } 36% { transform: scale(1.05); } }
.ini { font: 700 calc(20px * var(--z))/1 var(--ff); letter-spacing: .02em; color: #ffe8c4; }
.secs { position: absolute; inset: 0; display: grid; place-items: center; font: 800 calc(20px * var(--z))/1 var(--ff); color: #fff; background: rgba(160, 28, 18, .55); border-radius: 50%; }
.secs:empty { display: none; }
.info { max-width: 100%; display: flex; flex-direction: column; gap: calc(4px * var(--z)); min-width: 0; }
.name { font: 650 calc(14px * var(--z))/calc(16px * var(--z)) var(--ff); overflow-wrap: anywhere; text-wrap: balance; }
.chips { display: flex; flex-wrap: wrap; gap: calc(4px * var(--z)); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: calc(4px * var(--z)); white-space: nowrap; font: 700 calc(11px * var(--z))/calc(16px * var(--z)) var(--ff); letter-spacing: .04em; text-transform: uppercase; padding: 0 calc(8px * var(--z)); border-radius: 999px; background: rgba(255,255,255,.1); }
.chip.group::before { content: ""; flex: none; width: calc(8px * var(--z)); height: calc(8px * var(--z)); border-radius: 50%; background: rgba(255,255,255,.55); }
.chip.solid::before { background: radial-gradient(circle at 35% 30%, #ffe27a, #d9a400); }
.chip.stripe::before { background: linear-gradient(#f6f2e8 0 25%, #2b5fe0 25% 75%, #f6f2e8 75%); }
.chip.solid { background: rgba(243, 194, 27, .22); color: #ffd85c; }
.chip.stripe { background: rgba(43, 95, 224, .28); color: #cfe0ff; }
.chip.open { color: rgba(255,255,255,.7); }
.chip.streak { background: rgba(255, 120, 40, .25); color: #ffb37a; }
.chip[hidden] { display: none; }
.tray { max-width: 100%; display: flex; gap: 0; flex-wrap: wrap; }
.tray:empty { display: none; }
.tb { width: calc(12px * var(--z)); height: calc(12px * var(--z)); border-radius: 50%; font-size: 0; color: transparent;
  background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.75) 0 10%, transparent 24%), radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--bc) 70%, #fff), var(--bc) 60%, #000 140%); box-shadow: inset 0 -1px 2px rgba(0,0,0,.5); }
.tb.stripe { background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.75) 0 10%, transparent 24%), linear-gradient(#f6f2e8 0 22%, var(--bc) 22% 78%, #f6f2e8 78%); }
.tb.eight { background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.6) 0 10%, transparent 24%), radial-gradient(circle at 35% 30%, #555, #050505 70%); }
.tb.next { opacity: .45; outline: 1px dashed rgba(255,255,255,.5); outline-offset: 1px; }

/* ── hint, banner, flourish ── */
#hint { position: absolute; left: 50%; transform: translateX(-50%); padding: calc(4px * var(--z)) calc(12px * var(--z)); border-radius: 999px; background: rgba(0,0,0,.5);
  font: 600 calc(13px * var(--z))/calc(16px * var(--z)) var(--ff); white-space: nowrap; opacity: 0; transition: opacity .2s; }
#hint.on { opacity: 1; }
#banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96); display: flex; flex-direction: column; align-items: center; gap: calc(8px * var(--z));
  padding: calc(16px * var(--z)) calc(24px * var(--z)); border-radius: calc(16px * var(--z)); background: rgba(70, 14, 10, .72); border: 1px solid rgba(255, 120, 100, .35);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); opacity: 0; transition: opacity .2s, transform .2s; text-align: center; max-width: calc(100vw - 32px); }
#banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.b-title { font: 800 calc(24px * var(--z))/calc(28px * var(--z)) var(--ff); letter-spacing: .02em; text-transform: uppercase; color: #ffd9d2; }
.b-sub { font: 600 calc(13px * var(--z))/calc(16px * var(--z)) var(--ff); color: rgba(255,235,230,.85); text-wrap: balance; }
#flourish { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font: 900 italic calc(28px * var(--z))/1 var(--ff); letter-spacing: .03em; color: #ffe39a;
  text-shadow: 0 2px 12px rgba(255, 170, 40, .6), 0 1px 0 #7a4b00; opacity: 0; white-space: nowrap; }
#flourish.go { animation: flo 1.4s ease-out forwards; }
@keyframes flo { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 70% { opacity: 1; transform: translate(-50%, -54%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -64%) scale(1); } }

/* ── the called pocket ── */
#pockets { position: absolute; inset: 0; display: none; }
#pockets.on { display: block; }
.pk { position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); background: rgba(255,255,255,.06); pointer-events: auto; cursor: pointer;
  animation: pk 1.6s ease-in-out infinite; }
.pk.chosen { border-color: #ffd35a; background: radial-gradient(circle, rgba(255,211,90,.55), rgba(255,211,90,.05) 70%); box-shadow: 0 0 24px 8px rgba(255, 200, 70, .55); animation: none; }
#pockets.nudge .pk:not(.chosen) { animation: pkn .4s ease-in-out 2; }
@keyframes pk { 50% { box-shadow: 0 0 16px 4px rgba(255,255,255,.35); } }
@keyframes pkn { 50% { transform: scale(1.25); border-color: #fff; } }

/* ── the break choice and the spin panel: the SDK's dialog look ── */
.pool-dialog { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 8, 14, .45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); pointer-events: auto; }
.pool-dialog.on { display: flex; }
.pd-card { position: relative; width: min(100%, calc(360px * var(--z))); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: #e6f0ff;
  padding: 24px; border-radius: 18px; border: 1px solid rgba(255,255,255,.12); box-shadow: 0 22px 70px rgba(0,0,0,.65);
  background: radial-gradient(140% 120% at 50% 0%, rgba(38, 73, 128, .75) 0%, rgba(10, 16, 28, .92) 55%); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.pd-label { font: 700 12px/16px var(--ff); letter-spacing: .12em; text-transform: uppercase; color: rgba(150, 200, 255, .85); }
.pd-card h2 { margin: 0; font: 750 20px/24px var(--ff); text-wrap: balance; }
.pd-text { margin: 0; font: 500 14px/20px var(--ff); color: rgba(230,240,255,.8); text-wrap: balance; }
.pd-buttons { display: flex; gap: 12px; width: 100%; margin-top: 12px; }
.pd-btn { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff; font: 700 15px/1 var(--ff); cursor: pointer; }
.pd-btn.pd-primary { background: linear-gradient(180deg, #3d7bff, #2554d8); border-color: rgba(140,180,255,.6); }
.pd-btn:active { transform: scale(.97); }
.big-face { position: relative; width: 168px; height: 168px; border-radius: 50%; touch-action: none; cursor: crosshair;
  background: radial-gradient(circle at 34% 28%, #fff 0 8%, rgba(255,255,255,0) 22%), radial-gradient(circle at 42% 38%, #fbf8f1, #e4ddcf 48%, #9e978a 82%, #6b655c 100%); box-shadow: inset -10px -14px 28px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.5); }
.big-face .cross { position: absolute; inset: 20%; border-radius: 50%; border: 1px dashed rgba(0,0,0,.18); }
.dot { position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ff7a6a, #c01c10);
  transform: translate(calc(-50% + var(--sx, 0) * 180%), calc(-50% - var(--sy, 0) * 180%)); box-shadow: 0 1px 3px rgba(0,0,0,.5); }

/* ── controls ── */
.ctl { position: absolute; pointer-events: auto; touch-action: none; }
body:not(.my-shot) .ctl { opacity: .38; pointer-events: none; }
#spin-btn { width: calc(48px * var(--z)); height: calc(48px * var(--z)); border-radius: 50%; border: 1px solid var(--glass-b); background: var(--glass); padding: calc(4px * var(--z)); cursor: pointer; }
#spin-btn .face { position: relative; display: block; width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff 0 8%, rgba(255,255,255,0) 22%), radial-gradient(circle at 42% 38%, #fbf8f1, #e4ddcf 48%, #9e978a 82%, #6b655c 100%);
  box-shadow: inset -3px -5px 9px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.45); }
#spin-btn .face::after, .big-face::after { content: ""; position: absolute; inset: 18%; border-radius: 50%; border: 1.5px solid rgba(200, 40, 30, .35); pointer-events: none; }
#spin-btn .face .dot { width: 26%; height: 26%; box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 1px 3px rgba(0,0,0,.6); }
#power { border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-b); cursor: grab; }
#power .track { position: absolute; inset: calc(8px * var(--z)); border-radius: 999px; overflow: hidden; background: rgba(0,0,0,.45); }
#power .fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p, 0) * 100%); background: linear-gradient(90deg, #36d17a, #f3c969 60%, #ff5b4a); border-radius: inherit; }
#power .ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255,255,255,.18) calc(10% - 1px) 10%); }
#power .cue-icon { position: absolute; top: 50%; right: calc(16px * var(--z)); width: 40%; height: 4px; margin-top: -2px; border-radius: 2px; background: linear-gradient(90deg, #3b62a8 0 3%, #f4f1ea 3% 6%, #e9d2a6 6% 70%, #1a0f0b 70%); opacity: .55; pointer-events: none; }
#fine { border-radius: calc(12px * var(--z)); background: var(--glass); border: 1px solid var(--glass-b); overflow: hidden; cursor: ns-resize; }
#fine .wheel { position: absolute; inset: calc(4px * var(--z)); border-radius: calc(8px * var(--z));
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.04) 0 6px, rgba(255,255,255,.32) 6px 8px), linear-gradient(90deg, rgba(0,0,0,.6), rgba(70,50,35,.4) 50%, rgba(0,0,0,.6));
  background-position: 0 calc(var(--f, 0) * 120px), 0 0; }
#chalk { position: absolute; z-index: 13; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(120, 170, 255, .7), rgba(120,170,255,0) 70%); }
#chalk.go { animation: chalk .6s ease-out; }
@keyframes chalk { 0% { opacity: .9; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.8); } }

/* upright (phones and tablets held upright): plates over the table, power and spin under it,
   the fine wheel on the right rail by the thumb */
.lay-up #plates { left: 16px; right: 16px; top: max(calc(var(--xt) + 12px), calc(var(--xt) + (var(--tt) - var(--xt) - 68px * var(--z)) / 2)); justify-content: space-between; }
.lay-up .plate { flex: 0 1 calc(50% - 6px * var(--z)); }
.lay-up #plate-opp { flex-direction: row-reverse; text-align: right; padding: calc(8px * var(--z)) calc(8px * var(--z)) calc(8px * var(--z)) calc(12px * var(--z)); }
.lay-up #plate-opp .info { align-items: flex-end; }
.lay-up #spin-btn { left: 16px; bottom: calc(var(--xb) + (var(--tbm) - var(--xb) - 48px * var(--z)) / 2); }
.lay-up #power { left: calc(16px + 60px * var(--z)); right: calc(16px + 76px * var(--z)); height: calc(48px * var(--z)); bottom: calc(var(--xb) + (var(--tbm) - var(--xb) - 48px * var(--z)) / 2); }
.lay-up #fine { right: 16px; width: calc(64px * var(--z)); height: calc(48px * var(--z)); bottom: calc(var(--xb) + (var(--tbm) - var(--xb) - 48px * var(--z)) / 2); cursor: ew-resize; }
.lay-up #hint { bottom: calc(var(--tbm) + var(--rail-h) / 2 - 12px * var(--z)); }

/* wide screens (tablets sideways, desktops): the same bands, sized for the screen */
.lay-wide #plates { left: 50%; transform: translateX(-50%); width: min(calc(100vw - 32px), calc(760px * var(--z))); top: max(calc(var(--xt) + 12px), calc(var(--xt) + (var(--tt) - var(--xt) - 68px * var(--z)) / 2)); justify-content: space-between; }
.lay-wide .plate { flex: 0 1 calc(280px * var(--z)); }
.lay-wide #plate-opp { flex-direction: row-reverse; text-align: right; padding: calc(8px * var(--z)) calc(8px * var(--z)) calc(8px * var(--z)) calc(12px * var(--z)); }
.lay-wide #plate-opp .info { align-items: flex-end; }
.lay-wide #power { left: 50%; transform: translateX(-50%); width: min(calc(100vw - 200px), calc(480px * var(--z))); height: calc(48px * var(--z)); bottom: calc(var(--xb) + (var(--tbm) - var(--xb) - 48px * var(--z)) / 2); }
.lay-wide #spin-btn { left: calc(50% - min(calc(100vw - 200px), calc(480px * var(--z))) / 2 - 60px * var(--z)); bottom: calc(var(--xb) + (var(--tbm) - var(--xb) - 48px * var(--z)) / 2); }
.lay-wide #fine { left: calc(50% + min(calc(100vw - 200px), calc(480px * var(--z))) / 2 + 12px * var(--z)); width: calc(120px * var(--z)); height: calc(48px * var(--z)); bottom: calc(var(--xb) + (var(--tbm) - var(--xb) - 48px * var(--z)) / 2); cursor: ew-resize; }
.lay-up #fine .wheel, .lay-wide #fine .wheel { background: repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 6px, rgba(255,255,255,.32) 6px 8px), linear-gradient(0deg, rgba(0,0,0,.6), rgba(70,50,35,.4) 50%, rgba(0,0,0,.6)); background-position: calc(var(--f, 0) * 120px) 0, 0 0; }
.lay-wide #hint { bottom: calc(var(--tbm) + var(--rail-h) / 2 - 12px * var(--z)); }

/* a phone held sideways: the hands hold its ends. Spin and the fine wheel by the left thumb,
   the power bar by the right one, each about 16 px from its edge as upright */
.lay-side #plates { position: static; }
.lay-side .plate { position: absolute; top: calc(var(--xt) + 12px); flex-direction: column; text-align: center; padding: calc(8px * var(--z)); }
.lay-side .plate .info { align-items: center; }
.lay-side .plate .tray { justify-content: center; }
.lay-side #plate-me { left: calc(env(safe-area-inset-left, 0px) + 12px); width: calc(var(--tl) - env(safe-area-inset-left, 0px) - 24px); }
.lay-side #plate-opp { right: calc(env(safe-area-inset-right, 0px) + 12px); width: calc(var(--tr) - env(safe-area-inset-right, 0px) - 24px); }
.lay-side .pic { width: 40px; height: 40px; }
.lay-side .pic svg { width: 48px; height: 48px; inset: -4px; }
.lay-side .name { font-size: 13px; }
.lay-side #spin-btn { left: calc(env(safe-area-inset-left, 0px) + 16px); bottom: calc(var(--xb) + 16px); }
.lay-side #fine { left: calc(env(safe-area-inset-left, 0px) + 72px); width: 40px; bottom: calc(var(--xb) + 16px); height: 38%; }
.lay-side #power { right: calc(env(safe-area-inset-right, 0px) + 16px); width: 48px; bottom: calc(var(--xb) + 16px); height: 42%; }
.lay-side #power .fill { width: auto; right: 0; top: 0; bottom: auto; height: calc(var(--p, 0) * 100%); background: linear-gradient(180deg, #36d17a, #f3c969 60%, #ff5b4a); }
.lay-side #power .ticks { background: repeating-linear-gradient(180deg, transparent 0 calc(10% - 1px), rgba(255,255,255,.18) calc(10% - 1px) 10%); }
.lay-side #power .cue-icon { display: none; }
.lay-side #hint { bottom: calc(var(--xb) + 8px); }

@media (prefers-reduced-motion: reduce) {
  .plate.last5 .pic, .pk, #flourish.go, #chalk.go { animation: none !important; }
  #flourish.go { opacity: 1; }
}

/* the narrowest phones (under 360 px): a smaller picture and tighter chips, never under 11 px */
@media (max-width: 359px) {
  .lay-up .pic { width: 40px; height: 40px; }
  .lay-up .pic svg { width: 48px; height: 48px; inset: -4px; }
  .lay-up .chip { padding: 0 4px; letter-spacing: 0; }
}
