:root {
  --bg: #0c1f1a;
  --panel: #1c2a2c;
  --panel-2: #26383b;
  --edge: #3f5659;
  --text: #ffffff;
  --muted: #9fb5b3;
  --gold: #f7c548;
  --blue: #0a93f5;   --blue-d: #0561a6;
  --red: #fe5048;    --red-d: #a8302b;
  --orange: #ff9a1f; --orange-d: #b0620a;
  --green: #2fbf7f;  --green-d: #1a7a50;
  --grey: #5b6d70;   --grey-d: #37474a;
  --card: #f4efe4;
  --ink: #26324a;
  --suit-red: #e0443a;
  --print: rgba(247, 197, 72, .75);
  --cw: min(19vw, 80px, 11dvh);
  --ch: calc(var(--cw) * 1.4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: 'Silkscreen', ui-monospace, monospace;
  font-weight: 400;
  letter-spacing: -0.02em;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
  z-index: 0;
}
#bg.fallback { background: radial-gradient(circle at 50% 40%, #2f7a4f, #16453a 55%, #0c1f1a); }

.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .09) 0 1px, transparent 1px 3px);
}

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 45; overflow: hidden; }

#app {
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 12px);
}
#app.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 3px) rotate(-.6deg); }
  40% { transform: translate(6px, -3px) rotate(.5deg); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -1px); }
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 8px; }
.bank {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; text-align: left;
  background: var(--panel); border: 3px solid var(--edge); border-radius: 12px;
  padding: 4px 10px 5px; box-shadow: 0 4px 0 rgba(0, 0, 0, .4);
}
.bank:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
.bank-name { font-size: 10px; color: var(--muted); max-width: 48vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
.bank-row { display: flex; align-items: baseline; gap: 8px; }
.bank-row b { font-size: 18px; font-weight: 700; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, .5); white-space: nowrap; display: inline-block; }
.delta { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; text-transform: uppercase; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.bank.deny { animation: shake .35s; }
.top-btns { margin-left: auto; display: flex; gap: 6px; }
.mini {
  white-space: nowrap;
  background: var(--panel); border: 3px solid var(--edge); border-radius: 10px;
  font-size: 11px; padding: 7px 7px; color: var(--muted);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
}
.mini:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .4); }

/* ---------- table ---------- */
.table {
  flex: 1; min-height: 0; position: relative; margin: 10px -2px 12px;
  padding: 0 7px 8px;
  border-radius: 14px 14px 50% 50% / 14px 14px 16% 16%;
  background: var(--panel); border: 3px solid var(--edge);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .45);
}
.felt {
  position: relative; height: 100%; overflow: hidden;
  display: flex; flex-direction: column;
  border-radius: 8px 8px 50% 50% / 8px 8px 15% 15%;
  background: radial-gradient(ellipse 110% 80% at 50% 25%, rgba(30, 110, 76, .55), rgba(10, 46, 34, .7));
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .25), inset 0 0 40px rgba(0, 0, 0, .35);
}

