/* =============================================
   MIST — Frozen-night brand restyle
   (visual only — game logic/IDs unchanged)
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 50% -10%, #163a63, transparent 60%),
    var(--bg, #123254);
  color: var(--cream, #F4FAFF);
  font-family: var(--font-body, 'Nunito', system-ui, sans-serif);
  display: flex;
  flex-direction: column;
}

#snow-canvas { position: fixed; inset: 0; pointer-events: none; z-index: -1; }

/* ── TOPBAR ── */
.topbar {
  flex: 0 0 auto;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px 22px;
  background: rgba(8,28,51,0.86);
  border-bottom: 3px solid var(--ink, #0A1A2F);
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; }
.toolbar-btn {
  background: none; border: none; padding: 6px; cursor: pointer;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 301; transform: translateX(0);
  transition: transform 0.38s cubic-bezier(0.22,1,0.36,1);
}
.toolbar-btn.is-open { transform: translateX(280px); }
.toolbar-icon {
  font-size: 2rem; display: block; color: var(--ice, #3DC6F5);
  filter: drop-shadow(0 2px 0 var(--ink, #0A1A2F));
  transition: transform 0.5s cubic-bezier(0.22,1,0.36,1); transform-origin: center;
}
.toolbar-btn.is-open .toolbar-icon { transform: rotate(180deg); }
.topbar-logo {
  display: flex; align-items: center; gap: 9px; text-decoration: none;
  padding: 7px 16px 7px 12px; border-radius: 50px; border: 1px solid transparent;
  transition: background .2s, border-color .2s, transform .2s;
}
.topbar-logo:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.09); transform: translateY(-1px); }
.topbar-logo-icon { font-size: 1.75rem; color: var(--ice, #3DC6F5); filter: drop-shadow(0 2px 0 var(--ink, #0A1A2F)); }
.topbar-logo-name { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 1.4rem; letter-spacing: 0.5px; color: var(--cream, #F4FAFF); }
.hud-right { text-align: right; }
.hud-label { display: block; font-size: 0.7rem; color: var(--cream-dim, #8ba2bd); letter-spacing: 1.4px; text-transform: uppercase; font-weight: 800; }
.hud-value { font-size: 1.4rem; font-family: var(--font-display, 'Lilita One'), sans-serif; color: var(--gold, #FFC83D); }

/* ── SIDEBAR ── */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0); z-index: 299; pointer-events: none; transition: background .35s; }
.sidebar-backdrop.is-open { background: rgba(0,0,0,0.5); pointer-events: auto; }
.sidebar {
  position: fixed; top: 0; left: 0; width: 280px; height: 100vh;
  background: var(--bg-deep, #081C33); border-right: 3px solid var(--ink, #0A1A2F);
  box-shadow: 6px 0 40px rgba(0,0,0,0.7); z-index: 300;
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform 0.38s cubic-bezier(0.22,1,0.36,1); will-change: transform;
}
.sidebar.is-open { transform: translateX(0); }
.sidebar-header { padding: 26px 22px 16px; border-bottom: 1px solid rgba(255,255,255,0.09); }
.sidebar-title { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 1rem; letter-spacing: 0.5px; color: var(--ice, #3DC6F5); }
.sidebar-items { display: flex; flex-direction: column; padding: 12px; gap: 6px; overflow-y: auto; }
.td-item {
  display: flex; align-items: center; gap: 13px; padding: 13px 16px; border-radius: 14px;
  text-decoration: none; color: var(--cream-dim, #9fb6cc); font-weight: 800;
  transition: background .16s, color .16s, transform .16s;
}
.td-item:hover { background: var(--panel, #173B63); color: var(--cream, #F4FAFF); transform: translateX(3px); }
.td-item.td-active { background: var(--ice, #3DC6F5); color: var(--ink, #0A1A2F); border: 2.5px solid var(--ink, #0A1A2F); }
.td-icon { font-size: 1.1rem; flex-shrink: 0; }
.td-name { flex: 1; }

/* ── MAIN LAYOUT ── */
.play-layout { flex: 1; min-height: 0; display: flex; overflow: hidden; }

/* ── CONTROL PANEL (left) ── */
.ctrl-panel {
  flex: 0 0 240px;
  display: flex; flex-direction: column;
  background: var(--bg-deep, #081C33);
  border-right: 3px solid var(--ink, #0A1A2F);
  padding: 18px 16px; overflow-y: auto;
}
.mult-display-block { text-align: center; padding: 14px 0; }
.mult-label-sm { font-size: 0.6rem; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); margin-bottom: 6px; }
.mult-value-big {
  font-family: var(--font-display, 'Lilita One'), sans-serif;
  font-size: 2.9rem; line-height: 1; color: var(--cream-dim, #8ba2bd);
  transition: color 0.4s, text-shadow 0.4s;
  min-height: 3.2rem; display: flex; align-items: center; justify-content: center;
}
.mult-value-big.blue  { color: var(--ice, #3DC6F5);  text-shadow: 0 0 18px rgba(61,198,245,0.45); }
.mult-value-big.teal  { color: var(--teal, #2BE0CE); text-shadow: 0 0 18px rgba(43,224,206,0.45); }
.mult-value-big.amber { color: var(--gold-deep, #E0A21F); text-shadow: 0 0 20px rgba(224,162,31,0.5); }
.mult-value-big.gold  { color: var(--gold, #FFC83D); text-shadow: 0 0 28px rgba(255,200,61,0.7), 0 0 56px rgba(255,180,40,0.4); }
.mult-value-big.pulsing { animation: multPulse 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes multPulse { 0% { transform: scale(0.8); opacity: 0.6; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

.pot-win-label { font-size: 0.6rem; font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); margin-top: 12px; margin-bottom: 3px; }
.pot-win-amount { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 1.3rem; color: var(--gold, #FFC83D); }

.ctrl-divider { height: 2px; background: var(--hairline, rgba(244,250,255,0.10)); margin: 14px 0; flex-shrink: 0; border-radius: 2px; }
.ctrl-section { display: flex; flex-direction: column; gap: 9px; }
.ctrl-row-label { font-size: 0.64rem; font-weight: 900; letter-spacing: 1.8px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); }

/* Bet field */
.bet-field-row { display: flex; gap: 8px; align-items: center; }
.bet-input-wrap {
  display: flex; align-items: center; gap: 4px;
  background: rgba(8,28,51,0.6); border: 2.5px solid var(--ink, #0A1A2F);
  border-radius: 11px; padding: 0 12px; flex: 1;
}
.bet-input-wrap:focus-within { border-color: var(--ice, #3DC6F5); box-shadow: 0 0 0 3px rgba(61,198,245,0.18); }
.bet-dollar { font-size: 0.92rem; font-weight: 800; color: var(--ice, #3DC6F5); }
#bet-input {
  width: 100%; background: transparent; border: none; outline: none;
  font-size: 1rem; font-weight: 800; color: var(--cream, #F4FAFF); padding: 9px 0;
  font-family: inherit; -moz-appearance: textfield; appearance: textfield;
}
#bet-input::-webkit-inner-spin-button,
#bet-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.bet-btns { display: flex; flex-direction: column; gap: 5px; }
.bet-adj {
  width: 38px; height: 28px; border-radius: 8px;
  border: 2.5px solid var(--ink, #0A1A2F); background: var(--panel-2, #1E4C7E); color: var(--cream, #F4FAFF);
  font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 0.72rem; cursor: pointer;
  transition: background .14s;
}
.bet-adj:hover { background: var(--ice, #3DC6F5); color: var(--ink, #0A1A2F); }

/* Action buttons */
.ctrl-action { gap: 8px; }
.btn-explore, .btn-cashout, .btn-play-again {
  width: 100%; padding: 14px 12px; border-radius: var(--r-btn, 14px);
  border: 3px solid var(--ink, #0A1A2F);
  font-family: var(--font-display, 'Lilita One'), sans-serif;
  font-size: 1rem; letter-spacing: 0.8px; text-transform: uppercase; cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s;
}
.btn-explore { background: var(--ice, #3DC6F5); color: var(--ink, #0A1A2F);
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.45), 0 5px 0 0 var(--ice-deep, #1C97C4), 0 10px 16px rgba(5,16,30,0.4); }
.btn-explore:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.btn-explore:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255,255,255,0.45), 0 2px 0 0 var(--ice-deep, #1C97C4); }
.btn-explore:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: 0 5px 0 0 var(--ice-deep, #1C97C4); }

.btn-cashout { background: var(--teal, #15D6C4); color: var(--ink, #0A1A2F);
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.4), 0 5px 0 0 var(--teal-deep, #0FA897), 0 10px 16px rgba(5,16,30,0.4);
  animation: cashPulse 1.8s ease-in-out infinite; }
.btn-cashout:hover { transform: translateY(-2px) scale(1.02); animation-play-state: paused; }
.btn-cashout:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255,255,255,0.4), 0 2px 0 0 var(--teal-deep, #0FA897); }
@keyframes cashPulse {
  0%, 100% { box-shadow: inset 0 3px 0 rgba(255,255,255,0.4), 0 5px 0 0 var(--teal-deep, #0FA897), 0 10px 16px rgba(5,16,30,0.4); }
  50%       { box-shadow: inset 0 3px 0 rgba(255,255,255,0.4), 0 5px 0 0 var(--teal-deep, #0FA897), 0 0 30px rgba(21,214,196,0.5); }
}
.btn-play-again { background: var(--gold, #FFC83D); color: var(--ink, #0A1A2F);
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.5), 0 5px 0 0 var(--gold-deep, #E0A21F), 0 10px 16px rgba(5,16,30,0.4); }
.btn-play-again:hover { transform: translateY(-2px) scale(1.02); }
.btn-play-again:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255,255,255,0.5), 0 2px 0 0 var(--gold-deep, #E0A21F); }

/* Stats */
.stats-section { margin-top: auto; padding-top: 14px; gap: 7px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; }
.stat-lbl { font-size: 0.66rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); }
.stat-val { font-size: 0.95rem; font-weight: 800; color: var(--cream, #F4FAFF); }
.stat-val.positive { color: var(--teal, #2BE0CE); }
.stat-val.negative { color: var(--coral, #FF7D89); }

/* ── BOARD AREA (right) ── */
.board-area { flex: 1; display: flex; align-items: stretch; justify-content: center; padding: 16px 20px; overflow: hidden; }
.board-inner { display: flex; flex-direction: column; width: 100%; max-width: 660px; gap: 10px; }
.board-header { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.board-title { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 1rem; letter-spacing: 2px; text-transform: uppercase; color: var(--ice, #3DC6F5); }
.board-picks { font-size: 0.7rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); }

/* ── THE BOARD (5×5 grid) ── */
.board {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr);
  gap: 8px; padding: 14px; position: relative;
  background:
    linear-gradient(160deg, rgba(20,60,100,0.4) 0%, rgba(14,40,78,0.5) 55%, rgba(40,20,80,0.6) 100%);
  border: 4px solid var(--ink, #0A1A2F);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 8px 0 var(--ink, #0A1A2F), 0 16px 30px rgba(5,16,30,0.4);
}
.board::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 45%;
  background: radial-gradient(ellipse 80% 70% at 50% 0%, rgba(61,198,245,0.16) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
.board::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40%;
  background: radial-gradient(ellipse 70% 60% at 50% 100%, rgba(138,107,255,0.22) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── TILE BASE ── */
.tile {
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; user-select: none; cursor: default;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.18s; z-index: 1;
}
.tile.covered { background: rgba(10,24,46,0.85); border: 2px solid rgba(10,26,47,0.6); }
.tile.covered::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(-48deg, transparent 0px, transparent 9px, rgba(255,255,255,0.015) 9px, rgba(255,255,255,0.015) 10px);
  border-radius: inherit;
}
.tile.reachable {
  background: rgba(14,40,82,0.75); border: 2.5px solid rgba(61,198,245,0.55);
  cursor: pointer; animation: reachablePulse 2.4s ease-in-out infinite;
}
.tile.reachable:hover {
  transform: translateY(-4px) scale(1.06); background: rgba(20,56,108,0.9); border-color: var(--ice, #3DC6F5);
  box-shadow: 0 0 28px rgba(61,198,245,0.6), 0 8px 22px rgba(5,16,30,0.55), inset 0 1px 0 rgba(255,255,255,0.14);
  animation: none;
}
@keyframes reachablePulse {
  0%, 100% { box-shadow: 0 0 8px rgba(61,198,245,0.18); border-color: rgba(61,198,245,0.42); }
  50%      { box-shadow: 0 0 22px rgba(61,198,245,0.52), 0 0 44px rgba(61,198,245,0.18); border-color: rgba(61,198,245,0.85); }
}
.tile.just-unlocked { animation: becomeReachable 0.42s cubic-bezier(0.34,1.56,0.64,1) both, reachablePulse 2.4s ease-in-out 0.42s infinite; }
@keyframes becomeReachable { 0% { opacity: 0.2; transform: scale(0.85); } 55% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }

/* ── TILE: SAFE (gem) ── */
.tile.safe {
  background: linear-gradient(145deg, #0c3a50, #08222e); border: 3px solid var(--ice, #3DC6F5);
  box-shadow: 0 0 16px rgba(61,198,245,0.38), 0 0 38px rgba(28,151,196,0.14), inset 0 1px 0 rgba(255,255,255,0.08);
  animation: safeReveal 0.42s cubic-bezier(0.34,1.56,0.64,1) both; cursor: default;
}
@keyframes safeReveal { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.gem { width: 50%; height: 50%; position: relative; display: flex; align-items: center; justify-content: center; }
.gem-core {
  width: 100%; height: 100%; border-radius: 4px;
  background: linear-gradient(135deg, #3DC6F5, #15D6C4, #8A6BFF, #3DC6F5);
  background-size: 300% 300%; animation: gemShimmer 2.8s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(61,198,245,0.8), 0 0 28px rgba(138,107,255,0.4), inset 0 1px 0 rgba(255,255,255,0.55);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
@keyframes gemShimmer { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.tile.safe-center { border-color: var(--teal, #15D6C4); box-shadow: 0 0 20px rgba(21,214,196,0.4), 0 0 50px rgba(15,168,151,0.18), inset 0 1px 0 rgba(255,255,255,0.10); }
.tile.safe-center .gem-core { background: linear-gradient(135deg, #2BE0CE, #3DC6F5, #8A6BFF); box-shadow: 0 0 16px rgba(43,224,206,0.85), 0 0 36px rgba(21,214,196,0.5), inset 0 1px 0 rgba(255,255,255,0.6); }

/* ── TILE: VOID (death) ── */
.tile.void {
  background: linear-gradient(145deg, #5a1020, #2a0810); border: 3px solid var(--coral, #FF5D6C);
  box-shadow: 0 0 26px rgba(255,93,108,0.65), 0 0 58px rgba(214,59,88,0.28), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: voidReveal 0.3s ease both, tileShake 0.52s ease both 0.12s; cursor: default;
}
@keyframes voidReveal { 0% { transform: scale(1.2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes tileShake { 0%{transform:translateX(0) rotate(0)} 16%{transform:translateX(-8px) rotate(-2deg)} 33%{transform:translateX(7px) rotate(2deg)} 50%{transform:translateX(-5px) rotate(-1deg)} 66%{transform:translateX(4px) rotate(1deg)} 83%{transform:translateX(-2px)} 100%{transform:translateX(0)} }
.void-icon { width: 42%; height: 42%; position: relative; }
.void-icon::before, .void-icon::after {
  content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 3px;
  background: #ff9aa6; border-radius: 2px; box-shadow: 0 0 10px rgba(255,93,108,0.9), 0 0 22px rgba(255,93,108,0.5);
  animation: iconPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both 0.12s;
}
.void-icon::before { transform: rotate(45deg); }
.void-icon::after  { transform: rotate(-45deg); animation-name: iconPopAlt; }
@keyframes iconPop    { 0%{transform:rotate(45deg) scale(0);opacity:0} 60%{transform:rotate(45deg) scale(1.2)} 100%{transform:rotate(45deg) scale(1);opacity:1} }
@keyframes iconPopAlt { 0%{transform:rotate(-45deg) scale(0);opacity:0} 60%{transform:rotate(-45deg) scale(1.2)} 100%{transform:rotate(-45deg) scale(1);opacity:1} }

.tile.void-retro { background: rgba(70,14,26,0.62); border: 2px solid rgba(255,93,108,0.32); opacity: 0.72; animation: retroReveal 0.28s ease both; cursor: default; }
.tile.void-retro .void-icon::before, .tile.void-retro .void-icon::after { background: rgba(255,120,135,0.65); box-shadow: none; }
@keyframes retroReveal { 0% { opacity: 0; transform: scale(0.82); } 100% { opacity: 0.72; transform: scale(1); } }

/* ── BOARD SHAKE + CRACK ── */
.board.shake { animation: boardShake 0.55s ease; }
@keyframes boardShake { 0%{transform:translateX(0)} 12%{transform:translateX(-11px)} 24%{transform:translateX(9px)} 36%{transform:translateX(-7px)} 50%{transform:translateX(5px)} 64%{transform:translateX(-3px)} 80%{transform:translateX(2px)} 100%{transform:translateX(0)} }
.void-crack-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 6; border-radius: 20px; animation: crackFlash 0.65s ease both; }
@keyframes crackFlash { 0%{background:rgba(255,93,108,0)} 18%{background:rgba(255,93,108,0.34)} 55%{background:rgba(255,93,108,0.1)} 100%{background:rgba(255,93,108,0)} }

/* ── RESULT BANNER ── */
.result-banner {
  position: absolute; inset: 0; border-radius: 20px;
  background: rgba(8,28,51,0.9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 8;
  animation: bannerIn 0.38s ease both;
}
@keyframes bannerIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes bannerOut { to { opacity: 0; transform: scale(0.97); } }
.result-banner.fade-out { animation: bannerOut 0.28s ease forwards; pointer-events: none; }
.result-label { font-size: 0.68rem; font-weight: 900; letter-spacing: 3px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); }
.result-mult-big { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: clamp(2.6rem, 6vw, 4.2rem); animation: multPop 0.55s cubic-bezier(0.34,1.56,0.64,1) both 0.08s; }
@keyframes multPop { 0% { transform: scale(0.45); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.result-win-amount { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 1.5rem; color: var(--cream, #F4FAFF); }
.result-sub { font-size: 0.74rem; color: var(--cream-dim, #9fb6cc); letter-spacing: 1px; font-weight: 700; }

/* ── RESPONSIVE ── */
@media (max-width: 680px) {
  .ctrl-panel { flex: 0 0 190px; padding: 12px 10px; }
  .mult-value-big { font-size: 2.2rem; }
  .board-area { padding: 10px 8px; }
}
@media (max-width: 480px) {
  .play-layout { flex-direction: column; }
  .ctrl-panel { flex: 0 0 auto; }
  .board-area { flex: 1; }
}
