:root {
  --panel:        #1E1845;
  --board:        #120D24;
  --card-bg:      #1E1845;
  --card-shadow:  #0a0818;
  --elevated:     #272859;
  --hairline:     rgba(255, 255, 255, 0.06);
  --toggle-bg:    rgba(30, 24, 69, 0.8);
  --toggle-border:rgba(255, 255, 255, 0.12);
  --input-border: rgba(255, 255, 255, 0.10);
  --input-bg:     #1E1845;

  --text:         #FFFFFF;
  --text-75:      rgba(255, 255, 255, 0.75);
  --text-mid:     #8B8BA3;
  --text-dim:     rgba(139, 139, 163, 0.50);
  --text-dimmer:  #5C5C7A;

  --accent:       #F7931A;
  --accent-border:rgba(247, 147, 26, 0.45);
  --accent-glow:  rgba(247, 147, 26, 0.20);

  --green:        #0ECC68;
  --green-bright: #10e676;
  --green-bg:     rgba(14, 204, 104, 0.12);
  --red:          #F85F5D;
  --red-bg:       rgba(248, 95, 93, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
*, *::before, *::after { touch-action: manipulation; }
html, body {
  height: 100%;
  background: #120D24;
  color: var(--text);
  font-family: 'Montserrat', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body { display: flex; }
#root { width: 100%; height: 100%; display: flex; }

/* Disable text selection on game elements */
.app, .board, .header, .bottom, .stake-bet, .stake-chips,
.desktop-controls, .m-action-zone, .m-settings-row, .tile,
.grid-size-selector, .auto-chips {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }

/* ===== APP ===== */
.app {
  width: 100%; max-width: 100%; height: var(--app-height, 100%); max-height: var(--app-height, 100%);
  border-radius: 0;
  overflow: hidden; display: flex; flex-direction: column;
  background: var(--panel);
  box-shadow: none;
}

/* ===== HEADER ===== */
.header {
  display: flex; height: 50px; background: #23204e;
  border-bottom: 1px solid var(--hairline);
  align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; }
.game-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.game-name .ico { font-size: 18px; color: var(--accent); }

/* Header balance — right-aligned */
.header-bal {
  display: flex; align-items: center; gap: 4px;
  margin-left: auto; margin-right: 8px;
}
.header-bal-icon {
  font-size: 14px; font-weight: 700; color: var(--accent);
}
.header-bal-value {
  font-size: 14px; font-weight: 700; color: #fff;
}

/* Header right — action buttons (matches RPS) */
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: 8px; }
.header-right .hdr-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--toggle-border); border-radius: 8px;
  background: transparent; color: var(--text-mid);
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.header-right .hdr-btn:hover {
  border-color: var(--accent-border); color: var(--text);
  background: rgba(255,255,255,0.04);
}
.header-right .hdr-btn svg { width: 14px; height: 14px; }
.header-right .hdr-info { font-size: 12px; font-weight: 700; }
.hdr-desktop { display: flex !important; }
.hdr-mobile { display: none !important; }

/* Dots menu (mobile) */
.hdr-dots { position: relative; }
.dots-menu {
  display: none; position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 4px;
  min-width: 160px; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 60; flex-direction: column;
}
.dots-menu.open { display: flex; }
.dots-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 500; color: var(--text-75);
  cursor: pointer; transition: background 0.12s; white-space: nowrap;
}
.dots-menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.dots-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== GAME BODY ===== */
.game-body {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

/* ===== GAME BOARD ===== */
.board {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative;
  background: linear-gradient(rgba(18,13,36,0.50), rgba(18,13,36,0.50)), url('bg-new.png') center/cover no-repeat;
  background-color: var(--board);
  min-height: 0; min-width: 0; padding: 24px; overflow: hidden;
}

/* ===== GRID ===== */
.grid-wrap {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.grid {
  display: grid; gap: 8px;
  width: 100%; height: 100%;
  max-width: min(50vh, 580px); max-height: min(50vh, 580px);
  aspect-ratio: 1; grid-auto-rows: 1fr;
}
.grid.grid-boom { animation: gridShake 0.5s ease-out; }

/* ===== TILES ===== */
.tile {
  background: rgba(39, 40, 89, 0.6); border: none; border-radius: 14%;
  cursor: pointer; transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; position: relative; overflow: hidden;
  min-width: 0; min-height: 0; width: 100%; height: 100%;
  container-type: size; /* query container so children can size against the tile */
  -webkit-tap-highlight-color: transparent;
}
/* Hover only on devices with a real pointer (mouse) so it doesn't stick after a tap on touch screens */
@media (hover: hover) {
  .tile:hover:not(.tile-safe):not(.tile-mine):not(.tile-revealed):not(.tile-mine-other) { background: #3a5a6e; transform: translateY(-3px) scale(1.06); box-shadow: 0 4px 16px rgba(110, 207, 255, 0.2), 0 0 12px rgba(110, 207, 255, 0.1); }
}
/* Touch/press feedback: shows while finger is down, releases on lift (no sticking) */
.tile:active:not(.tile-safe):not(.tile-mine):not(.tile-revealed):not(.tile-mine-other) { background: #3a5a6e; transform: scale(0.96); box-shadow: 0 0 12px rgba(110, 207, 255, 0.12); }
.tile:disabled { cursor: default; }
.tile-revealed {
  background: linear-gradient(145deg, #163a58 0%, #1e4f75 40%, #2a6090 60%, #1e4f75 100%);
  box-shadow: inset 0 0 20px rgba(92, 184, 255, 0.08);
}
/* Queued (tapped, awaiting server confirmation) — pending highlight, not opened */
.tile-queued {
  background: rgba(247, 147, 26, 0.16);
  outline: 2px solid var(--accent); outline-offset: -2px;
  box-shadow: 0 0 14px rgba(247, 147, 26, 0.22);
  animation: tileQueuedPulse 0.9s ease-in-out infinite;
}
@keyframes tileQueuedPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.tile-mine {
  background: linear-gradient(145deg, #5c1a2a 0%, #7a2040 40%, #5c1a2a 100%);
  outline: 2px solid rgba(248, 95, 93, 0.6); outline-offset: -2px;
  box-shadow: 0 0 20px rgba(248, 95, 93, 0.35), inset 0 0 20px rgba(248, 95, 93, 0.12);
  animation: mineExplode 0.6s ease-out;
}
.tile-mine-other { background: var(--elevated); }
.tile-safe {
  background: linear-gradient(145deg, #163a58 0%, #1e4f75 40%, #2a6090 60%, #1e4f75 100%);
  opacity: 0.5;
}
.tile-icon { font-size: clamp(14px, 4vmin, 24px); line-height: 1; pointer-events: none; }
.tile-gem {
  width: 70%; height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.55)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.tile-gem-dim {
  width: 55%; height: 55%;
  object-fit: contain; opacity: 0.5;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.25));
}
.tile-bomb { width: 70%; height: 70%; object-fit: contain; animation: bombPulse 0.6s ease-out; }
.tile-bomb-other { width: 55%; height: 55%; object-fit: contain; opacity: 0.6; }
/* Floating multiplier that rises over the gem just revealed, then fades */
.tile-mult-pop {
  position: absolute; left: 50%; top: 50%;
  font-weight: 800; font-size: clamp(9px, 22cqmin, 22px);
  color: #fff; text-shadow: 0 1px 5px rgba(0,0,0,0.65), 0 0 10px rgba(0,0,0,0.4);
  pointer-events: none; z-index: 6; white-space: nowrap;
  animation: tileMultPop 0.75s ease-out forwards;
}
@keyframes tileMultPop {
  0%   { opacity: 0; transform: translate(-50%, -35%) scale(0.6); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  70%  { opacity: 1; transform: translate(-50%, -95%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -135%) scale(0.9); }
}

/* ===== RESULT BADGE ===== */
.result-badge {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 40px; border-radius: 14px;
  font-size: 20px; font-weight: 800; letter-spacing: 1px;
  white-space: nowrap; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; visibility: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.result-badge.win { color: #fff; background: var(--green); visibility: visible; animation: resultFade 0.3s ease; }
.result-badge.lose { color: #fff; background: var(--red); visibility: visible; animation: resultFade 0.3s ease; }
.result-badge.bigwin { color: #fff; background: linear-gradient(135deg, #0ECC68, #0aa855); visibility: visible; animation: resultFade 0.3s ease; font-size: 22px; box-shadow: 0 8px 30px rgba(14,204,104,0.4); }
.result-badge.superbigwin { color: #fff; background: linear-gradient(135deg, #F7931A, #E67A00); visibility: visible; animation: resultFade 0.3s ease; font-size: 24px; box-shadow: 0 8px 40px rgba(247,147,26,0.5); }
.result-badge.maxwin { color: #fff; background: linear-gradient(135deg, #FFD700, #F7931A); visibility: visible; animation: resultFade 0.3s ease; font-size: 26px; box-shadow: 0 8px 50px rgba(255,215,0,0.5); }
.result-badge.hidden { visibility: hidden; }

/* ===== STAKE-STYLE BET CONTROLS ===== */
.stake-bet { display: flex; gap: 6px; width: 100%; }
.stake-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.stake-input {
  display: flex; align-items: center; gap: 0;
  background: var(--board); border: 1px solid var(--hairline);
  border-radius: 10px; height: 38px; overflow: hidden;
}
.stake-pm {
  width: 36px; height: 100%; background: none; border: none;
  color: var(--text-mid); font-size: 18px; font-weight: 400;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color 0.12s;
}
.stake-pm:active { color: var(--text); }
.stake-pm:disabled { opacity: 0.3; cursor: not-allowed; }
.stake-amount {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; font-weight: 600;
  text-align: center; font-family: inherit;
  -moz-appearance: textfield;
}
.stake-amount::-webkit-inner-spin-button,
.stake-amount::-webkit-outer-spin-button { -webkit-appearance: none; }
.stake-amount:disabled { opacity: 0.5; }
.bet-amount-label { font-size: 11px; font-weight: 600; color: var(--text-mid); text-transform: uppercase; letter-spacing: 0.04em; }
/* Mini balance inside the bet input — desktop only */
.stake-input .stake-bal { display: none; }
@media (min-width: 861px) {
  .stake-input .stake-bal { display: flex; align-items: center; align-self: stretch; white-space: nowrap; font-size: 10px; font-weight: 600; color: var(--accent); border-left: 1px solid var(--hairline); padding: 0 10px 0 8px; flex-shrink: 0; }
}
.stake-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.stake-chip {
  height: 28px; background: var(--board); border: 1px solid var(--hairline);
  border-radius: 6px; color: var(--text-mid); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.12s;
}
.stake-chip:active { background: rgba(255,255,255,0.08); color: var(--text); }
.stake-chip:disabled { opacity: 0.3; cursor: not-allowed; }
.stake-bal {
  font-size: 10px; color: var(--accent); font-weight: 600;
  white-space: nowrap; padding-right: 10px;
  border-left: 1px solid var(--hairline); padding-left: 8px;
  height: 100%; display: flex; align-items: center;
}

/* Bet button (stake style) */
.stake-bet-btn {
  flex: 0 0 42%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: var(--accent); border: none; border-radius: 10px;
  cursor: pointer; transition: all 0.15s;
}
.stake-bet-btn:hover { filter: brightness(1.08); }
.stake-bet-btn:active { transform: scale(0.98); }
.stake-bet-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stake-bet-label {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.7);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.stake-bet-amount { font-size: 15px; font-weight: 800; color: #fff; }

/* Mobile cashout button */
.m-cashout-btn {
  flex: 0 0 42%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0ECC68 0%, #0aa855 100%);
  border: none; border-radius: 10px; color: #fff;
  font-family: inherit; font-weight: 800; font-size: 13px;
  cursor: pointer; text-transform: uppercase;
  transition: all 0.2s;
}
.m-cashout-btn:disabled {
  opacity: 1; background: #272859; color: #5C5C7A;
  cursor: not-allowed;
}
.m-cashout-btn .cashout-amount { font-size: 15px; font-weight: 800; }

/* Mobile stop button */
.m-stop-btn {
  flex: 0 0 42%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  background: var(--red); border: none; border-radius: 10px;
  color: #fff; font-weight: 800; font-size: 14px;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em;
}
.m-stop-sub {
  font-size: 10px; font-weight: 500; opacity: 0.7;
  letter-spacing: 0; font-variant-numeric: tabular-nums;
}

/* ===== COMPACT MINES/GRID SETTINGS ROW ===== */
.m-settings-row {
  display: flex; gap: 6px; width: 100%;
}
.mines-compact, .grid-compact {
  flex: 1; display: flex; flex-direction: column; gap: 3px;
}
.compact-label {
  font-size: 9px; font-weight: 600; color: var(--text-dimmer);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.compact-stepper {
  display: flex; align-items: center;
  background: var(--board); border: 1px solid var(--hairline);
  border-radius: 8px; height: 32px; overflow: hidden;
}
.compact-stepper button {
  width: 32px; height: 100%; background: none; border: none;
  color: var(--text-mid); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.compact-stepper button:active { color: var(--text); }
.compact-stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.compact-stepper span,
.compact-stepper input {
  flex: 1; text-align: center; font-size: 13px; font-weight: 700; color: var(--text);
  background: none; border: none; outline: none; font-family: inherit;
  -moz-appearance: textfield; width: 100%; min-width: 0;
}
.compact-stepper input::-webkit-inner-spin-button,
.compact-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.compact-stepper input:disabled { opacity: 0.5; }
.grid-size-selector {
  display: flex; gap: 0;
  background: var(--board); border: 1px solid var(--hairline);
  border-radius: 8px; overflow: hidden;
}
.grid-size-btn {
  flex: 1; height: 32px; border: none; background: transparent;
  color: var(--text-mid); font-family: inherit; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
  border-right: 1px solid var(--hairline);
}
.grid-size-btn:last-child { border-right: none; }
.grid-size-btn:hover:not(:disabled):not(.active) { background: var(--elevated); color: var(--text); }
.grid-size-btn.active { background: var(--accent); color: #fff; }
.grid-size-btn:disabled:not(.active) { opacity: 0.4; cursor: not-allowed; }

/* Auto open button */
.auto-open-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 32px;
  /* tinted accent fill so Auto Play clearly reads as an actionable button */
  background: var(--accent-glow); border: 1px solid var(--accent-border);
  border-radius: 8px; color: var(--text);
  font-size: 11px; font-weight: 700; cursor: pointer; transition: all 0.15s;
}
.auto-open-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.auto-open-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.auto-open-btn svg { width: 15px; height: 15px; }

/* ===== MOBILE ACTION ZONE ===== */
.m-action-zone { display: none; }

/* ===== DESKTOP FLOATING CONTROLS ===== */
.desktop-controls {
  position: fixed; bottom: 54px; left: 50%;
  transform: translateX(-50%);
  max-width: 480px; width: 90%;
  background: rgba(30, 24, 69, 0.92); backdrop-filter: blur(12px);
  border: 1px solid var(--hairline); border-radius: 12px;
  padding: 8px 10px; z-index: 40;
  display: flex; flex-direction: column; gap: 3px;
}
.desktop-controls .stake-bet-btn { flex: 0 0 40%; }
.desktop-controls .d-cashout-btn {
  display: none; flex: 0 0 40%;
  flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0ECC68 0%, #0aa855 100%);
  border: none; border-radius: 10px; color: #fff;
  font-weight: 800; font-size: 13px; cursor: pointer; text-transform: uppercase;
}
.desktop-controls .d-cashout-btn:disabled { opacity: 1; background: #272859; color: #5C5C7A; box-shadow: none; }
.desktop-controls .d-cashout-btn .cashout-amount { font-size: 15px; font-weight: 800; }
.desktop-controls .d-stop-btn {
  display: none; flex: 0 0 40%;
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--red); border: none; border-radius: 10px;
  color: #fff; font-weight: 800; font-size: 14px;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em;
}
.desktop-controls .d-stop-sub {
  font-size: 10px; font-weight: 500; opacity: 0.7;
  letter-spacing: 0; font-variant-numeric: tabular-nums;
}

/* Desktop states */
.app.playing .desktop-controls .stake-left { opacity: 0.4; pointer-events: none; }
.app.playing .desktop-controls .m-settings-row { opacity: 0.4; pointer-events: none; }
.app.playing .desktop-controls .stake-bet-btn { display: none; }
.app.playing .desktop-controls .d-cashout-btn { display: flex; }
.app.auto-running .desktop-controls .stake-left { opacity: 0.4; pointer-events: none; }
.app.auto-running .desktop-controls .m-settings-row { opacity: 0.4; pointer-events: none; }
.app.auto-running .desktop-controls .stake-bet-btn { display: none; }
.app.auto-running .desktop-controls .d-cashout-btn { display: none !important; }
.app.auto-running .desktop-controls .d-stop-btn { display: flex; }
.app.auto-running .desktop-controls .auto-open-btn {
  border-color: var(--accent); background: rgba(247,147,26,0.08);
  color: var(--accent); animation: autoPulse 2s ease-in-out infinite;
}

/* Desktop: board needs padding to clear overlay */
@media (min-width: 681px) {
  .board {
    padding: 16px 24px 140px;
    background: linear-gradient(rgba(18,13,36,0.50), rgba(18,13,36,0.50)), url('bg-new.png') center/cover no-repeat;
    background-color: var(--board);
  }
  .desktop-controls .stake-bet { gap: 4px; }
  .desktop-controls .stake-left { gap: 2px; }
  .desktop-controls .stake-input { height: 32px; }
  .desktop-controls .stake-pm { width: 28px; font-size: 15px; }
  .desktop-controls .stake-amount { font-size: 13px; }
  .desktop-controls .stake-chip { height: 22px; font-size: 10px; }
  .desktop-controls .stake-chips { gap: 2px; }
  .desktop-controls .stake-bet-btn { gap: 0; }
  .desktop-controls .stake-bet-label { font-size: 10px; }
  .desktop-controls .stake-bet-amount { font-size: 13px; }
  .desktop-controls .compact-stepper { height: 26px; }
  .desktop-controls .compact-stepper button { width: 26px; font-size: 13px; }
  .desktop-controls .compact-stepper span { font-size: 11px; }
  .desktop-controls .compact-label { font-size: 8px; }
  .desktop-controls .grid-size-btn { height: 26px; font-size: 10px; }
  .desktop-controls .grid-size-selector { border-radius: 6px; }
  .desktop-controls .auto-open-btn { height: 26px; font-size: 10px; }
  .desktop-controls .m-settings-row { gap: 4px; }
  .desktop-controls .m-stop-sub { font-size: 9px; }
}

/* ===== DRAWER SYSTEM ===== */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.08);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }
.drawer-backdrop.show .drawer { transform: translateY(0); }
.drawer {
  width: 100%; max-width: 480px; max-height: 85dvh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  overflow: hidden; /* clip header/body/footer to the rounded corners */
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; height: 56px; box-sizing: border-box; flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}
.drawer-title { font-weight: 600; font-size: 14px; color: var(--text); }
.drawer-close {
  width: 36px; height: 36px;
  display: flex; justify-content: center; align-items: center;
  background: none; border: none; border-radius: 10px;
  cursor: pointer; color: var(--text-mid);
}
.drawer-close:active { background: rgba(255,255,255,0.06); }
.drawer-close svg { width: 18px; height: 18px; }
.drawer-tabs {
  display: flex; align-items: center; padding: 4px;
  margin: 0 16px 12px;
  background: var(--board); border: 1px solid var(--hairline); border-radius: 14px;
}
.drawer-tab {
  flex: 1; height: 32px;
  display: flex; justify-content: center; align-items: center;
  border: none; border-radius: 10px; background: transparent;
  cursor: pointer; font-weight: 400; font-size: 12px; color: var(--text-mid);
  font-family: inherit;
}
.drawer-tab.active {
  background: var(--card-bg); color: var(--text);
  box-shadow: 0 1px 0 var(--card-shadow); font-weight: 500;
}
.drawer-body {
  overflow-y: auto; flex: 1;
  padding: 4px 16px 16px;
}
/* Pinned action footer (Auto Play "Start") — stays visible in short iframe
   viewports instead of scrolling out of view. */
.drawer-footer {
  flex-shrink: 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  background: var(--panel);
}
.drawer-footer .auto-start-drawer-btn { margin: 0; width: 100%; }
.drawer-body::-webkit-scrollbar { width: 3px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb { background: rgba(145,159,192,0.15); border-radius: 2px; }

/* Drawer → centered modal on desktop */
@media (min-width: 681px) {
  .drawer-backdrop { align-items: center; }
  .drawer-backdrop.show .drawer { transform: scale(1); }
  .drawer {
    max-width: 480px; max-height: 70dvh; border-radius: 16px;
    transform: scale(0.9); opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .drawer-backdrop.show .drawer { opacity: 1; }
  .drawer-header { border-radius: 16px 16px 0 0; }
  .drawer-body { border-radius: 0 0 16px 16px; }
}

/* Drawer content primitives */
.drw-text { font-size: 12px; line-height: 1.6; color: var(--text-75); }
.drw-card {
  background: rgba(0,0,0,0.2); border-radius: 16px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 10px;
}
.drw-card:last-child { margin-bottom: 0; }
.drw-card-title { font-weight: 500; font-size: 13px; color: var(--text); text-align: center; }
.drw-stat-row {
  display: flex; justify-content: space-between; align-items: center; height: 28px;
}
.drw-stat-label { font-size: 12px; color: var(--text-mid); }
.drw-stat-value { font-size: 12px; font-weight: 600; color: var(--text); }
.drw-stat-value.green { color: var(--green); }
.drw-steps {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(0,0,0,0.2); border-radius: 14px; padding: 12px;
}
.drw-step { display: flex; gap: 10px; align-items: center; }
.drw-step-num {
  width: 24px; height: 24px; min-width: 24px;
  border-radius: 50%; background: var(--accent); color: var(--board);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.drw-step-text { flex: 1; font-size: 12px; line-height: 1.5; color: var(--text-75); }
.drw-step-arrow { display: flex; padding: 0 12px; }
.drw-step-arrow-line { width: 0; height: 12px; border-left: 1px dashed var(--text-dim); }

/* PF drawer inputs */
.drw-input {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; background: var(--board);
  border: 1px solid var(--hairline); border-radius: 14px;
  padding: 8px 10px 8px 14px; box-sizing: border-box; width: 100%;
}
.drw-input:focus-within { border-color: var(--accent-border); }
.drw-input-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.drw-input-label { font-size: 10px; color: var(--text-mid); line-height: 1.4; }
.drw-input-value {
  font-size: 13px; color: var(--text); background: none; border: none;
  outline: none; padding: 0; width: 100%; font-family: inherit;
}
.drw-input-value.mono { font-family: monospace; font-size: 11px; word-break: break-all; }
.drw-input-value.green { color: var(--green); }
.drw-input-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; min-width: 32px;
  background: var(--card-bg); border: none; border-radius: 10px;
  cursor: pointer; color: var(--text-mid);
}
.drw-input-btn:active { transform: scale(0.92); }
.drw-input-btn svg { width: 14px; height: 14px; }
.drw-save-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 44px;
  background: rgba(255,255,255,0.08); border: 1px solid var(--hairline); border-radius: 12px;
  font-weight: 600; font-size: 13px; color: var(--text); cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.drw-save-btn:hover { background: rgba(255,255,255,0.12); }
.drw-save-btn:disabled { opacity: 0.4; cursor: default; }

/* ===== HISTORY LIST ===== */
.hist-list { display: flex; flex-direction: column; gap: 6px; }
.hist-item {
  background: var(--elevated); border-radius: 14px;
  overflow: hidden; cursor: pointer; transition: background 0.12s;
}
.hist-item:hover { background: #2f2c66; }
.hist-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 4px; width: 100%; box-sizing: border-box;
}
.hist-left { display: flex; align-items: center; min-width: 0; flex-shrink: 1; }
.hist-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; min-width: 36px; border-radius: 10px;
}
.hist-icon svg { width: 18px; height: 18px; }
.hist-info { display: flex; flex-direction: column; justify-content: center; margin-left: 2px; }
.hist-info-title { font-weight: 500; font-size: 13px; line-height: 1.4; color: var(--text); white-space: nowrap; }
.hist-info-sub { font-weight: 400; font-size: 10px; line-height: 1.4; color: var(--text-mid); white-space: nowrap; }
.hist-right { display: flex; align-items: center; flex-shrink: 0; margin-left: auto; }
.hist-chips { display: flex; align-items: center; gap: 6px; }
.hist-mult-chip {
  display: flex; align-items: center; justify-content: center;
  height: 24px; min-width: 48px; padding: 4px 8px;
  background: var(--card-bg); border-radius: 8px;
  box-shadow: 0 1px 0 var(--card-shadow);
  font-weight: 500; font-size: 11px; line-height: 1; color: var(--text-75);
  white-space: nowrap;
}
.hist-payout-chip {
  display: flex; align-items: center; justify-content: center;
  height: 24px; min-width: 64px; padding: 4px 8px;
  border-radius: 8px; font-weight: 600; font-size: 11px; line-height: 1; white-space: nowrap;
}
.hist-payout-chip--win { background: var(--green-bg); color: var(--green); }
.hist-payout-chip--lose { background: var(--red-bg); color: var(--red); }
.hist-chevron {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-left: 4px;
}
.hist-chevron svg { width: 14px; height: 14px; }
.hist-details { padding: 0 8px 8px; width: 100%; box-sizing: border-box; }
.hist-details-inner {
  display: flex; flex-direction: column; gap: 10px;
  background: rgba(0,0,0,0.18); border-radius: 10px; padding: 10px 12px;
}
.hist-seeds { display: flex; flex-direction: column; gap: 8px; }
.hist-seed-group { display: flex; flex-direction: column; }
.hist-seed-label { font-weight: 500; font-size: 10px; line-height: 1.4; color: var(--text-mid); }
.hist-seed-value {
  font-weight: 400; font-size: 11px; line-height: 1.4; color: var(--text-75);
  word-break: break-all; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.hist-verify-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 36px; background: rgba(255,255,255,0.06);
  border: 1px solid var(--hairline); border-radius: 8px;
  color: var(--text-75); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.hist-verify-btn:hover { border-color: var(--accent-border); color: var(--text); }
.hist-verify-btn:disabled { opacity: 0.5; cursor: default; }
.hist-verify-btn svg { width: 16px; height: 16px; }
.hist-pager {
  display: flex; justify-content: center; align-items: center;
  gap: 10px; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.hist-pager-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--toggle-border); background: transparent;
  color: var(--text-mid); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-family: inherit;
}
.hist-pager-btn:hover:not(:disabled) { border-color: var(--accent-border); color: var(--text); }
.hist-pager-btn:disabled { opacity: 0.2; cursor: default; }
.hist-pager-info { font-size: 11px; color: var(--text-mid); min-width: 40px; text-align: center; }
.hist-empty, .hist-loading {
  text-align: center; padding: 40px 0; color: var(--text-dim); font-size: 12px;
}

/* ===== AUTO PLAY CHIPS ===== */
.auto-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.auto-chip {
  flex: 1; min-width: 0; padding: 6px 4px;
  border: 1px solid var(--hairline); border-radius: 5px;
  background: transparent; color: var(--text-75);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; text-align: center; white-space: nowrap;
  font-family: inherit;
}
.auto-chip:hover { border-color: var(--text-mid); color: var(--text); }
.auto-chip.selected { border-color: var(--accent); color: var(--accent); background: rgba(247,147,26,0.06); }
.auto-start-drawer-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 40px;
  background: var(--accent); border: none; border-radius: 12px;
  color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; margin-top: 4px; transition: all 0.15s;
  font-family: inherit;
}
.auto-start-drawer-btn:hover { filter: brightness(1.1); }
.auto-start-drawer-btn:active { transform: scale(0.98); }

/* ===== FOOTER ===== */
.bottom {
  height: 44px; background: #23204e;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0;
}
.bottom-icons { display: flex; gap: 14px; align-items: center; }
.ic { color: rgba(255,255,255,0.7); cursor: pointer; display: flex; align-items: center; transition: color 0.2s, transform 0.15s; }
.ic:hover { color: #fff; transform: scale(1.1); }
.ic.muted { color: var(--red); }
.ic.faved { color: var(--accent); }
.ic.faved svg { fill: var(--accent); }
.bottom-logo { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.4); letter-spacing: 0.12em; }

/* ===== ALERT ===== */
/* Centered over the board, same position as the win/lose result badge */
.alert-toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 8px;
  padding: 14px 28px; background: rgba(248, 95, 93, 0.18);
  border: 1px solid rgba(248, 95, 93, 0.45); border-radius: 14px;
  color: var(--red); font-size: 14px; font-weight: 700;
  z-index: 40; backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: resultFade 0.3s ease; white-space: nowrap; pointer-events: none;
}
.alert-icon { font-size: 16px; }

/* ===== MODALS (kept for free bet welcome/summary) ===== */
.modal-overlay {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.08);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px;
  width: min(420px, calc(100vw - 32px)); max-height: min(520px, 70dvh);
  overflow-y: auto; padding: 24px; position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
}
.modal::-webkit-scrollbar { width: 3px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: rgba(145,159,192,0.15); border-radius: 2px; }
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; background: var(--card-bg);
  border: 1px solid var(--hairline); border-radius: 8px;
  color: var(--text-mid); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { border-color: var(--accent-border); color: var(--text); }

/* Playing stats (shown in board area on mobile) */
.playing-stats {
  display: flex; gap: 6px; width: 100%;
}
.playing-stat {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.03);
  border-radius: 10px; padding: 8px 4px; gap: 2px;
}
.playing-stat-label {
  font-size: 9px; font-weight: 600; color: var(--text-mid);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.playing-stat-val { font-size: 14px; font-weight: 800; color: var(--text); }
.playing-stat-val.accent { color: var(--accent); }
.playing-stat-val.green { color: var(--green); }

/* Profit display inline */
.profit-inline {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--green-bg); border: 1px solid rgba(14, 204, 104, 0.25);
  border-radius: 8px; padding: 6px 12px; width: 100%;
}
.profit-inline-label { font-size: 10px; font-weight: 600; color: var(--text-mid); }
.profit-inline-val { font-size: 14px; font-weight: 800; color: var(--green); }

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--board, #120D24);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.loading-screen.hidden { display: none; }
.loading-content {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.loading-logo { width: 80px; height: auto; }
.loading-bar-wrap {
  width: 160px; height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px; overflow: hidden; margin-top: 8px;
}
.loading-bar {
  width: 100%; height: 100%;
  background: #F7931A; border-radius: 3px;
  animation: loading-fill 2.5s ease forwards;
}
@keyframes loading-fill { 0% { width: 0%; } 100% { width: 100%; } }
.loading-text {
  font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 4px;
  font-family: 'Montserrat', sans-serif;
}

/* ===== ANIMATIONS ===== */
@keyframes mineExplode {
  0% {
    background: radial-gradient(circle, rgba(255,255,200,1) 0%, rgba(255,120,30,0.9) 40%, rgba(255,80,30,0.4) 100%);
    box-shadow: 0 0 80px rgba(255,200,50,0.9), 0 0 150px rgba(255,80,30,0.5);
  }
  20% {
    background: radial-gradient(circle, rgba(255,200,50,0.8) 0%, rgba(255,80,30,0.6) 50%, rgba(47,69,83,0.8) 100%);
    box-shadow: 0 0 40px rgba(255,150,50,0.6), 0 0 80px rgba(255,80,30,0.3);
  }
  50% {
    background: radial-gradient(circle, rgba(255,100,30,0.3) 0%, var(--elevated) 70%);
    box-shadow: 0 0 15px rgba(255,100,50,0.2);
  }
  100% {
    background: linear-gradient(145deg, #5c1a2a 0%, #7a2040 40%, #5c1a2a 100%);
    box-shadow: 0 0 20px rgba(248, 95, 93, 0.35), inset 0 0 20px rgba(248, 95, 93, 0.12);
  }
}
@keyframes bombPulse {
  0% { transform: scale(0); opacity: 0; }
  20% { transform: scale(1.4); opacity: 1; }
  40% { transform: scale(0.9); }
  55% { transform: scale(1.15); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); }
}
@keyframes gridShake {
  0% { transform: translate(0, 0); }
  10% { transform: translate(-6px, -4px); }
  20% { transform: translate(5px, 6px); }
  30% { transform: translate(-7px, 3px); }
  40% { transform: translate(4px, -5px); }
  50% { transform: translate(-3px, 4px); }
  60% { transform: translate(5px, -2px); }
  70% { transform: translate(-2px, 3px); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 1px); }
  100% { transform: translate(0, 0); }
}
@keyframes cashoutPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(247,147,26,0.30), inset 0 1px 0 rgba(255,255,255,0.2); }
  50% { box-shadow: 0 6px 28px rgba(247,147,26,0.50), inset 0 1px 0 rgba(255,255,255,0.2); }
}
@keyframes resultFade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes alertSlide {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes autoPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(247,147,26,0); }
  50% { box-shadow: 0 0 0 3px rgba(247,147,26,0.12); }
}
@keyframes freeBetPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(247,147,26,0.30), inset 0 1px 0 rgba(255,255,255,0.2); }
  50% { box-shadow: 0 8px 32px rgba(247,147,26,0.50), inset 0 1px 0 rgba(255,255,255,0.2); }
}
@keyframes fbwBounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== RESPONSIVE ===== */

/* Phone — mobile layout */
@media (max-width: 680px) {
  .desktop-controls { display: none !important; }
  .hdr-desktop { display: none !important; }
  .hdr-mobile { display: flex !important; }
  .bottom { display: none !important; }

  .header { padding: 0 10px; height: 44px; }
  .game-name span:last-child { display: none; }

  .m-action-zone {
    display: flex !important; flex-direction: column;
    gap: 6px; padding: 8px 12px 6px;
    background: var(--panel); flex-shrink: 0;
  }

  .board { padding: 8px; flex: 1; min-height: 0; overflow: hidden; }
  /* Square tiles on mobile, whatever the board's size: make grid-wrap a size
     container, then size the grid to the SMALLER of the board's width/height
     (min(100cqw,100cqh)) so the largest possible square always fits without
     overflowing/clipping. aspect-ratio:1 keeps tiles perfectly square. */
  .grid-wrap { container-type: size; }
  .grid {
    gap: 5px;
    width: min(100cqw, 100cqh); height: auto;
    max-width: 100%; max-height: 100%;
    aspect-ratio: 1;
  }
  .result-badge { font-size: 14px; padding: 10px 24px; }

  /* Mobile playing states */
  .app.playing .m-action-zone .stake-left { opacity: 0.4; pointer-events: none; }
  .app.playing .m-action-zone .m-settings-row { opacity: 0.4; pointer-events: none; }
  .app.playing .m-action-zone .stake-bet-btn { display: none !important; }
  .app.playing .m-action-zone .m-cashout-btn { display: flex !important; }

  .app.auto-running .m-action-zone .stake-left { opacity: 0.4; pointer-events: none; }
  .app.auto-running .m-action-zone .m-settings-row { opacity: 0.4; pointer-events: none; }
  .app.auto-running .m-action-zone .stake-bet-btn { display: none !important; }
  .app.auto-running .m-action-zone .m-cashout-btn { display: none !important; }
  .app.auto-running .m-action-zone .m-stop-btn { display: flex !important; }
  .app.auto-running .m-action-zone .auto-open-btn {
    border-color: var(--accent) !important;
    background: rgba(247,147,26,0.08) !important;
    color: var(--accent) !important;
    animation: autoPulse 2s ease-in-out infinite !important;
  }

  /* Hide default mobile buttons until state activates them */
  .m-action-zone .m-cashout-btn { display: none; }
  .m-action-zone .m-stop-btn { display: none; }
}

/* Small phone */
@media (max-width: 420px) {
  .grid { gap: 4px; }
  .header { height: 40px; padding: 0 8px; }
  .game-name { font-size: 12px; }
  .m-action-zone { padding: 6px 10px 4px; gap: 4px; }
  .compact-stepper { height: 28px; }
  .grid-size-btn { height: 28px; font-size: 10px; }
}

/* ===== FREE BET UI ===== */
.free-bet-banner {
  background: linear-gradient(135deg, rgba(247,147,26,0.15) 0%, rgba(247,147,26,0.05) 100%);
  border: 1px solid rgba(247,147,26,0.35); border-radius: 10px;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  margin: 0 12px;
}
.free-bet-icon { font-size: 20px; }
.free-bet-info { flex: 1; }
.free-bet-title { font-size: 12px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.free-bet-count { font-size: 11px; font-weight: 600; color: var(--text-mid); margin-top: 2px; }
.free-bet-progress { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.free-bet-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }
.place-btn.free-mode { background: linear-gradient(135deg, #F7931A 0%, #E67A00 100%); animation: freeBetPulse 2s ease-in-out infinite; }
.input-row.locked { opacity: 0.6; pointer-events: none; border-color: rgba(247,147,26,0.3); }

/* Free bet summary modal */
.free-bet-summary { text-align: center; max-width: 360px; }
.fbs-icon { font-size: 48px; margin-bottom: 8px; }
.free-bet-summary h2 { margin-bottom: 16px; }
.fbs-stats { display: flex; gap: 8px; margin-bottom: 16px; }
.fbs-stat {
  flex: 1; background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center;
}
.fbs-stat-label { font-size: 9px; font-weight: 600; color: var(--text-dimmer); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.fbs-stat-val { font-size: 15px; font-weight: 800; }
.fbs-stat-val.accent { color: var(--accent); }
.fbs-winnings {
  display: flex; flex-direction: column; align-items: center; padding: 16px;
  background: linear-gradient(135deg, rgba(247,147,26,0.12) 0%, rgba(247,147,26,0.04) 100%);
  border: 1px solid rgba(247,147,26,0.3); border-radius: 12px;
}
.fbs-winnings-label { font-size: 11px; font-weight: 600; color: var(--text-mid); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.fbs-winnings-val { font-size: 28px; font-weight: 800; color: var(--accent); }
.fbs-btn {
  display: block; width: 100%; height: 50px; margin-top: 16px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #F7931A 0%, #E67A00 100%);
  color: #fff; font-family: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em;
  box-shadow: 0 4px 16px rgba(247,147,26,0.30), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all 0.2s;
}
.fbs-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* Free bet welcome modal */
.free-bet-welcome { text-align: center; max-width: 360px; }
.fbw-icon { font-size: 56px; margin-bottom: 12px; animation: fbwBounce 0.6s ease-out; }
.fbw-desc { font-size: 15px; color: var(--text-mid); line-height: 1.5; margin-bottom: 4px; }
.fbw-hl { color: var(--accent); font-weight: 800; }
.fbw-sub { font-size: 13px; color: var(--text-mid); line-height: 1.6; margin-bottom: 18px; }
.fbw-sub strong { color: var(--text); font-weight: 800; }
.fbs-played { font-size: 14px; color: var(--text-mid); margin-bottom: 14px; }
.fbs-played strong { color: var(--text); font-weight: 800; }
.fbs-total { font-size: 20px; font-weight: 800; white-space: nowrap; margin: 4px 0 16px; }
.fbw-count {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px;
  background: linear-gradient(135deg, rgba(247,147,26,0.12) 0%, rgba(247,147,26,0.04) 100%);
  border: 1px solid rgba(247,147,26,0.3); border-radius: 12px;
}
.fbw-count-num { font-size: 40px; font-weight: 800; color: var(--accent); line-height: 1; }
.fbw-count-label { font-size: 13px; font-weight: 700; color: var(--text-mid); text-transform: uppercase; letter-spacing: 0.06em; }
.fbw-btn {
  display: block; width: 100%; height: 50px; margin-top: 16px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #F7931A 0%, #E67A00 100%);
  color: #fff; font-family: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em;
  box-shadow: 0 4px 16px rgba(247,147,26,0.30), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all 0.2s; animation: freeBetPulse 2s ease-in-out infinite;
}
.fbw-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

@media (max-width: 680px) {
  .free-bet-banner { margin: 0; padding: 8px 10px; border-radius: 8px; }
  .free-bet-title { font-size: 11px; }
  .free-bet-count { font-size: 10px; }
}

/* ===== Auto-play summary — SVG icon badge + win/lose tint ===== */
.fbs-icon {
  width: 60px; height: 60px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: rgba(247,147,26,0.14);
  border: 1px solid rgba(247,147,26,0.30);
  color: var(--accent);
  font-size: 30px; line-height: 1;
}
.fbs-icon svg { width: 28px; height: 28px; }
.fbs-icon-win { background: rgba(14,204,104,0.14); border-color: rgba(14,204,104,0.32); color: var(--green); }
.fbs-icon-lose { background: rgba(248,95,93,0.14); border-color: rgba(248,95,93,0.32); color: var(--red); }

/* ===== Free Rounds — compact tag (replaces the old banner + progress bar) ===== */
.free-round-tag {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(247,147,26,0.15) 0%, rgba(247,147,26,0.05) 100%);
  border: 1px solid rgba(247,147,26,0.35);
  border-radius: 10px; font-size: 12px;
}
.free-round-ico { display: flex; align-items: center; color: var(--accent); }
.free-round-ico svg { width: 16px; height: 16px; }
.free-round-text { font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.free-round-count { font-weight: 700; color: var(--text); }
.free-round-profit { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.free-round-profit.pos { color: var(--green); }
.free-round-profit.neg { color: var(--red); }
/* Free Round indicator occupying the bet-input slot — same size; layout & button unchanged */
.free-round-slot {
  flex: 1; min-width: 0; grid-column: 1 / -1;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(247,147,26,0.15) 0%, rgba(247,147,26,0.05) 100%);
  border: 1px solid rgba(247,147,26,0.35);
  border-radius: 10px;
}
.frs-row1 { display: flex; align-items: center; gap: 8px; }
.frs-row1 .free-round-ico { display: flex; align-items: center; color: var(--accent); }
.frs-row1 .free-round-ico svg { width: 16px; height: 16px; }
.frs-label { font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }
.frs-amount { margin-left: auto; font-weight: 700; color: var(--text-mid); font-size: 12px; font-variant-numeric: tabular-nums; }
.frs-count { margin-left: auto; font-weight: 700; color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.frs-row2 { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-mid); font-weight: 600; white-space: nowrap; }
.frs-tw { margin-left: auto; }
.frs-bet { color: var(--text); font-weight: 700; }
.frs-row2 b { color: var(--green); font-weight: 800; font-variant-numeric: tabular-nums; }
/* Keep the Free Round indicator fully visible while playing (don't dim it like the bet input) */
.app.playing .m-action-zone .stake-left:has(.free-round-slot),
.app.playing .desktop-controls .stake-left:has(.free-round-slot) { opacity: 1; pointer-events: auto; }

/* Bet Amount panel dimmed + locked during free rounds */
.stake-left.free-locked { opacity: 0.5; pointer-events: none; cursor: not-allowed; }

/* Gift icon badge (welcome) + sizing — replaces the emoji */
.fbw-icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px;
  background: rgba(247,147,26,0.14); border: 1px solid rgba(247,147,26,0.30);
  color: var(--accent);
}
.fbw-icon svg { width: 34px; height: 34px; }
.fbs-winnings.fbs-win { background: linear-gradient(135deg, rgba(14,204,104,0.14), rgba(14,204,104,0.04)); border-color: rgba(14,204,104,0.30); }
.fbs-winnings.fbs-lose { background: linear-gradient(135deg, rgba(248,95,93,0.14), rgba(248,95,93,0.04)); border-color: rgba(248,95,93,0.30); }

/* Mobile: .modal (free-bet + auto-play summary) becomes a bottom-sheet drawer */
@media (max-width: 680px) {
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%; max-height: 88dvh;
    border-radius: 18px 18px 0 0; border-bottom: none;
    padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
  }
  .modal::before {
    content: ''; display: block; width: 36px; height: 4px;
    background: var(--hairline); border-radius: 2px; margin: -4px auto 16px;
  }
  .modal-overlay.show .modal { animation: mines-sheet-up 0.3s cubic-bezier(0.16,1,0.3,1); }
}
@keyframes mines-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== Mines slider control — balls (gems) | slider | red cards (mines) ===== */
.m-settings-row { flex-direction: column; gap: 8px; }
.mines-slider-wrap { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.mines-bar { display: flex; align-items: center; gap: 10px; }
.mb-pill {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
  height: 32px; padding: 0 10px; border-radius: 10px;
  font-size: 16px; font-weight: 800; line-height: 1;
}
.mb-pill img { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.mb-gems  { background: var(--green-bg); border: 1px solid rgba(14,204,104,0.45); color: var(--green); }
.mb-mines { background: var(--red-bg);   border: 1px solid rgba(248,95,93,0.50); color: var(--red); }
.mines-bar .mines-slider { flex: 1; min-width: 0; }
.mines-slider {
  -webkit-appearance: none; appearance: none;
  height: 24px;            /* interaction area = thumb height, so it centers */
  background: transparent;  /* the visible bar is the runnable-track below */
  outline: none; cursor: pointer; margin: 0;
}
/* the visible track (8px), vertically centered in the 24px input */
.mines-slider::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--fill, 0%), rgba(248,95,93,0.55) var(--fill, 0%) 100%);
}
.mines-slider::-moz-range-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--fill, 0%), rgba(248,95,93,0.55) var(--fill, 0%) 100%);
}
/* white rounded-square thumb, centered on the 8px track */
.mines-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 7px;
  background: #fff; border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5); margin-top: -8px;
}
.mines-slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 7px;
  background: #fff; border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.mines-slider:disabled { opacity: 0.5; cursor: not-allowed; }
.mines-slider-odds { width: 100%; text-align: center; font-size: 10px; font-weight: 600; color: var(--text-mid); letter-spacing: 0.01em; }

/* Desktop: mines picker and grid selector on one aligned row (no GRID label,
   both halves single-height so they line up — keeps the panel compact) */
@media (min-width: 681px) {
  .m-settings-row { flex-direction: row; align-items: center; gap: 12px; }
  .mines-slider-wrap { flex: 1 1 62%; min-width: 0; }
  .grid-compact { flex: 1 1 38%; min-width: 0; }
  .grid-compact .grid-size-selector { width: 100%; }
}

/* ===== Phone landscape: two-column (grid left, control rail right) =====
   Mines has no .row/.side; the rail is built by turning .game-body into a row
   and promoting .m-action-zone to a right rail. !important beats the
   max-width:860 mobile rules that co-match at ~844x390. */
@media (max-height: 500px) and (orientation: landscape) and (min-width: 500px) {
  .bottom { display: none !important; }   /* no footer in landscape — saves the scarce vertical space */
  .game-body { flex-direction: row !important; }
  .board { flex: 1 1 auto !important; min-width: 0 !important; padding: 8px !important; }
  /* grid was capped at 50vh (~195px in landscape). Size it by HEIGHT with
     width:auto so aspect-ratio:1 makes a square that fills the short board. */
  .grid { height: 100% !important; width: auto !important; max-width: 100% !important; max-height: 100% !important; aspect-ratio: 1 !important; }
  .desktop-controls { display: none !important; }
  .m-action-zone {
    display: flex !important; flex-direction: column !important;
    order: 1 !important; width: 300px !important; flex: 0 0 300px !important;
    background: #23204e !important; border-left: 1px solid var(--hairline) !important;
    padding: 14px 12px !important; gap: 10px !important; overflow-y: auto !important;
    justify-content: flex-start !important;
  }
  /* bet block: stepper (left) + 1/5/10/Max horizontal row (right), label spans top */
  .m-action-zone .stake-bet { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
  .m-action-zone .stake-left { display: grid !important; grid-template-columns: minmax(0,1fr) minmax(0,1.25fr) !important; align-items: center !important; gap: 6px !important; }
  .m-action-zone .bet-amount-label { grid-column: 1 / -1 !important; margin: 0 !important; }
  .m-action-zone .stake-input { grid-column: 1 !important; width: auto !important; min-width: 0 !important; height: 44px !important; }
  .m-action-zone .stake-chips { grid-column: 2 !important; display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 4px !important; }
  .m-action-zone .stake-chip { height: 44px !important; min-width: 0 !important; padding: 0 !important; font-size: 13px !important; }
  .m-action-zone .stake-bet-btn { width: 100% !important; height: 46px !important; min-height: 0 !important; }
  .m-action-zone .config-chip, .m-action-zone .auto-open-btn { width: 100% !important; }
  .m-action-zone .config-chip { margin-top: 8px !important; }   /* separate from PLACE BET */
  /* drawers: centered, fit, scroll (covers the Config drawer too) */
  .drawer-backdrop { align-items: center !important; }
  .drawer { width: min(600px,92vw) !important; max-width: 600px !important; max-height: 90dvh !important; border-radius: 16px !important; }
  .drawer-body { max-height: none !important; }
  /* modals: centered + compact */
  .modal-overlay { align-items: center !important; }
  .modal { max-height: 92dvh !important; }
  .modal::before { display: none !important; }
  .fbs-icon { width: 40px !important; height: 40px !important; margin-bottom: 4px !important; }
  .fbs-icon svg { width: 22px !important; height: 22px !important; }
  .fbs-stats, .fbs-stats-3 { margin-bottom: 10px !important; }
  .fbs-winnings { padding: 10px !important; margin-bottom: 10px !important; }
  .fbs-winnings-val { font-size: 22px !important; }
}

/* Free-round welcome / summary / auto-summary: flex column so the action button
   sits in normal flow BELOW the content (never overlapping the Net Profit value).
   Taller max-height keeps it on-screen without scrolling in short / iframe viewports. */
.modal.free-bet-welcome,
.modal.free-bet-summary { display: flex; flex-direction: column; max-height: min(560px, 88dvh); }
.modal .fbw-btn,
.modal .fbs-btn { flex-shrink: 0; }
