/* ── Reset ── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* ── Tokens ── */
:root {
  --bg:        #080b1a;
  --surface:   #0f1226;
  --card:      #141830;
  --card2:     #1a1e3a;
  --border:    rgba(255,215,0,.18);
  --gold:      #ffd700;
  --gold-l:    #ffe566;
  --gold-dim:  rgba(255,215,0,.4);
  --red:       #e74c3c;
  --green:     #27ae60;
  --text:      #e8eaf6;
  --muted:     #6c7099;
  --win-c:     #2ecc71;
  --lose-c:    #e74c3c;
  --r:         16px;
  --glow:      0 0 28px rgba(255,215,0,.35);
}

/* ── Base ── */
html, body { height: 100%; }
body {
  font-family: 'Montserrat', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(88,28,220,.25) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(255,215,0,.06) 0%, transparent 60%),
    var(--bg);
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(20,24,56,.95) 0%, rgba(14,17,40,.85) 100%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 50;
}

.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5e35b1, #9c27b0);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff; flex-shrink: 0;
  border: 2px solid var(--gold-dim);
  box-shadow: 0 0 16px rgba(94,53,177,.5);
}

.user-info { flex: 1; min-width: 0; }

.username {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.balance-wrap { display: flex; align-items: center; gap: 4px; margin-top: 2px; }

.balance-icon { font-size: 13px; }

.balance {
  font-size: 20px; font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255,215,0,.55);
  letter-spacing: .5px;
}

.balance.pop { animation: balancePop .55s ease; }

.balance-label { font-size: 11px; color: var(--muted); }

.header-logo { font-size: 26px; flex-shrink: 0; filter: drop-shadow(0 0 8px rgba(255,215,0,.5)); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 6px;
  padding: 10px 14px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1; padding: 10px 6px;
  border: none; border-radius: 12px 12px 0 0;
  background: none;
  color: var(--muted);
  font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all .25s;
  white-space: nowrap;
}

.tab.active {
  background: var(--card);
  color: var(--gold);
  box-shadow: inset 0 -2px 0 var(--gold), var(--glow);
}

.tab:hover:not(.active) { color: var(--text); background: rgba(255,255,255,.04); }

/* ── Game area ── */
.game-area { flex: 1; padding: 18px 14px 30px; overflow-y: auto; }
.game.hidden { display: none; }

/* ── Card ── */
.game-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px 18px 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
  animation: cardIn .3s ease;
}

.game-title {
  font-size: 19px; font-weight: 900;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,.5);
  letter-spacing: 1px;
  margin-bottom: 22px;
}

/* ══════════════ SLOTS ══════════════ */
.slot-machine { position: relative; margin-bottom: 18px; }

.slot-glow {
  position: absolute; inset: -4px;
  border-radius: 22px;
  background: transparent;
  box-shadow: 0 0 0 0 rgba(255,215,0,0);
  transition: box-shadow .4s;
  pointer-events: none;
}
.slot-machine.winning .slot-glow { box-shadow: 0 0 40px 6px rgba(255,215,0,.45); }

.slot-frame {
  display: flex; align-items: center; justify-content: center;
  background: #060818;
  border: 3px solid rgba(255,215,0,.3);
  border-radius: 20px;
  padding: 18px 20px;
  gap: 0;
  box-shadow: inset 0 6px 24px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.03);
  position: relative;
  overflow: hidden;
}

.slot-frame::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 82px;
  border-top: 1px solid rgba(255,215,0,.25);
  border-bottom: 1px solid rgba(255,215,0,.25);
  pointer-events: none;
}

.reel-wrap {
  width: 80px; height: 80px;
  overflow: hidden;
  border-radius: 10px;
  position: relative;
}

.reel {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  background: #0e1128;
  border-radius: 10px;
  will-change: transform;
  transition: filter .2s;
}

.reel.spinning { animation: reelBlur .12s linear infinite; }
.reel.land { animation: reelLand .45s cubic-bezier(.36,.07,.19,.97); }

.reel-sep {
  width: 1px; height: 50px;
  background: linear-gradient(180deg, transparent, rgba(255,215,0,.35), transparent);
  margin: 0 10px;
}

/* Payout table */
.payout-table {
  margin-bottom: 18px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,215,0,.1);
  border-radius: 12px;
  padding: 12px 14px;
}

.pt-title {
  font-size: 10px; font-weight: 800; letter-spacing: 2px;
  color: var(--muted); text-align: center; margin-bottom: 8px;
}

.pt-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); padding: 3px 0;
}

.pt-mult { color: var(--gold); font-weight: 800; font-size: 14px; }

/* ══════════════ BET CONTROLS ══════════════ */
.bet-controls { margin-bottom: 14px; }

