/* ============================================================
   BMines Visual v2 — Component overrides
   Layered on top of styles.css. All tokens come from theme.css.
   Source-ordered after styles.css so equal-specificity wins here.
   ============================================================ */

/* ============================================================
   1. Shell — background, grain, drift blobs, glass topbar
   ============================================================ */

html,
body {
  background: var(--bg-fallback);
  color: var(--text-primary);
}

body {
  background: var(--bg-gradient);
  background-attachment: fixed;
  background-repeat: no-repeat;
  position: relative;
}

/* Drift blobs + grain live in a fixed sub-layer so they cover
   the viewport regardless of scroll context, without ever
   affecting layout. */
.bg-stack {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg-grain);
  pointer-events: none;
  overflow: hidden;
}

.bg-stack__grain {
  position: absolute;
  inset: -10%;
  background-image: var(--grain);
  background-size: 240px 240px;
  opacity: 0.06;
  mix-blend-mode: overlay;
}

.bg-stack__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.3;
  will-change: transform;
}

.bg-stack__blob--a {
  width: 60vmin;
  height: 60vmin;
  left: -10vmin;
  top: 10vh;
  background: radial-gradient(closest-side, rgba(184, 176, 255, 0.85), rgba(184, 176, 255, 0));
  animation: blobDriftA 58s var(--ease-out) infinite alternate;
}

.bg-stack__blob--b {
  width: 70vmin;
  height: 70vmin;
  right: -15vmin;
  bottom: -10vh;
  background: radial-gradient(closest-side, rgba(0, 82, 255, 0.7), rgba(0, 82, 255, 0));
  animation: blobDriftB 46s var(--ease-out) infinite alternate;
}

@keyframes blobDriftA {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(12vw, -8vh, 0) scale(1.08); }
}

@keyframes blobDriftB {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-10vw, 6vh, 0) scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-stack__blob {
    animation: none;
  }
}

/* The .app must sit above the bg layer. */
.app {
  position: relative;
  z-index: var(--z-base);
}

/* ---------- Topbar (glass, sticky, full bleed) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-hud);
  width: min(780px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: 12px 18px;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-top: none;
  border-radius: 0 0 var(--r-card) var(--r-card);
  backdrop-filter: blur(var(--surface-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--surface-blur)) saturate(140%);
  box-shadow: none;
  color: var(--text-primary);
}

.account-label {
  color: var(--text-primary);
  letter-spacing: 0.06em;
  font-weight: 600;
}

.account-logo {
  border-color: var(--surface-border-strong);
  background: var(--surface-bg-strong);
  width: 28px;
  height: 28px;
}

.balance {
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--surface-border);
}

.balance .value {
  color: var(--text-primary);
  font-feature-settings: var(--num-feat);
  font-variant-numeric: tabular-nums lining-nums;
}

button.balance {
  cursor: pointer;
}

button.balance:hover {
  background: var(--surface-bg-strong);
}

/* ---------- Hide theme toggle (single premium dark theme) ---------- */
#themeToggle,
.theme-toggle {
  display: none !important;
}

/* The header-icon-row is now just the "i" button; center it. */
.header-icon-row {
  margin-top: 8px;
  margin-bottom: 4px;
}

.onboarding-button {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  backdrop-filter: blur(var(--surface-blur));
  -webkit-backdrop-filter: blur(var(--surface-blur));
}

.onboarding-button:hover {
  background: var(--surface-bg-strong);
  border-color: var(--surface-border-strong);
}

/* ============================================================
   2. Mini 3D coin (used in topbar next to $BMINES balance)
   The full coin component (large variant) lands in commit 6.
   ============================================================ */

.coin3d {
  --coin-size: 22px;
  --coin-rim: rgba(255, 255, 255, 0.35);
  position: relative;
  width: var(--coin-size);
  height: var(--coin-size);
  display: inline-block;
  flex: 0 0 var(--coin-size);
  transform-style: preserve-3d;
  perspective: 220px;
  animation: coinSpin 14s linear infinite, coinFloat 6s var(--ease-out) infinite alternate;
  filter: drop-shadow(0 4px 8px rgba(0, 10, 50, 0.45));
}

.coin3d__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px var(--coin-rim);
}

.coin3d__face--front {
  background-image: url("/assets/promo/coin-3d.png");
}

