:root {
  --bg-0: #07041a;
  --bg-1: #110735;
  --bg-2: #1a0a4a;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f3eefe;
  --text-dim: #b9b0d8;
  --text-mute: #7a72a0;
  --accent: #ffd166;
  --accent-2: #ff5ec1;
  --accent-3: #5eead4;
  --danger: #ff5c75;
  --success: #4ade80;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-soft: 0 8px 30px -10px rgba(255, 94, 193, 0.25), 0 4px 20px -8px rgba(0,0,0,0.6);
  --shadow-strong: 0 20px 60px -20px rgba(94, 234, 212, 0.4);
  --font-display: "Segoe UI", "Inter", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-display);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 94, 193, 0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(94, 234, 212, 0.12), transparent 60%),
    radial-gradient(1000px 800px at 50% 110%, rgba(124, 92, 255, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, var(--bg-0));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ========== HEADER ========== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(7,4,26,0.85), rgba(7,4,26,0.5));
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
.app-header .row {
  display: flex; align-items: center; gap: 16px;
  max-width: 1400px; margin: 0 auto;
  flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 0.5px;
  font-size: 20px;
}
.brand .logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 20px;
  box-shadow: 0 6px 20px -6px var(--accent-2);
}
.brand .name {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.spacer { flex: 1; }

.balance {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  transition: transform 0.4s, color 0.4s;
}
.balance.up { color: var(--success); transform: scale(1.06); }
.balance.down { color: var(--danger); transform: scale(0.96); }
.balance .coin { font-size: 18px; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.icon-btn:hover { background: var(--surface-2); border-color: rgba(255,255,255,0.25); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #1a0420;
}
.icon-btn.primary:hover { filter: brightness(1.08); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== LEVEL BAR ========== */
.level-bar {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.level-bar .bar {
  width: 110px; height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.level-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-3), var(--accent));
  transition: width 0.4s;
}

/* ========== LOBBY ========== */
.lobby {
  max-width: 1400px; margin: 0 auto; padding: 24px 20px 80px;
  width: 100%;
  flex: 1;
  animation: fadeUp 0.4s ease-out;
}
.hero {
  border-radius: var(--radius-lg);
  padding: 28px;
  background:
    radial-gradient(600px 200px at 80% 0%, rgba(255, 94, 193, 0.25), transparent 60%),
    radial-gradient(500px 200px at 0% 100%, rgba(94, 234, 212, 0.18), transparent 60%),
    linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  margin-bottom: 24px;
  display: grid; gap: 16px;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.1;
}
.hero p { margin: 0; color: var(--text-dim); max-width: 60ch; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; padding: 20px; }
}

.section-title {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--text-mute);
  margin: 28px 0 12px;
}
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* Stats */
.stats-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 8px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 1px; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.stat .value.gold { color: var(--accent); }
.stat .value.green { color: var(--success); }
.stat .value.red { color: var(--danger); }

/* Filters */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 18px;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  transition: all 0.2s;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #1a0420; border-color: transparent;
}

