:root {
  --bg: #0a0e27;
  --bg-2: #0f1535;
  --panel: #1a1f3a;
  --panel-2: #1a2847;
  --border: #2a3560;
  --text: #e0e7ff;
  --text-2: #f3e8ff;
  --muted: #94a3b8;
  --cyan: #00d9ff;
  --cyan-2: #22e6ff;
  --cyan-3: #0a97b8;
  --purple: #7c3aed;
  --purple-2: #a855f7;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,.55);
  --glow-cyan: 0 0 20px rgba(0,217,255,.35);
  --glow-cyan-strong: 0 0 32px rgba(0,217,255,.55);
  --glow-purple: 0 0 20px rgba(124,58,237,.35);
  /* legacy — оставлены как алиас на новый акцент */
  --gold: var(--cyan);
  --gold-2: var(--cyan-2);
  --gold-3: var(--cyan-3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at top left, rgba(124,58,237,.15), transparent 45%),
    radial-gradient(ellipse at top right, rgba(0,217,255,.13), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(124,58,237,.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body::before {
  content: ""; position: fixed; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.35), transparent 100%),
    radial-gradient(1px 1px at 70% 60%, rgba(0,217,255,.35), transparent 100%),
    radial-gradient(1px 1px at 40% 80%, rgba(168,85,247,.35), transparent 100%),
    radial-gradient(1px 1px at 85% 20%, rgba(255,255,255,.25), transparent 100%);
  pointer-events: none; z-index: 0;
}
main, header, nav { position: relative; z-index: 1; }

.hidden { display: none !important; }

/* Loader */
.loader {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--panel-2); border-top-color: var(--cyan);
  border-radius: 50%; animation: spin .8s linear infinite;
  box-shadow: 0 0 20px rgba(0,217,255,.35);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(15,21,53,.95) 0%, rgba(10,14,39,.85) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand {
  font-weight: 800; font-size: 17px; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--purple-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 8px rgba(0,217,255,.4));
}
.balance {
  background: linear-gradient(135deg, rgba(0,217,255,.12), rgba(124,58,237,.12));
  padding: 6px 14px; border-radius: 20px;
  font-weight: 700; color: var(--cyan-2);
  border: 1px solid rgba(0,217,255,.35);
  box-shadow: 0 0 12px rgba(0,217,255,.2), inset 0 0 12px rgba(0,217,255,.08);
}

/* Tabs */
.tabs {
  display: flex; overflow-x: auto; gap: 8px;
  padding: 10px 12px;
  background: rgba(15,21,53,.5);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all .25s;
}
.tab:active { transform: scale(.95); }
.tab.active {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #fff; border-color: transparent;
  font-weight: 700;
  box-shadow: var(--glow-cyan);
  animation: tabPulse 2.5s ease-in-out infinite;
}
@keyframes tabPulse {
  0%, 100% { box-shadow: var(--glow-cyan); }
  50%      { box-shadow: var(--glow-cyan-strong); }
}

/* Panels */
main { padding: 16px 14px 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.panel { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-title {
  font-weight: 700; font-size: 14px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin: 20px 0 10px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform .1s, opacity .2s, box-shadow .3s;
  gap: 6px;
  position: relative;
  letter-spacing: .3px;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn.disabled {
  cursor: not-allowed;
  background: linear-gradient(135deg, #2a3560, #1a2847) !important;
  color: var(--muted) !important;
  box-shadow: none !important;
  animation: none !important;
  filter: grayscale(50%);
}
.btn.primary {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--purple) 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,217,255,.35), 0 0 0 1px rgba(0,217,255,.4) inset;
}
.btn.primary:not(:disabled):not(.disabled) {
  animation: btnGlow 2.5s ease-in-out infinite;
}
@keyframes btnGlow {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,217,255,.35), 0 0 0 1px rgba(0,217,255,.4) inset; }
  50%      { box-shadow: 0 4px 28px rgba(0,217,255,.6), 0 0 0 1px rgba(124,58,237,.5) inset; }
}
.btn.ghost {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border);
}