.coin3d__face--back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(145deg, #2f4dff 0%, var(--base-blue) 55%, var(--base-blue-deep) 100%);
  display: grid;
  place-items: center;
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: calc(var(--coin-size) * 0.5);
  letter-spacing: -0.04em;
}

.coin3d__face--back::after {
  content: "M";
  display: block;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

@keyframes coinSpin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

@keyframes coinFloat {
  0% { transform: rotateY(0deg) translateY(0); }
  100% { transform: rotateY(0deg) translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .coin3d {
    animation: none;
  }
  .coin3d__face--back {
    display: none;
  }
}

/* Balance pill: swap stock bmines.svg slot for the mini coin */
.balance .coin3d {
  margin-right: 2px;
}

.balance img[alt="$BMINES"] {
  display: none;
}

/* ============================================================
   3. Game board — 5x5 grid, glass tiles, reveal animations
   ============================================================ */

.grid-wrap {
  padding: 0;
}

.grid {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-card);
  padding: 10px;
  gap: 10px;
  backdrop-filter: blur(var(--surface-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--surface-blur)) saturate(140%);
  box-shadow: none;
}

.tile {
  border-radius: var(--r-tile);
  background: var(--tile-idle-bg);
  border: 1px solid var(--tile-idle-border);
  box-shadow: var(--tile-idle-highlight), 0 4px 10px rgba(0, 10, 60, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform-style: preserve-3d;
  perspective: 600px;
  transition: transform var(--d-micro) var(--ease-out),
              filter var(--d-micro) var(--ease-out),
              border-color var(--d-fast) var(--ease-out);
}

.tile:hover:not(.open) {
  border-color: var(--surface-border-strong);
  filter: brightness(1.05);
}

.tile:active:not(.open),
.tile.pressed:not(.open) {
  transform: scale(0.96);
  filter: brightness(1.12);
}

/* ---------- Safe reveal: Y-axis flip with overshoot ---------- */
.tile.open.safe {
  background: var(--tile-safe);
  background-image:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 50%),
    linear-gradient(145deg, #2f4dff 0%, var(--base-blue) 70%);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: var(--tile-safe-glow);
  animation:
    tileFlip 400ms var(--ease-bounce),
    tileSafePulse 700ms var(--ease-out) 380ms;
}

@keyframes tileFlip {
  0%   { transform: rotateY(180deg) scale(0.82); }
  55%  { transform: rotateY(0deg) scale(1.06); }
  100% { transform: rotateY(0deg) scale(1); }
}

@keyframes tileSafePulse {
  0%   { box-shadow: 0 0 0 rgba(0, 82, 255, 0), inset 0 1px 0 rgba(255,255,255,.28); }
  45%  { box-shadow: 0 0 38px rgba(0, 82, 255, 0.9), inset 0 1px 0 rgba(255,255,255,.42); }
  100% { box-shadow: var(--tile-safe-glow); }
}

/* Safe particle burst — multi-shadow projection from a tiny dot. */
.tile.open.safe::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  opacity: 0;
  pointer-events: none;
  box-shadow:
    18px -10px 0 0 rgba(255, 255, 255, 0.95),
    -16px -14px 0 0 rgba(255, 255, 255, 0.85),
    -22px 6px 0 0 rgba(184, 176, 255, 0.85),
    20px 12px 0 0 rgba(184, 176, 255, 0.75),
    -4px -22px 0 0 rgba(255, 255, 255, 0.7);
  animation: particleBurst 600ms var(--ease-out) 220ms;
}

@keyframes particleBurst {
  0%   { opacity: 1; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* ---------- Bomb reveal: shake + flash + shockwave ring ---------- */
.tile.open.mine {
  background: var(--tile-bomb);
  background-image:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 50%),
    linear-gradient(145deg, #ff5b5b 0%, var(--tile-bomb) 65%);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: var(--tile-bomb-glow);
  animation:
    tileShake 300ms steps(4, end),
    tileBombFlash 320ms var(--ease-out);
}

/* Shockwave uses the tile pseudo. The tile box-sizing keeps it
   centered on the tile face. */
.tile.open.mine::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-tile);
  border: 2px solid var(--tile-bomb);
  opacity: 0;
  pointer-events: none;
  animation: shockwave 600ms var(--ease-out);
}

@keyframes tileShake {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-3px); }
  50%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

