/* ==========================================================================
   Blackjack Salon — the table
   The game is laid out on a fixed "stage" that is scaled to fit the window:
   1600×1000 in landscape, 820×1600 in portrait (#stage.portrait). Every
   position below is in stage pixels. Shared pieces live in common.css.
   ========================================================================== */

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
body {
  background: radial-gradient(1200px 760px at 50% 40%, #241f19 0%, #15120f 58%, #0b0a08 100%);
}

#viewport {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  overflow: hidden;
}
#stage {
  position: absolute;
  width: 1600px;
  height: 1000px;
  transform-origin: 0 0;
  touch-action: manipulation;
}

/* ---------------------------------------------------------------- Top bar */

.topbar {
  position: absolute;
  left: 30px; right: 30px; top: 8px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 28px;
  z-index: 20;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark { color: var(--brass); font-size: 20px; }
.brand-name { font: 600 21px/1 var(--display); letter-spacing: .1em; }
.brand-name em { font-style: normal; color: var(--brass); }

.learn { display: flex; gap: 20px; }
.learn a, .top-actions button {
  font: 600 14px/1 var(--cond);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 6px 0;
  transition: color .15s;
}
.learn a:hover, .top-actions button:hover { color: var(--ink); }

.rules-summary {
  flex: 1; min-width: 0;
  background: none; border: 0; padding: 6px 0;
  text-align: center;
  font: 500 13.5px/1 var(--cond);
  letter-spacing: .06em;
  color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .15s;
}
.rules-summary:hover { color: var(--muted); }
.rules-summary .sep { margin: 0 8px; opacity: .5; }
.rules-summary .edge { color: var(--brass); }

.top-actions { display: flex; align-items: center; gap: 22px; }
.top-actions #btnBuy { color: var(--brass-hi); }
#btnSound { display: grid; place-items: center; width: 26px; padding: 0; }
#btnSound svg, #btnMenu svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#btnSound .snd-off { display: none; }
#btnSound.muted .snd-on { display: none; }
#btnSound.muted .snd-off { display: block; }
#btnMenu { display: none; }

/* ---------------------------------------------------------------- Table */

.table {
  position: absolute;
  left: 40px; top: 64px;
  width: 1520px; height: 790px;
  border-radius: 26px 26px 760px 760px / 26px 26px 760px 760px;
}
.rail {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #45291a 0%, #2f1b10 60%, #23140b 100%);
  box-shadow:
    0 36px 80px rgba(0, 0, 0, .6),
    inset 0 2px 0 rgba(255, 230, 200, .1),
    inset 0 -3px 8px rgba(0, 0, 0, .55);
}
.felt {
  position: absolute;
  left: 24px; right: 24px; top: 24px; bottom: 24px;
  border-radius: 6px 6px 736px 736px / 6px 6px 736px 736px;
  background: radial-gradient(70% 55% at 50% 24%, var(--felt-hi) 0%, var(--felt) 58%, var(--felt-lo) 100%);
  box-shadow:
    0 0 0 1.5px rgba(201, 164, 92, .6),
    0 0 0 5px rgba(0, 0, 0, .3),
    inset 0 0 110px rgba(0, 0, 0, .42),
    inset 0 16px 36px rgba(0, 0, 0, .3);
  overflow: hidden;
  transition: background .6s;
}
.felt::after {
  content: '';
  position: absolute; inset: 0;
  opacity: .2;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.felt-print {
  position: absolute; left: 0; top: 0;
  width: 1600px; height: 1000px;
  pointer-events: none;
}
.felt-print text { font-family: var(--display); fill: rgba(244, 228, 186, .5); }
.felt-print .t-main { font-size: 29px; font-weight: 600; letter-spacing: .1em; fill: rgba(244, 224, 166, .6); }
.felt-print .t-rule { font-size: 14px; font-family: var(--cond); font-weight: 600; letter-spacing: .26em; fill: rgba(255, 255, 255, .32); }
.felt-print .t-ins { font-size: 16px; font-weight: 600; letter-spacing: .28em; fill: rgba(244, 224, 166, .48); }
.felt-print .band { fill: none; stroke: rgba(244, 224, 166, .3); stroke-width: 1.5; }

.chip-rack {
  position: absolute;
  left: 620px; top: 60px;
  width: 360px; height: 54px;
  padding: 6px 8px;
  display: flex; gap: 4px;
  border-radius: 4px 4px 10px 10px;
  background: #17151a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 -2px 6px rgba(0, 0, 0, .6);
  z-index: 2;
}
.rack-col {
  flex: 1;
  border-radius: 5px;
  background: repeating-linear-gradient(180deg, var(--body) 0 3px, color-mix(in srgb, var(--body) 55%, #000) 3px 4px);
  box-shadow: inset 4px 0 6px rgba(255, 255, 255, .16), inset -4px 0 8px rgba(0, 0, 0, .45);
  position: relative;
}
.rack-col::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(180deg, transparent 0 9px, var(--edge) 9px 10px);
  opacity: .5;
}

.shoe {
  position: absolute;
  left: 1366px; top: 94px;
  width: 150px; height: 110px;
  z-index: 3;
}
.shoe-body {
  position: absolute; left: 14px; top: 6px;
  width: 124px; height: 70px;
  border-radius: 8px 8px 8px 30px;
  background: linear-gradient(160deg, #38352f, #151310 60%);
  box-shadow: 0 10px 20px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .12);
  transform: perspective(300px) rotateX(18deg);
}
.shoe-card {
  position: absolute; left: -10px; top: 12px;
  width: 54px; height: 50px;
  border-radius: 4px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .14) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .14) 0 1px, transparent 1px 6px),
    var(--back);
  border: 3px solid #f6f1e6;
  transform: skewX(-12deg);
  box-shadow: -2px 3px 6px rgba(0, 0, 0, .4);
}
.shoe.shuffling .shoe-body { animation: shake .18s 7 linear; }
@keyframes shake {
  0%, 100% { transform: perspective(300px) rotateX(18deg) translateX(0); }
  25% { transform: perspective(300px) rotateX(18deg) translateX(-4px) rotate(-1deg); }
  75% { transform: perspective(300px) rotateX(18deg) translateX(4px) rotate(1deg); }
}
.shoe-meter {
  position: absolute; left: 20px; top: 86px;
  width: 112px; height: 4px;
  background: rgba(0, 0, 0, .4);
  overflow: hidden;
}
.shoe-meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brass); transition: width .4s; }
.shoe-meter b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #e45b4f; }
.shoe-info {
  position: absolute; left: 0; top: 94px; width: 152px;
  white-space: nowrap;
  font: 600 11px/1.2 var(--cond);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .42);
  text-align: center;
}
.count-display {
  position: absolute;
  left: 1372px; top: 218px;
  width: 140px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .26);
  font: 600 12.5px/1.2 var(--cond);
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .7);
  text-align: center;
  display: none;
}
.count-display.show { display: block; }
.count-display b { color: var(--brass-hi); }

