:root {
  --bg-0:    #0e0821;
  --glass:   rgba(255,255,255,.05);
  --glass-2: rgba(255,255,255,.08);
  --stroke:  rgba(255,255,255,.09);
  --stroke-2:rgba(255,255,255,.15);
  --text:    #f2f0fb;
  --muted:   #9a92c4;
  --gold:    #ffd15c;
  --lime:    #7cf0a8;
  --pink:    #ff5db1;
  --grad:    linear-gradient(135deg, #8b5cf6 0%, #6366f1 48%, #22d3ee 100%);
  --r:       22px;
  --safe-t:  env(safe-area-inset-top, 0px);
  --safe-b:  env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg-0); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(60% 45% at 12% -5%, rgba(139,92,246,.42), transparent 60%),
    radial-gradient(55% 40% at 105% 8%, rgba(34,211,238,.26), transparent 55%),
    radial-gradient(75% 55% at 50% 112%, rgba(255,93,177,.22), transparent 62%),
    var(--bg-0);
}

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* -------- Шапка -------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(16px + var(--safe-t)) 18px 14px;
  background: linear-gradient(180deg, rgba(14,8,33,.97) 55%, rgba(14,8,33,.75));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}
.user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; object-fit: cover;
  background: var(--glass-2); border: 1.5px solid var(--stroke-2);
}
.username { font-weight: 700; font-size: 16px; line-height: 1.1; }
.hello { font-size: 12px; color: var(--muted); margin-top: 1px; }

.coins {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px 9px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--stroke-2);
  font-weight: 800; font-size: 16px;
}
.coin-e { font-size: 17px; line-height: 1; }

