:root {
  --bg: #0b0812;
  --surface: #15101f;
  --surface-2: #1d1629;
  --surface-3: #261c36;
  --ink: #f8f6fc;
  --sub: #aaa2b8;
  --muted: #82798f;
  --line: rgba(255, 255, 255, .075);
  --violet: #9b6dff;
  --violet-strong: #7d4bf2;
  --gold: #ffd669;
  --mint: #4be2aa;
  --danger: #ff6f86;
  --shadow: 0 14px 34px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 280px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(255, 214, 105, .42);
  outline-offset: 2px;
}
::selection { background: var(--gold); color: #1a1022; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% -8%, rgba(125, 75, 242, .18), transparent 32%),
    var(--bg);
  overflow: clip;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 0;
  margin: 0 0 14px;
  padding: 4px 0 0;
  overflow: visible;
  border: 0;
  background: transparent;
}
.topbar::before, .topbar::after { content: none; display: none; }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-orb {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 14px;
  color: #21152d;
  background: var(--gold);
  box-shadow: 0 8px 20px rgba(255, 190, 69, .18);
}
.brand-orb img { width: 21px; height: 21px; }
.brand-lockup .eyebrow { margin: 0 0 2px; color: #c7b6ff; font-size: 8px; letter-spacing: .13em; }
.brand-lockup h1 { margin: 0; font-size: clamp(14px, 4.2vw, 18px); letter-spacing: -.025em; line-height: 1.08; }
.brand-lockup small { display: block; margin-top: 3px; color: var(--sub); font-size: 10px; }
.balance-pill {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 0 6px;
  min-width: 78px; min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
}
.balance-pill strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.balance-pill small { color: var(--sub); font-size: 8px; letter-spacing: .08em; }

.live-activity {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
  width: auto;
  height: auto;
  min-height: 54px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .16);
}
.live-activity img { width: 32px; height: 32px; }
.live-activity p { min-width: 0; }
.live-activity small { color: var(--mint); font-size: 8px; letter-spacing: .11em; }
.live-activity b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.activity-pulse { width: 7px; height: 7px; background: var(--mint); box-shadow: none; }

main { display: block; }
.page { padding: 0; }
.page.active { animation: page-in .24s cubic-bezier(.2,.75,.3,1) both; }
@keyframes page-in { from { opacity: .45; transform: translateY(6px); } }

