: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; }
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; }

/* ===== 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;
}

.app > * { width: 100%; }

/* ===== HEADER ===== */
.header {
  display: flex; height: 50px; background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.game-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.game-name .ico { font-size: 18px; color: var(--accent); }
.header-balance {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, rgba(247,147,26,0.10) 0%, rgba(247,147,26,0.02) 100%);
  border: 1px solid rgba(247,147,26,0.18); border-radius: 999px;
  padding: 6px 16px 6px 10px; transition: border-color 0.2s;
}
.header-balance:hover { border-color: rgba(247,147,26,0.35); }
.header-bal-icon { font-size: 13px; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.header-bal-value { font-size: 14px; font-weight: 700; color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 8px; }
.fairplay {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--toggle-border); border-radius: 8px;
  font-size: 11px; font-weight: 600; color: var(--text-mid); cursor: pointer; transition: all 0.2s;
}
.fairplay::before {
  content: ''; width: 14px; height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23919FC0' stroke-width='2'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.fairplay:hover { border-color: var(--accent-border); color: var(--text); }
.info {
  width: 30px; height: 30px; border: 1px solid var(--toggle-border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-mid); cursor: pointer; transition: all 0.2s;
}
.info:hover { border-color: var(--accent-border); color: var(--text); }

/* ===== GAME BODY (sidebar + grid) ===== */
.game-body {
  flex: 1; display: flex; min-height: 0;
}

/* ===== LEFT SIDEBAR ===== */
.sidebar {
  width: 300px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  padding: 20px;
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(145,159,192,0.15); border-radius: 2px; }

.ctrl-group { display: flex; flex-direction: column; gap: 8px; }
.ctrl-action { display: flex; flex-direction: column; margin-top: auto; }
.ctrl-action .place-btn,
.ctrl-action .cancel-btn { margin-top: 0; }

/* Desktop: push button to bottom */
@media (min-width: 681px) {
  .sidebar { display: flex; flex-direction: column; }
  .ctrl-action { order: 99; margin-top: auto; }
  .ctrl-bet { order: 1; }
  .ctrl-grid { order: 2; }
  .ctrl-mines { order: 3; }
  .ctrl-stats { order: 4; }
  .ctrl-profit { order: 5; }
}
.ctrl-label {
  font-size: 12px; font-weight: 700; color: var(--text-mid);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Bet input */
.input-row {
  display: flex; align-items: center;
  border: 1px solid var(--input-border); border-radius: 10px; overflow: hidden;
  background: linear-gradient(180deg, #1E1845 0%, #1E1845 100%);
  transition: border-color 0.2s, box-shadow 0.2s;
  height: 46px;
}
.input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(247, 147, 26, 0.08); }
.currency { width: 38px; font-weight: 700; font-size: 14px; color: var(--accent); text-align: center; flex-shrink: 0; }
.input-row input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  font-family: inherit; font-weight: 600; font-size: 15px; color: var(--text); padding: 0 8px;
  -moz-appearance: textfield; width: 80px;
}
.input-row input::-webkit-outer-spin-button,
.input-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-row input:disabled { opacity: 0.5; }
.chips { display: flex; gap: 4px; padding: 0 8px; flex-shrink: 0; }
.chip {
  width: 40px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--toggle-border);
  color: var(--text-75); font-size: 11px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.chip:hover:not(:disabled) {
  border-color: var(--accent-border); background: rgba(247, 147, 26, 0.08);
  color: var(--accent); transform: translateY(-1px);
}
.chip:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== MINES SLIDER ===== */
.mines-slider-wrap { width: 100%; }
.mines-slider-ends {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 10px 14px;
  min-width: 0;
}
.slider-end {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 800;
  padding: 4px 10px; border-radius: 8px; white-space: nowrap;
  flex-shrink: 0;
}
.slider-end-icon { font-size: 16px; }
.gem-end {
  background: rgba(247, 147, 26, 0.12); color: var(--accent);
  border: 1px solid rgba(247, 147, 26, 0.25);
}
.mine-end {
  background: rgba(248, 95, 93, 0.12); color: var(--red);
  border: 1px solid rgba(248, 95, 93, 0.25);
}

.mines-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 8px; border-radius: 4px; outline: none; cursor: pointer;
  min-width: 0;
}
.mines-slider:disabled { opacity: 0.4; cursor: not-allowed; }
.mines-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 6px;
  background: #e0e0e0; border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.mines-slider::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 6px;
  background: #e0e0e0; border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ===== GRID SIZE SELECTOR ===== */
.grid-size-selector {
  display: flex; gap: 0;
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: 10px; overflow: hidden;
}
.grid-size-btn {
  flex: 1; height: 42px; border: none;
  background: transparent;
  color: var(--text-mid); font-family: inherit; font-size: 15px; 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; }

