:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2540;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef2fa;
  --muted: #8a97b2;
  --gold: #e9b44c;
  --gold-soft: rgba(233, 180, 76, 0.35);
  --accent: #6aa8ff;
  --accent-2: #3c7be0;
  --common: #8c9bb8;
  --rare: #49c6f2;
  --mythic: #b27dff;
  --legendary: #ff9f45;
  --radius: 16px;
  --card-h: 104px;
  --card-gap: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Profile */
.profile {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: linear-gradient(135deg, #ff7aa8, #8a5cff);
}
.profile-text { flex: 1; min-width: 0; }
.profile-name { font-weight: 650; }
.profile-sub { color: var(--muted); font-size: 12px; }
.profile-count { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { height: 4px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin-top: -4px; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .6s; }

/* Daily spin */
.daily {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 12px; border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(233, 180, 76, .16), rgba(233, 180, 76, .04));
  border: 1px solid var(--gold-soft);
}
.daily:disabled { opacity: .55; cursor: default; }
.daily-icon {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: #2a1d00; font-size: 16px;
}
.daily-text { flex: 1; display: flex; flex-direction: column; }
.daily-title { font-weight: 650; }
.daily-sub { font-size: 12px; color: var(--muted); }
.chev { color: var(--muted); font-size: 22px; }

/* Reel machine */
.machine {
  position: relative;
  border-radius: 22px;
  padding: 18px 12px 12px;
  background: linear-gradient(180deg, #1b1407, #0c0a06);
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(233, 180, 76, .12), 0 12px 40px rgba(0, 0, 0, .5);
}
.bulbs {
  position: absolute; left: 22px; right: 22px; top: 6px;
  display: flex; justify-content: space-between;
}
.bulb { width: 6px; height: 6px; border-radius: 50%; background: #fff3d1; box-shadow: 0 0 6px #ffd27a; opacity: .35; }
.machine.spinning .bulb { animation: blink .5s infinite alternate; }
.bulb:nth-child(even) { animation-delay: .25s !important; }
@keyframes blink { to { opacity: 1; } }

.window {
  position: relative;
  height: calc(var(--card-h) * 3 + var(--card-gap) * 2);
  overflow: hidden;
  border-radius: 14px;
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
          mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}
.strip { display: flex; flex-direction: column; gap: var(--card-gap); will-change: transform; }
.pointer {
  position: absolute; top: 50%; width: 0; height: 0; transform: translateY(-50%);
  border-top: 9px solid transparent; border-bottom: 9px solid transparent; z-index: 2;
}
.pointer.left { left: 0; border-left: 10px solid var(--gold); }
.pointer.right { right: 0; border-right: 10px solid var(--gold); }

.card {
  position: relative; flex: 0 0 var(--card-h); border-radius: 12px; overflow: hidden;
  border: 2px solid var(--rc, var(--common));
  background: radial-gradient(circle at 30% 40%, color-mix(in srgb, var(--rc) 45%, #000), #0b0b10 75%);
  box-shadow: inset 0 0 24px color-mix(in srgb, var(--rc) 30%, transparent);
}
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(10px) saturate(1.2); transform: scale(1.15); opacity: .85; }
.card .lock {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .45); color: var(--gold); font-size: 14px;
}
.card.owned .lock { color: #7be39b; }
.card.win { box-shadow: 0 0 0 2px var(--rc), 0 0 28px var(--rc); animation: pop .5s; }
@keyframes pop { 40% { transform: scale(1.04); } }

.badge {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: var(--rc, var(--common)); color: #071019;
}
.card .badge { position: absolute; left: 8px; top: 8px; }
.r-common { --rc: var(--common); }
.r-rare { --rc: var(--rare); }
.r-mythic { --rc: var(--mythic); }
.r-legendary { --rc: var(--legendary); }

/* Odds */
.odds { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; font-size: 11px; color: var(--muted); }
.odds span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--rc); margin-right: 5px; }

.note { text-align: center; font-size: 13px; color: var(--gold); padding: 10px 12px; border-radius: 12px; background: rgba(233, 180, 76, .08); border: 1px solid var(--gold-soft); }

/* Packs + spin */
.packs {
  margin-top: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
}
.pack { padding: 9px 4px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.pack small { color: var(--gold); font-weight: 700; margin-left: 4px; }
.pack[aria-selected="true"] { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; }
.pack[aria-selected="true"] small { color: #ffe7b0; }
.pack:disabled { opacity: .3; cursor: default; }

.spin-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 20px; border-radius: 16px; font-weight: 700; font-size: 17px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(60, 123, 224, .35);
}
.spin-btn:disabled { opacity: .5; cursor: default; }
.star, .price .star { color: var(--gold); }

/* Reveal sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 10; background: rgba(3, 6, 12, .6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 94%; overflow: auto;
  background: var(--panel); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  animation: up .3s cubic-bezier(.2, .9, .3, 1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.grabber { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 4px; }
.reveal-card {
  position: relative; aspect-ratio: 4 / 5; max-height: 52vh; border-radius: 18px; overflow: hidden;
  border: 2px solid var(--rc); box-shadow: 0 0 30px color-mix(in srgb, var(--rc) 50%, transparent);
  background: #000; margin: 0 auto; width: 100%;
}
.reveal-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reveal-info {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 14px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .8));
}
.reveal-title { font-size: 22px; font-weight: 750; margin-top: 4px; }
.reveal-sub { font-size: 12px; color: #cfd6e6; }

.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.thumb {
  flex: 0 0 54px; height: 54px; border-radius: 10px; border: 2px solid var(--rc);
  overflow: hidden; opacity: .6; background: #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb[aria-current="true"] { opacity: 1; }

.status {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: 14px; background: var(--panel-2); font-weight: 600; font-size: 14px;
}
.status-icon { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--mythic); border-right-color: transparent; animation: spin .8s linear infinite; }
.status.done .status-icon { animation: none; border: 0; background: #2fb36a; }
.status.done .status-icon::after { content: "✓"; display: block; text-align: center; font-size: 12px; line-height: 18px; color: #fff; }
.status.error .status-icon { animation: none; border: 0; background: #e2524a; }
.link-btn { margin-left: auto; color: var(--accent); font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary-btn, .ghost-btn { padding: 13px; border-radius: 14px; font-weight: 700; }
.primary-btn { background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.ghost-btn { background: var(--panel-2); }

/* Gate */
.gate { position: fixed; inset: 0; z-index: 20; background: rgba(3, 6, 12, .92); display: grid; place-items: center; padding: 24px; }
.gate-box { max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.gate-title { font-size: 22px; font-weight: 800; }
.gate-box p { color: var(--muted); margin: 0 0 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 30; background: #2a3550; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); }
