/* ============================================================================
   MageXL — Quick Earn Design System  v2.0
   Single source of truth for tokens + components.
   • Telegram theme-aware (light / dark) via [data-theme]
   • Mobile-first, safe-area aware, no framework dependency
   ========================================================================== */

/* ─────────────────────────── 1. DESIGN TOKENS ─────────────────────────── */
:root {
  /* — brand ramp — */
  --brand-50:  #eef4ff;
  --brand-100: #d9e5ff;
  --brand-300: #93b0ff;
  --brand-400: #6d92ff;
  --brand-500: #4f7cff;   /* primary */
  --brand-600: #3a62e0;
  --brand-700: #2b4ab8;

  /* — accent / semantic — */
  --accent:      #00d4c8;
  --accent-soft: rgba(0, 212, 200, .14);
  --success:     #22c55e;
  --success-soft:rgba(34, 197, 94, .14);
  --danger:      #ef4444;
  --danger-soft: rgba(239, 68, 68, .14);
  --warning:     #f5a524;
  --warning-soft:rgba(245, 165, 36, .15);
  --gold:        #ffc94d;
  --gold-soft:   rgba(255, 201, 77, .15);
  --purple:      #8b5cf6;
  --purple-soft: rgba(139, 92, 246, .15);
  --sky:         #2aabee;
  --sky-soft:    rgba(42, 171, 238, .15);
  --pink:        #fe2c55;
  --pink-soft:   rgba(254, 44, 85, .14);

  /* — spacing scale (4pt) — */
  --s-0: 0;  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

  /* — radius — */
  --r-xs: 8px; --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px; --r-full: 999px;

  /* — typography — */
  --font: 'Inter', 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-bn: 'Hind Siliguri', 'Inter', system-ui, sans-serif;
  --fs-2xs: 10.5px; --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-md: 14px;
  --fs-lg: 16px; --fs-xl: 19px; --fs-2xl: 24px; --fs-3xl: 30px; --fs-4xl: 38px;

  /* — layout — */
  --app-max: 480px;
  --header-h: 60px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* — motion — */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur-fast: .14s;
  --dur: .22s;
}

/* ── DARK (default brand look) ─────────────────────────────────────────── */
:root, [data-theme="dark"] {
  --bg:            #070d1c;
  --bg-2:          #0b1226;
  --bg-grad: radial-gradient(1100px 620px at 12% -8%, rgba(79,124,255,.20), transparent 58%),
             radial-gradient(900px 520px at 100% 4%, rgba(0,212,200,.13), transparent 55%),
             radial-gradient(800px 480px at 50% 108%, rgba(139,92,246,.12), transparent 60%),
             linear-gradient(180deg, #070d1c 0%, #060a15 100%);
  --surface:       rgba(255,255,255,.055);
  --surface-2:     rgba(255,255,255,.085);
  --surface-solid: #101a30;
  --surface-hi:    #16223c;
  --border:        rgba(255,255,255,.11);
  --border-strong: rgba(255,255,255,.20);
  --text:          #eef2fb;
  --text-2:        #c3cde2;
  --text-3:        #93a0bc;
  --overlay:       rgba(3,7,16,.76);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.30);
  --shadow:    0 10px 28px rgba(0,0,0,.38);
  --shadow-lg: 0 20px 52px rgba(0,0,0,.50);
  --skeleton-a: rgba(255,255,255,.06);
  --skeleton-b: rgba(255,255,255,.13);
  color-scheme: dark;
}

/* ── LIGHT ─────────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:            #f4f6fb;
  --bg-grad: radial-gradient(1000px 560px at 10% -6%, rgba(79,124,255,.16), transparent 58%),
             radial-gradient(820px 460px at 100% 2%, rgba(0,212,200,.13), transparent 55%),
             linear-gradient(180deg, #f7f9fe 0%, #eef1f8 100%);
  --surface:       #ffffff;
  --surface-2:     #f7f9fd;
  --surface-solid: #ffffff;
  --surface-hi:    #eef2fa;
  --border:        rgba(15,23,42,.10);
  --border-strong: rgba(15,23,42,.18);
  --text:          #0f172a;
  --text-2:        #3a4360;   /* secondary text — AA on light surfaces */
  --text-3:        #5f6a85;   /* muted text — still >= 4.5:1 on --surface */
  --overlay:       rgba(15,23,42,.42);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.07);
  --shadow:    0 8px 22px rgba(15,23,42,.09);
  --shadow-lg: 0 18px 44px rgba(15,23,42,.15);
  --skeleton-a: rgba(15,23,42,.06);
  --skeleton-b: rgba(15,23,42,.12);
  color-scheme: light;
}
/* dark background tokens (light theme overrides these above) */
:root { --bg-2: #0b1226; }

/* ─────────────────────────── 2. RESET / BASE ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  /* room for the fixed tab bar (incl. the iOS safe area) so nothing sits under it */
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-8));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
html[data-lang="bn"] body { font-family: var(--font-bn); }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4,h5 { margin: 0; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
p { margin: 0 0 var(--s-2); }

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }

/* ─────────────────────────── 3. LAYOUT ─────────────────────────── */
.container {
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  /* generous bottom padding — several pages render their own <main> and the
     fixed tab bar must never cover the last card/button */
  padding: var(--s-4) var(--s-4) calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-6));
}
.app-shell { padding-top: calc(var(--header-h) + var(--safe-top)); }
.row { display: flex; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.row-center  { display: flex; align-items: center; gap: var(--s-3); }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.mt-0{margin-top:0}.mt-1{margin-top:var(--s-2)}.mt-2{margin-top:var(--s-4)}.mt-3{margin-top:var(--s-6)}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:var(--s-2)}.mb-2{margin-bottom:var(--s-4)}.mb-3{margin-bottom:var(--s-6)}
.center{text-align:center}.bold{font-weight:800}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

