/* Molten Coins — volcanic hold & win theme */
:root {
  --magma: #ff4d1c;
  --ash: #1a1220;
  --obsidian: #0d0912;
  --gold: #ffd45b;
  --ember-glow: #ff8a3d;
  --panel: rgba(20, 12, 24, 0.92);
  --line: rgba(255, 212, 91, 0.22);
  --text: #f5ede2;
  --muted: #b9a68f;
  --asset-volcano: none;
  --asset-grid-frame: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 77, 28, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 15% 110%, rgba(255, 138, 61, 0.16) 0%, transparent 40%),
    linear-gradient(160deg, var(--obsidian), var(--ash) 55%, #21101a);
}

/* ---- ambient embers ---- */
.embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.embers span {
  position: absolute;
  bottom: -12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold), var(--magma));
  opacity: 0;
}
.embers span:nth-child(1)  { left: 6%;  }
.embers span:nth-child(2)  { left: 16%; }
.embers span:nth-child(3)  { left: 27%; }
.embers span:nth-child(4)  { left: 38%; }
.embers span:nth-child(5)  { left: 49%; }
.embers span:nth-child(6)  { left: 58%; }
.embers span:nth-child(7)  { left: 67%; }
.embers span:nth-child(8)  { left: 78%; }
.embers span:nth-child(9)  { left: 88%; }
.embers span:nth-child(10) { left: 95%; }
@media (prefers-reduced-motion: no-preference) {
  .embers span { animation: ember-rise 9s linear infinite; }
  .embers span:nth-child(2n)  { animation-duration: 12s; animation-delay: 2s; }
  .embers span:nth-child(3n)  { animation-duration: 10s; animation-delay: 4s; }
  .embers span:nth-child(4n)  { animation-duration: 14s; animation-delay: 6s; }
  @keyframes ember-rise {
    0%   { transform: translateY(0) scale(1);      opacity: 0; }
    12%  { opacity: 0.8; }
    100% { transform: translateY(-105vh) scale(0.3); opacity: 0; }
  }
}

.layout {
  position: relative;
  z-index: 1;
  width: min(520px, 96vw);
  margin: 0 auto;
  padding: 0.7rem 0 2rem;
}

/* ---- topbar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.2rem;
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 30%, var(--gold) 0%, var(--magma) 55%, #7a1802 100%);
  box-shadow: 0 0 12px rgba(255, 77, 28, 0.6);
}
.topbar h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 138, 61, 0.5);
}
.topbar h1 small {
  display: block;
  font-size: 0.58rem;
  letter-spacing: 0.3em;
  color: var(--ember-glow);
}
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.balance-pill {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-weight: 800;
  color: var(--gold);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ---- jackpot bar ---- */
.jackpot-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin: 0.55rem 0;
}
.jp-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.42rem 0.2rem;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.jp-label { font-size: 0.62rem; letter-spacing: 0.18em; color: var(--muted); font-weight: 700; }
.jp-value { font-size: 0.78rem; font-weight: 800; color: var(--text); }
.jp-tile[data-tier="grand"] { border-color: rgba(255, 77, 28, 0.65); box-shadow: 0 0 14px rgba(255, 77, 28, 0.25) inset; }
.jp-tile[data-tier="grand"] .jp-label { color: var(--magma); }
.jp-tile[data-tier="grand"] .jp-value { color: var(--gold); }
.jp-tile[data-tier="major"] .jp-label { color: var(--gold); }
.jp-tile[data-tier="minor"] .jp-label { color: var(--ember-glow); }