.bet-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}

.bet-adj {
  width: 44px; height: 44px; flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: rgba(255,215,0,.08);
  color: var(--gold);
  font-size: 22px; font-weight: 700;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.bet-adj:hover { background: rgba(255,215,0,.18); border-color: var(--gold-dim); }
.bet-adj:active { transform: scale(.9); }

.bet-input {
  flex: 1; height: 44px;
  background: rgba(255,255,255,.04);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text); font-family: inherit;
  font-size: 20px; font-weight: 900;
  text-align: center; outline: none;
  transition: border-color .2s;
}
.bet-input:focus { border-color: var(--gold-dim); }
.bet-input::-webkit-inner-spin-button,
.bet-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.bet-presets { display: flex; gap: 8px; }
.bet-presets button {
  flex: 1; padding: 8px 4px;
  border: 1px solid rgba(255,215,0,.15);
  border-radius: 8px;
  background: rgba(255,215,0,.04);
  color: var(--gold-dim);
  font-family: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.bet-presets button:hover {
  background: rgba(255,215,0,.14);
  color: var(--gold);
  border-color: var(--gold-dim);
}

/* ══════════════ PLAY BUTTON ══════════════ */
.play-btn {
  width: 100%; padding: 16px;
  background: linear-gradient(135deg, #b8860b 0%, #ffd700 50%, #b8860b 100%);
  background-size: 200% 100%;
  border: none; border-radius: 14px;
  color: #1a0f00;
  font-family: inherit; font-size: 15px; font-weight: 900;
  letter-spacing: 2.5px; text-transform: uppercase;
  cursor: pointer; transition: all .3s;
  box-shadow: 0 4px 24px rgba(255,215,0,.4), inset 0 1px 0 rgba(255,255,255,.3);
  position: relative; overflow: hidden;
  margin-bottom: 14px;
}
.play-btn:hover:not(:disabled) {
  background-position: 100% 0;
  box-shadow: 0 6px 32px rgba(255,215,0,.6), inset 0 1px 0 rgba(255,255,255,.3);
  transform: translateY(-1px);
}
.play-btn:active:not(:disabled) { transform: scale(.97) translateY(0); }
.play-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* shimmer on hover */
.play-btn::after {
  content: '';
  position: absolute; top: 0; left: -80%;
  width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.25), transparent);
  transform: skewX(-20deg);
  transition: left .6s;
}
.play-btn:hover:not(:disabled)::after { left: 130%; }

/* ══════════════ RESULT BOX ══════════════ */
.result-box {
  min-height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 15px; font-weight: 700; text-align: center;
  padding: 10px;
  transition: all .3s;
}
.result-box.win {
  background: rgba(46,204,113,.12);
  border: 1px solid rgba(46,204,113,.4);
  color: var(--win-c);
  animation: popIn .4s ease;
}
.result-box.lose {
  background: rgba(231,76,60,.08);
  border: 1px solid rgba(231,76,60,.25);
  color: var(--lose-c);
  animation: popIn .4s ease;
}

/* ══════════════ COIN ══════════════ */
.coin-arena {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  margin-bottom: 18px;
}

.coin-scene {
  width: 120px; height: 120px;
  perspective: 600px;
  display: flex; align-items: center; justify-content: center;
}

.coin {
  width: 110px; height: 110px;
  position: relative;
  transform-style: preserve-3d;
}