/* ─────────────────────────── 4. HEADER ─────────────────────────── */
.app-header {
  position: fixed; inset: 0 0 auto 0; z-index: 60;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--s-4) 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.hd-left { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.hd-logo {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px;
  display: grid; place-items: center; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--accent));
  box-shadow: 0 6px 16px rgba(79,124,255,.35);
}
.hd-title { font-size: var(--fs-md); font-weight: 800; letter-spacing: -.01em; }
.hd-sub { font-size: var(--fs-2xs); color: var(--text-3); font-weight: 600; }
.hd-actions { display: flex; align-items: center; gap: var(--s-2); }
.hd-balance {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 800; white-space: nowrap;
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid rgba(255,201,77,.30);
}
.icon-btn {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  font-size: 14px; cursor: pointer; transition: transform var(--dur-fast) var(--ease), background var(--dur-fast);
}
.icon-btn:active { transform: scale(.93); background: var(--surface-2); }

/* ─────────────────────────── 5. TAB BAR ─────────────────────────── */
.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 60;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
.bottom-nav .nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: var(--fs-2xs); font-weight: 700; color: var(--text-3);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  padding-top: 6px; position: relative;
}
.bottom-nav .nav-item i { font-size: 17px; }
.bottom-nav .nav-item.active { color: var(--brand-400); }
.bottom-nav .nav-item.active::before {
  content: ''; position: absolute; top: 0; width: 26px; height: 3px;
  border-radius: 0 0 4px 4px; background: linear-gradient(90deg, var(--brand-500), var(--accent));
}
.bottom-nav .nav-item:active { transform: scale(.9); }
[data-theme="light"] .bottom-nav .nav-item.active { color: var(--brand-600); }

/* ─────────────────────────── 6. CARDS ─────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  margin-bottom: var(--s-3);
}
.card-plain { background: var(--surface-2); box-shadow: none; }
.card-tight { padding: var(--s-3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.card-title { font-size: var(--fs-md); font-weight: 800; display: flex; align-items: center; gap: var(--s-2); }

/* section title */
.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  font-size: var(--fs-sm); font-weight: 800; color: var(--text-2);
  text-transform: none; letter-spacing: .01em;
  margin: var(--s-5) 0 var(--s-3);
}
.section-title i { color: var(--brand-400); }
.section-title .more { font-size: var(--fs-xs); font-weight: 700; color: var(--brand-400); }

/* ─────────────────────────── 7. HERO / BALANCE ─────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl);
  padding: var(--s-5);
  margin-bottom: var(--s-3);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-500) 42%, var(--accent) 130%);
  box-shadow: 0 14px 34px rgba(58,98,224,.34);
}
.hero::after {
  content: ''; position: absolute; inset: -40% -20% auto auto; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255,255,255,.13); filter: blur(6px);
}
.hero::before {
  content: ''; position: absolute; inset: auto auto -60% -20%; width: 200px; height: 200px;
  border-radius: 50%; background: rgba(255,255,255,.09);
}
.hero > * { position: relative; z-index: 1; }
.hero-label { font-size: var(--fs-xs); font-weight: 700; opacity: .9; display: flex; align-items: center; gap: 6px; }
.hero-amount { font-size: var(--fs-4xl); font-weight: 900; letter-spacing: -.03em; line-height: 1.1; margin: var(--s-1) 0 var(--s-3); }
.hero-amount .cur { font-size: var(--fs-lg); font-weight: 700; opacity: .88; }
.hero-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ─────────────────────────── 8. CHIPS / BADGES / PILLS ─────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: var(--r-full);
  font-size: var(--fs-2xs); font-weight: 700; white-space: nowrap;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.24); color: #fff;
}
.chip.sky    { background: var(--sky-soft);     border-color: rgba(42,171,238,.32);  color: var(--sky); }
.chip.green  { background: var(--success-soft); border-color: rgba(34,197,94,.32);   color: #4ade80; }
.chip.gold   { background: var(--gold-soft);    border-color: rgba(255,201,77,.34);  color: var(--gold); }
.chip.pink   { background: var(--pink-soft);    border-color: rgba(254,44,85,.32);   color: #ff7f9e; }
.chip.purple { background: var(--purple-soft);  border-color: rgba(139,92,246,.32);  color: #b193ff; }
.chip.plain  { background: var(--surface);      border-color: var(--border);         color: var(--text-2); }
[data-theme="light"] .chip.green { color: #15803d; }
[data-theme="light"] .chip.sky   { color: #0369a1; }
[data-theme="light"] .chip.gold  { color: #a16207; }
[data-theme="light"] .chip.pink  { color: #be123c; }
[data-theme="light"] .chip.purple{ color: #6d28d9; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: var(--fs-2xs); font-weight: 800; border: 1px solid transparent;
}
.badge.pending  { background: var(--warning-soft); color: #d97706; border-color: rgba(245,165,36,.32); }
.badge.approved { background: var(--success-soft); color: #16a34a; border-color: rgba(34,197,94,.32); }
.badge.rejected { background: var(--danger-soft);  color: #dc2626; border-color: rgba(239,68,68,.32); }
[data-theme="dark"] .badge.pending  { color: var(--warning); }
[data-theme="dark"] .badge.approved { color: #4ade80; }
[data-theme="dark"] .badge.rejected { color: #f87171; }

/* ─────────────────────────── 9. BUTTONS ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 13px 18px; border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 800; letter-spacing: .01em;
  border: 1px solid transparent; cursor: pointer; position: relative;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff; box-shadow: 0 6px 18px rgba(79,124,255,.30);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast), opacity var(--dur-fast);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.972); box-shadow: 0 3px 10px rgba(79,124,255,.26); }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 14px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn.lg { padding: 16px 22px; font-size: var(--fs-lg); }
.btn.green  { background: linear-gradient(135deg, #22c55e, #15a34a); box-shadow: 0 6px 18px rgba(34,197,94,.30); }
.btn.gold   { background: linear-gradient(135deg, #ffc94d, #f59e0b); color: #241700; box-shadow: 0 6px 18px rgba(245,165,36,.32); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 6px 18px rgba(239,68,68,.30); }
.btn.ghost {
  background: var(--surface); color: var(--text-2);
  border-color: var(--border); box-shadow: none;
}
.btn.ghost:active { background: var(--surface-2); }
.btn.outline { background: transparent; color: var(--brand-400); border-color: var(--border-strong); box-shadow: none; }
.btn[disabled], .btn.is-locked { opacity: .55; cursor: not-allowed; filter: grayscale(.4); transform: none; box-shadow: none; }
.btn-row { display: flex; gap: var(--s-2); }
.btn-row .btn { flex: 1; }

/* ─────────────────────────── 10. KPI / STAT CARDS ─────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-4); box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast);
  min-width: 0;   /* let long numbers shrink instead of clipping */
}
.kpi > * { max-width: 100%; }
.kpi .k-val, .kpi [class*="val"], .kpi [class*="num"] {
  font-variant-numeric: tabular-nums; line-height: 1.15; word-break: break-word;
}
.kpi:active { transform: scale(.98); }
.k-icon {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  font-size: 15px; margin-bottom: var(--s-3);
  background: var(--brand-500);
  color: #fff;
}
.k-icon.sky    { background: linear-gradient(135deg,#2aabee,#1d84c4); }
.k-icon.green  { background: linear-gradient(135deg,#22c55e,#15a34a); }
.k-icon.gold   { background: linear-gradient(135deg,#ffc94d,#f59e0b); color:#241700; }
.k-icon.pink   { background: linear-gradient(135deg,#fe2c55,#d31b40); }
.k-icon.purple { background: linear-gradient(135deg,#8b5cf6,#6d38e0); }
.k-val { font-size: var(--fs-xl); font-weight: 900; letter-spacing: -.02em; }
.k-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 700; margin-top: 2px; }

/* ─────────────────────────── 11. PROGRESS ─────────────────────────── */
.progress-track {
  height: 9px; border-radius: var(--r-full); overflow: hidden;
  background: var(--surface-hi); border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; width: 0; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-500), var(--accent));
  transition: width .6s var(--ease);
}
.progress-ring { --p: 0; width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--brand-500) calc(var(--p) * 1%), var(--surface-hi) 0); }
.progress-ring span { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-solid);
  display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 800; }

/* ─────────────────────────── 12. LISTS / ROWS ─────────────────────────── */
.list { display: flex; flex-direction: column; gap: var(--s-2); }
.list-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease);
}
.list-row:active { transform: scale(.99); background: var(--surface-2); }
.list-ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; display: grid; place-items: center;
  font-size: 15px; background: var(--surface-hi); color: var(--brand-400);
}
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: var(--fs-sm); font-weight: 800; }
.list-sub { font-size: var(--fs-2xs); color: var(--text-3); font-weight: 600; }
.list-val { font-size: var(--fs-sm); font-weight: 800; white-space: nowrap; }
.chev { color: var(--text-3); font-size: 12px; }

