:root {
  --bg: #0b0812;
  --bg2: #140e20;
  --card: #1a1229;
  --card2: #22183a;
  --line: rgba(190, 120, 255, .18);
  --text: #f4eefe;
  --muted: #a99bc2;
  --accent: #c24bff;
  --accent2: #ff4fa3;
  --gold: #ffc94a;
  --ok: #42d392;
  --r-common: #8fa3c7;
  --r-rare: #4fa3ff;
  --r-epic: #c24bff;
  --r-legend: #ffc94a;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(194, 75, 255, .25), transparent 60%),
    radial-gradient(80% 40% at 100% 30%, rgba(255, 79, 163, .10), transparent 60%),
    var(--bg);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#app { max-width: 520px; margin: 0 auto; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 12px; }
.brand-model { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.brand h1 { margin: 2px 0 0; font-size: 22px; line-height: 1.15; }
.balance {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(194, 75, 255, .25), rgba(255, 79, 163, .2));
  border: 1px solid var(--line); font-weight: 800; font-size: 17px; white-space: nowrap;
}
.balance.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* reel */
.reel-wrap { position: relative; margin: 8px -16px 0; padding: 14px 0; }
.reel-window {
  overflow: hidden; position: relative;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.reel { display: flex; gap: 10px; padding: 6px 0; will-change: transform; }
.reel-pointer {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; transform: translateX(-50%); z-index: 3;
  background: linear-gradient(var(--accent2), var(--accent)); border-radius: 3px;
  box-shadow: 0 0 14px var(--accent2);
}
.reel-pointer::before {
  content: ""; position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  border: 9px solid transparent; border-top-color: var(--accent2);
}

.pcard {
  flex: 0 0 auto; width: 112px; border-radius: 14px; padding: 8px; text-align: center;
  background: var(--card); border: 1.5px solid var(--rc, var(--line));
  box-shadow: inset 0 -30px 40px -30px var(--rc, transparent);
  position: relative;
}
.pcard .thumb {
  height: 92px; border-radius: 10px; overflow: hidden; background: var(--card2);
  display: grid; place-items: center; font-size: 36px; position: relative;
}
.pcard .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .thumb img.blur { filter: blur(9px) saturate(1.2); transform: scale(1.15); }
.pcard .thumb .lock { position: absolute; font-size: 22px; text-shadow: 0 2px 8px #000; }
.pcard .t { font-weight: 700; font-size: 12.5px; margin-top: 7px; min-height: 2.6em; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .r { font-size: 11px; color: var(--rc, var(--muted)); margin-top: 2px; font-weight: 600; }
.pcard .c { font-size: 11px; color: var(--muted); }
.pcard.win-pick { transform: scale(1.06); box-shadow: 0 0 26px var(--rc); transition: .3s; }

.rc-common { --rc: var(--r-common); }
.rc-rare { --rc: var(--r-rare); }
.rc-epic { --rc: var(--r-epic); }
.rc-legend { --rc: var(--r-legend); }

/* buttons */
.cta {
  display: block; width: 100%; padding: 16px; border-radius: var(--radius); font-weight: 800; font-size: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  box-shadow: 0 10px 30px -10px rgba(194, 75, 255, .8);
  transition: transform .1s, opacity .2s;
}
.cta:active { transform: scale(.98); }
.cta:disabled { opacity: .55; }
.ghost {
  padding: 12px 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); font-weight: 600;
}
.ghost.wide { width: 100%; margin-top: 8px; }
.hint { text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.sect { font-size: 16px; margin: 26px 0 12px; }
.sect.first { margin-top: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.grid .pcard { width: auto; }
.empty { text-align: center; color: var(--muted); padding: 14px; }

/* packs */
.packs { display: grid; gap: 10px; }
.pack {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); text-align: left; width: 100%;
}
.pack.best { border-color: var(--gold); background: linear-gradient(135deg, rgba(255, 201, 74, .12), var(--card)); }
.pack .n { font-size: 18px; font-weight: 800; }
.pack .per { font-size: 12px; color: var(--muted); }
.pack .price { font-weight: 800; font-size: 17px; padding: 9px 14px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); white-space: nowrap; }
.pack .tag { font-size: 11px; color: var(--gold); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.ref-card { margin-top: 22px; }
.ref-title { font-weight: 800; }
.ref-row { display: flex; gap: 8px; }
.ref-row .ghost { flex: 1; }

/* profile */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11.5px; color: var(--muted); }
.list { display: grid; gap: 8px; }
.row { display: flex; justify-content: space-between; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.claim { margin-top: 6px; width: 100%; padding: 6px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: var(--accent); color: #fff; }

/* nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11, 8, 18, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px;
  background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); }
.nav-btn span { font-size: 19px; }
.nav-btn.active { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* modals */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 3, 10, .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal { width: 100%; max-width: 360px; background: var(--bg2); border: 1px solid var(--line); border-radius: 22px;
  padding: 24px 20px 20px; text-align: center; position: relative; overflow: hidden; animation: pop .35s ease; }
.modal h3 { margin: 6px 0 6px; font-size: 21px; }
.modal .cta { margin-top: 16px; }
.modal-ico { font-size: 44px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.win-label { font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); position: relative; }
.win-card { display: flex; justify-content: center; margin: 14px 0 6px; position: relative; }
.win-card .pcard { width: 170px; }
.win-card .pcard .thumb { height: 150px; font-size: 56px; }
.modal.win > :not(.win-burst) { position: relative; z-index: 1; }
.win-burst { position: absolute; inset: -40%; z-index: 0; pointer-events: none; background: conic-gradient(from 0deg, transparent, rgba(194, 75, 255, .35),
  transparent 30%, rgba(255, 79, 163, .3), transparent 60%, rgba(255, 201, 74, .3), transparent 85%);
  animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 488px; margin: 0 auto; padding: 12px 14px; border-radius: 12px; background: #2b1f45;
  border: 1px solid var(--line); text-align: center; font-weight: 600; animation: pop .25s ease; }
