/* Onyx Club Blackjack - all the styling.
   A. Base            B. Room (background, table, bear)   C. Felt: cards, chips, bet spots, badges
   D. Plates          E. Entry screen                     F. Top bar (HUD)
   G. Lobby           H. Table controls                   I. Celebration
   J. Sheets          K. Daily wheel                      L. Small things (toast, notice)
   M. Animations      N. Landscape                        O. Less motion
   Sizes are in em: .app's font-size (set by layout in src/main.js) is the one scale knob.
   Plates (buttons, badges, panels) are 9-slice art; their cuts come from src/ui/art.js and are written
   as CSS rules by plateRules in src/main.js, then baked seamless by src/ui/nine.js. */

/* ============================== A. Base ============================== */
:root {
  --ink: #fffaee;
  --ink-dim: #dfd1aa;
  --navy: #211c11;
  --navy-2: #16120b;
  --teal: #5e4e2d;
  --cyan: #fbd773;
  --gold: #ffe08a;
  --red: #ff6b7a;
  --serif: Georgia, 'Times New Roman', 'Noto Serif', 'Songti SC', 'Yu Mincho', serif;
  --sans: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, Roboto, 'Noto Sans', sans-serif;
}
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--navy-2);
  overscroll-behavior: none;
}
body {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button {
  padding: 0;
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
img {
  display: block;
  -webkit-user-drag: none;
}
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-size: 16px;
}

/* ============================== B. Room ============================== */
.bg,
.bg-img,
.bg-glow {
  position: absolute;
  inset: 0;
}
.bg-img {
  background: url(../../art/bg-portrait.webp) center top / cover no-repeat;
  transform: scale(1.04) translate(calc(var(--px, 0) * -0.6%), calc(var(--py, 0) * -0.4%));
  transition: transform 0.6s ease-out;
}
.app[data-mode='landscape'] .bg-img {
  background-image: url(../../art/bg-landscape.webp);
}
/* the room light breathes: a slow veil of colour over the windows */
/* the room lights answer a win */
.app.is-glow .bg-glow {
  filter: brightness(1.9) saturate(1.3);
}
.bg-glow {
  transition: filter 0.5s;
  background:
    radial-gradient(60% 30% at 50% 12%, rgba(251, 209, 94, 0.16), transparent 70%),
    radial-gradient(40% 24% at 22% 16%, rgba(252, 217, 123, 0.16), transparent 70%);
  mix-blend-mode: screen;
  animation: aurora 9s ease-in-out infinite alternate;
}
.stage {
  position: absolute;
  inset: 0;
}
.table {
  position: absolute;
  left: 50%;
  top: var(--table-top, 40%);
  width: var(--table-w, 100%);
  height: var(--table-h, 100%);
  transform: translateX(-50%);
  background: url(../../art/table-portrait.webp) center top / 100% 100% no-repeat;
  filter: drop-shadow(0 -0.4em 0.9em rgba(14, 12, 6, 0.45));
}
.app[data-mode='landscape'] .table {
  background-image: url(../../art/table-landscape.webp);
}
.bear {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.world {
  position: absolute;
  inset: 0;
}
.crystal {
  position: absolute;
  bottom: -0.6em;
  width: 7.5em;
  pointer-events: none;
  filter: drop-shadow(0 0 0.6em rgba(251, 215, 114, 0.35));
}
.crystal-l {
  left: -1.6em;
}
.crystal-r {
  right: -1.6em;
  transform: scaleX(-1);
}
/* the table screens fade in over the same room */
.app[data-screen='entry'] .world,
.app[data-screen='lobby'] .world,
.app.is-moving .world {
  opacity: 0;
  pointer-events: none;
}
.world {
  transition: opacity 0.35s;
}

/* ============================== C. Felt ============================== */
.felt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.felt-ink {
  stroke: rgba(240, 200, 110, 0.55);
  stroke-linecap: round;
}
.felt-line {
  stroke-width: 1.4;
}
.felt-sprig path {
  fill: rgba(240, 196, 96, 0.8);
  stroke: rgba(254, 244, 215, 0.7);
  stroke-width: 0.8;
  stroke-linejoin: round;
}
.felt-line.thin {
  stroke-width: 0.9;
}
.felt-t1,
.felt-t2 {
  fill: rgba(240, 200, 110, 0.9);
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.07em;
}
.felt-t2 {
  fill: rgba(232, 200, 130, 0.72);
  letter-spacing: 0.1em;
}
.prop {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  filter: drop-shadow(0 0.5em 0.5em rgba(16, 13, 6, 0.5));
}
.cards-layer,
.chips-layer,
.spots,
.marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* cards: the outer box is placed by src/ui/table.js; the inner one carries the flip and the shadow */
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  aspect-ratio: 200 / 280;
  transform-origin: 50% 50%;
  will-change: transform;
}
.card-in {
  position: absolute;
  inset: 0;
  filter: drop-shadow(0 2px 2px rgba(14, 12, 6, 0.34));
  transition: filter 0.25s;
}
.card-face,
.card-back {
  position: absolute;
  inset: 0;
  background: url(../../art/cards.webp) 0 0 / 1300% 500% no-repeat;
}
.card-back {
  background-position: 0% 100%;
}
.card.is-down .card-face,
.card:not(.is-down) .card-back {
  visibility: hidden;
}
.card.is-active .card-in {
  filter: drop-shadow(0 2px 2px rgba(14, 12, 6, 0.34)) drop-shadow(0 0 calc(var(--cw) * 0.1) rgba(251, 215, 115, 0.95));
}
.card.is-waiting .card-in {
  filter: brightness(0.7) saturate(0.85);
}
.card.is-won .card-in {
  filter: drop-shadow(0 0 calc(var(--cw) * 0.05) #fff) drop-shadow(0 0 calc(var(--cw) * 0.16) rgba(255, 224, 138, 0.95));
  animation: card-hop 0.42s cubic-bezier(0.3, 1.4, 0.5, 1) calc(var(--i, 0) * 0.1s) both;
}
.card.is-lost .card-in {
  filter: brightness(0.6) saturate(0.6);
}
/* a busted hand dims: a veil on the cards, and they slump a little */
.card.is-bust .card-in {
  filter: brightness(0.86) saturate(0.55);
  transform: rotate(var(--tilt, 0deg)) translateY(3%);
  transition:
    transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1),
    filter 0.3s;
}
.card.is-bust .card-in::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 7% / 5%;
  background:
    linear-gradient(155deg, rgba(254, 249, 235, 0.72), rgba(238, 215, 152, 0.34) 45%, rgba(254, 245, 221, 0.62)),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.8), transparent 40%);
  box-shadow: inset 0 0 0 0.09em rgba(254, 248, 231, 0.9);
  animation: fade-in 0.35s;
}

