/* ThePit · Copyright (C) 2026 abel0x
   SPDX-License-Identifier: AGPL-3.0-or-later
   Free software with ABSOLUTELY NO WARRANTY; see LICENSE for the terms. */

/* =========================================================
   Table 9: offline Punto Banco
   The felt, the two hands, the betting spots and the scoreboards.
   The frame, the cards and the chips come from shared/css.
   ========================================================= */
:root {
  --red: #b7151e;
  --print: rgba(240, 222, 168, .78);
  --print-soft: rgba(240, 222, 168, .3);
  /* The traditional colours of the two sides and the tie. */
  --player: #6f9cf0;
  --player-ink: #b9d0ff;
  --banker: #e0545a;
  --banker-ink: #ffc0b8;
  --tie: #2fae6c;
  --tie-ink: #a9ecc6;
  --rail: clamp(8px, 1.3vh, 13px);
}

body[data-theme="bordeaux"] {
  --red: #c3202a;
  --banker: #f06a6f;
}

/* ----------------------- Top bar on phones ----------------------- */
/* The language stays one tap away in the settings, and the way back to the
   lobby stands in for the table's mark. */
@media (max-width: 600px) {
  .topbar { gap: 8px; padding-inline: 10px; }
  .subtitle,
  .topbar .lang-switch,
  .brand-mark { display: none; }
  .topbar-actions { gap: 6px; }
  .brand { gap: 8px; }
  .brand-text h1 { font-size: 14px; letter-spacing: 2.2px; gap: 6px; }
  .brand-number { min-width: 28px; padding: 2px 5px; }
  .balance-pill { min-width: 0; padding: 4px 10px; }
  .balance-value { font-size: 17px; }
  .icon-btn { width: 36px; height: 36px; }
  .toast { top: 64px; }
}

/* ----------------------- The table ----------------------- */
.table-wrap {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.3vh, 14px);
  padding: clamp(6px, 1.4vh, 20px) clamp(8px, 2vw, 26px);
  padding-bottom: max(clamp(6px, 1.4vh, 16px), env(safe-area-inset-bottom));
  overflow: hidden;
}