@keyframes tileBombFlash {
  0%   { filter: brightness(1.2); }
  35%  { filter: brightness(2.6) saturate(1.3); }
  100% { filter: brightness(1); }
}

@keyframes shockwave {
  0%   { transform: scale(1); opacity: 0.95; border-width: 2px; }
  100% { transform: scale(2.4); opacity: 0;    border-width: 0; }
}

/* Neighbor "inhale" — closed tiles flinch when a mine is opened.
   Uses :has() to detect the round state; no JS coupling. */
.grid:has(.tile.open.mine) .tile:not(.open) {
  animation: tileInhale 520ms var(--ease-out);
}

@keyframes tileInhale {
  0%   { transform: scale(1); filter: brightness(1); }
  40%  { transform: scale(0.97); filter: brightness(0.88); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Tile inner content (safe / bomb icons): we keep them hidden as
   in current build — palette communicates state via color. The
   bomb glyph will return in commit 6 as a clean SVG. */
.tile-content img {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .tile.open.safe,
  .tile.open.mine,
  .tile.open.safe::after,
  .tile.open.mine::before,
  .grid:has(.tile.open.mine) .tile:not(.open) {
    animation: none !important;
  }
  .tile.open.safe {
    transform: none;
  }
}

/* ============================================================
   4. HUD — info bar, hero multiplier, primary CTA, reward strip
   ============================================================ */

.info-bar {
  position: relative;
  background-color: rgba(255, 255, 255, 0);
  border-width: 0;
  border-color: rgba(0, 0, 0, 0);
  border-style: none;
  border-image: none;
  border-radius: var(--r-pill);
  padding: 35px 16px;
  color: var(--text-primary);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.info-bar .value {
  color: var(--text-primary);
  font-feature-settings: var(--num-feat);
  font-variant-numeric: tabular-nums lining-nums;
}

.bet-info,
.mines-tiles {
  gap: 8px;
}

/* ---------- Hero multiplier ---------- */
.hero-multiplier-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0;
}

.hero-multiplier-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.hero-multiplier {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(180deg, #ffffff 0%, var(--lavender-soft) 55%, var(--lavender) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 28px rgba(184, 176, 255, 0.25);
  transform-origin: center;
}

.hero-multiplier.pop {
  animation: heroPop 360ms var(--ease-bounce);
}

@keyframes heroPop {
  0%   { transform: scale(1); filter: drop-shadow(0 0 0 rgba(184,176,255,0)); }
  45%  { transform: scale(1.08); filter: drop-shadow(0 0 14px rgba(184,176,255,0.55)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(184,176,255,0)); }
}

/* ---------- Reward strip below the grid (muted, tabular) ---------- */
.reward-box {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-pill);
  padding: 10px 18px;
  color: var(--text-primary);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.reward-box .label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 600;
}

.reward-box .value {
  color: var(--text-primary);
  font-feature-settings: var(--num-feat);
  font-variant-numeric: tabular-nums lining-nums;
}

.reward-box .reward-main .value {
  font-family: var(--font-display);
  font-weight: 700;
}

/* ---------- Primary / Secondary buttons: pill 56 ---------- */
button.primary,
button.secondary,
.balance-button.deposit,
.balance-button.withdraw {
  min-height: 56px;
  padding: 0 28px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: transform var(--d-micro) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out),
              filter var(--d-micro) var(--ease-out);
  animation: none;
}

button.primary,
.balance-button.deposit {
  background: linear-gradient(180deg, #1a66ff 0%, var(--base-blue) 55%, #003fcc 100%);
  color: #ffffff;
  box-shadow: none;
}

button.primary:hover,
.balance-button.deposit:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: none;
}

button.primary:active,
.balance-button.deposit:active {
  transform: scale(0.98) translateY(0);
}

button.secondary {
  background: linear-gradient(120deg, var(--base-blue) 0%, #6a55ff 60%, var(--lavender) 100%);
  color: #ffffff;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 14px 28px rgba(70, 50, 200, 0.45);
  animation: cashoutBreathe 2.2s var(--ease-out) infinite;
}

button.secondary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

button.secondary:active {
  transform: scale(0.98);
}

@keyframes cashoutBreathe {
  0%, 100% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.45),
      0 14px 28px rgba(70, 50, 200, 0.35),
      0 0 0 rgba(184, 176, 255, 0);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.55),
      0 18px 36px rgba(70, 50, 200, 0.55),
      0 0 38px rgba(184, 176, 255, 0.5);
  }
}