/* chips */
.chip {
  display: block;
  background: center / contain no-repeat;
}
.chip-top {
  width: var(--chip);
  aspect-ratio: 1;
}
.chip-fly {
  position: absolute;
  left: 0;
  top: 0;
  filter: drop-shadow(0 0.5em 0.4em rgba(14, 12, 6, 0.5));
  will-change: transform;
}
.pile {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  will-change: transform;
}
.pile .chip-side {
  position: absolute;
  width: calc(var(--chip) * var(--s, 1));
  aspect-ratio: var(--chip-ratio, 1.5);
  left: calc(var(--chip) * var(--s, 1) * -0.5);
  bottom: calc(var(--chip) * var(--s, 1) * (var(--j) * var(--chip-rise, 0.12) - 0.3));
  filter: drop-shadow(0 1px 1px rgba(14, 12, 6, 0.4));
}
.pile .chip-side:first-child {
  filter: drop-shadow(0 0.25em 0.25em rgba(14, 12, 6, 0.55));
}

/* bet spots: glowing rings printed on the felt; they take taps only while betting */
.spot {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: rgba(252, 240, 207, 0.72);
}
.spots.is-open .spot {
  pointer-events: auto;
}
.spot .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 0.12em solid rgba(248, 222, 152, 0.5);
  box-shadow:
    0 0 0.7em rgba(251, 215, 115, 0.28),
    inset 0 0 0.9em rgba(251, 215, 115, 0.14);
  background: radial-gradient(circle, rgba(251, 215, 115, 0.07), transparent 70%);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.spot-main .ring {
  inset: -4% -22%;
  border-radius: 50%;
}
.spots.is-open .spot .ring {
  border-color: rgba(253, 237, 192, 0.85);
  box-shadow:
    0 0 1em rgba(251, 215, 115, 0.55),
    inset 0 0 1em rgba(251, 215, 115, 0.22);
  animation: ring-breathe 1.8s ease-in-out infinite alternate;
}
.spot.has-bet .ring {
  animation: none;
}
.spot.is-turn .ring {
  border-color: rgba(253, 237, 192, 0.95);
  box-shadow:
    0 0 1.1em rgba(251, 215, 115, 0.75),
    inset 0 0 1.1em rgba(251, 215, 115, 0.3);
  animation: ring-breathe 1.1s ease-in-out infinite alternate;
}
.spot-label {
  position: relative;
  font-size: max(0.56em, 9px);
  letter-spacing: 0.05em;
  text-align: center;
  line-height: 1.05;
  white-space: pre-line;
  max-width: 92%;
  text-shadow: 0 1px 2px rgba(22, 17, 8, 0.8);
}
.spot-side .spot-label {
  font-size: max(0.5em, 8.5px);
}
.spot.has-bet .spot-label {
  opacity: 0;
}
.spot:not(.has-bet):active .ring {
  transform: scale(0.94);
}
.plate.bet-label {
  position: absolute;
  left: 0;
  top: 0;
  --ph: 1.75em;
  font-size: 0.86em;
}
/* a side spot with no stake disappears once the cards are out */
.spots:not(.is-open) .spot-side:not(.has-bet) {
  opacity: 0;
}
.spot-side {
  transition: opacity 0.25s;
}

/* total badges, result tags */
.plate.total,
.plate.tag {
  position: absolute;
  left: 0;
  top: 0;
  margin: calc(var(--ph) * -0.5) 0 0 0;
}
.total {
  --ph: 1.9em;
  font-size: 1.02em;
  min-width: calc(var(--ph) * 1.9);
  translate: 0 0;
}
.total[data-side='top'] {
  margin-left: 0;
  translate: -50% -50%;
}
.total[data-side='right'] {
  translate: 0 0;
}
.total.is-active {
  filter: drop-shadow(0 0 0.5em rgba(251, 215, 115, 0.9));
}
.tag {
  --ph: 2.1em;
  font-size: 0.95em;
  z-index: 60;
}
.tag-win > span,
.tag-blackjack > span {
  color: var(--gold);
}
.tag-lose > span,
.tag-bust > span {
  color: #ffd6da;
}

