/* Aces Texas Hold'em No Limit — portrait-first table UI */

:root {
  --felt: #1b5e20;
  --felt-deep: #0d3d12;
  --bar-blue: #1565c0;
  --bar-blue-hi: #42a5f5;
  --cyan: #00e5ff;
  --panel: rgba(0, 40, 20, 0.72);
  --text: #f5f5f5;
  --ink: #111;
  --gold: #ffd54f;
  --radius: 10px;
  --font: "Trebuchet MS", "Segoe UI", sans-serif;
  /* Global UI scale (fonts, info plates) */
  --ui-scale: 1;
  --opponents-scale: 1.19;
  /* Board / hole card size (--board-card-scale may grow on tall stages) */
  --card-scale: 1.2;
  --board-card-scale: 1.2;
  --card-width: 72px;
  --card-height: 80px;
  /* Actions softkey + actions popup (same control surface) */
  --softkey-scale: 1;
  --softkey-height: 56px;
  --softkey-aspect-w: 200 ;
  --softkey-aspect-h: 62;
  /* actions_menu.png strips are wider than the softkey (230×62) */
  --actions-menu-aspect-w: 230;
  --actions-menu-aspect-h: 62;
  /* Statistics / Restart stacked softkey (buttons_bada 188×124) */
  --endgame-aspect-w: 188;
  --endgame-aspect-h: 124;
  /* Design size; --stage-fit scales the whole stage uniformly.
     On portrait, --stage-design-h grows so the window fills the viewport. */
  --stage-design-w: 720px;
  --stage-design-h: 720px;
  --stage-fit: 1;
  --chrome-inset-top: 52.875px;
  --chrome-inset-right: 9px;
  --chrome-inset-bottom: 6.75px;
  --chrome-inset-left: 9px;
}

* {
  box-sizing: border-box;
}

/* Author display:flex rules otherwise override the HTML hidden attribute. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #1a120c;
  font-family: var(--font);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  /* Kill double-tap zoom; pinch still blocked via viewport + gesture handlers */
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  height: 100dvh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  /* Fill letterbox around the square stage */
  background-color: #1a120c;
  background-image: url("../assets/menus/far_background.jpg");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* Outer slot = visible size (so flex centering isn't based on the huge unscaled box).
   Inner stage keeps design coordinates and is scaled from the top-left. */
.game-stage-slot {
  position: relative;
  width: calc(var(--stage-design-w) * var(--stage-fit));
  height: calc(var(--stage-design-h) * var(--stage-fit));
  flex-shrink: 0;
  overflow: hidden;
}

.game-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--stage-design-w);
  height: var(--stage-design-h);
  transform: scale(var(--stage-fit));
  transform-origin: 0 0;
}

/* Hand / action history — inside felt, bottom-right, 85% of prior width.
   Use an explicit height (not aspect-ratio alone): iOS Safari lets flex
   content grow past aspect-ratio, so the panel would expand forever. */
.game-log {
  --game-log-w: 204px; /* 240px × 0.85 */
  --game-log-ratio: 1.22;
  --game-log-min-h: calc(var(--game-log-w) * var(--game-log-ratio));
  /* Header + a few short lines — fixed regardless of stage height */
  --game-log-compact-h: 8.2rem;
  position: absolute;
  right: 0.6%;
  bottom: 0.6%;
  top: auto;
  width: var(--game-log-w);
  max-width: 32%;
  height: var(--game-log-min-h);
  max-height: var(--game-log-min-h);
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, #0d2137C0 0%, #07101880 100%);
  border: 1px solid rgba(144, 202, 249, 0.35);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: pointer;
  transition:
    top 0.22s ease,
    height 0.22s ease,
    max-height 0.22s ease,
    box-shadow 0.22s ease,
    border-radius 0.22s ease;
}

/* Few lines only — ignores tall-stage stretch */
.game-log.is-compact {
  top: auto;
  height: var(--game-log-compact-h);
  max-height: var(--game-log-compact-h);
  z-index: 5;
}