.rack {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1;
  width: min(54%, 250px); height: 20px; display: flex; gap: 3px; padding: 3px 5px;
  background: var(--panel); border: 3px solid var(--edge); border-top: 0; border-radius: 0 0 10px 10px;
}
.rack i { flex: 1; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--c) 0 3px, rgba(0, 0, 0, .4) 3px 4px); }
.tags { position: absolute; left: 8px; top: 8px; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tags span { font-size: 9px; padding: 2px 6px; border-radius: 6px; color: #fff; background: var(--blue); box-shadow: 0 2px 0 rgba(0, 0, 0, .4); text-transform: uppercase; }
.tags span:nth-child(2) { background: var(--green); }
.tags .streak { background: var(--orange) !important; animation: bob 1.2s ease-in-out infinite; }

.shoe { position: absolute; right: 8px; top: 8px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.shoe-cards { position: relative; width: calc(var(--cw) * .5); height: calc(var(--ch) * .5); }
.shoe-cards i {
  position: absolute; inset: 0; border-radius: 5px; border: 2px solid var(--card);
  background: repeating-linear-gradient(45deg, #c93a31 0 4px, #e0534a 4px 8px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.shoe-cards i:nth-child(1) { transform: translate(3px, 3px); }
#shoeCount { font-size: 10px; color: var(--muted); background: rgba(12, 22, 24, .7); border-radius: 4px; padding: 0 4px; }

.dealer-zone { position: relative; z-index: 2; padding-top: 26px; }
.zone-head { display: flex; justify-content: center; margin-bottom: 6px; min-height: 24px; }
.score {
  background: rgba(12, 22, 24, .82); border: 2px solid var(--edge); border-radius: 8px;
  padding: 2px 8px; font-size: 12px; font-weight: 700; color: #fff; min-width: 34px; text-align: center;
}
.score.bust { background: var(--red); border-color: var(--red-d); }
.score.hot { background: var(--gold); border-color: #b88a1c; color: #2a1d00; }
.bump { animation: pop .25s; }

/* printed felt */
.print { flex: 1; min-height: 40px; position: relative; }
.print svg { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); width: 100%; height: min(100% + 16px, 150px); overflow: visible; }
.print text { font-family: 'Silkscreen', monospace; fill: var(--print); }
.print .p1 { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.print .p2 { font-size: 9px; letter-spacing: 1px; }
.print .p3 { font-size: 9px; font-weight: 700; letter-spacing: 1px; }
.print .band { fill: none; stroke: var(--print); stroke-width: 2; stroke-dasharray: 6 4; opacity: .7; }

.banner {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 20; pointer-events: none; text-align: center;
}
.banner[hidden] { display: none; }
.banner .title {
  display: inline-block; font-size: clamp(26px, 8.4vw, 42px); font-weight: 700; line-height: 1;
  color: #fff; letter-spacing: .02em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .55), 0 0 18px rgba(0, 0, 0, .35);
  animation: slam .5s cubic-bezier(.2, 1.6, .4, 1) both, wobble 2.4s ease-in-out .5s infinite;
}
.banner .title.win { color: var(--gold); }
.banner .title.bj { color: var(--gold); background: linear-gradient(180deg, #fff3b0, #f7c548 55%, #ff9a1f); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .55)); }
.banner .title.lose { color: var(--red); }
.banner .title.push { color: #d6e2e1; }
.banner .sub {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700;
  background: rgba(12, 22, 24, .85); border: 3px solid var(--edge); border-radius: 12px; padding: 6px 10px;
  animation: rise .35s ease-out .2s both;
}
.banner .detail { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--muted); background: rgba(12, 22, 24, .85); border-radius: 8px; padding: 3px 8px; }
.bx { border-radius: 7px; padding: 2px 8px; color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.bx.blue { background: var(--blue); }
.bx.red { background: var(--red); }
.sub .x { color: var(--red); }
.sub .eq { color: var(--muted); }
.sub .pos { color: var(--gold); }
.sub .neg { color: var(--red); }

.hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 15;
  display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 88%;
  background: rgba(12, 22, 24, .9); border: 3px solid var(--blue); border-radius: 12px;
  padding: 6px 14px; text-align: center; pointer-events: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45);
  animation: hintIn .3s cubic-bezier(.2, 1.5, .4, 1) both;
}
.hint[hidden] { display: none; }
.hint b { font-size: 18px; color: #fff; text-transform: uppercase; }
.hint small { font-size: 11px; color: var(--muted); }
@keyframes hintIn { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.btn.suggest:not(:disabled) { outline: 3px solid #fff; outline-offset: 3px; animation: pulse .9s ease-in-out infinite; }

/* ---------- cards ---------- */
.hand { display: flex; justify-content: center; align-items: flex-start; min-height: var(--ch); }
/* Recompute the card height wherever the card width is overridden (split hands, other seats). */
.dealer-zone, .spot, .hand, .card { --ch: calc(var(--cw) * 1.4); }
.card { width: var(--cw); height: var(--ch); position: relative; flex: none; will-change: transform; }
.card + .card { margin-left: calc(var(--cw) * -0.56); }
.sway { width: 100%; height: 100%; perspective: 700px; animation: sway 4.2s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(-1.1deg) translateY(0); }
  50% { transform: rotate(1.1deg) translateY(-2px); }
}
.flip { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform .42s cubic-bezier(.3, 1.35, .5, 1); }
.flip.down { transform: rotateY(180deg); }
.card.peek .flip { animation: peek .55s ease-in-out; }
@keyframes peek {
  0%, 100% { transform: rotateY(180deg); }
  40%, 60% { transform: rotateY(180deg) translateY(-6px) rotateX(24deg); }
}
.face {
  position: absolute; inset: 0; border-radius: calc(var(--cw) * .09);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .38);
  overflow: hidden;
}
.front { background: var(--card); border: 2px solid #d4c9b3; color: var(--ink); }
.front.red { color: var(--suit-red); }
.back {
  transform: rotateY(180deg);
  border: calc(var(--cw) * .06) solid var(--card);
  background: repeating-linear-gradient(45deg, #c93a31 0 5px, #e0534a 5px 10px);
}
.back::after {
  content: ''; position: absolute; inset: 12%; border: 2px solid rgba(255, 255, 255, .55); border-radius: 4px;
  background: radial-gradient(circle, rgba(255, 255, 255, .5) 0 14%, transparent 15%);
}
.corner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  line-height: .9; font-weight: 700; font-size: calc(var(--cw) * .19); letter-spacing: -.1em;
}
.corner i { font-style: normal; font-size: calc(var(--cw) * .19); font-family: system-ui, sans-serif; }
.corner.tl { top: 5%; left: 6%; }
.corner.br { bottom: 5%; right: 6%; transform: rotate(180deg); }
.pips { position: absolute; inset: 0; }
.pips i {
  position: absolute; font-style: normal; font-family: system-ui, sans-serif;
  font-size: calc(var(--cw) * .2); line-height: 1; transform: translate(-50%, -50%);
}
.pips i.f { transform: translate(-50%, -50%) rotate(180deg); }
.ace { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .56); font-family: system-ui, sans-serif; }
.court {
  position: absolute; inset: 20% 22%; border-radius: 4px; border: 2px solid currentColor;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, rgba(0, 0, 0, .04) 0 3px, transparent 3px 6px);
}
.court b { font-size: calc(var(--cw) * .36); line-height: .9; }
.court i { font-style: normal; font-size: calc(var(--cw) * .22); font-family: system-ui, sans-serif; }

/* ---------- player spots ---------- */
.player-zone { position: relative; z-index: 2; padding-bottom: 7%; }
.hands { display: flex; justify-content: center; align-items: flex-end; gap: 10px; width: 100%; }
.hands.n2 { --cw: min(16vw, 74px, 10.5dvh); gap: 14px; }
.hands.n3 { --cw: min(12vw, 60px, 9dvh); gap: 8px; }
.hands.n4 { --cw: min(10vw, 54px, 8.5dvh); gap: 6px; }
.spot { --sw: calc(var(--cw) * .46); position: relative; display: flex; flex-direction: column; align-items: center; transition: transform .25s, opacity .25s; }
.spot > .hand { position: relative; z-index: 1; }
.ring-row { display: flex; align-items: center; gap: 16px; margin-top: calc(var(--cw) * -.2); }
.ring {
  position: relative; padding: 0; flex: none;
  width: calc(var(--cw) * 1.3); height: calc(var(--cw) * .82); border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, .45); background: rgba(0, 0, 0, .22);
  transition: border-color .2s;
}
.spot.betting .ring { cursor: pointer; }
.ring:has(.stk) { border-style: solid; border-color: var(--gold); }
.spot.active .ring { border-style: solid; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247, 197, 72, .3); }
.hands.multi .spot:not(.active):not(.settled) { opacity: .6; }
.hands.multi .spot.active { transform: translateY(-6px); }
.piles {
  position: absolute; left: 50%; bottom: 26%; transform: translateX(-50%);
  display: grid; justify-items: center; pointer-events: none; z-index: 2; transition: left .35s cubic-bezier(.3, .8, .3, 1);
}
.prow { display: flex; align-items: flex-end; grid-area: 1 / 1; }
.prow.far { transform: translateY(calc(var(--sw) * -.34)); }
.stk { width: var(--sw); height: auto; display: block; flex: none; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .45)); }
.stk + .stk { margin-left: calc(var(--sw) * -.08); }
.piles.bump .stk { animation: settleIn .25s ease-out; }
@keyframes settleIn { from { transform: translateY(-6px); } to { transform: none; } }
.tool {
  width: 44px; height: 44px; border-radius: 50%; flex: none; border: 3px solid var(--edge);
  background: var(--panel); color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .45);
}
.tool:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .45); }
.tool:disabled { opacity: .35; }
.spot:not(.betting) .tool { visibility: hidden; }
.hands.multi .tool { display: none; }
.meta { display: flex; gap: 4px; margin-top: 6px; align-items: center; min-height: 26px; }
.hbet { font-size: 13px; color: var(--muted); background: rgba(12, 22, 24, .8); border-radius: 8px; padding: 3px 10px; white-space: nowrap; text-transform: uppercase; }
.hbet.has { color: var(--gold); font-size: 15px; font-weight: 700; border: 2px solid var(--edge); padding: 1px 8px; }
.hands.n3 .meta, .hands.n4 .meta { flex-direction: column; gap: 3px; }
.hands.multi .hbet.has { font-size: 11px; padding: 1px 6px; }

