* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --panel: #111923;
  --panel-deep: #070c12;
  --steel: #49627b;
  --lime: #83f23b;
  --gold: #ffbd22;

  /* Display-cutout insets, resolved once here so the breakpoints below only
     have to restate the design numbers (index.html sets viewport-fit=cover). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --topbar-h: 104px;
  --topbar-pad-x: 18px;
  --topbar-pad-top: 8px;
  --rail-top: 34px;
  --controls-gap: 16px;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #070b10;
  color: #fff;
  font-family: "Arial Black", "Segoe UI", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  /* stop Android Chrome's pull-to-refresh and iOS rubber-banding mid-round */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
/* suppresses the double-tap-to-zoom delay/gesture without disabling pinch-zoom */
button, input, .preset, .toggle-switch { touch-action: manipulation; }
#app { position: relative; width: 100%; height: 100%; }
#game-container { position: absolute; inset: 0; }
#game-container canvas { display: block; touch-action: none; }

/* ---------- boot splash ---------- */
/* Ported from the sibling Phaser preloaders (Blackjack-Mania
   src/scenes/game-preloader.js plus the "loading" block of its config.json):
   company stamp on black, a soft white bar revealed left-to-right, percentage
   underneath. Those scenes lay everything out in design pixels multiplied by
   the letterbox fit min(w/1920, h/1080) (utils.js getScale), so --px restates
   that unit here and every offset below is the config's raw number.
   --pull-up centres the group the way the scene does: its logo sits above the
   viewport centre, so the block is not vertically centred as a whole. */
#boot-splash {
  --px: min(0.0520833vw, 0.0925926vh);
  --bar-w: calc(1000 * var(--px));
  --pull-up: calc(83.5 * var(--px));
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: var(--pull-up);
  background: #000;
  transition: opacity .3s ease;
}
#boot-splash .splash-brand {
  width: calc(472 * var(--px));
  height: calc(297 * var(--px));
}
#boot-splash .splash-bar {
  width: var(--bar-w);
  /* floor keeps the bar visible once the fit scale gets very small */
  height: max(2px, calc(8 * var(--px)));
  margin-top: calc(97.5 * var(--px));
  overflow: hidden;
}
#boot-splash .splash-bar i {
  display: block;
  width: 0;
  height: 100%;
  /* progress-bar.png is a white streak whose alpha peaks mid-bar and fades to
     nothing at both ends, and the scene reveals it by cropping — so the
     gradient is pinned to the full bar width and only the clip grows. */
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 50%, rgba(255, 255, 255, 0));
  background-size: var(--bar-w) 100%;
  background-repeat: no-repeat;
  transition: width .2s linear;
}
#splash-percent {
  margin-top: calc(51 * var(--px));
  color: #fff;
  /* the sibling scenes set this readout in a condensed face, so it deliberately
     opts out of the Arial Black body stack */
  font-family: "Arial Narrow", "Segoe UI Semilight", "Segoe UI", Arial, sans-serif;
  font-size: calc(40 * var(--px));
  font-weight: 400;
  line-height: 1;
}
/* portrait numbers come from the config's second orientation block, where the
   design surface is 1080x1920 and the stamp carries a 1.5 scale */
@media (orientation: portrait) {
  #boot-splash {
    --px: min(0.0925926vw, 0.0520833vh);
    --pull-up: calc(258 * var(--px));
  }
  #boot-splash .splash-brand { width: calc(708 * var(--px)); height: calc(445.5 * var(--px)); }
  #boot-splash .splash-bar { margin-top: calc(223.25 * var(--px)); }
  #splash-percent { margin-top: calc(111 * var(--px)); font-size: calc(80 * var(--px)); }
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.label {
  color: #d5dfeb;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.5px;
  line-height: 1;
  text-shadow: 0 2px 2px #000;
}

/* ---------- steel top rail ---------- */
#topbar {
  /* positioned so ::after resolves against the rail itself, not #hud */
  position: relative;
  height: calc(var(--topbar-h) + var(--safe-top));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(var(--topbar-pad-top) + var(--safe-top)) calc(var(--topbar-pad-x) + var(--safe-right))
           var(--topbar-pad-top) calc(var(--topbar-pad-x) + var(--safe-left));
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(25, 39, 54, .14) 18% 82%, transparent 88%),
    linear-gradient(180deg, rgba(3, 7, 13, .98) 0 38%, rgba(3, 7, 13, .78) 58%, transparent 100%);
  border-top: 2px solid #1a2a3b;
}