.balance-button.withdraw {
  background: var(--surface-bg);
  color: var(--text-primary);
  border: 1px solid var(--surface-border-strong);
  box-shadow: var(--surface-highlight);
  backdrop-filter: blur(var(--surface-blur));
  -webkit-backdrop-filter: blur(var(--surface-blur));
}

.balance-button.withdraw:hover {
  background: var(--surface-bg-strong);
  transform: translateY(-1px);
}

button.primary.wide {
  min-width: 260px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.4);
  animation: none;
}

/* Small variants (txModal Confirm / Cancel) — keep pill, lighter. */
button.primary.small,
button.secondary.small {
  min-height: 48px;
  padding: 0 22px;
  font-size: 16px;
  border-radius: var(--r-pill);
  animation: none;
  box-shadow: none;
}

button.secondary.small {
  background: var(--surface-bg-strong);
  color: var(--text-primary);
  border: 1px solid var(--surface-border-strong);
  backdrop-filter: blur(var(--surface-blur));
  -webkit-backdrop-filter: blur(var(--surface-blur));
}

@media (prefers-reduced-motion: reduce) {
  .hero-multiplier.pop,
  button.secondary {
    animation: none !important;
  }
}

/* ============================================================
   5. Modals as bottom sheets + floating glass tab bar
   ============================================================ */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* ---------- Modal backdrop + sheet ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0, 5, 30, 0.5);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: modalBackdropIn 360ms var(--ease-out);
}

.modal.hidden {
  display: none;
}

.modal-content {
  position: relative;
  z-index: var(--z-modal);
  width: min(540px, 100%);
  max-height: 92dvh;
  height: auto !important;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  border-radius: var(--r-modal) var(--r-modal) 0 0;
  border: 1px solid var(--surface-border);
  border-bottom: none;
  background: var(--surface-bg-strong);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 60%);
  backdrop-filter: blur(var(--surface-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--surface-blur)) saturate(160%);
  box-shadow: 0 -20px 60px rgba(0, 5, 30, 0.55), var(--surface-highlight);
  color: var(--text-primary);
  overflow: hidden;
  animation: sheetSlideUp 450ms var(--ease-bounce);
}

/* Drag handle */
.modal-content::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes sheetSlideUp {
  from { transform: translateY(110%); opacity: 0.85; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-content {
    animation: none !important;
  }
}

.modal-header {
  margin: 6px 0 16px;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0;
  height: auto;
}

.modal-body p {
  height: auto;
}

.modal-header .icon-button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--r-pill);
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}

.modal-header .icon-button:hover {
  background: var(--surface-bg-strong);
}

.modal-body label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 600;
  display: block;
  margin: 6px 0 8px;
}

.modal-body p {
  color: var(--text-secondary);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.tx-modal-actions {
  justify-content: space-between;
}

.modal-body input[type="number"]:not(.bet-stepper-input input) {
  width: 100%;
  height: 52px;
  border-radius: var(--r-pill);
  border: 1px solid var(--surface-border);
  background: var(--surface-bg);
  color: var(--text-primary);
  padding: 0 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  font-feature-settings: var(--num-feat);
  font-variant-numeric: tabular-nums lining-nums;
  text-align: center;
  outline: none;
  transition: border-color var(--d-fast) var(--ease-out), background var(--d-fast) var(--ease-out);
}

.modal-body input[type="number"]:not(.bet-stepper-input input):focus {
  border-color: var(--lavender);
  background: var(--surface-bg-strong);
}

/* ---------- Bet stepper ---------- */
.settings-bet-control {
  display: grid;
  gap: 12px;
}

.bet-stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.step-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform var(--d-micro) var(--ease-out), background var(--d-fast) var(--ease-out);
}

.step-btn:hover {
  background: var(--surface-bg-strong);
}

.step-btn:active {
  transform: scale(0.94);
}

.bet-stepper-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 44px;
  border-radius: var(--r-pill);
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
}