.table {
  position: relative;
  width: min(1180px, 100%);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* One felt with a walnut rail, as at the other tables of the pit. */
.table-felt {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  /* The width of a card; everything on the felt is sized around it. */
  --w: clamp(44px, min(7vw, 12.5vh), 100px);
  display: grid;
  /* The hands always have room for a whole card; the scoreboard gives way. */
  grid-template-rows: auto minmax(calc(var(--w) * 1.42 + 2.6em), 1fr) auto minmax(0, auto);
  gap: clamp(6px, 1.4vh, 16px);
  padding: clamp(10px, 1.8vh, 22px) clamp(10px, 2vw, 30px);
  border: var(--rail) solid transparent;
  border-radius: clamp(22px, 4vh, 44px);
  background:
    radial-gradient(ellipse 70% 60% at 30% -10%, rgba(255, 247, 218, .1), transparent 66%) padding-box,
    repeating-linear-gradient(4deg, rgba(255,255,255,.016) 0 1px, transparent 1px 4px) padding-box,
    repeating-linear-gradient(94deg, rgba(0,0,0,.024) 0 1px, transparent 1px 5px) padding-box,
    radial-gradient(130% 110% at 50% 10%, var(--felt-highlight) 0%, var(--felt-1) 26%, var(--felt-2) 64%, var(--felt-edge) 100%) padding-box,
    linear-gradient(142deg, rgba(255,232,164,.3), transparent 24%, rgba(0,0,0,.42) 72%, rgba(255,214,117,.2)) border-box,
    repeating-linear-gradient(102deg, #25160b 0 10px, #52371a 10px 18px, #30200f 18px 29px, #694821 29px 34px) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(241, 211, 130, .18),
    inset 0 0 110px rgba(0, 0, 0, .55),
    inset 0 9px 34px rgba(255, 255, 255, .05),
    0 0 0 1px #0b0704,
    0 0 0 4px rgba(105, 72, 31, .58),
    0 30px 60px rgba(0, 0, 0, .6);
}
.table-rim {
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  border: 2px solid rgba(225, 190, 99, .5);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.5), 0 1px 0 rgba(255,244,205,.16);
  z-index: 0;
}

/* ----------------------- Shoe, banner and plaque ----------------------- */
.felt-head {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

/* The dealing shoe: a dark box with the back of the next card in its mouth. */
.shoe {
  justify-self: start;
  position: relative;
  width: clamp(54px, 7vh, 70px);
  height: clamp(40px, 5.2vh, 52px);
  border-radius: 8px 8px 14px 6px;
  background: linear-gradient(160deg, #2b2f33, #0d0f11 70%);
  border: 1px solid rgba(217, 182, 95, .45);
  box-shadow: 0 8px 16px rgba(0,0,0,.45), inset 0 1px rgba(255,255,255,.08);
  transform: rotate(-6deg);
}
.shoe-mouth {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 42%;
  height: 62%;
  border-radius: 3px;
  background:
    linear-gradient(45deg, var(--card-pattern-light) 25%, transparent 25% 75%, var(--card-pattern-light) 75%) 0 0 / 6px 6px,
    linear-gradient(145deg, var(--card-back-top), var(--shoe-card-back) 58%, var(--card-back-bottom));
  box-shadow: inset 0 0 0 1.5px #f4efe3, inset 0 0 0 2.5px #9d7a35;
}
.shoe-count {
  position: absolute;
  left: 6px;
  bottom: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  color: rgba(244, 226, 166, .85);
  font-variant-numeric: tabular-nums;
}
.shoe.shuffling { animation: shoeShuffle .7s ease; }
@keyframes shoeShuffle {
  30% { transform: rotate(-6deg) translateY(-4px); }
  60% { transform: rotate(-3deg) translateY(1px); }
}

.banner {
  min-width: 0;
  max-width: min(460px, 52vw);
  pointer-events: none;
  padding: 7px 18px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(217, 182, 95, .35);
  font-weight: 600;
  letter-spacing: 1px;
  font-size: clamp(10.5px, 1.6vh, 14px);
  text-transform: uppercase;
  text-align: center;
  color: var(--gold-bright);
  line-height: 1.3;
  text-wrap: balance;
  transition: background .25s, border-color .25s, color .25s;
}
.banner small {
  display: block;
  margin-top: 1px;
  font-size: .8em;
  letter-spacing: .9px;
  opacity: .78;
}
.banner small:empty { display: none; }
.banner.flash-lose { background: rgba(0, 0, 0, .5); border-color: rgba(226, 104, 95, .55); color: #ffd9d6; }

.table-specs {
  justify-self: end;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(205,169,82,.46);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(18,24,20,.78), rgba(5,10,8,.78));
  box-shadow: 0 5px 12px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.05);
}
.table-spec { min-width: 50px; padding: 5px 10px 6px; text-align: left; }
.table-spec small {
  display: block;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: rgba(232, 202, 125, .62);
}
.table-spec strong {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--cream);
}

/* ----------------------- The two hands ----------------------- */
.bays {
  position: relative;
  z-index: 2;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 2vw, 28px);
}
/* A gold line between the hands, printed on the cloth. */
.bays::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--print-soft) 20%, var(--print-soft) 80%, transparent);
}
.bay {
  --side: var(--player);
  --side-ink: var(--player-ink);
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  gap: clamp(4px, 1vh, 10px);
}
.bay-banker { --side: var(--banker); --side-ink: var(--banker-ink); }
.bay-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(13px, 2vh, 18px);
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--side-ink);
  text-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.bay-total {
  min-width: 1.9em;
  height: 1.9em;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.25), transparent 50%), var(--side);
  border: 1px solid rgba(255, 255, 255, .35);
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
  color: #fff;
  font-family: var(--font-display);
  font-size: .95em;
  letter-spacing: 0;
  transform: scale(1);
  transition: transform .2s ease;
}
.bay-total:empty { visibility: hidden; }
.bay-total.bump { animation: totalBump .32s ease; }
@keyframes totalBump { 50% { transform: scale(1.22); } }
.bay.winner .bay-head { color: #fff; }
.bay.winner .bay-total { box-shadow: 0 0 0 2px var(--gold-bright), 0 0 16px rgba(244, 226, 166, .55); }

.bay-cards {
  min-height: calc(var(--w) * 1.42);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--w) * .12);
}
/* The third card is laid sideways across the felt, as the croupier does. */
.bay-cards .card.third {
  margin-inline: calc(var(--w) * .22);
  transform: translateY(var(--card-lift)) rotate(calc(90deg + var(--card-turn)));
  transform-origin: center center;
}
.bay-cards .card.deal-ready { animation: dealIn .36s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes dealIn {
  from { opacity: 0; translate: -70px -60px; }
  to { opacity: 1; translate: 0 0; }
}
.bay-cards .card.collecting { animation: collectCard .5s cubic-bezier(.4, 0, .7, .4) forwards; }
@keyframes collectCard {
  to { opacity: 0; translate: 110px -70px; scale: .8; }
}

/* ----------------------- Betting spots ----------------------- */
.spots {
  position: relative;
  z-index: 2;
  display: grid;
  /* Dragon, pair, Player, Tie, Banker, pair, dragon. */
  grid-template-columns: .72fr .8fr 1.35fr 1fr 1.35fr .8fr .72fr;
  gap: clamp(6px, 1vw, 12px);
}
.spot.spot-dragon { border-style: dashed; }
.spot-dragon .spot-name { font-size: clamp(9px, 1.5vh, 14px); }
.spot {
  --spot-ink: var(--print);
  position: relative;
  min-width: 0;
  min-height: clamp(72px, 13vh, 118px);
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 2px;
  /* The lower part of a spot is the chips' lane, clear of the print. */
  padding: clamp(7px, 1.2vh, 12px) 6px clamp(34px, 5.6vh, 52px);
  border: 1.6px solid var(--print);
  border-radius: 14px;
  background: rgba(0, 0, 0, .1);
  color: var(--spot-ink);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.spot-main { border-width: 2.2px; }
.spot-player { --spot-ink: var(--player-ink); }
.spot-banker { --spot-ink: var(--banker-ink); }
.spot-tie { --spot-ink: var(--tie-ink); }
.spot:not(:disabled):hover { background: rgba(255, 238, 190, .1); }
.spot:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.spot-name {
  font-size: clamp(10px, 1.8vh, 17px);
  font-weight: 700;
  letter-spacing: clamp(1px, .3vw, 3px);
  text-transform: uppercase;
  line-height: 1.1;
  text-align: center;
}
.spot-main .spot-name { font-size: clamp(13px, 2.4vh, 22px); }
.spot-pay {
  font-size: clamp(8px, 1.2vh, 11px);
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--print);
  opacity: .8;
  text-align: center;
}
/* Where the chips sit; the stacks come from shared/js/chips.js. */
.spot-stack {
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 2.8vh, 26px);
  width: 0;
  height: 0;
}
.spot-stack .bet-chip { --chip: clamp(30px, 4.6vh, 44px); left: 0; top: 0; }
.spot-stack .bet-chip.payout { left: calc(var(--chip) * 1.05); }
.spot.won { border-color: var(--gold-bright); box-shadow: 0 0 0 1px rgba(244, 226, 166, .5), 0 0 22px rgba(244, 226, 166, .25); }
.spot:disabled { cursor: default; }
body:not([data-phase="betting"]) .spot { cursor: default; }