/* ---- stage & grid ---- */
.stage {
  position: relative;
  border-radius: 18px;
  padding: 4.5rem 1rem 1rem;
  overflow: hidden;
  background: linear-gradient(180deg, #291012 2%, transparent);
  border: 1px solid var(--line);
}
.volcano {
  position: absolute;
  inset: 0;
  background-image: var(--asset-volcano);
  background-size: cover;
  background-position: center top;
  opacity: 0.9;
  z-index: 0;
}
.grid-frame {
  position: absolute;
  inset: 0;
  background-image: var(--asset-grid-frame);
  background-size: 100% 100%;
  pointer-events: none;
  z-index: 2;
}
.grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  aspect-ratio: 1;
  padding: 0.55rem;
  border-radius: 14px;
  background: rgba(10, 6, 12, 0.72);
  border: 1px solid rgba(255, 212, 91, 0.28);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
}
.grid.bonus-mode {
  border-color: var(--magma);
  box-shadow: 0 0 22px rgba(255, 77, 28, 0.45), 0 8px 30px rgba(0, 0, 0, 0.55);
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(46, 26, 34, 0.9), rgba(22, 12, 20, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.cell img.symbol {
  width: 74%;
  height: 74%;
  object-fit: contain;
  visibility: hidden;
}
.cell-value {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.cell-mult {
  position: absolute;
  top: 3px;
  right: 6px;
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--magma);
  text-shadow: 0 0 6px rgba(255, 77, 28, 0.8);
  pointer-events: none;
}
.cell.win { border-color: var(--gold); box-shadow: 0 0 14px rgba(255, 212, 91, 0.55) inset; }
.cell.land { border-color: var(--ember-glow); }
.cell.erupt { border-color: var(--magma); }
.cell.collected { border-color: var(--gold); }
.cell.shuffling img.symbol { opacity: 0.55; filter: brightness(1.25); }
@media (prefers-reduced-motion: no-preference) {
  .cell.win { animation: cell-glow 0.9s ease-in-out infinite alternate; }
  .cell.land img.symbol { animation: cell-pop 0.35s ease-out; }
  .cell.erupt img.symbol { animation: cell-pop 0.45s ease-out; }
  .cell.collected { animation: collect-pulse 0.6s ease-out; }
  @keyframes cell-glow {
    from { box-shadow: 0 0 6px rgba(255, 212, 91, 0.35) inset; }
    to   { box-shadow: 0 0 18px rgba(255, 212, 91, 0.75) inset; }
  }
  @keyframes cell-pop {
    0%   { transform: scale(0.4); }
    70%  { transform: scale(1.12); }
    100% { transform: scale(1); }
  }
  @keyframes collect-pulse {
    0%   { background-color: rgba(255, 212, 91, 0.4); }
    100% { background-color: transparent; }
  }
}

/* ---- eruption overlay & bonus HUD (hidden-attribute overrides are
   mandatory: these classes set display, so the native hidden attribute
   needs an equal-specificity win) ---- */
#eruptionFx {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 100%, rgba(255, 77, 28, 0.55), rgba(13, 9, 18, 0.65));
}
#eruptionFx[hidden] { display: none; }
.eruption-text {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow: 0 0 18px var(--magma), 0 2px 4px #000;
}
@media (prefers-reduced-motion: no-preference) {
  .eruption-text { animation: erupt-shake 0.45s ease-in-out infinite; }
  @keyframes erupt-shake {
    0%, 100% { transform: translate(0, 0) rotate(-1deg); }
    25% { transform: translate(-3px, 2px) rotate(1deg); }
    75% { transform: translate(3px, -2px) rotate(-1deg); }
  }
}

#bonusHud {
  position: absolute;
  top: 0.7rem;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 0.7rem;
}
#bonusHud[hidden] { display: none; }
.hud-block {
  background: rgba(10, 6, 12, 0.85);
  border: 1px solid var(--magma);
  border-radius: 999px;
  padding: 0.32rem 0.8rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.hud-block b { color: var(--gold); font-size: 0.85rem; margin-left: 0.25rem; }

/* ---- winbar ---- */
.winbar {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.6rem;
  min-height: 2rem;
  margin: 0.55rem 0 0.2rem;
  font-weight: 700;
}
#winLabel { color: var(--muted); font-size: 0.85rem; letter-spacing: 0.08em; }
#winAmount { color: var(--gold); font-size: 1.15rem; text-shadow: 0 0 10px rgba(255, 212, 91, 0.5); }

/* ---- controls ---- */
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  margin: 0.4rem 0 0.9rem;
}
.bet-group { display: flex; align-items: center; gap: 0.4rem; }
.round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
}
.bet-value {
  min-width: 6.2rem;
  text-align: center;
  font-weight: 800;
  color: var(--text);
  font-size: 0.92rem;
}
.spin-btn {
  border: 0;
  border-radius: 14px;
  padding: 0.85rem 2rem;
  font-size: 1.02rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #401103;
  background: linear-gradient(180deg, var(--gold), var(--ember-glow) 60%, var(--magma));
  box-shadow: 0 6px 18px rgba(255, 77, 28, 0.45);
  cursor: pointer;
}
.buy-btn {
  border: 1px solid var(--magma);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 77, 28, 0.12);
  color: var(--ember-glow);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.buy-btn span { display: block; color: var(--gold); font-size: 0.82rem; }
