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

/* ── 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 ease, text-shadow 0.4s ease;
  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, transform .14s;
}
.bet-adj:hover { background: var(--ice, #3DC6F5); color: var(--ink, #0A1A2F); }

/* Action buttons */
.ctrl-action { gap: 8px; }
.btn-descend, .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-descend { 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-descend:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.btn-descend: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-descend: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: 700px; 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-depth { font-size: 0.7rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); }

/* ── BOARD: 8-tier vertical grid ── */
.board {
  flex: 1; display: flex; flex-direction: column; gap: 5px; min-height: 0;
  background:
    linear-gradient(180deg,
      rgba(20,60,100,0.35) 0%,
      rgba(14,40,78,0.45) 35%,
      rgba(20,18,60,0.55) 70%,
      rgba(40,20,80,0.65) 100%);
  border: 4px solid var(--ink, #0A1A2F);
  border-radius: 20px; padding: 12px 10px; overflow: hidden; position: relative;
  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: 40%;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(61,198,245,0.18) 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 80% 60% at 50% 100%, rgba(138,107,255,0.28) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── TIER ROW ── */
.tier-row {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 56px 1fr 56px;
  align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px;
  border-left: 3px solid transparent; position: relative; z-index: 1;
  transition: background 0.3s, border-color 0.3s;
}
.tier-row:nth-child(1), .tier-row:nth-child(2) { --tier-accent: #3DC6F5; --payout-color: #3DC6F5; }
.tier-row:nth-child(3), .tier-row:nth-child(4) { --tier-accent: #15D6C4; --payout-color: #15D6C4; }
.tier-row:nth-child(5), .tier-row:nth-child(6) { --tier-accent: #8A6BFF; --payout-color: #8A6BFF; }
.tier-row:nth-child(7), .tier-row:nth-child(8) { --tier-accent: #FFC83D; --payout-color: #FFC83D; }
.tier-row.active-tier { background: rgba(255,255,255,0.05); border-left-color: var(--tier-accent); }

/* ── DANGER INDICATORS (left) ── */
.tier-danger { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.danger-icon { width: 9px; height: 9px; background: var(--coral, #FF5D6C); transform: rotate(45deg); border-radius: 2px; box-shadow: 0 0 6px rgba(255,93,108,0.5); flex-shrink: 0; }

/* ── CELLS ── */
.tier-cells { display: flex; gap: 5px; align-items: center; justify-content: center; height: 100%; }
.cell {
  flex: 1; height: 100%; min-height: 28px; max-height: 60px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  position: relative; overflow: hidden;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.2s; user-select: none;
}
.cell.locked { background: rgba(14,30,54,0.6); border: 2px solid rgba(10,26,47,0.6); cursor: not-allowed; }
.cell.locked::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0px, transparent 8px, rgba(255,255,255,0.02) 8px, rgba(255,255,255,0.02) 9px);
}
.cell.active {
  background: rgba(24,52,100,0.65); border: 2.5px solid var(--tier-accent, #3DC6F5); cursor: pointer;
  box-shadow: 0 0 12px rgba(61,198,245,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
  animation: cellPulse 2s ease-in-out infinite;
}
.cell.active:hover {
  transform: translateY(-3px) scale(1.04); background: rgba(30,70,130,0.78);
  box-shadow: 0 0 22px rgba(61,198,245,0.45), 0 6px 18px rgba(5,16,30,0.4), inset 0 1px 0 rgba(255,255,255,0.12);
  animation: none;
}
@keyframes cellPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(61,198,245,0.15), inset 0 1px 0 rgba(255,255,255,0.06); }
  50%       { box-shadow: 0 0 20px rgba(61,198,245,0.4), inset 0 1px 0 rgba(255,255,255,0.10); }
}
.cell.chosen-safe {
  background: linear-gradient(135deg, #0e4866, #0a2840); border: 3px solid var(--ice, #3DC6F5);
  box-shadow: 0 0 28px rgba(61,198,245,0.6), 0 0 60px rgba(61,198,245,0.25), inset 0 1px 0 rgba(255,255,255,0.18);
  cursor: default; animation: safeReveal 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}
.cell.chosen-safe .cell-icon { color: #8aeaff; filter: drop-shadow(0 0 8px rgba(138,234,255,0.8)); font-size: 1.3rem; animation: iconPop 0.5s cubic-bezier(0.34,1.56,0.64,1) both 0.1s; }
@keyframes safeReveal { 0% { transform: scale(0.7); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.cell.chosen-void {
  background: linear-gradient(135deg, #6a1426, #3a0a16); border: 3px solid var(--coral, #FF5D6C);
  box-shadow: 0 0 28px rgba(255,93,108,0.6), 0 0 60px rgba(214,59,88,0.25), inset 0 1px 0 rgba(255,255,255,0.06);
  cursor: default; animation: voidReveal 0.3s ease both, cellShake 0.5s ease both 0.15s;
}
.cell.chosen-void .cell-icon { color: #ff9aa6; font-size: 1.2rem; filter: drop-shadow(0 0 6px rgba(255,154,166,0.7)); animation: iconPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both 0.1s; }
@keyframes voidReveal { 0% { transform: scale(1.2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes cellShake { 0%{transform:translateX(0)} 15%{transform:translateX(-8px) rotate(-2deg)} 30%{transform:translateX(7px) rotate(2deg)} 45%{transform:translateX(-5px) rotate(-1deg)} 60%{transform:translateX(4px) rotate(1deg)} 75%{transform:translateX(-2px)} 100%{transform:translateX(0)} }
@keyframes iconPop { 0%{transform:scale(0);opacity:0} 60%{transform:scale(1.3);opacity:1} 100%{transform:scale(1);opacity:1} }
.cell.safe { background: rgba(10,40,70,0.55); border: 2px solid rgba(61,198,245,0.28); cursor: default; opacity: 0.65; }
.cell.safe .cell-icon { color: rgba(120,210,245,0.7); font-size: 0.9rem; }
.cell.void { background: rgba(70,14,26,0.55); border: 2px solid rgba(255,93,108,0.28); cursor: default; opacity: 0.65; }
.cell.void .cell-icon { color: rgba(255,120,135,0.7); font-size: 0.9rem; }
.cell.reveal-anim { animation: retroReveal 0.3s ease both; }
@keyframes retroReveal { 0% { opacity: 0; transform: scale(0.8); } 100% { opacity: 0.65; transform: scale(1); } }

/* ── PAYOUT LABEL (right) ── */
.tier-payout {
  text-align: right; font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 0.78rem;
  color: var(--payout-color, #3DC6F5); opacity: 0.45; white-space: nowrap;
  transition: opacity 0.3s, text-shadow 0.3s; padding-right: 2px;
}
.tier-payout.earned { opacity: 1; text-shadow: 0 0 12px var(--payout-color, #3DC6F5); }
.tier-row:nth-child(7) .tier-payout.earned, .tier-row:nth-child(8) .tier-payout.earned {
  color: var(--gold, #FFC83D); text-shadow: 0 0 14px rgba(255,200,61,0.8), 0 0 28px rgba(255,180,20,0.4);
}

/* ── BOARD SHAKE + CRACK ── */
.board.shake { animation: boardShake 0.55s ease; }
@keyframes boardShake { 0%{transform:translateX(0)} 12%{transform:translateX(-10px)} 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: 5; border-radius: 20px; animation: crackFlash 0.6s ease both; }
@keyframes crackFlash { 0%{background:rgba(255,93,108,0)} 20%{background:rgba(255,93,108,0.32)} 50%{background:rgba(255,93,108,0.12)} 100%{background:rgba(255,93,108,0)} }

/* ── RESULT OVERLAY ── */
.result-banner {
  position: absolute; inset: 0; border-radius: 20px;
  background: rgba(8,28,51,0.9); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 8;
  animation: bannerIn 0.4s 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-banner[hidden] { display: none; }
.result-label { font-size: 0.7rem; 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.6s cubic-bezier(0.34,1.56,0.64,1) both 0.1s; }
@keyframes multPop { 0% { transform: scale(0.5); 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; }
}