/* ============================== D. Plates ============================== */
/* A plate is --ph tall; its label sits on the glass (padding and nudge come from the art's measurements). */
.plate,
.btn-act,
.btn-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ph);
  padding: 0 calc(var(--ph) * var(--gr, 0.4)) 0 calc(var(--ph) * var(--gl, 0.4));
  border: 0 solid transparent;
  white-space: nowrap;
}
.plate > span,
.btn-act > span,
.btn-pill > span {
  position: relative;
  top: calc(var(--ph) * var(--gy, 0));
  display: block;
  white-space: nowrap;
  line-height: 1;
}
.badge {
  color: #fffcf3;
  text-shadow:
    0 0.06em 0 rgba(22, 17, 8, 0.9),
    0 0 0.3em rgba(36, 29, 14, 0.8);
  letter-spacing: 0.03em;
}
.banner {
  --ph: 2.5em;
  color: #fffbf1;
  letter-spacing: 0.09em;
  text-shadow:
    0 0.07em 0 rgba(25, 20, 9, 0.95),
    0 0 0.45em rgba(251, 215, 115, 0.45);
}
.plaque {
  --ph: 2.5em;
  justify-content: flex-start;
  gap: 0.35em;
}

.btn-act {
  --ph: 3.9em;
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  gap: 0.12em;
  font-size: 1em;
  letter-spacing: 0.04em;
  color: #fffcf5;
  text-shadow:
    0 0.07em 0 rgba(29, 23, 11, 0.9),
    0 0 0.3em rgba(36, 29, 14, 0.7);
  filter: drop-shadow(0 0.22em 0.3em rgba(14, 12, 6, 0.55));
  transition:
    transform 0.09s,
    filter 0.2s,
    opacity 0.2s;
}
.btn-act .ico {
  height: calc(var(--ph) * 0.4);
  width: auto;
  filter: drop-shadow(0 0.08em 0.06em rgba(26, 21, 10, 0.7));
}
.btn-act > span {
  font-size: max(0.82em, 10px);
}
.btn-act:active,
.btn-pill:active,
.btn-round:active,
.btn-tab:active,
.chip-btn:active {
  transform: scale(0.92);
}
.btn-act:disabled {
  transform: none;
}
.app[data-phase='player'] .row-act .btn-act:disabled .ico,
.app[data-phase='player'] .row-act .btn-act:disabled > span,
.row-bet .btn-act:disabled .ico,
.row-bet .btn-act:disabled > span,
.table-card .btn-act:disabled > span {
  opacity: 0.5;
}
.app:not([data-phase='player']) .row-act .btn-act:disabled {
  filter: saturate(0.45) brightness(0.62) drop-shadow(0 0.22em 0.3em rgba(14, 12, 6, 0.45));
}
.btn-act.is-hint {
  animation: hint 1.1s ease-in-out infinite alternate;
}
.x2 {
  font-size: 1.35em;
}

.btn-pill {
  --ph: 3.5em;
  min-width: 9em;
  font-size: 1.3em;
  letter-spacing: 0.08em;
  color: #fffcf6;
  text-shadow:
    0 0.07em 0 rgba(39, 31, 15, 0.9),
    0 0 0.35em rgba(51, 40, 19, 0.7);
  filter: drop-shadow(0 0.25em 0.4em rgba(14, 12, 6, 0.55)) drop-shadow(0 0 0.7em rgba(236, 195, 84, 0.4));
  transition:
    transform 0.09s,
    filter 0.2s,
    opacity 0.2s;
}
.btn-pill:disabled {
  filter: grayscale(0.7) brightness(0.8) drop-shadow(0 0.25em 0.4em rgba(14, 12, 6, 0.45));
}

.btn-round {
  position: relative;
  width: 2.6em;
  height: 2.6em;
  display: grid;
  place-items: center;
  background: url(../../art/round-btn.webp) center / contain no-repeat;
  transition: transform 0.09s;
}
.btn-round .ico {
  width: 52%;
  height: 52%;
  object-fit: contain;
}
.btn-round .ico.off,
.is-muted .btn-round .ico.on {
  display: none;
}
.is-muted .btn-round .ico.off {
  display: block;
}
.gift-dot {
  position: absolute;
  top: 4%;
  right: 4%;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #ffb300);
  box-shadow: 0 0 0.5em #ffd24d;
  animation: ring-breathe 0.9s ease-in-out infinite alternate;
}

