/* Card tables: green felt with a padded rail, casino chips, and the Stake-style control bar.
   Used by PWAPJack, Nick's Table, Three Card Poker, Baccarat and Double Down Madness (casino/table.js).
   The page around it keeps the casino's dark ink; the felt is the one saturated surface. */

body[data-line="casino"] {
  --felt-hi: #178a5c;
  --felt-mid: #0e6a45;
  --felt-lo: #06311f;
  --felt-print: #d8f0e0;
  --felt-line: rgb(214 240 224 / .34);
  --rail: #4a0f12;
  --gold: #ffd166;
  --on-gold: #241800;
  --sbar-bg: #0e1326;
  --tile-bg: #1a2140;
  --go: #2a74cf;
  --go-hi: #3485e6;
}

/* ================= layout ================= */
.cx-view.game { grid-template-columns: minmax(0, 1fr); }
.tbl-game { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; min-width: 0; }
.tbl-game > * { min-width: 0; }
.tbl-below { min-width: 0; }
@media (min-width: 900px) {
  .tbl-game { grid-template-columns: 330px minmax(0, 1fr); grid-template-areas: "bar felt" "bar below"; gap: 18px; }
  .tbl-game > .sbar { grid-area: bar; position: sticky; top: 16px; }
  .tbl-game > .felt { grid-area: felt; }
  .tbl-game > .tbl-below { grid-area: below; }
}

/* ================= felt ================= */
.felt {
  --cw: clamp(40px, 11cqi, 74px);
  position: relative; container-type: inline-size; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; min-height: 470px; padding: 62px 10px 70px;
  border-radius: 22px;
  background: radial-gradient(ellipse 85% 75% at 50% 42%, var(--felt-hi) 0%, var(--felt-mid) 46%, var(--felt-lo) 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .06), inset 0 0 90px rgb(0 0 0 / .5), 0 18px 40px -18px rgb(0 0 0 / .8);
  color: #fff;
}
@media (min-width: 900px) { .felt { min-height: 560px; padding-top: 70px; } }
.felt::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 .7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.felt .pc { --w: var(--cw); }
.felt .hand { min-height: 0; justify-content: center; }
.felt .hand .pc + .pc { margin-left: calc(var(--cw) * -.5); }

