/* ==========================================================================
   Baccarat 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; }
.felt-print .box { fill: rgba(0, 0, 0, .07); stroke: rgba(244, 224, 166, .2); stroke-width: 1.5; }
.felt-print .box.p { stroke: rgba(170, 198, 255, .3); }
.felt-print .box.b { stroke: rgba(255, 176, 166, .3); }

.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;
}

.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; }

/* ---------------------------------------------------------------- Scoreboard */

/* The score card (drawn by roads.js, styled in common.css) in a dark frame.
   Column counts come from the layout in app.js. */
.roads {
  position: absolute;
  left: 800px; top: 124px;
  transform: translateX(-50%);
  padding: 7px 9px 9px;
  border-radius: 6px;
  background: rgba(8, 9, 8, .66);
  border: 1px solid rgba(201, 164, 92, .45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .05);
  z-index: 3;
  transition: opacity .25s;
}
.roads.off { opacity: 0; pointer-events: none; }
.roads-head {
  display: flex; align-items: baseline; gap: 14px;
  margin: 0 1px 6px;
  font: 600 11px/1 var(--cond);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .46);
  white-space: nowrap;
}
.roads-head b { margin-left: 4px; font-size: 13.5px; letter-spacing: .02em; color: #fff; font-variant-numeric: tabular-nums; }
.rc.p b { color: #9dbcff; }
.rc.b b { color: #ff998f; }
.rc.t b { color: #8fe0a8; }
.rc.pp b { margin: 0 2px 0 4px; color: rgba(255, 255, 255, .8); }
.rc.n { margin-left: auto; }
.roads-body { display: flex; gap: 8px; }

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

.side-area {
  position: absolute;
  width: 400px;
  margin-left: -200px;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
  z-index: 4;
}
/* The two cards sit almost side by side; a third card is dealt sideways,
   clear of the second (app.js widens the hand to match). */
.coup-hand { --base: 92px; --fan: calc(var(--base) * .64 * var(--s)); }
.coup-hand .card.sideways { translate: calc(var(--cw) * .6) calc(var(--cw) * .04); }
.side-area .cards { transition: filter .4s; }
.side-area.lost .cards { filter: brightness(.68) saturate(.7); }
.side-area.win .card-face.front { box-shadow: 0 0 0 .13em var(--brass-hi), 0 .3em .9em rgba(0, 0, 0, .45); }
.side-tag {
  margin-top: 12px;
  display: flex; align-items: center; gap: 9px;
  font: 600 13px/1 var(--cond);
  letter-spacing: .3em;
  text-transform: uppercase;
}
.side-area.player .side-tag span { color: rgba(184, 206, 255, .75); }
.side-area.banker .side-tag span { color: rgba(255, 190, 180, .75); }
.side-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;
  transition: background .2s, color .2s;
}
.side-tag b:empty { display: none; }
.side-tag b.nat { background: var(--brass); color: #1e1606; }
.side-area.win .side-tag b { background: var(--brass-hi); color: #1e1606; }

.card.squeeze .card-inner { animation: squeeze .9s ease-in-out; transform-origin: 50% 100%; }
@keyframes squeeze {
  0%, 100% { transform: rotateY(180deg); }
  40%, 70% { transform: rotateY(180deg) rotateX(-34deg); }
}

.coup-result {
  position: absolute;
  left: 800px; top: 360px;
  transform: translate(-50%, -50%) scale(.6);
  opacity: 0;
  padding: 10px 20px 9px;
  border-radius: 4px;
  font: 700 22px/1 var(--cond);
  letter-spacing: .14em;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
  transition: transform .3s cubic-bezier(.2, 1.5, .4, 1), opacity .2s;
  z-index: 6;
}
.coup-result small { display: block; margin-top: 5px; font-size: 15px; letter-spacing: .06em; font-weight: 600; opacity: .88; }
.coup-result.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.coup-result.player { background: #2d5cab; color: #fff; }
.coup-result.banker { background: #a3342a; color: #fff; }
.coup-result.tie { background: #2a7a48; color: #fff; }

.burn { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 41; pointer-events: none; }
.burn .hand { position: absolute; left: calc(var(--cw) / -2); top: calc(var(--cw) * -.7); }

/* ---------------------------------------------------------------- Betting areas */

.bet-area { position: absolute; width: 0; height: 0; z-index: 5; }
.bet-area.off { display: none; }
.bet-area.player { --d: 156px; --ring: rgba(160, 192, 255, .55); --ink-l: rgba(190, 210, 255, .8); }
.bet-area.banker { --d: 156px; --ring: rgba(255, 168, 156, .55); --ink-l: rgba(255, 196, 186, .8); }
.bet-area.tie { --d: 124px; --ring: rgba(244, 228, 186, .5); --ink-l: rgba(244, 228, 186, .62); }
.bet-area.ppair, .bet-area.bpair { --d: 102px; --ring: rgba(244, 228, 186, .36); --ink-l: rgba(244, 228, 186, .5); }
.spot {
  position: absolute;
  left: calc(var(--d) / -2); top: calc(var(--d) / -2);
  width: var(--d); height: var(--d);
  border-radius: 50%;
  border: 2px solid var(--ring);
  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-label {
  position: absolute; inset: 0;
  display: grid; place-content: center;
  text-align: center;
  font: 600 16px/1.15 var(--display);
  letter-spacing: .12em;
  color: var(--ink-l);
  transition: opacity .2s;
}
.spot-label small {
  display: block;
  margin-top: 5px;
  font: 600 12.5px/1 var(--cond);
  letter-spacing: .16em;
  color: rgba(255, 255, 255, .38);
}
.ppair .spot-label, .bpair .spot-label { font-size: 12px; letter-spacing: .1em; }
.ppair .spot-label small, .bpair .spot-label small { font-size: 11px; margin-top: 4px; }
.spot.has-bet .spot-label { 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, .62); }
.spot.won { border-color: var(--brass-hi); box-shadow: 0 0 0 4px rgba(227, 200, 143, .18); }
.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: calc(var(--d) / 2 + 8px);
  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; }

.hand-result {
  position: absolute;
  left: 0; top: 0;
  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.big { background: var(--brass); color: #1e1606; }
.hand-result.push { background: #b9b2a5; color: #1c1915; }
.hand-result.lose { background: #a3342a; color: #fff; }

.stack { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.stack .chip { position: absolute; }
.stack .chip, .fly .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);
}
.fly { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 40; pointer-events: none; }

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

.toast {
  position: absolute;
  left: 800px; top: 472px;
  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: Deal and a button per
   betting area in the middle, 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 .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; }

.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.clear { --c: #5c564d; }
/* the one-card-at-a-time switch sits at the end of the action buttons */
.step-toggle {
  flex: none;
  width: 118px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel-2);
  font: 600 12.5px/1.15 var(--cond);
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
  transition: color .15s, border-color .15s;
  touch-action: manipulation;
}
.step-toggle:hover { border-color: rgba(240, 226, 200, .28); }
.step-toggle[aria-pressed="true"] { color: var(--ink); }
.step-toggle .switch { display: block; }
.act.waiting { 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(3, 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: 1002px;
  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: 32px; letter-spacing: .08em; }
#stage.portrait .felt-print .t-rule { font-size: 17px; letter-spacing: .14em; }
#stage.portrait .felt-print .t-ins { font-size: 19px; letter-spacing: .22em; }

#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 .discard { left: 46px; top: 116px; }

#stage.portrait .roads { left: 410px; top: 134px; padding: 8px 10px 10px; }
#stage.portrait .roads-head { font-size: 15px; gap: 16px; margin-bottom: 8px; }
#stage.portrait .roads-head b { font-size: 19px; }
#stage.portrait .bead, #stage.portrait .bigroad { --c: 24px; }

#stage.portrait .coup-hand { --base: 100px; }
#stage.portrait .side-tag { font-size: 18px; margin-top: 14px; }
#stage.portrait .side-tag b { font-size: 31px; padding: 6px 12px 5px; }
#stage.portrait .coup-result { font-size: 31px; padding: 13px 24px 12px; }
#stage.portrait .coup-result small { font-size: 21px; }
#stage.portrait .spot-label { font-size: 21px; }
#stage.portrait .spot-label small { font-size: 17px; }
#stage.portrait .ppair .spot-label, #stage.portrait .bpair .spot-label { font-size: 15px; }
#stage.portrait .ppair .spot-label small, #stage.portrait .bpair .spot-label small { font-size: 14px; }
#stage.portrait .hand-result { font-size: 22px; padding: 8px 13px 7px; }
#stage.portrait .hand-result small { font-size: 19px; }
#stage.portrait .seat-amount { font-size: 22px; }

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

#stage.portrait .actionbar {
  left: 14px; right: 14px; top: 1100px;
  height: 488px;
  padding: 18px 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: 19px; }
#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: 27px; }
#stage.portrait .bar-main { gap: 10px; }
#stage.portrait .bar-info { height: 44px; font-size: 29px; gap: 16px; }
#stage.portrait .acts { gap: 8px; }
#stage.portrait .act { height: 118px; border-radius: 10px; border-bottom-width: 6px; gap: 7px; }
#stage.portrait .act .lbl { font-size: 28px; letter-spacing: .04em; }
#stage.portrait .act.waiting { box-shadow: 0 0 0 3px #1a1713, 0 0 0 7px var(--brass-hi); }
#stage.portrait .act .sub { font-size: 21px; }
#stage.portrait .step-toggle { width: 170px; gap: 12px; font-size: 19px; border-radius: 10px; }
#stage.portrait .step-toggle .switch { width: 64px; height: 36px; border-radius: 18px; }
#stage.portrait .step-toggle .switch::after { width: 28px; height: 28px; left: 3px; top: 3px; }
#stage.portrait .step-toggle .switch.on::after { transform: translateX(28px); }
#stage.portrait .act kbd { display: none; }
#stage.portrait .bar-bets { gap: 12px; }
#stage.portrait .carousel { justify-content: center; gap: 10px; }
#stage.portrait .car-view { --cd: 92px; --cg: 12px; padding: 14px 6px 6px; }
#stage.portrait .tray-chip.selected { transform: translateY(-8px); }
#stage.portrait .tray-chip.selected::after { inset: -5px; border-width: 3px; }
#stage.portrait .car-arrow { width: 64px; height: 96px; }
#stage.portrait .car-arrow svg { width: 44px; height: 44px; }
#stage.portrait .bet-ctl { gap: 10px; padding: 0; }
#stage.portrait .bet-ctl .btn { height: 58px; font-size: 22px; border-radius: 8px; }

/* Landscape on a small screen (phone turned sideways): enlarge the text. */
#stage.boost .side-tag b { font-size: 26px; }
#stage.boost .coup-result { font-size: 28px; }
#stage.boost .coup-result small { 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; }
/* The table gives up some height so the bar can grow. */
#stage.boost .table { height: 744px; }
#stage.boost .actionbar { top: 812px; height: 176px; padding: 12px 22px; }
#stage.boost .balance-block { width: 210px; }
#stage.boost .bal-main label, #stage.boost .bal-sub label { font-size: 14px; }
#stage.boost .bal-main strong { font-size: 40px; }
#stage.boost .bal-sub span { font-size: 19px; }
#stage.boost .bar-info { font-size: 24px; height: 32px; }
#stage.boost .act { height: 108px; }
#stage.boost .act .lbl { font-size: 24px; letter-spacing: .04em; }
#stage.boost .act .sub { font-size: 17px; }
#stage.boost .step-toggle { width: 150px; font-size: 16px; gap: 10px; }
#stage.boost .act kbd { display: none; }
#stage.boost .bar-bets { gap: 6px; }
#stage.boost .car-view { --cd: 76px; --cg: 9px; padding: 12px 5px 4px; }
#stage.boost .car-arrow { width: 36px; height: 80px; }
#stage.boost .car-arrow svg { width: 30px; height: 30px; }
#stage.boost .bet-ctl { gap: 8px; }
#stage.boost .bet-ctl .btn { height: 48px; font-size: 19px; }
#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); }
#edgeOthers { display: block; margin-bottom: 3px; font-size: 13.5px; color: var(--muted); }
.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(7, 1fr); gap: 8px; margin-bottom: 22px; }
@media (max-width: 980px) { .presets { grid-template-columns: repeat(4, 1fr); } }
.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); }
.stat b small { margin-left: 3px; font-size: 14px; font-weight: 500; color: var(--dim); }

.help-card { width: min(600px, 100%); }
.help-card p a, .help-card li a { color: var(--brass-hi); }
.help-card .fine { margin-top: 18px; font-size: 13px; color: var(--dim); }
.help-card .fine a { color: var(--muted); }
.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); }
  .preset:last-child:nth-child(odd) { grid-column: span 2; }
  .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; }
}