.hero {
  height: 194px;
  margin: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  contain: layout paint;
}
.hero-slide { border-radius: 16px; background: #3e2478; }
.hero-slide.cosmic { background: linear-gradient(135deg, #4a2a8d, #9a45bd); }
.hero-slide.channel { background: linear-gradient(135deg, #1b6b5b, #33b687); }
.hero-slide.nft { background: linear-gradient(135deg, #39206f, #764ac2); }
.hero-slide.friends { background: linear-gradient(135deg, #452373, #b43d8f); }
.hero-copy { width: 66%; padding: 24px 0 30px 20px; }
.hero-kicker { color: #ffe28c; font-size: 8px; letter-spacing: .14em; }
.hero h2 { margin: 7px 0 8px; color: #fff; font-size: clamp(27px, 9vw, 36px); line-height: .95; letter-spacing: -.035em; }
.hero p { max-width: 29ch; margin: 0; color: rgba(255,255,255,.84); font-size: 11px; line-height: 1.35; }
.hero-action {
  min-height: 38px;
  margin-top: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #28143d;
  font-size: 10px;
  font-weight: 800;
}
.hero-art { right: -15%; top: 2%; width: 70%; height: 98%; filter: none; }
.hero-gift, .hero-nft { filter: none; }
.hero-dots { bottom: 12px; left: 20px; gap: 5px; }
.hero-dots button { width: 6px; height: 6px; background: rgba(255,255,255,.38); box-shadow: none; }
.hero-dots button.active { width: 22px; background: #fff; }

.streak-strip, .quick-promo, .reminder-banner {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: none;
}
.streak-strip { margin-top: 12px; padding: 12px; }
.streak-strip b { font-size: 12px; }
.streak-strip small { font-size: 9px; color: var(--sub); }
.streak-orb { width: 34px; height: 34px; box-shadow: none; }
.quick-promo { min-height: 68px; margin-top: 10px; padding: 11px 12px; }
.quick-promo-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: rgba(255,214,105,.12); }
.quick-promo-icon img { width: 22px; height: 22px; color: var(--gold); }
.quick-promo b { font-size: 12px; }
.quick-promo small { margin-top: 2px; color: var(--sub); font-size: 9px; }
.quick-promo button { width: 42px; height: 42px; border: 1px solid var(--line); background: var(--surface-3); color: var(--ink); }

.section-heading { margin: 24px 0 12px; }
.section-heading .eyebrow, .page-title .eyebrow, .eyebrow { color: #aa93df; font-size: 8px; letter-spacing: .12em; }
.section-heading h3 { margin: 2px 0 0; font-size: 25px; line-height: 1; letter-spacing: -.035em; }
.ready-count { padding: 7px 10px; border-radius: 10px; background: rgba(75,226,170,.12); color: var(--mint); font-size: 10px; }

.case-list { display: grid; gap: 10px; }
.case-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
  content-visibility: auto;
  contain-intrinsic-size: 116px;
}
.case-card::before, .case-card::after { display: none; }
.case-art { width: 82px; height: 82px; filter: none; }
.case-card h4 { font-size: 17px; letter-spacing: -.02em; }
.case-card p { margin: 4px 0 10px; color: var(--sub); font-size: 10px; }
.case-meta { align-items: center; }
.reward-range { color: var(--gold); font-size: 13px; font-variant-numeric: tabular-nums; }
.status-badge { color: var(--mint); font-size: 8px; }
.open-button, .primary-button, .premium-button {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: var(--violet-strong);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(83, 39, 172, .22);
}
.open-button:disabled, .primary-button:disabled, .premium-button:disabled { background: #2b2435; color: #7e7589; box-shadow: none; }

.reminder-banner { margin: 12px 0; padding: 13px; }
.reminder-banner b { font-size: 11px; }
.reminder-banner small { color: var(--sub); font-size: 9px; line-height: 1.3; }
.reminder-banner em { color: var(--mint); background: rgba(75,226,170,.1); }
.bonus-case { border: 0; border-radius: 16px; background: #31204d; box-shadow: var(--shadow); }

.page-title {
  margin: 0 -16px 16px;
  padding: 22px 18px 24px;
  border-radius: 0 0 20px 20px;
  background: #281940;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.page-title h2 { margin: 2px 0 0; font-size: 30px; letter-spacing: -.035em; }
.title-icon { width: 46px; height: 46px; border: 0; border-radius: 14px; background: rgba(155,109,255,.18); }
.title-icon img { width: 23px; height: 23px; }
.task-summary { gap: 10px; }
.task-summary > div { min-height: 76px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: none; color: var(--ink); }
.task-summary span { color: var(--sub); font-size: 10px; }
.task-summary strong { font-size: 22px; }
.segment-control { margin: 12px 0; padding: 3px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.segment-control button { min-height: 42px; color: var(--sub); font-size: 11px; }
.segment-control button.active { background: var(--surface-3); color: #fff; box-shadow: none; }
.task-list, .my-tasks { gap: 9px; }
.task-card, .task-card.user-task {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: none;
  color: var(--ink);
}
.task-logo { width: 44px; height: 44px; border-radius: 13px; background: rgba(155,109,255,.12) !important; color: var(--violet); }
.task-logo img { width: 22px; height: 22px; }
.task-card h3 { margin: 0 0 4px; font-size: 12px; line-height: 1.2; }
.task-card p { color: var(--sub); font-size: 9px; }
.task-chip { margin-top: 5px !important; background: rgba(75,226,170,.1) !important; color: var(--mint) !important; }
.task-reward b { color: var(--gold); font-size: 12px; white-space: nowrap; }
.task-reward button { min-height: 36px; margin-top: 5px; padding: 0 11px; border-radius: 11px; background: rgba(155,109,255,.13); color: #cdbaff; }
.premium-quest, .creator-card, .campaign { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: none; }

.wheel-hero, .balance-card, .profile-card, .admin-hero { border-radius: 16px; box-shadow: var(--shadow); }
.wheel-hero { background: #34205a; }
.main-wheel-card { border: 1px solid var(--line) !important; background: var(--surface) !important; }
.wheel-machine::before { animation-duration: 16s; opacity: .35; }
.wheel-control button { min-height: 44px; border-radius: 13px; background: var(--violet-strong) !important; }
.roulette-card {
  display: flex;
  flex-direction: column;
  min-height: 228px !important;
  padding: 18px !important;
  border: 1px solid var(--line);
  border-radius: 16px !important;
  background: var(--surface);
  box-shadow: none;
}
.roulette-card .roulette-art {
  top: 14px !important;
  right: 14px !important;
  width: 84px !important;
  height: 84px !important;
}
.roulette-card .case-tier {
  position: relative;
  z-index: 4;
  max-width: calc(100% - 98px) !important;
}
.roulette-card > h3 {
  position: relative;
  z-index: 2;
  max-width: calc(100% - 98px) !important;
  margin: 34px 0 0 !important;
  padding: 0 !important;
  line-height: 1.18;
}
.roulette-card > p {
  position: relative;
  z-index: 2;
  min-height: 0 !important;
  max-width: calc(100% - 98px) !important;
  margin: 6px 0 0 !important;
  padding: 0 !important;
  line-height: 1.45;
}
.roulette-card .ref-case-progress {
  position: relative !important;
  inset: auto !important;
  width: 100%;
  flex: 0 0 5px;
  margin: 14px 0 0 !important;
}
.roulette-card footer {
  position: relative !important;
  inset: auto !important;
  width: 100%;
  min-height: 42px;
  margin: 10px 0 0 !important;
}
.roulette-card footer b {
  line-height: 1.25;
  white-space: nowrap;
}
.roulette-card footer button { min-height: 42px; }

.wallet-card { background: #2f1e4a; }
.panel, .history-block, .stats-grid div, .info-row, .admin-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}
.panel p, .panel li, .stats-grid span, .profile-card span, .info-row small { color: var(--sub); }
.profile-card { background: #38215d; }
.leaderboard-entry { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: none; }
.gift-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: none; }

input, select {
  min-height: 46px;
  border: 1px solid var(--line) !important;
  border-radius: 12px !important;
  background: #0f0b17 !important;
  color: var(--ink) !important;
}
.bottom-nav {
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(calc(100% - 20px), 460px);
  min-height: 68px;
  padding: 7px 6px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: rgba(21,16,31,.96);
  box-shadow: 0 18px 40px rgba(0,0,0,.5);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}
.bottom-nav button { min-width: 0; min-height: 54px; gap: 3px; border-radius: 13px; color: #837b90; }
.bottom-nav button span { width: 24px; height: 24px; display: grid; place-items: center; }
.bottom-nav button span img { width: 21px; height: 21px; }
.bottom-nav button b { font-size: 9px; }
.bottom-nav button.active { background: rgba(155,109,255,.14); color: #d7c8ff; }
.bottom-nav button.active::after { display: none; }

.modal-backdrop { background: rgba(4,2,8,.78); backdrop-filter: blur(4px); }
.reward-dialog, .sheet-dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 30px 70px rgba(0,0,0,.6); }
.toast { border: 1px solid var(--line); background: #241a32; color: #fff; box-shadow: var(--shadow); }

@media (max-width: 360px) {
  .app-shell { padding-inline: 12px; }
  .page-title { margin-inline: -12px; }
  .brand-lockup small { display: none; }
  .balance-pill { min-width: 70px; padding-inline: 9px; }
  .hero { height: 184px; }
  .hero-copy { width: 70%; padding-left: 17px; }
  .hero h2 { font-size: 28px; }
  .hero p { font-size: 10px; }
  .case-card { grid-template-columns: 70px minmax(0,1fr); }
  .case-art { width: 68px; height: 68px; }
  .task-card, .task-card.user-task { grid-template-columns: 38px minmax(0,1fr) auto; gap: 8px; }
  .task-logo { width: 38px; height: 38px; }
  .task-reward button { padding-inline: 8px; }
  .roulette-card { min-height: 220px !important; padding: 16px !important; }
  .roulette-card .roulette-art { top: 12px !important; right: 12px !important; width: 76px !important; height: 76px !important; }
  .roulette-card > h3 { max-width: calc(100% - 88px) !important; margin-top: 28px !important; }
  .roulette-card > p { max-width: calc(100% - 88px) !important; }
  .bottom-nav button b { font-size: 8px; }
}

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 28px 80px rgba(0,0,0,.5); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-reduced-data: reduce) {
  .hero-art, .reward-rays, .wheel-machine::before { display: none !important; }
}