/* Sidebar stats */
.sidebar-stats { display: flex; gap: 6px; }
.sidebar-stat {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 8px 6px;
}
.sidebar-stat-label {
  font-size: 9px; font-weight: 600; color: var(--text-dimmer);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.sidebar-stat-val { font-size: 14px; font-weight: 800; }
.sidebar-stat-val.accent { color: var(--accent); }

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

/* Place bet / cashout button */
.place-btn {
  width: 100%; height: 50px; 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;
  transition: all 0.2s; flex-shrink: 0; margin-top: auto;
  box-shadow: 0 4px 16px rgba(247,147,26,0.30), inset 0 1px 0 rgba(255,255,255,0.2);
  white-space: nowrap;
}
.place-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 24px rgba(247,147,26,0.40), inset 0 1px 0 rgba(255,255,255,0.2);
  transform: translateY(-1px);
}
.place-btn:active:not(:disabled) { transform: translateY(0); }
.place-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.place-btn.cashout-mode { animation: cashoutPulse 1.5s ease-in-out infinite; }

/* Cancel bet button */
.cancel-btn {
  width: 100%; height: 50px; border-radius: 10px;
  background: var(--elevated);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-mid); font-family: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em;
  transition: all 0.2s; flex-shrink: 0; margin-top: auto;
}
.cancel-btn:hover {
  color: var(--red);
  border-color: rgba(248, 95, 93, 0.3);
}

/* ===== GAME BOARD (right side) ===== */
.board {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative;
  background: 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;
}
.grid {
  display: grid;
  gap: 8px;
  width: 100%; height: 100%;
  max-width: 580px; max-height: 580px;
  aspect-ratio: 1;
  grid-auto-rows: 1fr;
}
.grid.grid-boom {
  animation: gridShake 0.5s ease-out;
}

/* ===== TILES ===== */
.tile {
  background: var(--elevated);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 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%;
}
.tile:hover:not(:disabled):not(.tile-safe):not(.tile-mine) {
  background: #3a5a6e;
}
.tile:disabled { cursor: default; }

/* Revealed gem tile (during play + after bust safe path) */
.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);
}

/* Clicked mine — boom */
.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;
}

/* Other mines revealed after bust */
.tile-mine-other {
  background: var(--elevated);
}

.tile-icon {
  font-size: 24px; line-height: 1;
  pointer-events: none;
}
.tile-gem {
  color: #6ecfff;
  width: 28px; height: 28px;
  filter: drop-shadow(0 0 8px rgba(110, 207, 255, 0.7)) drop-shadow(0 0 20px rgba(110, 207, 255, 0.4));
}
.tile-gem-dim {
  color: #6ecfff;
  width: 22px; height: 22px;
  opacity: 0.5;
  filter: drop-shadow(0 0 4px rgba(110, 207, 255, 0.3));
}
.tile-bomb {
  font-size: 28px;
  animation: bombPulse 0.6s ease-out;
}
.tile-bomb-other {
  font-size: 22px;
  opacity: 0.6;
}