.mode-group { display: flex; gap: 0.4rem; }
.toggle-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.toggle-btn.active { color: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px rgba(255, 212, 91, 0.35); }
.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.8rem;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- panels ---- */
.panels { display: grid; gap: 0.55rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0.6rem 0.85rem;
}
.panel summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.06em;
  font-size: 0.88rem;
}
.panel table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.82rem; }
.panel th, .panel td { text-align: left; padding: 0.3rem 0.35rem; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.panel th { color: var(--muted); font-weight: 600; }
.pay-icon { width: 22px; height: 22px; vertical-align: middle; }
.note { color: var(--muted); font-size: 0.74rem; margin: 0.5rem 0 0.1rem; }
.coin-ladder { color: var(--gold); font-weight: 700; font-size: 0.85rem; margin: 0.5rem 0 0.1rem; }
.rules { margin: 0.5rem 0 0.1rem; padding-left: 1.1rem; font-size: 0.79rem; color: var(--text); }
.rules li { margin-bottom: 0.4rem; }
.rules b { color: var(--gold); }

/* ---- modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(8, 4, 10, 0.75);
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: min(430px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
}
.modal[hidden] { display: none; }
.modal h2 { margin: 0 0 0.6rem; color: var(--gold); font-size: 1.05rem; letter-spacing: 0.08em; }
.modal-actions { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.verify-details { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.7rem; font-size: 0.76rem; margin: 0.6rem 0; }
.verify-details dt { color: var(--muted); }
.verify-details dd { margin: 0; overflow-wrap: anywhere; color: var(--text); }
.ok { color: #7ce7a5; }
.bad { color: #ff7d7d; }
.big-win { text-align: center; border-color: var(--gold); }
.big-win h2 { font-size: 1.7rem; text-shadow: 0 0 16px var(--magma); }
.big-win p { font-size: 1.25rem; font-weight: 900; color: var(--gold); }

/* ---- toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 20;
  display: block;
  background: rgba(20, 10, 14, 0.95);
  border: 1px solid var(--magma);
  border-radius: 11px;
  padding: 0.6rem 1rem;
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  max-width: 90vw;
}
#toast[hidden] { display: none; }

/* ---- profit-practices additions (presentation only) ---- */
#nearMissFx {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 60%, rgba(255, 212, 91, 0.28), rgba(13, 9, 18, 0.45));
  pointer-events: none;
}
#nearMissFx[hidden] { display: none; }
.cell.near-miss { border-color: var(--gold); box-shadow: 0 0 16px rgba(255, 212, 91, 0.7) inset; }
.cell.anticipate { border-color: var(--magma); box-shadow: 0 0 18px rgba(255, 77, 28, 0.8) inset; }
@media (prefers-reduced-motion: no-preference) {
  .cell.anticipate { animation: cell-glow 0.45s ease-in-out infinite alternate; }
  .winbar.celebrate #winAmount { animation: cell-pop 0.4s ease-out; }
}
.bet-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; width: 100%; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.74rem;
  cursor: pointer;
}
.chip.active { color: var(--gold); border-color: var(--gold); }
.chip.anchor { border-color: var(--magma); color: var(--gold); box-shadow: 0 0 10px rgba(255, 77, 28, 0.4); font-size: 0.82rem; }
.social-strip { margin: 0.25rem 0; }
.recent-wins, .recent-results { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; min-height: 1.4rem; }
.social-win {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(20, 12, 24, 0.7);
}
.social-win.mine { color: var(--gold); border-color: var(--gold); }
.result-chip {
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.result-chip.win { color: var(--gold); }
.result-chip.bonus { color: #401103; background: linear-gradient(180deg, var(--gold), var(--ember-glow)); }
.tap-hint { width: 100%; text-align: center; color: var(--muted); font-size: 0.7rem; margin: 0.1rem 0 0; }

@media (max-width: 420px) {
  .topbar h1 { font-size: 0.9rem; }
  .spin-btn { padding: 0.75rem 1.4rem; }
}