.felt-rack {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; padding: 8px 12px 11px;
  border-radius: 0 0 14px 14px; background: linear-gradient(#c79a45, #7b5517);
  box-shadow: inset 0 -3px 5px rgb(0 0 0 / .45), inset 0 2px 0 rgb(255 255 255 / .25), 0 8px 16px -4px rgb(0 0 0 / .55);
}
.felt-rack::before { content: ""; position: absolute; inset: 5px 6px 7px; border-radius: 0 0 9px 9px; background: #1b1209; box-shadow: inset 0 3px 6px rgb(0 0 0 / .7); z-index: -0; }
.felt-rack .chip { position: relative; }
.felt-shoe { position: absolute; top: 12px; right: 14px; width: 44px; height: 60px; transform: rotate(7deg); }
.shoe-card, .felt-shoe::after { position: absolute; inset: 0; border-radius: 6px; }
.shoe-card { background: #b3202a; border: 2px solid #f6f1e6; box-shadow: 0 2px 5px rgb(0 0 0 / .5); }
.shoe-card:nth-child(1) { translate: 0 6px; }
.shoe-card:nth-child(2) { translate: 0 3px; }
.shoe-card:nth-child(3)::after { content: ""; position: absolute; inset: 4px; border-radius: 3px; border: 1px solid rgb(255 255 255 / .6);
  background: repeating-linear-gradient(45deg, rgb(255 255 255 / .2) 0 2px, transparent 2px 6px), repeating-linear-gradient(-45deg, rgb(255 255 255 / .2) 0 2px, transparent 2px 6px); }

.felt-dealer { display: grid; justify-items: center; align-content: start; gap: 6px; --cw: clamp(44px, 12cqi, 78px); min-height: calc(var(--cw) * 1.43 + 34px); }
.felt-dealer .dealer-row { position: relative; display: grid; justify-items: center; align-items: center; min-height: calc(var(--cw) * 1.43); }
.felt-ribbon { width: min(88%, 420px); margin: 8px auto 0; }
.felt-ribbon svg { display: block; width: 100%; height: auto; overflow: visible; }
.rb-band { fill: rgb(0 0 0 / .1); stroke: rgb(216 240 224 / .28); stroke-width: 1.5; }
.rb-top, .rb-bot { font-family: var(--font); font-weight: 800; fill: var(--felt-print); opacity: .82; text-transform: uppercase; }
.rb-top { font-size: 11.5px; letter-spacing: .1em; }
.rb-bot { font-size: 14.5px; letter-spacing: .08em; }
.felt-mid { flex: 1; display: grid; justify-items: center; align-content: center; gap: 8px; min-height: 8px; }
.felt-spots { margin-top: auto; }
.felt-rail {
  position: absolute; left: -10%; right: -10%; bottom: -34px; height: 78px; border-radius: 50% 50% 0 0 / 100% 100% 0 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 60% 100% at 50% 0, #7a1f22, var(--rail) 70%);
  box-shadow: 0 -10px 22px rgb(0 0 0 / .55), inset 0 3px 0 rgb(255 255 255 / .16), inset 0 10px 14px rgb(255 255 255 / .06);
}
.felt > * { position: relative; }
.felt > .felt-rack, .felt > .felt-shoe, .felt > .felt-rail { position: absolute; }

.fpill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; line-height: 1.4; font-variant-numeric: tabular-nums; background: rgb(8 12 24 / .74); border: 1px solid rgb(255 255 255 / .16); color: #fff; white-space: nowrap; }
.fpill.gold { background: var(--gold); color: var(--on-gold); border-color: transparent; }
.fpill.bad { background: #cf3b32; border-color: transparent; }
.fpill.good { background: #1b8a50; border-color: transparent; }
.fpill:empty { display: none; }
.felt .banner { padding: 4px 12px; gap: 6px; font-size: 13px; background: rgb(8 12 24 / .86); border-color: rgb(255 255 255 / .16); color: #fff; box-shadow: 0 4px 12px rgb(0 0 0 / .45); }
.felt .banner-delta { font-size: 15px; }
.felt .banner.win { background: #1a7f4a; color: #fff; border-color: transparent; }
.felt .banner.lose { color: #ffb4ad; }
.felt .banner.even { color: #dfe6f5; }

/* ================= playing cards (cream stock, corner indices; red lattice back) ================= */
.pc-face { display: block; background: #fbf8f1; color: #15181f; border-radius: calc(var(--w) * .13); box-shadow: 0 1px 2px rgb(0 0 0 / .35), 0 6px 12px -5px rgb(0 0 0 / .5); }
.pc-face.red { color: #c8322a; }
.pc-corner { position: absolute; display: grid; justify-items: center; line-height: .95; font-family: var(--font); }
.pc-corner.tl { top: 5%; left: 8%; }
.pc-corner.br { bottom: 5%; right: 8%; transform: rotate(180deg); }
.pc-corner .pc-rank { font-style: normal; font-weight: 900; font-size: calc(var(--w) * .3); letter-spacing: -.04em; }
.pc-corner .pc-suit { font-style: normal; font-size: calc(var(--w) * .26); line-height: 1; }
.pc-pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .54); line-height: 1; }
.pc-back { box-sizing: border-box; border-radius: calc(var(--w) * .13); background: #b3202a; border: calc(var(--w) * .06) solid #fbf8f1; box-shadow: 0 1px 2px rgb(0 0 0 / .35), 0 6px 12px -5px rgb(0 0 0 / .5); }
.pc-back::after { inset: calc(var(--w) * .05); border-radius: calc(var(--w) * .06); border: 1.5px solid rgb(255 255 255 / .7);
  background: repeating-linear-gradient(45deg, rgb(255 255 255 / .22) 0 2px, transparent 2px 7px), repeating-linear-gradient(-45deg, rgb(255 255 255 / .22) 0 2px, transparent 2px 7px); }

/* ================= betting spots ================= */
.spot { position: relative; width: calc(var(--cw) + 10px); height: calc(var(--cw) * 1.43 + 10px); border: 2px solid var(--felt-line); border-radius: 10px; }
.rspot {
  position: relative; display: grid; place-items: center; align-content: center; gap: 2px; width: clamp(70px, 22cqi, 96px); aspect-ratio: 1; padding: 0;
  border: 2px solid var(--felt-line); border-radius: 50%; color: var(--felt-print); background: rgb(0 0 0 / .08);
  font-family: var(--font); font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; text-align: center;
  transition: border-color 160ms var(--ease-out), box-shadow 200ms var(--ease-out), background-color 200ms, transform 160ms var(--ease-out);
}
button.rspot { cursor: pointer; }
button.rspot:not(:disabled):active { transform: scale(.96); }
button.rspot:disabled { cursor: default; }
.rspot.sel, .bjbox.sel .spot { border-color: var(--gold); box-shadow: 0 0 0 3px rgb(255 209 102 / .22), 0 0 22px rgb(255 209 102 / .3); }
.rspot.sel { color: var(--gold); background: rgb(255 209 102 / .08); }
@media (hover: hover) and (pointer: fine) { button.rspot:not(:disabled):not(.sel):hover { border-color: rgb(255 255 255 / .6); } }
.rspot .cstack { position: absolute; left: 50%; bottom: 14%; translate: -50% 0; }
.rspot-l { position: relative; z-index: 0; }
.rspot.has .rspot-l { position: absolute; top: calc(100% + 4px); left: 50%; translate: -50% 0; white-space: nowrap; color: var(--felt-print); z-index: 2; text-shadow: 0 1px 2px rgb(0 0 0 / .6); }

/* ================= chips ================= */
.chip {
  --s: 44px; --c: #f2f3f7; --edge: #c3c8d4; --tx: #1b1e27;
  position: relative; display: inline-grid; place-items: center; flex: none; width: var(--s); height: var(--s); border-radius: 50%;
  background: repeating-conic-gradient(var(--edge) 0 14deg, var(--c) 14deg 45deg);
  box-shadow: 0 2px 0 rgb(0 0 0 / .4), 0 4px 8px rgb(0 0 0 / .4), inset 0 0 0 1px rgb(0 0 0 / .28);
}
.chip::before { content: ""; position: absolute; inset: 13%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgb(255 255 255 / .28), transparent 55%), var(--c); border: 2px dashed rgb(255 255 255 / .8); box-shadow: inset 0 1px 3px rgb(0 0 0 / .35); }
.c1::before { border-color: rgb(30 34 46 / .45); }
.chip-n { position: relative; font-family: var(--font); font-weight: 900; font-size: calc(var(--s) * .3); letter-spacing: -.02em; line-height: 1; color: var(--tx); font-variant-numeric: tabular-nums; text-shadow: 0 1px 1px rgb(0 0 0 / .25); }
.c1 .chip-n { text-shadow: none; }
.c5 { --c: #d8353a; --edge: #fff; --tx: #fff; }
.c10 { --c: #2d7fe6; --edge: #fff; --tx: #fff; }
.c25 { --c: #1d9a56; --edge: #fff; --tx: #fff; }
.c100 { --c: #1c1f29; --edge: #e8e9ee; --tx: #fff; }
.c500 { --c: #7a4fd6; --edge: #fff; --tx: #fff; }

.cstack { display: grid; justify-items: center; gap: 3px; }
.cstack-pile { position: relative; width: 38px; height: 62px; }
.cstack-pile .chip { --s: 38px; position: absolute; left: 0; bottom: calc(var(--i) * 4.5px); animation: chip-drop 220ms var(--ease-out) both; animation-delay: calc(var(--i) * 28ms); }
.cstack.empty .cstack-pile { height: 38px; }
.cstack.empty .cstack-pile::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px dashed var(--felt-line); }
.cstack-amt { padding: 1px 9px; border-radius: 999px; background: rgb(8 12 24 / .78); color: #fff; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; border: 1px solid rgb(255 255 255 / .14); }
@keyframes chip-drop { from { opacity: 0; transform: translateY(-14px) scale(1.15); } }

/* ================= Stake-style control bar ================= */
.sbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 14px; border-radius: 16px; background: var(--sbar-bg); border: 1px solid rgb(255 255 255 / .07); box-shadow: 0 10px 28px -14px rgb(0 0 0 / .8); }
.sbar-go { min-height: 52px; border-radius: 10px; background: var(--go); color: #fff; font: inherit; font-size: 17px; font-weight: 700; box-shadow: 0 1px 0 rgb(255 255 255 / .25) inset, 0 8px 18px -10px rgb(42 116 207 / .9); transition: background-color 160ms var(--ease-out), transform 140ms var(--ease-out), opacity 160ms; }
.sbar-go:not(:disabled):active { transform: scale(.985); }
@media (hover: hover) and (pointer: fine) { .sbar-go:not(:disabled):hover { background: var(--go-hi); } }
.sbar-go:disabled { opacity: .45; box-shadow: none; cursor: default; }
.sbar-tiles { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; }
.sbar-tiles[hidden] { display: none; }
.tile {
  display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 76px; padding: 8px 4px; border-radius: 12px;
  background: var(--tile-bg); border: 1px solid rgb(255 255 255 / .06); color: #aab3cf; font: inherit;
  transition: background-color 160ms var(--ease-out), transform 140ms var(--ease-out), opacity 160ms, border-color 160ms;
}
.tile i { font-size: 24px; line-height: 1; color: #6f8fe8; }
.tile.violet i { color: #9a7df0; }
.tile.amber i { color: #d99a45; }
.tile.green i, .tile.green .tile-x { color: #34b377; }
.tile.red i { color: #ef6a62; }
.tile-x { font-size: 22px; font-weight: 900; line-height: 24px; color: #34b377; letter-spacing: -.02em; }
.tile-l { font-size: 15px; font-weight: 700; }
.tile:not(:disabled) { color: #e6ebfa; }
.tile:not(:disabled):active { transform: scale(.96); }
@media (hover: hover) and (pointer: fine) { .tile:not(:disabled):hover { background: #232c52; border-color: rgb(255 255 255 / .14); } }
.tile:disabled { opacity: .42; cursor: default; }
.sbar-amount { display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 12px; border-radius: 10px; background: #0a0e1c; border: 1px solid rgb(255 255 255 / .09); }
.sbar-amount:focus-within { border-color: #4a8be0; box-shadow: 0 0 0 3px rgb(74 139 224 / .28); }
.sbar-amount > i { color: #f0b83c; font-size: 19px; }
.sbar-input { flex: 1; min-width: 0; min-height: 40px; padding: 0 4px; background: transparent; border: 0; outline: 0; color: #f1f4fb; font: inherit; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sbar-input::selection { background: rgb(74 139 224 / .5); }
.sbar-mini { min-height: 40px; min-width: 44px; padding: 0 10px; border-radius: 8px; background: var(--tile-bg); color: #d6dcf0; font: inherit; font-size: 15px; font-weight: 700; transition: background-color 160ms, transform 140ms var(--ease-out); }
.sbar-mini:not(:disabled):active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .sbar-mini:not(:disabled):hover { background: #2a3463; } }
.sbar-mini:disabled { opacity: .45; }
.sbar-chips { display: flex; justify-content: space-between; gap: 4px; }
.sbar-chip { padding: 0; border-radius: 50%; transition: transform 160ms var(--ease-out), opacity 160ms; }
.sbar-chip .chip { --s: min(48px, 100%); }
.sbar-chip:not(:disabled):active { transform: scale(.9); }
@media (hover: hover) and (pointer: fine) { .sbar-chip:not(:disabled):hover { transform: translateY(-3px); } }
.sbar-chip:disabled { opacity: .45; }
.sbar-hint { font-size: 13px; color: #aab3cf; text-wrap: pretty; }
.sbar-seg { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sbar-seg-l { font-size: 14px; font-weight: 700; color: #aab3cf; }
.seg-btns { display: flex; gap: 6px; }
.seg-btn { min-width: 44px; min-height: 36px; padding: 0 12px; border-radius: 8px; background: var(--tile-bg); color: #d6dcf0; font: inherit; font-size: 15px; font-weight: 700; border: 1px solid transparent; transition: background-color 160ms, border-color 160ms; }
.seg-btn[aria-pressed="true"] { background: #1d3f73; border-color: #4a8be0; color: #fff; }
.seg-btn:disabled { opacity: .45; }
.sbar-say { display: grid; gap: 8px; }
.sbar-say p { margin: 0; font-size: 14px; line-height: 1.4; color: #c9d1e8; text-wrap: pretty; }
.sbar-yn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sbar-yn .tile { min-height: 56px; }

/* ================= blackjack boxes ================= */
.bj-boxes { display: grid; grid-template-columns: repeat(var(--n, 1), minmax(0, 1fr)); gap: clamp(4px, 2cqi, 16px); align-items: end; }
.bjbox { --cw: clamp(32px, 46cqi, 74px); container-type: inline-size; display: grid; justify-items: center; align-content: end; gap: 5px; transition: transform 260ms var(--ease-out); }
.bj-boxes[data-n="3"] .bjbox:nth-child(1) { transform: rotate(-2.5deg) translateY(-4px); }
.bj-boxes[data-n="3"] .bjbox:nth-child(2) { transform: translateY(14px); }
.bj-boxes[data-n="3"] .bjbox:nth-child(3) { transform: rotate(2.5deg) translateY(-4px); }
.bj-boxes[data-n="1"] { grid-template-columns: minmax(0, 220px); justify-content: center; }
.bj-boxes[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 190px)); justify-content: center; gap: clamp(14px, 8cqi, 60px); }
.bjbox-top { min-height: 26px; display: grid; align-content: end; justify-items: center; }
.bjbox .spot { position: relative; display: block; padding: 0; cursor: default; transition: border-color 200ms var(--ease-out), box-shadow 240ms var(--ease-out); }
.bjbox .hand { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.bjbox.active .spot { border-color: var(--gold); box-shadow: 0 0 0 3px rgb(255 209 102 / .22), 0 0 24px rgb(255 209 102 / .35); }
.bjbox.pickable .spot { cursor: pointer; }
.bjbox-bet { min-height: 62px; display: grid; justify-items: center; align-content: start; }
.bjbox-result { min-height: 0; display: grid; justify-items: center; }
.bjbox-result:empty { display: none; }
.bjbox-pick { position: absolute; inset: 0; padding: 0; background: transparent; border-radius: inherit; }
.bjbox-pick:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.bjbox.lost .hand { opacity: .55; transition: opacity 300ms; }

/* ================= other tables ================= */
.fx-row { display: flex; justify-content: center; align-items: flex-end; gap: clamp(8px, 4cqi, 28px); flex-wrap: wrap; }
.fx-hand { display: grid; justify-items: center; gap: 6px; }
.fx-head { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.fx-hand .hand { min-height: calc(var(--cw) * 1.43); }
.fx-hand.winner .fpill { background: var(--gold); color: var(--on-gold); border-color: transparent; }
.fx-hand.winner .hand { filter: drop-shadow(0 0 12px rgb(255 209 102 / .6)); }
.fx-label { font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--felt-print); text-shadow: 0 1px 2px rgb(0 0 0 / .5); }
.fx-note { margin: 0; text-align: center; font-size: 14px; font-weight: 600; color: var(--felt-print); text-shadow: 0 1px 2px rgb(0 0 0 / .5); text-wrap: balance; }
.fx-spots { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 6cqi, 40px); padding-bottom: 6px; }
.fx-spots .rspot { --cw: 44px; }
.fx-wide { width: clamp(84px, 26cqi, 120px); aspect-ratio: 5 / 4; border-radius: 16px; }
.fx-tip { margin-top: 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; opacity: .85; }
.fx-pay { padding: 12px 14px; border-radius: 14px; background: var(--sbar-bg); border: 1px solid rgb(255 255 255 / .07); }
.fx-pay summary { cursor: pointer; font-size: 14px; font-weight: 700; color: #c9d1e8; }
.fx-pay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 10px; }
.fx-pay-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: #c9d1e8; padding: 2px 0; }
.fx-pay-row strong { color: #fff; font-variant-numeric: tabular-nums; }

/* Nick's Table commentary sits above the felt */
.tbl-game .bubble { grid-column: 1 / -1; }

@media (prefers-reduced-motion: reduce) {
  .cstack-pile .chip { animation: none; }
  .bjbox { transition: none; }
}