.stamp {
  position: absolute; left: 50%; top: calc(var(--ch) * .38); z-index: 5;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-size: clamp(11px, calc(var(--cw) * .2), 19px); font-weight: 700; padding: 2px 8px;
  border-radius: 7px; color: #fff; white-space: nowrap; text-transform: uppercase;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .4);
  animation: stamp .35s cubic-bezier(.2, 1.7, .4, 1) both;
}
.stamp.win { background: var(--green); }
.stamp.bj { background: var(--gold); color: #3a2600; }
.stamp.lose, .stamp.bust { background: var(--red); }
.stamp.push { background: var(--grey); }
.dealer-zone .stamp { top: calc(26px + 30px + var(--ch) * .5); }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); opacity: 0; } to { transform: translate(-50%, -50%) rotate(-12deg) scale(1); opacity: 1; } }

.flying { position: fixed; z-index: 46; width: 40px; height: 40px; pointer-events: none; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .45)); }
.flying svg { width: 100%; height: 100%; display: block; }

/* ---------- controls ---------- */
.controls { height: 136px; flex: none; }
.panel-bet { display: flex; flex-direction: column; gap: 12px; }
.tray { display: flex; justify-content: space-between; gap: 6px; padding: 0 2px; }
.tchip { width: min(56px, 15vw); aspect-ratio: 1; padding: 0; border: 0; background: none; border-radius: 50%; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .45)); }
.tchip svg { width: 100%; height: 100%; display: block; }
.tchip:active:not(:disabled) { transform: translateY(3px); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .45)); }
.tchip:disabled { filter: grayscale(1) brightness(.5); cursor: default; }
.row { display: flex; gap: 8px; }
.grow { flex: 1; }
.panel-play { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.panel-bet[hidden], .panel-play[hidden], .panel-ins[hidden] { display: none; }

.btn {
  --c: var(--grey); --cd: var(--grey-d);
  font-weight: 700; color: #fff; border: 0; border-radius: 11px;
  height: 54px; padding: 0 14px; font-size: 18px; letter-spacing: 0;
  background: var(--c);
  box-shadow: 0 5px 0 var(--cd);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  transition: transform .06s, box-shadow .06s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd); }