/* Advent */
.advent-header {
  background: linear-gradient(135deg, rgba(26,31,58,.9), rgba(15,21,53,.9));
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 20px rgba(0,217,255,.05);
}
.advent-status { font-size: 14px; color: var(--text); margin-bottom: 12px; line-height: 1.5; }
.advent-status b { color: var(--cyan-2); }
.advent-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 14px 0;
}
.day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  transition: transform .2s;
}
.day.claimed { background: rgba(34,197,94,.15); color: #4ade80; border-color: rgba(34,197,94,.4); }
.day.today {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #fff; border-color: transparent;
  animation: dayPulse 1.5s ease-in-out infinite;
}
.day.jackpot {
  background: linear-gradient(135deg, rgba(124,58,237,.25), rgba(0,217,255,.15));
  color: var(--cyan-2); border-color: rgba(124,58,237,.5);
}
.day.jackpot.today { animation: pulseJack 1s infinite; }
@keyframes dayPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(0,217,255,.4); transform: scale(1); }
  50%      { box-shadow: 0 0 24px rgba(0,217,255,.7); transform: scale(1.05); }
}
@keyframes pulseJack {
  0%, 100% { box-shadow: 0 0 15px rgba(124,58,237,.5), 0 0 8px rgba(0,217,255,.3); transform: scale(1); }
  50%      { box-shadow: 0 0 30px rgba(124,58,237,.9), 0 0 16px rgba(0,217,255,.6); transform: scale(1.08); }
}
.legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 12px; color: var(--muted);
  margin-top: 10px; justify-content: center;
}