.bet-stepper-input input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  width: 100%;
  outline: none;
  font-feature-settings: var(--num-feat);
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.bet-stepper-input input::-webkit-outer-spin-button,
.bet-stepper-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Deposit / withdraw amount — same stepper as settings bet */
.tx-amount-stepper {
  grid-template-columns: 48px 1fr 48px;
  gap: 10px;
}

.tx-amount-stepper .step-btn {
  width: 48px;
  height: 48px;
}

.tx-amount-stepper .bet-stepper-input {
  height: 52px;
  padding: 0 14px;
  transition: border-color var(--d-fast) var(--ease-out), background var(--d-fast) var(--ease-out);
}

.tx-amount-stepper .bet-stepper-input:focus-within {
  border-color: var(--lavender);
  background: var(--surface-bg-strong);
}

.tx-amount-stepper .bet-stepper-input input {
  font-size: 20px;
}

.settings-bet-suffix {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.bet-chips {
  display: flex;
  gap: 8px;
}

.bet-chip {
  flex: 1 1 0;
  min-height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--surface-border);
  background: var(--surface-bg);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform var(--d-micro) var(--ease-out), background var(--d-fast) var(--ease-out);
}

.bet-chip:hover {
  background: var(--surface-bg-strong);
}

.bet-chip:active {
  transform: scale(0.96);
}

/* ---------- Mines segment ---------- */
.mines-segment {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-pill);
}

.mines-chip {
  flex: 1 1 0;
  min-width: 40px;
  height: 44px;
  border-radius: var(--r-pill);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease-bounce),
              background var(--d-fast) var(--ease-out),
              color var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
}

.mines-chip:hover {
  color: var(--text-primary);
}

.mines-chip[aria-checked="true"] {
  background: linear-gradient(180deg, #1a66ff 0%, var(--base-blue) 100%);
  color: #ffffff;
  transform: scale(1.15);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 10px 20px rgba(0, 22, 100, 0.45);
}

/* ---------- Floating glass tab bar w/ animated indicator ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  height: 64px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
  border-radius: var(--r-pill);
  border: 1px solid var(--surface-border);
  background: var(--surface-bg);
  backdrop-filter: blur(var(--surface-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--surface-blur)) saturate(160%);
  box-shadow: var(--surface-shadow), var(--surface-highlight);
  z-index: var(--z-hud);
}

.bottom-nav::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: var(--nav-indicator-w, calc(33.333% - 4px));
  height: calc(100% - 12px);
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, #1a66ff 0%, var(--base-blue) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 10px 22px rgba(0, 22, 100, 0.45);
  transform: translateX(var(--nav-indicator-x, 0));
  transition: transform 420ms var(--ease-bounce), width 280ms var(--ease-out);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .bottom-nav::before {
    transition: none;
  }
}

.nav-item {
  position: relative;
  z-index: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  transition: color var(--d-fast) var(--ease-out);
}

.nav-item img {
  width: 22px;
  height: 22px;
  filter: none;
  opacity: 0.65;
  transition: opacity var(--d-fast) var(--ease-out), filter var(--d-fast) var(--ease-out);
}

.nav-item.active {
  color: #ffffff;
}

.nav-item.active img {
  opacity: 1;
  filter: brightness(0) invert(1);
}

/* The bottom-nav pushes screen content up so it never hides under the
   floating pill. styles.css already sets screen padding-bottom to ~84px;
   we keep a slightly larger reserve for the bigger pill. */
.screen {
  padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important;
}

/* ============================================================
   6. Illustrations, tile glyphs, polish
   ============================================================ */

/* Larger 3D coin variants */
.coin3d--md {
  --coin-size: 56px;
}

.coin3d--lg {
  --coin-size: 132px;
  animation:
    coinSpin 18s linear infinite,
    coinFloat 5s var(--ease-out) infinite alternate;
  filter: drop-shadow(0 18px 28px rgba(0, 10, 50, 0.55));
}

.leaderboard-empty-illustration {
  display: grid;
  place-items: center;
  padding: 24px 0 16px;
}

.token-info-coin {
  display: grid;
  place-items: center;
  padding: 4px 0 12px;
}

/* Clean safe / bomb glyphs rendered as backgrounds on the
   already-styled .tile-content element. Inline SVG data URIs
   keep the build dependency-free. */
.tile.open.safe .tile-content {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23ffffff' d='M12 2.2 4 6v6c0 4.97 3.4 9.4 8 9.8 4.6-.4 8-4.83 8-9.8V6l-8-3.8Zm0 5.6 4.6 3.4-1.7 5.4L12 14.7l-2.9 1.9-1.7-5.4L12 7.8Z' opacity='0.92'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 46% 46%;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15));
  opacity: 0;
  animation: tileGlyphIn 320ms var(--ease-out) 260ms forwards;
}

.tile.open.mine .tile-content {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round'><circle cx='12' cy='13.5' r='6.2' fill='%23ffffff' fill-opacity='0.95' stroke='none'/><path d='M12 7.3v-2M14.4 5.3l1.6-1.6' stroke='%23ffe7a8'/><circle cx='17' cy='3.2' r='1.2' fill='%23ffd05a' stroke='none'/><g stroke='%230b113a' stroke-width='1.2'><path d='M9 11l1.2-1.2M14.5 16l1.2-1.2M9 16l1.2 1.2M14.5 11l1.2 1.2'/></g></g></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 56% 56%;
  opacity: 0;
  animation: tileGlyphIn 320ms var(--ease-out) 60ms forwards;
}

@keyframes tileGlyphIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .tile.open .tile-content {
    animation: none !important;
    opacity: 1;
  }
}

