/* ============================ Vault Grid (Mines) ============================ */
/* Reuses :root vars, .btn, .chip, .bet-row/.bet-field, .chip-stat, .result-banner
   from style.css. This file: page layout, the grid, the live risk→reward preview,
   and the juice (heat glow, shockwave, coins, flash, shake). */

body.mines-body { overflow-y: auto; height: auto; min-height: 100dvh; display: block; }

/* sticky header */
.mines-body .hud-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(5, 7, 15, 0.97), rgba(5, 7, 15, 0.78));
  -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
  border-bottom: 1px solid #1b2344;
}
.mines-body .balance-chip { margin-left: 0; }
.mines-body .brand { margin-right: auto; }

/* diamond brand logo (replaces the emoji mark — cyan glow instead of gold) */
.brand-gem { display: inline-flex; align-items: center; line-height: 0; filter: drop-shadow(0 0 6px rgba(110, 220, 255, 0.6)); }
.brand-gem svg { display: block; width: 20px; height: 20px; }

.mines-main { max-width: 980px; margin: 0 auto; padding: 16px 14px 30px; }

.mg-head { text-align: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid color-mix(in srgb, var(--gold) 22%, transparent); }
.mg-title {
  font-size: clamp(1.7rem, 5vw, 2.3rem); font-weight: 900; letter-spacing: 0.09em; line-height: 1;
  background: linear-gradient(180deg, #ffffff 0%, #ffc83d 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px color-mix(in srgb, var(--gold) 28%, transparent);
}
.mg-sub { color: var(--text-dim); font-size: 0.85rem; margin-top: 6px; }

/* ----------------------------- two-column layout ------------------------- */
.mg-layout { display: grid; grid-template-columns: 1fr; gap: clamp(16px, 3vw, 28px); align-items: start; }
@media (min-width: 860px) {
  .mg-layout { grid-template-columns: minmax(0, 520px) 372px; justify-content: center; align-items: stretch; }
  /* equal-height columns: the control rail fills the grid's height, content centered */
  .mg-side { display: flex; flex-direction: column; }
  .mg-side .mg-panel:not(.hidden) { flex: 1; justify-content: space-between; }
}

.mg-board { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.mg-stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; width: 100%; margin-bottom: 14px; }

/* ------------------------------- the grid -------------------------------- */
.grid-wrap { position: relative; width: 100%; max-width: 520px; }
.grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  width: 100%;
  padding: 14px; border-radius: 20px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(40, 52, 92, 0.4), rgba(8, 12, 24, 0.6));
  border: 1px solid #1b2344;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 30px rgba(0, 0, 0, 0.45),
    0 0 calc(var(--heat, 0) * 46px) color-mix(in srgb, var(--gold) calc(var(--heat, 0) * 65%), transparent);
  transition: box-shadow 0.4s ease;
}
.cell {
  aspect-ratio: 1; border-radius: 13px; position: relative; cursor: pointer;
  border: 1px solid #33406e;
  background: linear-gradient(158deg, #38436a 0%, #232c4a 46%, #161d34 100%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.12), inset 0 -5px 10px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.35);
  display: grid; place-items: center;
  font-size: clamp(1.2rem, 5.5vw, 1.8rem);
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.cell::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14%; height: 14%;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c2cbe6, #4b5572); opacity: 0.55;
}
@media (hover: hover) {
  .grid:not(.locked) .cell:not(.revealed):hover {
    filter: brightness(1.2); transform: translateY(-2px);
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.15), 0 8px 18px rgba(0, 0, 0, 0.45), 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
  }
}
.grid:not(.locked) .cell:not(.revealed):active { transform: scale(0.94); }
.grid.locked .cell { cursor: default; }

