*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --felt-light: #166a45;
  --felt-mid: #0e4a30;
  --felt-dark: #062719;
  --rail-top: #442616;
  --rail-bot: #1e0f08;
  --brass: #e8c36a;
  --brass-soft: rgba(232, 195, 106, 0.34);
  --card-w: 62px;
  --card-h: 88px;
  --card-overlap: -24px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(232, 195, 106, 0.12), transparent 65%),
    radial-gradient(ellipse 75% 60% at 50% 100%, rgba(16, 98, 60, 0.16), transparent 70%);
}

.bj-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1160px;
  margin: 0 auto;
  padding:
    calc(var(--safe-top) + 8px)
    12px
    calc(var(--safe-bottom) + 8px);
  gap: 8px;
}

/* ==================== TOP BAR ==================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  flex: 0 0 auto;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 4px 2px;
}
.back-link:hover { color: var(--text); }

.title-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.brand-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #f7e6bd;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.brand-title span {
  color: var(--brass);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.11); }
.icon-btn:active { transform: scale(0.93); }
.speed-btn.is-fast {
  border-color: var(--brass);
  color: var(--brass);
  background: rgba(232, 195, 106, 0.14);
}

/* ==================== VEGAS SEMICIRCULAR FELT TABLE ==================== */
.table-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-rail {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 26px 26px 50% 50% / 24px 24px 28% 28%;
  padding: 10px;
  background: linear-gradient(180deg, var(--rail-top) 0%, #2a150b 55%, var(--rail-bot) 100%);
  box-shadow:
    inset 0 2px 3px rgba(255, 224, 178, 0.18),
    inset 0 -4px 10px rgba(0, 0, 0, 0.65),
    0 14px 36px rgba(0, 0, 0, 0.55);
  display: flex;
}

.table-felt {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px 18px 48% 48% / 16px 16px 26% 26%;
  border: 2px solid var(--brass-soft);
  background:
    radial-gradient(ellipse 90% 72% at 50% 18%, var(--felt-light) 0%, var(--felt-mid) 56%, var(--felt-dark) 100%);
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.52);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 24px 18px;
}

/* Subtle curved brass felt typography */
.felt-arc-svg {
  position: absolute;
  top: 19%;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 760px);
  height: auto;
  pointer-events: none;
  z-index: 0;
}
.felt-arc-main {
  fill: rgba(244, 212, 128, 0.34);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.22em;
}
.felt-arc-sub {
  fill: rgba(244, 212, 128, 0.24);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

/* ==================== DEALER ZONE ==================== */
.dealer-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: start;
  gap: 8px;
}

.dealer-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: calc(var(--card-h) + 26px);
}

.dealer-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--card-h);
}

/* Shoe & Discard Tray */
.tray-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.shoe-body,
.discard-body {
  position: relative;
  width: 34px;
  height: 52px;
  border-radius: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 16, 11, 0.62);
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65);
}

.shoe-deck-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    0deg,
    #f2eee4 0px,
    #f2eee4 2px,
    #c9c2b2 2px,
    #c9c2b2 3px
  );
  transition: height 0.3s ease;
}

.shoe-cut-marker {
  position: absolute;
  left: 1px;
  right: 1px;
  height: 3px;
  background: #ffd43b;
  box-shadow: 0 0 6px rgba(255, 212, 59, 0.85);
}

.shoe-box.needs-shuffle .shoe-body {
  border-color: #ffd43b;
  box-shadow: 0 0 12px rgba(255, 212, 59, 0.55);
}

.discard-stack {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    0deg,
    #8d1f35 0px,
    #8d1f35 2px,
    #621222 2px,
    #621222 3px
  );
  transition: height 0.3s ease;
}

.shoe-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.shoe-label {
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(244, 212, 128, 0.72);
}
.shoe-box.needs-shuffle .shoe-label {
  color: #ffd43b;
}
.shoe-count {
  font-size: 0.7rem;
  color: #e9f5ee;
}

/* ==================== TOAST BANNER ==================== */
.table-toast {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(8, 18, 14, 0.94);
  border: 1px solid rgba(232, 195, 106, 0.62);
  color: #fae6b0;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.58);
  white-space: nowrap;
  pointer-events: none;
}