/* ============================================================
   7. Experiments (gated by body.experiments-on)
   ============================================================ */

/* Heat edge: outer glow on game screen warms with multiplier. */
body.experiments-on .game-screen {
  position: relative;
}

body.experiments-on .game-screen::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  border-radius: 0;
  box-shadow: inset 0 0 0 0 rgba(0, 82, 255, 0);
  transition: box-shadow 450ms var(--ease-out);
  z-index: -1;
}

body.experiments-on.heat-warm .game-screen::after {
  box-shadow: inset 0 0 140px 0 rgba(122, 85, 255, 0.32);
}

body.experiments-on.heat-hot .game-screen::after {
  box-shadow: inset 0 0 200px 0 rgba(255, 102, 196, 0.42);
}

body.experiments-on.heat-warm .hero-multiplier {
  background: linear-gradient(180deg, #ffffff 0%, var(--lavender) 60%, #7a55ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body.experiments-on.heat-hot .hero-multiplier {
  background: linear-gradient(180deg, #ffffff 0%, #ffb547 45%, #ff66c4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 0 32px rgba(255, 102, 196, 0.5);
}

/* Soft-confirm ring on Cash Out: an in-button progress fill. */
body.experiments-on button.secondary {
  overflow: hidden;
}

body.experiments-on button.secondary.soft-confirming::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 100%);
  transform-origin: left center;
  transform: scaleX(0);
  animation: softConfirmFill 600ms var(--ease-out) forwards;
  pointer-events: none;
}

body.experiments-on button.secondary.soft-confirmed {
  filter: brightness(1.15);
}

@keyframes softConfirmFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  body.experiments-on button.secondary.soft-confirming::after {
    animation: none;
    transform: scaleX(1);
  }
  body.experiments-on .game-screen::after {
    transition: none;
  }
}

/* Provide a hint pill (visible only when experiments are on)
   describing the swipe-up gesture. Keep small + muted. */
body.experiments-on .grid-wrap::after {
  content: "Swipe up to cash out";
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.7;
}

.grid-wrap {
  position: relative;
}

/* Hide scrollbars across app surfaces */
.app,
.screen,
.screen-panel,
.modal,
.modal-content,
.leaderboard {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app::-webkit-scrollbar,
.screen::-webkit-scrollbar,
.screen-panel::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.leaderboard::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* ---------- Provably-fair trigger + verification panel ---------- */
.fairness-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px auto 0;
  padding: 6px 14px;
  border: 1px solid var(--surface-border);
  border-radius: var(--r-pill);
  background: var(--surface-bg);
  color: var(--text-muted);
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.fairness-trigger:hover,
.fairness-trigger:focus-visible {
  color: var(--text-primary);
  border-color: var(--surface-border-strong);
}

.fairness-trigger-lock {
  font-size: 11px;
  line-height: 1;
}

.fairness-modal {
  height: auto;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.fairness-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.fairness-intro,
.fairness-field,
.fairness-result {
  flex-shrink: 0;
}

.fairness-intro {
  margin: 0;
  height: auto; /* override global p { height: 21px } */
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.fairness-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fairness-field > label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.fairness-field small {
  font-size: 11px;
  color: var(--text-faint);
}

.fairness-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 9px;
  letter-spacing: 0.1em;
  vertical-align: middle;
}

.fairness-tag.muted {
  background: var(--surface-bg);
  color: var(--text-faint);
}

.fairness-seed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fairness-seed-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: var(--surface-bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
}

.fairness-seed-row input:focus-visible {
  outline: none;
  border-color: var(--surface-border-strong);
}

.fairness-code {
  display: block;
  padding: 9px 12px;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: var(--surface-bg);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}

#fairnessVerify {
  margin-top: 2px;
}

#fairnessVerify:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.fairness-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: var(--surface-bg);
}