/* Dice */
.dice-area {
  background: linear-gradient(135deg, rgba(26,31,58,.9), rgba(15,21,53,.9));
  border-radius: var(--radius);
  padding: 30px 16px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 30px rgba(0,217,255,.05);
}
.dice-face {
  width: 100px; height: 100px;
  background: linear-gradient(135deg, #fff, #d5e0ff);
  color: var(--bg);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 800;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 30px rgba(0,217,255,.2);
  transition: transform .5s cubic-bezier(.34, 1.5, .64, 1);
}
.dice-face.rolling { animation: toss 1.4s cubic-bezier(.35,.85,.5,1) forwards; }
@keyframes toss {
  0%   { transform: translateY(0) rotate(0deg) scale(1); }
  15%  { transform: translateY(-140px) rotate(200deg) scale(.85); }
  35%  { transform: translateY(-190px) rotate(500deg) scale(.75); }
  55%  { transform: translateY(-140px) rotate(720deg) scale(.85); }
  75%  { transform: translateY(-40px) rotate(900deg) scale(.95); }
  88%  { transform: translateY(0) rotate(1080deg) scale(1.05); }
  95%  { transform: translateY(-12px) rotate(1080deg) scale(1); }
  100% { transform: translateY(0) rotate(1080deg) scale(1); }
}
.dice-face.win {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 40px rgba(0,217,255,.6);
}
.dice-msg { font-size: 15px; margin-bottom: 16px; min-height: 22px; }
.dice-rules { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* Shop */
.shop-categories {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 8px; margin-bottom: 8px;
  scrollbar-width: none;
}
.shop-categories::-webkit-scrollbar { display: none; }
.cat {
  flex-shrink: 0;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border); padding: 6px 12px;
  border-radius: 16px; font-size: 12px; white-space: nowrap;
  cursor: pointer; transition: all .2s;
}
.cat:active { transform: scale(.95); }
.cat.active {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #fff; border-color: transparent; font-weight: 700;
  box-shadow: var(--glow-cyan);
}
.shop-items { display: grid; gap: 10px; }
.item {
  background: linear-gradient(135deg, rgba(26,31,58,.95), rgba(15,21,53,.95));
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .2s, border-color .2s, box-shadow .3s;
}
.item:active { transform: scale(.99); }
.item-title { font-weight: 700; font-size: 15px; color: var(--text-2); }
.item-desc { color: var(--muted); font-size: 13px; line-height: 1.5; }
.item-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.item-price {
  color: var(--cyan-2); font-weight: 700; font-size: 15px;
  text-shadow: 0 0 10px rgba(0,217,255,.4);
}
.item .btn { padding: 8px 14px; font-size: 13px; }
.item.chest_bronze { border-color: rgba(139,90,43,.5); }
.item.chest_silver { border-color: rgba(168,168,168,.4); }
.item.chest_gold {
  border-color: rgba(0,217,255,.5);
  box-shadow: 0 0 18px rgba(0,217,255,.15);
}

/* Chest items — компактный layout с картинкой слева */
.item.is-chest {
  flex-direction: row; align-items: center; gap: 14px;
  padding: 12px;
}
.chest-svg-wrap {
  width: 72px; height: 72px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chest-svg { width: 100%; height: 100%; animation: chestIdle 3s ease-in-out infinite; }
@keyframes chestIdle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-4px) rotate(-2deg); }
}
.chest-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chest-head { display: flex; align-items: center; gap: 6px; }
.chest-head .item-title { font-size: 14px; }
.info-btn {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel-2); color: var(--cyan);
  border: 1px solid rgba(0,217,255,.4); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all .2s;
  box-shadow: 0 0 8px rgba(0,217,255,.2);
}
.info-btn:active { transform: scale(.9); background: var(--cyan); color: var(--bg); }
.chest-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chest-row .btn { padding: 6px 12px; font-size: 13px; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .2s;
}
.modal-content {
  background: var(--panel); border: 1px solid #2a2a2a;
  border-radius: 18px; padding: 22px 20px;
  max-width: 340px; width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--panel-2); color: var(--muted); border: none;
  font-size: 18px; cursor: pointer;
}
.modal-title {
  font-weight: 800; font-size: 17px; margin-bottom: 12px;
  color: var(--cyan-2);
  text-shadow: 0 0 12px rgba(0,217,255,.4);
}
.modal-body { color: var(--text); font-size: 14px; line-height: 1.6; text-align: left; }
.modal-body b { color: var(--cyan-2); }
.chances-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.chance-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; background: var(--bg-2); border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.chance-row.jack {
  background: linear-gradient(90deg, rgba(124,58,237,.2), rgba(0,217,255,.15));
  color: var(--cyan-2); font-weight: 700;
  border-color: rgba(124,58,237,.5);
  box-shadow: 0 0 12px rgba(0,217,255,.2);
}
.chance-prob { color: var(--muted); font-size: 12px; }
.chance-row.jack .chance-prob { color: var(--cyan); }

