/* ============================================================
   Apex — Instant-win mini game bundle
   Dark neon palette: deep navy + cyan + violet + gold accents
   ============================================================ */

:root {
  --bg0: #060d18;
  --bg1: #0c1a2e;
  --bg2: #142640;
  --felt: #040810;
  --accent: #00d4ff;     /* neon cyan */
  --accent-dim: #0088aa;
  --violet: #8b5cf6;
  --violet-dim: #5a3ab0;
  --gold: #ffd700;
  --gold-dim: #b89900;
  --gold-1: #fff4b0;
  --gold-2: #ffcc33;
  --gold-3: #a87100;
  --line: #1a3050;
  --line-bright: #2a4a6a;
  --text: #dde7f2;
  --text-dim: #8ea0b6;
  --text-mute: #5a6a80;
  --danger: #ff4d4d;
  --ok: #5ad37a;
  --warn: #ffb020;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  touch-action: manipulation;
  background: radial-gradient(ellipse at top, #0c1a30 0%, var(--bg0) 60%) fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: manipulation;
}

/* ===== Splash ===== */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0c1a30 0%, #040810 100%);
  transition: opacity 600ms ease, visibility 600ms ease;
}
.splash.dismissed { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 18px; padding: 40px; text-align: center;
}
.splash-logo { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.splash-logo strong {
  font-size: 46px; font-weight: 900; letter-spacing: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--violet) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 212, 255, 0.4));
}
.splash-logo span {
  font-size: 13px; font-weight: 700; letter-spacing: 6px;
  color: var(--text-dim); margin-top: 8px;
}
.splash-art {
  font-size: 56px;
  animation: splash-float 2.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(0, 212, 255, 0.3));
}
@keyframes splash-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.05); }
}
.splash-bar {
  width: 200px; height: 5px;
  background: rgba(0, 212, 255, 0.15); border-radius: 3px; overflow: hidden;
}
.splash-progress {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  border-radius: 3px;
  transition: width 300ms ease;
}
.splash-status { font-size: 12px; color: var(--text-dim); }
.splash-sub { font-size: 11px; color: var(--text-mute); letter-spacing: 1px; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(6,13,24,0.9);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-mark { flex: 0 0 auto; }
.brand-text { font-weight: 800; letter-spacing: 3px; font-size: 15px; color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: transparent; border: 1px solid var(--line-bright);
  color: var(--text-dim); border-radius: 8px;
  width: 34px; height: 32px; font-size: 14px; cursor: pointer;
  transition: border-color 0.2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.demo-badge[hidden] { display: none; }
.demo-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 8px;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  font-family: var(--mono); animation: demo-pulse 2s ease-in-out infinite;
}
@keyframes demo-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.balance-box {
  padding: 6px 10px; border: 1px solid var(--line-bright); border-radius: 8px;
  font-family: var(--mono); font-size: 14px; color: var(--accent); letter-spacing: 0.5px;
}
.balance-box small { color: var(--text-mute); margin-left: 4px; font-weight: 400; }

/* ===== Session strip ===== */
.session-strip {
  display: flex; gap: 0;
  background: var(--bg1); border-bottom: 1px solid var(--line);
  font-size: 11px; overflow-x: auto;
}
.ss-cell {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 5px 12px; border-right: 1px solid var(--line); white-space: nowrap;
}
.ss-label { font-size: 9px; color: var(--text-mute); letter-spacing: 1.2px; }
.ss-value { font-family: var(--mono); color: var(--text); font-size: 12px; margin-top: 1px; }
.ss-flag { font-size: 18px; padding: 4px 10px; display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); }
.ss-verdict { margin-left: auto; border-right: none; border-left: 1px solid var(--line); align-items: flex-end; }

/* ===== Tab bar ===== */
.tab-bar {
  display: flex; gap: 0;
  background: var(--bg1);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 0;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  font-family: var(--font);
}
.tab:hover { color: var(--text); background: rgba(0, 212, 255, 0.04); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(0, 212, 255, 0.06);
}
.tab-icon { font-size: 16px; }

/* ===== Stage ===== */
.stage {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 100%);
  min-height: 200px;
}
.game-panel {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  transition: opacity 0.25s ease;
}
.game-panel[hidden] { display: none; }

/* ===== Celebration overlay ===== */
.celebration-canvas {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 50;
  width: 100%; height: 100%;
}

/* ===== Scratch game ===== */
#scratchCanvas {
  border-radius: var(--radius);
  cursor: crosshair;
  touch-action: none;
  max-width: 340px; max-height: 340px;
  width: 90vw; height: 90vw;
  box-shadow: 0 4px 30px rgba(0,0,0,0.4), inset 0 0 60px rgba(0,0,0,0.2);
  border: 2px solid var(--line-bright);
}
.scratch-result {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.scratch-result[hidden] { display: none; }
.result-title {
  font-size: 28px; font-weight: 900; letter-spacing: 2px;
  text-shadow: 0 2px 12px rgba(0, 212, 255, 0.5);
}
.result-amount {
  font-size: 36px; font-weight: 900; margin-top: 8px;
  font-family: var(--mono); color: var(--gold);
  text-shadow: 0 2px 12px rgba(255, 215, 0, 0.5);
}

/* ===== Wheel game ===== */
.wheel-wrap {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
#wheelCanvas {
  width: min(340px, 85vw);
  height: min(340px, 85vw);
  transition: filter 0.3s;
}
.wheel-pointer {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 30px solid var(--gold);
  z-index: 10;
  filter: drop-shadow(0 2px 6px rgba(255, 215, 0, 0.5));
}

/* ===== Flip game ===== */
.flip-wrap {
  perspective: 800px;
  width: 160px; height: 160px;
  margin: 10px auto;
}
.coin {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.1s;
}
.coin.flipping {
  animation: coin-flip 0.6s ease-out forwards;
}
.coin.flipping-tails {
  animation: coin-flip-tails 0.6s ease-out forwards;
}
@keyframes coin-flip {
  0%   { transform: translateY(0)    rotateY(0deg); }
  40%  { transform: translateY(-60px) rotateY(540deg); }
  100% { transform: translateY(0)    rotateY(720deg); }
}
@keyframes coin-flip-tails {
  0%   { transform: translateY(0)    rotateY(0deg); }
  40%  { transform: translateY(-60px) rotateY(540deg); }
  100% { transform: translateY(0)    rotateY(900deg); }
}
.coin-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 50%;
  backface-visibility: hidden;
  font-weight: 800;
}
.coin-heads {
  background: radial-gradient(circle at 40% 35%, #00e8ff 0%, #0088cc 60%, #005580 100%);
  border: 3px solid rgba(0, 212, 255, 0.6);
  box-shadow: 0 0 24px rgba(0, 212, 255, 0.3), inset 0 -4px 12px rgba(0,0,0,0.3);
  color: #fff;
}
.coin-tails {
  background: radial-gradient(circle at 40% 35%, #c084fc 0%, #7c3aed 60%, #4c1d95 100%);
  border: 3px solid rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 24px rgba(139, 92, 246, 0.3), inset 0 -4px 12px rgba(0,0,0,0.3);
  color: #fff;
  transform: rotateY(180deg);
}
.coin-symbol { font-size: 48px; line-height: 1; }
.coin-label { font-size: 14px; letter-spacing: 3px; margin-top: 4px; }

.flip-streak {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 0; font-family: var(--mono);
}
.streak-label { font-size: 10px; color: var(--text-mute); letter-spacing: 2px; }
.streak-count { font-size: 22px; font-weight: 900; color: var(--accent); }
.streak-mult { font-size: 16px; font-weight: 700; color: var(--gold); }

.flip-pick {
  display: flex; gap: 12px; justify-content: center; padding: 4px 0;
}
.pick-btn {
  flex: 1; max-width: 140px;
  padding: 12px 0;
  border: 2px solid var(--line-bright); border-radius: var(--radius);
  background: rgba(0, 212, 255, 0.06); color: var(--text);
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all 0.15s; font-family: var(--font);
}
.pick-btn:hover { border-color: var(--accent); background: rgba(0, 212, 255, 0.12); }
.pick-btn:active { transform: scale(0.96); }
.pick-btn.selected { border-color: var(--accent); background: rgba(0, 212, 255, 0.15); color: var(--accent); }
.pick-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Bet panel ===== */
.bet-panel {
  padding: 10px 14px 14px;
  background: var(--bg1);
  border-top: 1px solid var(--line);
}
.stake-row {
  display: flex; align-items: center; gap: 8px;
}
.stake-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--line-bright); border-radius: 8px;
  background: rgba(0, 212, 255, 0.06); color: var(--text);
  font-size: 20px; cursor: pointer; font-family: var(--font);
  transition: border-color 0.15s;
}
.stake-btn:hover { border-color: var(--accent); }
.stake-btn:active { transform: scale(0.94); }
.stake-display {
  display: flex; flex-direction: column; align-items: center; min-width: 70px;
}
.stake-label { font-size: 9px; color: var(--text-mute); letter-spacing: 1.5px; }
.stake-value { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--text); }
.stake-chips {
  display: flex; gap: 6px; margin-left: auto;
}
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line-bright); border-radius: 6px;
  background: transparent; color: var(--text-dim);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: var(--font);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { border-color: var(--accent); background: rgba(0, 212, 255, 0.1); color: var(--accent); }
.chip.needs-confirm {
  border-color: var(--warn); color: var(--warn);
  animation: confirm-pulse 0.8s ease-in-out infinite;
}
@keyframes confirm-pulse {
  50% { box-shadow: 0 0 8px rgba(255, 176, 32, 0.4); }
}

.action-row {
  display: flex; gap: 10px; margin-top: 10px;
}
.action {
  flex: 1; padding: 14px 0;
  border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 800; letter-spacing: 2px;
  cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.action:active { transform: scale(0.97); }
.action:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.action-play {
  background: linear-gradient(135deg, var(--accent) 0%, var(--violet) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}
.action-play:hover:not(:disabled) { box-shadow: 0 4px 24px rgba(0, 212, 255, 0.45); }
.action-cashout {
  background: linear-gradient(135deg, var(--gold) 0%, #ff9800 100%);
  color: #1a1a1a;
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}
.action-cashout:hover:not(:disabled) { box-shadow: 0 4px 24px rgba(255, 215, 0, 0.45); }

.hint-row {
  text-align: center; font-size: 11px; color: var(--text-mute);
  margin-top: 8px; min-height: 16px;
}
.hint-row.warn { color: var(--warn); }
.hint-row.ok { color: var(--ok); }

/* ===== Drawer ===== */
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(360px, 90vw);
  background: var(--bg1); border-left: 1px solid var(--line);
  z-index: 200; overflow-y: auto;
  box-shadow: -6px 0 30px rgba(0,0,0,0.5);
  transition: transform 0.3s ease;
}
.drawer[hidden] { display: block; transform: translateX(100%); pointer-events: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-weight: 700; letter-spacing: 1px;
}
.drawer-body {
  padding: 16px; font-size: 13px; line-height: 1.6; color: var(--text-dim);
}
.drawer-body dl { margin: 12px 0; }
.drawer-body dt { font-size: 10px; color: var(--text-mute); letter-spacing: 1px; margin-top: 10px; }
.drawer-body dd {
  margin: 4px 0 0 0; font-family: var(--mono); font-size: 11px;
  word-break: break-all; color: var(--text);
}
.drawer-body .small { font-size: 11px; color: var(--text-mute); }

/* ===== Modals ===== */
.modal {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg2); border: 1px solid var(--line-bright);
  border-radius: 16px; padding: 32px 28px; text-align: center;
  min-width: 280px; max-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.modal-title {
  font-size: 22px; font-weight: 900; letter-spacing: 3px;
  color: var(--accent);
}
.modal-title.win { color: var(--gold); }
.modal-title.loss { color: var(--danger); }
.modal-sub { font-size: 14px; color: var(--text-dim); margin-top: 8px; }
.modal-payout {
  font-size: 28px; font-weight: 900; margin-top: 12px;
  font-family: var(--mono);
}
.modal-ok {
  margin-top: 20px; padding: 12px 36px;
  border: none; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 2px;
  cursor: pointer; font-family: var(--font);
}
.modal-ok:hover { box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .stake-chips { gap: 4px; }
  .chip { padding: 5px 8px; font-size: 12px; }
  #scratchCanvas { max-width: 300px; max-height: 300px; }
  .flip-wrap { width: 130px; height: 130px; }
  .coin-symbol { font-size: 40px; }
}
@media (min-width: 780px) {
  .stage { min-height: 380px; }
  #scratchCanvas { max-width: 380px; max-height: 380px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