.fairness-verdict {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.fairness-verdict.pass {
  color: var(--success);
}

.fairness-verdict.fail {
  color: var(--danger);
}

.fairness-checks {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fairness-checks li {
  font-size: 12px;
  line-height: 1.4;
  padding-left: 18px;
  position: relative;
  color: var(--text-secondary);
}

.fairness-checks li::before {
  position: absolute;
  left: 0;
  top: 0;
}

.fairness-checks li.ok::before {
  content: "✓";
  color: var(--success);
}

.fairness-checks li.bad::before {
  content: "✗";
  color: var(--danger);
}

.fairness-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 140px;
  margin: 2px auto 0;
}

.fairness-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--surface-bg-strong);
  border: 1px solid var(--surface-border);
}

.fairness-cell.mine {
  background: var(--danger);
  border-color: var(--danger);
}

.fairness-note,
.fairness-fail {
  margin: 0;
  height: auto; /* override global p { height: 21px } */
  font-size: 12px;
  text-align: center;
  color: var(--text-muted);
}

.fairness-fail {
  color: var(--danger);
}

/* ---------- Retention: daily streak + missions ---------- */
.rewards-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  margin: 10px auto 0;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--surface-border-strong);
  background: var(--surface-bg);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  backdrop-filter: blur(var(--surface-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--surface-blur)) saturate(160%);
}
.rewards-trigger:hover {
  background: var(--surface-bg-strong);
}
.rewards-trigger-flame {
  font-size: 16px;
}
.rewards-trigger-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--base-blue-deep);
  box-shadow: 0 0 10px rgba(52, 210, 122, 0.8);
}
.rewards-trigger-badge.hidden {
  display: none;
}

.rewards-modal {
  height: auto;
  max-height: 92dvh;
  overflow-y: auto;
}

.daily-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--surface-border);
  background: linear-gradient(135deg, rgba(0, 82, 255, 0.25), rgba(255, 255, 255, 0.04));
  flex-shrink: 0;
}
.daily-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.daily-streak-flame {
  font-size: 28px;
  line-height: 1;
}
.daily-streak-line {
  font-weight: 700;
  font-size: 16px;
  height: auto;
}
.daily-sub {
  color: var(--text-muted);
  font-size: 12px;
  height: auto;
}
.daily-card .primary {
  flex: none;
  width: auto;
  padding: 10px 16px;
  white-space: nowrap;
}

.missions-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 2px 10px;
  font-weight: 700;
  font-size: 15px;
}
.missions-reset {
  font-size: 11px;
  font-weight: 500;
}
.missions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.mission-row {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  background: var(--surface-bg);
}
.mission-row.done {
  opacity: 0.6;
}
.mission-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mission-label {
  font-weight: 600;
  font-size: 14px;
}
.mission-reward {
  font-weight: 700;
  font-size: 13px;
  color: var(--success);
}
.mission-bar {
  margin: 8px 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.mission-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--base-blue), #7a55ff);
  transition: width 240ms ease;
}
.mission-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mission-progress {
  font-size: 12px;
}
.mission-claim {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--surface-border-strong);
  background: var(--accent-soft);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
}
.mission-claim:disabled {
  opacity: 0.5;
  background: transparent;
}

.rewards-toast {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  background: rgba(52, 210, 122, 0.16);
  border: 1px solid rgba(52, 210, 122, 0.4);
  color: var(--text-primary);
  flex-shrink: 0;
}
.rewards-toast.hidden {
  display: none;
}