/* Tall stage + normal size: JS sets top to keep a fixed gap under the river */
.game-log.is-tall:not(.is-compact):not(.is-expanded) {
  top: var(--game-log-top, auto);
  height: auto;
  max-height: none;
}

.game-log.is-expanded {
  top: 0.6%;
  bottom: 0.6%;
  /* Pin height so content cannot stretch the absolute box on iOS */
  height: calc(100% - 1.2%);
  max-height: calc(100% - 1.2%);
  z-index: 9;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.game-log-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #90caf9;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(144, 202, 249, 0.25);
  cursor: pointer;
  user-select: none;
}

.game-log-title {
  flex: 1 1 auto;
  min-width: 0;
}

.game-log-expand {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(144, 202, 249, 0.35);
  border-radius: 4px;
  margin: 0;
  padding: 0;
  width: 1.7rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(144, 202, 249, 0.12);
  color: #90caf9;
  cursor: pointer;
}

.game-log-expand:hover,
.game-log-expand:focus-visible {
  background: rgba(144, 202, 249, 0.28);
  outline: none;
}

.game-log-expand-icon {
  display: block;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  /* Point up — next size is larger */
  transform: rotate(-135deg);
  margin-top: 0.2rem;
  transition: transform 0.2s ease;
}

.game-log.is-expanded .game-log-expand-icon {
  /* Point down — next is compact */
  transform: rotate(45deg);
  margin-top: -0.15rem;
}

.game-log.is-compact .game-log-expand-icon {
  /* Point up — next is normal */
  transform: rotate(-135deg) scale(0.85);
  margin-top: 0.2rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game-log-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.5rem 0.75rem;
  /* flex-basis 0% + min-height 0: required for overflow scroll inside a
     column flex on iOS (basis:auto sizes to content and grows the panel). */
  flex: 1 1 0%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.game-log-entry {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
  padding: 0.28rem 0.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  line-height: 1.3;
  color: #e3f2fd;
}

.game-log-time {
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
  color: rgba(187, 222, 251, 0.55);
}

.game-log-text {
  flex: 1 1 auto;
  word-break: break-word;
}

.game-log-entry.log-fold .game-log-text {
  color: #ffab91;
}

.game-log-entry.log-win .game-log-text {
  color: #ffd54f;
  font-weight: 700;
}

.game-log-entry.log-allin .game-log-text {
  color: #80deea;
  font-weight: 700;
}

.game-log-entry.log-bet .game-log-text {
  color: #b3e5fc;
}

.game-log-entry.log-info .game-log-text {
  color: #c5cae9;
}

.game-log-divider {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.55rem 0.1rem;
  padding: 0;
  list-style: none;
  border: none;
}

.game-log-divider-line {
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(144, 202, 249, 0.45),
    transparent
  );
}

.game-log-divider-label {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(144, 202, 249, 0.55);
}

/* 9-slice frame — eight background pieces (not border-image; that drops on iOS).
   Below softkeys (.bottom-bar z-index 45) and chrome buttons (z-index 7). */
