:root {
  --bg: #0b0b10;
  --bg-2: #14141c;
  --card: #1a1a24;
  --card-2: #22222e;
  --line: rgba(255, 255, 255, .07);
  --text: #f4f3fa;
  --muted: #9a98ab;
  --accent: #8b5cf6;
  --accent-2: #6d3df2;
  --gold: #ffc23d;
  --danger: #ff5a6a;
  --ok: #3ddc84;
  --r-common: #9aa3b2;
  --r-uncommon: #4cd07d;
  --r-rare: #4aa3ff;
  --r-epic: #b46bff;
  --r-legendary: #ffc23d;
  --radius: 22px;
  --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); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Inter, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(139, 92, 246, .35), transparent 60%),
    radial-gradient(80% 40% at 100% 0%, rgba(255, 140, 60, .18), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: inherit; }
img { display: block; }
.hidden { display: none !important; }

/* ---------- верхняя панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 8px;
  background: linear-gradient(to bottom, rgba(11, 11, 16, .92), rgba(11, 11, 16, .6) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .2px; margin-right: auto;
  background: linear-gradient(90deg, #fff, #c9b6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.balance {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px 0 8px; border-radius: 18px;
  background: rgba(139, 92, 246, .22); border: 1px solid rgba(139, 92, 246, .45);
  font-weight: 700;
}
.coin { width: 22px; height: 22px; flex: none; }
.coin.sm { width: 16px; height: 16px; }
.plus {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; box-shadow: 0 4px 16px rgba(109, 61, 242, .5);
}
.plus svg { width: 20px; height: 20px; }

/* ---------- лента выпадений ---------- */
.feed { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.feed-item {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line);
  animation: pop .35s ease;
}
.feed-item .thumb { width: 30px; height: 30px; border-radius: 10px; }
.feed-item b { display: block; font-size: 12px; font-weight: 600; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item small { color: var(--muted); font-size: 11px; }

/* ---------- общее ---------- */
.view { padding: 0 16px calc(110px + var(--safe-bottom)); }
.h2 { font-size: 24px; font-weight: 800; margin: 22px 0 4px; letter-spacing: -.2px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

.banner {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; margin-top: 10px; border-radius: 18px; text-align: left;
  background: linear-gradient(100deg, #7c3aed, #5b21b6 60%, #3b1a7a);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 8px 24px rgba(91, 33, 182, .35);
}
.banner.dark { background: var(--card); box-shadow: none; border-color: var(--line); }
.banner.green { background: linear-gradient(100deg, #0f5132, #136c43); }
.banner .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #ffd66b, #f59e0b); color: #6b3a00; }
.banner .ico svg { width: 26px; height: 26px; }
.banner b { display: block; font-size: 15px; }
.banner small { color: rgba(255, 255, 255, .75); font-size: 12px; }
.banner > svg { width: 20px; height: 20px; margin-left: auto; opacity: .8; flex: none; }

/* ---------- карточки кейсов ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.case-card {
  position: relative; overflow: hidden; border-radius: var(--radius);
  aspect-ratio: .78; padding: 12px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  border: 1px solid rgba(255, 255, 255, .1);
  transition: transform .15s ease;
}
.case-card:active { transform: scale(.97); }
.case-card .hero { position: absolute; inset: 10% 12% 34%; display: grid; place-items: center; }
.case-card .hero img, .case-card .hero .ph { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .45)); }
.case-card .title { position: relative; font-weight: 800; font-size: 15px; text-shadow: 0 1px 8px rgba(0, 0, 0, .4); margin-bottom: 8px; }
.price-pill {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px 6px 8px; border-radius: 16px; font-weight: 800;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(6px);
}
.case-card .tag { position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 10px; background: rgba(0, 0, 0, .4); }
.case-card.wide { grid-column: span 2; aspect-ratio: 1.75; }
.case-card.wide .hero { inset: 8% 30% 30%; }

.t-violet   { background: radial-gradient(90% 70% at 50% 35%, #a78bfa, #6d28d9 55%, #2e1065); }
.t-peach    { background: radial-gradient(90% 70% at 50% 35%, #ffd2c2, #f19a7c 55%, #8a3d2b); }
.t-silver   { background: radial-gradient(90% 70% at 50% 35%, #eef2f7, #a9b4c4 55%, #48526a); }
.t-amber    { background: radial-gradient(90% 70% at 50% 35%, #ffd28a, #f08a1c 55%, #7a3a05); }
.t-crimson  { background: radial-gradient(90% 70% at 50% 35%, #ff7a8a, #c0263d 55%, #4a0714); }
.t-teal     { background: radial-gradient(90% 70% at 50% 35%, #7ef0f5, #1ba7bd 55%, #08414d); }
.t-graphite { background: radial-gradient(90% 70% at 50% 35%, #8b8b99, #3b3b47 55%, #111116); }
.t-lime     { background: radial-gradient(90% 70% at 50% 35%, #c8f7a8, #55c25d 55%, #1a5523); }

/* ---------- страница кейса ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin: 6px 0 0; padding: 6px 0; }
.back svg { width: 18px; height: 18px; transform: rotate(180deg); }
.case-hero { border-radius: 28px; padding: 18px; margin-top: 8px; text-align: center; position: relative; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12); }
.case-hero .img { height: 190px; display: grid; place-items: center; }
.case-hero .img img, .case-hero .img .ph { max-height: 190px; max-width: 70%; object-fit: contain; filter: drop-shadow(0 16px 24px rgba(0, 0, 0, .5)); animation: float 4s ease-in-out infinite; }
.case-hero h1 { margin: 10px 0 4px; font-size: 26px; font-weight: 900; text-shadow: 0 2px 12px rgba(0, 0, 0, .35); }
.case-hero p { margin: 0; color: rgba(255, 255, 255, .85); font-size: 13px; }
.actions { display: grid; gap: 10px; margin-top: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; border-radius: 18px; font-weight: 800; font-size: 16px; width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(109, 61, 242, .45);
}
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--card-2); box-shadow: none; border: 1px solid var(--line); }
.btn.gold { background: linear-gradient(135deg, #ffd66b, #f59e0b); color: #3d2300; box-shadow: 0 8px 24px rgba(245, 158, 11, .35); }
.btn.sm { height: 42px; font-size: 14px; border-radius: 14px; }
.demo-badge { display: inline-block; font-size: 11px; font-weight: 900; letter-spacing: .5px; padding: 2px 7px; border-radius: 8px;
  background: #22c55e; color: #052e16; }
.note { margin: 12px 2px 0; color: var(--muted); font-size: 12px; }

.items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.item {
  position: relative; border-radius: 16px; padding: 8px 6px 9px; text-align: center; overflow: hidden;
  background: linear-gradient(to top, color-mix(in srgb, var(--rc) 22%, var(--card)), var(--card) 70%);
  border: 1px solid color-mix(in srgb, var(--rc) 45%, transparent);
}
.item::after { content: ""; position: absolute; left: 15%; right: 15%; bottom: 0; height: 3px; border-radius: 3px; background: var(--rc); }
.item .pic { aspect-ratio: 1; display: grid; place-items: center; }
.item .pic img, .item .pic .ph { width: 88%; height: 88%; object-fit: contain; }
.item .name { font-size: 11.5px; font-weight: 600; line-height: 1.2; height: 2.4em; overflow: hidden; margin-top: 4px; }
.item .val { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .chance { position: absolute; top: 6px; left: 6px; font-size: 10.5px; font-weight: 800; padding: 2px 6px; border-radius: 8px;
  background: rgba(0, 0, 0, .45); color: var(--rc); }
.item .demo-badge { position: absolute; top: 6px; right: 6px; font-size: 9px; }
.r-common { --rc: var(--r-common); } .r-uncommon { --rc: var(--r-uncommon); } .r-rare { --rc: var(--r-rare); }
.r-epic { --rc: var(--r-epic); } .r-legendary { --rc: var(--r-legendary); }

.ph { display: grid; place-items: center; border-radius: 14px; font-weight: 900; font-size: 20px; color: rgba(255, 255, 255, .92);
  background: linear-gradient(135deg, color-mix(in srgb, var(--rc, #8b5cf6) 80%, #000), #22222e); }
.case-hero .img .ph { width: 160px; height: 160px; border-radius: 32px; font-size: 44px; }
.result .glow .ph { border-radius: 32px; font-size: 44px; }

/* ---------- рулетка ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 5, 9, .88); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; animation: fade .2s ease; }
.roulette-title { font-weight: 800; font-size: 18px; margin-bottom: 18px; }
.roulette { position: relative; width: 100%; overflow: hidden; height: 150px; border-radius: 20px; background: var(--bg-2); border: 1px solid var(--line); }
.roulette::before, .roulette::after { content: ""; position: absolute; top: 0; bottom: 0; width: 60px; z-index: 2; pointer-events: none; }
.roulette::before { left: 0; background: linear-gradient(90deg, var(--bg-2), transparent); }
.roulette::after { right: 0; background: linear-gradient(-90deg, var(--bg-2), transparent); }
.marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; z-index: 3; background: var(--gold); box-shadow: 0 0 14px var(--gold); }
.marker::before, .marker::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); border: 8px solid transparent; }
.marker::before { top: 0; border-top-color: var(--gold); }
.marker::after { bottom: 0; border-bottom-color: var(--gold); }
.strip { display: flex; gap: 8px; padding: 15px 0; will-change: transform; }
.strip .item { flex: none; width: 110px; height: 120px; padding-top: 6px; }
.strip .item .pic { height: 74px; aspect-ratio: auto; }
.skip { margin-top: 16px; color: var(--muted); font-size: 13px; padding: 8px 16px; }

.result { width: 100%; max-width: 360px; text-align: center; animation: pop .35s ease; }
.result .glow { width: 220px; height: 220px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--rc) 55%, transparent), transparent 68%); }
.result .glow img, .result .glow .ph { width: 160px; height: 160px; object-fit: contain; animation: float 3s ease-in-out infinite; }
.result h2 { margin: 6px 0 4px; font-size: 22px; }
.result .rar { color: var(--rc); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.result .value { margin: 10px auto 4px; display: inline-flex; gap: 6px; align-items: center; padding: 8px 14px; border-radius: 14px; background: var(--card); font-weight: 700; }
.result .actions { margin-top: 18px; }

/* ---------- каталог ---------- */
.search { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { flex: 1; background: none; border: 0; outline: none; min-width: 0; }
.chips { display: flex; gap: 8px; margin: 12px 0; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.active { background: rgba(139, 92, 246, .25); border-color: rgba(139, 92, 246, .6); color: var(--text); }
.cat-list { display: grid; gap: 10px; }
.cat {
  display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 18px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line);
}
.cat .pic { width: 64px; height: 64px; border-radius: 14px; background: var(--card-2); display: grid; place-items: center; flex: none; overflow: hidden; }
.cat .pic img, .cat .pic .ph { width: 100%; height: 100%; object-fit: contain; }
.cat .info { min-width: 0; flex: 1; }
.cat .nm { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat .nums { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.cat .nums b { color: var(--text); }
.cat .flags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.flag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 8px; background: var(--card-2); color: var(--muted); }
.flag.warn { background: rgba(255, 90, 106, .18); color: #ff8f9a; }
.flag.hot { background: rgba(255, 194, 61, .18); color: var(--gold); }
.source { margin: 14px 0 0; font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- инвентарь и профиль ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { padding: 12px 10px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-align: center; }
.stat b { display: block; font-size: 18px; font-weight: 800; }
.stat span { font-size: 11px; color: var(--muted); }
.profile-head { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none;
  background: linear-gradient(135deg, var(--accent), #f472b6); display: grid; place-items: center; font-weight: 900; font-size: 26px; }
.profile-head h3 { margin: 0; font-size: 20px; }
.card { padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); margin-top: 12px; }
.card h4 { margin: 0 0 10px; font-size: 15px; }
.bal-big { display: flex; align-items: center; gap: 8px; font-size: 30px; font-weight: 900; }
.bal-big .coin { width: 32px; height: 32px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.list-row:first-of-type { border-top: 0; }
.status { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: var(--card-2); }
.status.paid { color: var(--ok); } .status.refunded { color: var(--muted); } .status.needs_review { color: var(--gold); }
.link-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 0; border-top: 1px solid var(--line); font-weight: 600; text-align: left; }
.link-btn:first-of-type { border-top: 0; }
.link-btn svg { width: 18px; height: 18px; margin-left: auto; color: var(--muted); }
.disclaimer { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* ---------- нижняя навигация ---------- */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px;
  border-radius: 26px; background: rgba(28, 28, 38, .82); backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .09); box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 6px; border-radius: 20px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--text); background: linear-gradient(135deg, rgba(139, 92, 246, .45), rgba(109, 61, 242, .25)); }

/* ---------- шторка ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 88vh; overflow-y: auto;
  padding: 10px 16px calc(20px + var(--safe-bottom)); border-radius: 26px 26px 0 0;
  background: #15151d; border-top: 1px solid var(--line); animation: up .25s ease;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .18); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.preset { padding: 12px 6px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-align: center; }
.preset.active { border-color: var(--accent); background: rgba(139, 92, 246, .2); }
.preset b { display: block; font-size: 17px; }
.preset span { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.amount { display: flex; align-items: center; gap: 8px; height: 50px; padding: 0 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); margin-bottom: 12px; }
.amount input { flex: 1; background: none; border: 0; outline: none; font-size: 17px; font-weight: 700; min-width: 0; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .55); animation: fade .2s ease; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(96px + var(--safe-bottom)); z-index: 80; padding: 12px 16px; border-radius: 16px;
  background: #2a2a38; border: 1px solid var(--line); font-weight: 600; text-align: center; animation: pop .25s ease; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.err { background: #3a1820; border-color: rgba(255, 90, 106, .4); }

.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--card-2), var(--card)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (min-width: 560px) {
  .view, .topbar, .feed { max-width: 560px; margin-left: auto; margin-right: auto; }
  .tabbar { max-width: 536px; margin: 0 auto; }
  .items { grid-template-columns: repeat(4, 1fr); }
}
