* { 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: url("assets/images/ui/game-panel.png") center/cover no-repeat,
    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:active:not(:disabled) { transform: translateY(2px); }
.big-btn:disabled { filter: grayscale(.72) brightness(.58); cursor: default; }
.big-btn.play { background: linear-gradient(180deg, #ffe98a 0%, #ffd23f 28%, #e0961a 62%, #b96e0a 100%); font-size: 42px; color: #402300; }
.big-btn.go { background: linear-gradient(180deg, #fff8b8 0%, #ffdc62 26%, #e4a526 65%, #a85b06 100%); font-size: 42px; color: #402300; border-color: #ffe072; box-shadow: inset 0 0 0 4px #a45c0c, inset 0 5px 8px #fff8, 0 0 0 4px #172516, 0 0 16px #ffc74788, 0 5px 8px #000; }
.big-btn.cashout { background: linear-gradient(180deg, #176c91, #08415f); border-color: #ffe16a; box-shadow: inset 0 0 0 4px #f5bd30, inset 0 5px 8px #fff5, 0 0 0 4px #172516, 0 0 16px #ffc74777, 0 5px 8px #000; }
.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); }
/* win-tier art (_design/presentation/) layered over the base card, by multiplier — see entry.js WIN_TIERS */
#popup-card.tier-big { background: url("assets/images/presentation/big-win.png") center/cover no-repeat; }
#popup-card.tier-mega { background: url("assets/images/presentation/mega-win.png") center/cover no-repeat; }
#popup-card.tier-max { background: url("assets/images/presentation/max-win.png") center/cover no-repeat; }
@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; }
}

/* Stadium presentation and responsive match console. */
:root { --gold: #f4d17f; --lime: #bdedcb; }
body { font-family: 'Segoe UI', Arial, sans-serif; }
#hud { display: block; }
#topbar { height: auto; padding: 0; background: none; border: 0; }
#topbar::after { display: none; }
.brand { position: absolute; left: 2.4%; top: 1.4%; width: clamp(170px, 23vw, 340px); height: auto; margin: 0; filter: drop-shadow(0 8px 16px #0009); mix-blend-mode: screen; mask-image: linear-gradient(90deg,transparent,#000 6% 87%,transparent),linear-gradient(0deg,transparent,#000 15% 85%,transparent); mask-composite: intersect; }
.stadium-atmosphere { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: linear-gradient(180deg,#030b18aa,transparent 27%,transparent 57%,#06100e88 83%),linear-gradient(90deg,#020b1644,transparent 30% 73%,#020b1688); }
.stadium-atmosphere i { position: absolute; top: -20%; left: 8%; width: 24%; height: 90%; background: linear-gradient(#d5ecff18,transparent); transform-origin: top center; transform: rotate(-24deg); filter: blur(24px); animation: floodlight 16s ease-in-out infinite alternate; }
.stadium-atmosphere i + i { left: 66%; animation-delay: -9s; animation-direction: alternate-reverse; }
@keyframes floodlight { to { transform: rotate(23deg); opacity: .4; } }
.top-actions { position: fixed; right: 2.4%; top: max(18px,var(--safe-top)); }
#menu-button { width: 44px; height: 44px; border: 1px solid #ffffff30; border-radius: 14px; background: #08151ad9; box-shadow: 0 4px 20px #0004; }
#menu-button span { width: 18px; height: 2px; background: #e6e9e4; box-shadow: none; }
#match-status { position: absolute; top: 3.5%; left: 50%; transform: translateX(-50%); width: 270px; text-align: center; text-shadow: 0 2px 12px #000; }
.match-eyebrow { display: flex; align-items: center; justify-content: center; gap: 8px; color: #dfd9bc; font-size: 10px; font-weight: 700; letter-spacing: 2.5px; }
.match-eyebrow i { width: 5px; height: 5px; border-radius: 50%; background: #c6f9d0; box-shadow: 0 0 8px #a9ffc4; }
.match-score { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 6px 0 9px; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 2px; }
#kick-total { color: #ffffff65; }
.match-divider { font-size: 24px; font-weight: 300; color: #efd18b80; }
#kick-progress { display: flex; gap: 4px; justify-content: center; margin: 0 auto 10px; }
#kick-progress i { width: 14px; height: 4px; border-radius: 2px; background: #ffffff30; transition: background .3s, box-shadow .3s; }
#kick-progress .scored { background: #efd18b; box-shadow: 0 0 10px #efd18b80; }
#round-status { color: #d2dcd4; font-size: 9px; font-weight: 600; letter-spacing: 2px; }
#hud[data-state="busy"] .match-eyebrow i { animation: status-pulse .7s ease-in-out infinite alternate; }
@keyframes status-pulse { to { opacity: .3; } }
#controls { position: absolute; left: 2.4%; bottom: max(28px,var(--safe-bottom)); width: 95.2%; height: 146px; min-height: 0; margin: 0; padding: 20px 24px; display: grid; grid-template-columns: 1fr 1.5fr 2.65fr; gap: 26px; align-items: center; border: 1px solid #e6d39c40; border-radius: 20px; background: linear-gradient(115deg,#14232bf5,#0b151af5 55%,#16231df5); box-shadow: 0 16px 60px #0009,inset 0 1px #ffffff0c; backdrop-filter: blur(18px); }
#controls::before { content: ''; position: absolute; left: 8%; right: 8%; top: -1px; height: 1px; background: linear-gradient(90deg,transparent,#f4d17fa0,transparent); }
.balance-box { min-width: 0; max-width: none; min-height: 76px; padding: 12px 10px; align-items: flex-start; border: 0; border-right: 1px solid #ffffff14; border-radius: 0; background: none; box-shadow: none; gap: 12px; }
.label { color: #9fadb3; font: 600 10px/1.2 'Segoe UI',Arial,sans-serif; letter-spacing: 1.6px; text-shadow: none; }
#balance { color: #eff3ef; font-size: clamp(15px,1.65vw,26px); font-weight: 700; font-variant-numeric: tabular-nums; text-shadow: none; white-space: nowrap; }
#bet-panel { display: flex; flex-direction: column; gap: 8px; width: 100%; min-width: 0; pointer-events: auto; }
.bet-adjust { flex: auto; min-width: 0; width: 100%; padding: 0; border: 0; }
.bet-adjust .label { display: block; text-align: left; }
.bet-row { display: grid; grid-template-columns: 38px minmax(0,1fr) 38px; gap: 6px; margin-top: 7px; min-width: 0; }
#bet-input,.stepper { height: 36px; border: 1px solid #ffffff18; border-radius: 7px; background: #ffffff08; box-shadow: none; }
#bet-input { color: #f8f5e9; font-size: 19px; font-weight: 700; background: #040c1270; user-select: text; -webkit-user-select: text; }
.stepper { font-size: 22px; color: #e0d6b6; }
#bet-presets { display: flex; width: 100%; gap: 5px; min-width: 0; }
.preset { flex: 1; width: auto; height: 28px; min-height: 28px; aspect-ratio: auto; border: 1px solid #ffffff16; outline: none; border-radius: 6px; background: #ffffff05; color: #adbbc1; box-shadow: none; font: 600 11px Arial,sans-serif; text-shadow: none; }
.preset.selected { color: #f5d78e; border-color: #eaca7960; background: #e9c77818; box-shadow: inset 0 0 10px #e9c77808; }
#bet-panel.bet-locked { opacity: .65; pointer-events: none; }
#bet-panel.bet-locked :disabled { filter: none; }
#action-panel { height: 82px; gap: 14px; }
.big-btn,.big-btn.play,.big-btn.go,.big-btn.cashout { overflow: hidden; max-width: none; min-height: 0; height: 100%; padding: 10px; border: 1px solid #ffe8aa; border-radius: 12px; box-shadow: inset 0 1px #fff7,0 6px 20px #dfb85720; background: linear-gradient(125deg,#f9e7ae,#e5bd65); color: #272215; font: 800 clamp(22px,2.2vw,34px)/1 'Segoe UI',Arial,sans-serif; letter-spacing: 2px; transition: transform .2s,filter .2s,box-shadow .2s; }
.big-btn.play::after,.big-btn.go::after { content: ''; position: absolute; inset: -80% -30%; transform: translateX(-100%) rotate(24deg); background: linear-gradient(90deg,transparent 42%,#ffffff66 50%,transparent 58%); animation: button-sheen 6s ease-in-out infinite; pointer-events: none; }
@keyframes button-sheen { 0%,65% { transform: translateX(-100%) rotate(24deg); } 90%,100% { transform: translateX(100%) rotate(24deg); } }
.big-btn.cashout { border-color: #afc9b348; background: linear-gradient(125deg,#293e32,#14261e); color: #d2ebd2; box-shadow: inset 0 1px #ffffff10; }
.big-btn.go .btn-title,.big-btn.cashout .btn-title { visibility: visible; font: inherit; font-size: clamp(20px,2vw,30px); }
.btn-sub { font: 600 11px/1.5 'Segoe UI',Arial,sans-serif; color: inherit; letter-spacing: .5px; opacity: .8; }
.big-btn:disabled { filter: saturate(.25); opacity: .45; }
.big-btn:disabled::after { animation: none; }
#tagline { position: absolute; bottom: 9px; width: 100%; text-align: center; font: 9px Arial,sans-serif; letter-spacing: 3px; color: #c4cdc180; }
#multiplier-plaque { position: absolute; bottom: calc(100% + 15px); left: 50%; transform: translateX(-50%); width: 218px; min-width: 0; height: 83px; padding: 13px 10px 8px; text-align: center; background: linear-gradient(120deg,#16261dee,#091611ee); border: 1px solid #d4d8aa40; border-radius: 14px; box-shadow: 0 10px 30px #0005,inset 0 1px #fff1; backdrop-filter: blur(12px); }
#multiplier-plaque span { display: block; color: #c6ceb8; font: 600 9px Arial,sans-serif; letter-spacing: 2px; }
#current-multiplier { display: block; color: #d8f5c7; font-size: 39px; line-height: 1.25; font-weight: 800; text-shadow: 0 0 25px #a6e58c30; font-variant-numeric: tabular-nums; }
#multiplier-ladder { position: absolute; top: 11%; right: 2.4%; width: clamp(145px,15%,230px); bottom: 202px; padding: 17px 12px 12px; border: 1px solid #d7c48d40; border-radius: 16px; background: linear-gradient(140deg,#122026ee,#0a1417f5); box-shadow: 0 12px 35px #0005,inset 0 1px #fff1; backdrop-filter: blur(16px); display: flex; flex-direction: column; }
#multiplier-ladder h2 { font: 800 clamp(15px,1.6vw,23px) 'Segoe UI',Arial,sans-serif; text-align: center; letter-spacing: 2px; }
#multiplier-ladder p { text-align: center; font: 600 9px Arial,sans-serif; letter-spacing: 3px; color: #d7c28c; margin: 5px 0 15px; }
#ladder-rows { list-style: none; display: grid; gap: 4px; flex: 1; min-height: 0; }
#ladder-rows li { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 10px; border: 1px solid #ffffff0c; border-radius: 6px; background: #ffffff03; font: 700 clamp(11px,1.22vw,19px) 'Segoe UI',Arial,sans-serif; transition: background .4s,border-color .4s,opacity .4s; }
#ladder-rows span { color: #8e9da3; font-size: .7em; font-weight: 500; }
#ladder-rows strong { color: #d6d6c7; white-space: nowrap; font-variant-numeric: tabular-nums; }
#ladder-rows .jackpot { background: linear-gradient(110deg,#eed493,#caa14f); border-color: #ffe7a080; box-shadow: 0 0 20px #e7ba521a; }
#ladder-rows .jackpot strong,#ladder-rows .jackpot span { color: #332813; }
#ladder-rows .current { border-color: #b7d68b80; background: linear-gradient(100deg,#55763b90,#26392780); box-shadow: 0 0 15px #b9df8310; }
#ladder-rows .current::before { content: ''; position: absolute; left: -2px; top: 25%; height: 50%; width: 3px; border-radius: 2px; background: #d5f4a9; box-shadow: 0 0 10px #b4ed86; }
#ladder-rows .current strong { color: #e0f3be; }
#ladder-rows .passed { opacity: .4; }
#multiplier-ladder footer { display: block; text-align: center; margin-top: 11px; color: #83938f; font: 600 7px Arial,sans-serif; letter-spacing: 1px; }
#message { top: 23%; padding: 9px 18px; border: 1px solid #e6d49d30; border-radius: 30px; background: #0a171cd9; color: #f0e2b9; font: 600 12px/1.4 'Segoe UI',Arial,sans-serif; }
#shot-feedback { position: absolute; top: 24%; left: 50%; transform: translate(-50%,12px) scale(.92); opacity: 0; text-align: center; transition: opacity .2s, transform .35s; }
#shot-feedback.visible { opacity: 1; transform: translate(-50%,0) scale(1); }
#shot-feedback strong { display: block; font: italic 900 clamp(38px,5vw,76px)/1 'Segoe UI',Arial,sans-serif; color: #fff3c9; letter-spacing: 4px; text-shadow: 0 4px 0 #625125,0 8px 30px #000,0 0 50px #edc96b60; }
#shot-feedback span { display: inline-block; margin-top: 10px; padding: 5px 15px; border-radius: 30px; background: #0a171de8; color: #eee9ce; font-size: 11px; letter-spacing: 2px; }
#shot-feedback.save strong { color: #f2c4b6; text-shadow: 0 4px 0 #5a3b32,0 8px 30px #000; }
#popup-card { border-width: 1px; border-radius: 20px; background: radial-gradient(ellipse at top,#384630,#0c1919 75%); box-shadow: 0 25px 90px #0009,0 0 70px #ebca7525; }
@media (max-width:1050px) { #controls { gap: 15px; padding: 16px; grid-template-columns: 1fr 1.5fr 2.4fr; } #balance { font-size: 17px; } }
@media (max-width:759px) and (orientation:portrait) {
  .brand { width: 155px; left: 3%; top: 0; }
  .top-actions { top: max(15px,var(--safe-top)); right: 4%; }
  #match-status { top: 13%; left: 30%; width: 190px; }
  .match-eyebrow { font-size: 7px; letter-spacing: 1.5px; }
  .match-score { font-size: 26px; margin: 4px 0 6px; }
  #kick-progress { gap: 3px; margin-bottom: 7px; }
  #kick-progress i { width: 10px; height: 3px; }
  #round-status { font-size: 7px; letter-spacing: 1px; }
  #menu-button { width: 40px; height: 40px; }
  #controls { left: 3%; width: 94%; height: 204px; bottom: max(26px,var(--safe-bottom)); padding: 13px; border-radius: 16px; grid-template-columns: .9fr 1.4fr; grid-template-rows: 103px 62px; gap: 10px 13px; }
  #action-panel { grid-column: 1/-1; grid-row: 2; height: 62px; gap: 10px; }
  .balance-box { grid-column: 1; grid-row: 1; min-height: 75px; padding: 10px 0; gap: 10px; }
  #balance { font-size: clamp(13px,3.7vw,20px); }
  #bet-panel { grid-column: 2; grid-row: 1; gap: 7px; }
  .bet-row { grid-template-columns: 34px minmax(0,1fr) 34px; gap: 4px; }
  #bet-input,.stepper { height: 38px; font-size: 18px; }
  #bet-presets { gap: 3px; }
  .preset { font-size: 9px; height: 28px; min-height: 28px; }
  .label { font-size: 8px; letter-spacing: 1px; }
  .big-btn,.big-btn.play,.big-btn.go,.big-btn.cashout { font-size: 24px; border-radius: 10px; min-height: 0; }
  .big-btn.go .btn-title,.big-btn.cashout .btn-title { font-size: 21px; }
  .btn-sub { font-size: 10px; }
  #multiplier-plaque { height: 66px; width: 165px; padding-top: 10px; bottom: calc(100% + 12px); }
  #multiplier-plaque span { font-size: 7px; }
  #current-multiplier { font-size: 31px; }
  #multiplier-ladder { top: 12%; bottom: 318px; right: 3%; width: 26%; padding: 9px 6px; border-radius: 12px; }
  #multiplier-ladder h2 { font-size: 12px; letter-spacing: 1px; white-space: nowrap; }
  #multiplier-ladder p { font-size: 7px; letter-spacing: 1.4px; margin: 3px 0 8px; }
  #ladder-rows { gap: 3px; }
  #ladder-rows li { padding: 0 5px; font-size: clamp(9px,2.7vw,13px); border-radius: 4px; }
  #multiplier-ladder footer { display: none; }
  #tagline { bottom: 8px; font-size: 6px; letter-spacing: 1.4px; }
  #message { top: 27%; left: 34%; max-width: 65%; font-size: 10px; padding: 6px 10px; }
  #shot-feedback { top: 30%; left: 38%; }
  #shot-feedback strong { font-size: 39px; }
}
@media (max-height:700px) and (orientation:portrait) {
  #match-status { top: 12%; } .match-score { font-size: 20px; } #round-status { display: none; }
  #multiplier-ladder { top: 12%; bottom: 306px; }
  #multiplier-ladder h2 { font-size: 10px; } #multiplier-ladder p { margin-bottom: 5px; }
  #ladder-rows { gap: 2px; } #ladder-rows li { font-size: 9px; }
}
@media (max-height:520px) and (orientation:landscape) {
  .brand { width: 145px; top: -3%; }
  #match-status { top: 3%; } .match-score { font-size: 23px; margin: 2px 0 4px; } .match-eyebrow { font-size: 7px; } #round-status { display: none; }
  #controls { height: 105px; bottom: 16px; padding: 8px 15px; gap: 15px; }
  #action-panel { height: 65px; }
  .big-btn,.big-btn.play,.big-btn.go,.big-btn.cashout { font-size: 23px; }
  #bet-input,.stepper { height: 29px; font-size: 17px; } .preset { height: 24px; min-height: 24px; } #bet-panel { gap: 5px; }
  #multiplier-plaque { height: 54px; width: 165px; bottom: calc(100% + 8px); padding: 6px; }
  #multiplier-plaque span { font-size: 7px; } #current-multiplier { font-size: 29px; }
  #multiplier-ladder { top: 6%; bottom: 137px; right: 8%; width: 125px; padding: 7px; }
  #multiplier-ladder h2 { font-size: 12px; } #multiplier-ladder p { font-size: 7px; margin: 2px 0 6px; }
  #ladder-rows { gap: 2px; } #ladder-rows li { font-size: 9px; padding: 0 5px; }
  #multiplier-ladder footer { display: none; } #tagline { bottom: 4px; font-size: 6px; letter-spacing: 2px; }
  #message { top: 24%; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation: none !important; transition: none !important; }
  .stadium-atmosphere i { display: none; }
}

.preset:focus-visible { outline: 3px solid #8ec8f2; outline-offset: 2px; }