.game-border {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.game-border .gb {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-color: transparent;
}

.gb-tl {
  left: 0;
  top: 0;
  width: var(--chrome-inset-left);
  height: var(--chrome-inset-top);
}
.gb-t {
  left: var(--chrome-inset-left);
  right: var(--chrome-inset-right);
  top: 0;
  height: var(--chrome-inset-top);
}
.gb-tr {
  right: 0;
  top: 0;
  width: var(--chrome-inset-right);
  height: var(--chrome-inset-top);
}
.gb-l {
  left: 0;
  top: var(--chrome-inset-top);
  bottom: var(--chrome-inset-bottom);
  width: var(--chrome-inset-left);
}
.gb-r {
  right: 0;
  top: var(--chrome-inset-top);
  bottom: var(--chrome-inset-bottom);
  width: var(--chrome-inset-right);
}
.gb-bl {
  left: 0;
  bottom: 0;
  width: var(--chrome-inset-left);
  height: var(--chrome-inset-bottom);
}
.gb-b {
  left: var(--chrome-inset-left);
  right: var(--chrome-inset-right);
  bottom: 0;
  height: var(--chrome-inset-bottom);
}
.gb-br {
  right: 0;
  bottom: 0;
  width: var(--chrome-inset-right);
  height: var(--chrome-inset-bottom);
}

.game-chrome-top {
  position: absolute;
  left: var(--chrome-inset-left, 1.25%);
  right: var(--chrome-inset-right, 1.25%);
  top: 0;
  height: var(--chrome-inset-top, 7.35%);
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  scale: 1.5;
}

.game-chrome-top .round-label {
  font-size: calc(0.85rem * var(--ui-scale));
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

/* Plain glyphs in the top border corner cells (no chrome/background) */
.btn-chrome-corner {
  position: absolute;
  top: 0;
  z-index: 7;
  /* Corner cell is a bit wider than the top-bar height */
  --btn-corner-w: calc(var(--chrome-inset-top, 7.35%) * 1.55);
  width: var(--btn-corner-w);
  height: var(--chrome-inset-top, 7.35%);
  margin: 0;
  padding: 0;
  appearance: none;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.92);
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(2rem * var(--ui-scale));
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.btn-chrome-corner:active {
  color: #fff;
  transform: translateY(1px);
}

.btn-new-game {
  left: 0;
  /* Slight optical nudge — "+" sits a bit high vs "i" */
  padding-bottom: 0.08em;
  font-size: calc(2.15rem * var(--ui-scale));
}

.btn-info {
  right: 0;
}

.game-inner {
  position: absolute;
  left: var(--chrome-inset-left, 1.25%);
  right: var(--chrome-inset-right, 1.25%);
  top: var(--chrome-inset-top, 7.35%);
  bottom: var(--chrome-inset-bottom, 0.95%);
  z-index: 1;
  overflow: hidden;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  background: var(--felt-deep);
}

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  /* Allow bet-pad glow to paint; table art still clipped by .game-inner */
  overflow: visible;
}

/* Title */
.screen-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: #0d2137 url("../assets/menus/background.jpg") center/cover no-repeat;
}

.title-splash {
  width: min(92%, 360px);
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.title-logo {
  width: 120px;
  height: auto;
  opacity: 0.9;
}

.title-sub {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.8;
}

.btn-primary,
.btn-secondary {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 2.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--bar-blue-hi), var(--bar-blue));
  box-shadow: 0 4px 0 #0d47a1;
}

.btn-secondary {
  background: linear-gradient(180deg, #78909c, #455a64);
  box-shadow: 0 4px 0 #263238;
  margin-top: 0.5rem;
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Table */
.screen-table {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at center, rgba(46, 125, 50, 0.55), transparent 70%),
    url("../assets/table/game_background_800x800_24bit.png") center/cover no-repeat,
    var(--felt);
  /* Extend to the bottom of game-inner; softkeys (bottom-bar) paint on top */
  padding-bottom: 0;
}

.opponents {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: calc(0.45rem * var(--opponents-scale));
  padding: calc(0.6rem * var(--opponents-scale)) calc(0.4rem * var(--opponents-scale));
  /* Scale seats as a group and nudge down slightly */
  transform: scale(var(--opponents-scale));
  transform-origin: top center;
  margin-top: 0.85rem;
  margin-bottom: 1.25rem;
}

.seat {
  position: relative;
  width: 110px;
  flex: 0 0 auto;
  text-align: center;
  padding: 0.3rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.seat-active {
  outline: 2px solid var(--cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.55);
}

.seat-folded {
  opacity: 0.45;
}

.seat-out {
  opacity: 0.3;
  filter: grayscale(0.8);
}

.seat-face {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.2rem;
  border-radius: 6px;
  background-color: #333;
  background-repeat: no-repeat;
  /* border: 2px solid rgba(255, 255, 255, 0.25); */
}

.seat-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.seat-stack {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
}

/* Physical chip piles (chips_xtralarge_24bit.png) — zig-zag offsets in JS.
   Sized at 75% of the original chip art footprint. */
.chip-tray {
  --chip-scale: 0.75;
  position: relative;
  display: block;
  margin: 0.7rem auto 0.05rem;
  min-width: calc(40px * var(--chip-scale));
  min-height: calc(22px * var(--chip-scale));
  overflow: visible;
}

.chip-stack {
  position: absolute;
  width: calc(26px * var(--chip-scale));
  height: calc(22px * var(--chip-scale));
}

.chip {
  position: absolute;
  left: 0;
  width: calc(26px * var(--chip-scale));
  height: calc(15px * var(--chip-scale));
  background-repeat: no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.human-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin-top: 0.25rem;
}

.human-stack .chip-tray {
  min-height: calc(26px * var(--chip-scale));
}

.human-stack .chip-stack {
  width: calc(32px * var(--chip-scale));
  height: calc(26px * var(--chip-scale));
}

.human-stack .chip {
  width: calc(32px * var(--chip-scale));
  height: calc(18px * var(--chip-scale));
}

.seat-cards {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 0.25rem;
}


.dealer-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eee;
  color: #111;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #999;
}

.table-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem;
  min-height: 0;
}