.coin-face {
  position: absolute; inset: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 900;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 4px solid;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

.coin-front {
  background: radial-gradient(circle at 38% 32%, #ffe780, #c8900a);
  border-color: rgba(255,231,128,.6);
  color: rgba(0,0,0,.35);
  box-shadow: 0 0 28px rgba(255,215,0,.45);
}

.coin-back {
  background: radial-gradient(circle at 38% 32%, #c8c8c8, #666);
  border-color: rgba(200,200,200,.5);
  color: rgba(0,0,0,.35);
  transform: rotateY(180deg);
}

.coin-payout-info { font-size: 13px; color: var(--muted); }

/* Coin state helpers (set via JS style.transform) */

.choice-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}

.choice-btn {
  flex: 1; padding: 16px 10px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-family: inherit; font-size: 22px;
  cursor: pointer; transition: all .3s;
  text-align: center;
  line-height: 1.3;
}
.choice-btn span { display: block; font-size: 11px; font-weight: 800; letter-spacing: 1px; margin-top: 4px; }

.choice-btn.active {
  border-color: var(--gold);
  background: rgba(255,215,0,.1);
  color: var(--gold);
  box-shadow: var(--glow);
}

.choice-vs {
  font-size: 12px; font-weight: 800; color: var(--muted);
  letter-spacing: 1px;
}

/* ══════════════ ROULETTE ══════════════ */
.roulette-arena {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px; padding: 10px;
}

.roulette-ring {
  width: 130px; height: 130px;
  border-radius: 50%;
  background: conic-gradient(
    #c0392b 0% 48.65%,
    #1a1a1a 48.65% 97.3%,
    #1e8449 97.3% 100%
  );
  padding: 6px;
  box-shadow: 0 0 30px rgba(0,0,0,.6), 0 0 0 2px rgba(255,215,0,.2);
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}

.roulette-ring.spinning { animation: rouletteSpin 2s cubic-bezier(.1,.6,.1,1); }

.roulette-ball {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: #0e1128;
  border: 3px solid rgba(255,215,0,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 900;
  color: var(--gold);
  box-shadow: inset 0 4px 14px rgba(0,0,0,.5);
  transition: background .5s, box-shadow .5s, color .5s;
}

.roulette-ball.r-red {
  background: radial-gradient(circle at 35% 35%, #ff6b6b, #c0392b);
  color: #fff; border-color: rgba(231,76,60,.6);
  box-shadow: 0 0 28px rgba(231,76,60,.5);
}
.roulette-ball.r-black {
  background: radial-gradient(circle at 35% 35%, #444, #111);
  color: #fff; border-color: rgba(255,255,255,.15);
  box-shadow: 0 0 18px rgba(0,0,0,.8);
}
.roulette-ball.r-green {
  background: radial-gradient(circle at 35% 35%, #5dda80, #1e8449);
  color: #fff; border-color: rgba(93,218,128,.6);
  box-shadow: 0 0 28px rgba(39,174,96,.55);
}

/* color choice buttons */
.color-choices {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 18px;
}

.color-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .3s;
}

.c-dot { font-size: 18px; flex-shrink: 0; }
.c-name { flex: 1; text-align: left; }
.c-mult {
  background: rgba(255,215,0,.12);
  color: var(--gold); font-weight: 800;
  padding: 2px 10px; border-radius: 20px; font-size: 12px;
}

.color-btn.c-red.active  { border-color: #e74c3c; background: rgba(231,76,60,.12); color: #ff7070; box-shadow: 0 0 18px rgba(231,76,60,.25); }
.color-btn.c-green.active{ border-color: #27ae60; background: rgba(39,174,96,.12); color: #5dda80; box-shadow: 0 0 18px rgba(39,174,96,.25); }
.color-btn.c-black.active{ border-color: #888; background: rgba(255,255,255,.08); color: var(--text); box-shadow: 0 0 14px rgba(255,255,255,.08); }
.color-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,.06); }

/* ══════════════ WIN OVERLAY ══════════════ */
.win-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  animation: fadeIn .3s ease;
  cursor: pointer;
}
.win-overlay.hidden { display: none; }

.win-box {
  text-align: center; position: relative;
  animation: winPop .55s cubic-bezier(.36,.07,.19,.97);
}

.win-stars {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 60px; pointer-events: none;
}

.win-trophy { font-size: 80px; line-height: 1; filter: drop-shadow(0 0 24px rgba(255,215,0,.8)); }

.win-label {
  font-size: 13px; font-weight: 800; letter-spacing: 3px;
  color: var(--muted); margin-top: 6px;
}

.win-amount {
  font-size: 60px; font-weight: 900; line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255,215,0,.9);
}

.win-currency { font-size: 22px; color: var(--text); margin-top: 2px; }

.win-tap { font-size: 12px; color: var(--muted); margin-top: 16px; }

/* ══════════════ TOAST ══════════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #1e2248;
  border: 1px solid rgba(255,215,0,.2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px; font-weight: 600;
  z-index: 300;
  max-width: 80%; text-align: center;
  animation: slideUp .3s ease;
  white-space: nowrap;
}
.toast.hidden { display: none; }

/* ══════════════ KEYFRAMES ══════════════ */
@keyframes reelBlur {
  0%   { transform: translateY(0);    filter: blur(0px); }
  50%  { transform: translateY(-12px); filter: blur(1.5px); }
  100% { transform: translateY(0);    filter: blur(0px); }
}

@keyframes reelLand {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.18) rotate(-1deg); }
  60%  { transform: scale(.94); }
  80%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes rouletteSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(1440deg); }
}

@keyframes balancePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); color: var(--win-c); text-shadow: 0 0 24px rgba(46,204,113,.7); }
  100% { transform: scale(1); color: var(--gold); }
}

@keyframes popIn {
  from { transform: scale(.8); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

@keyframes winPop {
  from { transform: scale(.2) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(2deg); }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}

@keyframes cardIn {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes starBurst {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(3); opacity: 0; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }
