/* =============================================
   QUICKDRAW — 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);
}
.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 ── */
.game-wrap {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 10px 10px 14px; overflow: hidden;
}

/* ── BOARD ── */
.board {
  --bd: min(920px, 98vw, calc(100dvh - 150px));
  width: var(--bd); height: var(--bd);
  min-width: 280px; min-height: 280px;
  background: var(--bg-deep, #081C33);
  border: 4px solid var(--ink, #0A1A2F);
  border-radius: 26px;
  box-shadow: 0 10px 0 var(--ink, #0A1A2F), 0 24px 50px rgba(5,16,30,0.45);
  position: relative; overflow: hidden; flex-shrink: 1;
}
.board::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 45% at 50% 18%, rgba(61,198,245,0.16) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── IDLE STACK ── */
.idle-stack {
  position: absolute; top: 50%; left: 50%;
  width: 38%; height: 38%; min-width: 110px; min-height: 110px; max-width: 280px; max-height: 280px;
  transform: translate(-50%, -58%);
  transition: opacity 0.32s ease, transform 0.32s ease; z-index: 2;
}
.idle-stack.hidden { opacity: 0; transform: translate(-50%, -65%) scale(0.88); pointer-events: none; }
.stack-card {
  position: absolute; inset: 0; border-radius: 14px;
  background:
    repeating-linear-gradient(128deg, transparent 0px, transparent 14px, rgba(255,255,255,0.06) 14px, rgba(255,255,255,0.06) 15px),
    linear-gradient(148deg, #2C9AD6 0%, #1C6FA6 48%, #134E7C 100%);
  border: 3px solid var(--ink, #0A1A2F);
  box-shadow: 0 8px 24px rgba(5,16,30,0.6), inset 0 2px 0 rgba(255,255,255,0.18);
}
.stack-card.top::after {
  content: '❄'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.8rem, 5vw, 3rem); color: #EAF6FF; filter: drop-shadow(0 0 9px rgba(255,255,255,0.5));
}
.idle-prompt {
  position: absolute; bottom: 5%; left: 0; right: 0; text-align: center;
  font-size: clamp(0.55rem, 1.4%, 0.75rem); font-weight: 800; letter-spacing: 2px; text-transform: uppercase;
  color: var(--cream-dim, #9fb6cc); opacity: .6; z-index: 2; transition: opacity 0.3s;
}
.idle-prompt.hidden { opacity: 0; }

/* ── CARD GRID ── */
.card-grid {
  position: absolute; inset: 4% 3.5% 3.5%;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 2.5%; z-index: 2;
}
.card-grid[hidden] { display: none; }

.card-item { position: relative; border-radius: 14px; cursor: pointer; transition: transform 0.32s cubic-bezier(0.22,1,0.36,1), box-shadow 0.32s ease; user-select: none; }
.card-item:not(.selected):not(.no-hover):hover { transform: translateY(-4%); box-shadow: 0 14px 30px rgba(5,16,30,0.55); }
.card-item.selected {
  transform: translateY(-14%) !important;
  box-shadow: 0 22px 42px rgba(5,16,30,0.65), 0 0 24px rgba(61,198,245,0.4) !important;
  outline: 3px solid var(--ice, #3DC6F5);
}
.card-item.unchosen { opacity: 0.5; transition: opacity 0.55s ease, transform 0.32s cubic-bezier(0.22,1,0.36,1); }
.card-item.unchosen .card-front { background: linear-gradient(160deg, #e7eef7 0%, #cfdcec 100%); }
.card-item.dimmed { opacity: 0.3; transition: opacity 0.5s ease, transform 0.32s cubic-bezier(0.22,1,0.36,1); }
.card-item.no-hover { cursor: default; }

.card-inner { width: 100%; height: 100%; position: relative; border-radius: 14px; transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.22,1,0.36,1); }
.card-inner.flipped { transform: rotateY(180deg); }

.card-face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }

/* Back face — frozen ice */
.card-back {
  background:
    repeating-linear-gradient(128deg, transparent 0px, transparent 14px, rgba(255,255,255,0.06) 14px, rgba(255,255,255,0.06) 15px),
    linear-gradient(148deg, #2C9AD6 0%, #1C6FA6 48%, #134E7C 100%);
  border: 3px solid var(--ink, #0A1A2F);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
}
.card-back-icon { font-size: clamp(1rem, 3vw, 1.8rem); color: #EAF6FF; filter: drop-shadow(0 0 7px rgba(255,255,255,0.5)); transition: transform 0.4s; }
.card-item:not(.no-hover):hover .card-back-icon { transform: scale(1.14); }

/* Front face — light card with multiplier */
.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #f4f8fc 0%, #e2ebf5 100%);
  border: 3px solid var(--ink, #0A1A2F);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.90);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3%;
}
.mult-value { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: clamp(0.9rem, 2.9vw, 1.7rem); line-height: 1; }
.mult-label { font-size: clamp(0.45rem, 1.1vw, 0.65rem); font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: #5e7793; }

/* ── DEAL ANIMATION ── */
@keyframes cardDealIn {
  0% { transform: translateY(var(--dy, -55px)) scale(0.38) rotate(var(--dr, 12deg)); opacity: 0; }
  55% { opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}
.card-item.dealing { animation: cardDealIn 0.52s cubic-bezier(0.22,1,0.36,1) both; }

/* ── RESULT OVERLAY ── */
.result-overlay {
  position: absolute; inset: 0; border-radius: 22px;
  background: rgba(8,28,51,0.92); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 2vw, 14px); z-index: 10; animation: overlayIn 0.38s ease both;
}
.result-overlay[hidden] { display: none; }
@keyframes overlayOut { to { opacity: 0; transform: scale(0.97); } }
.result-overlay.fade-out { animation: overlayOut 0.28s ease forwards; pointer-events: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.result-cards-info { font-size: clamp(0.58rem, 1.4vw, 0.75rem); font-weight: 800; letter-spacing: 2.5px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); }
.result-mult { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: clamp(2.6rem, 8vw, 4.4rem); line-height: 1; animation: multPop 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes multPop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.result-amount { font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: clamp(1.1rem, 2.6vw, 1.6rem); letter-spacing: 0.3px; }

.btn-play-again {
  margin-top: 8px; padding: 13px 34px; border-radius: var(--r-btn, 16px);
  border: 3.5px solid var(--ink, #0A1A2F);
  background: var(--gold, #FFC83D); color: var(--ink, #0A1A2F);
  font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  letter-spacing: 0.6px; text-transform: uppercase; cursor: pointer;
  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);
  transition: transform .14s, box-shadow .14s;
}
.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); }

/* ── ACTION PANEL ── */
.action-panel {
  display: flex; align-items: stretch;
  width: min(920px, 98vw, calc(100dvh - 150px)); min-width: 280px;
  background: var(--panel, #173B63);
  border: 4px solid var(--ink, #0A1A2F);
  border-radius: 18px;
  box-shadow: 0 8px 0 var(--ink, #0A1A2F), 0 16px 28px rgba(5,16,30,0.4);
  overflow: hidden; flex-shrink: 0;
}
.ap-group { display: flex; flex-direction: column; justify-content: center; gap: 7px; padding: 12px 18px; flex: 1; }
.ap-group:first-child { flex: 0 0 auto; }
.ap-action { flex: 1; }
.ap-label { font-size: 0.66rem; font-weight: 900; letter-spacing: 1.6px; text-transform: uppercase; color: var(--cream-dim, #9fb6cc); white-space: nowrap; }
.ap-divider { width: 2px; background: var(--hairline, rgba(244,250,255,0.12)); flex-shrink: 0; }

/* Bet */
.bet-row { display: flex; gap: 6px; align-items: center; }
.bet-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 10px;
}
.bet-wrap:focus-within { border-color: var(--ice, #3DC6F5); box-shadow: 0 0 0 3px rgba(61,198,245,0.18); }
.bet-sign { font-size: 0.95rem; font-weight: 800; color: var(--ice, #3DC6F5); }
#bet-input {
  width: 64px; background: transparent; border: none; outline: none;
  font-size: 1.05rem; 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-adj {
  width: 36px; height: 36px; border-radius: 10px;
  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.82rem; cursor: pointer;
  transition: background .14s, transform .14s;
}
.bet-adj:hover { background: var(--ice, #3DC6F5); color: var(--ink, #0A1A2F); transform: translateY(-1px); }

/* Volatility segmented control */
.seg-row { display: flex; border-radius: 12px; overflow: hidden; border: 2.5px solid var(--ink, #0A1A2F); }
.seg-btn {
  flex: 1; padding: 10px 8px; background: rgba(8,28,51,0.5); border: none;
  border-right: 2px solid var(--ink, #0A1A2F);
  color: var(--cream-dim, #9fb6cc); font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 0.82rem;
  cursor: pointer; transition: background .16s, color .16s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--panel-2, #1E4C7E); color: var(--cream, #F4FAFF); }
.seg-btn.active { background: var(--ice, #3DC6F5); color: var(--ink, #0A1A2F); }

/* Main action button */
.btn-main {
  width: 100%; padding: 11px 12px; border-radius: var(--r-btn, 14px);
  border: 3px solid var(--ink, #0A1A2F);
  background: var(--gold, #FFC83D); color: var(--ink, #0A1A2F);
  font-family: var(--font-display, 'Lilita One'), sans-serif; font-size: 0.98rem; letter-spacing: 0.5px;
  text-transform: uppercase; cursor: pointer; white-space: nowrap;
  transition: transform .14s, box-shadow .14s;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.5), 0 5px 0 0 var(--gold-deep, #E0A21F), 0 10px 14px rgba(5,16,30,0.35);
}
.btn-main:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.btn-main:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255,255,255,0.5), 0 2px 0 0 var(--gold-deep, #E0A21F); }
.btn-main:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: 0 5px 0 0 var(--gold-deep, #E0A21F); }

.sel-info { font-size: 0.65rem; color: var(--cream-dim, #9fb6cc); text-align: center; min-height: 13px; letter-spacing: 0.5px; font-weight: 700; }

/* ── ROUND-END: fresh pile slides in ── */
@keyframes stackSlideIn {
  from { transform: translate(calc(-50% - 110vw), -58%); opacity: 0; }
  to { transform: translate(-50%, -58%); opacity: 1; }
}
.idle-stack.slide-in { animation: stackSlideIn 0.52s cubic-bezier(0.22,1,0.36,1) both; }

/* ── RESPONSIVE ── */
@media (max-width: 420px) {
  .action-panel { flex-direction: column; border-radius: 16px; }
  .ap-divider { width: auto; height: 2px; }
  .ap-group { padding: 12px 14px; }
}