/* ─────────────────────────── 13. TASK / CONTENT CARDS ─────────────────────────── */
.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-4); box-shadow: var(--shadow-sm); margin-bottom: var(--s-3);
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast);
}
.task-card:active { transform: scale(.99); }
.tc-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.tc-icon {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px; display: grid; place-items: center;
  font-size: 17px; background: var(--brand-500); color: #fff;
}
.tc-icon.sky{background:linear-gradient(135deg,#2aabee,#1d84c4)}
.tc-icon.green{background:linear-gradient(135deg,#22c55e,#15a34a)}
.tc-icon.gold{background:linear-gradient(135deg,#ffc94d,#f59e0b);color:#241700}
.tc-icon.pink{background:linear-gradient(135deg,#fe2c55,#d31b40)}
.tc-icon.purple{background:linear-gradient(135deg,#8b5cf6,#6d38e0)}
.tc-title { font-size: var(--fs-md); font-weight: 800; }
.tc-sub { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.tc-desc { font-size: var(--fs-sm); color: var(--text-2); margin: var(--s-2) 0 var(--s-3); }
.tc-reward {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--gold-soft); border: 1px solid rgba(255,201,77,.30);
  color: var(--gold); font-size: var(--fs-xs); font-weight: 800;
}
[data-theme="light"] .tc-reward { color: #a16207; }

/* ─────────────────────────── 14. FORMS ─────────────────────────── */
.form-group { margin-bottom: var(--s-4); }
.form-label { display: flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 800; color: var(--text-2); margin-bottom: var(--s-2); }
.form-label i { color: var(--brand-400); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 13px 15px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: var(--fs-md); font-weight: 600;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
  -webkit-appearance: none; appearance: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); font-weight: 500; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(79,124,255,.18); background: var(--surface);
}
.form-input.err { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.form-hint { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 5px; font-weight: 600; }
.form-err  { font-size: var(--fs-2xs); color: var(--danger); margin-top: 5px; font-weight: 700; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237f8ca6' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center; padding-right: 40px;
}
.input-row { display: flex; gap: var(--s-2); align-items: stretch; }
.input-row .form-input { flex: 1; }
.switch { position: relative; width: 46px; height: 27px; flex: 0 0 46px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--surface-hi); border: 1px solid var(--border); cursor: pointer; transition: background var(--dur) var(--ease); }
.switch .slider::before { content: ''; position: absolute; width: 21px; height: 21px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: linear-gradient(135deg, var(--brand-500), var(--accent)); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(19px); }

/* ─────────────────────────── 15. ALERTS ─────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.5;
  border: 1px solid var(--border); background: var(--surface-2); margin-bottom: var(--s-3);
}
.alert i { margin-top: 2px; }
.alert-success { background: var(--success-soft); border-color: rgba(34,197,94,.32); color: #16a34a; }
.alert-error   { background: var(--danger-soft);  border-color: rgba(239,68,68,.32);  color: #dc2626; }
.alert-warning { background: var(--warning-soft); border-color: rgba(245,165,36,.32); color: #b45309; }
.alert-info    { background: var(--sky-soft);     border-color: rgba(42,171,238,.30); color: #0369a1; }
[data-theme="dark"] .alert-success { color: #4ade80; }
[data-theme="dark"] .alert-error   { color: #f87171; }
[data-theme="dark"] .alert-warning { color: var(--warning); }
[data-theme="dark"] .alert-info    { color: #6cc9f5; }

/* ─────────────────────────── 16. EMPTY / SKELETON ─────────────────────────── */
.empty { text-align: center; padding: var(--s-7) var(--s-4); }
.empty .e-icon { font-size: 40px; margin-bottom: var(--s-3); opacity: .85; }
.empty p { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; margin: 0; }
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 37%, var(--skeleton-a) 63%);
  background-size: 400% 100%; animation: sk 1.35s ease infinite;
}
.skeleton.line { height: 12px; margin-bottom: var(--s-2); }
.skeleton.line.w60 { width: 60%; } .skeleton.line.w40 { width: 40%; }
.skeleton.card { height: 96px; margin-bottom: var(--s-3); }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ─────────────────────────── 17. TOAST ─────────────────────────── */
.toast-container {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-4));
  z-index: 200; display: flex; flex-direction: column; gap: var(--s-2);
  width: min(calc(100% - 32px), 420px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 13px 16px; border-radius: var(--r-md);
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: 700;
  color: var(--text); animation: toastIn .26s var(--ease);
}
.toast i { font-size: 16px; flex: 0 0 16px; }
.toast.success i { color: var(--success); }
.toast.error   i { color: var(--danger); }
.toast.info    i { color: var(--sky); }
.toast.warning i { color: var(--warning); }
.toast.out { animation: toastOut .22s var(--ease) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ─────────────────────────── 18. MODAL / SHEET ─────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 150; background: var(--overlay);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s var(--ease);
}
.modal-box {
  width: 100%; max-width: var(--app-max);
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-5) var(--s-4) calc(var(--s-5) + var(--safe-bottom));
  box-shadow: var(--shadow-lg); animation: sheetUp .28s var(--ease);
  max-height: 86vh; overflow-y: auto;
}
.modal-grab { width: 42px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto var(--s-4); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* notice popup (legacy class kept working) */
.notice-popup { position: fixed; inset: 0; z-index: 150; background: var(--overlay); display: grid; place-items: center; padding: var(--s-4); }
.notice-box { width: 100%; max-width: 400px; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--s-5); box-shadow: var(--shadow-lg); }
.notice-title { font-size: var(--fs-lg); font-weight: 800; display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); }
.notice-body { font-size: var(--fs-sm); color: var(--text-2); }

/* ─────────────────────────── 19. LOADER ─────────────────────────── */
.spin-ring {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3.5px solid var(--border); border-top-color: var(--brand-500);
  animation: spin .85s linear infinite; margin: 0 auto var(--s-4);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-wrap {
  min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100vh);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-2); padding: var(--s-6) var(--s-4); text-align: center;
}
.loader-logo {
  width: 74px; height: 74px; border-radius: 22px; display: grid; place-items: center; font-size: 32px;
  background: linear-gradient(135deg, var(--brand-500), var(--accent));
  box-shadow: 0 16px 40px rgba(79,124,255,.42); margin-bottom: var(--s-3);
}
.loader-title { font-size: var(--fs-3xl); font-weight: 900; letter-spacing: -.03em; }
.loader-sub { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.steps-row { display: flex; align-items: center; justify-content: center; gap: var(--s-2); margin: var(--s-4) 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: var(--fs-2xs); color: var(--text-3); font-weight: 700; }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-hi); border: 1px solid var(--border); font-size: var(--fs-2xs); font-weight: 800;
  transition: all var(--dur) var(--ease);
}
.step.done .step-dot { background: linear-gradient(135deg, var(--brand-500), var(--accent)); color: #fff; border-color: transparent; }
.step.done { color: var(--text-2); }
.step-line { width: 26px; height: 2px; background: var(--border); border-radius: 2px; }
.emoji-lg { font-size: 44px; }

/* ─────────────────────────── 20. TABLE ─────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; padding: var(--s-3); font-size: var(--fs-2xs); font-weight: 800;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.table td { padding: var(--s-3); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text-2); }
.table tr:last-child td { border-bottom: none; }
.table td.amount { font-weight: 800; color: var(--text); }
.table td.date { font-size: var(--fs-2xs); color: var(--text-3); white-space: nowrap; }

/* ─────────────────────────── 21. VIDEO ─────────────────────────── */
.video-wrap {
  position: relative; width: 100%; padding-top: 56.25%; border-radius: var(--r-lg);
  overflow: hidden; border: 1px solid var(--border); background: #000; margin-bottom: var(--s-3);
}
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ─────────────────────────── 22. LANGUAGE SWITCHER ─────────────────────────── */
.lang-switch {
  display: inline-flex; padding: 3px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border); gap: 2px;
}
.lang-switch a {
  padding: 5px 11px; border-radius: var(--r-full); font-size: var(--fs-2xs); font-weight: 800;
  color: var(--text-3); transition: all var(--dur-fast) var(--ease);
}
.lang-switch a.on { background: linear-gradient(135deg, var(--brand-500), var(--accent)); color: #fff; }

/* ─────────────────────────── 23. MISC ─────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--s-4) 0; }
.refer-box {
  background: linear-gradient(135deg, rgba(79,124,255,.10), rgba(0,212,200,.07)), var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); margin-bottom: var(--s-3);
}
.refer-link-box { display: flex; gap: var(--s-2); align-items: center; margin: var(--s-3) 0; }
.refer-link {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  font-size: var(--fs-2xs); font-weight: 600; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr;
}
.muted { color: var(--text-3); }
.small { font-size: var(--fs-xs); }
.fade-in { animation: fadeIn .3s var(--ease); }
.pull-refresh-hint { text-align: center; font-size: var(--fs-2xs); color: var(--text-3); padding: var(--s-2); font-weight: 600; }

/* ═══════════════════ 24. LEGACY COMPATIBILITY ALIASES ═══════════════════
   Older pages (contest.php, admin, gigapub) still use the v1 class names and
   CSS variables. These aliases keep them looking correct on the new tokens
   without touching their markup.                                             */
:root {
  --sky-2: var(--sky);
  --navy-2: var(--surface-2);
  --navy: var(--bg);
  --sky-soft: rgba(42,171,238,.15);
  --grad: var(--bg-grad);
  --green: var(--success);
  --red: var(--danger);
}
.flex { display: flex; gap: var(--s-3); align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.tgroup { display: block; }
.tc-actions { display: flex; gap: var(--s-2); margin-top: var(--s-3); }
.tc-actions .btn { flex: 1; }
.msg-box { display: none; }
.tt-bar { height: 5px; border-radius: 4px; background: var(--surface-hi); overflow: hidden; margin: 8px 0 4px; }
.tt-bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #25F4EE, #FE2C55); transition: width .9s linear; }
.tt-lock-note { display: flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 700; margin: 4px 0 8px; color: var(--warning); }
.tt-lock-note.ok { color: #4ade80; }
[data-theme="light"] .tt-lock-note { color: #b45309; }
[data-theme="light"] .tt-lock-note.ok { color: #15803d; }
.kb { display: inline-flex; align-items: center; gap: 5px; border-radius: var(--r-full); padding: 3px 10px;
      font-size: var(--fs-2xs); font-weight: 800; border: 1px solid transparent; }
.kb.tg { background: var(--sky-soft); border-color: rgba(42,171,238,.38); color: var(--sky); }
.kb.yt { background: var(--danger-soft); border-color: rgba(239,68,68,.34); color: #ff7b74; }
.kb.tt { background: var(--pink-soft); border-color: rgba(254,44,85,.34); color: #ff7f9e; }
.kb.done { background: var(--success-soft); border-color: rgba(34,197,94,.34); color: #4ade80; }
[data-theme="light"] .kb.yt { color: #b91c1c; }
[data-theme="light"] .kb.tt { color: #be123c; }
[data-theme="light"] .kb.done { color: #15803d; }
.flt-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.flt-bar::-webkit-scrollbar { display: none; }
.flt-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 800; white-space: nowrap; cursor: pointer; user-select: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast), color var(--dur-fast); }
.flt-chip .n { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: var(--r-full); background: var(--surface-hi); font-size: var(--fs-2xs); font-weight: 800; }
.flt-chip.on { color: #fff; border-color: transparent; }
.flt-chip.on[data-f="all"] { background: linear-gradient(135deg, var(--brand-500), var(--brand-600)); }
.flt-chip.on[data-f="telegram"] { background: linear-gradient(135deg, #2AABEE, #1d7fb5); }
.flt-chip.on[data-f="youtube"] { background: linear-gradient(135deg, #FF3B30, #b81f18); }
.flt-chip.on[data-f="tiktok"] { background: linear-gradient(135deg, #25F4EE, #FE2C55 70%); }
.flt-chip.on .n { background: rgba(0,0,0,.26); color: #fff; }
.task-card[data-kind] { position: relative; }
a .task-card, a .kpi, a .list-row { color: inherit; }
table.table, .table { color: var(--text-2); }
.alert.mt-2 { margin-top: var(--s-4); }
.btn.block + .btn.block { margin-top: var(--s-2); }
.hero .chip { backdrop-filter: blur(4px); }
.notice-body { line-height: 1.65; }

/* contest.php legacy helpers */
.ct-hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: var(--s-5); color: #fff;
  background: linear-gradient(135deg, #b45309, #f59e0b 55%, #ffc94d); box-shadow: 0 14px 34px rgba(245,165,36,.34); margin-bottom: var(--s-3); }
.ct-tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-full);
  background: rgba(0,0,0,.22); font-size: var(--fs-2xs); font-weight: 800; margin-bottom: var(--s-3); }
.ct-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff5252; box-shadow: 0 0 0 3px rgba(255,82,82,.28); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.ct-title { font-size: var(--fs-2xl); font-weight: 900; letter-spacing: -.02em; }
.ct-title-sub { font-size: var(--fs-sm); opacity: .92; margin-top: 4px; }
.ct-pool { font-size: var(--fs-4xl); font-weight: 900; letter-spacing: -.03em; margin-top: var(--s-3); }
.ct-pool-cur { font-size: var(--fs-lg); font-weight: 700; opacity: .9; }
.req-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); }
.req-box b { color: var(--gold); }
[data-theme="light"] .req-box b { color: #a16207; }

@media (min-width: 520px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── tab-bar clearance for pages that ship their own wrapper ─────────── */
main, .wrap, .page, .app, .content, .main-content, .page-wrap {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-5));
}
@media (min-width: 620px) { main, .wrap, .page, .app, .content { padding-bottom: var(--s-8); } }
/* profile menu list: never hidden behind the nav */
.profile-menu, .menu-list, .settings-list {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-4));
}

/* ============================================================================
   ██  v6 PREMIUM LAYER
   Glassmorphism surfaces · deep gradients · border-glow · layered shadows
   Motion: reveal · shimmer · count-up · confetti · spin wheel
   Light + dark are both first-class.
   ========================================================================== */

:root {
  /* — deeper, richer backgrounds — */
  --grad-deep:   linear-gradient(168deg, #0a1226 0%, #070d1c 44%, #060a15 100%);
  --grad-hero:   linear-gradient(135deg, rgba(79,124,255,.22) 0%, rgba(0,212,200,.13) 48%, rgba(139,92,246,.20) 100%);
  --grad-gold:   linear-gradient(135deg, #ffdf8a 0%, #ffc94d 42%, #f0a01e 100%);
  --grad-glass:  linear-gradient(160deg, rgba(255,255,255,.075) 0%, rgba(255,255,255,.022) 100%);
  --grad-ring:   conic-gradient(from 0deg, rgba(79,124,255,.9), rgba(0,212,200,.75), rgba(139,92,246,.9), rgba(79,124,255,.9));

  /* — glass tokens — */
  --glass-bg:     rgba(255,255,255,.055);
  --glass-brd:    rgba(255,255,255,.105);
  --glass-blur:   blur(18px) saturate(150%);
  --glow-brand:   0 0 0 1px rgba(79,124,255,.35), 0 10px 34px -10px rgba(79,124,255,.55);
  --glow-gold:    0 0 0 1px rgba(255,201,77,.45), 0 10px 40px -8px rgba(255,201,77,.60);

  /* — layered elevation — */
  --el-1: 0 1px 2px rgba(2,6,18,.30), 0 2px 8px rgba(2,6,18,.22);
  --el-2: 0 2px 6px rgba(2,6,18,.34), 0 8px 22px -6px rgba(2,6,18,.40);
  --el-3: 0 4px 12px rgba(2,6,18,.38), 0 18px 44px -10px rgba(2,6,18,.52);
  --el-4: 0 8px 22px rgba(2,6,18,.42), 0 32px 72px -16px rgba(2,6,18,.60);

  --dur-slow: .42s;
  --ease-spring: cubic-bezier(.34, 1.42, .48, 1);
}

[data-theme="light"] {
  --grad-deep:  linear-gradient(168deg, #f7f9ff 0%, #eef2fb 52%, #e8edf8 100%);
  --grad-hero:  linear-gradient(135deg, rgba(79,124,255,.13) 0%, rgba(0,212,200,.09) 48%, rgba(139,92,246,.12) 100%);
  --glass-bg:   rgba(255,255,255,.72);
  --glass-brd:  rgba(15,23,42,.075);
  --glass-blur: blur(18px) saturate(165%);
  --glow-brand: 0 0 0 1px rgba(79,124,255,.22), 0 10px 30px -12px rgba(79,124,255,.42);
  --glow-gold:  0 0 0 1px rgba(226,160,20,.34), 0 10px 34px -10px rgba(226,160,20,.42);
  --el-1: 0 1px 2px rgba(15,23,42,.05), 0 2px 8px rgba(15,23,42,.05);
  --el-2: 0 2px 6px rgba(15,23,42,.06), 0 8px 22px -8px rgba(15,23,42,.11);
  --el-3: 0 4px 12px rgba(15,23,42,.07), 0 18px 42px -12px rgba(15,23,42,.15);
  --el-4: 0 8px 22px rgba(15,23,42,.08), 0 30px 68px -18px rgba(15,23,42,.18);
}

/* ── 1. page canvas ──────────────────────────────────────────────────────── */
body {
  background: var(--grad-deep);
  background-attachment: fixed;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(52% 34% at 12% -6%,  rgba(79,124,255,.20), transparent 70%),
    radial-gradient(46% 30% at 92% 2%,   rgba(0,212,200,.15), transparent 72%),
    radial-gradient(60% 40% at 50% 108%, rgba(139,92,246,.16), transparent 74%);
}
[data-theme="light"] body::before {
  background:
    radial-gradient(52% 34% at 12% -6%,  rgba(79,124,255,.14), transparent 70%),
    radial-gradient(46% 30% at 92% 2%,   rgba(0,212,200,.11), transparent 72%),
    radial-gradient(60% 40% at 50% 108%, rgba(139,92,246,.10), transparent 74%);
}
body > * { position: relative; z-index: 1; }

/* ── 2. glass cards & elevation ──────────────────────────────────────────── */
.card, .task-card, .kpi, .spin-table-card, .contest-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--el-2);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.card, .task-card { border-radius: var(--r-lg); }

/* hairline highlight along the top edge — the "glass" tell */
.card::after, .task-card::after, .kpi::after, .spin-table-card::after {
  content: '';
  position: absolute; inset: 0 0 auto 0;
  height: 1px; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28) 22%, rgba(255,255,255,.28) 78%, transparent);
  pointer-events: none;
}
[data-theme="light"] .card::after,
[data-theme="light"] .task-card::after,
[data-theme="light"] .kpi::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.9) 22%, rgba(255,255,255,.9) 78%, transparent); }
.card, .task-card, .kpi, .spin-table-card { position: relative; overflow: hidden; }

/* interactive lift */
.task-card:active, a .task-card:active { transform: scale(.985); }
@media (hover: hover) {
  .task-card:hover, .kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--el-3);
    border-color: rgba(79,124,255,.32);
  }
}

/* KPI tiles */
.kpi {
  background: var(--grad-glass), var(--glass-bg);
  border-radius: var(--r-md);
  position: relative;
}
.kpi .k-val { font-variant-numeric: tabular-nums; letter-spacing: -.015em; font-weight: 800; }

/* ── 3. header ───────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(180deg, rgba(7,13,28,.92), rgba(7,13,28,.62) 70%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid rgba(255,255,255,.055);
}
[data-theme="light"] .app-header {
  background: linear-gradient(180deg, rgba(247,249,255,.95), rgba(247,249,255,.7) 70%, transparent);
  border-bottom-color: rgba(15,23,42,.06);
}
.hd-balance {
  background: linear-gradient(135deg, rgba(255,201,77,.20), rgba(240,160,30,.10));
  border: 1px solid rgba(255,201,77,.34);
  box-shadow: 0 4px 16px -6px rgba(255,201,77,.45);
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

/* ── 4. buttons ──────────────────────────────────────────────────────────── */
.btn {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  box-shadow: 0 6px 20px -8px rgba(79,124,255,.75), inset 0 1px 0 rgba(255,255,255,.18);
  border: none; border-radius: var(--r-md);
  font-weight: 700; letter-spacing: .005em;
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn:active { transform: scale(.972); filter: brightness(.96); }
.btn:disabled { opacity: .5; filter: grayscale(.35); box-shadow: none; }
.btn.ghost {
  background: var(--glass-bg); border: 1px solid var(--glass-brd); box-shadow: var(--el-1);
}

/* the money badge next to any amount */
.cur-badge {
  display: inline-block; margin-left: 5px; padding: 1px 6px;
  font-size: .68em; font-weight: 800; letter-spacing: .06em; vertical-align: middle;
  color: #0b1020; background: var(--grad-gold); border-radius: var(--r-full);
  box-shadow: 0 2px 10px -3px rgba(255,201,77,.7);
}
[data-theme="light"] .cur-badge { color: #3a2600; }
.amt { font-variant-numeric: tabular-nums; font-weight: 750; letter-spacing: -.01em; }

/* ── 5. motion primitives ────────────────────────────────────────────────── */
[data-reveal] {
  opacity: 0; transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  will-change: opacity, transform;
}
[data-reveal].in { opacity: 1; transform: none; }

.skeleton {
  position: relative; overflow: hidden;
  background: rgba(255,255,255,.07);
  border-radius: var(--r-md);
}
[data-theme="light"] .skeleton { background: rgba(15,23,42,.07); }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.16) 50%, transparent);
  animation: qeShimmer 1.5s infinite;
}
[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.85) 50%, transparent); }
@keyframes qeShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.qe-confetti {
  position: fixed; inset: 0; z-index: 9998;
  pointer-events: none; width: 100%; height: 100%;
}

/* ── 6. SPIN & WIN ───────────────────────────────────────────────────────── */
.spin-wrap { display: block; margin: var(--s-5) 0; }

.spin-hero {
  position: relative; overflow: hidden;
  padding: var(--s-5) var(--s-4) var(--s-5);
  border-radius: var(--r-xl);
  background: var(--grad-hero), var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--el-3);
}
.spin-hero-glow {
  position: absolute; top: -46%; left: 50%; width: 150%; height: 150%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(79,124,255,.30), transparent 72%);
  animation: qePulse 4.5s var(--ease) infinite;
  pointer-events: none;
}
@keyframes qePulse { 0%,100% { opacity: .55; } 50% { opacity: .95; } }

.spin-head { text-align: center; position: relative; }
.spin-title {
  font-size: var(--fs-xl); font-weight: 850; letter-spacing: -.02em;
  background: var(--grad-gold); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.spin-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 3px; }

.spin-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2);
  margin: var(--s-4) 0 var(--s-2);
}
.spin-stat {
  text-align: center; padding: var(--s-2) var(--s-1);
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-brd);
  border-radius: var(--r-md);
}
[data-theme="light"] .spin-stat { background: rgba(255,255,255,.66); }
.spin-stat b {
  display: block; font-size: var(--fs-lg); font-weight: 850;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.spin-stat b i { font-style: normal; font-size: .68em; color: var(--text-3); }
.spin-stat span { display: block; font-size: var(--fs-2xs); color: var(--text-3); margin-top: 1px; }

/* wheel */
.wheel-stage {
  position: relative; width: min(260px, 74vw); aspect-ratio: 1;
  margin: var(--s-5) auto var(--s-3);
}
.wheel-disc {
  position: absolute; inset: 0; border-radius: 50%;
  transition: transform 3.4s cubic-bezier(.16, .84, .22, 1);
  transform: rotate(var(--rot, 0deg));
  box-shadow: 0 0 0 6px rgba(255,255,255,.06), 0 0 0 7px rgba(255,201,77,.30),
              0 18px 46px -14px rgba(0,0,0,.65), inset 0 0 32px rgba(0,0,0,.34);
}
.wheel-disc.spinning { will-change: transform; }
.wheel-face { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.wheel-face::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(closest-side, transparent 58%, rgba(0,0,0,.30) 100%);
  pointer-events: none;
}
.wheel-lab {
  position: absolute; top: 50%; left: 50%;
  font-size: 9.5px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.65);
  font-variant-numeric: tabular-nums; pointer-events: none;
  white-space: nowrap;
}
.wheel-lab.jackpot { color: #3a2600; text-shadow: 0 1px 2px rgba(255,255,255,.5); font-size: 10px; }

.wheel-hub {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 26%; aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-gold);
  color: #2b1c00; font-size: 1.45rem;
  box-shadow: 0 0 0 5px rgba(7,13,28,.72), 0 6px 22px -6px rgba(255,201,77,.85);
  z-index: 2;
}
[data-theme="light"] .wheel-hub { box-shadow: 0 0 0 5px rgba(255,255,255,.92), 0 6px 22px -6px rgba(226,160,20,.7); }

.wheel-pointer {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  z-index: 3; font-size: 2rem; color: var(--gold);
  filter: drop-shadow(0 4px 10px rgba(255,201,77,.85));
}
.wheel-shine {
  position: absolute; inset: -22%; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(255,255,255,.22) 26deg, transparent 52deg);
  animation: qeSpinShine 5.5s linear infinite; mix-blend-mode: screen;
}
@keyframes qeSpinShine { to { transform: rotate(360deg); } }

.spin-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; max-width: 320px; margin: var(--s-2) auto 0;
  padding: 15px 20px; font-size: var(--fs-lg); letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--grad-gold); color: #2b1c00;
  box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255,255,255,.5);
}
.spin-btn i { animation: qeSpinIcon 6s linear infinite; }
@keyframes qeSpinIcon { to { transform: rotate(360deg); } }
.spin-btn:disabled { animation: none; }

.spin-reveal {
  min-height: 0; max-height: 0; overflow: hidden; text-align: center;
  opacity: 0; transition: max-height var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
}
.spin-reveal.show { max-height: 130px; opacity: 1; margin-top: var(--s-2); }
.sr-amt {
  font-size: var(--fs-2xl); font-weight: 900; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--success);
  animation: qePop .5s var(--ease-spring);
}
.spin-reveal.jackpot .sr-amt {
  background: var(--grad-gold); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 16px rgba(255,201,77,.6));
}
.spin-reveal.err .sr-amt, .spin-reveal.err .sr-msg { color: var(--danger); }
.sr-msg { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }
@keyframes qePop { 0% { transform: scale(.6); opacity: 0; } 62% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

.spin-foot {
  text-align: center; font-size: var(--fs-xs); color: var(--text-3);
  margin-top: var(--s-3); line-height: 1.5;
}

/* reward table */
.sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.sec-title { font-size: var(--fs-md); font-weight: 800; display: flex; align-items: center; gap: 7px; }
.sec-sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }

.rw-table { display: flex; flex-direction: column; gap: 7px; }
.rw-row {
  display: grid; grid-template-columns: 88px 1fr 54px;
  align-items: center; gap: var(--s-3);
  padding: 8px 10px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.032); border: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
[data-theme="light"] .rw-row { background: rgba(15,23,42,.035); }
.rw-row:hover { transform: translateX(2px); }
.rw-row.jackpot {
  background: linear-gradient(90deg, rgba(255,201,77,.20), rgba(255,201,77,.05));
  border-color: rgba(255,201,77,.48);
  box-shadow: 0 0 0 1px rgba(255,201,77,.16), 0 6px 22px -10px rgba(255,201,77,.85);
  animation: qeJackpot 2.6s var(--ease) infinite;
}
@keyframes qeJackpot {
  0%,100% { box-shadow: 0 0 0 1px rgba(255,201,77,.16), 0 6px 20px -10px rgba(255,201,77,.75); }
  50%     { box-shadow: 0 0 0 1px rgba(255,201,77,.42), 0 8px 30px -8px rgba(255,201,77,1); }
}
.rw-amt {
  font-weight: 800; font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.rw-row.jackpot .rw-amt { color: var(--gold); }
.rw-tag {
  font-size: 8.5px; font-weight: 900; letter-spacing: .07em;
  padding: 1px 5px; border-radius: var(--r-full);
  background: var(--grad-gold); color: #2b1c00;
}
.rw-bar {
  height: 8px; border-radius: var(--r-full); overflow: hidden;
  background: rgba(255,255,255,.08);
}
[data-theme="light"] .rw-bar { background: rgba(15,23,42,.08); }
.rw-bar i {
  display: block; height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  box-shadow: 0 0 10px -2px rgba(79,124,255,.75);
  transition: width var(--dur-slow) var(--ease);
}
.rw-row.jackpot .rw-bar i { background: var(--grad-gold); box-shadow: 0 0 12px -1px rgba(255,201,77,.9); }
.rw-pct { text-align: right; font-size: var(--fs-xs); font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── 7. referral page ────────────────────────────────────────────────────── */
.ref-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.ref-stat {
  position: relative; overflow: hidden;
  padding: var(--s-4); border-radius: var(--r-md);
  background: var(--grad-glass), var(--glass-bg);
  border: 1px solid var(--glass-brd); box-shadow: var(--el-2);
}
.ref-stat .rs-ico {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; margin-bottom: var(--s-2);
}
.ref-stat .rs-val { font-size: var(--fs-xl); font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ref-stat .rs-lab { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 1px; }

.ref-rule {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(255,201,77,.14), rgba(255,201,77,.04));
  border: 1px solid rgba(255,201,77,.32);
  font-size: var(--fs-sm); line-height: 1.55;
}
.ref-rule i { color: var(--gold); margin-top: 2px; }

.ref-link-box {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 12px; border-radius: var(--r-md);
  background: rgba(0,0,0,.22); border: 1px dashed rgba(79,124,255,.42);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: var(--fs-xs);
  word-break: break-all; color: var(--text-2);
}
[data-theme="light"] .ref-link-box { background: rgba(15,23,42,.045); }

/* ── 8. misc list rows / empty states ────────────────────────────────────── */
.row-line {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 11px 2px; border-bottom: 1px solid var(--glass-brd);
}
.row-line:last-child { border-bottom: none; }
.row-title { font-size: var(--fs-sm); font-weight: 700; }
.row-sub { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 1px; }
.row-amt { font-weight: 800; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.row-amt.ok { color: var(--success); }
.list-ico {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-500-soft, rgba(79,124,255,.15)); color: var(--brand-400);
}
.list-ico.gold { background: var(--gold-soft); color: var(--gold); }

.empty-state {
  text-align: center; padding: var(--s-6) var(--s-4); color: var(--text-3);
}
.empty-state i { font-size: 2rem; opacity: .5; display: block; margin-bottom: var(--s-2); }
.empty-state div { font-size: var(--fs-sm); }

/* ── 9. light-mode contrast fixes ────────────────────────────────────────── */
[data-theme="light"] .muted, [data-theme="light"] .small.muted { color: #55617a; }
[data-theme="light"] .spin-hero-glow { opacity: .6; }
[data-theme="light"] .wheel-disc {
  box-shadow: 0 0 0 6px rgba(255,255,255,.85), 0 0 0 7px rgba(226,160,20,.34),
              0 18px 42px -16px rgba(15,23,42,.30), inset 0 0 26px rgba(0,0,0,.14);
}
[data-theme="light"] .spin-btn { box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255,255,255,.65); }

@media (max-width: 380px) {
  .rw-row { grid-template-columns: 76px 1fr 46px; gap: var(--s-2); }
  .spin-stats { gap: 6px; }
  .ref-grid { gap: var(--s-2); }
}