.btn:disabled { filter: grayscale(1) brightness(.5); cursor: default; }
.btn.blue { --c: var(--blue); --cd: var(--blue-d); }
.btn.red { --c: var(--red); --cd: var(--red-d); }
.btn.orange { --c: var(--orange); --cd: var(--orange-d); }
.btn.green { --c: var(--green); --cd: var(--green-d); }
.btn.grey { --c: var(--grey); --cd: var(--grey-d); }
.btn.wide { width: 100%; }
.btn.play { height: 64px; font-size: 22px; }
#btnDeal:not(:disabled) { animation: pulse 1.1s ease-in-out infinite; }
.panel-bet .btn.red, .panel-bet .btn.orange { font-size: 13px; padding: 0 10px; }

.panel-play.easy { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; height: 100%; }
.panel-play.easy #btnDbl, .panel-play.easy #btnSplit { display: none; }
.panel-ins { display: flex; flex-direction: column; gap: 12px; }
.ins-q { text-align: center; font-size: 18px; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, .5); background: rgba(12, 22, 24, .8); border-radius: 10px; padding: 6px; }
.ins-q span { color: #fff; font-size: 13px; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(3, 10, 10, .72); padding: 16px;
}
.modal[hidden] { display: none; }
.sheet {
  width: min(100%, 400px); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--panel); border: 3px solid var(--edge); border-radius: 16px;
  padding: 18px 16px 20px; box-shadow: 0 8px 0 rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; gap: 12px;
  animation: slam .35s cubic-bezier(.2, 1.5, .4, 1) both;
}
.sheet h2 { margin: 0; text-align: center; font-size: 24px; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, .5); text-transform: uppercase; }
.note { margin: 0; text-align: center; font-size: 12px; color: var(--gold); line-height: 1.35; text-transform: uppercase; }
.note:empty { display: none; }
.ledger { display: flex; flex-direction: column; gap: 6px; }
.kv { display: flex; justify-content: space-between; align-items: baseline; background: var(--panel-2); border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.kv b { color: #fff; font-size: 15px; }
.kv.total { border: 3px solid var(--edge); }
.kv.total span { color: #fff; }
.kv.total b { font-size: 21px; }
.kv b.pos { color: var(--green); }
.kv b.neg { color: var(--red); }
.block-head { font-size: 11px; color: var(--muted); margin: 2px 2px -4px; text-transform: uppercase; }
.field {
  display: flex; align-items: center; gap: 6px;
  background: #0f1819; border: 3px solid var(--edge); border-radius: 12px; padding: 0 5px 0 12px;
}
.field span { font-size: 22px; color: var(--gold); }
.field input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: #fff; font: inherit; font-size: 20px; font-weight: 700; padding: 10px 0;
  user-select: text; -webkit-user-select: text;
}
.field .btn { height: 40px; font-size: 15px; box-shadow: 0 3px 0 var(--cd); margin-bottom: 3px; }
.field input::placeholder { color: #4d6264; }
.quick, .seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.quick button, .seg button {
  background: var(--panel-2); border: 2px solid var(--edge); border-radius: 9px; padding: 9px 0; font-size: 12px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
}
.quick button:active, .seg button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .4); }
.seg button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid div { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.stat-grid span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.stat-grid b { font-size: 16px; }
.rules { margin: 0; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.4; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 70px); z-index: 80;
  transform: translateX(-50%);
  background: var(--panel); border: 3px solid var(--edge); border-radius: 10px;
  padding: 6px 14px; font-size: 13px; white-space: nowrap; text-transform: uppercase;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45);
  animation: rise .25s ease-out both;
  --tx: -50%;
}
.toast[hidden] { display: none; }