/* ----------------------- Scoreboards ----------------------- */
.roads {
  --bead: clamp(13px, 2.1vh, 19px);
  min-height: 0;
  overflow: hidden;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: start;
  gap: 4px 12px;
  padding: 7px 10px;
  border: 1px solid rgba(217, 182, 95, .3);
  border-radius: 8px;
  background: rgba(0, 0, 0, .3);
}
/* Each road is printed as a grid of cells, six rows deep, like the
   scoreboards beside a real baccarat table. */
.road {
  --cell: calc(var(--bead) + 2px);
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(6, var(--bead));
  grid-auto-columns: var(--bead);
  gap: 2px;
  overflow: hidden;
  height: calc(var(--cell) * 6);
  background-image:
    linear-gradient(to right, rgba(240, 222, 168, .12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(240, 222, 168, .12) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  border: 1px solid rgba(240, 222, 168, .16);
}
.road-bead { width: calc(var(--cell) * 12 + 1px); }
.road-big { justify-content: start; }
.road-counts {
  grid-column: 1 / -1;
  font-size: 10px;
  letter-spacing: .4px;
  color: rgba(244, 239, 226, .6);
}
.bead {
  width: var(--bead);
  height: var(--bead);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: calc(var(--bead) * .58);
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.bead.player { background: var(--player); }
.bead.banker { background: var(--banker); }
.bead.tie { background: var(--tie); }
.bead.pair-player { box-shadow: inset 2px 2px 0 -0.5px #fff; }
.bead.pair-banker { box-shadow: inset -2px -2px 0 -0.5px #fff; }
.ring {
  position: relative;
  width: var(--bead);
  height: var(--bead);
  border-radius: 50%;
  border: 2.5px solid var(--player);
}
.ring.banker { border-color: var(--banker); }
/* A tie is a green slash across the win before it. */
.ring.tied::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--tie);
  transform: rotate(45deg);
}
.ring .tie-count {
  position: absolute;
  right: -3px;
  bottom: -4px;
  font-size: 8px;
  font-weight: 700;
  color: var(--tie-ink);
}

/* ----------------------- Controls ----------------------- */
.controls {
  position: relative;
  z-index: 3;
  width: min(1180px, 100%);
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.2vh, 14px) clamp(8px, 1.6vw, 22px);
}
.chips-tray {
  flex: 0 0 auto;
  display: flex;
  gap: clamp(6px, 1.1vw, 14px);
  justify-content: center;
  padding: clamp(8px, 1.3vh, 13px) clamp(10px, 1.6vw, 18px);
  padding-top: clamp(12px, 1.8vh, 18px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent 36%),
    linear-gradient(180deg, var(--tray-top), var(--tray-bottom));
  border: 1px solid rgba(217,182,95,.25);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.055), inset 0 -8px 16px rgba(0,0,0,.24), 0 12px 25px rgba(0,0,0,.24);
}
.action-row {
  flex: 1 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1.4vw, 18px);
}
.bet-actions { display: flex; gap: clamp(5px, .7vw, 9px); }
.bet-total {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 92px;
  text-align: right;
}
.bet-total small {
  color: rgba(244, 239, 226, .55);
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.bet-total strong {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.3vh, 22px);
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bet-total .last-win { letter-spacing: .6px; text-transform: none; font-size: 10px; }
.bet-total .last-win b { color: rgba(214, 255, 233, .85); font-variant-numeric: tabular-nums; }

/* Deal: a brass plaque beside the tray. */
.deal-btn {
  flex: 0 0 auto;
  min-width: clamp(96px, 13vh, 132px);
  height: clamp(48px, 7.4vh, 64px);
  padding: 0 22px;
  border-radius: 14px;
  border: 1px solid rgba(80, 56, 12, .9);
  background:
    radial-gradient(120% 90% at 40% 20%, rgba(255,255,255,.45), transparent 45%),
    linear-gradient(180deg, #f3d985, #c9a24b 62%, #8c6a1c);
  box-shadow:
    0 0 0 3px rgba(20, 13, 4, .55),
    0 0 0 4px rgba(240, 215, 143, .45),
    0 10px 22px rgba(0,0,0,.45),
    inset 0 -5px 8px rgba(110, 76, 14, .5);
  color: #2a1d05;
  font-family: var(--font-display);
  font-size: clamp(14px, 2.2vh, 19px);
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .14s ease, filter .2s ease;
}
.deal-btn:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.05); }
.deal-btn:not(:disabled):active { transform: translateY(1px) scale(.98); }
.deal-btn:disabled { cursor: not-allowed; filter: grayscale(.55) brightness(.62); }
.deal-btn.ready { animation: dealReady 2.4s ease-in-out infinite; }
@keyframes dealReady {
  0%, 100% { box-shadow: 0 0 0 3px rgba(20,13,4,.55), 0 0 0 4px rgba(240,215,143,.45), 0 10px 22px rgba(0,0,0,.45), inset 0 -5px 8px rgba(110,76,14,.5); }
  50% { box-shadow: 0 0 0 3px rgba(20,13,4,.55), 0 0 0 4px rgba(244,226,166,.9), 0 0 24px rgba(244,226,166,.4), inset 0 -5px 8px rgba(110,76,14,.5); }
}

