:root {
  --bg: #0a0c11;
  --surface: #12151c;
  --surface-2: #181c25;
  --surface-3: #20252f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #f1f3f7;
  --text-2: #b4bac8;
  --muted: #7d8597;
  --accent: #f5b53d;
  --accent-2: #e8892a;
  --accent-ink: #1d1404;
  --accent-soft: rgba(245, 181, 61, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.no-nav { padding-bottom: 24px; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: rgba(10, 12, 17, 0.82); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; flex: 1; min-width: 0; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--accent-ink);
  background: linear-gradient(135deg, #ffd166, var(--accent) 45%, var(--accent-2)); box-shadow: 0 4px 14px rgba(245, 181, 61, 0.35); }
.logo svg.i { width: 17px; height: 17px; stroke-width: 2.4; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-2); font-weight: 700; font-size: 13px; white-space: nowrap; }
.pill .coin { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #ffd166, var(--accent-2)); color: var(--accent-ink); font-size: 10px; font-weight: 900; }
.lang-btn { padding: 0 10px; color: var(--text-2); background: transparent; }
.lang-btn svg.i { width: 15px; height: 15px; }
.menu { position: absolute; right: 16px; top: 54px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); min-width: 150px; z-index: 30; }
.menu button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 0; border-radius: 9px; background: transparent; text-align: left; font-weight: 600; }
.menu button:hover, .menu button.on { background: var(--surface-3); }
.menu button.on::after { content: "✓"; color: var(--accent); }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- typography ---------- */
.h1 { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 24px 2px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.h2:first-child { margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.grad { background: linear-gradient(90deg, #ffd166, var(--accent) 40%, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.card.glow { background: radial-gradient(120% 140% at 0% 0%, rgba(245, 181, 61, 0.16), transparent 55%), var(--surface); border-color: rgba(245, 181, 61, 0.22); }
.card.hl { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border: 0; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px; background: linear-gradient(135deg, #ffcb5c, var(--accent) 50%, var(--accent-2)); color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(232, 137, 42, 0.28); transition: transform .08s ease, opacity .15s ease; white-space: nowrap; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.btn.block { width: 100%; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); box-shadow: none; }
.btn.outline { background: transparent; color: var(--accent); border: 1px solid rgba(245, 181, 61, 0.45); box-shadow: none; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.35); box-shadow: none; }
.btn.done { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(52, 211, 153, 0.3); box-shadow: none; }
.field { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line-strong); transition: border-color .15s; }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .pre { color: var(--muted); font-weight: 700; }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.field input::placeholder { color: #5b6273; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- segmented ---------- */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.seg button { flex: 1; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }
.seg .count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: 11px; display: inline-grid; place-items: center; color: var(--text-2); }
.seg button.on .count { background: var(--accent-soft); color: var(--accent); }

/* ---------- avatar ---------- */
.av { width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 16px; overflow: hidden; position: relative; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.lg { width: 64px; height: 64px; font-size: 24px; }
.av.sm { width: 32px; height: 32px; font-size: 13px; }

/* ---------- campaign card ---------- */
.raid .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 2px; }
.raid .meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.handle { font-weight: 700; font-size: 15px; }
.bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin: 12px 0; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.bar.ok > i { background: linear-gradient(90deg, #10b981, var(--ok)); }
.acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 12px; font-weight: 600; }
.act svg.i { width: 17px; height: 17px; }
.act b { font-size: 12px; color: var(--muted); font-weight: 700; }
.act.on { background: var(--ok-soft); border-color: rgba(52, 211, 153, 0.35); color: var(--ok); }
.act.on b { color: var(--ok); }
.raid .foot { margin-top: 10px; }
.badge { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.badge.gold { background: var(--accent-soft); color: var(--accent); border-color: rgba(245, 181, 61, .3); }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: rgba(248, 113, 113, .3); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .k svg.i { width: 14px; height: 14px; }
.stat .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- list rows ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.li + .li { border-top: 1px solid var(--line); }
.li .r { text-align: right; }
.li.me { background: linear-gradient(90deg, var(--accent-soft), transparent); }
.rank { width: 26px; text-align: center; font-weight: 800; color: var(--muted); font-size: 14px; }
.ico-box { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.ico-box.ok { background: var(--ok-soft); color: var(--ok); }
.ico-box.gold { background: var(--accent-soft); color: var(--accent); }
.ico-box.red { background: var(--danger-soft); color: var(--danger); }
.plus { color: var(--ok); font-weight: 800; }
.minus { color: var(--danger); font-weight: 800; }

/* ---------- podium ---------- */
.podium { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); gap: 8px; align-items: end; margin-top: 4px; }
.pod { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 6px 12px; position: relative; }
.pod.p1 { padding-top: 20px; background: radial-gradient(100% 80% at 50% 0%, rgba(245, 181, 61, .22), transparent 70%), var(--surface); border-color: rgba(245, 181, 61, .3); }
.pod .av { margin: 0 auto 8px; }
.pod .medal { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #1b1405; }
.pod { min-width: 0; }
.pod .nm { font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 2px; min-width: 0; }
.pod .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pt { color: var(--accent); font-weight: 800; font-size: 15px; margin-top: 2px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ico-box { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; }
.empty .ico-box svg.i { width: 24px; height: 24px; }

/* ---------- onboarding ---------- */
.hero { text-align: center; padding: 18px 4px 6px; }
.hero .logo { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 18px; box-shadow: 0 10px 40px rgba(245, 181, 61, .35); }
.hero .logo svg.i { width: 32px; height: 32px; }
.hero p { color: var(--text-2); margin: 10px auto 0; max-width: 360px; }
.steps .li { align-items: flex-start; }
.steps .t { font-weight: 700; }

/* ---------- reward strip ---------- */
.rewards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.rw { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.rw .e { font-size: 20px; }
.rw .t { font-size: 12px; font-weight: 700; margin-top: 2px; }
.rw .s { font-size: 11px; color: var(--muted); }

details.faq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; }
details.faq summary { list-style: none; padding: 14px 0; font-weight: 700; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq[open] summary svg.i { transform: rotate(180deg); }
details.faq ol { margin: 0 0 14px; padding-left: 20px; color: var(--text-2); }
details.faq li + li { margin-top: 6px; }

/* ---------- table (admin) ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 10px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .n { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* ---------- nav ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10, 12, 17, 0.9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabs .inner { display: flex; width: 100%; max-width: 640px; gap: 4px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; font-size: 11px; font-weight: 600; }
.tabs button svg.i { width: 22px; height: 22px; }
.tabs button.on { color: var(--accent); }
.tabs button.on svg.i { filter: drop-shadow(0 0 8px rgba(245, 181, 61, .45)); }

/* ---------- toast / skeleton ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); z-index: 40;
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text); padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); display: flex; gap: 8px; align-items: center; }
.toast.err { border-color: rgba(248, 113, 113, .4); }
.toast.ok { border-color: rgba(52, 211, 153, .4); }
.skel { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--radius); height: 150px; border: 1px solid var(--line); }
.skel + .skel { margin-top: 10px; }
@keyframes sh { to { background-position: -200% 0; } }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
[hidden] { display: none !important; }