.discard {
  position: absolute;
  left: 80px; top: 96px;
  width: 92px; height: 106px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, .13);
  background: rgba(0, 0, 0, .12);
  transform: rotate(-8deg);
  z-index: 3;
}
.discard-stack {
  position: absolute;
  left: 10px; right: 10px; bottom: 12px;
  height: 0;
  border-radius: 3px;
  background: repeating-linear-gradient(0deg, #d6d0c3 0 1px, #faf7f0 1px 3px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transition: height .4s;
}
.discard-stack::after {
  content: '';
  position: absolute; left: 0; right: 0; top: -1px; height: 6px;
  border-radius: 3px 3px 0 0;
  background: var(--back);
}
.discard-stack.empty::after { display: none; }

/* ---------------------------------------------------------------- Hands */

.hand.active .card-face.front { box-shadow: 0 0 0 .13em var(--brass-hi), 0 .3em .9em rgba(0, 0, 0, .45); }
.hand.lost .cards { filter: brightness(.7) saturate(.7); transition: filter .4s; }

.hand-head {
  position: absolute;
  bottom: 100%; left: 50%;
  transform: translate(-50%, -7px);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  white-space: nowrap;
  pointer-events: none;
}
.pill {
  font: 600 19px/1 var(--cond);
  letter-spacing: .02em;
  padding: 5px 9px 4px;
  border-radius: 3px;
  background: rgba(12, 10, 8, .78);
  color: #fff;
  transition: background .2s, color .2s;
}
.pill:empty { display: none; }
.pill.bet { font-size: 14.5px; padding: 3px 7px 2px; color: var(--brass-hi); }
.pill.bust { background: #9f3128; }
.pill.bj { background: var(--brass); color: #1e1606; }
.pill.t21 { background: #2f7d4c; }
.hand.active .pill.total { background: var(--brass-hi); color: #1e1606; }
.hand.active .hand-head::before {
  content: '';
  position: absolute;
  left: 50%; top: -12px;
  border: 5px solid transparent;
  border-top-color: var(--brass-hi);
  transform: translateX(-50%);
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, -3px); } }

.hand-result {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.5);
  opacity: 0;
  padding: 6px 11px 5px;
  border-radius: 3px;
  font: 700 15px/1.05 var(--cond);
  letter-spacing: .1em;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.2, 1.5, .4, 1), opacity .2s;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
  z-index: 5;
}
.hand-result small { display: block; font-size: 13px; letter-spacing: .03em; margin-top: 2px; font-weight: 600; }
.hand-result.show { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
.hand-result.win { background: #2a7a48; color: #fff; }
.hand-result.bj { background: var(--brass); color: #1e1606; }
.hand-result.push { background: #b9b2a5; color: #1c1915; }
.hand-result.lose { background: #a3342a; color: #fff; }
.hand-result.surrender { background: #6e675d; color: #fff; }

/* ---------------------------------------------------------------- Dealer */

.dealer-area {
  position: absolute;
  left: 0; right: 0; top: 126px;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
  z-index: 4;
}
.dealer-hand { order: 1; }
.dealer-tag {
  order: 2;
  margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  font: 600 12px/1 var(--cond);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .5);
}
.dealer-tag b {
  font: 600 19px/1 var(--cond);
  letter-spacing: .02em;
  padding: 5px 9px 4px;
  border-radius: 3px;
  background: rgba(12, 10, 8, .78);
  color: #fff;
}
.dealer-tag b:empty { display: none; }
.dealer-tag b.bust { background: #9f3128; }
.dealer-tag b.bj { background: var(--brass); color: #1e1606; }
.card.peek { animation: peek .7s ease-in-out; }
@keyframes peek {
  0%, 100% { transform: none; }
  40%, 60% { transform: translateY(-9px) rotate(-3deg); }
}

/* ---------------------------------------------------------------- Seats */

.seat { position: absolute; width: 0; height: 0; z-index: 5; }
.spot {
  position: absolute;
  left: -58px; top: -58px;
  width: 116px; height: 116px;
  border-radius: 50%;
  border: 2px solid rgba(244, 228, 186, .4);
  background: rgba(0, 0, 0, .1);
  transition: border-color .2s, box-shadow .25s;
  -webkit-touch-callout: none;
}
.spot::before {
  content: '';
  position: absolute; inset: 7px;
  border-radius: 50%;
  border: 1px solid rgba(244, 228, 186, .13);
}
.spot .seat-no {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 600 13px/1.25 var(--cond);
  letter-spacing: .28em;
  text-align: center;
  color: rgba(244, 228, 186, .34);
  transition: opacity .2s;
}
.spot.has-bet .seat-no { opacity: 0; }
.spot .ghost {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.86);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.phase-betting .spot { cursor: pointer; }
@media (hover: hover) {
  .phase-betting .spot:hover { border-color: var(--brass-hi); }
  .phase-betting .spot:hover .ghost { opacity: .4; }
  .phase-betting .spot.has-bet:hover .ghost { opacity: 0; }
}
.spot.in-play { border-color: rgba(244, 228, 186, .55); }
.spot.active { border-color: var(--brass-hi); box-shadow: 0 0 0 4px rgba(227, 200, 143, .16); }
.spot.flash { animation: spotFlash .5s; }
@keyframes spotFlash { 50% { box-shadow: 0 0 0 8px rgba(217, 104, 92, .35); border-color: var(--loss); } }

.seat-amount {
  position: absolute;
  left: 0; top: 64px;
  transform: translateX(-50%);
  font: 600 14px/1 var(--cond);
  letter-spacing: .03em;
  color: var(--brass-hi);
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  opacity: 0;
  transition: opacity .2s;
}
.seat-amount.show { opacity: 1; }

.seat .hands {
  position: absolute;
  left: 0; bottom: 76px;
  width: max-content;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 22px;
  transition: transform .3s ease;
}

.stack { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.stack .chip { position: absolute; }
.ins-stack { position: absolute; left: 66px; top: -64px; width: 0; height: 0; }
.ins-stack .tag {
  position: absolute; left: -20px; top: 22px; width: 40px;
  font: 700 10px/1 var(--cond); letter-spacing: .16em;
  text-align: center; color: rgba(244, 224, 166, .8);
}
.ins-stack:empty { display: none; }

.stack .chip, .fly .chip, .ins-stack .chip {
  --d: 50px;
  box-shadow:
    inset 0 0 0 calc(var(--d) * .03) rgba(0, 0, 0, .22),
    0 3px 0 color-mix(in srgb, var(--body) 55%, #000),
    0 4px 0 var(--edge),
    0 5px 0 color-mix(in srgb, var(--body) 50%, #000),
    0 7px 6px rgba(0, 0, 0, .45);
}
.ins-stack .chip { --d: 36px; }
.fly { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 40; pointer-events: none; }

/* ---------------------------------------------------------------- Toast */

.toast {
  position: absolute;
  left: 50%; top: 418px;
  transform: translate(-50%, -50%) translateY(6px);
  padding: 10px 20px 9px;
  border-radius: 4px;
  border-left: 3px solid var(--brass);
  background: rgba(14, 12, 9, .92);
  font: 600 17px/1.2 var(--cond);
  letter-spacing: .03em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%); }
.toast.gold { color: var(--brass-hi); }
.toast.warn { border-left-color: var(--loss); }

.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; }

/* ---------------------------------------------------------------- Action bar */

.actionbar {
  position: absolute;
  left: 24px; right: 24px; top: 868px;
  height: 116px;
  padding: 0 24px;
  display: flex; align-items: center; gap: 22px;
  border-radius: 10px;
  background: #1a1713;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  z-index: 20;
}
.balance-block { width: 236px; flex: none; }
.bal-main label, .bal-sub label {
  display: block;
  font: 600 11.5px/1 var(--cond);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--dim);
}
.bal-main strong {
  display: block;
  margin-top: 5px;
  font: 600 34px/1 var(--cond);
  letter-spacing: .01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bal-sub { display: flex; gap: 22px; margin-top: 9px; }
.bal-sub div { display: flex; align-items: baseline; gap: 8px; }
.bal-sub label { display: inline; }
.bal-sub span { font: 600 16px/1 var(--cond); font-variant-numeric: tabular-nums; color: var(--muted); }
.bal-sub span.pos { color: var(--win); }
.bal-sub span.neg { color: var(--loss); }

/* The bar keeps the same controls in every phase: actions in the middle
   (Deal beside Hit/Stand), chips and bet controls on the right. */
.bar-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.bar-info {
  height: 24px;
  display: flex; align-items: center; gap: 14px;
  min-width: 0;
  font: 600 16px/1 var(--cond);
  letter-spacing: .02em;
}
.bar-info .q { color: var(--ink); white-space: nowrap; }
.bar-info .h { flex: 1; min-width: 0; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-info .h b { color: var(--brass-hi); font-weight: 600; }
.bar-info .prompt { display: flex; gap: 8px; margin-left: auto; flex: none; }
.bar-info .prompt:empty { display: none; }
.bar-info.asking .q { color: var(--brass-hi); }
.bar-info .dots i { animation: blink 1.2s infinite; font-style: normal; }
.bar-info .dots i:nth-child(2) { animation-delay: .2s; }
.bar-info .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
.wait { color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }

.pbtn {
  height: 30px;
  padding: 0 12px;
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  font: 600 14.5px/1 var(--cond);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  touch-action: manipulation;
}
.pbtn.yes { background: var(--brass); border-color: var(--brass); color: #1e1606; }
.pbtn small { font-size: 13px; font-weight: 500; letter-spacing: .01em; text-transform: none; opacity: .8; }
.pbtn kbd { min-width: 0; padding: 2px 4px; border: 0; background: rgba(0, 0, 0, .22); font-size: 10.5px; color: inherit; }
.pbtn.suggested { box-shadow: 0 0 0 2px #1a1713, 0 0 0 4px var(--brass-hi); }
.pbtn:disabled { opacity: .35; }

.acts { display: flex; gap: 8px; }
.act {
  --c: #2c7d4f;
  position: relative;
  flex: 1; min-width: 0;
  height: 72px;
  border-radius: 8px;
  border: 0;
  border-bottom: 4px solid color-mix(in srgb, var(--c) 62%, #000);
  background: var(--c);
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: filter .15s, opacity .2s, transform .1s;
  touch-action: manipulation;
}
@media (hover: hover) { .act:hover:not(:disabled) { filter: brightness(1.1); } }
.act:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.act:disabled { opacity: .22; filter: grayscale(.6); }
.act .lbl { font: 700 19px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; }
.act .sub { font: 500 12.5px/1 var(--cond); opacity: .8; }
.act .sub:empty { display: none; }
.act kbd {
  position: absolute; right: 7px; top: 6px;
  min-width: 0;
  padding: 2px 4px;
  border: 0;
  background: rgba(0, 0, 0, .22);
  color: rgba(255, 255, 255, .75);
  font-size: 10.5px;
}
.act.deal { --c: #b8913f; color: #1e1606; }
.act.deal kbd { background: rgba(0, 0, 0, .14); color: rgba(30, 22, 6, .7); }
.act.hit { --c: #2c7d4f; }
.act.stand { --c: #a3392f; }
.act.double { --c: #a88232; }
.act.split { --c: #335c9c; }
.act.surrender { --c: #5c564d; }
.act.surrender .lbl { font-size: 16px; letter-spacing: .05em; }
.act.suggested { box-shadow: 0 0 0 2px #1a1713, 0 0 0 4px var(--brass-hi); }

/* chips: a sliding window of five */
.bar-bets { flex: none; display: flex; flex-direction: column; gap: 5px; }
.carousel { display: flex; align-items: center; gap: 2px; }
.car-arrow {
  width: 28px; height: 56px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: none;
  color: var(--muted);
  touch-action: manipulation;
}
.car-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.car-arrow:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, .04); }
.car-arrow:disabled { opacity: .2; }
.car-view {
  --cd: 54px; --cg: 8px;
  width: calc(var(--cd) * 5 + var(--cg) * 4 + 10px);
  padding: 9px 5px 4px;
  overflow: hidden;
  touch-action: pan-y;
}
.car-track { display: flex; gap: var(--cg); width: max-content; transition: transform .28s ease; }
.tray-chip {
  position: relative;
  flex: none;
  padding: 0; border: 0; background: none;
  border-radius: 50%;
  transition: transform .15s ease-out, opacity .2s;
  touch-action: manipulation;
}
.tray-chip .chip { --d: var(--cd); }
@media (hover: hover) { .tray-chip:hover:not(:disabled) { transform: translateY(-3px); } }
.tray-chip.selected { transform: translateY(-6px); }
.tray-chip.selected::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--brass-hi);
}
.tray-chip:disabled { opacity: .25; filter: grayscale(.8); }
.bet-ctl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 2px; }
.bet-ctl .btn { height: 28px; padding: 0; font-size: 13px; }

/* ==========================================================================
   Portrait (phones) — 820×1600 stage. Text is sized up because the stage
   renders at roughly half scale on a phone.
   ========================================================================== */

#stage.portrait .topbar { left: 22px; right: 22px; top: 12px; height: 60px; gap: 20px; }
#stage.portrait .brand-mark { font-size: 30px; }
#stage.portrait .brand-name { font-size: 30px; }
#stage.portrait .learn,
#stage.portrait .rules-summary,
#stage.portrait #btnRules,
#stage.portrait #btnStats,
#stage.portrait #btnHelp,
#stage.portrait #btnSound { display: none; }
#stage.portrait .top-actions { margin-left: auto; gap: 26px; }
#stage.portrait .top-actions button { font-size: 24px; }
#stage.portrait #btnMenu { display: grid; place-items: center; width: 52px; height: 52px; color: var(--ink); }
#stage.portrait #btnMenu svg { width: 38px; height: 38px; stroke-width: 1.6; }

#stage.portrait .table {
  left: 14px; top: 84px;
  width: 792px; height: 1112px;
  border-radius: 24px 24px 396px 396px / 24px 24px 396px 396px;
}
#stage.portrait .felt {
  left: 18px; right: 18px; top: 18px; bottom: 18px;
  border-radius: 6px 6px 378px 378px / 6px 6px 378px 378px;
  background: radial-gradient(80% 50% at 50% 30%, var(--felt-hi) 0%, var(--felt) 58%, var(--felt-lo) 100%);
}
#stage.portrait .felt-print .t-main { font-size: 30px; letter-spacing: .08em; }
#stage.portrait .felt-print .t-rule { font-size: 17px; letter-spacing: .16em; }
#stage.portrait .felt-print .t-ins { font-size: 19px; letter-spacing: .24em; }

#stage.portrait .chip-rack { left: 290px; top: 80px; width: 240px; height: 42px; padding: 5px 6px; gap: 3px; }
#stage.portrait .shoe { left: 640px; top: 112px; }
#stage.portrait .shoe-info { font-size: 17px; top: 98px; }
#stage.portrait .count-display { left: 618px; top: 244px; width: 176px; font-size: 18px; }
#stage.portrait .discard { left: 46px; top: 116px; }

#stage.portrait .hand { --base: 100px; }
#stage.portrait .dealer-area { top: 150px; }
#stage.portrait .dealer-tag { font-size: 18px; margin-top: 12px; }
#stage.portrait .dealer-tag b,
#stage.portrait .pill { font-size: 31px; padding: 6px 12px 5px; }
#stage.portrait .pill.bet { font-size: 22px; padding: 4px 8px 3px; }
#stage.portrait .hand-result { font-size: 22px; padding: 8px 13px 7px; }
#stage.portrait .hand-result small { font-size: 19px; }
#stage.portrait .hand.active .hand-head::before { top: -17px; border-width: 7px; }
#stage.portrait .seat .hands { gap: 14px; }
#stage.portrait .spot .seat-no { font-size: 19px; letter-spacing: .2em; }
#stage.portrait .seat-amount { font-size: 22px; top: 66px; }
#stage.portrait .ins-stack .tag { font-size: 14px; top: 24px; }

#stage.portrait .toast { top: 540px; font-size: 27px; padding: 14px 24px 13px; border-left-width: 5px; }

#stage.portrait .actionbar {
  left: 14px; right: 14px; top: 1212px;
  height: 376px;
  padding: 20px 22px;
  display: flex; flex-direction: column; align-items: stretch; justify-content: space-between;
  gap: 12px;
}
#stage.portrait .balance-block { width: auto; flex: none; display: flex; align-items: flex-end; justify-content: space-between; }
#stage.portrait .bal-main label, #stage.portrait .bal-sub label { font-size: 17px; }
#stage.portrait .bal-main strong { font-size: 48px; margin-top: 6px; }
#stage.portrait .bal-sub { flex-direction: column; align-items: flex-end; gap: 8px; margin: 0; }
#stage.portrait .bal-sub span { font-size: 24px; }
#stage.portrait .bar-main { gap: 10px; }
#stage.portrait .bar-info { height: 40px; font-size: 25px; gap: 16px; }
#stage.portrait .pbtn { height: 52px; padding: 0 16px; font-size: 22px; border-radius: 8px; }
#stage.portrait .pbtn small { font-size: 19px; }
#stage.portrait .pbtn kbd { display: none; }
#stage.portrait .acts { gap: 8px; }
#stage.portrait .act { height: 100px; border-radius: 10px; border-bottom-width: 6px; gap: 6px; }
#stage.portrait .act .lbl { font-size: 24px; letter-spacing: .06em; }
#stage.portrait .act.surrender .lbl { font-size: 17px; letter-spacing: .01em; }
#stage.portrait .act .sub { font-size: 17px; }
#stage.portrait .act kbd { display: none; }
#stage.portrait .act.suggested { box-shadow: 0 0 0 3px #1a1713, 0 0 0 7px var(--brass-hi); }
#stage.portrait .bar-bets { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
#stage.portrait .car-view { --cd: 62px; --cg: 8px; padding: 10px 5px 4px; }
#stage.portrait .car-arrow { width: 42px; height: 66px; }
#stage.portrait .car-arrow svg { width: 34px; height: 34px; }
#stage.portrait .bet-ctl { flex: 1; grid-template-columns: repeat(2, 1fr); gap: 8px; }
#stage.portrait .bet-ctl .btn { height: 36px; font-size: 18px; }

/* Landscape on a small screen (phone turned sideways): enlarge the text. */
#stage.boost .pill, #stage.boost .dealer-tag b { font-size: 26px; }
#stage.boost .pill.bet { font-size: 19px; }
#stage.boost .hand-result { font-size: 19px; }
#stage.boost .hand-result small { font-size: 16px; }
#stage.boost .seat-amount { font-size: 19px; }
#stage.boost .toast { font-size: 24px; }
#stage.boost .bar-info { font-size: 20px; height: 28px; }
#stage.boost .pbtn { height: 34px; font-size: 17px; }
#stage.boost .act .lbl { font-size: 23px; }
#stage.boost .act.surrender .lbl { font-size: 18px; }
#stage.boost .act { height: 74px; }
#stage.boost .act .sub { font-size: 14px; }
#stage.boost .bar-bets { gap: 3px; }
#stage.boost .bet-ctl .btn { height: 32px; font-size: 16px; }
#stage.boost .learn, #stage.boost .rules-summary { display: none; }
#stage.boost .top-actions { margin-left: auto; }
#stage.boost .top-actions button { font-size: 19px; }

/* ==========================================================================
   Overlays (outside the stage, real pixels)
   ========================================================================== */

.menu {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  width: min(300px, calc(100vw - 16px));
  padding: 8px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
  z-index: 90;
  display: none;
  user-select: none;
}
.menu.open { display: block; animation: rise .18s ease-out; }
.menu button, .menu a {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 13px 14px;
  border: 0; border-radius: 6px;
  background: none;
  font: 600 17px/1 var(--cond);
  letter-spacing: .04em;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
}
.menu button:active, .menu a:active, .menu button:hover, .menu a:hover { background: rgba(255, 255, 255, .05); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu small { font: 500 12px/1 var(--cond); color: var(--dim); letter-spacing: .14em; text-transform: uppercase; padding: 10px 14px 4px; display: block; }
.menu .val { color: var(--muted); font-weight: 500; }
.menu-scrim { position: fixed; inset: 0; z-index: 89; display: none; }
.menu-scrim.open { display: block; }

.modal {
  position: fixed; inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(6, 5, 4, .66);
  z-index: 100;
}
.modal.open { display: grid; animation: fadeIn .18s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px 30px 24px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6);
  animation: rise .22s ease-out;
  user-select: text;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-card h2 { margin: 0 0 6px; font: 600 25px/1.2 var(--display); letter-spacing: .04em; }
.modal-card h3 { margin: 24px 0 10px; font: 600 13px/1 var(--cond); letter-spacing: .2em; text-transform: uppercase; color: var(--brass); }
.muted { color: var(--muted); margin: 0; font-size: 15px; line-height: 1.5; }
.modal-x {
  position: absolute; right: 14px; top: 14px;
  width: 34px; height: 34px;
  border-radius: 6px;
  border: 0;
  background: none;
  font-size: 26px; line-height: 1;
  color: var(--muted);
}
.modal-x:hover { color: var(--ink); background: rgba(255, 255, 255, .05); }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }

.buy-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0 14px; }
.buy-presets button {
  height: 60px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font: 600 18px/1 var(--cond);
  letter-spacing: .02em;
  transition: border-color .15s, background .15s;
}
.buy-presets button .chip { --d: 32px; }
.buy-presets button:hover { background: #221e19; }
.buy-presets button.active { border-color: var(--brass); background: rgba(201, 164, 92, .1); }
.buy-input {
  display: flex; align-items: center;
  height: 56px;
  padding: 0 16px;
  border-radius: 6px;
  background: #12100d;
  border: 1px solid var(--line-2);
}
.buy-input:focus-within { border-color: var(--brass); }
.buy-input span { font: 600 26px var(--cond); color: var(--brass); margin-right: 6px; }
.buy-input input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  color: var(--ink);
  font: 600 28px var(--cond);
  font-variant-numeric: tabular-nums;
}
#buySlider { width: 100%; margin: 16px 0 6px; accent-color: var(--brass); }
.buy-note { font-size: 14px; color: var(--muted); min-height: 18px; }
.buy-note.err { color: var(--loss); }

.rules-card { width: min(940px, 100%); }
.rules-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-right: 40px; }
.edge-meter { text-align: right; }
.edge-meter label { display: block; font: 600 12px/1 var(--cond); letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }
.edge-meter strong { display: block; font: 600 32px/1.1 var(--cond); color: var(--brass-hi); margin: 3px 0 1px; font-variant-numeric: tabular-nums; }
.edge-meter strong.player { color: var(--win); }
.edge-meter small { font-size: 12.5px; color: var(--dim); }
.edge-meter a { color: var(--muted); }
#rulesNote.warn { color: var(--brass-hi); }

.tabs { display: flex; gap: 22px; margin: 18px 0 18px; border-bottom: 1px solid var(--line); }
.tab {
  border: 0; background: none;
  padding: 10px 0;
  font: 600 15px/1 var(--cond);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--ink); border-bottom-color: var(--brass); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 22px; }
.preset {
  text-align: left;
  padding: 10px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  transition: border-color .15s;
}
.preset:hover { border-color: var(--line-2); }
.preset.active { border-color: var(--brass); }
.preset b { display: block; font: 600 15px/1.1 var(--cond); letter-spacing: .02em; }
.preset span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.35; }

.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 36px; }
.rule-group { padding: 4px 0 10px; border-top: 1px solid var(--line-2); }
.rule-group h4 {
  margin: 12px 0 4px;
  font: 600 12.5px/1 var(--cond);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brass);
}
.rule-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  transition: opacity .2s;
}
.rule-row.disabled { opacity: .35; pointer-events: none; }
.rule-row .rl { font-size: 15px; font-weight: 500; }
.rule-row .rl small { display: block; font-size: 12.5px; color: var(--dim); margin-top: 2px; line-height: 1.35; }
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap input { width: 130px; accent-color: var(--brass); }
.range-wrap output { width: 40px; text-align: right; font: 600 15px var(--cond); }
.swatches { display: flex; gap: 6px; }
.swatches button {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--sw);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .3);
}
.swatches button.active { border-color: var(--brass-hi); }

.stats-card { width: min(620px, 100%); }
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.stat { padding: 13px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat label { display: block; font: 600 11.5px/1 var(--cond); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.stat b { display: block; margin-top: 7px; font: 600 22px/1 var(--cond); font-variant-numeric: tabular-nums; }
.stat b.pos { color: var(--win); }
.stat b.neg { color: var(--loss); }

.help-card { width: min(600px, 100%); }
.help-card p a, .help-card li a { color: var(--brass-hi); }
.help-steps { margin: 16px 0 0; padding-left: 20px; line-height: 1.6; font-size: 15.5px; color: #d9d1c3; }
.help-steps li { margin-bottom: 6px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.keys div { display: flex; align-items: center; gap: 8px; font-size: 15px; color: #d9d1c3; }
.keys span { margin-left: 4px; }

@media (max-width: 720px) {
  .modal { padding: 0; place-items: end stretch; }
  .modal-card {
    width: 100%;
    max-height: 92dvh;
    border-radius: 14px 14px 0 0;
    padding: 24px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .rules-grid { grid-template-columns: 1fr; }
  .presets { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .rules-head { flex-direction: column; gap: 10px; }
  .edge-meter { text-align: left; }
  .rule-row { flex-wrap: wrap; }
  .rule-row .rl { flex: 1 1 160px; }
  .keys { grid-template-columns: 1fr; }
  .buy-presets button { height: 54px; font-size: 16px; }
}