#topbar::after {
  content: "";
  position: absolute;
  top: calc(var(--rail-top) + var(--safe-top));
  left: 12%;
  right: 8%;
  height: 5px;
  border-radius: 5px;
  background: linear-gradient(90deg, #18283b, #7890a4 18%, #182334 43%, #8d6928 55%, #18324a 75%, #25384b);
  box-shadow: 0 1px 0 #000, 0 0 8px rgba(91, 141, 192, .32);
  opacity: .8;
}

.brand {
  position: relative;
  z-index: 2;
  width: 178px;
  height: auto;
  margin-top: -5px;
  filter: drop-shadow(0 4px 4px #000) drop-shadow(0 0 8px rgba(255, 173, 22, .2));
}

.top-actions { display: flex; align-items: center; gap: 16px; pointer-events: auto; z-index: 2; }

.balance-box, #menu-button {
  background: linear-gradient(180deg, #111a25, #05090e);
  border: 2px solid #31475d;
  box-shadow: inset 0 0 0 3px #05080c, 0 3px 9px #000, 0 0 7px rgba(96, 151, 203, .24);
}

.balance-box {
  min-width: 218px;
  /* backend-driven currencies (IDR, VND, COP) produce far longer strings than
     USD — the box may grow, but never past the space the menu button needs */
  max-width: min(46vw, 420px);
  min-height: 70px;
  border-radius: 17px;
  padding: 10px 17px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#balance {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--lime);
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 8px rgba(105, 255, 54, .38);
}

#menu-button {
  width: 80px;
  height: 70px;
  border-radius: 17px;
  display: grid;
  place-content: center;
  gap: 7px;
  cursor: pointer;
}
#menu-button span { display: block; width: 32px; height: 4px; border-radius: 4px; background: #8ec8f2; box-shadow: 0 0 6px #529bda; }

/* ---------- bottom arcade console ---------- */
#controls {
  pointer-events: auto;
  width: min(1420px, calc(100% - 44px - var(--safe-left) - var(--safe-right)));
  min-height: 154px;
  /* clears the home indicator / gesture bar */
  margin: 0 auto calc(var(--controls-gap) + var(--safe-bottom));
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 345px);
  align-items: center;
  gap: 20px;
  border: 3px solid #31475d;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(27, 39, 52, .98), rgba(7, 12, 18, .99));
  box-shadow: inset 0 0 0 4px #080d13, inset 0 2px 1px #72859a, 0 5px 20px #000, 0 0 12px rgba(83, 126, 166, .32);
}

#bet-panel {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2vw, 28px);
}

.bet-adjust { flex: 0 1 410px; min-width: 250px; text-align: center; }
.bet-row { display: grid; grid-template-columns: 70px minmax(110px, 1fr) 70px; align-items: center; gap: 14px; margin-top: 7px; }

#bet-input, .stepper {
  height: 68px;
  color: #fff;
  background: linear-gradient(180deg, #111923, #080d13);
  border: 2px solid #54a722;
  box-shadow: inset 0 0 0 2px #030609, 0 2px 7px #000;
  outline: none;
}

#bet-input { width: 100%; border-radius: 15px; text-align: center; font-size: 32px; font-weight: 900; }
.stepper { border-radius: 16px; font-size: 42px; font-family: Arial, sans-serif; font-weight: 700; cursor: pointer; }

#bet-presets { display: flex; flex: 0 1 auto; justify-content: center; align-items: center; gap: 9px; min-width: 0; }