/* ===== 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.hidden { visibility: hidden; }

/* ===== FOOTER ===== */
.bottom {
  height: 44px; background: var(--panel);
  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 ===== */
.alert-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; background: rgba(248, 95, 93, 0.15);
  border: 1px solid rgba(248, 95, 93, 0.4); border-radius: 10px;
  color: var(--red); font-size: 13px; font-weight: 700;
  z-index: 200; backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: alertSlide 0.3s ease-out forwards; white-space: nowrap;
}
.alert-icon { font-size: 16px; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(6px);
  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 h3 { font-size: 13px; font-weight: 700; color: var(--accent); margin: 12px 0 6px; }
.modal p, .modal li { font-size: 12px; line-height: 1.6; color: var(--text-75); }
.modal ul, .modal ol { padding-left: 18px; margin-bottom: 8px; }
.modal li { margin-bottom: 3px; }
.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); }
.modal-payout-box {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--card-bg);
  border: 1px solid var(--hairline); border-radius: 10px; margin-bottom: 8px;
}
.modal-payout-box .label { font-size: 12px; color: var(--text-mid); text-transform: none; letter-spacing: 0; }
.modal-payout-box .value { font-size: 13px; font-weight: 700; color: var(--accent); }
.info-box {
  display: flex; gap: 10px; padding: 12px;
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: 10px; margin-bottom: 8px;
}
.info-box .info-icon { font-size: 20px; flex-shrink: 0; }
.info-box p { margin: 0; }
.mult-table-wrap { overflow-x: auto; margin-bottom: 8px; }
.mult-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mult-table th, .mult-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--hairline); }
.mult-table th { color: var(--text-mid); font-weight: 600; }
.mult-table td { color: var(--text-75); }
.pf-desc { margin-bottom: 16px; }
.pf-section { background: var(--card-bg); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.pf-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.pf-icon { font-size: 14px; }
.pf-sublabel { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.pf-toggle-row { display: flex; gap: 6px; margin-bottom: 10px; }
.pf-toggle-btn {
  flex: 1; height: 32px; border: 1px solid var(--toggle-border); border-radius: 8px;
  background: transparent; color: var(--text-mid); font-family: inherit;
  font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.pf-toggle-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(247, 147, 26, 0.08); }
.pf-input-row { display: flex; gap: 6px; margin-bottom: 8px; }
.pf-input-row input {
  flex: 1; height: 34px; border: 1px solid var(--input-border); border-radius: 8px;
  background: linear-gradient(180deg, #1E1845 0%, #1E1845 100%);
  color: var(--text); font-family: monospace; font-size: 11px; padding: 0 10px; outline: none;
}
.pf-input-row input:focus { border-color: var(--accent); }
.pf-btn-sm {
  width: 34px; height: 34px; border: 1px solid var(--toggle-border); border-radius: 8px;
  background: rgba(255,255,255,0.03); color: var(--text-mid);
  font-family: inherit; font-size: 10px; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.pf-btn-sm:hover { border-color: var(--accent-border); color: var(--text); }
.pf-hash-box {
  background: rgba(255,255,255,0.02); border: 1px solid var(--hairline); border-radius: 8px;
  padding: 10px; font-family: monospace; font-size: 10px; color: var(--text-mid);
  word-break: break-all; margin-bottom: 8px; line-height: 1.5;
}
.pf-cp-row { display: flex; gap: 6px; margin-bottom: 8px; }
.pf-note { font-size: 11px; color: var(--text-dim); margin: 0; line-height: 1.5; }
.pf-how { background: var(--card-bg); border: 1px solid var(--hairline); border-radius: 10px; padding: 16px; }
.pf-how-title { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.pf-how ol { padding-left: 18px; }
.pf-how li { font-size: 11px; color: var(--text-75); margin-bottom: 5px; line-height: 1.5; }

/* ===== ANIMATIONS ===== */
@keyframes tileReveal {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@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); }
}

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

/* Fluid app */
@media (max-width: 1168px) {
  .app { width: 100%; height: var(--app-height, 100%); border-radius: 0; box-shadow: none; }
}

/* Tablet — sidebar shrinks */
@media (max-width: 960px) {
  .sidebar { width: 250px; padding: 14px; gap: 10px; }
  .grid { gap: 6px; }
  .tile { border-radius: 10px; }
  .grid-size-btn { height: 36px; font-size: 13px; }
  .input-row { height: 42px; }
  .place-btn { height: 44px; font-size: 13px; }
  .cancel-btn { height: 44px; font-size: 13px; }
}

/* Small tablet */
@media (max-width: 780px) {
  .sidebar { width: 210px; padding: 10px; gap: 8px; }
  .ctrl-label { font-size: 10px; }
  .input-row { height: 36px; }
  .input-row input { font-size: 13px; }
  .currency { width: 28px; font-size: 12px; }
  .chip { width: 32px; height: 24px; font-size: 9px; }
  .grid-size-btn { height: 32px; font-size: 11px; }
  .mines-slider-ends { padding: 6px 8px; }
  .slider-end { font-size: 11px; padding: 2px 6px; }
  .slider-end-icon { font-size: 13px; }
  .place-btn { height: 40px; font-size: 12px; }
  .cancel-btn { height: 40px; font-size: 12px; }
  .tile-gem { width: 22px; height: 22px; }
}

/* Phone — stack vertically */
@media (max-width: 680px) {
  .game-body { flex-direction: column-reverse; }
  .sidebar {
    width: 100%; border-right: none; border-top: 1px solid var(--hairline);
    padding: 12px 16px; gap: 8px;
    flex-shrink: 0; overflow-y: auto;
    max-height: 45dvh;
  }
  .board { padding: 8px; flex: 1; min-height: 0; }
  .grid { gap: 5px; }
  .tile { border-radius: 8px; }
  .tile-icon { font-size: 22px; }
  .tile-gem { width: 22px; height: 22px; }
  .place-btn { height: 44px; font-size: 13px; margin-top: 0; }
  .cancel-btn { height: 44px; font-size: 13px; margin-top: 0; }
  .ctrl-action { margin-top: 0; }
  .header { padding: 0 10px; height: 44px; }
  .game-name span:last-child { display: none; }
  .header-balance { padding: 4px 10px 4px 8px; }
  .header-bal-value { font-size: 12px; }
  .fairplay { font-size: 0; padding: 6px 8px; gap: 0; }
  .fairplay::before { width: 12px; height: 14px; }
  .info { width: 26px; height: 26px; font-size: 10px; }
  .bottom { height: 36px; padding: 0 10px; }
  .result-badge { font-size: 14px; padding: 10px 24px; }
}

/* Small phone */
@media (max-width: 420px) {
  .grid { gap: 4px; }
  .tile { border-radius: 6px; }
  .tile-icon { font-size: 18px; }
  .sidebar { max-height: 220px; padding: 10px 12px; gap: 8px; }
  .mines-presets { gap: 3px; }
  .mine-btn { height: 32px; font-size: 11px; }
  .input-row { height: 40px; }
  .chip { width: 34px; height: 26px; font-size: 10px; }
  .currency { width: 30px; font-size: 12px; }
  .header { height: 40px; padding: 0 8px; }
  .game-name { font-size: 12px; }
  .bottom { height: 32px; }
  .bottom-logo { font-size: 10px; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) and (min-width: 500px) {
  .game-body { flex-direction: row; }
  .sidebar {
    width: 240px; padding: 10px; gap: 6px;
    max-height: none; overflow-y: auto;
    border-right: 1px solid var(--hairline); border-top: none;
    flex-shrink: 0;
  }
  .sidebar { display: flex; flex-direction: column; }
  .ctrl-action { order: 99; margin-top: auto; }
  .ctrl-bet { order: 1; }
  .ctrl-grid { order: 2; }
  .ctrl-mines { order: 3; }
  .ctrl-stats { order: 4; }
  .ctrl-profit { order: 5; }
  .header { height: 36px; }
  .board { padding: 8px; }
  .grid { gap: 3px; }
  .grid-wrap { padding: 0; }
  .tile { border-radius: 6px; }
  .tile-icon { font-size: 14px; }
  .tile-gem { width: 18px; height: 18px; }
  .tile-gem-dim { width: 14px; height: 14px; }
  .place-btn { height: 36px; font-size: 11px; }
  .cancel-btn { height: 36px; font-size: 11px; }
  .ctrl-label { font-size: 10px; }
  .input-row { height: 34px; }
  .chip { width: 32px; height: 24px; font-size: 9px; }
  .currency { width: 28px; font-size: 11px; }
  .grid-size-btn { height: 30px; font-size: 11px; }
  .mines-slider-ends { padding: 6px 8px; gap: 6px; flex-wrap: wrap; justify-content: center; }
  .mines-slider { min-width: 60px; }
  .slider-end { font-size: 10px; padding: 2px 5px; gap: 3px; }
  .slider-end-icon { font-size: 11px; }
  .sidebar-stat { padding: 4px 4px; }
  .sidebar-stat-label { font-size: 8px; }
  .sidebar-stat-val { font-size: 11px; }
  .profit-box { padding: 6px 10px; }
  .profit-label { font-size: 10px; }
  .profit-val { font-size: 13px; }
  .result-badge { font-size: 12px; padding: 6px 16px; }
  .bottom { height: 28px; }
  .bottom-logo { font-size: 10px; }
}

/* ===== FREE BET UI ===== */

/* Desktop: free bet banner at top */
@media (min-width: 681px) {
  .ctrl-free { order: 0; }
}

/* Mobile: compact free bet elements */
@media (max-width: 680px) {
  .free-bet-banner { padding: 8px 10px; border-radius: 8px; }
  .free-bet-title { font-size: 11px; }
  .free-bet-count { font-size: 10px; }
  .free-bet-progress { margin-top: 4px; }
  .ctrl-group { gap: 4px; }
  .ctrl-label { font-size: 10px; }
  .mines-slider-ends { padding: 6px 8px; }
  .slider-end { font-size: 11px; padding: 2px 6px; }
  .grid-size-btn { height: 34px; font-size: 12px; }
}

/* Free bet banner */
.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;
}
.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;
}

/* Free bet button variant */
.place-btn.free-mode {
  background: linear-gradient(135deg, #F7931A 0%, #E67A00 100%);
  animation: freeBetPulse 2s ease-in-out infinite;
}
@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); }
}

/* Locked bet input during free mode */
.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);
  box-shadow: 0 6px 24px rgba(247,147,26,0.40), inset 0 1px 0 rgba(255,255,255,0.2);
  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;
}
@keyframes fbwBounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
.fbw-desc {
  font-size: 13px;
  color: var(--text-75);
  line-height: 1.6;
  margin-bottom: 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);
  box-shadow: 0 6px 24px rgba(247,147,26,0.40), inset 0 1px 0 rgba(255,255,255,0.2);
  transform: translateY(-1px);
}
