:root {
  --bg: #0b0d14;
  --bg2: #121624;
  --card: #171c2d;
  --card2: #1e2438;
  --line: #2a3150;
  --text: #eef1ff;
  --muted: #8d95b5;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --good: #34d399;
  --bad: #fb7185;
  --common: #b4b4be;
  --rare: #50aaff;
  --epic: #be5aff;
  --legendary: #ffaa28;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { min-height: 100vh; overflow-x: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
.hidden { display: none !important; }

/* ---------- каркас */
#app { max-width: 560px; margin: 0 auto; padding: 0 14px calc(84px + var(--safe-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 10px; background: linear-gradient(var(--bg) 70%, transparent); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.logo { filter: drop-shadow(0 0 10px rgba(124, 92, 255, .8)); }
.wallet { background: var(--card); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-weight: 700; }
.event { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(90deg, rgba(124,92,255,.25), rgba(34,211,238,.18)); border: 1px solid rgba(124,92,255,.5); font-weight: 600; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 2px; padding: 6px 6px calc(6px + var(--safe-bottom)); background: rgba(11, 13, 20, .92); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; max-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 12px; color: var(--muted); font-size: 11px; }
.tabs button i { font-style: normal; font-size: 20px; }
.tabs button.active { color: var(--text); background: var(--card); }

h2 { font-size: 18px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 14px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; width: 100%; transition: transform .08s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--card2); border: 1px solid var(--line); }
.btn.gold { background: linear-gradient(135deg, #ffb340, #ff7a18); }
.btn.cyan { background: linear-gradient(135deg, #22d3ee, #6366f1); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--card2); border: 1px solid var(--line); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.chip.on { color: var(--text); border-color: var(--accent); background: rgba(124, 92, 255, .18); }

/* ---------- главная */
.hero { position: relative; overflow: hidden; background: radial-gradient(120% 120% at 100% 0%, rgba(124,92,255,.35), transparent 55%), radial-gradient(120% 120% at 0% 100%, rgba(34,211,238,.2), transparent 50%), var(--card); }
.hero .dev { display: flex; gap: 14px; align-items: center; }
.hero img { width: 84px; height: 84px; object-fit: cover; border-radius: 14px; border: 2px solid var(--line); background: #000; }
.big { font-size: 28px; font-weight: 800; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.bar { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; transition: width .6s; }
.ach { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ach div { background: var(--card2); border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 22px; opacity: .3; }
.ach div.done { opacity: 1; box-shadow: 0 0 0 1px rgba(255,170,40,.5) inset; }
.ach small { display: block; font-size: 10px; color: var(--muted); line-height: 1.2; margin-top: 2px; }
svg.chart { width: 100%; height: 120px; display: block; }

/* ---------- редкости */
.r-common { --rc: var(--common); } .r-rare { --rc: var(--rare); } .r-epic { --rc: var(--epic); } .r-legendary { --rc: var(--legendary); }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--rc); box-shadow: 0 0 14px var(--rc); }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #000; }
.tile .name { font-weight: 700; font-size: 13px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: 11px; color: var(--rc); }
.tile.locked img { filter: grayscale(1) brightness(.25); }
.tile.locked .name { color: var(--muted); }
.tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tile.sel { border-color: var(--good); box-shadow: 0 0 0 2px var(--good) inset; }
.badge { position: absolute; top: 6px; left: 6px; font-size: 10px; padding: 2px 6px; border-radius: 999px; background: rgba(0,0,0,.65); }

/* ---------- рулетка */
.roulette { position: relative; height: 150px; border-radius: 16px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); margin: 6px 0 12px; }
.roulette .track { position: absolute; top: 15px; left: 0; display: flex; gap: 8px; will-change: transform; }
.roulette .cell { width: 112px; height: 120px; flex: none; border-radius: 12px; background: var(--card); border-bottom: 3px solid var(--rc); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; }
.roulette .cell img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; }
.roulette .cell span { font-size: 11px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.roulette .marker { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px; background: var(--legendary); box-shadow: 0 0 16px var(--legendary); z-index: 2; }
.roulette::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg2), transparent 18%, transparent 82%, var(--bg2)); pointer-events: none; }
.chances { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.chances .tile .sub b { color: var(--text); }

/* ---------- окна */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom)); border-top: 1px solid var(--line); animation: up .25s; }
.win { text-align: center; }
.win img { width: 160px; height: 160px; object-fit: cover; border-radius: 20px; border: 3px solid var(--rc); box-shadow: 0 0 40px var(--rc); margin: 8px auto; display: block; animation: pop .5s; }
.win .t { font-size: 22px; font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translateX(-50%); z-index: 40; background: #222842; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; max-width: 90vw; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(40px); opacity: 0 } }
@keyframes pop { 0% { transform: scale(.3) rotate(-8deg); opacity: 0 } 70% { transform: scale(1.08) } }

/* ---------- списки */
.list .item { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.list .item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: #000; }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .item .act { flex: none; width: auto; padding: 8px 12px; }
.place { width: 30px; text-align: center; font-weight: 800; color: var(--muted); }
.me { border-color: var(--accent) !important; }
.lvl { display: grid; grid-template-columns: 38px 1fr 1fr; gap: 6px; align-items: stretch; margin-bottom: 6px; }
.lvl > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px; font-size: 12px; }
.lvl .n { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.lvl.reached .n { background: var(--accent); border-color: var(--accent); }
.lvl .prem { background: rgba(255,170,40,.08); border-color: rgba(255,170,40,.3); }
.lvl .claimed { opacity: .45; text-decoration: line-through; }
.slider { display: grid; grid-template-columns: 90px 1fr 48px; gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.slider input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
.dist { display: flex; gap: 2px; align-items: flex-end; height: 70px; margin-top: 8px; }
.dist div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.dist div.neg { background: var(--bad); }
.dist div span { position: absolute; bottom: -16px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.skeleton { height: 120px; border-radius: 16px; background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0 } }