.status-msg {
  margin: 0;
  font-weight: 800;
  font-size: calc(1.1rem * var(--ui-scale));
  color: #fff;
  text-shadow: 0 2px 4px #000;
  min-height: 1.4em;
  text-align: center;
}

.board-cards,
.hole-cards {
  display: flex;
  gap: calc(0.35rem * var(--board-card-scale));
  justify-content: center;
  flex-wrap: nowrap;
  min-height: calc(var(--card-height) * var(--board-card-scale));
}

.hole-cards {
  margin-top: 0.25rem;
}

.card {
  /* layout.xml large card aspect 43×48; seat cards use --card-scale */
  width: calc(var(--card-width) * var(--card-scale));
  height: calc(var(--card-height) * var(--card-scale));
  border-radius: calc(4px * var(--card-scale));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  background-color: #fff;
}

.board-cards .card,
.hole-cards .card {
  width: calc(var(--card-width) * var(--board-card-scale));
  height: calc(var(--card-height) * var(--board-card-scale));
  border-radius: calc(4px * var(--board-card-scale));
}

.card-sprite:not(.card-back) {
  /* background-* set in JS to crop face-only from tmpl sheet */
  background-repeat: no-repeat;
}

/* Positions/sizes set in JS (cribbage CardNode layout). Do not use max-height —
   it was breaking aspect-ratio and distorting the detail sprite crop. */
.cs-detail,
.cs-rank,
.cs-suit {
  position: absolute;
  box-sizing: border-box;
  background-repeat: no-repeat;
  transform: none;
}

.cs-rank,
.cs-suit {
  z-index: 2;
}

.card-back {
  background: linear-gradient(135deg, #b71c1c, #e53935 40%, #b71c1c);
  padding: 3px;
}

.card-back-pattern {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.15) 0 4px,
      transparent 4px 8px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.12) 0 4px,
      transparent 4px 8px
    );
}

.card-hl {
  outline: 2px solid var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.seat-cards .card {
  width: calc(40px * var(--card-scale));
  height: calc(45px * var(--card-scale));
  border-radius: calc(3px * var(--card-scale));
}

.info-row {
  display: flex;
  gap: calc(0.5rem * var(--ui-scale));
  padding: 0 calc(0.75rem * var(--ui-scale));
  justify-content: center;
  align-items: stretch;
}

.info-panel {
  /* Background from game_table_transparent.png (top/bottom half via JS) */
  background-color: transparent;
  border-radius: 0;
  padding: calc(0.55rem * var(--ui-scale)) calc(0.9rem * var(--ui-scale));
  font-size: calc(0.85rem * var(--ui-scale));
  font-weight: 700;
  color: #e8f5e9;
  min-width: calc(130px * var(--ui-scale));
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.info-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.25);
  margin: calc(0.25rem * var(--ui-scale)) 0;
}

.bankroll {
  text-align: center;
  font-size: calc(1.35rem * var(--ui-scale));
  font-weight: 800;
  color: var(--ink);
  margin: calc(0.4rem * var(--ui-scale)) 0 0.2rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Softkeys flush to bottom-left of the stage window */
.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  /* Above border (6) / chrome (7) / actions menu (7); below overlays (40) */
  z-index: 15;
  pointer-events: none;
}

