:root {
  --bg: #070a12;
  --bg-2: #0c1120;
  --card: rgba(18, 25, 43, 0.72);
  --card-solid: #121a2c;
  --stroke: rgba(120, 140, 190, 0.16);
  --text: #eef3ff;
  --muted: #8a97b8;
  --gold: #ffcf5c;
  --gold-2: #ff9f1a;
  --violet: #8b5cff;
  --cyan: #3fd6ff;
  --green: #37e0a0;
  --red: #ff6b8a;
  --radius: 24px;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.center { text-align: center; }

/* ---------- background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 50% -15%, rgba(80, 70, 180, 0.35), transparent 60%),
    radial-gradient(700px 500px at 100% 10%, rgba(20, 120, 160, 0.18), transparent 55%),
    var(--bg);
}
.aurora span {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: drift 18s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { background: #5b3cff; top: -18vmax; left: -12vmax; }
.aurora span:nth-child(2) { background: #0e7f9c; top: 32vh; right: -20vmax; animation-delay: -6s; }
.aurora span:nth-child(3) { background: #b06a12; bottom: -22vmax; left: 10vw; animation-delay: -12s; opacity: 0.3; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4vmax, 5vmax, 0) scale(1.12); }
}

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  text-align: center;
  padding: 34px 26px 30px;
  border-radius: 30px;
  background: var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.login-card h1 { margin: 18px 0 6px; font-size: 34px; letter-spacing: -0.5px; }
.login-card h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--gold), var(--gold-2), #ff7bd5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-card p { margin: 8px 0; }
.orbit {
  width: 110px; height: 110px; margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px dashed rgba(255, 207, 92, 0.4);
  animation: spin 14s linear infinite;
}
.coin-hero {
  width: 74px; height: 74px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 34px; font-weight: 800;
  color: #5a3a06;
  background: radial-gradient(circle at 35% 30%, #fff0b0, var(--gold-2));
  box-shadow: 0 12px 34px rgba(255, 159, 26, 0.4), inset 0 -6px 0 rgba(0, 0, 0, 0.15);
  animation: spin 14s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gsi { min-height: 44px; display: flex; justify-content: center; margin-top: 14px; }
.native-login-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 15px;
  color: #4a3005;
  background: linear-gradient(120deg, var(--gold), var(--gold-2));
  box-shadow: 0 10px 26px rgba(255, 159, 26, 0.28);
}
.msg { min-height: 16px; font-size: 13px; color: var(--gold); margin: 8px 0; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }

/* ---------- app shell ---------- */
.app { padding: 0 0 108px; }
.content { width: min(560px, 100%); margin: 0 auto; padding: 18px 16px 0; }

.page { animation: fadeUp 0.3s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title { font-size: 22px; margin: 6px 0 4px; letter-spacing: -0.3px; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  object-fit: cover; background: var(--card-solid);
  border: 1px solid var(--stroke);
}
.who-name { font-weight: 700; font-size: 15.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

.icon-btn {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--stroke);
  color: var(--muted);
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- balance ---------- */
.balance-card {
  position: relative;
  overflow: hidden;
  margin-top: 16px;
  padding: 20px 20px 18px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 207, 92, 0.12), rgba(139, 92, 255, 0.1)),
    var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
}
.balance-glow {
  position: absolute;
  width: 220px; height: 220px; right: -80px; top: -120px;
  background: radial-gradient(circle, rgba(255, 207, 92, 0.45), transparent 65%);
  filter: blur(10px);
  pointer-events: none;
}
.balance-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: relative; }
.chip {
  font-size: 10.5px; letter-spacing: 1.5px; font-weight: 700;
  color: #4a3005;
  background: linear-gradient(120deg, var(--gold), var(--gold-2));
  padding: 5px 10px; border-radius: 999px;
}
.chip.soft {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--stroke);
  letter-spacing: 0.4px;
  font-weight: 600;
}
.balance-value {
  display: flex; align-items: center; gap: 10px;
  font-size: 46px; font-weight: 800; letter-spacing: -1.5px;
  color: var(--gold);
  margin-top: 12px;
  line-height: 1;
  text-shadow: 0 8px 30px rgba(255, 159, 26, 0.25);
}
.coin-badge {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 17px; color: #5a3a06;
  background: radial-gradient(circle at 35% 30%, #fff0b0, var(--gold-2));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.balance-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.cap-track {
  height: 8px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  margin-top: 16px; overflow: hidden;
}
.cap-fill {
  height: 100%; width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--violet), var(--cyan));
  box-shadow: 0 0 14px rgba(139, 92, 255, 0.6);
  transition: width 0.5s ease;
}
.cap-label { color: var(--muted); font-size: 11.5px; margin-top: 7px; }