/* ---------- fx ---------- */
.px { position: absolute; width: 8px; height: 8px; animation: burst .9s cubic-bezier(.2, .7, .4, 1) forwards; }
.px.round { border-radius: 50%; width: 12px; height: 12px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
@keyframes burst {
  from { transform: translate(-50%, -50%) rotate(0); opacity: 1; }
  to { transform: translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%)) rotate(var(--r)); opacity: 0; }
}
.float {
  position: absolute; font-size: 16px; font-weight: 700; transform: translate(-50%, -50%); text-transform: uppercase;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .6); animation: floatUp 1.3s ease-out forwards; white-space: nowrap;
}
.float.pos, .float.info { color: var(--gold); }
.float.neg { color: var(--red); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
@keyframes slam { from { transform: scale(.3) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes rise { from { transform: translate(var(--tx, 0), 12px); opacity: 0; } to { transform: translate(var(--tx, 0), 0); opacity: 1; } }

/* ---------- home ---------- */
.home {
  position: fixed; inset: 0; z-index: 55; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(10, 20, 20, .72), rgba(5, 10, 10, .92));
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 20px);
}
.home[hidden] { display: none; }
.home-inner { max-width: 420px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.marquee { position: relative; padding: 16px; border-radius: 22px; background: linear-gradient(180deg, #3a2a0a, #1d1404); border: 4px solid #c9962b; box-shadow: 0 8px 0 rgba(0, 0, 0, .5), 0 0 40px rgba(255, 190, 60, .25); animation: slam .6s cubic-bezier(.2, 1.5, .4, 1) both; }
.bulbs { position: absolute; inset: 0; pointer-events: none; }
.bulb {
  position: absolute; width: 11px; height: 11px; border-radius: 50%; transform: translate(-50%, -50%);
  background: #6b4f1c; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .35);
  animation: bulb 0.9s steps(1) infinite;
}
.bulb.b1 { animation-delay: -.3s; }
.bulb.b2 { animation-delay: -.6s; }
@keyframes bulb {
  0% { background: #fff6c8; box-shadow: 0 0 6px 2px #ffd65a, 0 0 14px 4px rgba(255, 170, 40, .6); }
  33.3%, 100% { background: #6b4f1c; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .35); }
}
.sign {
  position: relative; border-radius: 12px; padding: 14px 10px 12px; text-align: center;
  background: radial-gradient(ellipse at 50% 0%, #a3172b, #5c0816 70%);
  border: 3px solid #f7c548; box-shadow: inset 0 0 0 3px #5c0816, inset 0 0 30px rgba(0, 0, 0, .5);
}
.sign-top { font-size: 20px; color: var(--gold); letter-spacing: .08em; text-shadow: 0 3px 0 #3a0510, 0 0 12px rgba(247, 197, 72, .6); }
.sign-main {
  font-size: clamp(38px, 12.5vw, 60px); line-height: 1; font-weight: 700; color: #fff4f0; letter-spacing: -.02em;
  text-shadow: 0 0 6px #ff6b8a, 0 0 18px #ff2d55, 0 0 36px #ff2d55, 0 5px 0 #3a0510;
  animation: neon 5s infinite;
}
@keyframes neon {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: .55; text-shadow: 0 5px 0 #3a0510; }
}
.sign-suits { display: flex; justify-content: center; gap: 14px; font-size: 22px; color: #fff; margin-top: 4px; font-family: system-ui, sans-serif; }
.sign-suits .r { color: #ffb3c0; }
.ribbon { text-align: center; font-size: 11px; color: var(--gold); background: rgba(12, 22, 24, .85); border: 2px solid var(--edge); border-radius: 10px; padding: 6px; }
.block { display: flex; flex-direction: column; gap: 8px; }
.wallet {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; text-align: left;
  background: var(--panel); border: 3px solid var(--edge); border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .4);
}
.wallet:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
.w-lbl { grid-column: 1; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.w-row { grid-column: 1; display: flex; align-items: baseline; gap: 10px; }
.w-row b { font-size: 24px; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.w-row .delta { font-size: 12px; }
.w-add {
  grid-column: 2; grid-row: 1 / 3; font-size: 12px; color: #fff; background: var(--blue); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 3px 0 var(--blue-d);
}
.name-field[hidden] { display: none; }
.name-field input { text-transform: uppercase; text-align: center; }
.btn.small { height: 44px; font-size: 14px; }
.modal .toggle { width: 100%; }
.toggle {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--panel); border: 3px solid var(--edge); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .4);
}
.toggle:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
.t-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.t-txt b { font-size: 15px; text-transform: uppercase; }
.t-txt small { font-size: 10px; line-height: 1.35; color: var(--muted); }
.switch { width: 50px; height: 28px; border-radius: 14px; background: var(--grey-d); position: relative; flex: none; transition: background .15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .3); transition: transform .15s cubic-bezier(.3, 1.5, .5, 1); }
.toggle[aria-pressed="true"] { border-color: var(--green); }
.toggle[aria-pressed="true"] .switch { background: var(--green); }
.toggle[aria-pressed="true"] .switch i { transform: translateX(22px); }

@media (min-height: 800px) {
  .controls { height: 146px; }
  .btn { height: 58px; }
}
@media (max-height: 640px) {
  .controls { height: 120px; }
  .btn { height: 46px; font-size: 16px; }
  .panel-bet { gap: 10px; }
  .tchip { width: min(46px, 13vw); }
  .dealer-zone { padding-top: 24px; }
  .zone-head { margin-bottom: 3px; }
}
@media (max-width: 380px) {
  .bank-row b { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bulb, .sign-main, .sway, .banner .title, .tags .streak, #btnDeal, .bump, .piles.bump .stk { animation: none !important; }
  #app.shake { animation: none; }
  .bulb.b0 { background: #fff6c8; box-shadow: 0 0 6px 2px #ffd65a; }
}

/* ---------- tables with friends ---------- */
.tags .code { background: var(--grey) !important; }
.others { display: none; }

/* Other players: one full-width row each. The row whose turn it is grows, cards and all.
   The rows area has a fixed height (room for one grown row), so nothing else on the felt moves. */
@property --cw { syntax: '<length>'; inherits: true; initial-value: 60px; }
.room { --rh: 38px; --rh2: 76px; }
.room.crowd .felt {
  --rows-h: calc(var(--rows, 1) * var(--rh) + var(--rh2) - var(--rh) + (var(--rows, 1) - 1) * 5px + 10px);
  --k: calc((var(--fh, 480px) - var(--rows-h) - 118px) / 3.3);
}
.room.crowd .print { flex: none; height: var(--rows-h); padding: 5px 0; display: block; }
.room.crowd .print > svg { display: none; }
.room .others { position: relative; z-index: 3; display: flex; flex-direction: column; gap: 5px; }
.room.crowd .others { --cw: calc((var(--rh) - 10px) / 1.4); }
.seat {
  --cw: calc((var(--rh) - 10px) / 1.4);
  position: relative; flex: none; height: var(--rh); min-width: 0;
  display: grid; grid-template-columns: minmax(0, 31%) minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 0 8px; border-radius: 10px; background: rgba(6, 14, 14, .55); border: 2px solid rgba(255, 255, 255, .07);
  transition: height .4s cubic-bezier(.3, 1.2, .5, 1), --cw .4s cubic-bezier(.3, 1.2, .5, 1), border-color .25s, background .25s, box-shadow .25s, opacity .3s;
}
.seat.turn {
  height: var(--rh2); --cw: calc((var(--rh2) - 14px) / 1.4);
  border-color: var(--gold); background: rgba(48, 38, 8, .62);
  box-shadow: 0 0 0 3px rgba(247, 197, 72, .22), 0 0 22px rgba(247, 197, 72, .28);
}
.seat.away { opacity: .45; }
.seat.out .seat-hands { opacity: .45; }
.seat-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.seat-name { font-size: 11px; color: #fff; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.turn .seat-name { color: var(--gold); font-size: 13px; }
.seat-bank { font-size: 9px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-bank i { font-style: normal; color: var(--muted); }
.seat-bank i.up { color: var(--green); }
.seat-bank i.down { color: var(--red); }
.seat-hands { min-width: 0; height: 100%; display: flex; align-items: center; gap: 6px; overflow-x: clip; }
.seat-status {
  font-size: 9px; text-transform: uppercase; white-space: nowrap; color: #fff; text-align: center;
  padding: 3px 6px; border-radius: 6px; background: rgba(12, 22, 24, .85);
}
.seat-status:empty { display: none; }
.seat-status.muted { color: var(--muted); background: none; padding: 3px 0; }
.seat-status.ready { background: var(--green); }
.seat-status.turn { background: var(--gold); color: #2a1d00; font-size: 10px; animation: bob 1s ease-in-out infinite; }
.seat-status.next { color: var(--gold); border: 1px solid var(--gold); background: none; }
.seat-status.away { color: var(--muted); }
.seat-status.win { background: var(--green); font-size: 11px; }
.seat-status.lose { background: var(--red); font-size: 11px; }
.seat-status.push { background: var(--grey); font-size: 11px; }
.others .spot { flex-direction: row; align-items: center; gap: 4px; flex: none; }
.others .hand { align-items: center; min-height: 0; }
.others .card + .card { margin-left: calc(var(--cw) * (var(--step, .55) - 1)); }
.others .ring-row { display: none; }
.others .meta { margin: 0; min-height: 0; flex-direction: column; gap: 2px; }
.others .score { font-size: 9px; padding: 0 4px; min-width: 0; border-width: 1px; border-radius: 5px; }
.seat.turn .score { font-size: 12px; padding: 1px 5px; }
.others .hbet, .others .hbet.has { display: none; }
.others .stamp { display: none; }
.others .spot.active .hand { filter: drop-shadow(0 0 6px rgba(247, 197, 72, .7)); }
.others .face { box-shadow: 0 2px 0 rgba(0, 0, 0, .38); border-width: 1px; }
.cmini { display: none; }
.others .front > :not(.cmini) { display: none; }
.others .cmini {
  position: absolute; left: 8%; top: 5%; display: flex; flex-direction: column; align-items: center; line-height: .95;
  font-weight: 700;
}
.others .cmini b { font-size: calc(var(--cw) * .44); letter-spacing: -.08em; }
.others .cmini i { font-style: normal; font-size: calc(var(--cw) * .44); font-family: system-ui, sans-serif; }
.seat.invite {
  display: flex; align-items: center; justify-content: center; gap: 8px; grid-template-columns: none;
  border: 2px dashed rgba(255, 255, 255, .3); background: none; color: var(--muted); font-size: 10px; text-transform: uppercase;
}
.seat.invite b { font-size: 16px; line-height: 1; color: #fff; }
.seat.invite:active { transform: translateY(2px); }
.seat.invite.quiet { visibility: hidden; }
/* alone at the table: a single invite pill under the printing */
.room:not(.crowd) .others { position: absolute; left: 0; right: 0; bottom: calc(100% + 30px); align-items: center; }
.room.dealing:not(.crowd) .others { display: none; }
.room:not(.crowd) .seat.invite {
  width: auto; height: auto; gap: 6px; padding: 5px 12px; font-size: 11px; color: #fff;
  background: rgba(12, 22, 24, .85); border-color: rgba(255, 255, 255, .5);
}
.crowd .hint { top: auto; bottom: -4px; transform: translate(-50%, 0); animation: none; }

/* With others at the table, your cards and the dealer's are sized from what's left of the felt. */
.room.crowd .dealer-zone { --cw: max(30px, min(16vw, 70px, var(--k))); padding-top: 22px; }
.room.crowd .zone-head { margin-bottom: 3px; }
.room.crowd .hands.n1 { --cw: max(30px, min(16vw, 70px, var(--k))); }
.room.crowd .hands.n2 { --cw: max(28px, min(14vw, 64px, var(--k))); }
.room.crowd .hands.n3 { --cw: max(26px, min(11vw, 54px, var(--k))); }
.room.crowd .hands.n4 { --cw: max(24px, min(9.4vw, 48px, var(--k))); }
.room.crowd .player-zone { padding-bottom: 5%; }
/* Your turn: no one else's row is open, so your hand steps forward into that space. */
.room.crowd .player-zone { transform-origin: 50% 100%; transition: transform .4s cubic-bezier(.3, 1.3, .5, 1); }
.room.crowd.myturn .player-zone { transform: scale(1.18); }
@media (max-height: 760px) { .room { --rh: 32px; --rh2: 64px; } }
@media (max-height: 620px) { .room { --rh: 28px; --rh2: 54px; } .seat-bank { font-size: 8px; } }

.controls { position: relative; }
.clock { position: absolute; left: 4px; right: 4px; top: -9px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .4); overflow: hidden; }
.clock[hidden] { display: none; }
.clock i { display: block; height: 100%; width: 100%; background: var(--gold); }
.clock.mine i { background: var(--red); }
.panel-wait { height: 100%; display: grid; place-items: center; }
.panel-wait[hidden] { display: none; }
.wait-txt {
  font-size: 17px; color: var(--gold); text-transform: uppercase; text-align: center;
  background: rgba(12, 22, 24, .8); border: 3px solid var(--edge); border-radius: 12px; padding: 10px 18px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}
.wait-txt:empty { display: none; }
#roomBtns[hidden] { display: none; }

/* ---------- felted (bankroll hit zero) ---------- */
body.felted #app, body.felted #bg {
  filter: grayscale(1) brightness(.55) contrast(1.1);
  transform: scale(1.05);
  transition: filter 1.3s ease-in, transform 2.5s ease-out;
}
#app, #bg { transition: filter .4s, transform .4s; }
.felted-screen {
  position: fixed; inset: 0; z-index: 58; display: grid; place-items: center; pointer-events: none;
  animation: feltIn .5s ease-out both;
}
.felted-screen.out { animation: feltOut .4s ease-in both; }
.felted-screen .band {
  width: 100%; text-align: center; padding: 22px 0 18px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .78) 18%, rgba(0, 0, 0, .78) 82%, transparent);
}
.felted-word {
  font-size: clamp(48px, 16vw, 84px); font-weight: 700; color: #c9302c; line-height: 1; letter-spacing: .02em;
  text-shadow: -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000, 0 6px 0 #000;
  animation: feltSlam .55s cubic-bezier(.2, 1.4, .4, 1) both;
}
.felted-sub { margin-top: 10px; font-size: 13px; color: #cfcfcf; letter-spacing: .2em; }
@keyframes feltIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes feltOut { to { opacity: 0; } }
@keyframes feltSlam { from { transform: scale(1.8); opacity: 0; filter: blur(4px); } to { transform: scale(1); opacity: 1; filter: blur(0); } }