/* Soft buttons (Actions) — size via --softkey-* in :root */
.btn-sprite {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  background-color: transparent;
  background-repeat: no-repeat;
  color: transparent;
  text-shadow: none;
  overflow: hidden;
  pointer-events: auto;
  display: block;
  position: relative;
  z-index: 1;
  height: calc(var(--softkey-height) * var(--softkey-scale));
  width: calc(
    var(--softkey-height) * var(--softkey-scale) * var(--softkey-aspect-w) /
      var(--softkey-aspect-h)
  );
  aspect-ratio: var(--softkey-aspect-w) / var(--softkey-aspect-h);
}

/* CSS fallback sprite (buttons_bada actions @ 300,372 188×62) — JS may override */
#btn-actions {
  background-image: url("../assets/table/buttons_bada.png");
  background-size: calc(488 / 188 * 100%) calc(863 / 62 * 100%);
  background-position: 100% calc(372 / (863 - 62) * 100%);
  background-repeat: no-repeat;
}

/* No separate pressed art — slight press only.
   #btn-actions is excluded: pressed only while its menu is open. */
.btn-sprite:active:not(#btn-actions),
.btn-sprite.is-pressed:not(#btn-actions),
#btn-actions.is-pressed {
  filter: brightness(1.08);
  transform: translateY(1px);
}

#btn-actions:active:not(.is-pressed) {
  filter: none;
  transform: none;
}

/* Winner-screen Statistics (top) + Restart (bottom) softkey pair */
.endgame-softkeys {
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  height: calc(
    var(--softkey-height) * var(--softkey-scale) * var(--endgame-aspect-h) /
      var(--softkey-aspect-h)
  );
  width: calc(
    var(--softkey-height) * var(--softkey-scale) * var(--endgame-aspect-w) /
      var(--softkey-aspect-h)
  );
  aspect-ratio: var(--endgame-aspect-w) / var(--endgame-aspect-h);
}

.endgame-hit {
  flex: 1 1 50%;
  appearance: none;
  border: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  color: transparent;
  text-shadow: none;
  background-color: transparent;
  background-repeat: no-repeat;
}

