:root {
  --bg: #120c24;
  --bg-2: #1d1438;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f1ff;
  --muted: #a99cc9;
  --gold: #ffcf5a;
  --gold-2: #f29a1f;
  --accent: #8b5cf6;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(120% 70% at 50% 0%, #2a1a57 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(88px + var(--safe-bottom));
  min-height: 100vh;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 { margin: 8px 0 12px; font-size: 20px; }

.wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid rgba(255, 207, 90, 0.35);
  color: var(--text);
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.wallet:active { transform: scale(0.97); }
.wallet-amount { font-weight: 800; font-size: 17px; color: var(--gold); font-variant-numeric: tabular-nums; }
.wallet-plus {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 18px;
  color: #2a1600;
  background: linear-gradient(180deg, #ffe08a, var(--gold-2));
}

/* Второстепенные кнопки */
.ghost-btn {
  flex: 1;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
}
.ghost-btn:active { transform: scale(0.98); }
.ghost-btn.gold { border-color: rgba(255, 207, 90, 0.4); color: var(--gold); }
.ghost-btn[hidden] { display: none; }
.modal-actions .ghost-btn { white-space: nowrap; }

.item-row { display: flex; align-items: center; gap: 12px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; }
.badge-owned { background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.badge-sold { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }

.modal-actions { position: relative; display: grid; gap: 8px; }
.modal-actions .row { display: flex; gap: 8px; }

/* Нижний лист пополнения */
.modal.sheet { place-items: end center; padding: 0; }
.sheet-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: 22px 16px calc(22px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #2b1d57, var(--bg-2));
  border: 1px solid var(--line);
  border-bottom: 0;
  animation: slideUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-card h3 { margin: 0 0 6px; font-size: 20px; }
.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.pack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.pack:active { transform: scale(0.97); }
.pack.is-suggested { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.pack-amount { font-size: 20px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.pack-sub { font-size: 12.5px; color: var(--muted); }

.tab { position: relative; }
.dot {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5d73;
}
.dot[hidden] { display: none; }

.view { display: none; animation: fade 0.25s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* Колесо */
.wheel-wrap {
  position: relative;
  width: min(88vw, 380px);
  aspect-ratio: 1;
  margin: 20px auto 24px;
}
.wheel-wrap::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--gold), var(--gold-2), var(--gold), var(--gold-2), var(--gold));
  box-shadow: 0 0 40px rgba(255, 190, 70, 0.35), 0 20px 60px rgba(0, 0, 0, 0.5);
}
#wheel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  will-change: transform;
}
.pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 34px solid #fff;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
  z-index: 3;
}
.hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(22px, 7vw, 32px);
  background: radial-gradient(circle at 35% 30%, #fff6d8, var(--gold) 45%, var(--gold-2));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 -3px 6px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.spin-btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #2a1600;
  background: linear-gradient(180deg, #ffe08a, var(--gold-2));
  box-shadow: 0 8px 24px rgba(242, 154, 31, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s ease;
}
.spin-btn:active { transform: scale(0.98); }
.spin-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; filter: grayscale(0.4); }

.hint { min-height: 20px; margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* Списки */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.item-emoji { font-size: 26px; width: 34px; text-align: center; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 650; }
.item-sub { color: var(--muted); font-size: 12.5px; }
.item-right { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 4px; margin-top: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.empty { padding: 32px 12px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-sent { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; }
.badge-pending, .badge-sending { background: rgba(255, 207, 90, 0.15); color: var(--gold); }
.badge-failed { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }
.badge-test { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }

/* Нижние вкладки */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(18, 12, 36, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.tab {
  flex: 1;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}
.tab span { font-size: 11.5px; font-weight: 600; }
.tab.is-active { color: var(--text); background: var(--card); }

/* Окно результата */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 4, 20, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  animation: fade 0.2s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 28px 22px 22px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #2b1d57, var(--bg-2));
  border: 1px solid rgba(255, 207, 90, 0.35);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }
.modal-glow {
  position: absolute;
  inset: -40% -40% auto;
  height: 220px;
  background: radial-gradient(closest-side, rgba(255, 207, 90, 0.45), transparent);
  animation: spinGlow 6s linear infinite;
}
@keyframes spinGlow { to { transform: rotate(360deg); } }
.modal-emoji { position: relative; font-size: 84px; line-height: 1; margin-bottom: 10px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.modal-kicker { position: relative; margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; }
.modal-card h3 { position: relative; margin: 4px 0 8px; font-size: 26px; }
.modal-status { position: relative; margin: 0 0 20px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: #2e2350;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  text-align: center;
  z-index: 20;
}
.toast[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .modal-glow, .modal-emoji { animation: none; }
}

/* Лента и админка */
h3.sub { margin: 20px 0 10px; font-size: 15px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.stat {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.stat b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.gold b { color: var(--gold); }
.best {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 207, 90, 0.35);
  background: linear-gradient(90deg, rgba(255, 207, 90, 0.12), transparent);
}
.best[hidden] { display: none; }
.best .item-emoji { font-size: 30px; }
.feed-item .item-right { font-size: 13px; color: var(--gold); }
.time { color: var(--muted); font-size: 12px; }
.tab[hidden] { display: none; }
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.ghost-btn.small { flex: 0 0 auto; padding: 7px 12px; font-size: 13px; }
.bot-balance {
  display: grid;
  gap: 2px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 207, 90, 0.4);
  background: linear-gradient(135deg, rgba(255, 207, 90, 0.16), rgba(139, 92, 246, 0.1));
}
.bot-balance strong { font-size: 32px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.count { color: var(--gold); }
.ghost-btn.ok { border-color: rgba(52, 211, 153, 0.45); color: #6ee7b7; }
.ghost-btn.no { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.req-who { margin-top: 6px; font-size: 13px; color: var(--muted); }
.req-who a { color: var(--text); }

/* Вывод звёзд админу */
.payout {
  margin-top: 12px;
  padding: 4px 14px 14px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}
.payout h3.sub { margin-top: 12px; }
.payout-rows { display: grid; gap: 6px; font-size: 14px; }
.payout-rows div { display: flex; justify-content: space-between; gap: 12px; }
.payout-rows span { color: var(--muted); }
.payout-rows b { font-variant-numeric: tabular-nums; }
.payout-rows .total { padding-top: 8px; border-top: 1px solid var(--line); }
.payout-rows .total span { color: var(--text); font-weight: 650; }
.payout-rows .total b { color: var(--gold); font-size: 17px; }
.payout-input { display: grid; gap: 6px; margin: 14px 0 8px; font-size: 13px; color: var(--muted); }
.payout-input input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
}
.payout .row { display: flex; gap: 8px; margin-bottom: 10px; }
.payout-steps { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
.payout-steps[hidden] { display: none; }
.payout > .muted.small { margin: 12px 0 0; }

/* Выбор игрока для перевода */
.user-pick { list-style: none; margin: 0 0 4px; padding: 0; max-height: 260px; overflow-y: auto; display: grid; gap: 6px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.user-row b { color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.user-row .item-title { font-size: 14px; }
.user-row .item-sub { font-size: 12px; }
.user-row.is-picked { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.empty.small { padding: 10px; font-size: 13px; }
#transfer { margin-bottom: 4px; }
#transfer .muted.small { margin: 0 0 10px; }

.take { margin-top: 8px; }
.take[hidden] { display: none; }
.take .row { margin: 0; }
.ghost-btn:disabled { opacity: 0.45; cursor: default; }

/* Переключатель колёс */
.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 4px 0 6px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.switch-btn {
  position: relative;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.switch-btn.is-active { background: linear-gradient(180deg, #ffe08a, var(--gold-2)); color: #2a1600; }
.switch-btn .dot { top: 6px; right: 12px; }

/* Реферальная ссылка игрока */
.ref-box {
  margin-top: 16px;
  padding: 4px 14px 14px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid rgba(255, 207, 90, 0.35);
}
.ref-box .row { display: flex; gap: 8px; margin: 10px 0 0; }
.ref-box .muted.small { margin: 8px 0 0; }
.ref-link {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}
.ref-list { margin-top: 12px; }
.item.is-off { opacity: 0.6; }
#refsAdmin { margin-top: 12px; }

.sell-all { margin: 4px 0 14px; font-size: 16px; padding: 14px; }
.sell-all[hidden] { display: none; }

/* Сколько прокрутов за раз */
.multi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 10px; }
.multi-btn {
  padding: 9px 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted, #b9b0d8);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.multi-btn.is-active { background: rgba(255, 200, 80, 0.16); border-color: var(--gold-2); color: #ffe08a; }

/* Несколько выигрышей */
.res-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0 14px; position: relative; }
.res-list[hidden] { display: none; }
.res-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); font-size: 14px; font-weight: 700;
}
.res-chip-e { font-size: 18px; }

/* Мини-колёса при ×3 / ×5 / ×10 */
.multi-card { padding-top: 18px; }
.multi-card h3 { margin: 0 0 12px; position: relative; }
.multi-grid { display: grid; gap: 10px 8px; margin-bottom: 14px; position: relative; }
.multi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.multi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.mini { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.mini-wheel {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%;
  padding: 3px; background: linear-gradient(180deg, #ffe08a, var(--gold-2));
  box-shadow: 0 4px 14px rgba(242, 154, 31, 0.25);
}
.mini-wheel canvas { display: block; width: 100%; height: 100%; border-radius: 50%; }
.mini-hub {
  position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; transform: translate(-50%, -50%);
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3c4, var(--gold-2));
}
.mini-ptr {
  position: absolute; left: 50%; top: -5px; z-index: 2; transform: translateX(-50%);
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 12px solid #fff;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}
.mini-label { min-height: 18px; font-size: 13px; font-weight: 800; white-space: nowrap; opacity: 0; transition: opacity 0.25s; }
.mini.is-done .mini-label { opacity: 1; }
.mini.is-big .mini-wheel { box-shadow: 0 0 0 2px #fff, 0 0 22px rgba(255, 210, 90, 0.9); }
.mini.is-big .mini-label { color: #ffe08a; }
#multiOk[hidden], #multiTotal[hidden] { display: none; }