/* ---------- game ---------- */
.game-card {
  margin-top: 16px; padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
}
.game-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.game-title { font-weight: 800; font-size: 17px; }
.hud { display: flex; gap: 16px; }
.hud > div { display: flex; flex-direction: column; align-items: center; }
.hud span { font-size: 20px; font-weight: 800; color: var(--gold); line-height: 1; }
.hud small { font-size: 10px; color: var(--muted); margin-top: 3px; }
.canvas-wrap {
  position: relative;
  margin-top: 14px;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #16203a 0%, #0a0f1d 70%);
  border: 1px solid var(--stroke);
  min-height: 300px;
}
#gameCanvas { display: block; width: 100%; height: 300px; touch-action: none; }
.game-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(7, 10, 18, 0.55);
  backdrop-filter: blur(3px);
  transition: opacity 0.25s;
}
.game-overlay.gone { opacity: 0; pointer-events: none; }
.play-btn {
  padding: 15px 34px; border-radius: 999px;
  font-weight: 800; font-size: 16px; color: #4a3005;
  background: linear-gradient(120deg, var(--gold), var(--gold-2));
  box-shadow: 0 12px 34px rgba(255, 159, 26, 0.4);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ---------- generic panels ---------- */
.panel, .wheel-card, .ref-card {
  margin-top: 16px; padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
}
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- missions ---------- */
.bonus-card {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0; padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(120deg, rgba(255, 207, 92, 0.16), rgba(139, 92, 255, 0.12)),
    var(--card);
  border: 1px solid rgba(255, 207, 92, 0.35);
  backdrop-filter: blur(14px);
}
.bonus-card.claimed { opacity: 0.6; }
.bonus-icon {
  flex: none;
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  color: #4a3005;
  background: linear-gradient(120deg, var(--gold), var(--gold-2));
}
.bonus-icon svg { width: 22px; height: 22px; }
.bonus-info { flex: 1; min-width: 0; }
.bonus-title { font-weight: 700; font-size: 14px; }
.bonus-btn {
  flex: none;
  padding: 10px 14px; border-radius: 12px;
  font-size: 12.5px; font-weight: 800; color: #4a3005;
  background: linear-gradient(120deg, var(--gold), var(--gold-2));
  white-space: nowrap;
}
.bonus-btn:disabled { background: #232c44; color: var(--muted); }

.mission {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: var(--bg-2);
  border: 1px solid var(--stroke);
}
.mission-info { flex: 1; min-width: 0; }
.mission-title { font-weight: 700; font-size: 14.5px; }
.mission-desc { color: var(--muted); font-size: 12px; margin-top: 2px; }
.progress { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); margin-top: 9px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); width: 0; transition: width 0.4s; }
.claim-btn {
  padding: 10px 15px; border-radius: 13px;
  font-size: 13px; font-weight: 800; color: #fff;
  background: linear-gradient(120deg, var(--violet), #6b7bff);
  white-space: nowrap;
}
.claim-btn:disabled { background: #232c44; color: var(--muted); }

/* ---------- wheel ---------- */
.wheel-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#wheelCanvas { width: min(280px, 78vw); height: min(280px, 78vw); touch-action: none; }
.primary {
  padding: 14px 20px; border-radius: 16px;
  font-weight: 800; font-size: 15px; color: #4a3005;
  background: linear-gradient(120deg, var(--gold), var(--gold-2));
  box-shadow: 0 10px 26px rgba(255, 159, 26, 0.28);
}
.primary.big { width: 100%; padding: 16px; font-size: 16px; }
.primary:disabled { filter: grayscale(0.6); opacity: 0.55; box-shadow: none; }
.prize-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 9px; margin-top: 14px; }
.prize {
  padding: 12px 8px; border-radius: 14px; text-align: center;
  background: var(--card); border: 1px solid var(--stroke);
  font-size: 12.5px; color: var(--muted);
}
.prize b { display: block; color: var(--gold); font-size: 16px; margin-bottom: 2px; }

/* ---------- referral ---------- */
.ref-card { text-align: center; }
.ref-code {
  font-size: 34px; font-weight: 800; letter-spacing: 7px;
  color: var(--gold); margin: 10px 0 16px;
  text-shadow: 0 8px 26px rgba(255, 159, 26, 0.3);
}
.ref-actions { display: flex; gap: 10px; }
.ref-actions > * { flex: 1; }
.ghost {
  padding: 14px 18px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke);
  color: var(--text); font-weight: 700; font-size: 14px;
}
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.stat {
  padding: 16px; border-radius: 18px; text-align: center;
  background: var(--card); border: 1px solid var(--stroke);
}
.stat .v { font-size: 26px; font-weight: 800; color: var(--gold); }
.stat .k { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.reward-list { list-style: none; margin: 0; padding: 0; }
.reward-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--stroke); font-size: 13.5px;
}
.reward-list li:last-child { border-bottom: none; }
.reward-list b { color: var(--gold); }
.invitee {
  padding: 12px 14px; border-radius: 14px; background: var(--bg-2);
  border: 1px solid var(--stroke); font-size: 13px;
  display: flex; justify-content: space-between; gap: 10px;
}