/* ============================== E. Entry ============================== */
.entry {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(1.2em, env(safe-area-inset-top)) 1em max(0.8em, env(safe-area-inset-bottom));
  pointer-events: none;
}
.entry > * {
  pointer-events: auto;
}
.entry-logo {
  width: auto;
  max-width: 88vw;
  height: min(31vh, 62vw);
  margin-top: 1.2em;
  filter: drop-shadow(0 0.5em 0.9em rgba(17, 14, 7, 0.65));
  animation: floaty 5s ease-in-out infinite alternate;
}
.entry-cta {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7em;
  width: 100%;
}
.loading {
  width: min(19em, 82vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55em;
}
.loading-label {
  --ph: 2.3em;
  font-size: 0.95em;
}
.loading-bar {
  width: 100%;
  height: 1.15em;
  border-radius: 1em;
  background: rgba(33, 27, 15, 0.85);
  box-shadow:
    inset 0 0 0 0.11em rgba(250, 235, 192, 0.75),
    0 0 0.9em rgba(251, 215, 115, 0.35);
  overflow: hidden;
  padding: 0.2em;
}
.loading-bar i {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: 1em;
  background: linear-gradient(#fdebb9, #e0b43b 55%, #bc921e);
  box-shadow: 0 0 0.7em #fbd773;
  transition: width 0.25s;
}
.btn-play {
  --ph: 3.7em;
  min-width: 12.5em;
  font-size: 1.45em;
  animation: play-breathe 1.6s ease-in-out infinite alternate;
}
.disclaimer {
  margin-top: 0.8em;
  max-width: 30em;
  font: 400 max(0.62em, 9px) / 1.3 var(--sans);
  text-align: center;
  color: rgba(247, 239, 215, 0.82);
  text-shadow: 0 1px 2px #110e07;
}
.maker {
  margin-top: 0.3em;
  font: italic 400 max(0.62em, 9px) var(--serif);
  letter-spacing: 0.12em;
  color: rgba(247, 239, 215, 0.6);
}
.age {
  position: absolute;
  top: max(0.7em, env(safe-area-inset-top));
  right: 0.8em;
  padding: 0.2em 0.5em;
  border: 0.12em solid #fff;
  border-radius: 0.5em;
  font: 800 0.8em var(--sans);
}

/* ============================== F. Top bar ============================== */
.top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 0.45em;
  padding: max(0.45em, env(safe-area-inset-top)) max(0.5em, env(safe-area-inset-right)) 0
    max(0.5em, env(safe-area-inset-left));
  z-index: 30;
}
.balance {
  min-width: 6.6em;
  padding-left: calc(var(--ph) * 0.5);
}
.coin-ico {
  width: 1.45em;
  height: 1.45em;
  margin-left: -0.2em;
  object-fit: contain;
  filter: drop-shadow(0 0.08em 0.1em rgba(14, 12, 6, 0.6));
}
#balance {
  font-size: 1.12em;
}
.level {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  max-width: 13em;
}
.level-badge {
  position: relative;
  z-index: 1;
  flex: none;
  width: 2.5em;
  height: 2.7em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 0.95;
  background: url(../../art/level-badge.webp) center / 165% auto no-repeat;
}
.level-badge small {
  font: 400 0.5em var(--serif);
  color: var(--ink-dim);
}
.level-badge b {
  font-size: 0.92em;
}
.xp {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 1.15em;
  margin-left: -0.5em;
  border-radius: 1em;
  background: rgba(33, 27, 15, 0.88);
  box-shadow: inset 0 0 0 0.09em rgba(244, 225, 172, 0.7);
  overflow: hidden;
}
.xp i {
  position: absolute;
  inset: 0.14em;
  width: calc((100% - 0.28em) * var(--p, 0));
  border-radius: 1em;
  background: linear-gradient(#fdebb9, #e0b43b 55%, #bc921e);
  transition: width 0.5s;
}
.xp em {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 max(0.5em, 8px) var(--sans);
  font-style: normal;
  color: #fff;
  text-shadow: 0 1px 1px #191409;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.top-buttons {
  margin-left: auto;
  display: flex;
  gap: 0.3em;
}
.btn-gift {
  display: none;
}
.btn-gift.is-ready {
  display: grid;
}

/* ============================== G. Lobby ============================== */
.lobby {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: var(--lobby-top, 36%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7em;
  padding: 0.4em 0.6em max(0.6em, env(safe-area-inset-bottom));
}
.lobby-title {
  font-size: 1.12em;
}
.tables {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  max-width: 46em;
  display: flex;
  justify-content: center;
  gap: 0.5em;
}
.table-card {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 13em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35em;
  padding: 0.55em 0.4em 0.6em;
  border-radius: 0.9em;
  background: linear-gradient(rgba(64, 53, 30, 0.78), rgba(44, 36, 20, 0.86));
  box-shadow:
    inset 0 0 0 0.1em rgba(246, 226, 172, 0.75),
    inset 0 0 1.4em rgba(251, 215, 115, 0.18),
    0 0.4em 0.9em rgba(14, 12, 6, 0.5);
  transition: transform 0.12s;
}
.table-card:active {
  transform: scale(0.97);
}
.table-card h3 {
  margin: 0;
  font-size: max(0.82em, 10px);
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.05;
  min-height: 2.1em;
  display: grid;
  place-items: center;
  text-shadow: 0 0.07em 0 rgba(25, 20, 9, 0.95);
}
.table-card .thumb {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}
.table-card .range {
  --ph: 1.65em;
  font-size: max(0.66em, 9px);
}
.table-card .state {
  font: 400 max(0.6em, 9px) var(--serif);
  color: var(--ink-dim);
  min-height: 1.2em;
  text-align: center;
}
.table-card .btn-act {
  --ph: 2.3em;
  flex: none;
  width: 92%;
  flex-direction: row;
}
.table-card.is-locked .thumb {
  filter: brightness(0.55) saturate(0.7);
}
.table-card .lock {
  position: absolute;
  top: 38%;
  left: 50%;
  width: 2.6em;
  translate: -50% -50%;
  filter: drop-shadow(0 0.2em 0.3em rgba(14, 12, 6, 0.7));
}
.tabbar {
  display: flex;
  gap: 0.35em;
  width: 100%;
  max-width: 30em;
}
.btn-tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 3.5em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  border-radius: 0.7em;
  background: linear-gradient(rgba(84, 70, 42, 0.9), rgba(53, 44, 25, 0.92));
  box-shadow:
    inset 0 0 0 0.09em rgba(242, 221, 162, 0.7),
    0 0.25em 0.5em rgba(14, 12, 6, 0.5);
  transition: transform 0.09s;
}
.btn-tab.is-on {
  background: linear-gradient(rgba(147, 117, 33, 0.95), rgba(83, 68, 39, 0.95));
  box-shadow:
    inset 0 0 0 0.1em rgba(254, 240, 201, 0.9),
    0 0 0.8em rgba(236, 195, 84, 0.4);
}
.btn-tab .ico {
  height: 1.5em;
  width: auto;
}
.btn-tab > span {
  font-size: max(0.56em, 9px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  max-width: 96%;
}

/* ============================== H. Table controls ============================== */
.game {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.game > * {
  pointer-events: auto;
}
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  padding: 0 0.55em max(0.3em, env(safe-area-inset-bottom));
}
.rack {
  --ph: 3.3em;
  gap: 0.5em;
  padding: 0 calc(var(--ph) * 0.42);
}
.chip-btn {
  position: relative;
  width: calc(var(--ph) * 0.84);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: center / contain no-repeat;
  font: 900 0.8em var(--serif);
  color: #ffd36e;
  text-shadow:
    0 1px 1px rgba(0, 0, 0, 0.95),
    0 0 2px rgba(0, 0, 0, 0.8);
  filter: drop-shadow(0 0.15em 0.15em rgba(14, 12, 6, 0.55));
  transition:
    transform 0.14s cubic-bezier(0.3, 1.5, 0.5, 1),
    filter 0.14s;
}
.chip-btn.is-on {
  transform: translateY(-16%) scale(1.14);
  filter: drop-shadow(0 0.3em 0.25em rgba(14, 12, 6, 0.5)) drop-shadow(0 0 0.5em rgba(253, 231, 172, 0.95));
}
.chip-btn:disabled {
  filter: grayscale(0.8) brightness(0.7);
}
.chip-btn span {
  font-size: var(--fs, 1em);
  letter-spacing: -0.02em;
}
.row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  width: 100%;
  max-width: 30em;
}
/* the three rows (bet, moves, next) are equally tall, so the felt above never jumps between phases */
.row {
  min-height: 3.9em;
}
.row-bet .btn-act {
  --ph: 3.3em;
  flex: 0 1 auto;
  min-width: 4.9em;
  flex-direction: row;
  gap: 0.3em;
}
.row-bet .btn-act .ico {
  height: calc(var(--ph) * 0.42);
}
.row-bet #x2 {
  min-width: 3.9em;
}
.btn-deal {
  --ph: 3.3em;
  flex: 1 1 0;
  min-width: 6em;
  font-size: 1.18em;
}
.btn-deal:not(:disabled) {
  animation: play-breathe 1.4s ease-in-out infinite alternate;
}
.row-act {
  align-items: stretch;
}
/* SURRENDER: a small extra move above the four, only when the rules offer it on this hand */
.row-more {
  justify-content: flex-end;
  height: 0;
  min-height: 0;
  overflow: visible;
  align-items: flex-end;
}
.row-next {
  gap: 0.6em;
}
.btn-again {
  --ph: 3.3em;
  flex: 1.3 1 0;
  font-size: 1.15em;
  min-width: 0;
}
.btn-newbet {
  --ph: 3.3em;
  flex: 1 1 0;
  flex-direction: row;
}
.notice {
  font: 400 italic max(0.62em, 9px) var(--serif);
  letter-spacing: 0.04em;
  color: rgba(249, 240, 215, 0.78);
  text-shadow: 0 1px 2px #110e07;
  text-align: center;
  white-space: nowrap;
}
.prompt {
  position: absolute;
  left: 50%;
  top: var(--prompt-y, 50%);
  translate: -50% -50%;
  font-size: 1.05em;
  z-index: 5;
  pointer-events: none;
}
.tip {
  position: absolute;
  left: var(--tip-x, 60%);
  top: var(--tip-y, 60%);
  padding: 0.75em 0.8em;
  border-radius: 0.7em 0.7em 0.7em 0.15em;
  background: rgba(45, 37, 21, 0.92);
  box-shadow:
    inset 0 0 0 0.09em rgba(246, 224, 162, 0.85),
    0 0.2em 0.5em rgba(14, 12, 6, 0.5);
  font: 400 max(0.72em, 10px) var(--serif);
  color: #fef9ea;
  white-space: nowrap;
  z-index: 6;
  pointer-events: none;
  animation: tip-in 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.app[data-phase='result'] .rack,
.app[data-phase='player'] .rack,
.app[data-phase='deal'] .rack,
.app[data-phase='dealer'] .rack,
.app[data-phase='insurance'] .rack {
  opacity: 0.45;
  filter: saturate(0.5);
  pointer-events: none;
}
.rack {
  transition:
    opacity 0.25s,
    filter 0.25s;
}

/* the result of a plain round, in the middle of the felt: a painted title, the amount, a line of text */
.outcome {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--out-y, 50%);
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  z-index: 20;
  pointer-events: none;
}
.world.felt-hidden .felt {
  opacity: 0.1;
}
.felt {
  transition: opacity 0.2s;
}
.outcome[data-where='hand'] .outcome-title {
  width: min(11.5em, 60vw);
}
.outcome[data-where='cards'] .outcome-title {
  width: min(10.5em, 54vw);
}
.world.bet-hidden .bet-label {
  opacity: 0;
}
.bet-label {
  transition: opacity 0.15s;
}
.outcome-title {
  width: min(15.5em, 78vw);
  height: auto;
  filter: drop-shadow(0 0.3em 0.5em rgba(14, 12, 6, 0.75));
}
.outcome-title.slam {
  animation: slam 0.36s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.outcome-amount {
  font-size: 2.3em;
  line-height: 1;
  margin-top: -0.1em;
  animation: pop 0.4s 0.12s ease-out both;
}
.outcome-sub {
  --ph: 2em;
  font: 400 max(0.82em, 10px) var(--serif);
  letter-spacing: 0.03em;
  margin-top: 0.2em;
  animation: pop 0.35s 0.15s ease-out both;
}
.app[data-mode='landscape'] .outcome-title {
  width: min(17em, 34vw);
}

/* ============================== I. Celebration ============================== */
.dim {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(19, 16, 9, 0.2), rgba(15, 12, 7, 0.62));
  z-index: 40;
  animation: fade-in 0.25s;
}
.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 45;
}
.celebrate {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.cel-title {
  position: absolute;
  left: 50%;
  top: var(--cel-title-y, 40%);
  translate: -50% -50%;
  width: var(--cel-w, 90vw);
  height: auto;
  filter: drop-shadow(0 0.4em 0.7em rgba(14, 12, 6, 0.7));
}
.cel-title.slam {
  animation: slam 0.42s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.cel-title.step {
  animation: step-punch 0.34s ease-out both;
}
.cel-amount {
  position: absolute;
  left: 50%;
  top: var(--cel-amount-y, 55%);
  translate: -50% -50%;
  font-size: 3.1em;
  line-height: 1;
  min-height: 1em;
  white-space: nowrap;
}
.cel-amount.step {
  animation: step-punch 0.34s ease-out both;
}
.cel-skip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9%;
  text-align: center;
  font: 400 max(0.75em, 10px) var(--serif);
  letter-spacing: 0.14em;
  color: #fef8e7;
  text-shadow: 0 1px 3px #110e07;
  animation: play-breathe 1.2s ease-in-out infinite alternate;
}
/* painted digits (src/ui/glyphs.js): each <i> shows its piece of the atlas */
.glyph {
  display: inline-block;
  height: 0.86em;
  vertical-align: -0.1em;
  margin-right: -0.035em;
  background: url(../../art/font-ice.webp) no-repeat;
  background-size: calc(var(--glyph-atlas, 10) * 1em) 0.86em;
  filter: drop-shadow(0 0.05em 0.04em rgba(22, 17, 8, 0.95)) drop-shadow(0 0 0.12em rgba(26, 21, 10, 0.6));
}
.gold .glyph {
  background-image: url(../../art/font-gold.webp);
  background-size: calc(var(--glyph-atlas-gold, var(--glyph-atlas, 10)) * 1em) 0.86em;
}

/* ============================== J. Sheets ============================== */
.sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 3.4em 0.5em 0.8em;
  background: rgba(16, 13, 8, 0.66);
  z-index: 70;
  animation: fade-in 0.2s;
}
.sheet-card {
  --k: 0.42;
  position: relative;
  display: block;
  height: auto;
  width: min(26em, 100%);
  max-height: 100%;
  padding: 0;
  white-space: normal;
  animation: sheet-in 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.sheet-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55em;
  max-height: calc(100vh - 6em);
  max-height: calc(100dvh - 6em);
  overflow-y: auto;
  scrollbar-width: none;
  text-align: center;
  padding: 0.2em 0.3em 0.4em;
}
.sheet-body::-webkit-scrollbar {
  display: none;
}
.sheet-close {
  position: absolute;
  top: calc(var(--pt, 1em) * -0.35);
  right: -0.35em;
  z-index: 2;
  width: 2.3em;
  height: 2.3em;
}
.sheet-card.is-modal .sheet-close {
  display: none;
}
.sheet-title {
  font-size: 1.35em;
  letter-spacing: 0.09em;
  margin: 0;
  text-shadow:
    0 0.07em 0 rgba(25, 20, 9, 0.95),
    0 0 0.5em rgba(251, 215, 115, 0.5);
  white-space: nowrap;
}
.sheet-sub {
  font: 400 max(0.62em, 9px) var(--serif);
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  margin-top: -0.5em;
}
.sheet-text {
  font: 400 1.02em / 1.3 var(--serif);
  max-width: 19em;
}
.sheet-small {
  font: 400 italic max(0.74em, 10px) / 1.3 var(--serif);
  color: var(--ink-dim);
  max-width: 22em;
}
.sheet-actions {
  display: flex;
  justify-content: center;
  gap: 0.7em;
  width: 100%;
  margin-top: 0.3em;
}
.sheet-actions .btn-act {
  --ph: 3em;
  flex: 1 1 0;
  max-width: 9em;
  flex-direction: row;
  font-size: 1.15em;
}
.sheet-actions .btn-pill {
  --ph: 3.2em;
  font-size: 1.2em;
  min-width: 8.5em;
}
.sheet-art {
  width: min(13em, 60%);
  height: auto;
}
.sheet-amount {
  display: flex;
  align-items: center;
  gap: 0.3em;
  font-size: 2.1em;
}
.sheet-amount img {
  width: 0.95em;
  height: 0.95em;
}
.sheet-title-img {
  width: min(18em, 96%);
  height: auto;
}
.sheet-title.small {
  font-size: 1.05em;
  margin-top: 0.3em;
}
.sheet-actions.three .btn-act {
  max-width: none;
  font-size: 0.95em;
}
.level-big {
  width: 7.2em;
  height: 7em;
  display: grid;
  place-items: center;
  background: url(../../art/level-badge.webp) center / contain no-repeat;
  animation: pop 0.45s ease-out both;
}
.level-big b {
  font-size: 2.7em;
  text-shadow:
    0 0.06em 0 rgba(25, 20, 9, 0.95),
    0 0 0.4em rgba(251, 215, 115, 0.7);
}
.reward {
  justify-content: center;
  gap: 0.6em;
  font-size: 1.05em;
}
.reward b {
  display: block;
  line-height: 1.1;
  letter-spacing: 0.04em;
}
.reward small {
  display: block;
  font: 400 max(0.6em, 9px) var(--serif);
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}
.reward .ico {
  height: 1.5em;
  width: 1.5em;
}
/* settings rows */
.opt {
  --ph: 2.55em;
  width: 100%;
  justify-content: space-between;
  gap: 0.5em;
  font: 400 0.95em var(--serif);
}
.opt > .opt-name {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 0;
  top: 0;
  white-space: nowrap;
}
.opt-name .ico {
  height: 1.15em;
  width: 1.15em;
  object-fit: contain;
  flex: none;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 1 9em;
  min-width: 4em;
  height: 1.7em;
  margin: 0;
  background: none;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  height: 0.5em;
  border-radius: 1em;
  background:
    linear-gradient(90deg, #fdebb9, #e0b43b) 0 / calc(var(--p, 1) * 100%) 100% no-repeat,
    rgba(33, 27, 15, 0.9);
  box-shadow: inset 0 0 0 0.07em rgba(242, 221, 162, 0.7);
}
.slider::-moz-range-track {
  height: 0.5em;
  border-radius: 1em;
  background: rgba(33, 27, 15, 0.9);
  box-shadow: inset 0 0 0 0.07em rgba(242, 221, 162, 0.7);
}
.slider::-moz-range-progress {
  height: 0.5em;
  border-radius: 1em;
  background: linear-gradient(90deg, #fdebb9, #e0b43b);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.3em;
  height: 1.3em;
  margin-top: -0.4em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8d8ab 60%, #cdb471);
  box-shadow:
    0 0.1em 0.25em rgba(14, 12, 6, 0.6),
    0 0 0.5em rgba(251, 215, 115, 0.6);
}
.slider::-moz-range-thumb {
  width: 1.3em;
  height: 1.3em;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8d8ab 60%, #cdb471);
  box-shadow: 0 0.1em 0.25em rgba(14, 12, 6, 0.6);
}
.toggle {
  position: relative;
  flex: none;
  width: 4.2em;
  height: 1.75em;
  border-radius: 1em;
  background: rgba(33, 27, 15, 0.9);
  box-shadow: inset 0 0 0 0.09em rgba(242, 221, 162, 0.7);
  font: 800 max(0.6em, 9px) var(--sans);
  color: #f5ebd0;
  transition: background 0.2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 0.2em;
  left: 0.2em;
  width: 1.35em;
  height: 1.35em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #dfd5b9);
  box-shadow: 0 0.1em 0.2em rgba(14, 12, 6, 0.6);
  transition: left 0.2s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.toggle[aria-pressed='true'] {
  background: linear-gradient(#c5a03a, #95751f);
}
.toggle[aria-pressed='true']::after {
  left: calc(100% - 1.55em);
}
.toggle span {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  right: 0.6em;
}
.toggle[aria-pressed='true'] span {
  right: auto;
  left: 0.65em;
  color: #fff;
}
.seg {
  display: flex;
  flex: none;
  border-radius: 1em;
  overflow: hidden;
  box-shadow: inset 0 0 0 0.09em rgba(242, 221, 162, 0.7);
  background: rgba(33, 27, 15, 0.9);
}
.seg button {
  padding: 0.35em 0.8em;
  font: 400 max(0.8em, 10px) var(--serif);
  color: #f5ebd0;
  white-space: nowrap;
}
.seg button[aria-pressed='true'] {
  background: linear-gradient(#c5a03a, #95751f);
  color: #fff;
  border-radius: 1em;
}
.opt select {
  flex: 0 1 9em;
  min-width: 0;
  padding: 0.3em 0.6em;
  border-radius: 1em;
  border: 0;
  background: rgba(33, 27, 15, 0.9);
  box-shadow: inset 0 0 0 0.09em rgba(242, 221, 162, 0.7);
  color: #fef9eb;
  font: 400 max(0.85em, 11px) var(--serif);
}
/* rules */
.tabs {
  display: flex;
  gap: 0.25em;
  width: 100%;
}
.tabs button {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5em 0.45em;
  border-radius: 0.5em;
  background: rgba(54, 45, 26, 0.9);
  box-shadow: inset 0 0 0 0.08em rgba(238, 215, 152, 0.6);
  font: 700 max(0.6em, 9px) var(--serif);
  letter-spacing: 0.03em;
  color: #f5ebd0;
  white-space: nowrap;
  overflow: hidden;
}
.tabs button[aria-selected='true'] {
  background: linear-gradient(#b99533, #6c5b38);
  color: #fff;
  box-shadow: inset 0 0 0 0.1em rgba(254, 240, 201, 0.9);
}
.rule-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  width: 100%;
  padding: 0.45em 0.6em;
  border-radius: 0.6em;
  background: rgba(47, 38, 21, 0.72);
  box-shadow: inset 0 0 0 0.07em rgba(238, 215, 152, 0.45);
  text-align: left;
  font: 400 max(0.82em, 11px) / 1.25 var(--serif);
}
.rule-row .ico {
  width: 1.7em;
  height: 1.7em;
  object-fit: contain;
  flex: none;
}
.rule-row b {
  flex: none;
  min-width: 5.2em;
  letter-spacing: 0.04em;
}
.rule-row .pay {
  margin-left: auto;
  color: var(--gold);
  white-space: nowrap;
  flex: none;
}
.rule-list {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  width: 100%;
}
/* stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35em;
  width: 100%;
}
.stat {
  padding: 0.45em 0.2em;
  border-radius: 0.6em;
  background: rgba(47, 38, 21, 0.75);
  box-shadow: inset 0 0 0 0.07em rgba(238, 215, 152, 0.5);
}
.stat:nth-child(n + 4) {
  grid-column: span 3;
}
.stat-grid .stat:nth-child(4),
.stat-grid .stat:nth-child(5) {
  grid-column: auto;
}
.stat-grid.two {
  grid-template-columns: repeat(2, 1fr);
}
.stat small {
  display: block;
  font: 700 max(0.5em, 8.5px) var(--serif);
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  white-space: nowrap;
}
.stat b {
  display: block;
  font-size: 1.25em;
  margin-top: 0.15em;
}
.ach {
  display: flex;
  align-items: center;
  gap: 0.6em;
  width: 100%;
  padding: 0.4em 0.6em;
  border-radius: 0.6em;
  background: rgba(47, 38, 21, 0.75);
  box-shadow: inset 0 0 0 0.07em rgba(238, 215, 152, 0.5);
  text-align: left;
}
.ach .ico {
  width: 1.9em;
  height: 1.9em;
  object-fit: contain;
  flex: none;
}
.ach-main {
  flex: 1 1 0;
  min-width: 0;
}
.ach-main b {
  display: block;
  font-size: max(0.8em, 10px);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ach-bar {
  position: relative;
  height: 0.95em;
  margin-top: 0.25em;
  border-radius: 1em;
  background: rgba(33, 27, 15, 0.9);
  box-shadow: inset 0 0 0 0.07em rgba(242, 221, 162, 0.6);
  overflow: hidden;
}
.ach-bar i {
  position: absolute;
  inset: 0.12em;
  width: calc((100% - 0.24em) * var(--p, 0));
  border-radius: 1em;
  background: linear-gradient(#fdebb9, #e0b43b 55%, #bc921e);
}
.ach-bar em {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 max(0.5em, 8px) var(--sans);
  font-style: normal;
  color: #fff;
  text-shadow: 0 1px 1px #191409;
}
.ach.is-done .ach-bar i {
  background: linear-gradient(#fdecbb, #cba233 55%, #977518);
}

/* ============================== K. Daily wheel ============================== */
.wheel-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: max(0.8em, env(safe-area-inset-top)) 0.6em max(0.8em, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 46%, rgba(52, 43, 24, 0.78), rgba(18, 15, 8, 0.94));
  z-index: 65;
  animation: fade-in 0.25s;
}
.wheel-title {
  width: min(19em, 86vw);
  height: auto;
  filter: drop-shadow(0 0.4em 0.7em rgba(14, 12, 6, 0.7));
}
.wheel-wrap {
  position: relative;
  width: min(21em, 88vw, 52vh);
  aspect-ratio: 1;
  flex: none;
}
.wheel {
  width: 100%;
  height: 100%;
}
.wheel-pointer {
  position: absolute;
  left: 50%;
  top: -5%;
  width: 14%;
  height: auto;
  translate: -50% 0;
  filter: drop-shadow(0 0.2em 0.3em rgba(14, 12, 6, 0.6));
}
.wheel-win {
  display: flex;
  align-items: center;
  gap: 0.3em;
  font-size: 2.4em;
  animation: slam 0.4s both;
}
.wheel-win img {
  width: 0.95em;
  height: 0.95em;
}
.btn-spin {
  --ph: 3.6em;
  font-size: 1.5em;
  min-width: 9em;
}
.wheel-note {
  font: 400 italic max(0.72em, 10px) var(--serif);
  color: rgba(249, 240, 215, 0.8);
  min-height: 1.2em;
}
.wheel-close {
  position: absolute;
  top: max(0.6em, env(safe-area-inset-top));
  right: 0.6em;
}

/* ============================== L. Small things ============================== */
.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  translate: -50% 0;
  --ph: 2.3em;
  max-width: 94vw;
  font: 400 max(0.85em, 11px) var(--serif);
  z-index: 80;
  animation: tip-in 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
  pointer-events: none;
}
.fatal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2em;
  background: #16120b;
  color: #fff;
  font: 400 1em / 1.4 var(--sans);
  text-align: center;
  z-index: 99;
  white-space: pre-line;
}

/* End of assets/ui/styles.css */
