/* Blackjack table activity: dark glass UI over an emerald felt. No external assets. */
:root {
  --bg: #080b10;
  --panel: rgba(18, 24, 33, .78);
  --panel-line: rgba(255, 255, 255, .09);
  --text: #eef2f7;
  --muted: #8d99ab;
  --gold: #f2c14e;
  --gold-2: #ffdd8a;
  --green: #2ecc8f;
  --red: #ff5a67;
  --blue: #4aa8ff;
  --amber: #ffb02e;
  --felt-1: #167a52;
  --felt-2: #0b4a32;
  --felt-3: #06291d;
  --cw: clamp(40px, 5.4vw, 74px);      /* card width; everything on the table scales from this */
  --ch: calc(var(--cw) * 1.42);
  --chip: clamp(46px, 5.6vw, 62px);
}

[hidden] { display: none !important; }      /* the hidden attribute must win over any component's display rule */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }

#app { height: 100dvh; width: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
#app > *, #controls > *, #felt { min-width: 0; }

/* ---------- top bar ---------- */
#topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px;
  background: linear-gradient(#0d121a, #0a0e14); border-bottom: 1px solid var(--panel-line); z-index: 5; }
.brand { font-weight: 800; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand b { color: var(--gold); font-size: 1.25em; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.meta span b { color: var(--text); font-weight: 600; }
.top-actions { display: flex; gap: 6px; align-items: center; }
#vol { width: 92px; accent-color: var(--gold); cursor: pointer; }
@media (max-width: 720px) { #vol { width: 64px; } }
.icon-btn { width: 34px; height: 34px; border-radius: 1px; background: rgba(255,255,255,.06); border: 1px solid var(--panel-line);
  display: grid; place-items: center; font-size: 16px; transition: background .15s, transform .1s; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn:active { transform: scale(.94); }

/* ---------- felt ---------- */
#table { position: relative; min-height: 0; padding: 10px; display: flex; }
#felt { position: relative; flex: 1; border-radius: 2.8px; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; align-items: center; padding: 14px 10px 12px;
  background:
    radial-gradient(ellipse 80% 70% at 50% 35%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.35), inset 0 0 0 6px #2b1d12, inset 0 0 0 8px #4a3320, inset 0 0 90px rgba(0,0,0,.55), 0 10px 40px rgba(0,0,0,.5); }
#felt::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: repeating-radial-gradient(circle at 50% 120%, transparent 0 22px, rgba(255,255,255,.018) 22px 23px); }
.felt-text { margin-top: 10px; text-align: center; pointer-events: none;
  color: rgba(255, 221, 138, .2); font-weight: 800; letter-spacing: .28em; font-size: clamp(10px, 1.5vw, 16px); white-space: nowrap; }
.felt-text small { display: block; letter-spacing: .12em; font-size: .62em; margin-top: 6px; font-weight: 600; }

#shoe { position: absolute; right: 18px; top: 16px; width: calc(var(--cw) * .9); height: calc(var(--ch) * .9); border-radius: 0.8px;
  background: radial-gradient(ellipse at 50% 35%, #4a735c 0%, #34553f 55%, #223a2e 100%); border: 2px solid #c9d4c6; opacity: .97;
  box-shadow: 3px 3px 0 -1px #1d3328, 6px 6px 0 -2px #c9d4c6, 8px 8px 12px rgba(0,0,0,.5); }
#shoe i { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font: 600 10px/1 system-ui; color: rgba(255,255,255,.6); }

/* ---------- dealer ---------- */
#dealer { display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 1; }
.label { font-size: 11px; font-weight: 700; letter-spacing: .2em; color: rgba(255, 255, 255, .55); text-transform: uppercase; }
.hand-row { position: relative; display: flex; align-items: center; justify-content: center; min-height: var(--ch); }
.cards { display: flex; align-items: center; min-width: var(--cw); min-height: var(--ch); }
.cards .card + .card { margin-left: calc(var(--cw) * -.44); }

/* ---------- banner ---------- */
#banner { z-index: 1; display: flex; align-items: center; gap: 10px; padding: 7px 16px; border-radius: 2px;
  background: rgba(6, 14, 11, .62); border: 1px solid rgba(255, 221, 138, .25); backdrop-filter: blur(6px);
  font-weight: 600; font-size: 14px; max-width: 92%; text-align: center; }
#banner .phase { font-size: 10px; letter-spacing: .16em; font-weight: 800; padding: 3px 8px; border-radius: 2px; background: rgba(242, 193, 78, .16); color: var(--gold-2); }
#banner .count { min-width: 2.2ch; font-variant-numeric: tabular-nums; color: var(--gold-2); font-weight: 800; }
#banner .count:empty { display: none; }

/* ---------- cards ---------- */
.card { position: relative; width: var(--cw); height: var(--ch); perspective: 700px; flex: none; }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .7, .2, 1); }
.card.down .inner { transform: rotateY(180deg); }
.card .face, .card .back { position: absolute; inset: 0; border-radius: calc(var(--cw) * .012); backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.25); }
.card .face { background: linear-gradient(160deg, #ffffff, #eceff4); color: #15181f; overflow: hidden; }
.card .face::before { content: ""; position: absolute; inset: 0; background: var(--art, none) center / cover no-repeat; opacity: .3; }
.card .c { z-index: 1; text-shadow: 0 0 2px #fff, 0 0 4px #fff, 0 0 7px rgba(255,255,255,.9); }
.card.red .face { color: #d92d3b; }
.card .back { transform: rotateY(180deg); border: calc(var(--cw) * .05) solid #c9d4c6; overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #4a735c 0%, #34553f 55%, #223a2e 100%); }
.card .back::after, #shoe::after { content: ""; position: absolute; inset: 11%; background: url("pol.png") center / contain no-repeat;
  opacity: .8; filter: saturate(.65) brightness(1.08) contrast(1.05); }
.card .c { position: absolute; font-weight: 800; line-height: 1; text-align: center; font-size: calc(var(--cw) * .27); }
.card .c.tl { top: 7%; left: 9%; }
.card .c.br { bottom: 7%; right: 9%; transform: rotate(180deg); }
.card .c.mid { top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .56); }
.card .c small { display: block; font-size: .82em; margin-top: 1px; }
.card.new { animation: dealIn .25s cubic-bezier(.2, .8, .25, 1) both; z-index: 3; }
@keyframes dealIn {
  from { transform: translate(var(--dx, 100px), var(--dy, -120px)) rotate(-24deg) scale(.55); opacity: 0; }
  60%  { opacity: 1; }
  to   { transform: none; opacity: 1; }
}

/* ---------- value / result badges ---------- */
.hv { position: absolute; top: -11px; right: -8px; z-index: 4; min-width: 26px; padding: 2px 7px; border-radius: 2px; text-align: center;
  font-size: 12px; font-weight: 800; background: #0b0f14; border: 1.5px solid rgba(255,255,255,.35); color: #fff; font-variant-numeric: tabular-nums; }
.hv.bust { background: var(--red); border-color: #fff; }
.hv.bj { background: var(--gold); color: #3a2a00; border-color: #fff; }
.hv:empty { display: none; }
.res { position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); z-index: 5; white-space: nowrap; padding: 3px 10px; border-radius: 2px;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both; box-shadow: 0 4px 12px rgba(0,0,0,.45); }
.res:empty { display: none; }
.res.win { background: var(--green); color: #032a1a; }
.res.blackjack { background: linear-gradient(90deg, var(--gold), var(--gold-2)); color: #3a2a00; }
.res.push { background: #9aa6b8; color: #10141b; }
.res.lose, .res.bust { background: var(--red); color: #2c0006; }
@keyframes pop { from { transform: translateX(-50%) scale(.3); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ---------- seats ---------- */
#seats { width: 100%; display: flex; justify-content: center; align-items: flex-end; gap: clamp(6px, 1.2vw, 16px); z-index: 1;
  overflow-x: auto; overflow-y: hidden; padding: 46px 6px 6px; scrollbar-width: none; }
#seats::-webkit-scrollbar { display: none; }
.seat { flex: 1 1 0; min-width: calc(var(--cw) * 2.1); max-width: 210px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: translateY(var(--arc, 0px)); transition: opacity .25s; }
.seat.empty { opacity: .9; justify-content: flex-end; }
.seat.away { opacity: .55; }
.hands { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px 14px; min-height: var(--ch); align-items: flex-end; }
.hand { position: relative; padding-bottom: 12px; border-radius: 1px; transition: filter .2s, transform .2s; }
.hand.active { filter: drop-shadow(0 0 10px rgba(242, 193, 78, .9)); transform: translateY(-6px); }
.hand.dim { opacity: .75; }

.bet-spot { --sc: calc(clamp(46px, 5.6vw, 62px) * .72); --step: 3px; height: calc(var(--sc) * .8 + var(--step) * 8 + 20px); margin-top: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
/* A solid stack seen from slightly above: tilted chips packed tightly, value only on the top chip, one shadow under the pile. */
.bet-spot .stack { position: relative; width: var(--sc); height: calc(var(--sc) * .62 + var(--n, 1) * var(--step));
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.bet-spot .stack .chip { --chip: var(--sc); position: absolute; left: 0; bottom: calc(var(--i, 0) * var(--step) - var(--sc) * .19);
  transform: perspective(240px) rotateX(48deg); transform-origin: 50% 50%;
  box-shadow: inset 0 0 0 2px var(--c, #555), inset 0 0 0 3px rgba(255,255,255,.3), 0 var(--step) 0 0 color-mix(in srgb, var(--c, #555) 60%, #000); }
.bet-spot .stack .chip:not(:last-child) span { visibility: hidden; }
.bet-spot .stack .chip:not(:last-child)::after { display: none; }
.bet-spot .stack .chip.drop { animation: stackDrop .35s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes stackDrop {
  from { transform: perspective(240px) translateY(-46px) rotateX(48deg) scale(1.25); opacity: 0; }
  to   { transform: perspective(240px) rotateX(48deg); opacity: 1; }
}
.bet-spot .amt { font-size: 12px; font-weight: 800; color: var(--gold-2); text-shadow: 0 1px 3px #000; font-variant-numeric: tabular-nums; }
.bet-spot .ring { display: none; position: absolute; bottom: 14px; width: calc(var(--chip) * .62); height: calc(var(--chip) * .62); border-radius: 50%;
  border: 2px dashed rgba(255, 221, 138, .28); }

.plate { position: relative; width: 100%; padding: 7px 9px 9px; border-radius: 1.4px; background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--panel-line); display: flex; align-items: center; gap: 8px; overflow: hidden; transition: box-shadow .2s, border-color .2s; }
.seat.me .plate { border-color: rgba(242, 193, 78, .7); box-shadow: 0 0 0 1px rgba(242, 193, 78, .25), 0 6px 18px rgba(0,0,0,.4); }
.seat.active .plate { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242, 193, 78, .55), 0 0 22px rgba(242, 193, 78, .35); }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 5%; background: #2a3342 center/cover no-repeat; border: 2px solid rgba(255,255,255,.15);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; }
.who { min-width: 0; flex: 1; line-height: 1.2; }
.who .nm { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 5px; align-items: center; }
.who .bal { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-size: 9px; font-weight: 800; letter-spacing: .1em; padding: 2px 5px; border-radius: 0.5px; background: var(--gold); color: #3a2a00; }
.tag.ready { background: var(--green); color: #032a1a; }
.tag.away { background: #3a4252; color: #c5cdd9; }
.plate .timer { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.08); opacity: 0; }
.seat.active .plate .timer, .seat.timing .plate .timer { opacity: 1; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transform-origin: left; }
.timer.low i { background: var(--red); }

.ghost-seat { width: 100%; padding: 14px 6px; border-radius: 1.4px; border: 1.5px dashed rgba(255,255,255,.22); color: rgba(255,255,255,.5);
  font-size: 12px; font-weight: 700; letter-spacing: .08em; transition: all .15s; }
.ghost-seat:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); background: rgba(242, 193, 78, .08); }

/* ---------- chips ---------- */
.chip { position: relative; isolation: isolate; width: var(--chip); height: var(--chip); border-radius: 50%; flex: none; color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: calc(var(--chip) * .27); background: var(--c, #555);
  box-shadow: inset 0 0 0 3px var(--c, #555), inset 0 0 0 4px rgba(255,255,255,.35), 0 2px 0 rgba(0,0,0,.45), 0 4px 8px rgba(0,0,0,.4);
  text-shadow: 0 1px 2px rgba(0,0,0,.6); user-select: none; }
.chip::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: calc(var(--chip) * .11) dashed rgba(255,255,255,.88); }
.chip::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.6); background: rgba(0,0,0,.18); }
.chip span { position: relative; z-index: 1; }
.chip.light { color: #1a1d24; text-shadow: none; }
.chip.drop { animation: chipDrop .35s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes chipDrop { from { transform: translateY(-46px) scale(1.25); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- controls ---------- */
#controls { padding: 10px 14px 14px; background: linear-gradient(#0a0e14, #070a0f); border-top: 1px solid var(--panel-line);
  display: grid; grid-template-columns: minmax(110px, auto) 1fr minmax(110px, auto); gap: 14px; align-items: center; }
.wallet { line-height: 1.15; }
.wallet .k { font-size: 10px; letter-spacing: .18em; color: var(--muted); font-weight: 700; }
.wallet .v { font-size: 20px; font-weight: 800; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.wallet .v small { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 4px; }
.panel { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 56px; }
.panel .info { color: var(--muted); font-size: 14px; text-align: center; }
.panel .info b { color: var(--text); }
.right-ctl { display: flex; justify-content: flex-end; }

.chips { display: flex; gap: 8px; align-items: center; }
.chip-btn { border-radius: 50%; transition: transform .12s, filter .12s; }
.chip-btn:hover:not(:disabled) { transform: translateY(-4px) scale(1.05); }
.chip-btn:active:not(:disabled) { transform: scale(.95); }
.chip-btn:disabled { filter: grayscale(.9) brightness(.55); }
.chip-btn .chip { --chip: clamp(44px, 5vw, 56px); }
.betline { display: flex; flex-direction: column; align-items: center; min-width: 84px; line-height: 1.1; }
.betline .k { font-size: 10px; letter-spacing: .16em; color: var(--muted); font-weight: 700; }
.betline .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

.btn { padding: 11px 20px; border-radius: 1.2px; font-weight: 800; letter-spacing: .03em; font-size: 14px; border: 1px solid var(--panel-line);
  background: rgba(255,255,255,.07); transition: transform .1s, filter .15s, background .15s; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,.13); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .35; }
.btn kbd { font: 700 10px/1 system-ui; padding: 3px 5px; border-radius: 0.4px; background: rgba(0,0,0,.28); color: rgba(255,255,255,.75); }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2f2200; border-color: transparent; box-shadow: 0 4px 16px rgba(242, 193, 78, .3); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.btn.primary.on { background: linear-gradient(180deg, #6ff0b6, var(--green)); color: #032a1a; box-shadow: 0 4px 16px rgba(46, 204, 143, .3); }
.btn.hit { background: linear-gradient(180deg, #34d99b, #1fa974); color: #03271a; border-color: transparent; }
.btn.stand { background: linear-gradient(180deg, #ff7480, #e04353); color: #2c0006; border-color: transparent; }
.btn.double { background: linear-gradient(180deg, #ffc65a, #ed9a12); color: #3a2400; border-color: transparent; }
.btn.split { background: linear-gradient(180deg, #6cbcff, #2f8ae0); color: #04213f; border-color: transparent; }
.btn.hit:hover:not(:disabled), .btn.stand:hover:not(:disabled), .btn.double:hover:not(:disabled), .btn.split:hover:not(:disabled) { filter: brightness(1.1); }
.btn.big { padding: 14px 26px; font-size: 15px; min-width: 112px; justify-content: center; }
.btn.small { padding: 8px 13px; font-size: 12px; border-radius: 1px; }
.btn.ghost { background: none; color: var(--muted); }

/* ---------- overlays ---------- */
#loading, #fatal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; text-align: center; padding: 24px;
  background: radial-gradient(circle at 50% 40%, #12301f, #070b0e 70%); }
#loading .spin { width: 42px; height: 42px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid rgba(255,255,255,.12); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading h1, #fatal h1 { margin: 0 0 6px; font-size: 22px; }
#loading p, #fatal p { margin: 0; color: var(--muted); max-width: 420px; }
#fatal .btn { margin-top: 18px; }
.hidden { display: none !important; }

#toasts { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 9px 16px; border-radius: 1.2px; background: rgba(20, 26, 36, .95); border: 1px solid var(--panel-line); font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: toastIn .25s ease both; }
.toast.err { border-color: rgba(255, 90, 103, .6); color: #ffc1c6; }
.toast.ok { border-color: rgba(46, 204, 143, .75); background: rgba(12, 38, 28, .96); color: #b9f3d9; }
.toast.warn { border-color: rgba(255, 200, 60, .8); background: rgba(46, 36, 8, .96); color: #ffe39a; }
.toast.bad { border-color: rgba(255, 90, 103, .9); background: rgba(60, 12, 20, .97); color: #ffc1c6; font-weight: 700; }
.toast.out { animation: toastOut .3s ease both; }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

#resultpop { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 30; pointer-events: none; text-align: center;
  padding: 16px 56px; --pop: #c7d0de;
  background: color-mix(in srgb, var(--pop) 16%, rgba(8, 12, 18, .94)); border: 2px solid var(--pop);
  box-shadow: 0 0 0 1px rgba(0,0,0,.7), 0 18px 50px rgba(0,0,0,.65), 0 0 44px color-mix(in srgb, var(--pop) 38%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: resultIn .5s cubic-bezier(.2, 1.3, .4, 1) both; }
#resultpop.out { animation: resultOut .5s ease both; }
#resultpop .big { font-size: clamp(32px, 7vw, 64px); font-weight: 900; letter-spacing: .04em; color: var(--pop); text-shadow: 0 3px 14px rgba(0,0,0,.55); }
#resultpop.win { --pop: var(--green); }
#resultpop.blackjack { --pop: var(--gold-2); }
#resultpop.lose { --pop: var(--red); }
#resultpop.push { --pop: #c7d0de; }
@keyframes resultIn { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes resultOut { to { transform: translate(-50%, -62%) scale(1.05); opacity: 0; } }


.modal { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 18px; background: rgba(4, 7, 10, .7); backdrop-filter: blur(4px); }
.modal .sheet { width: 100%; max-width: 520px; max-height: 90dvh; overflow: auto; padding: 22px 24px; border-radius: 1.8px; background: #131a24; border: 1px solid var(--panel-line); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal h2 { margin: 0 0 10px; font-size: 20px; color: var(--gold-2); }
.modal ul { margin: 0 0 12px; padding-left: 18px; color: #c9d2de; font-size: 14px; line-height: 1.5; }
.modal li + li { margin-top: 6px; }
.howto-text { margin: 0 0 12px; color: #c9d2de; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.howto-edit { display: block; width: 100%; min-height: 230px; resize: vertical; margin: 0 0 4px; padding: 10px; background: #0b111a; color: #e6ebf2;
  border: 1px solid var(--gold); border-radius: 1px; font: 14px/1.5 inherit; font-family: inherit; }
.howto-count { margin: 0 0 8px; text-align: right; font-size: 11px; color: var(--muted); }
.howto-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.howto-actions .grow { flex: 1; }
.modal .keys { color: var(--muted); font-size: 12px; line-height: 2; }
.modal kbd { font: 700 11px/1 system-ui; padding: 3px 6px; border-radius: 0.5px; background: rgba(255,255,255,.1); color: #fff; }


/* ---------- table drawing ---------- */
#paint-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
body.drawing #paint-canvas { pointer-events: auto; touch-action: none; cursor: none; }
body.drawing #dealer, body.drawing #seats, body.drawing #banner, body.drawing #shoe { pointer-events: none; }
#brush-cursor { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; border-radius: 50%; border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.35); }
#brush-cursor.eraser { border-style: dashed; background: rgba(255,255,255,.12); }

/* the always-visible Draw button next to the controls */
.right-ctl { gap: 8px; align-items: center; }
.paint-toggle { border: 1px solid var(--gold); color: var(--gold-2); background: rgba(242, 193, 78, .1); font-weight: 800; padding: 10px 16px; font-size: 13px; }
.paint-toggle span { font-size: 15px; }
.paint-toggle:hover:not(:disabled) { background: rgba(242, 193, 78, .22); }
.paint-toggle.on { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2f2200; border-color: transparent; }
.paint-toggle.attn { animation: attn 1.8s ease-in-out infinite; }
@keyframes attn { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 193, 78, 0); } 50% { box-shadow: 0 0 14px 2px rgba(242, 193, 78, .55); } }

/* the paint bar: floats over the bottom of the table (it never moves the layout) and lets the felt show through */
#paint-panel { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 8; width: max-content; max-width: calc(100% - 20px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; padding: 8px 12px;
  background: rgba(13, 19, 29, .74); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  border: 1px solid rgba(242, 193, 78, .5); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#paint-panel[hidden] { display: none; }
.pp-group { display: flex; gap: 6px; align-items: center; }
.pp-btn { padding: 8px 14px; font-size: 12px; font-weight: 800; border-radius: 1px; background: rgba(255,255,255,.08); border: 1px solid var(--panel-line); transition: background .12s; }
.pp-btn:hover { background: rgba(255,255,255,.16); }
.pp-btn.on { background: var(--gold); color: #2f2200; border-color: transparent; }
.pp-done { border-color: var(--gold); color: var(--gold-2); }
.pp-colors { display: flex; gap: 5px; align-items: center; }
.pp-sw { width: 26px; height: 26px; flex: none; border-radius: 1px; border: 1px solid rgba(255,255,255,.3); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.pp-sw.on { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.pp-sw.custom { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); }
.pp-sw.custom input { position: absolute; inset: -6px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.pp-size input { width: 140px; accent-color: var(--gold); }
.pp-dot { width: 38px; height: 38px; display: grid; place-items: center; flex: none; background: rgba(0,0,0,.3); border-radius: 1px; }
.pp-dot i { display: block; border-radius: 50%; background: #fff; }
@media (max-width: 720px) {
  #paint-panel { left: 8px; right: 8px; bottom: 8px; transform: none; width: auto; max-width: none; gap: 8px 10px; padding: 8px 10px; }
  .pp-btn { padding: 8px 10px; }
  .pp-colors { flex-wrap: wrap; }
  .pp-size input { width: 100px; }
}

/* everyone else's pointer: a circle with their picture and role colour; the corner that points is the real position */
#cursor-layer { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.rc { position: absolute; width: 36px; height: 36px; --rc: #9aa6b8; --tip: #fff; transition: left .09s linear, top .09s linear, opacity .2s;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.55)); }
.rc.off { opacity: 0; }
.rc-av { position: absolute; inset: 0; background: #2a3342 center / cover no-repeat; border: 2.5px solid var(--rc); border-radius: 0 50% 50% 50%;
  transition: border-radius .15s, transform .15s; }
.rc-brush { position: absolute; left: -4px; top: -4px; width: 34px; height: 34px; opacity: 0; transition: opacity .15s; overflow: visible; }
.rc-brush .tip { fill: var(--tip); stroke: rgba(0,0,0,.55); stroke-width: .7; }
.rc.drawing .rc-av { border-radius: 50%; transform: translate(14px, 14px); }
.rc.drawing .rc-brush { opacity: 1; }

/* win streak + cards leaving the table */
.tag.streak { background: #ff8a3d; color: #2b1100; }
.card.leaving { animation: cardOut .35s ease-in both; pointer-events: none; }
.hand.gone .hv, .hand.gone .res { animation: cardOut .25s ease-in both; }
@keyframes cardOut { to { opacity: 0; transform: translateY(-8px) scale(.9); } }

/* Confetti pours in from above the screen. Two elements on purpose: the OUTER one only falls and sways (so a falling piece can never be
   pulled sideways by its own rotation), the INNER one only spins and flutters. */
.confetti { position: fixed; z-index: 29; pointer-events: none;
  animation: confettiFall var(--fall) cubic-bezier(.25, .05, .55, 1) both, confettiSway var(--sway) ease-in-out infinite alternate; }
.confetti b { display: block; width: 100%; height: 100%; border-radius: 1px; animation: confettiSpin var(--spin) linear infinite; }
@keyframes confettiFall { from { transform: translateY(0); } to { transform: translateY(130vh); } }
@keyframes confettiSway { from { translate: calc(var(--sx) * -1) 0; } to { translate: var(--sx) 0; } }
@keyframes confettiSpin { from { transform: rotate(0deg) scaleY(1); } 50% { transform: rotate(180deg) scaleY(.35); } to { transform: rotate(360deg) scaleY(1); } }

/* ---------- pictures on the table ---------- */
#img-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.pimg { position: absolute; height: auto; max-width: none; object-fit: fill; user-select: none; -webkit-user-drag: none; pointer-events: auto; touch-action: none; }
.pimg.mine { cursor: grab; }
body.drawing .pimg { pointer-events: none; }
#img-ui { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
body.drawing #img-ui { display: none; }
.sel { position: absolute; border: 1.5px solid var(--gold); box-shadow: 0 0 0 1px rgba(0,0,0,.55); pointer-events: none; }
.sel[hidden] { display: none; }
.sel .h { position: absolute; width: 13px; height: 13px; background: var(--gold); border: 1px solid #2b1d00; pointer-events: auto; touch-action: none; }
.sel .h.nw { left: -8px; top: -8px; cursor: nwse-resize; } .sel .h.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.sel .h.sw { left: -8px; bottom: -8px; cursor: nesw-resize; } .sel .h.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.sel .edge { position: absolute; pointer-events: auto; cursor: move; touch-action: none; }
.sel .edge.t { left: 6px; right: 6px; top: -5px; height: 9px; } .sel .edge.b { left: 6px; right: 6px; bottom: -5px; height: 9px; }
.sel .edge.l { top: 6px; bottom: 6px; left: -5px; width: 9px; } .sel .edge.r { top: 6px; bottom: 6px; right: -5px; width: 9px; }
.sel .del { position: absolute; right: 14px; top: -31px; pointer-events: auto; padding: 4px 10px; background: var(--red); color: #2c0006; font: 800 12px system-ui; border-radius: 1px; }
#drop-hint { position: fixed; inset: 0; z-index: 55; pointer-events: none; display: grid; place-items: center; background: rgba(6, 12, 10, .6); }
#drop-hint[hidden] { display: none; }
#drop-hint > div { padding: 28px 44px; border: 2px dashed var(--gold); background: rgba(14, 20, 30, .85); font-size: 20px; font-weight: 800; text-align: center; color: var(--gold-2); }
#drop-hint small { display: block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
/* Cards and plates catch clicks; the blank table around them lets clicks through to pictures underneath. */
#dealer, #banner, #seats, .seat { pointer-events: none; }
.seat .plate, .seat .ghost-seat, .card { pointer-events: auto; }
body.drawing .seat .plate, body.drawing .seat .ghost-seat, body.drawing .card { pointer-events: none; }

/* clicking a player's plate opens a small menu (hide their drawings and pictures) */
.seat:not(.me):not(.empty) .plate { cursor: pointer; }
.seat:not(.me):not(.empty) .plate:hover { border-color: rgba(255,255,255,.35); }
#player-menu { position: fixed; z-index: 58; width: 250px; padding: 10px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(14, 20, 30, .97); border: 1px solid var(--panel-line); box-shadow: 0 12px 30px rgba(0,0,0,.6); }
#player-menu[hidden] { display: none; }
.pm-head { display: flex; gap: 8px; align-items: center; }
.pm-av { width: 28px; height: 28px; flex: none; background: #2a3342 center / cover no-repeat; border-radius: 5%; }
.pm-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-btn { padding: 9px 10px; font-weight: 800; font-size: 12px; border: 1px solid var(--panel-line); background: rgba(255,255,255,.08); transition: background .12s; }
.pm-btn:hover { background: rgba(255,255,255,.16); }
.pm-btn.on { background: var(--gold); color: #2f2200; border-color: transparent; }
.pp-btn.full { opacity: .55; }
.pp-btn:disabled { opacity: .4; }

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  .seat { transform: translateY(var(--arc, 0px)); }
}
@media (max-width: 899px) {
  .seat { --arc: 0px !important; }
}
@media (hover: none) { .btn kbd { display: none; } }
@media (max-width: 720px) {
  #controls { grid-template-columns: 1fr auto; }
  .panel { grid-column: 1 / -1; order: 3; }
  .meta { display: none; }
  #shoe i { display: none; }
  .seat { min-width: calc(var(--cw) * 2.5); }
  .btn.big { padding: 13px 10px; min-width: 0; flex: 1 1 0; }
  .panel { width: 100%; }
  .chips { gap: 5px; }
  .betline { min-width: 60px; }
  #banner { font-size: 13px; }
}
@media (max-height: 560px) {
  :root { --cw: clamp(36px, 4.6vw, 56px); }
  #topbar { padding: 5px 12px; }
  #controls { padding: 6px 12px 8px; }
  .panel { min-height: 46px; }
  .felt-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card.new, .chip.drop, .res, #resultpop { animation-duration: .01s; }
  .card .inner { transition-duration: .01s; }
}