/* ---------- wallet ---------- */
.mini-balance {
  margin-top: 12px; padding: 14px 16px;
  border-radius: 16px; background: var(--card);
  border: 1px solid var(--stroke); font-size: 14px;
}
.mini-balance b { color: var(--gold); font-size: 18px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 14px; }
.preset {
  padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 700;
  color: var(--text); background: var(--bg-2); border: 1px solid var(--stroke);
}
.preset.active { border-color: var(--gold); color: var(--gold); background: rgba(255, 207, 92, 0.1); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.form input, .form select {
  background: var(--bg-2); border: 1px solid var(--stroke); color: var(--text);
  padding: 13px 14px; border-radius: 14px; font-size: 15px; outline: none;
}
.form input:focus, .form select:focus { border-color: var(--gold); }
.form .primary { margin-top: 4px; }

.wd-item {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 12px 14px; border-radius: 14px;
  background: var(--bg-2); border: 1px solid var(--stroke); font-size: 13px;
}
.badge { padding: 4px 10px; border-radius: 99px; font-size: 11px; font-weight: 800; text-transform: capitalize; }
.badge-pending { background: rgba(255, 207, 92, 0.15); color: var(--gold); }
.badge-processing { background: rgba(63, 214, 255, 0.15); color: var(--cyan); }
.badge-paid { background: rgba(55, 224, 160, 0.15); color: var(--green); }
.badge-rejected { background: rgba(255, 107, 138, 0.15); color: var(--red); }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 4px; padding: 8px;
  border-radius: 24px;
  background: rgba(12, 17, 32, 0.82);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(20px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  z-index: 50;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px 7px; border-radius: 16px;
  background: transparent; color: var(--muted);
  font-size: 10.5px; font-weight: 600;
  transition: color 0.2s, background 0.2s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active {
  color: var(--gold);
  background: linear-gradient(180deg, rgba(255, 207, 92, 0.14), rgba(255, 207, 92, 0.04));
}

/* ---------- ad overlay ---------- */
.ad-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 22px;
  background: rgba(4, 6, 12, 0.82);
  backdrop-filter: blur(8px);
}
.ad-box {
  width: min(380px, 100%);
  padding: 22px;
  border-radius: 26px;
  background: var(--card-solid);
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.ad-label { font-size: 11px; letter-spacing: 1.6px; color: var(--muted); text-transform: uppercase; }
.ad-visual {
  position: relative; overflow: hidden;
  margin-top: 12px; padding: 34px 18px;
  border-radius: 18px; text-align: center;
  background: linear-gradient(120deg, #241a45, #0e2b3d 55%, #3a2410);
  border: 1px solid var(--stroke);
}
.ad-shine {
  position: absolute; top: -40%; left: -30%;
  width: 40%; height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  transform: rotate(18deg);
  animation: shine 2.2s linear infinite;
}
@keyframes shine { from { left: -40%; } to { left: 110%; } }
.ad-text { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.ad-count { text-align: center; margin: 16px 0 8px; font-size: 30px; font-weight: 800; color: var(--gold); }
.ad-count small { font-size: 12px; color: var(--muted); margin-left: 4px; }
.ad-progress { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.ad-progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--violet)); transition: width 0.2s linear; }

@media (max-width: 380px) {
  .balance-value { font-size: 40px; }
  .ref-code { font-size: 28px; letter-spacing: 5px; }
}