/* Overlays — on #game-stage */
.overlay-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92%, 280px);
  z-index: 40;
  background: linear-gradient(180deg, #1e88e5, #0d47a1);
  border: 3px solid #90caf9;
  border-radius: 14px;
  padding: 0.85rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* Actions menu — size via --softkey-scale / --actions-menu-aspect-* in :root.
   z-index below .bottom-bar (8) so the Actions softkey paints over the anchor. */
.actions-menu {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: calc(
    var(--softkey-height) * var(--softkey-scale) * var(--actions-menu-aspect-w) /
      var(--actions-menu-aspect-h)
  );
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

.actions-menu-items {
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.actions-menu-item {
  appearance: none;
  border: none;
  margin: 0;
  padding: 0 0.75rem;
  box-sizing: border-box;
  cursor: pointer;
  color: #fff;
  font-family: var(--font);
  font-size: calc(1.6rem * var(--softkey-scale));
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  background-color: transparent;
  background-repeat: no-repeat;
  /* Sheet art is quite dark navy — lift it to match table chrome */
  filter: brightness(1.45) saturate(1.2);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--softkey-height) * var(--softkey-scale));
  width: 100%;
}

.actions-menu-item:disabled {
  cursor: not-allowed;
  pointer-events: none;
  filter: brightness(.75) saturate(0);
}

/* Pressed = highlighted (cyan) strip — JS also swaps background-position */
.actions-menu-item:active:not(:disabled),
.actions-menu-item.is-pressed:not(:disabled) {
  filter: brightness(1.15) saturate(1.25);
}

/* Mesh strip behind Actions — wider than the softkey so it remains visible */
.actions-menu-anchor {
  flex: 0 0 auto;
  pointer-events: none;
  background-repeat: no-repeat;
  filter: brightness(1.55) saturate(1.15);
  height: calc(var(--softkey-height) * var(--softkey-scale));
  width: 100%;
  min-height: calc(var(--softkey-height) * var(--softkey-scale));
}

/* Bet keypad centered in the stage */
.overlay-panel.betbox {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  max-height: none;
  overflow: visible;
}

/* All-In confirmation — centered, art from allin_bada */
.overlay-panel.allin-confirm {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.5rem !important;
  width: auto !important;
  max-width: 96%;
  overflow: visible !important;
}

.allin-pad {
  position: relative;
  width: min(84vw, 320px);
  max-width: 100%;
  background-repeat: no-repeat;
  overflow: visible;
}

.allin-highlight {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  background-repeat: no-repeat;
}

.allin-hit {
  position: absolute;
  appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

.overlay-panel h2 {
  margin: 0 0 0.25rem;
  text-align: center;
  font-size: 1.2rem;
}

.btn-action {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: calc(0.7rem * var(--ui-scale));
  font-size: calc(1rem * var(--ui-scale));
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #64b5f6, #1565c0);
  cursor: pointer;
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-muted {
  background: linear-gradient(180deg, #90a4ae, #546e7a);
}

/* Full dark keypad unit; hit targets are transparent overlays */
.betbox {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.75rem !important;
  width: auto !important;
  max-width: 96%;
  overflow: visible !important;
}

.betbox-pad {
  position: relative;
  width: min(78vw, 300px);
  max-width: 100%;
  background-repeat: no-repeat;
  /* Keep baked PNG glow/shadow from being clipped by ancestors */
  overflow: visible;
  /* aspect-ratio set from chrome-layout.js */
}

.betbox-amount {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0.35rem;
  background: transparent;
  color: #111;
  text-align: center;
  font-size: calc(3rem * var(--ui-scale));
  font-weight: 800;
  border-radius: 0;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 1;
}

.bet-hit {
  position: absolute;
  appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

/* Cyan highlight sprite only while pressed (image applied via JS; URL must
   resolve from this stylesheet, so chrome-layout uses ../assets/...) */
.bet-hit::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--hi-image, none);
  background-size: var(--hi-size, 100% 100%);
  background-position: var(--hi-pos, 0 0);
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}

.bet-hit:active::after,
.bet-hit.is-pressed::after {
  opacity: 1;
}

.betbox .btn-muted {
  margin-top: 0.35rem;
}

/* Congrats — winner art fills the screen */
.screen-congrats {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem;
  overflow: hidden;
  background: #0d3d12;
}

.congrats-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}

.congrats-text {
  position: relative;
  z-index: 1;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

.stats-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.new-game-panel {
  width: min(92%, 320px);
  gap: 0.75rem;
}

.new-game-panel h2 {
  margin: 0;
  font-size: 1.25rem;
  text-align: center;
}

.new-game-body {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
}

.new-game-actions {
  display: flex;
  gap: 0.5rem;
}

.new-game-actions .btn-action {
  flex: 1 1 0;
}

.stats-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.stats-body dt {
  margin: 0;
  opacity: 0.85;
}

.stats-body dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

/* Rules / hand-ranking help */
.info-help-panel {
  width: min(92%, 400px);
  max-height: min(88%, 560px);
  gap: 0.55rem;
  overflow: hidden;
}

.info-help-panel h2 {
  margin: 0;
  font-size: 1.25rem;
  text-align: center;
  flex: 0 0 auto;
}

.info-help-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  text-align: left;
  font-size: calc(0.82rem * var(--ui-scale));
  line-height: 1.4;
  padding-right: 0.15rem;
}

.info-help-body h3 {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.95em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #bbdefb;
}

.info-help-body h3:first-child {
  margin-top: 0;
}

.info-help-body p {
  margin: 0 0 0.45rem;
  color: #e3f2fd;
}

.info-help-body ol {
  margin: 0 0 0.45rem;
  padding-left: 1.25rem;
  color: #e3f2fd;
}

.info-help-body li {
  margin: 0.2rem 0;
}

.info-help-body .hand-ranks li {
  margin: 0.28rem 0;
}

.info-help-panel .btn-action {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.chip-legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
}

.chip-legend-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chip-legend-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  background-repeat: no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

.chip-legend-label {
  color: #e3f2fd;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

