:root {
  --bg: #0b0b0d;
  --panel: #141418;
  --panel-2: #1c1c22;
  --line: #2b2b33;
  --text: #f1ece0;
  --muted: #9b978d;
  --gold: #d9b65c;
  --gold-soft: #a7893f;
  --felt: #13774b;
  --felt-dark: #07452a;
  --player: #2f7be0;
  --player-soft: rgba(47, 123, 224, 0.22);
  --banker: #dc4136;
  --banker-soft: rgba(220, 65, 54, 0.22);
  --tie: #2fae5f;
  --tie-soft: rgba(47, 174, 95, 0.22);
  --tiger: #e89b22;
  --tiger-soft: rgba(232, 155, 34, 0.16);
  --card-w: clamp(40px, 3.9vw, 68px);
  --card-h: calc(var(--card-w) * 1.43);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* No double-tap or pinch zoom: rapid taps on chips and bet spots must place chips, not zoom the page. */
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; }
button, .spot, .chip, [role="button"] { touch-action: manipulation; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--sans);
  overflow: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.zh { font-family: var(--sans); font-weight: 800; }

/* ============ App frame: fills the whole screen ============ */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) auto;
  background: var(--bg);
}

/* ============ Top bar ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px;
  background: linear-gradient(#18181d, #0f0f12);
  border-bottom: 1px solid var(--line);
  z-index: 10; min-width: 0;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--banker); color: #fff; font-size: 14px; flex: none;
}
.brand-name { font: 700 20px/1 var(--serif); letter-spacing: .5px; }
.tb-sep { width: 1px; height: 20px; background: var(--line); }
.tb-user { color: var(--muted); }
.tb-balance { display: flex; align-items: baseline; gap: 6px; position: relative; }
.tb-balance-label { color: var(--muted); font-size: 12px; }
#balance { color: var(--gold); font-size: 18px; font-variant-numeric: tabular-nums; }
#balance.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.15); color: #fff4c8; } }
.balance-delta {
  position: absolute; left: 100%; top: -2px; margin-left: 8px;
  font-weight: 800; font-size: 15px; white-space: nowrap; opacity: 0; pointer-events: none;
}
.balance-delta.show { animation: delta 1.6s ease forwards; }
.balance-delta.neg { color: #ff8a80; }
.balance-delta.pos { color: #6fe39a; }
@keyframes delta { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }
.tb-table { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tb-table b { color: var(--text); }
.tb-btn {
  height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tb-btn:hover { border-color: var(--gold-soft); }
.tb-btn.icon { width: 34px; padding: 0; font-size: 16px; display: inline-grid; place-items: center; }

/* ============ Stage (studio + dealer + felt) ============ */
.stage { position: relative; overflow: hidden; min-height: 0; isolation: isolate; }
.studio { position: absolute; inset: 0; z-index: -2; background: #1a0c0c; }
.curtain {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 70% at 50% 35%, rgba(255, 190, 140, .22), transparent 70%),
    repeating-linear-gradient(90deg, #4a0d12 0 22px, #6e1219 22px 40px, #3a090d 40px 58px),
    #4a0d12;
  box-shadow: inset 0 -120px 120px rgba(0,0,0,.6), inset 0 60px 80px rgba(0,0,0,.6);
}
.curtain::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.75), transparent 22%, transparent 78%, rgba(0,0,0,.75));
}
.lamp {
  position: absolute; top: 14%; width: 26px; height: 40px; border-radius: 40% 40% 10px 10px;
  background: radial-gradient(circle at 50% 70%, #fff2c6, #f0b860 60%, #9a6526);
  box-shadow: 0 0 40px 18px rgba(255, 190, 100, .35), 0 0 120px 50px rgba(255, 170, 80, .18);
}
.lamp-l { left: 7%; } .lamp-r { right: 7%; }
.lamp-l2 { left: 22%; top: 9%; transform: scale(.7); opacity: .8; }
.lamp-r2 { right: 22%; top: 9%; transform: scale(.7); opacity: .8; }

/* AI dealer */
.dealer {
  position: absolute; left: 50%; bottom: 31%;
  height: 72%; aspect-ratio: 320 / 300;
  transform: translateX(-50%);
  z-index: 3;
}
.dealer-svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 18px 24px rgba(0,0,0,.5)); }
.d-body { animation: breathe 4.5s ease-in-out infinite; transform-origin: 160px 300px; }
@keyframes breathe { 50% { transform: translateY(-2px) scale(1.006); } }
.d-eyes { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.d-ai { animation: aiPulse 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes aiPulse { 50% { opacity: .35; transform: scale(.8); } }
.d-mouth { transform-box: fill-box; transform-origin: center; }
.dealer.speaking .d-mouth { animation: talk .22s ease-in-out 6 alternate; }
@keyframes talk { to { transform: scaleY(2.2) scaleX(.85); } }
.d-arm { transition: transform .25s ease; transform-box: view-box; }
.d-arm-l { transform-origin: 112px 210px; }
.d-arm-r { transform-origin: 208px 210px; }
.dealer.reach-player .d-arm-l { transform: rotate(14deg) translate(-12px, 4px); }
.dealer.reach-banker .d-arm-r { transform: rotate(-14deg) translate(12px, 4px); }
.dealer.reach-shoe .d-arm-r { transform: rotate(-26deg) translate(26px, -4px); }

.dealer-speech {
  position: absolute; left: 82%; top: 6%;
  min-width: 170px; max-width: min(320px, 30vw);
  padding: 8px 14px; border-radius: 14px 14px 14px 4px;
  background: rgba(10, 10, 14, .82); border: 1px solid rgba(217, 182, 92, .6);
  font: 700 clamp(14px, 1.35vw, 19px)/1.25 var(--serif); color: #fff; letter-spacing: .2px;
  box-shadow: 0 8px 20px rgba(0,0,0,.45);
}
.dealer-speech.flash { animation: flash .45s ease; }
@keyframes flash { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Countdown: top-right corner */
.countdown {
  position: absolute; top: 14px; right: 16px; z-index: 6;
  width: clamp(70px, 6.5vw, 96px); aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%; background: rgba(0,0,0,.55);
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  --cd: #3ddc7a;
}
.countdown svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.cd-track { fill: none; stroke: rgba(255,255,255,.14); stroke-width: 5; }
.cd-ring {
  fill: none; stroke: var(--cd); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 175.93; stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke .3s;
}
.cd-num { font: 800 clamp(26px, 2.6vw, 38px)/1 var(--sans); color: var(--cd); font-variant-numeric: tabular-nums; margin-top: -8px; }
.cd-label { position: absolute; bottom: 18%; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: rgba(255,255,255,.75); }
.countdown.warn { --cd: #f5b83d; }
.countdown.danger { --cd: #ff5a4f; animation: tick 1s ease-in-out infinite; }
.countdown.idle { --cd: #8a8a8a; }
.countdown.idle .cd-num { font-size: clamp(14px, 1.3vw, 18px); margin-top: -6px; }
@keyframes tick { 50% { transform: scale(1.06); } }

.red-notice {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-radius: 10px;
  background: rgba(179, 38, 30, .92); color: #fff; font-weight: 700; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.red-chip { width: 12px; height: 18px; border-radius: 2px; background: #ff3b30; box-shadow: 0 0 0 2px #fff; }

.result-banner {
  position: absolute; left: 50%; top: 50%; z-index: 7;
  transform: translate(-50%, -50%);
  padding: 10px 28px; border-radius: 14px;
  font: 700 clamp(22px, 2.6vw, 38px)/1.1 var(--serif); letter-spacing: 1px; color: #fff; text-align: center;
  background: rgba(0,0,0,.7); border: 2px solid var(--gold);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: pop .35s ease;
  white-space: nowrap;
}
.result-banner small { display: block; font: 600 13px/1.4 var(--sans); letter-spacing: .3px; color: rgba(255,255,255,.85); }
.result-banner.player { border-color: var(--player); background: rgba(20, 50, 100, .88); }
.result-banner.banker { border-color: var(--banker); background: rgba(100, 20, 16, .88); }
.result-banner.tie { border-color: var(--tie); background: rgba(14, 70, 38, .9); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.7); opacity: 0; } }

/* Felt table */
.felt {
  position: absolute; left: -12%; right: -12%; bottom: 0; height: 40%; z-index: 2;
  border-radius: 50% 50% 0 0 / 38% 38% 0 0;
  background:
    radial-gradient(ellipse 50% 70% at 50% 10%, rgba(255,255,255,.1), transparent 70%),
    radial-gradient(ellipse at 50% 30%, var(--felt), var(--felt-dark));
  border-top: 14px solid #2d1a10;
  box-shadow: inset 0 3px 0 rgba(217,182,92,.55), 0 -6px 18px rgba(0,0,0,.5);
}
.discard {
  position: absolute; left: 20%; top: 14%;
  width: calc(var(--card-w) * 1.5); height: calc(var(--card-h) * .9);
  border-radius: 6px; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06);
  transform: rotate(-8deg);
}
.shoe-box { position: absolute; right: 18%; top: 6%; width: clamp(110px, 10vw, 150px); text-align: center; }
.shoe-body {
  position: relative; height: calc(var(--card-h) * .85); border-radius: 8px 8px 6px 6px;
  background: linear-gradient(135deg, rgba(255,255,255,.35), rgba(255,255,255,.08));
  border: 2px solid rgba(255,255,255,.4);
  transform: perspective(300px) rotateX(18deg) rotate(6deg);
}
.shoe-card {
  position: absolute; left: 10%; right: 18%; top: 18%; bottom: 14%; border-radius: 4px;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 3px, transparent 3px 6px), linear-gradient(#a3221b, #6e140f);
  border: 2px solid #f4f1ea;
}
.shoe-card.s2 { left: 14%; right: 14%; top: 22%; opacity: .8; }
.shoe-info { margin-top: 6px; font-size: 12px; color: rgba(255,255,255,.85); }
.shoe-info b { color: #fff; font-variant-numeric: tabular-nums; }
.shoe-bar { height: 4px; border-radius: 2px; background: rgba(0,0,0,.3); margin: 4px 10%; overflow: hidden; }
#shoe-bar-fill { height: 100%; background: var(--gold); transition: width .3s; }
.shoe-burn { font-size: 11px; color: rgba(255,255,255,.65); min-height: 1em; }

.hand { position: absolute; top: 16%; width: 22%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hand-player { right: 50.6%; }
.hand-banker { left: 50.6%; }
.cards { display: flex; gap: 6px; height: var(--card-h); align-items: flex-end; }
.hand-label {
  display: flex; align-items: center; gap: 10px;
  font: 800 clamp(16px, 1.6vw, 24px)/1 var(--sans); letter-spacing: 2px; font-style: italic;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.hand-player .hand-label { color: #6fb0ff; }
.hand-banker .hand-label { color: #ff7b70; }
.hand-total {
  min-width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font: 800 18px/1 var(--sans); font-style: normal; letter-spacing: 0; color: #fff;
  background: rgba(0,0,0,.45);
}
.hand-total:empty { visibility: hidden; }
.hand-player .hand-total { border: 2px solid var(--player); }
.hand-banker .hand-total { border: 2px solid var(--banker); }
.hand.winner .cards { filter: drop-shadow(0 0 12px rgba(255, 230, 150, .9)); }
.hand.winner .hand-total { background: #f4d77a; color: #2a1d00; }

/* Cards */
.card { width: var(--card-w); height: var(--card-h); perspective: 600px; flex: none; }
.card.third { width: var(--card-h); display: grid; place-items: center; }
.card-inner {
  position: relative; width: var(--card-w); height: var(--card-h);
  transform-style: preserve-3d; transition: transform .38s ease;
}
.card.third .card-inner { transform: rotate(90deg); }
.card.flipped .card-inner { transform: rotateY(180deg); }
.card.third.flipped .card-inner { transform: rotate(90deg) rotateY(180deg); }
.card-face, .card-back {
  position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
}
.card-back {
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.14) 0 4px, transparent 4px 8px), linear-gradient(#a3221b, #6e140f);
  border: 3px solid #f4f1ea;
}
.card-face {
  transform: rotateY(180deg); background: #fbf9f4; color: #1b1b1f; border: 1px solid #d9d4c7;
  display: flex; flex-direction: column; justify-content: space-between; padding: 3px 5px;
}
.card-face.red { color: #c0281f; }
.card-corner { font: 800 calc(var(--card-w) * .26)/1 var(--sans); }
.card-corner small { display: block; font-size: .85em; }
.card-pip { font-size: calc(var(--card-w) * .46); line-height: 1; text-align: center; margin-top: -8%; }
.card-corner.br { transform: rotate(180deg); align-self: flex-end; }

/* ============ Bottom area ============ */
.bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(520px, 700px) minmax(0, 1fr);
  gap: 10px; padding: 8px 10px 10px;
  background: linear-gradient(#101013, #0a0a0c);
  border-top: 1px solid var(--line);
  min-width: 0;
}
.road {
  min-width: 0; display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
}
.road-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.road-scroll { overflow-x: auto; overflow-y: hidden; border-radius: 6px; background: #f4f1ea; }
.link { background: none; border: none; color: var(--gold); cursor: pointer; font-size: 12px; padding: 0; text-transform: none; letter-spacing: 0; }

.bead-plate {
  display: inline-grid; grid-auto-flow: column;
  grid-template-rows: repeat(6, 24px); grid-auto-columns: 24px;
  gap: 1px; padding: 3px; background: #f4f1ea;
}
.bead { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; position: relative; }
.bead.empty { border-radius: 0; box-shadow: inset 0 0 0 1px #e4dfd1; }
.bead.player { background: var(--player); }
.bead.banker { background: var(--banker); }
.bead.tie { background: var(--tie); }
.bead.tiger::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--tiger); }

.big-road {
  display: inline-grid; grid-auto-flow: column;
  grid-template-rows: repeat(6, 18px); grid-auto-columns: 18px;
  padding: 3px; background: #f4f1ea;
}
.br-cell { width: 18px; height: 18px; box-shadow: inset 0 0 0 .5px #e1dccd; display: grid; place-items: center; position: relative; }
.br-cell i { width: 14px; height: 14px; border-radius: 50%; border: 3px solid; display: block; }
.br-cell.banker i { border-color: var(--banker); }
.br-cell.player i { border-color: var(--player); }
.br-cell.tiger i { background: rgba(232,155,34,.55); }
.br-cell b { position: absolute; inset: 0; display: grid; place-items: center; color: #127a3c; font-size: 9px; font-weight: 900; }
.br-cell.has-tie::after { content: ''; position: absolute; width: 2px; height: 18px; background: var(--tie); transform: rotate(45deg); }

.road-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.road-stats b { font-variant-numeric: tabular-nums; }
.rs-b { color: #ff7b70; } .rs-p { color: #6fb0ff; } .rs-t { color: #5fd68a; } .rs-g { color: var(--tiger); }

/* Win rate 胜率 */
.winrate {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center;
  padding: 6px 8px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line);
}
.wr-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.wr-title .zh { color: var(--gold); font-size: 15px; letter-spacing: 1px; margin-right: 4px; }
.wr-pct { font: 800 24px/1 var(--sans); color: var(--gold); text-align: right; font-variant-numeric: tabular-nums; }
.wr-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: #2a2a31; overflow: hidden; display: flex; }
.wr-bar span { display: block; height: 100%; }
.wr-bar .w { background: #3ddc7a; } .wr-bar .p { background: #9a9a9a; } .wr-bar .l { background: #ff5a4f; }
.wr-detail { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wr-detail b { color: var(--text); }
.wr-detail .w b { color: #6fe39a; } .wr-detail .l b { color: #ff8a80; }

/* Bet panel */
.betpanel {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 8px; border-radius: 12px;
  background: linear-gradient(#123f2b, #0b2c1d); border: 1px solid #1f5a3d;
  box-shadow: inset 0 0 0 1px rgba(217,182,92,.25);
}
.bet-status {
  text-align: center; font-weight: 700; font-size: 13px; letter-spacing: .5px;
  padding: 3px 10px; border-radius: 6px; background: rgba(0,0,0,.35); color: #bff3d2;
}
.bet-status.closed { color: #ffcf8a; }
.spots { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.spot.side { grid-column: span 3; min-height: 62px; }
.spot.main { grid-column: span 4; min-height: 84px; }
.spot {
  position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  border-radius: 8px; border: 1.5px solid rgba(255,255,255,.28);
  padding: 6px 8px; text-align: center;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px;
  transition: background .15s, box-shadow .2s, opacity .3s, transform .08s;
}
.spot:hover { background-color: rgba(255,255,255,.06); }
.spot:active { transform: scale(.985); }
.spot:focus-visible, .chip:focus-visible, .act:focus-visible, .tb-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.spot.side { background: var(--tiger-soft); border-color: rgba(232,155,34,.55); }
.spot-player { background: var(--player-soft); border-color: var(--player); }
.spot-banker { background: var(--banker-soft); border-color: var(--banker); }
.spot-tie { background: var(--tie-soft); border-color: var(--tie); }
.spot-label { font-weight: 800; font-size: 12px; letter-spacing: .4px; color: #fff; line-height: 1.15; }
.spot-label .zh { display: block; font-size: 15px; color: #ffd27a; }
.spot.main .spot-label { font: 800 clamp(18px, 1.6vw, 24px)/1 var(--sans); letter-spacing: 1.5px; }
.spot.main .spot-label .zh { display: inline; font-size: inherit; color: inherit; }
.spot-player .spot-label { color: #8cc0ff; }
.spot-banker .spot-label { color: #ff978d; }
.spot-tie .spot-label { color: #7fe3a6; }
.spot-odds { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.8); font-variant-numeric: tabular-nums; }
.chip-stack { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; pointer-events: none; }
.chip-stack .chip { position: absolute; left: 0; bottom: 0; width: 30px; height: 30px; font-size: 9px; border-width: 2px; }
.spot-amount {
  position: absolute; left: 6px; bottom: 5px; font-weight: 800; font-size: 11px; color: #fff;
  background: rgba(0,0,0,.55); padding: 0 6px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.spot-amount:empty { display: none; }
.spot-remove {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.75); background: #222; color: #fff; font-size: 15px; line-height: 1;
  cursor: pointer; display: none; padding: 0; z-index: 2;
}
.spot.has-bet .spot-remove { display: block; }
.locked .spot { cursor: default; }
.locked .spot-remove { display: none !important; }
.spot-result {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 800 18px/1 var(--sans); padding: 5px 10px; border-radius: 8px; pointer-events: none; display: none; white-space: nowrap; z-index: 1;
}
.spot.hit { box-shadow: 0 0 0 2px #fff3c2, 0 0 18px rgba(255, 223, 128, .65); }
.spot.win .spot-result { display: block; background: #f4d77a; color: #2a1d00; animation: popc .4s ease; }
.spot.push .spot-result { display: block; background: rgba(255,255,255,.9); color: #222; animation: popc .4s ease; }
.spot.lose { opacity: .45; }
@keyframes popc { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

.chipbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.chip-tray { display: flex; gap: 6px; }
.chip {
  --c: #eee; --t: #222; --s: #fff;
  width: 46px; height: 46px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  font: 800 13px/1 var(--sans); color: var(--t);
  background: radial-gradient(circle, var(--c) 0 50%, transparent 51%), repeating-conic-gradient(var(--c) 0 20deg, var(--s) 20deg 40deg);
  border: 3px solid var(--c);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.18), 0 3px 6px rgba(0,0,0,.45);
}
.chip span { width: 64%; height: 64%; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed rgba(255,255,255,.4); }
.chip[data-value="1"] { --c: #f2f0ea; --t: #333; --s: #8a8a8a; }
.chip[data-value="1"] span { border-color: rgba(0,0,0,.25); }
.chip[data-value="5"] { --c: #d0342c; --t: #fff; }
.chip[data-value="10"] { --c: #2459c4; --t: #fff; }
.chip[data-value="50"] { --c: #1f9a4f; --t: #fff; }
.chip[data-value="100"] { --c: #1b1b1f; --t: #f4d77a; --s: #d9b65c; }
.chip-tray .chip { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.chip-tray .chip:hover:not(:disabled) { transform: translateY(-3px); }
.chip-tray .chip[aria-checked="true"] { transform: translateY(-5px); box-shadow: 0 0 0 3px var(--gold), 0 8px 14px rgba(0,0,0,.5); }
.chip-tray .chip:disabled { opacity: .4; cursor: not-allowed; }
.bet-total { color: rgba(255,255,255,.7); font-size: 13px; }
.bet-total b { color: #fff; font-size: 16px; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; }
.act {
  height: 38px; padding: 0 14px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px;
  border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.35);
  transition: opacity .15s, border-color .15s;
}
.act:hover:not(:disabled) { border-color: var(--gold); }
.act:disabled { opacity: .35; cursor: not-allowed; }
.act.confirm { background: linear-gradient(#e2c26c, #b8923b); color: #1d1607; border-color: #e7cf86; }
#btn-clear { width: 38px; padding: 0; }
.hint { min-height: 16px; text-align: center; font-size: 12px; color: #ffb4a8; }

/* ============ Modals ============ */
.modal {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 20px 24px; border-radius: 16px;
  background: var(--panel); color: var(--text); border: 1px solid var(--gold-soft);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal.wide { width: min(1100px, calc(100vw - 32px)); }
.modal.small { width: min(440px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0,0,0,.65); }
.modal h2 { font: 700 28px/1.1 var(--serif); margin: 0 0 12px; }
.modal h3 { font: 700 19px/1.2 var(--serif); color: var(--gold); margin: 20px 0 8px; }
.modal ol { padding-left: 20px; margin: 8px 0; }
.modal li { margin: 4px 0; }
.modal-head { display: flex; align-items: center; gap: 16px; margin-right: 48px; }
.modal-head h2 { margin: 0; }
.modal-close-form { position: absolute; top: 10px; right: 10px; margin: 0; }
.modal-x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); font-size: 22px; cursor: pointer; }
.btn { min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: var(--gold-soft); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { min-height: 32px; font-size: 13px; }
.rules-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rules-table th, .rules-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rules-table th { color: var(--muted); font-weight: 600; }
.toggle { display: flex; align-items: center; gap: 10px; margin-top: 10px; cursor: pointer; font-weight: 600; min-height: 40px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--gold); }
.muted { color: var(--muted); font-size: 13px; }
.settings-row { margin-top: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 14px 0; }
.stat { padding: 8px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); border-top: 3px solid var(--line); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.stat-value { font: 800 20px/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.stat-pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat.player { border-top-color: var(--player); }
.stat.banker { border-top-color: var(--banker); }
.stat.tie { border-top-color: var(--tie); }
.stat.tiger { border-top-color: var(--tiger); }
.stat.you { border-top-color: var(--gold); }

.history-scroll { max-height: 56vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.history { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.history th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--muted); font-weight: 600; text-align: left; padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.history td { padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,.05); white-space: nowrap; }
.history tr.shoe-row td { background: rgba(217,182,92,.1); color: var(--gold); font-weight: 700; text-align: center; letter-spacing: 1px; font-size: 12px; text-transform: uppercase; }
.history .r { color: #ff7a70; }
.history .num { text-align: right; }
.history .pos { color: #6fd393; }
.history .neg { color: #ff8a80; }
.winner-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 700; color: #fff; font-size: 12px; }
.winner-tag.player { background: var(--player); }
.winner-tag.banker { background: var(--banker); }
.winner-tag.tie { background: var(--tie); }
.tiger-tag { color: var(--tiger); font-weight: 700; }
.history-empty { color: var(--muted); text-align: center; margin: 18px 0; }

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .betpanel { grid-column: 1 / -1; order: -1; }
  .tb-table { display: none; }
}
@media (max-width: 1180px), (max-height: 720px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-rows: 44px auto auto; }
  .stage { height: max(380px, 56vh); }
}
@media (max-width: 720px) {
  :root { --card-w: 34px; }
  .topbar { padding: 0 8px; gap: 6px; }
  .brand-name, .tb-sep, .tb-user, .tb-balance-label { display: none; }
  #btn-rules, #btn-history { padding: 0 8px; }
  .stage { height: 400px; }
  .dealer { height: 52%; bottom: 36%; }
  .dealer-speech { left: 50%; top: auto; bottom: 100%; transform: translateX(-50%); min-width: 220px; max-width: 86vw; text-align: center; border-radius: 12px; font-size: 15px; }
  .dealer-speech.flash { animation: none; }
  .felt { height: 38%; left: -30%; right: -30%; }
  .hand { width: 34%; top: 10%; }
  .hand-player { right: 50.5%; }
  .hand-banker { left: 50.5%; }
  .cards { gap: 2px; }
  .hand-label { font-size: 13px; letter-spacing: .5px; gap: 6px; }
  .hand-total { min-width: 26px; height: 26px; font-size: 14px; }
  .discard { display: none; }
  .shoe-box { right: 26%; top: auto; bottom: 4px; width: auto; }
  .shoe-body, .shoe-bar, .shoe-burn { display: none; }
  .countdown { width: 64px; top: 10px; right: 10px; }
  .red-notice { top: auto; bottom: 40%; font-size: 12px; }
  .bottom { grid-template-columns: minmax(0, 1fr); padding: 6px; }
  .spot.side { grid-column: span 6; min-height: 54px; }
  .spot.main { min-height: 72px; }
  .spot.main .spot-label { font-size: 16px; letter-spacing: .5px; }
  .chip { width: 42px; height: 42px; font-size: 12px; }
  .chipbar { justify-content: center; }
  .actions { width: 100%; }
  .act { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