/* ----------------------- Dialogs ----------------------- */
/* A miniature of this table on each cloth: two hands of cards. */
.theme-preview::before,
.theme-preview::after {
  content: "";
  position: absolute;
  top: 22%;
  width: 16px;
  height: 23px;
  border-radius: 2px;
  background: #fbf8ef;
  box-shadow: 9px 1px 0 -1px #f1ece0, 9px 1px 0 0 rgba(0,0,0,.25), 0 3px 6px rgba(0,0,0,.45);
}
.theme-preview::before { left: 16%; transform: rotate(-6deg); }
.theme-preview::after { right: 26%; transform: rotate(6deg); }
.theme-option[data-set-theme="midnight"] { --preview-felt-top: #2b6288; --preview-felt-bottom: #0b2b47; }
.theme-option[data-set-theme="bordeaux"] { --preview-felt-top: #8e3a49; --preview-felt-bottom: #3e111c; }
.theme-option[data-set-theme="onyx"] { --preview-felt-top: #5d6268; --preview-felt-bottom: #2a2d31; }
.theme-option[data-set-theme="amethyst"] { --preview-felt-top: #7a54a8; --preview-felt-bottom: #36215a; }
.rules-title {
  margin-top: 6px;
  font-size: 13px;
  color: var(--gold-bright);
  letter-spacing: .6px;
}
.payout-table .settings-hint + .settings-hint { margin-top: 0; }

/* ----------------------- Pace ----------------------- */
body[data-animation-speed="fast"] .bay-cards .card.deal-ready { animation-duration: .24s; }
body[data-animation-speed="cinematic"] .bay-cards .card.deal-ready { animation-duration: .5s; }

/* ----------------------- Phones and short screens ----------------------- */
@media (max-width: 760px) {
  .felt-head { grid-template-columns: auto 1fr; }
  .table-specs { display: none; }
  /* The commission box stays in sight while it holds anything. */
  .felt-head:has(.table-box-spec:not([hidden])) { grid-template-columns: auto 1fr auto; }
  .table-specs:has(.table-box-spec:not([hidden])) { display: flex; }
  .table-specs .table-spec:not(.table-box-spec) { display: none; }
  .banner { justify-self: center; max-width: 100%; }
  .table-felt { --w: clamp(30px, 9.4vw, 62px); }
  .spots {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    grid-template-areas:
      "pd pd pp pp tie tie bp bp bd bd"
      "player player player player player banker banker banker banker banker";
  }
  .spot-player-dragon { grid-area: pd; }
  .spot-banker-dragon { grid-area: bd; }
  .spot-dragon .spot-name, .spot-pair .spot-name, .spot-tie .spot-name { font-size: 9px; letter-spacing: .5px; }
  .spot-pair .spot-pay, .spot-tie .spot-pay { font-size: 8px; letter-spacing: 0; }
  .spot-pair, .spot-tie { padding-inline: 2px; }
  .spot-player-pair { grid-area: pp; }
  .spot-tie { grid-area: tie; }
  .spot-banker-pair { grid-area: bp; }
  .spot-player { grid-area: player; }
  .spot-banker { grid-area: banker; }
  .spot { min-height: 66px; padding-bottom: 38px; }
  .spot-main { min-height: 78px; }
  .spot-stack .bet-chip { --chip: 28px; }
  .spot-stack { bottom: 15px; }
  .road-bead { width: calc(var(--cell) * 8 + 1px); }
  .roads { --bead: clamp(10px, 3vw, 15px); padding: 5px 8px; }
  .controls { justify-content: center; }
  .chips-tray { width: 100%; gap: 4px; padding-inline: 6px; }
  .chips-tray .chip { --size: clamp(36px, 12vw, 50px); }
  .action-row { width: 100%; justify-content: space-between; }
  .btn-tool { min-width: 0; padding-inline: 7px; }
}

@media (max-width: 420px) {
  .bet-total { min-width: 0; }
  .bet-total .last-win { display: none; }
  .bet-actions { gap: 4px; }
  .btn-tool span { display: none; }
  .deal-btn { min-width: 84px; padding: 0 14px; }
}

/* The narrowest phones: slimmer tools and button, so that a large total
   still fits beside them. */
@media (max-width: 360px) {
  .spot-tie .spot-name { font-size: 8px; letter-spacing: 0; }
  .btn-tool { padding-inline: 5px; }
  .deal-btn { min-width: 72px; padding: 0 10px; }
  .bet-total strong { font-size: 16px; }
}

@media (max-height: 640px) {
  .roads { --bead: 11px; padding-block: 4px; }
  .road-counts { display: none; }
  .spot { min-height: 52px; padding-block: 5px 28px; }
  .table-felt { --w: clamp(30px, 7vh, 56px); }
  .bay-head { font-size: 12px; }
}

/* Short phones keep the bead plate and let the big road step aside. */
@media (max-height: 640px) and (max-width: 760px) {
  .roads { grid-template-columns: minmax(0, 1fr); --bead: 9px; }
  .road-big { display: none; }
  .spot { min-height: 52px; padding-bottom: 32px; }
  /* A full stack of five chips needs its whole lane. */
  .spot-main { min-height: 72px; padding-bottom: 40px; }
}

/* Phones on their side: only the hands, the spots and the controls. */
@media (max-height: 480px) {
  .topbar { padding-block: 4px; }
  .table-wrap { padding-block: 4px; gap: 4px; }
  .table-felt { --w: clamp(28px, 8.4vh, 44px); padding: 6px 12px; gap: 4px; border-radius: 20px; }
  .felt-head { grid-template-columns: auto 1fr auto; }
  .shoe { width: 44px; height: 32px; }
  .banner { padding: 3px 12px; font-size: 10px; }
  .banner small { display: inline; margin-left: 6px; }
  .table-specs { display: flex; }
  .table-specs .table-spec:not(.table-box-spec) { display: block; }
  .bay-head { font-size: 11px; letter-spacing: 2px; }
  .roads { display: none; }
  .spots { grid-template-columns: .72fr .8fr 1.35fr 1fr 1.35fr .8fr .72fr; grid-template-areas: none; }
  .spot-player-dragon, .spot-banker-dragon, .spot-player-pair, .spot-tie, .spot-banker-pair, .spot-player, .spot-banker { grid-area: auto; }
  .spot, .spot-main { min-height: 58px; padding: 4px 4px 36px; }
  .spot-name, .spot-main .spot-name { font-size: 11px; letter-spacing: 1px; }
  .spot-stack { bottom: 12px; }
  .spot-stack .bet-chip { --chip: 26px; }
  /* The tray and every action share one row: the tools keep only their icons. */
  .controls { flex-wrap: nowrap; gap: 8px; }
  .chips-tray { width: auto; gap: 4px; padding: 6px 8px; }
  .chips-tray .chip { --size: 30px; }
  .action-row { width: auto; gap: 8px; }
  .bet-actions { gap: 4px; }
  .btn-tool { min-width: 0; padding: 6px 7px; }
  .btn-tool span { display: none; }
  /* The stakes stand on the felt; here only their amount is repeated. */
  .bet-total { min-width: 0; }
  .bet-total small { display: none; }
  .deal-btn { height: 42px; min-width: 76px; padding-inline: 12px; }
  .bet-total .last-win { display: none; }
}

/* No transitions at all for reduced motion: each step appears in place. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