.preset {
  --chip: #168530;
  --chip-light: #80ee66;
  flex: 0 1 74px;
  width: clamp(54px, 5vw, 74px);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  border: 5px dashed #ecfff1;
  outline: 4px solid var(--chip);
  outline-offset: -4px;
  color: #fff;
  background: radial-gradient(circle, #172219 0 35%, var(--chip) 37% 61%, var(--chip-light) 64% 100%);
  box-shadow: inset 0 0 0 4px #e9f1e9, inset 0 0 0 7px var(--chip), 0 4px 5px #000, 0 0 8px color-mix(in srgb, var(--chip-light), transparent 55%);
  text-shadow: 0 2px 2px #000;
  font-size: clamp(14px, 1.45vw, 21px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .1s ease, filter .1s ease;
}
.preset:nth-child(2) { --chip: #1767aa; --chip-light: #69b9f2; }
.preset:nth-child(3) { --chip: #8721a8; --chip-light: #db63f0; }
.preset:nth-child(4) { --chip: #b52b28; --chip-light: #ff7465; }
.preset:nth-child(5) { --chip: #b47a0b; --chip-light: #ffc946; }
.preset:nth-child(6) { --chip: #315b82; --chip-light: #80b4df; }
.preset:disabled, .stepper:disabled, #bet-input:disabled { filter: grayscale(.72) brightness(.55); cursor: default; }

#action-panel { display: flex; width: 100%; gap: 10px; }
.big-btn {
  position: relative;
  min-width: 0;
  width: 100%;
  min-height: 104px;
  padding: 11px 18px;
  border: 5px solid #b9ff70;
  border-radius: 23px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 900;
  box-shadow: inset 0 0 0 4px #367900, inset 0 5px 8px rgba(255,255,255,.34), 0 0 0 4px #172516, 0 0 16px rgba(126, 255, 30, .42), 0 5px 8px #000;
  transition: transform .08s ease, filter .12s ease;
}
.big-btn::before, .big-btn::after { content: "»"; position: absolute; font-size: 38px; color: #b7ff45; text-shadow: 0 2px 2px #285700; }
.big-btn::before { margin-left: -85%; }
.big-btn::after { margin-left: 85%; }
.big-btn:active:not(:disabled) { transform: translateY(2px); }
.big-btn:disabled { filter: grayscale(.72) brightness(.58); cursor: default; }
.big-btn.play, .big-btn.cashout { background: linear-gradient(180deg, #67ca16 0, #3d9a06 48%, #266f02 100%); font-size: 42px; }
.big-btn.go { background: linear-gradient(180deg, #ffc54a, #db8115); color: #402300; border-color: #fff0a6; box-shadow: inset 0 0 0 4px #aa5707, inset 0 5px 8px rgba(255,255,255,.4), 0 0 0 4px #2a1d0c, 0 0 16px rgba(255, 184, 38, .4); }
.btn-title { font-size: 28px; letter-spacing: 1px; }
.btn-sub { font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; font-weight: 800; }

/* ---------- messages and win card ---------- */
#message { position: absolute; left: 50%; top: calc(105px + var(--safe-top)); max-width: calc(100% - 32px); transform: translateX(-50%); text-align: center; color: #ffd83d; font-size: 17px; font-weight: 900; text-shadow: 0 2px 6px #000; opacity: 0; transition: opacity .25s ease; }
#message.show { opacity: 1; }
#popup { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(3, 6, 10, .62); pointer-events: none; }
#popup-card { min-width: 330px; padding: 34px 64px; text-align: center; border: 3px solid var(--gold); border-radius: 22px; background: radial-gradient(circle at 50% 0, #2b4055, #0b1119 70%); box-shadow: inset 0 0 0 4px #090d12, 0 0 55px rgba(255, 190, 29, .4); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#popup-title { color: var(--gold); font-size: 26px; font-weight: 900; letter-spacing: 3px; }
#popup-amount { color: var(--lime); font-size: 44px; font-weight: 900; margin: 8px 0 2px; }
#popup-mult { color: #afc1d4; font-size: 18px; }
.hidden { display: none !important; }

/* ---------- translated hamburger menu + popups ---------- */
#menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
           calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  pointer-events: auto;
  background: rgba(2, 5, 9, .76);
  backdrop-filter: blur(5px);
}

#menu-card {
  /* Shared by the card and its views so a view can scroll inside the card
     instead of being silently clipped (landscape phones are far shorter than
     the settings/rules content). */
  --menu-max-h: min(760px, calc(100dvh - 48px - var(--safe-top) - var(--safe-bottom)));
  position: relative;
  width: min(620px, 94vw);
  max-height: var(--menu-max-h);
  overflow: hidden;
  border: 3px solid #49647e;
  border-radius: 25px;
  background: radial-gradient(circle at 50% 0, #263b50 0, #101923 46%, #070c12 100%);
  box-shadow: inset 0 0 0 4px #060a0f, inset 0 2px 1px #7b91a5, 0 0 45px rgba(38, 116, 174, .36), 0 12px 34px #000;
}

.menu-close {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 18px;
  width: 47px;
  height: 47px;
  border: 2px solid #5b7792;
  border-radius: 13px;
  color: #dff3ff;
  background: linear-gradient(180deg, #1f3041, #0b121b);
  box-shadow: inset 0 0 0 2px #070b10, 0 2px 6px #000;
  font: 800 30px/1 Arial, sans-serif;
  cursor: pointer;
}

.menu-view {
  max-height: var(--menu-max-h);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 40px 46px 38px;
}
.menu-view h2 {
  margin: 0 55px 28px;
  color: #ffd13b;
  text-align: center;
  font-size: 32px;
  letter-spacing: 3px;
  text-shadow: 0 2px 4px #000, 0 0 12px rgba(255, 193, 36, .28);
}

.menu-actions { display: grid; gap: 14px; }
.menu-action {
  min-height: 62px;
  padding: 10px 22px;
  border: 2px solid #52708d;
  border-radius: 15px;
  color: #f3f8fc;
  background: linear-gradient(180deg, #263c50, #111d29);
  box-shadow: inset 0 0 0 2px #0a1017, inset 0 3px 5px rgba(255,255,255,.08), 0 3px 8px #000;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
}
.menu-action:active { transform: translateY(1px); }
.menu-back { width: 180px; min-height: 52px; margin: 24px auto 0; display: block; }

/* ---------- blocking error popup (src/error-handler.js) ---------- */
/* z-index sits above the menu (40) and the win card (20): an error can be
   raised while either is open, and it must never end up behind them. */
#error-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
           calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  pointer-events: auto;
  background: rgba(2, 5, 9, .82);
  backdrop-filter: blur(5px);
}

#error-card {
  width: min(560px, 94vw);
  max-height: calc(100dvh - 48px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 38px 42px 32px;
  text-align: center;
  border: 3px solid #b8514a;
  border-radius: 25px;
  background: radial-gradient(circle at 50% 0, #3d2630 0, #1a1017 46%, #0b0709 100%);
  box-shadow: inset 0 0 0 4px #0a0507, inset 0 2px 1px #a5757b, 0 0 45px rgba(174, 58, 48, .34), 0 12px 34px #000;
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}

#error-title {
  margin: 0 0 18px;
  color: #ffcf6b;
  /* the Phaser siblings uppercase this in code (popup-error.js `.toUpperCase()`);
     the backend strings are sentence case, so do it here */
  text-transform: uppercase;
  font-size: 30px;
  letter-spacing: 3px;
  text-shadow: 0 2px 4px #000, 0 0 12px rgba(255, 178, 36, .26);
}

#error-description {
  margin: 0 auto 26px;
  max-width: 430px;
  color: #e2d3d6;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

/* reuses .menu-action for shape/typography, restyled to the popup's palette */
#error-action {
  width: min(240px, 100%);
  margin: 0 auto;
  border-color: #a8615c;
  background: linear-gradient(180deg, #5a2f35, #2a161c);
}

#error-code {
  margin-top: 16px;
  color: #8d7679;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

#menu-rules-description {
  margin: -12px auto 20px;
  max-width: 490px;
  color: #c3d1de;
  text-align: center;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}
.rules-scroll { max-height: min(430px, 52vh); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-right: 5px; }
.rules-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.rules-table th { padding: 5px 15px; color: #90a9be; font-size: 12px; letter-spacing: 1.5px; text-align: left; }
.rules-table th:last-child, .rules-table td:last-child { text-align: right; }
.rules-table td { padding: 10px 15px; background: rgba(21, 34, 46, .92); border-top: 1px solid #31485c; border-bottom: 1px solid #172634; font-family: "Segoe UI", Arial, sans-serif; font-weight: 800; }
.rules-table td:first-child { border-left: 1px solid #31485c; border-radius: 10px 0 0 10px; }
.rules-table td:last-child { border-right: 1px solid #31485c; border-radius: 0 10px 10px 0; color: #ffd13b; }

.settings-list { display: grid; gap: 18px; margin: 45px 0; }
.settings-row {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px 14px 24px;
  border: 1px solid #31485c;
  border-radius: 16px;
  background: rgba(10, 18, 26, .72);
  font-size: 18px;
  font-weight: 900;
}
.toggle-switch {
  position: relative;
  width: 112px;
  height: 49px;
  flex: 0 0 auto;
  border: 2px solid #43576b;
  border-radius: 25px;
  color: #8798a8;
  background: #111923;
  cursor: pointer;
  transition: .18s ease;
}
.toggle-switch span { position: absolute; top: 6px; left: 7px; width: 33px; height: 33px; border-radius: 50%; background: #8292a0; box-shadow: 0 2px 4px #000; transition: .18s ease; }
.toggle-switch b { position: absolute; right: 13px; top: 14px; font: 900 13px/1 "Segoe UI", Arial, sans-serif; }
.toggle-switch.active { border-color: #78dc3e; color: #dffff0; background: #285f18; box-shadow: 0 0 10px rgba(108, 240, 55, .2); }
.toggle-switch.active span { left: 68px; background: #8df35c; }
.toggle-switch.active b { left: 13px; right: auto; }

/* ---------- pointer- and keyboard-conditional affordances ---------- */

/* On touch, :hover latches after a tap and stays applied until the player taps
   elsewhere — chips would sit raised and buttons stay lit. Gate every hover
   affordance behind a real pointing device. */
@media (hover: hover) and (pointer: fine) {
  .stepper:hover:not(:disabled) { filter: brightness(1.28); }
  .preset:hover:not(:disabled) { transform: translateY(-3px) scale(1.04); filter: brightness(1.12); }
  .big-btn:hover:not(:disabled) { filter: brightness(1.14); transform: translateY(-2px); }
  .menu-close:hover { filter: brightness(1.25); }
  .menu-action:hover { border-color: #91c8ef; filter: brightness(1.16); transform: translateY(-1px); }
}

/* #bet-input and .stepper clear their outline for the arcade look, which left
   keyboard users with no focus indicator at all. */
:focus-visible {
  outline: 3px solid #8ec8f2;
  outline-offset: 3px;
}
#bet-input:focus-visible { outline-offset: 0; }
.preset:focus-visible { outline-offset: 5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .preset, .big-btn, .menu-action { transform: none !important; }
}

@media (max-width: 520px) {
  #menu-overlay {
    padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right))
             calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
  }
  #menu-card {
    --menu-max-h: calc(100dvh - 20px - var(--safe-top) - var(--safe-bottom));
    border-radius: 20px;
  }
  .menu-view { padding: 30px 20px 24px; }
  .menu-view h2 { margin-bottom: 22px; font-size: 25px; }
  .menu-close { top: 10px; right: 11px; width: 42px; height: 42px; }
  .menu-action { min-height: 53px; font-size: 17px; }
  .rules-scroll { max-height: 48vh; }
  .settings-row { min-height: 70px; padding-left: 15px; font-size: 15px; }
}

@media (max-width: 1050px) {
  :root { --controls-gap: 8px; }
  #controls { width: calc(100% - 20px - var(--safe-left) - var(--safe-right)); min-height: 132px; padding: 12px; grid-template-columns: minmax(0, 1fr) minmax(205px, 28%); gap: 12px; }
  #bet-panel { gap: 13px; }
  .bet-adjust { min-width: 205px; }
  .bet-row { grid-template-columns: 50px minmax(90px, 1fr) 50px; gap: 8px; }
  #bet-input, .stepper { height: 56px; }
  #bet-input { font-size: 24px; }
  .stepper { font-size: 32px; }
  .big-btn { min-height: 88px; }
  .big-btn.play, .big-btn.cashout { font-size: 32px; }
}

@media (max-width: 720px) {
  :root { --topbar-h: 76px; --topbar-pad-x: 8px; --topbar-pad-top: 5px; --rail-top: 25px; }
  .brand { width: 112px; }
  .top-actions { gap: 7px; }
  .balance-box { min-width: 140px; min-height: 54px; padding: 7px 10px; border-radius: 13px; gap: 4px; }
  #balance { font-size: 15px; }
  #menu-button { width: 54px; height: 54px; border-radius: 13px; gap: 5px; }
  #menu-button span { width: 24px; height: 3px; }
  #controls { min-height: 0; grid-template-columns: 1fr; gap: 8px; border-radius: 20px; padding: 9px; }
  #bet-panel { width: 100%; }
  .bet-adjust { min-width: 180px; flex: 1 1 45%; }
  #bet-presets { flex: 1 1 55%; gap: 5px; }
  .preset { width: clamp(44px, 9vw, 58px); border-width: 4px; font-size: 13px; }
  #action-panel { justify-content: center; }
  .big-btn { max-width: 370px; min-height: 62px; border-radius: 17px; }
  .big-btn.play, .big-btn.cashout { font-size: 27px; }
  .btn-title { font-size: 21px; }
  #message { top: calc(77px + var(--safe-top)); font-size: 14px; }
}

@media (max-width: 500px) {
  .brand { width: 94px; }
  .balance-box { min-width: 112px; }
  #menu-button { width: 48px; }
  #bet-panel { flex-direction: column; gap: 7px; }
  .bet-adjust { width: 100%; min-width: 0; flex-basis: auto; }
  .bet-row { grid-template-columns: 48px minmax(85px, 1fr) 48px; }
  #bet-input, .stepper { height: 44px; }
  #bet-input { font-size: 19px; }
  #bet-presets { width: 100%; }
  /* 44px floor keeps the chips at the minimum comfortable touch-target size */
  .preset { width: clamp(44px, 12vw, 56px); }
}

@media (max-height: 520px) {
  /* --rail-top deliberately left at its inherited value so the steel rail sits
     exactly where it does today at this breakpoint */
  :root { --topbar-h: 60px; --controls-gap: 5px; }
  .brand { width: 88px; }
  .balance-box { min-height: 45px; padding: 5px 10px; }
  #menu-button { width: 48px; height: 45px; }
  #controls { min-height: 92px; padding: 7px 10px; grid-template-columns: minmax(0, 1fr) minmax(180px, 28%); }
  #bet-panel { flex-direction: row; }
  .bet-adjust { min-width: 175px; width: auto; }
  .bet-row { margin-top: 3px; grid-template-columns: 42px minmax(75px, 1fr) 42px; }
  #bet-input, .stepper { height: 40px; }
  #bet-input { font-size: 17px; }
  .preset { width: clamp(44px, 8vh, 49px); font-size: 11px; border-width: 3px; }
  .big-btn { min-height: 66px; }
  .big-btn.play, .big-btn.cashout { font-size: 27px; }
  #message { top: calc(60px + var(--safe-top)); }

  /* Landscape phones are ~390px tall but match on height, not width, so the
     max-width:520px compaction never applied here — the settings and rules
     views overflowed the card and their BACK button became unreachable. */
  #menu-card { --menu-max-h: calc(100dvh - 20px - var(--safe-top) - var(--safe-bottom)); border-radius: 18px; }
  #menu-overlay {
    padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right))
             calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
  }
  .menu-view { padding: 18px 22px 20px; }
  .menu-view h2 { margin: 0 55px 14px; font-size: 22px; }
  .menu-close { top: 10px; right: 11px; width: 40px; height: 40px; font-size: 26px; }
  .menu-actions { gap: 9px; }
  .menu-action { min-height: 46px; font-size: 16px; }
  .menu-back { min-height: 44px; margin-top: 14px; }
  #menu-rules-description { margin: -6px auto 12px; font-size: 13px; }
  .rules-scroll { max-height: 40vh; }
  .settings-list { gap: 10px; margin: 16px 0; }
  .settings-row { min-height: 54px; padding: 8px 14px; font-size: 15px; }
  .toggle-switch { width: 92px; height: 42px; }
  .toggle-switch span { width: 28px; height: 28px; top: 5px; }
  .toggle-switch.active span { left: 56px; }
  .toggle-switch b { top: 12px; }
}
