:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface2: #1f1f23;
  --border: #2d2d35;
  --accent: #9147ff;
  --accent-hover: #772ce8;
  --text: #efeff1;
  --text-muted: #adadb8;
  --win: #00c853;
  --lose: #ff4444;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 800px; margin: 0 auto; padding: 0 1rem; }

/* Nav */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
nav .brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
nav .nav-links { display: flex; gap: 1rem; flex: 1; }
nav .balance-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.3s, border-color 0.3s;
}
nav .balance-chip.flash-win {
  color: var(--win);
  border-color: var(--win);
}
nav button.logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}
nav button.logout:hover { border-color: var(--lose); color: var(--lose); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* Buttons */
button.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
}
button.btn:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(145,71,255,0.4); }
button.btn:active:not(:disabled) { transform: scale(0.95); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
button.btn.secondary:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(145,71,255,0.2); }

/* Inputs */
input[type="number"], input[type="text"], select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }

label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--text-muted); }
.field { margin-bottom: 1rem; }

/* Result banner */
.result {
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  text-align: center;
  font-weight: 600;
  font-size: 1.1rem;
  display: none;
}
.result.win {
  background: rgba(0,200,83,0.15);
  border: 1px solid var(--win);
  color: var(--win);
  animation: winPulse 0.45s cubic-bezier(0.2,0,0,1.6) both;
}
.result.lose {
  background: rgba(255,68,68,0.12);
  border: 1px solid var(--lose);
  color: var(--lose);
  animation: loseShake 0.45s ease both;
}
.result.push {
  background: rgba(173,173,184,0.12);
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  animation: winPulse 0.35s ease both;
}

/* Game grid on dashboard */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  animation: cardEntrance 0.4s ease forwards;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.12s; }
.game-card:nth-child(3) { animation-delay: 0.19s; }
.game-card:nth-child(4) { animation-delay: 0.26s; }
.game-card:nth-child(5) { animation-delay: 0.33s; }
.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-5px);
  box-shadow: 0 8px 28px rgba(145,71,255,0.25);
}
.game-card .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
  transition: transform 0.2s;
}
.game-card:hover .icon { transform: scale(1.15); }
.game-card h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.game-card p { font-size: 0.8rem; color: var(--text-muted); }

/* Hero on index */
.hero { text-align: center; padding: 5rem 1rem 3rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.75rem; }
.hero p { color: var(--text-muted); margin-bottom: 2rem; font-size: 1.05rem; }

/* History table */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; }
td.win { color: var(--win); }
td.lose { color: var(--lose); }

/* Slots reels */
.reels {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem 0;
}
.reel {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  transition: filter 0.15s, border-color 0.3s, box-shadow 0.3s, transform 0.15s;
}
.reel.spinning {
  filter: blur(1.5px) brightness(0.75);
}
.reel.win-reel {
  border-color: #ffd700;
  box-shadow: 0 0 18px rgba(255,215,0,0.5);
  animation: reelWin 0.6s ease infinite alternate;
}
.reel.stop-bounce {
  animation: reelStop 0.22s ease both;
}

/* Coin display */
#coinDisplay {
  display: inline-block;
  width: 100%;
  text-align: center;
  font-size: 4rem;
  margin: 1rem 0;
}
#coinDisplay.coin-flipping {
  animation: coinFlip 0.55s ease-in-out infinite;
}

/* Roulette wheel display */
.roulette-result-num {
  font-size: 4rem;
  font-weight: 900;
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  transition: color 0.2s, text-shadow 0.2s;
}
.roulette-result-num.red { color: #ff4444; text-shadow: 0 0 20px rgba(255,68,68,0.4); }
.roulette-result-num.black { color: var(--text); }
.roulette-result-num.green { color: var(--win); text-shadow: 0 0 20px rgba(0,200,83,0.4); }
.roulette-result-num.cycling { filter: blur(1px); opacity: 0.85; }
.roulette-result-num.landed {
  animation: winPulse 0.5s cubic-bezier(0.2,0,0,1.5) both;
}

/* Blackjack hand */
.hand { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.5rem 0; min-height: 44px; }
.playing-card {
  background: #fff;
  color: #111;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  animation: cardDeal 0.22s ease both;
}
.playing-card.red { color: #cc0000; }
.bj-score { font-size: 0.85rem; color: var(--text-muted); margin-left: 0.5rem; }

/* Bet quick-pick buttons */
.quick-bets { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.quick-bets button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.08s;
}
.quick-bets button:hover { border-color: var(--accent); }
.quick-bets button:active { transform: scale(0.94); }
.quick-bets button.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(145,71,255,0.12);
}

.mt1 { margin-top: 1rem; }
.flex-gap { display: flex; gap: 0.75rem; }
.loading { color: var(--text-muted); font-style: italic; }

/* ── Keyframe Animations ── */

@keyframes winPulse {
  0%   { transform: scale(0.92); opacity: 0; }
  70%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

@keyframes loseShake {
  0%   { transform: translateX(0); }
  18%  { transform: translateX(-7px); }
  36%  { transform: translateX(7px); }
  54%  { transform: translateX(-5px); }
  72%  { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

@keyframes coinFlip {
  0%   { transform: scaleX(1) scale(1); }
  12%  { transform: scaleX(0.08) scale(1.12); }
  25%  { transform: scaleX(1) scale(1); }
  37%  { transform: scaleX(0.08) scale(1.12); }
  50%  { transform: scaleX(1) scale(1); }
  62%  { transform: scaleX(0.08) scale(1.12); }
  75%  { transform: scaleX(1) scale(1); }
  87%  { transform: scaleX(0.08) scale(1.12); }
  100% { transform: scaleX(1) scale(1); }
}

@keyframes cardDeal {
  from { opacity: 0; transform: translateY(-18px) scale(0.88) rotate(-4deg); }
  to   { opacity: 1; transform: translateY(0)     scale(1)    rotate(0); }
}

@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes reelWin {
  from { border-color: #ffd700; box-shadow: 0 0 10px rgba(255,215,0,0.35); }
  to   { border-color: #ffaa00; box-shadow: 0 0 24px rgba(255,170,0,0.65); }
}

@keyframes reelStop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes particle {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--pdx), var(--pdy)) scale(0); opacity: 0; }
}
