/* ============ Theme + base (mobile-first) — Gold (#f0b90b) ============ */
:root {
  --bg:        #0b0e11;
  --bg-2:      #11151c;
  --panel:     #161b22;
  --panel-2:   #1e2530;
  --line:      rgba(255,255,255,.07);
  --text:      #eaecef;
  --muted:     #848e9c;
  --accent:    #f0b90b;   /* gold */
  --accent-2:  #f8d12f;   /* light gold */
  --gold:      #f0b90b;
  --win:       #0ecb81;
  --lose:      #f6465d;
  --shadow:    0 12px 34px rgba(0,0,0,.5);
  --r:         14px;
  --r-sm:      10px;
  --tap:       44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ===== Themed scrollbars (gold on dark) ===== */
* { scrollbar-width: thin; scrollbar-color: rgba(240,185,11,.4) rgba(255,255,255,.04); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.03); border-radius: 999px; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, rgba(240,185,11,.5), rgba(240,185,11,.3)); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(240,185,11,.65); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---- Splash / loading screen ---- */
#splash {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .45s ease; pointer-events: none;
}
#splash.splash-done { opacity: 0; }
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.splash-logo {
  height: 48px; width: auto;
  filter: drop-shadow(0 0 12px rgba(240,185,11,.55));
  animation: splash-pulse 1.6s ease-in-out infinite;
}
@keyframes splash-pulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 10px rgba(240,185,11,.45)); }
  50%       { transform: scale(1.06); filter: drop-shadow(0 0 22px rgba(240,185,11,.8));  }
}
.splash-dots { display: flex; gap: 8px; }
.splash-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: splash-dot 1.1s ease-in-out infinite;
}
.splash-dots span:nth-child(2) { animation-delay: .18s; }
.splash-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes splash-dot {
  0%, 80%, 100% { transform: scale(.55); opacity: .35; }
  40%            { transform: scale(1);   opacity: 1; }
}

html, body {
  margin: 0;
  background: radial-gradient(1200px 800px at 50% -10%, #15191f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: 'Sora', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .2px;
}
body { min-height: 100dvh; overflow-x: hidden; }

#app {
  max-width: 1040px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column; position: relative;
}

button { font-family: inherit; cursor: pointer; border: none; }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(11,14,17,.97), rgba(11,14,17,.8));
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; background: none; padding: 0; }
.brand-logo { height: 2.5rem; width: auto; object-fit: contain; image-rendering: -webkit-optimize-contrast; filter: drop-shadow(0 0 8px rgba(240,185,11,.25)); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: var(--tap); height: var(--tap); display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 18px; color: var(--text);
}

/* Volume popover */
.vol-popover {
  position: fixed; z-index: 999; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; display: none; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
}
.vol-popover.open { display: flex; }
.vol-slider {
  -webkit-appearance: none; appearance: none; width: 130px; height: 5px;
  border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) var(--pct, 90%), #3a3f4a var(--pct, 90%));
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.vol-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.balance {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15;
  background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: var(--r-sm);
}
.balance-mode { font-size: 9px; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.balance-mode.real { color: var(--gold); }
.balance-amount { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============ Buttons ============ */
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: var(--r-sm);
  background: var(--panel-2); color: var(--text); font-weight: 500; font-size: 14px;
  border: 1px solid var(--line); transition: transform .06s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-login { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #1a1300; border: none; font-weight: 700; }
.btn-ghost { background: var(--panel); }

/* ============ View ============ */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

/* ============ Toasts ============ */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; z-index: 60; padding: 0 14px;
}
.toast {
  pointer-events: auto; max-width: 92%;
  background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .25s ease, toast-out .3s ease forwards; animation-delay: 0s, var(--ttl, 2.4s);
}
.toast.win  { border-color: rgba(14,203,129,.5); box-shadow: 0 8px 28px rgba(14,203,129,.25); }
.toast.lose { border-color: rgba(246,70,93,.5); box-shadow: 0 8px 28px rgba(246,70,93,.25); }
.toast .toast-ic { display: inline-flex; }
.toast .toast-ic .ic { width: 18px; height: 18px; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ============ Mobile topbar compact ============ */
@media (max-width: 479px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .topbar-right { gap: 5px; }
  .brand-logo { height: 2rem; }
  .icon-btn { width: 36px; height: 36px; }
  .balance { padding: 4px 9px; }
  .balance-amount { font-size: 13px; }
  #auth-btn { padding: 0 10px; font-size: 12px; min-height: 34px; white-space: nowrap; border-radius: 8px; }
}