/* -------- Экран -------- */
.screen { flex: 1; padding: 8px 18px calc(122px + var(--safe-b)); animation: rise .26s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.h1 { font-size: 28px; font-weight: 800; letter-spacing: -.6px; margin: 12px 0 3px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* -------- Фильтры -------- */
.filters { display: flex; gap: 9px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--stroke); color: var(--muted);
}
.pill.active { background: var(--grad); border-color: transparent; color: #fff; }

/* -------- Карточка задания -------- */
.task {
  position: relative; overflow: hidden;
  background: var(--glass); border: 1px solid var(--stroke);
  border-radius: var(--r); padding: 16px; margin-bottom: 13px;
}
.task.unique { border-color: rgba(255,209,92,.35); background: linear-gradient(180deg, rgba(255,209,92,.06), var(--glass)); }
.task.done { opacity: .5; }

.task-top { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.task-ic {
  width: 48px; height: 48px; border-radius: 15px; flex: none; display: grid; place-items: center;
  font-size: 23px; background: var(--accent, var(--glass-2));
  box-shadow: 0 8px 20px -10px var(--accent-sh, rgba(0,0,0,.4));
}
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 700; font-size: 15.5px; line-height: 1.25; display: flex; align-items: center; gap: 6px; }
.star { color: var(--gold); font-size: 14px; }
.task-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.reward-pill {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px; border-radius: 12px; font-weight: 800; font-size: 14px;
  background: var(--glass-2); border: 1px solid var(--stroke);
}
.reward-pill .coin-e { font-size: 14px; }

.btn { border: none; cursor: pointer; font-weight: 700; font-size: 15px; border-radius: 15px; padding: 14px; width: 100%; transition: transform .1s, filter .15s; }
.btn:active { transform: scale(.985); }
.btn-main { background: var(--grad); color: #fff; box-shadow: 0 12px 26px -14px rgba(99,102,241,1); }
.btn-check { background: linear-gradient(135deg, #34d399, #10b981); box-shadow: 0 12px 26px -14px rgba(16,185,129,1); }
.btn-ok { background: var(--glass-2); color: var(--muted); box-shadow: none; }
.btn:disabled { opacity: .6; }

/* -------- Кейсы -------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.case {
  text-align: center; padding: 24px 14px 16px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--r);
}
.orb {
  width: 82px; height: 82px; margin: 0 auto 14px; border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #ffffffd0, transparent 44%), var(--c1);
  box-shadow: 0 0 36px -6px var(--c1), inset 0 -8px 18px -6px rgba(0,0,0,.45);
}
.case-name { font-weight: 700; font-size: 15px; }
.case-price { display: inline-flex; align-items: center; gap: 6px; margin: 7px 0 14px; font-weight: 800; font-size: 16px; }
.case-price .coin-e { font-size: 15px; }

/* -------- Вывод -------- */
.shop-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--r);
  padding: 14px; margin-bottom: 12px;
}
.shop-orb {
  width: 54px; height: 54px; border-radius: 16px; flex: none; display: grid; place-items: center;
  font-size: 26px; background: linear-gradient(135deg, rgba(124,240,168,.22), rgba(34,211,238,.14));
  border: 1px solid var(--stroke);
}
.shop-body { flex: 1; min-width: 0; }
.shop-title { font-weight: 800; font-size: 18px; }
.shop-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: inline-flex; align-items: center; gap: 5px; }
.shop-sub .coin-e { font-size: 12px; }
.shop-buy { flex: 0 0 auto; }
.mini-btn { border: none; border-radius: 13px; padding: 11px 18px; font-weight: 700; font-size: 14px;
  background: var(--grad); color: #fff; box-shadow: 0 10px 22px -14px rgba(99,102,241,1); }
.mini-btn.off { background: var(--glass-2); color: var(--muted); box-shadow: none; }

/* -------- Профиль -------- */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 22px;
  background: var(--grad); margin-bottom: 18px;
  box-shadow: 0 22px 44px -22px rgba(99,102,241,1);
}
.hero::after { content: ""; position: absolute; right: -46px; top: -46px; width: 170px; height: 170px;
  border-radius: 50%; background: rgba(255,255,255,.16); }
.hero-cap { font-size: 12px; opacity: .9; }
.hero-bal { font-size: 42px; font-weight: 800; display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.hero-row { display: flex; gap: 10px; margin-top: 18px; }
.hero-chip { flex: 1; background: rgba(255,255,255,.15); border-radius: 16px; padding: 12px 14px; }
.hero-chip small { display: block; font-size: 11px; opacity: .9; margin-bottom: 2px; }
.hero-chip b { font-size: 17px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px; margin-bottom: 16px; }
.seg button { padding: 12px; border: none; border-radius: 12px; font-weight: 700; font-size: 14px; background: transparent; color: var(--muted); }
.seg button.active { background: var(--grad); color: #fff; }

.row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 10px;
}
.row-title { font-weight: 700; font-size: 14px; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.amt { font-weight: 800; font-size: 15px; }
.amt.plus { color: var(--lime); }
.amt.minus { color: var(--pink); }

.ref-banner { text-align: center; font-weight: 700; padding: 16px; border-radius: 16px; margin-bottom: 14px;
  background: linear-gradient(135deg, #ff5db1, #a855f7); }
.ref-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ref-cell { text-align: center; background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px; padding: 14px 8px; }
.ref-num { font-size: 20px; font-weight: 800; }
.ref-cap { color: var(--muted); font-size: 11px; margin-top: 4px; }
.ref-link { display: flex; gap: 10px; }
.ref-link input { flex: 1; min-width: 0; background: var(--glass); border: 1px solid var(--stroke); color: var(--text);
  border-radius: 14px; padding: 13px; font-size: 13px; }
.ref-link .btn { width: auto; padding: 13px 18px; }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* -------- Док -------- */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b)); z-index: 30;
  width: calc(100% - 28px); max-width: 492px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 8px; border-radius: 24px;
  background: rgba(20,14,42,.72); border: 1px solid var(--stroke-2);
  backdrop-filter: blur(22px);
  box-shadow: 0 20px 45px -18px rgba(0,0,0,.8);
}
.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--muted); font-size: 11px; padding: 9px 0; border-radius: 16px; transition: .16s; }
.dock-btn.active { color: #fff; background: var(--grad); }
.dl { font-weight: 600; }
.di { width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.di-bolt { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M13 2L4 14h6l-1 8 9-12h-6z'/></svg>"); }
.di-box  { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 2l9 4.5v11L12 22l-9-4.5v-11zM12 4.3L5.5 7.5 12 10.7l6.5-3.2zM5 9.2v6.6l6 3v-6.6zm14 0l-6 3v6.6l6-3z'/></svg>"); }
.di-bag  { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 2a5 5 0 00-5 5H4v13a1 1 0 001 1h14a1 1 0 001-1V7h-3a5 5 0 00-5-5zm-3 5a3 3 0 016 0zm3 6l4 3-1.5 1L12 16l-2.5 2L8 17z'/></svg>"); }
.di-user { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 12a5 5 0 100-10 5 5 0 000 10zm0 2c-4 0-8 2-8 5v1h16v-1c0-3-4-5-8-5z'/></svg>"); }

/* -------- Тост -------- */
.toast {
  position: fixed; left: 50%; bottom: calc(106px + var(--safe-b)); transform: translateX(-50%) translateY(16px);
  background: rgba(30,22,58,.96); color: var(--text); border: 1px solid var(--stroke-2);
  padding: 13px 20px; border-radius: 16px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 88%;
  backdrop-filter: blur(16px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.win { border-color: rgba(124,240,168,.5); }

/* ===================== РУЛЕТКА ===================== */
.di-roulette { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 2a10 10 0 100 20 10 10 0 000-20zm0 2.6a7.4 7.4 0 110 14.8 7.4 7.4 0 010-14.8zM12 8a4 4 0 100 8 4 4 0 000-8zm0 2.2a1.8 1.8 0 110 3.6 1.8 1.8 0 010-3.6z'/></svg>"); }

/* Живой тикер выпадений */
.drops {
  display: flex; gap: 8px; overflow: hidden; margin-bottom: 16px;
  -webkit-mask: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
          mask: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.drop {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  background: var(--glass); border: 1px solid var(--stroke); border-left: 3px solid var(--rc, #6b7280);
  border-radius: 11px; padding: 7px 11px; font-size: 12px; font-weight: 700;
}
.drop .who { color: var(--muted); font-weight: 500; }
.drop .coin-e { font-size: 12px; }

/* Барабан */
.reel-wrap { position: relative; margin: 4px 0 20px; }
.reel-mask {
  overflow: hidden; border-radius: 22px;
  border: 1px solid var(--stroke-2);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.35));
  padding: 18px 0; box-shadow: inset 0 0 50px rgba(0,0,0,.6);
}
.reel { display: flex; will-change: transform; padding-left: 0; }
.r-chip {
  flex: 0 0 auto; width: 90px; height: 108px; margin-right: 12px; border-radius: 18px;
  background: linear-gradient(180deg, #191238, #120d29);
  border: 1px solid var(--stroke);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  position: relative; overflow: hidden;
  box-shadow: inset 0 -40px 34px -26px var(--rc);
}
.r-chip::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: var(--rc); box-shadow: 0 0 14px var(--rc);
}
.r-chip .coin-e { font-size: 22px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.r-chip .amt { font-weight: 800; font-size: 15px; }
.r-chip.empty .amt { color: var(--muted); }
.r-chip.win { animation: winpulse 1s ease-in-out infinite; z-index: 2; }
@keyframes winpulse {
  0%, 100% { box-shadow: inset 0 -40px 34px -26px var(--rc), 0 0 0 0 var(--rc); }
  50%      { box-shadow: inset 0 -40px 34px -26px var(--rc), 0 0 28px 2px var(--rc); }
}

.reel-fade { position: absolute; top: 1px; bottom: 1px; width: 64px; pointer-events: none; z-index: 4; }
.reel-fade.left  { left: 1px;  border-radius: 22px 0 0 22px; background: linear-gradient(90deg, #0e0821 10%, transparent); }
.reel-fade.right { right: 1px; border-radius: 0 22px 22px 0; background: linear-gradient(270deg, #0e0821 10%, transparent); }

.reel-pointer {
  position: absolute; top: -3px; bottom: -3px; left: 50%; width: 3px; z-index: 6;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #22d3ee, #8b5cf6);
  box-shadow: 0 0 18px #8b5cf6;
}
.reel-pointer::before, .reel-pointer::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent;
}
.reel-pointer::before { top: -8px;   border-top: 10px solid #22d3ee;   filter: drop-shadow(0 0 5px #22d3ee); }
.reel-pointer::after  { bottom: -8px; border-bottom: 10px solid #8b5cf6; filter: drop-shadow(0 0 5px #8b5cf6); }

.spin-btn { font-size: 16px; padding: 16px; letter-spacing: .2px; }
.spin-btn:disabled { filter: grayscale(.3) brightness(.8); }

/* Легенда шансов */
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.leg {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 12px; padding: 8px 11px;
}
.leg .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rc); box-shadow: 0 0 9px var(--rc); }
.leg .pc { color: var(--muted); font-weight: 500; }

/* Модалка результата */
.modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(6,4,16,.72); backdrop-filter: blur(7px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%; max-width: 320px; text-align: center; padding: 30px 24px; border-radius: 28px;
  background: #150f31; border: 1px solid var(--rc, var(--stroke-2));
  box-shadow: 0 0 70px -12px var(--rc, #000), 0 24px 50px -20px #000;
  transform: scale(.88) translateY(10px); transition: transform .3s cubic-bezier(.2,1.2,.3,1);
}
.modal.show .modal-card { transform: scale(1) translateY(0); }
.modal-emoji { font-size: 58px; line-height: 1; }
.modal-title { color: var(--muted); font-size: 14px; margin-top: 10px; }
.modal-amt { font-size: 38px; font-weight: 800; margin: 4px 0 4px; }
.modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { padding: 13px; }
.btn-outline { background: var(--glass-2); color: var(--text); }

/* Мульти-результат в модалке */
.modal-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 18px; }
.modal-list .mchip {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 13px;
  padding: 7px 10px; border-radius: 11px; background: var(--glass);
  border: 1px solid var(--rc, var(--stroke)); box-shadow: 0 0 12px -4px var(--rc);
}
.modal-list .mchip.empty { opacity: .55; }

/* Селектор количества открытий */
.multi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 2px 0 14px; }
.multi button {
  padding: 12px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--glass);
  color: var(--muted); font-weight: 800; font-size: 15px;
}
.multi button small { display: block; font-weight: 600; font-size: 10px; margin-top: 2px; }
.multi button.active { background: var(--grad); border-color: transparent; color: #fff; }

/* Компактнее чипы при мульти-ленте */
.reel-wrap + .reel-wrap { margin-top: 10px; }
.reel-wrap.small .reel-mask { padding: 12px 0; }
.reel-wrap.small .r-chip { width: 74px; height: 88px; }
.reel-wrap.small .r-chip .coin-e { font-size: 18px; }
.reel-wrap.small .r-chip .amt { font-size: 13px; }

/* ===================== ЛОК-ЭКРАН ===================== */
.lock {
  min-height: 78vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 8px;
}
.lock-emoji { font-size: 62px; }
.lock-title { font-size: 24px; font-weight: 800; }
.lock-sub { color: var(--muted); font-size: 15px; max-width: 300px; }

/* ===================== АДМИНКА ===================== */
.di-admin { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 2l7 3v6c0 4.4-3 8.3-7 9-4-.7-7-4.6-7-9V5l7-3zm-1 6v3H8v2h3v3h2v-3h3v-2h-3V8h-2z'/></svg>"); }

.admin-card {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 20px; padding: 16px; margin-bottom: 16px;
}
.admin-card h3 { margin: 0 0 14px; font-size: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg-0); border: 1px solid var(--stroke); color: var(--text);
  border-radius: 12px; padding: 12px; font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 46px; }
.field.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field.row2 > div { min-width: 0; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.chk input { width: 20px; height: 20px; accent-color: var(--violet); }

.acat { display: flex; gap: 8px; flex-wrap: wrap; }
.acat button {
  padding: 9px 13px; border-radius: 999px; border: 1px solid var(--stroke); background: var(--glass);
  color: var(--muted); font-size: 12px; font-weight: 700;
}
.acat button.active { background: var(--grad); border-color: transparent; color: #fff; }

.atask {
  display: flex; align-items: center; gap: 12px; background: var(--glass); border: 1px solid var(--stroke);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 10px;
}
.atask.off { opacity: .5; }
.atask .a-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px;
  background: var(--glass-2); border: 1px solid var(--stroke); flex: none; }
.atask .a-main { flex: 1; min-width: 0; }
.atask .a-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atask .a-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.atask .a-acts { display: flex; gap: 6px; flex: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--stroke); background: var(--glass-2);
  color: var(--text); font-size: 16px; display: grid; place-items: center; }
.icon-btn.danger { color: var(--pink); border-color: rgba(255,93,177,.3); }

/* Док: подстройка при 5 кнопках */
.dock.cols5 { grid-template-columns: repeat(5, 1fr); }
.dock.cols5 .dl { font-size: 10px; }