/* Chest open modal — большой сундук + анимация */
.open-modal .modal-content { padding: 30px 20px; max-width: 320px; }
.chest-open-wrap {
  width: 180px; height: 180px; margin: 0 auto;
  position: relative; overflow: visible;
}
.chest-open-wrap svg { width: 100%; height: 100%; }
.chest-open-wrap.shaking svg { animation: shakeChest .1s 12 ease-in-out; }
@keyframes shakeChest {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-4deg); }
  75% { transform: rotate(4deg); }
}
.chest-lid { transform-origin: 50% 100%; transition: transform .6s cubic-bezier(.34, 1.5, .64, 1); }
.chest-open .chest-lid { transform: translateY(-40px) rotate(-25deg); }
.chest-light {
  position: absolute; top: 20%; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--cyan);
  opacity: 0; pointer-events: none;
}
.chest-open .chest-light {
  animation: burst 1s ease-out forwards;
}
@keyframes burst {
  0%   { opacity: 1; transform: translateX(-50%) scale(1); box-shadow: 0 0 0 0 rgba(0,217,255,.9); }
  100% { opacity: 0; transform: translateX(-50%) scale(20); box-shadow: 0 0 60px 40px rgba(0,217,255,0); }
}
.chest-reward {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%);
  font-size: 34px; font-weight: 800; color: var(--cyan-2);
  text-shadow: 0 0 20px rgba(0,217,255,.8), 0 0 30px rgba(124,58,237,.5);
  opacity: 0; pointer-events: none;
  white-space: nowrap;
}
.chest-open .chest-reward {
  animation: rewardIn .8s .5s cubic-bezier(.34, 1.5, .64, 1) forwards;
}
@keyframes rewardIn {
  from { opacity: 0; transform: translate(-50%, 20px) scale(.5); }
  60%  { opacity: 1; transform: translate(-50%, -10px) scale(1.2); }
  to   { opacity: 1; transform: translate(-50%, -10px) scale(1); }
}
.chest-caption { color: var(--muted); font-size: 13px; margin: 14px 0 4px; min-height: 20px; }
.chest-caption.big {
  color: var(--cyan-2); font-weight: 700; font-size: 16px;
  text-shadow: 0 0 10px rgba(0,217,255,.4);
}

/* Referrals */
.refs-hero {
  background: linear-gradient(135deg, rgba(0,217,255,.12), rgba(124,58,237,.15));
  border: 1px solid rgba(0,217,255,.35);
  border-radius: var(--radius); padding: 16px;
  text-align: center;
  box-shadow: 0 0 24px rgba(0,217,255,.1);
}
.refs-title {
  font-weight: 800; color: var(--cyan-2); margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(0,217,255,.5);
}
.refs-percents { color: var(--text); font-size: 13px; }
.refs-percents b { color: var(--cyan-2); }
.refs-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 14px 0;
}
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 8px; text-align: center;
  transition: box-shadow .3s;
}
.stat:hover { box-shadow: 0 0 12px rgba(0,217,255,.2); }
.stat-value {
  font-weight: 800; color: var(--cyan-2); font-size: 24px;
  text-shadow: 0 0 12px rgba(0,217,255,.4);
}
.stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.refs-link-block {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.hint { font-size: 12px; color: var(--muted); }
.ref-link {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px;
  font-family: monospace; font-size: 12px;
  word-break: break-all; margin: 8px 0 12px;
  color: var(--cyan-2);
}
.refs-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.refs-list { display: flex; flex-direction: column; gap: 6px; }
.ref-item {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.ref-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800;
  box-shadow: 0 0 12px rgba(0,217,255,.35);
}

/* Withdraw */
.wd-summary {
  background: linear-gradient(135deg, rgba(0,217,255,.08), rgba(124,58,237,.08));
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  text-align: center;
}
.wd-summary .label { color: var(--muted); font-size: 12px; }
.wd-summary .value {
  color: var(--cyan-2); font-weight: 800; font-size: 26px; margin: 4px 0;
  text-shadow: 0 0 14px rgba(0,217,255,.4);
}
.wd-methods { display: grid; gap: 8px; }
.wd-method {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
  cursor: pointer; transition: all .2s;
}
.wd-method:active { transform: scale(.98); }
.wd-method.active {
  border-color: var(--cyan);
  background: linear-gradient(135deg, rgba(0,217,255,.1), rgba(124,58,237,.08));
  box-shadow: var(--glow-cyan);
  color: var(--cyan-2);
}
.wd-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.wd-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.wd-form input, .wd-form textarea {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; font-size: 14px; font-family: inherit;
  outline: none; transition: all .2s;
}
.wd-form input:focus, .wd-form textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,217,255,.2);
}
.wd-form textarea { resize: vertical; min-height: 60px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #333; color: white;
  padding: 12px 18px; border-radius: 20px;
  font-size: 14px; box-shadow: var(--shadow);
  z-index: 999;
  animation: toastIn .3s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