/* Slot cards */
.slot-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.slot-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 240px;
}
.slot-card::before {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(135deg, var(--c1, #220a4a), var(--c2, #0a0220));
  opacity: 0.55;
  transition: opacity 0.25s;
}
.slot-card::after {
  content: "";
  position: absolute; top: -40%; right: -20%;
  width: 160px; height: 160px;
  background: radial-gradient(circle, var(--accent, #fff), transparent 70%);
  filter: blur(20px); opacity: 0.4;
  pointer-events: none;
}
.slot-card > * { position: relative; z-index: 1; }
.slot-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.3);
  box-shadow: var(--shadow-soft);
}
.slot-card:hover::before { opacity: 0.75; }

.slot-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.slot-card .tag {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px;
  padding: 4px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.4);
  color: var(--accent-glow, var(--accent));
  border: 1px solid rgba(255,255,255,0.18);
}
.slot-card h3 { margin: 0; font-size: 20px; line-height: 1.2; }
.slot-card .theme { color: var(--text-dim); font-size: 13px; }
.slot-card .meta {
  display: flex; gap: 12px; font-size: 12px; color: var(--text-dim);
  flex-wrap: wrap;
}
.slot-card .meta span strong { color: var(--text); }
.slot-card .jackpot {
  font-size: 12px; color: var(--accent);
  display: flex; align-items: center; gap: 6px;
}
.slot-card .play-btn {
  margin-top: auto;
  align-self: stretch;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0420; border: none;
  padding: 12px; border-radius: 12px;
  font-weight: 800; letter-spacing: 0.5px;
  font-size: 14px;
  transition: transform 0.15s, filter 0.2s;
}
.slot-card .play-btn:hover { filter: brightness(1.1); }
.slot-card .play-btn:active { transform: scale(0.96); }
.vol {
  display: inline-flex; gap: 2px; align-items: center;
}
.vol i {
  width: 6px; height: 8px; background: var(--text-mute); border-radius: 1px; display: inline-block;
}
.vol i.on { background: var(--accent); }

/* ========== SLOT VIEW ========== */
.slot-view {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  animation: fadeUp 0.35s ease-out;
  position: relative;
  --c1: #220a4a; --c2: #0a0220;
}
.slot-view::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(800px 500px at 50% 0%, var(--c-accent, rgba(255, 209, 102, 0.15)), transparent 60%),
    linear-gradient(180deg, var(--c1), var(--c2));
}
.slot-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  background: rgba(0,0,0,0.25);
}
.slot-toolbar h2 { margin: 0; font-size: 18px; }
.slot-toolbar .desc { color: var(--text-dim); font-size: 13px; }

.slot-stage {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  max-width: 1400px; margin: 0 auto;
  padding: 20px;
  width: 100%;
}
@media (max-width: 960px) {
  .slot-stage { grid-template-columns: 1fr; }
}

.machine {
  border-radius: var(--radius-lg);
  background:
    radial-gradient(400px 200px at 50% 0%, rgba(255,255,255,0.06), transparent 60%),
    rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

.reels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  overflow: hidden;
  aspect-ratio: 5 / 3;
  position: relative;
}
.reel {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.4));
  border: 1px solid rgba(255,255,255,0.06);
}
.reel-strip {
  display: flex; flex-direction: column;
  will-change: transform;
}
.reel-cell {
  flex: 1 0 33.333%;
  display: grid; place-items: center;
  font-size: clamp(28px, 6vw, 56px);
  border-bottom: 1px dashed rgba(255,255,255,0.06);
  transition: filter 0.2s;
  user-select: none;
}
.reel-cell:last-child { border-bottom: none; }
.reel-cell.win {
  animation: winPulse 0.7s ease-out infinite alternate;
  filter: drop-shadow(0 0 12px var(--accent));
}
@keyframes winPulse {
  to { transform: scale(1.15); filter: drop-shadow(0 0 24px var(--accent)); }
}
.reel.spinning .reel-strip {
  animation: reelSpin 0.35s linear infinite;
}
@keyframes reelSpin {
  from { transform: translateY(0); }
  to { transform: translateY(-33.333%); }
}

.win-banner {
  text-align: center;
  min-height: 56px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--border);
  font-weight: 700;
  position: relative; overflow: hidden;
}
.win-banner.win { color: var(--success); animation: bannerFlash 0.4s ease-out; }
.win-banner.big {
  color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.15), rgba(255, 94, 193, 0.15));
  animation: bannerFlash 0.5s ease-out, glow 1.4s ease-in-out infinite alternate;
}
.win-banner.jackpot {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
  animation: jackpotPulse 0.5s ease-out infinite alternate;
  font-size: 18px;
}
@keyframes bannerFlash { from { transform: scale(0.9); opacity: 0; } }
@keyframes glow { to { box-shadow: 0 0 30px rgba(255, 209, 102, 0.4); } }
@keyframes jackpotPulse { to { transform: scale(1.04); filter: brightness(1.15); } }

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
}
@media (max-width: 600px) {
  .controls { grid-template-columns: 1fr; }
}
.bet-selector {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
}
.bet-selector .bet {
  background: transparent; border: none; color: var(--text-dim);
  padding: 8px 10px; border-radius: 8px;
  font-weight: 700; font-size: 13px;
  transition: all 0.15s;
}
.bet-selector .bet.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #1a0420;
}
.bet-selector .bet:hover:not(.active) { color: var(--text); }