.cell.revealed { cursor: default; }
.cell.revealed::before { display: none; }
.cell.revealed.safe {
  border-color: color-mix(in srgb, var(--gold) 50%, #000);
  background: radial-gradient(circle at 50% 38%, #4a3a12 0%, #271e08 60%, #140f04 100%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 45%, transparent), inset 0 0 16px rgba(0, 0, 0, 0.6), 0 0 16px color-mix(in srgb, var(--gold) 32%, transparent);
  animation: cellPop 0.34s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.cell.revealed.mine {
  border-color: color-mix(in srgb, var(--red) 60%, #000);
  background: radial-gradient(circle at 50% 40%, #ff5a72 0%, #c0142f 55%, #4a0512 100%);
  box-shadow: 0 0 22px color-mix(in srgb, var(--red) 65%, transparent), inset 0 0 14px rgba(0, 0, 0, 0.4);
  animation: cellBoom 0.4s ease;
}
.cell.other-mine { border-color: #5a2230; background: radial-gradient(circle at 50% 40%, #5e2230, #2a0d15); opacity: 0.78; }
@keyframes cellPop { 0% { transform: scale(0.55); opacity: 0.3; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes cellBoom { 0% { transform: scale(0.6); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }

/* reveal shockwave (spawned in JS) — satisfying gold ring on every safe box */
.shock { position: absolute; width: 48px; height: 48px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--gold) 92%, #fff); box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 60%, transparent); transform: translate(-50%, -50%); pointer-events: none; opacity: 1; animation: shockOut 0.55s ease-out forwards; }
@keyframes shockOut { to { transform: translate(-50%, -50%) scale(5); opacity: 0; } }

/* WIN pulse — board warms up brightly on cashout */
.grid.winpulse { animation: winPulse 0.7s ease; }
@keyframes winPulse { 0%, 100% { filter: brightness(1); } 40% { filter: brightness(1.28) saturate(1.15); } }

/* LOSS — kept gentle (no screen shake): a brief soft dim only */
.grid.bust { animation: gridBust 0.5s ease; }
@keyframes gridBust { 0% { filter: brightness(1); } 30% { filter: grayscale(0.3) brightness(0.85); } 100% { filter: brightness(1); } }

/* flash overlay over the board */
.mg-flash { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 20px; z-index: 5; opacity: 0; background: radial-gradient(circle at 50% 45%, rgba(255, 240, 200, 0.9), rgba(255, 200, 61, 0) 60%); }
.mg-flash.win { animation: mgFlash 0.7s ease-out; }
.mg-flash.bust { background: radial-gradient(circle at 50% 45%, rgba(255, 70, 90, 0.28), transparent 66%); animation: mgFlash 0.45s ease-out; }
@keyframes mgFlash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

/* WIN treasure burst — full-screen, spawned in JS (.mg-particle positioned at grid centre) */
.mg-burst { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999; }
.mg-particle {
  position: absolute; opacity: 0; will-change: transform, opacity; line-height: 1;
  filter: drop-shadow(0 2px 7px rgba(0, 0, 0, 0.45));
  animation-name: mgTreasure; animation-timing-function: cubic-bezier(0.16, 0.7, 0.3, 1); animation-fill-mode: forwards;
}
@keyframes mgTreasure {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(0deg); }
  10%  { opacity: 1; transform: translate(-50%, -50%) scale(1.25) rotate(calc(var(--rot) * 0.15)); }
  42%  { opacity: 1; transform: translate(calc(-50% + var(--bx)), calc(-50% + var(--by))) scale(1.05) rotate(calc(var(--rot) * 0.55)); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--fx)), calc(-50% + var(--fy))) scale(0.78) rotate(var(--rot)); }
}

/* progress bar */
.mg-progress { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 10px; }
.mg-progress-track { flex: 1; height: 8px; border-radius: 999px; background: #161d34; overflow: hidden; border: 1px solid #232c4a; }
.mg-progress-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width 0.35s ease; }
.mg-progress-label { font-size: 0.7rem; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------- control rail ---------------------------- */
.mg-panel {
  display: flex; flex-direction: column; gap: 11px;
  border: 1px solid #1b2344; border-radius: 20px; padding: 14px;
  background: rgba(10, 18, 32, 0.82);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent), 0 8px 22px rgba(0, 0, 0, 0.4);
}
.mines-row { margin-top: 2px; }
.mines-chip { min-width: 0; }

/* style the Alarms number input like the Bet input (no white default field) */
#minesInput {
  width: 100%; text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--text);
  background: none; border: none; padding: 0 0 5px; appearance: textfield; -moz-appearance: textfield;
}
#minesInput::-webkit-outer-spin-button, #minesInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#minesInput:focus { outline: none; }

/* live risk → reward preview */
.preview-card {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 13px;
  background: linear-gradient(180deg, rgba(26, 37, 64, 0.6), rgba(10, 16, 30, 0.6));
  padding: 14px; text-align: center;
}
.risk-meter { height: 8px; border-radius: 999px; background: #11182f; overflow: hidden; border: 1px solid #232c4a; }
.risk-fill { display: block; height: 100%; width: 12%; border-radius: 999px; background: var(--risk-color, var(--accent)); transition: width 0.3s ease, background 0.3s ease; }
.risk-label { margin: 7px 0 8px; font-size: 0.64rem; font-weight: 900; letter-spacing: 0.14em; color: var(--risk-color, var(--text-dim)); }
.pc-next-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); }
.pc-next {
  font-size: 2.3rem; font-weight: 900; line-height: 1.05; color: var(--gold); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px color-mix(in srgb, var(--gold) 45%, transparent);
}
.pc-next.bump { animation: pcBump 0.32s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes pcBump { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }
.pc-curve { font-size: 0.72rem; color: var(--text-dim); margin-top: 4px; }
.pc-max { font-size: 0.82rem; color: var(--text-dim); margin-top: 8px; }
.pc-max b { color: #ffe9a8; font-variant-numeric: tabular-nums; }

.play-info { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.play-mult { color: var(--gold); font-size: clamp(2.8rem, 8vw, 3.6rem); }
#playPanel .pick-hint { color: var(--accent); }
.end-summary {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; color: var(--text);
}
.end-summary .es-label { font-size: 0.9rem; font-weight: 800; color: var(--text-dim); letter-spacing: 0.01em; }
.end-summary .es-amt {
  font-size: clamp(2.4rem, 7vw, 3.2rem); font-weight: 900; line-height: 1.02;
  font-variant-numeric: tabular-nums; text-shadow: 0 0 24px color-mix(in srgb, currentColor 30%, transparent);
}
.end-summary .es-amt.es-word { font-size: clamp(2.2rem, 6vw, 2.9rem); letter-spacing: 0.01em; }
.end-summary.win .es-amt { color: var(--green); }
.end-summary.lose .es-amt { color: var(--red); }

.mg-foot { text-align: center; color: var(--text-faint); font-size: 0.7rem; line-height: 1.5; margin-top: 18px; }

/* ====================== ambience: kill the flat dark ====================== */
body.mines-body::before {
  content: ''; position: fixed; inset: -10%; z-index: -2; pointer-events: none;
  background:
    radial-gradient(42% 42% at 16% 20%, rgba(60, 150, 240, 0.12), transparent 70%),
    radial-gradient(40% 40% at 84% 26%, rgba(255, 200, 61, 0.08), transparent 70%),
    radial-gradient(55% 50% at 50% 92%, rgba(120, 90, 220, 0.10), transparent 72%);
  animation: bgDrift 20s ease-in-out infinite alternate;
}
@keyframes bgDrift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(0, -3%, 0) scale(1.07); } }

/* slow floating diamonds drifting up behind everything */
.mg-ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.mg-ambient span {
  position: absolute; bottom: -8%; opacity: 0; font-size: 1.7rem;
  filter: drop-shadow(0 0 8px rgba(110, 220, 255, 0.45));
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  12% { opacity: 0.16; } 86% { opacity: 0.16; }
  100% { transform: translateY(-116vh) rotate(220deg); opacity: 0; }
}
.mg-ambient span:nth-child(1) { left: 7%;  font-size: 1.5rem; animation-duration: 19s; animation-delay: 0s; }
.mg-ambient span:nth-child(2) { left: 21%; font-size: 2.2rem; animation-duration: 24s; animation-delay: 6s; }
.mg-ambient span:nth-child(3) { left: 34%; font-size: 1.2rem; animation-duration: 17s; animation-delay: 11s; }
.mg-ambient span:nth-child(4) { left: 48%; font-size: 2.6rem; animation-duration: 27s; animation-delay: 3s; }
.mg-ambient span:nth-child(5) { left: 62%; font-size: 1.4rem; animation-duration: 21s; animation-delay: 14s; }
.mg-ambient span:nth-child(6) { left: 75%; font-size: 2.0rem; animation-duration: 23s; animation-delay: 8s; }
.mg-ambient span:nth-child(7) { left: 87%; font-size: 1.3rem; animation-duration: 18s; animation-delay: 17s; }
.mg-ambient span:nth-child(8) { left: 94%; font-size: 1.8rem; animation-duration: 26s; animation-delay: 2s; }
@media (prefers-reduced-motion: reduce) { .mg-ambient, body.mines-body::before { animation: none; } .mg-ambient { display: none; } }

/* subtle idle "breathing" wave across the locked board (before a round) */
.grid.locked .cell { animation: cellBreathe 3.6s ease-in-out infinite; }
.grid.locked .cell:nth-child(5n+1) { animation-delay: 0s; }
.grid.locked .cell:nth-child(5n+2) { animation-delay: 0.16s; }
.grid.locked .cell:nth-child(5n+3) { animation-delay: 0.32s; }
.grid.locked .cell:nth-child(5n+4) { animation-delay: 0.48s; }
.grid.locked .cell:nth-child(5n+5) { animation-delay: 0.64s; }
@keyframes cellBreathe { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.14); } }
@media (prefers-reduced-motion: reduce) { .grid.locked .cell { animation: none; } }

/* =================== Live Wins + Leaderboard panels ====================== */
.mg-social {
  max-width: 908px; margin: 22px auto 0; display: grid; gap: 16px;
  grid-template-columns: 1fr 1fr;
}
.social-card {
  border: 1px solid #1b2344; border-radius: 18px; padding: 14px 16px;
  background: rgba(10, 18, 32, 0.62);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 10%, transparent), 0 8px 22px rgba(0, 0, 0, 0.35);
}
.social-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 11px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim);
}
.lb-list { display: flex; flex-direction: column; }
.lb-list .muted, .lw-list:empty::after { color: var(--text-faint); font-size: 0.8rem; }
.lw-list:empty::after { content: 'Waiting for the next win...'; }
@media (max-width: 720px) { .mg-social { grid-template-columns: 1fr; } }