/* ==================== PLAYING CARDS & 3D FLIPS ==================== */
.playing-card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  perspective: 820px;
  flex: 0 0 auto;
  z-index: calc(1 + var(--card-i, 0));
  will-change: transform;
}
.playing-card + .playing-card {
  margin-left: var(--card-overlap);
}
.playing-card.is-flying {
  z-index: 60;
}
.playing-card.is-flying .card-face {
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.56);
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.playing-card.is-facedown .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.42);
  transition: box-shadow 0.2s ease;
}

.card-front {
  background: linear-gradient(160deg, #ffffff 0%, #f5f2e9 100%);
  border: 1px solid rgba(20, 25, 38, 0.22);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 4px;
}

.suit-red .card-front { color: #c81e30; }
.suit-black .card-front { color: #161c2a; }

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  width: fit-content;
}
.card-br {
  align-self: flex-end;
  transform: rotate(180deg);
}
.card-rank {
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}
.card-suit {
  font-size: 0.7rem;
}

.card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.card-pip-std .center-suit {
  font-size: 1.55rem;
  opacity: 0.9;
}
.card-pip-ace .center-suit {
  font-size: 2.1rem;
}
.card-pip-royal {
  flex-direction: column;
  line-height: 0.9;
}
.royal-letter {
  font-size: 1.3rem;
  font-weight: 900;
  opacity: 0.2;
}
.royal-suit {
  font-size: 1.15rem;
  margin-top: -4px;
}

.card-back {
  transform: rotateY(180deg);
  background: #fdfaf2;
  border: 1px solid rgba(0, 0, 0, 0.25);
  padding: 3px;
}
.card-back-pattern {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  border: 1px solid rgba(232, 195, 106, 0.65);
  background:
    repeating-linear-gradient(45deg, rgba(232, 195, 106, 0.16) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(-45deg, rgba(232, 195, 106, 0.16) 0 4px, transparent 4px 8px),
    linear-gradient(155deg, #8f162e 0%, #5a0c1b 100%);
}

/* ==================== 3-SEAT CIRCULAR VEGAS ARC ==================== */
.seats-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 18px;
  padding: 22px 12px 6px;
}

/* Authentic curved circular Vegas rail geometry: Anchor (left) -> Center -> 1st Base (right) */
.seat-pos-0 { transform: translateY(-24px) rotate(4.2deg); }
.seat-pos-1 { transform: translateY(0px) rotate(0deg); }
.seat-pos-2 { transform: translateY(-24px) rotate(-4.2deg); }

.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.seat.is-pickable {
  cursor: pointer;
}
.seat.is-pickable:hover {
  background: rgba(255, 255, 255, 0.06);
}
.seat.is-pickable:hover .bet-circle {
  border-color: var(--brass);
}

.seat.is-active {
  background: radial-gradient(ellipse at 50% 60%, rgba(232, 195, 106, 0.2), transparent 76%);
  box-shadow: 0 0 0 1.5px rgba(232, 195, 106, 0.52), 0 0 24px rgba(232, 195, 106, 0.24);
}

.seat-hands {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  min-height: calc(var(--card-h) + 22px);
  width: 100%;
}

.hand-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 2px;
  border-radius: 10px;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.hand-slot.is-sub-active {
  background: rgba(232, 195, 106, 0.14);
  box-shadow: 0 0 0 1.5px var(--brass);
}

.hand-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--card-h);
}

/* Compress card sizes automatically when a seat splits */
.seat.is-split-hands {
  --card-w: 46px;
  --card-h: 66px;
  --card-overlap: -23px;
}
.seat.split-n-3,
.seat.split-n-4 {
  --card-w: 38px;
  --card-h: 54px;
  --card-overlap: -20px;
}

.hand-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 20px;
}

.total-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(7, 16, 12, 0.86);
  color: #edf5f0;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.total-pill.val-empty {
  color: rgba(244, 212, 128, 0.62);
  border-color: rgba(244, 212, 128, 0.22);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
}
.total-pill.val-soft {
  border-color: rgba(114, 214, 255, 0.45);
  color: #bde9ff;
}
.total-pill.val-21 {
  border-color: var(--good);
  color: var(--good);
}
.total-pill.val-bj {
  background: linear-gradient(135deg, #ffd866, #d99b26);
  color: #1b1203;
  border-color: #fff2b2;
}
.total-pill.val-bust {
  background: rgba(185, 28, 46, 0.9);
  border-color: #ff7a87;
  color: #fff;
}

.action-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-bj { background: linear-gradient(135deg, #ffe07d, #e09c24); color: #1f1302; }
.badge-win { background: #1ec97e; color: #052214; }
.badge-push { background: rgba(180, 194, 212, 0.24); color: #e2eaf4; border: 1px solid rgba(255, 255, 255, 0.2); }
.badge-lose { background: rgba(220, 48, 68, 0.88); color: #fff; }
.badge-gold { background: rgba(232, 195, 106, 0.22); color: #ffd97a; border: 1px solid rgba(232, 195, 106, 0.5); }
.badge-info { background: rgba(108, 172, 255, 0.22); color: #c7e1ff; border: 1px solid rgba(108, 172, 255, 0.45); }
.badge-muted { background: rgba(255, 255, 255, 0.1); color: #cfd8d3; }

.ins-pill {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(232, 195, 106, 0.2);
  color: #ffe08a;
  border: 1px solid rgba(232, 195, 106, 0.4);
}
.ins-pill.ins-win { background: #1ec97e; color: #052214; border-color: #6df2b6; }
.ins-pill.ins-lose { opacity: 0.55; text-decoration: line-through; }

.split-bet-chip {
  font-size: 0.62rem;
  font-weight: 800;
  color: #f3dc9a;
}

/* ==================== THREE BETTING CIRCLES (BONUS | MAIN | BUSTER) ==================== */
.bet-circles-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.bet-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(232, 195, 106, 0.4);
  background: rgba(4, 22, 14, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.14s ease;
}
.seat.is-human .bet-circle {
  border-color: rgba(232, 195, 106, 0.68);
  box-shadow: inset 0 0 12px rgba(232, 195, 106, 0.15);
}
.bet-circle.empty-circle {
  border-style: dashed;
  border-color: rgba(232, 195, 106, 0.26);
  background: rgba(4, 22, 14, 0.14);
}

.side-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.75px solid rgba(232, 195, 106, 0.36);
  background: rgba(4, 20, 12, 0.32);
  box-shadow: inset 0 0 0 3px rgba(232, 195, 106, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.14s ease, background 0.16s ease;
}
.seat.is-human .side-circle {
  border-color: rgba(232, 195, 106, 0.56);
}
.side-circle.bonus-circle {
  background: radial-gradient(circle at 50% 45%, rgba(232, 195, 106, 0.12), rgba(4, 20, 12, 0.38));
}
.side-circle.buster-circle {
  background: radial-gradient(circle at 50% 45%, rgba(235, 118, 56, 0.12), rgba(4, 20, 12, 0.38));
}

.bet-circle.is-selectable,
.side-circle.is-selectable,
.side-circle.is-turn-clickable {
  cursor: pointer;
}
.bet-circle.is-selectable:hover,
.side-circle.is-selectable:hover,
.side-circle.is-turn-clickable:hover {
  border-color: #ffe394;
  transform: scale(1.04);
}

.bet-circle.is-target,
.side-circle.is-target {
  border-color: #ffe285;
  box-shadow:
    0 0 0 2px rgba(255, 226, 133, 0.42),
    0 0 18px rgba(255, 212, 84, 0.45),
    inset 0 0 12px rgba(255, 218, 112, 0.24);
  background: rgba(232, 195, 106, 0.16);
}

.side-circle.is-turn-clickable:not(.is-target) {
  border-color: rgba(255, 178, 86, 0.85);
  box-shadow: 0 0 12px rgba(255, 166, 62, 0.32);
}

.side-circle-label {
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: rgba(244, 212, 128, 0.82);
  line-height: 1.05;
  text-align: center;
}
.side-circle-odds {
  font-size: 0.44rem;
  font-weight: 800;
  color: rgba(255, 196, 132, 0.78);
  line-height: 1;
  margin-top: 1px;
}

.side-outcome-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.side-outcome-badge.side-win {
  background: linear-gradient(135deg, #ffe282, #23d485);
  color: #072112;
  border: 1px solid #fff5c8;
}
.side-outcome-badge.side-lose {
  background: rgba(185, 32, 50, 0.9);
  color: #ffe7ea;
  border: 1px solid rgba(255, 130, 145, 0.4);
}

.seat-pos-tag {
  font-size: 0.58rem;
  font-weight: 700;
  color: rgba(232, 195, 106, 0.68);
  text-align: center;
  line-height: 1.1;
}
.sit-hint {
  font-size: 0.54rem;
  font-weight: 800;
  color: #f8e5ae;
  margin-top: 2px;
}
.circle-hint {
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(244, 212, 128, 0.78);
  text-align: center;
  padding: 0 4px;
}

.bet-chips {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.mini-chip-stack {
  position: relative;
  width: 26px;
  height: 26px;
}
.mini-chip {
  position: absolute;
  left: 0;
  bottom: calc(var(--stack-i, 0) * 3px);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px dashed rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}
.side-chips .mini-chip-stack,
.side-chips .mini-chip {
  width: 20px;
  height: 20px;
  border-width: 2px;
}
.side-chips .mini-chip {
  bottom: calc(var(--stack-i, 0) * 2.5px);
}
.mini-chip.chip-5 { background: #c92638; }
.mini-chip.chip-25 { background: #198754; }
.mini-chip.chip-100 { background: #1a1f2c; border-color: #ffd45c; }
.mini-chip.chip-500 { background: #6b2dbd; border-color: #f4d3ff; }
.mini-chip.chip-frac { background: #d4a026; }

.bet-amt-pill {
  position: relative;
  z-index: 4;
  margin-top: -6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(6, 15, 11, 0.94);
  border: 1px solid rgba(232, 195, 106, 0.48);
  color: #fce8af;
  font-size: 0.64rem;
  font-weight: 800;
}
.side-chips .bet-amt-pill {
  font-size: 0.56rem;
  padding: 0 5px;
  margin-top: -5px;
}

/* Seat Nameplate & Drink Indicator */
.seat-plate {
  width: 100%;
  max-width: 176px;
  padding: 4px 9px;
  border-radius: 10px;
  background: rgba(6, 16, 12, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.18;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.seat.is-human .seat-plate {
  border-color: rgba(232, 195, 106, 0.58);
  background: rgba(24, 18, 6, 0.84);
}
.seat-plate.is-max-drinks {
  border-color: rgba(255, 192, 68, 0.72);
  background: linear-gradient(180deg, rgba(44, 28, 8, 0.86), rgba(18, 14, 7, 0.86));
  box-shadow: 0 0 14px rgba(255, 186, 56, 0.24);
}
.seat-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
}
.seat-name {
  font-size: 0.76rem;
  font-weight: 800;
  color: #f2f7f4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat.is-human .seat-name { color: var(--brass); }
.drink-icons {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: -0.08em;
  flex: 0 0 auto;
}
.drink-icons.is-max-drinks {
  filter: drop-shadow(0 0 5px rgba(255, 198, 66, 0.85));
}
.seat-label-mini {
  font-size: 0.58rem;
  color: rgba(210, 224, 216, 0.6);
  white-space: nowrap;
}
.seat-bank {
  font-size: 0.72rem;
  color: #8ee6b8;
  font-weight: 700;
}

/* Vegas Table Quip Bubble (Multi-line, High Contrast, Easy to Read) */
.quip-bubble {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  width: max-content;
  max-width: 220px;
  padding: 6px 11px;
  border-radius: 13px;
  background: rgba(9, 13, 22, 0.96);
  border: 1.5px solid rgba(244, 206, 114, 0.72);
  color: #fff8e6;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.28;
  text-align: center;
  white-space: normal;
  overflow-wrap: break-word;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.62);
  pointer-events: none;
  animation: quipIn 0.22s ease both;
}
.quip-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: rgba(9, 13, 22, 0.96);
  border-right: 1.5px solid rgba(244, 206, 114, 0.72);
  border-bottom: 1.5px solid rgba(244, 206, 114, 0.72);
  transform: translateX(-50%) rotate(45deg);
}
.quip-bubble.is-tipsy {
  background: linear-gradient(160deg, rgba(36, 20, 6, 0.97), rgba(16, 10, 4, 0.97));
  border-color: #ffc857;
  color: #fff2cc;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.66), 0 0 14px rgba(255, 196, 64, 0.28);
}
.quip-bubble.is-tipsy::after {
  background: rgba(20, 12, 5, 0.97);
  border-right-color: #ffc857;
  border-bottom-color: #ffc857;
}
@keyframes quipIn {
  from { opacity: 0; transform: translate(-50%, 6px) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ==================== BOTTOM CONTROL DECK ==================== */
.control-deck {
  flex: 0 0 auto;
  background: rgba(11, 16, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hud-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.hud-cell {
  display: flex;
  flex-direction: column;
  line-height: 1.12;
}
.hud-center { align-items: center; }
.hud-right { align-items: flex-end; }
.hud-label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.hud-val {
  font-size: 0.98rem;
  font-weight: 900;
  color: var(--text);
}
.hud-val.val-pos { color: var(--good); }
.hud-val.val-neg { color: var(--bad); }

.deck-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bet-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-rack {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clay-chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3.5px dashed rgba(255, 255, 255, 0.86);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, 0.25),
    0 4px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.clay-chip-sm {
  width: 36px;
  height: 36px;
  font-size: 0.66rem;
  border-width: 2.5px;
}
.clay-chip:hover:not(:disabled) { transform: translateY(-2px); }
.clay-chip:active:not(:disabled) { transform: scale(0.92); }
.clay-chip:disabled { opacity: 0.3; cursor: not-allowed; }
.rack-chip-5 { background: radial-gradient(circle at 32% 30%, #ea3a4c, #a71929); }
.rack-chip-25 { background: radial-gradient(circle at 32% 30%, #24ab6c, #11623d); }
.rack-chip-100 { background: radial-gradient(circle at 32% 30%, #343d52, #121620); border-color: #ffd564; color: #ffe7a3; }
.rack-chip-500 { background: radial-gradient(circle at 32% 30%, #924ae8, #501b92); border-color: #f5d8ff; }

.bet-utilities {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.util-btn {
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.util-btn:active:not(:disabled) { transform: scale(0.94); }
.util-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.refill-btn {
  height: 38px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid #ffd45c;
  background: linear-gradient(135deg, #f3c44d, #cf8f1a);
  color: #1f1302;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.primary-cta {
  height: 42px;
  width: 100%;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #27d98b 0%, #11995d 100%);
  color: #041d11;
  font-size: 0.94rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(17, 153, 93, 0.36);
  transition: transform 0.12s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.primary-cta:active:not(:disabled) { transform: scale(0.98); }
.primary-cta:disabled { opacity: 0.38; cursor: not-allowed; box-shadow: none; }

/* Inline Mid-Turn Buster Chip Picker */
.turn-buster-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 11px;
  background: rgba(255, 168, 66, 0.11);
  border: 1px solid rgba(255, 184, 88, 0.44);
  flex-wrap: wrap;
}
.turn-buster-label {
  font-size: 0.76rem;
  font-weight: 800;
  color: #ffd89b;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.turn-buster-chips {
  display: flex;
  align-items: center;
  gap: 6px;
}
.buster-close-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 0.72rem;
}

/* Action Buttons */
.action-grid {
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-grid .action-btn {
  flex: 1 1 0;
  min-width: 0;
}

.action-btn {
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  padding: 0 10px;
}
.action-btn kbd {
  font-family: inherit;
  font-size: 0.64rem;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  opacity: 0.8;
}
.action-btn:active:not(:disabled) { transform: scale(0.95); }
.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-hit { background: linear-gradient(135deg, #27d98b, #14a364); color: #042013; border-color: #5bf0ae; }
.btn-stand { background: linear-gradient(135deg, #e04657, #ad2132); color: #fff; border-color: #ff8290; }
.btn-double { background: linear-gradient(135deg, #f3c44d, #cf8f1a); color: #1f1302; border-color: #ffe394; }
.btn-split { background: linear-gradient(135deg, #6298ff, #386be0); color: #fff; border-color: #9ec0ff; }
.btn-buster {
  background: linear-gradient(135deg, #ff9f43, #d36319);
  color: #210d02;
  border-color: #ffca8a;
}
.btn-buster.is-open {
  box-shadow: 0 0 0 2px rgba(255, 202, 138, 0.55), 0 0 14px rgba(255, 159, 67, 0.45);
}
.btn-gold { background: linear-gradient(135deg, #f3c44d, #cf8f1a); color: #1f1302; border-color: #ffe394; padding: 0 16px; }
.btn-neutral { background: rgba(255, 255, 255, 0.09); color: var(--text); padding: 0 14px; }

.insurance-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.insurance-text {
  font-size: 0.86rem;
  font-weight: 700;
  color: #fce8b2;
}
.insurance-btns {
  display: flex;
  gap: 8px;
}

.wait-status {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 700;
  color: #cbd7d0;
  letter-spacing: 0.03em;
}

.over-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.over-row .primary-cta { flex: 1; }
.over-row .action-btn { height: 42px; }

/* ==================== MODALS ==================== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(3, 7, 14, 0.76);
  display: grid;
  place-items: center;
  padding: 12px;
  backdrop-filter: blur(6px);
}

.sheet {
  width: 100%;
  max-width: 460px;
  max-height: 92%;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid rgba(232, 195, 106, 0.28);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sheet-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}
.close-x {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.sheet-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.38;
}

.setup-block h3 {
  margin: 0 0 6px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
}

.pill-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pill-opt {
  padding: 9px 6px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.pill-opt small {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--muted);
}
.pill-opt.active {
  border-color: var(--brass);
  background: rgba(232, 195, 106, 0.18);
  color: #ffe8a6;
}
.pill-opt:disabled { opacity: 0.4; cursor: not-allowed; }

.midhand-note {
  margin: 0;
  font-size: 0.78rem;
  color: #ffd46a;
}

.info-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.tab-btn {
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.active {
  background: rgba(232, 195, 106, 0.18);
  border-color: var(--brass);
  color: #ffe8a6;
}

.rules-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  line-height: 1.38;
  color: #d7e0ed;
}
.rules-list code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.stat-card {
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-card span {
  font-size: 0.7rem;
  color: var(--muted);
}
.stat-card strong {
  font-size: 0.94rem;
  font-weight: 800;
}

.sheet-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.sheet-hub {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

/* ==================== AUTO-ROTATED LANDSCAPE ON PORTRAIT PHONES ==================== */
@media (orientation: portrait) and (max-width: 760px) {
  .bj-shell {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100dvh;
    height: 100dvw;
    max-width: none;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
    padding:
      4px
      calc(var(--safe-bottom) + 8px)
      4px
      calc(var(--safe-top) + 8px);
    gap: 4px;
  }
}

/* ==================== COMPACT LANDSCAPE PHONE DENSITY ==================== */
/* Applies to BOTH native sideways phones AND auto-rotated portrait phones */
@media (max-height: 520px), (orientation: portrait) and (max-width: 760px) {
  :root {
    --card-w: 42px;
    --card-h: 58px;
    --card-overlap: -19px;
  }

  .bj-shell {
    gap: 4px;
  }

  .top-bar {
    min-height: 26px;
    gap: 6px;
  }
  .back-link { font-size: 0.74rem; padding: 2px 0; }
  .brand-title { font-size: 0.92rem; letter-spacing: 0.12em; }
  .icon-btn {
    height: 26px;
    min-width: 28px;
    padding: 0 6px;
    font-size: 0.76rem;
    border-radius: 8px;
  }

  .table-rail {
    border-radius: 16px 16px 50% 50% / 14px 14px 30% 30%;
    padding: 5px;
  }
  .table-felt {
    border-radius: 12px 12px 48% 48% / 12px 12px 28% 28%;
    padding: 6px 14px 8px;
  }

  .felt-arc-svg {
    top: 17%;
    width: min(74%, 520px);
    opacity: 0.78;
  }

  .dealer-row {
    grid-template-columns: 44px 1fr 44px;
    gap: 4px;
  }
  .dealer-hand {
    min-height: calc(var(--card-h) + 18px);
    gap: 3px;
  }
  .shoe-body, .discard-body {
    width: 24px;
    height: 36px;
  }
  .shoe-label { font-size: 0.48rem; }
  .shoe-count { font-size: 0.6rem; }

  /* Full 3-seat circular edge curve scaled for phone landscape */
  .seats-grid {
    gap: 10px;
    padding: 6px 6px 2px;
  }
  .seat-pos-0 { transform: translateY(-16px) rotate(3.6deg); }
  .seat-pos-1 { transform: translateY(0px) rotate(0deg); }
  .seat-pos-2 { transform: translateY(-16px) rotate(-3.6deg); }

  .seat {
    gap: 3px;
    padding: 3px 4px;
  }
  .seat-hands {
    min-height: calc(var(--card-h) + 16px);
    gap: 4px;
  }
  .seat.is-split-hands {
    --card-w: 32px;
    --card-h: 46px;
    --card-overlap: -16px;
  }
  .seat.split-n-3,
  .seat.split-n-4 {
    --card-w: 26px;
    --card-h: 38px;
    --card-overlap: -14px;
  }

  .card-rank { font-size: 0.66rem; }
  .card-suit { font-size: 0.54rem; }
  .card-pip-std .center-suit { font-size: 1.05rem; }
  .card-pip-ace .center-suit { font-size: 1.35rem; }
  .royal-letter { font-size: 0.92rem; }
  .royal-suit { font-size: 0.8rem; }

  .hand-meta { min-height: 16px; gap: 2px; }
  .total-pill { font-size: 0.62rem; padding: 1px 5px; }
  .action-badge { font-size: 0.56rem; padding: 1px 5px; }

  .bet-circles-row {
    gap: 6px;
  }
  .bet-circle {
    width: 40px;
    height: 40px;
  }
  .side-circle {
    width: 32px;
    height: 32px;
  }
  .side-circle-label { font-size: 0.39rem; }
  .side-circle-odds { font-size: 0.36rem; }
  .side-outcome-badge { font-size: 0.5rem; padding: 0 4px; top: -9px; }

  .mini-chip-stack, .mini-chip {
    width: 18px;
    height: 18px;
    border-width: 2px;
  }
  .side-chips .mini-chip-stack,
  .side-chips .mini-chip {
    width: 14px;
    height: 14px;
    border-width: 1.5px;
  }
  .bet-amt-pill { font-size: 0.54rem; padding: 0px 4px; }
  .side-chips .bet-amt-pill { font-size: 0.48rem; padding: 0 3px; }
  .seat-pos-tag, .sit-hint, .circle-hint { font-size: 0.48rem; }

  .seat-plate {
    padding: 2px 6px;
    max-width: 138px;
    border-radius: 8px;
  }
  .seat-label-mini { display: none; }
  .seat-name { font-size: 0.64rem; }
  .drink-icons { font-size: 0.6rem; }
  .seat-bank { font-size: 0.6rem; }
  .quip-bubble {
    font-size: 0.66rem;
    padding: 4px 8px;
    top: -14px;
    max-width: 180px;
    line-height: 1.24;
  }

  /* Single-row sleek horizontal casino control rail */
  .control-deck {
    flex-direction: row;
    align-items: center;
    padding: 5px 10px;
    gap: 10px;
    border-radius: 13px;
  }

  .hud-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 0;
    padding-right: 10px;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    flex: 0 0 auto;
  }
  .hud-center, .hud-right { align-items: flex-start; }
  .hud-label { font-size: 0.5rem; }
  .hud-val { font-size: 0.8rem; }

  .deck-panel {
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  #panel-turn {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .turn-buster-bar {
    padding: 3px 8px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .turn-buster-label { font-size: 0.66rem; }
  .clay-chip-sm {
    width: 28px;
    height: 28px;
    font-size: 0.56rem;
  }
  .buster-close-btn { height: 26px; padding: 0 8px; font-size: 0.64rem; }

  .bet-controls-row {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .chip-rack { gap: 5px; }
  .clay-chip {
    width: 34px;
    height: 34px;
    font-size: 0.64rem;
    border-width: 2.5px;
  }
  .bet-utilities { gap: 4px; margin-left: 4px; }
  .util-btn { height: 32px; padding: 0 8px; font-size: 0.7rem; }
  .refill-btn { height: 34px; padding: 0 10px; font-size: 0.74rem; }
  .primary-cta {
    width: auto;
    min-width: 118px;
    height: 36px;
    padding: 0 16px;
    font-size: 0.8rem;
  }

  .action-grid {
    flex: 1 1 auto;
    width: 100%;
    gap: 6px;
  }
  .action-btn {
    height: 34px;
    font-size: 0.72rem;
    padding: 0 8px;
  }
  .action-btn kbd { display: none; }

  .insurance-banner {
    width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .insurance-text { font-size: 0.76rem; }

  .wait-status {
    height: 36px;
    width: 100%;
    font-size: 0.78rem;
  }

  .over-row {
    width: 100%;
    justify-content: flex-end;
  }
  .over-row .primary-cta { flex: 0 1 auto; min-width: 150px; }
  .over-row .action-btn { height: 36px; }

  .sheet {
    max-width: 520px;
    padding: 12px 14px;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