.spin-btn {
  position: relative;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0420;
  border: none;
  padding: 14px 28px;
  border-radius: 14px;
  font-weight: 900; font-size: 16px; letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 8px 24px -8px var(--accent-2);
  transition: transform 0.12s, filter 0.2s;
  min-width: 120px;
}
.spin-btn:hover { filter: brightness(1.08); }
.spin-btn:active { transform: scale(0.93); }
.spin-btn.shake { animation: shake 0.3s ease-in-out; }
.spin-btn:disabled { opacity: 0.6; cursor: not-allowed; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-3px); }
  40%,80% { transform: translateX(3px); }
}

.auto-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 700;
  transition: all 0.2s;
}
.auto-btn:hover { background: var(--surface-2); }
.auto-btn.active { background: var(--danger); border-color: transparent; }

/* Right sidebar */
.side {
  display: flex; flex-direction: column; gap: 14px;
}
.panel {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.panel h4 {
  margin: 0 0 10px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-mute);
}
.paytable {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  font-size: 12px;
}
.paytable .row {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.03);
  padding: 6px 8px; border-radius: 8px;
}
.paytable .row .e { font-size: 18px; }
.paytable .row .p { color: var(--text-dim); margin-left: auto; }

.history-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; max-height: 320px; overflow-y: auto; }
.history-list .item {
  display: flex; justify-content: space-between;
  padding: 6px 8px; border-radius: 8px;
  background: rgba(255,255,255,0.03);
}
.history-list .item .w { color: var(--success); font-weight: 700; }
.history-list .item .w.zero { color: var(--text-mute); }

/* ========== MODAL ========== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s;
}
.modal {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 520px; width: 100%;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6);
  animation: modalIn 0.3s cubic-bezier(.2,.9,.2,1.2);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 10px; }
.modal p { color: var(--text-dim); line-height: 1.5; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal .btn {
  padding: 10px 18px; border-radius: 10px; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: all 0.2s;
}
.modal .btn:hover { background: var(--surface-2); }
.modal .btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1a0420; border: none; }
.modal .btn.danger { background: var(--danger); border: none; color: white; }

.missions { display: flex; flex-direction: column; gap: 10px; }
.mission {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.mission .top { display: flex; justify-content: space-between; align-items: center; }
.mission .label { font-weight: 700; }
.mission .reward { color: var(--accent); font-size: 13px; }
.mission .bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; margin: 8px 0; }
.mission .bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent-3), var(--accent)); transition: width 0.4s; }
.mission .claim {
  background: var(--success); color: #042; border: none;
  padding: 6px 12px; border-radius: 8px; font-weight: 700;
}
.mission .claim:disabled { background: rgba(255,255,255,0.1); color: var(--text-mute); cursor: not-allowed; }

/* Footer */
.footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-mute);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}
.footer a { color: var(--text-dim); cursor: pointer; text-decoration: underline; }

/* ========== TOAST ========== */
.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200; pointer-events: none;
}
.toast {
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  animation: toastIn 0.3s, toastOut 0.3s 2.4s forwards;
  box-shadow: var(--shadow-soft);
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.gold { border-color: var(--accent); color: var(--accent); }

/* ========== CONFETTI ========== */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti {
  position: absolute; top: -20px;
  width: 10px; height: 14px;
  animation: fall linear forwards;
  border-radius: 2px;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20px); } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Small screens */
@media (max-width: 480px) {
  .app-header { padding: 12px 14px; }
  .app-header .row { gap: 8px; }
  .brand { font-size: 16px; }
  .brand .logo { width: 32px; height: 32px; font-size: 18px; }
  .level-bar .bar { width: 60px; }
  .lobby { padding: 16px 12px 60px; }
  .slot-stage { padding: 12px; gap: 12px; }
  .machine { padding: 12px; }
  .icon-btn { padding: 6px 10px; font-size: 12px; }
}
