/* Single visual world: a casino table at night. Walnut room, baize felt, oxblood rail, gold print. */
:root {
  color-scheme: dark;
  --ground: #140f0d;
  --panel: #1e1613;
  --panel-2: #2a1f1b;
  --line: rgba(216, 178, 92, .18);
  --line-2: rgba(216, 178, 92, .4);
  --text: #efe7d9;
  --muted: #b8a893;
  --faint: #8d7d6a;
  --gold: #d8b25c;
  --gold-hi: #f0d28a;
  --gold-ink: #241a07;
  --felt: #0f5c45;
  --felt-deep: #062f23;
  --felt-hi: #1b7c5d;
  --felt-text: #e8f1eb;
  --felt-muted: #a4c8b7;
  --rail: #3b1a14;
  --rail-hi: #62301f;
  --paper: #fbf8f0;
  --ink: #16171b;
  --suit-red: #c0262d;
  --win: #83dca4;
  --lose: #ff927f;
  --push: #ecd384;
  --c-hit: #3f8f72;
  --c-stand: #c9a24a;
  --c-double: #4f7fb8;
  --c-split: #9a6bb3;
  --c-surr: #c65a4e;
  --f-display: "Bodoni Moda", "Bodoni 72", Didot, Georgia, serif;
  --f-ui: "Barlow Semi Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
  --f-body: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-suit: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", "Noto Sans Symbols 2", sans-serif;
}

[hidden] { display: none !important; }
html, body { background: var(--ground); }
body {
  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  padding-inline: 16px;
  min-height: 100%;
  background:
    radial-gradient(1100px 520px at 50% -8%, #2b1d16 0%, transparent 65%),
    var(--ground);
}
button { font: inherit; color: inherit; }
kbd { font-family: var(--f-ui); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  max-width: 1280px;
  margin: 0 auto;
  padding-block: 14px 10px;
  display: flex;
  align-items: center;
  gap: 12px 28px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 40px;
  border-radius: 5px;
  background: var(--paper);
  color: var(--suit-red);
  font: 700 17px/1 var(--f-display);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 3px 3px 0 var(--rail-hi);
  rotate: -6deg;
}
.brand-name { font: 500 23px/1 var(--f-display); letter-spacing: .01em; }
.brand-name em { color: var(--gold); font-style: italic; }
.tabs { display: flex; gap: 4px 20px; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; cursor: pointer;
  padding: 8px 0 6px;
  font: 600 14px var(--f-ui);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--gold-hi); border-bottom-color: var(--gold); }
.bank { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.bank-label { font: 600 11px var(--f-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.bank-value { font: 700 24px var(--f-display); color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.bank-value.bump { animation: bump .5s ease; }
@keyframes bump { 40% { scale: 1.08; } }

main { max-width: 1280px; margin: 0 auto; padding-block: 6px 48px; }

/* ---------- Table layout ---------- */
.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.table-col { min-width: 0; }

.felt {
  --cw: clamp(48px, 10cqw, 90px);
  position: relative;
  container-type: inline-size;
  margin: 14px 14px 26px;
  padding: 18px 18px 40px;
  min-height: 500px;
  display: flex; flex-direction: column; gap: 4px;
  border-radius: 30px 30px 50% 50% / 30px 30px 20% 20%;
  background: radial-gradient(ellipse 85% 75% at 50% 32%, var(--felt-hi) 0%, var(--felt) 45%, var(--felt-deep) 100%);
  box-shadow:
    0 0 0 12px var(--rail), 0 0 0 13px var(--rail-hi), 0 0 0 15px #0d0605,
    0 26px 60px rgba(0,0,0,.6), inset 0 0 90px rgba(0,0,0,.45);
}
.felt::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  opacity: .16; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.felt > * { position: relative; }

.felt-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; }
.tray, .shoe { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tray { justify-self: start; }
.shoe { justify-self: end; }
.tray-box, .shoe-box {
  position: relative; overflow: hidden;
  width: calc(var(--cw) * .78); height: calc(var(--cw) * 1.05);
  border-radius: 7px;
  background: rgba(0,0,0,.28);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.35);
}
.tray-stack {
  position: absolute; left: 4px; right: 4px; bottom: 3px; height: 0;
  border-radius: 3px;
  background: repeating-linear-gradient(to top, #eee5d2 0 2px, #c7b99d 2px 3px);
  transition: height .5s ease;
}
.shoe-box { background: linear-gradient(160deg, #2a1812, #120a08); }
.shoe-card {
  position: absolute; left: 14%; top: 18%; width: 78%; height: 100%;
  border-radius: 6px; rotate: -10deg;
  background:
    repeating-linear-gradient(45deg, rgba(240,210,138,.35) 0 1.5px, transparent 1.5px 7px),
    repeating-linear-gradient(-45deg, rgba(240,210,138,.35) 0 1.5px, transparent 1.5px 7px),
    #6d231c;
  box-shadow: inset 0 0 0 3px #f2ebdc;
}
.shoe.shuffling .shoe-card { animation: riffle .3s ease-in-out 4; }
@keyframes riffle { 50% { translate: 0 -8px; rotate: -2deg; } }
.felt-label {
  font: 600 11px var(--f-ui); letter-spacing: .14em; text-transform: uppercase;
  color: var(--felt-muted); text-align: center; white-space: nowrap;
}

.dealer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hand-cards { display: flex; min-height: calc(var(--cw) * 1.4); padding-inline: 4px; }
.total-pill {
  min-width: 2.6em; padding: 1px 10px; border-radius: 999px; text-align: center;
  background: rgba(0,0,0,.42); color: var(--felt-text);
  font: 600 15px/1.5 var(--f-ui); font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Table print */
.print { margin-block: -2px -26px; }
.print-svg { display: block; width: 100%; max-width: 620px; height: auto; margin: 0 auto; overflow: visible; }
.p-main { fill: var(--gold); font: 700 40px var(--f-display); letter-spacing: 5px; opacity: .92; }
.p-rule { fill: var(--gold); font: italic 500 25px var(--f-display); opacity: .85; }
.p-band { fill: none; stroke: var(--gold); stroke-width: 1.6; opacity: .5; }
.p-ins { fill: var(--gold); font: 600 17px var(--f-ui); letter-spacing: 6px; opacity: .7; dominant-baseline: middle; }
.table-msg {
  position: absolute; left: 50%; top: 42%; translate: -50% -50%;
  max-width: 92%; width: max-content; z-index: 3;
  padding: 7px 18px; border-radius: 999px; text-align: center;
  background: rgba(3, 22, 16, .82); border: 1px solid var(--line-2);
  color: var(--felt-text); font: 600 17px/1.3 var(--f-ui); letter-spacing: .02em;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  animation: msgIn .25s ease both;
}
.table-msg:empty { display: none; }
.table-msg .up { color: var(--win); }
.table-msg .down { color: var(--lose); }
@keyframes msgIn { from { opacity: 0; translate: -50% -30%; } }

.player-area { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 1; }
.player-hands { display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; gap: 10px 18px; min-height: calc(var(--cw) * 1.4 + 38px); }
.player-hands[data-count="3"], .player-hands[data-count="4"] { --cw: clamp(40px, 7.4cqw, 70px); }
.hand {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px 6px 4px; border-radius: 14px;
  border: 1px solid transparent;
  transition: background .2s, border-color .2s;
}
.hand.active { background: rgba(240, 210, 138, .09); border-color: var(--line-2); }
.hand.idle { opacity: .72; }
.hand-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.hand-bet { font: 600 13px var(--f-ui); color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.badge {
  padding: 1px 8px; border-radius: 6px;
  font: 700 12px/1.6 var(--f-ui); letter-spacing: .08em; text-transform: uppercase;
  animation: pop .3s ease-out both;
}
.badge.win { background: var(--win); color: #06301a; }
.badge.bj { background: var(--gold-hi); color: var(--gold-ink); }
.badge.lose { background: var(--lose); color: #3a0c05; }
.badge.push { background: var(--push); color: #352a05; }

.bet-spot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bet-ring {
  width: 76px; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid rgba(216,178,92,.55);
  box-shadow: inset 0 0 0 5px rgba(216,178,92,.12);
}
.bet-stack { position: relative; width: 44px; height: 44px; }
.bet-amount { font: 600 14px var(--f-ui); color: var(--felt-muted); letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* ---------- Cards ---------- */
.card {
  position: relative; flex: none;
  width: var(--cw); aspect-ratio: 5 / 7; max-width: 100%;
  perspective: 900px;
  container-type: inline-size;
}
.card + .card { margin-left: calc(var(--cw) * -.56); }
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.3, .7, .2, 1);
}
.card.down .card-inner { transform: rotateY(180deg); }
.card-face, .card-back {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 7cqw;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.card-face {
  color: var(--ink);
  background: linear-gradient(155deg, #fffdf8, var(--paper) 55%, #efe7d4);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.14), 0 1px 1px rgba(0,0,0,.3), 0 4px 10px rgba(0,0,0,.32);
}
.card.red .card-face { color: var(--suit-red); }
.card-back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(240,210,138,.38) 0 1.3cqw, transparent 1.3cqw 8cqw),
    repeating-linear-gradient(-45deg, rgba(240,210,138,.38) 0 1.3cqw, transparent 1.3cqw 8cqw),
    radial-gradient(circle at 50% 50%, #86302a, #501611);
  box-shadow: inset 0 0 0 4.5cqw #f3ecdd, inset 0 0 0 5.6cqw #b8923f, 0 1px 1px rgba(0,0,0,.3), 0 4px 10px rgba(0,0,0,.32);
}
.corner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  width: 17cqw; line-height: .92;
}
.corner.tl { top: 5cqw; left: 3.5cqw; }
.corner.br { bottom: 5cqw; right: 3.5cqw; rotate: 180deg; }
.corner .r { font: 700 20cqw/1 var(--f-display); letter-spacing: -.04em; }
.corner .r.ten { font-size: 17cqw; letter-spacing: -.1em; margin-left: -.1em; }
.corner .s { font: 15cqw/1 var(--f-suit); margin-top: 1.5cqw; }
.pips { position: absolute; inset: 15cqw 20cqw; }
.pip {
  position: absolute; translate: -50% -50%;
  font: 25cqw/1 var(--f-suit);
}
.pip.flip { rotate: 180deg; }
.pip.ace { font-size: 56cqw; }
.court {
  position: absolute; inset: 17cqw 19cqw;
  display: grid; place-items: center;
  border-radius: 3cqw;
  background:
    repeating-linear-gradient(135deg, rgba(184,146,63,.12) 0 2cqw, transparent 2cqw 4cqw),
    linear-gradient(#fff9ea, #f1e3bf);
  box-shadow: inset 0 0 0 1.4cqw currentColor, inset 0 0 0 2.6cqw #fffaf0, inset 0 0 0 3.2cqw rgba(184,146,63,.9);
}
.court-l { font: italic 700 52cqw/1 var(--f-display); translate: 0 -2cqw; }
.court-s { position: absolute; font: 15cqw/1 var(--f-suit); }
.court-s.tl { top: 5cqw; left: 6cqw; }
.court-s.br { bottom: 5cqw; right: 6cqw; rotate: 180deg; }

.card.deal-in { animation: dealIn .42s cubic-bezier(.2, .75, .25, 1) both; }
@keyframes dealIn {
  from { transform: translate(var(--fx, 0px), var(--fy, -140px)) rotate(-16deg) scale(.92); opacity: .5; }
  to { transform: none; opacity: 1; }
}
.card.sideways { rotate: 90deg; margin-left: calc(var(--cw) * -.3); translate: 0 calc(var(--cw) * .12); }
.card.pop { animation: pop .22s ease-out both; }
@keyframes pop { from { transform: scale(.9) translateY(8px); opacity: 0; } }
.sweep .card { transition: opacity .25s, translate .25s; opacity: 0; translate: 0 -12px; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 10px; }
.chip {
  --c: #b3262d;
  position: relative; display: grid; place-items: center;
  width: 56px; aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background:
    radial-gradient(circle, var(--c) 0 55%, transparent 56%),
    repeating-conic-gradient(from 8deg, #f3ecdd 0 14deg, var(--c) 14deg 45deg);
  box-shadow: inset 0 0 0 3px var(--c), 0 3px 0 rgba(0,0,0,.45), 0 6px 12px rgba(0,0,0,.3);
  transition: translate .12s, box-shadow .12s;
}
.chip span {
  display: grid; place-items: center;
  width: 64%; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px dashed rgba(243,236,221,.75);
  font: 700 15px/1 var(--f-ui); color: #fbf6ea; letter-spacing: .02em;
}
button.chip:hover:not(:disabled) { translate: 0 -3px; box-shadow: inset 0 0 0 3px var(--c), 0 6px 0 rgba(0,0,0,.45), 0 10px 16px rgba(0,0,0,.3); }
button.chip:disabled { opacity: .35; cursor: not-allowed; }
.chip.mini { position: absolute; left: 0; width: 44px; box-shadow: inset 0 0 0 2px var(--c), 0 2px 0 rgba(0,0,0,.5); animation: pop .18s ease-out both; }
.chip.mini span { font-size: 11px; border-width: 1px; }

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 16px;
  font: 600 16px var(--f-ui); letter-spacing: .07em; text-transform: uppercase;
  color: var(--text);
  background: linear-gradient(#35271f, #251b16);
  border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 2px 0 rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  cursor: pointer; transition: border-color .15s, translate .1s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:active:not(:disabled) { translate: 0 1px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#f2d690, #c99a3e); color: var(--gold-ink); border-color: #f6e0a6; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn kbd {
  padding: 0 5px; border-radius: 4px; border: 1px solid currentColor;
  font-size: 11px; font-weight: 600; opacity: .55; letter-spacing: 0;
}
.btn.act::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 2px rgba(0,0,0,.3); }
.btn.suggest { border-color: var(--gold-hi); animation: glow 1.1s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(240,210,138,.35), 0 2px 0 rgba(0,0,0,.45); } }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.controls { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ctrl-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 12px; }
.ctrl-q { margin: 0; font: 500 17px var(--f-ui); color: var(--text); }
.ctrl-q b { color: var(--gold-hi); }
.coach-ask {
  max-width: 640px; padding: 12px 14px; border-radius: 12px;
  background: rgba(198, 90, 78, .12); border: 1px solid rgba(255, 146, 127, .4);
}
.coach-ask p { margin: 0; flex: 1 1 280px; text-wrap: pretty; }
.coach-ask b { color: var(--gold-hi); }
.coach-strip {
  max-width: 680px; min-height: 2.9em; text-align: center; text-wrap: pretty;
  display: flex; flex-direction: column; gap: 2px; font-size: 14.5px; color: var(--muted);
}
.coach-state { font: 600 13px var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.coach-fb b { color: var(--text); }
.coach-fb .good { color: var(--win); font-weight: 600; }
.coach-fb .bad { color: var(--lose); font-weight: 600; }

.stepper { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.stepper button { width: 42px; border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--text); }
.stepper button:hover { background: rgba(216,178,92,.12); }
.stepper input {
  width: 70px; border: 0; border-radius: 0; background: transparent; text-align: center;
  font: 700 22px var(--f-display); color: var(--gold-hi); padding: 6px 0;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .card.deal-in, .card.pop, .chip.mini, .table-msg, .badge, .btn.suggest, .shoe.shuffling .shoe-card, .bank-value.bump { animation: none; }
  .card-inner, .tray-stack { transition: none; }
}
