/* ===== 设计令牌 ===== */
:root {
  --bg: #0f1419;
  --card: #1a212b;
  --line: rgba(255,255,255,.07);
  --txt: #e7ebf1;
  --muted: #8b95a7;
  --pri: #2d8cff;
  --up: #2fbf71;
  --down: #e5484d;
  --radius: .75rem;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100dvh;
  font-size: .9375rem;
}

:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .625rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .625rem; cursor: pointer; }
.logo {
  width: 2rem; height: 2rem; border-radius: .5rem;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem; color: #fff;
  background: linear-gradient(135deg, var(--pri), #1663c7);
}
.brandName { font-size: 1rem; font-weight: 700; letter-spacing: .02em; }
.authArea { display: flex; gap: .5rem; align-items: center; margin-inline-start: auto; font-size: .875rem; }

.mainNav { display: flex; gap: .25rem; overflow-x: auto; }
.navTab {
  background: none; border: 0; color: var(--muted);
  font-size: .9375rem; padding: .625rem 1rem; min-height: 2.75rem;
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.navTab:hover { color: var(--txt); }
.navTab.active { color: var(--pri); border-bottom-color: var(--pri); font-weight: 700; }

/* ===== 按钮 ===== */
.btn {
  background: var(--pri); color: #fff; border: 0; border-radius: .5rem;
  padding: .5rem 1rem; font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
  min-height: 2.25rem;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); }
.btn.ghost:hover:not(:disabled) { border-color: var(--pri); color: var(--pri); filter: none; }
.gold-btn { background: var(--pri); }
.wide { width: 100%; margin-top: .625rem; }

/* ===== 落地页 ===== */
.hero { text-align: center; padding: 4rem 1.25rem 2rem; }
.heroTitle { font-size: clamp(1.75rem, 5.5vw, 3.25rem); margin: 0 0 .75rem; font-weight: 800; text-wrap: balance; }
.gold { color: var(--pri); }
.heroSub { color: var(--muted); margin: 0 0 1.875rem; font-size: .9375rem; }
.ctaRow { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.cta { font-size: 1rem; padding: .75rem 1.875rem; min-height: 3rem; border-radius: .625rem; }
.narrow { max-width: 35rem; }

/* ===== 布局 ===== */
main { max-width: 72rem; margin: 0 auto; padding: .75rem 1rem 2rem; }
#view-portfolio, #view-leaderboard { max-width: 47.5rem; margin-inline: auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.125rem;
  margin-bottom: .875rem;
}
.card h3 { margin: 0 0 .75rem; font-size: 1rem; }
.card h4 { margin: .875rem 0 .5rem; font-size: .875rem; color: var(--muted); }

/* ===== 统计条 / 统计卡 ===== */
.statsStrip { display: flex; justify-content: space-around; gap: 1rem; flex-wrap: wrap; padding: .875rem 1.125rem; text-align: center; }
.statNum { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; color: var(--pri); font-variant-numeric: tabular-nums; }
.statLabel { color: var(--muted); font-size: .75rem; margin-top: .25rem; }
.statCards { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr)); gap: .75rem; margin-bottom: .875rem; }
.statCard { margin-bottom: 0; padding: .875rem 1rem; }
.statCard .big { font-size: 1.375rem; font-weight: 800; margin-top: .25rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ===== 赌局卡片网格（Polymarket 式） ===== */
#markets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: .875rem;
  align-items: start;
}
#markets .card { margin-bottom: 0; display: flex; flex-direction: column; }
.market { transition: border-color .2s, transform .2s; }
.market:hover { border-color: rgba(255,255,255,.16); transform: translateY(-2px); }

.q { font-size: 1.05rem; font-weight: 700; margin-bottom: .625rem; line-height: 1.4; text-wrap: pretty; }
.metaRow { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; margin-bottom: .75rem; }
.badge { font-size: .75rem; border-radius: .375rem; padding: .1875rem .5625rem; white-space: nowrap; }
.badge.open { background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up); }
.badge.closed { background: color-mix(in srgb, #f5a623 12%, transparent); color: #f5a623; }
.badge.done { background: color-mix(in srgb, var(--pri) 15%, transparent); color: var(--pri); }
.badge.cancel { background: rgba(148,163,184,.15); color: #cbd5e1; }
.pool { color: var(--muted); font-size: .8125rem; }

/* 选项行：彩色概率条 + 大字号概率 + 押注按钮 */
.opt {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .625rem; margin-bottom: .375rem;
  position: relative; overflow: clip; border-radius: .5rem;
  background: rgba(255,255,255,.025);
}
.optBar {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  background: color-mix(in srgb, var(--oc, var(--pri)) 14%, transparent);
  pointer-events: none; transition: width .5s ease;
}
.opt.win { outline: 1px solid color-mix(in srgb, var(--up) 60%, transparent); }
.optName { font-weight: 600; z-index: 1; flex: 1; min-inline-size: 0; overflow-wrap: break-word; }
.optPct { color: var(--oc, var(--pri)); font-size: .9375rem; font-weight: 800; z-index: 1; font-variant-numeric: tabular-nums; }
.optPool { color: var(--muted); font-size: .75rem; z-index: 1; white-space: nowrap; }
.betBtn {
  z-index: 1; cursor: pointer; font-weight: 700; font-size: .8125rem;
  border: 1px solid color-mix(in srgb, var(--oc, var(--pri)) 55%, transparent);
  color: var(--oc, var(--pri));
  background: color-mix(in srgb, var(--oc, var(--pri)) 10%, transparent);
  border-radius: 999px; padding: .25rem 1rem; min-height: 2rem;
  transition: background .15s, color .15s;
}
.betBtn:hover { background: var(--oc, var(--pri)); color: #0b0e12; }
.myTag {
  font-size: .6875rem; color: var(--pri);
  border: 1px solid color-mix(in srgb, var(--pri) 40%, transparent);
  border-radius: 999px; padding: .0625rem .5rem; margin-inline-start: .375rem;
  white-space: nowrap;
}

.betRow { display: flex; gap: .5rem; margin-top: .5rem; align-items: center; }
.betRow input { flex: 1; margin: 0; }
.claim { background: var(--up); width: 100%; margin-top: .75rem; font-weight: 700; }
.claim:hover:not(:disabled) { filter: brightness(1.1); }
.claimMini { background: var(--up); padding: .25rem .875rem; font-size: .75rem; border-radius: 999px; min-height: 2rem; }

/* ===== 表单 ===== */
input, textarea, select {
  background: rgba(10,14,19,.7); color: var(--txt);
  border: 1px solid var(--line); border-radius: .5rem;
  padding: .625rem .75rem; font-size: .875rem; width: 100%; margin: .25rem 0;
}
input:focus, textarea:focus { outline: none; border-color: var(--pri); }
code { background: rgba(255,255,255,.07); padding: .0625rem .375rem; border-radius: .3125rem; font-size: .75rem; word-break: break-all; }
.muted { color: var(--muted); font-size: .8125rem; }
.tiny { font-size: .75rem; margin-top: .625rem; }
.err { color: var(--down); font-size: .8125rem; margin-top: .5rem; min-height: 1.125rem; }

/* ===== 排行榜 ===== */
.lb ol { list-style: none; padding: 0; margin: 0; counter-reset: rk; }
.lb li {
  display: flex; justify-content: space-between; gap: .5rem;
  padding: .5rem .25rem; counter-increment: rk; font-size: .875rem;
}
.lb li:not(:last-child) { border-bottom: 1px solid var(--line); }
.lb li::before {
  content: counter(rk); width: 1.375rem; height: 1.375rem; border-radius: .375rem;
  background: rgba(255,255,255,.06); display: inline-grid; place-items: center;
  font-size: .75rem; color: var(--muted); margin-right: .625rem; flex-shrink: 0;
}
.lb li:nth-child(1)::before { background: #f5a623; color: #111; font-weight: 800; }
.lb li:nth-child(2)::before { background: #9aa7b8; color: #111; font-weight: 800; }
.lb li:nth-child(3)::before { background: #b0753c; color: #111; font-weight: 800; }
.lb li .who { flex: 1; min-inline-size: 0; }
.lb li .amt { color: var(--pri); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lbTime { font-size: .75rem; margin: -.5rem 0 .75rem; min-height: .9375rem; }

/* ===== 持仓 ===== */
.posRow { padding: .75rem .125rem; }
.posRow:not(:first-child) { border-top: 1px solid var(--line); }
.posQ { font-weight: 700; margin-bottom: .375rem; }
.posMeta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .75rem; color: var(--muted); }
.chip {
  display: inline-block; border: 1px solid var(--line); border-radius: 999px;
  padding: .125rem .625rem; font-size: .75rem; color: var(--txt);
}
.chip.win { border-color: color-mix(in srgb, var(--up) 50%, transparent); color: var(--up); }
.chip.lose { border-color: color-mix(in srgb, var(--down) 40%, transparent); color: var(--down); }
.posRight { margin-inline-start: auto; text-align: end; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: grid; place-items: center; z-index: 100; padding: 1rem;
}
.modalBox {
  width: min(100%, 22.5rem); background: var(--card);
  border: 1px solid var(--line); border-radius: 1rem; padding: 1.375rem;
}
#qrBox { background: #fff; padding: 1rem; border-radius: .875rem; width: fit-content; margin: 0 auto; }
.modalTabs { display: flex; gap: .375rem; margin-bottom: .875rem; }
.mtab {
  flex: 1; background: transparent; color: var(--muted); border: 0;
  border-bottom: 2px solid transparent; padding: .5rem; font-size: .9375rem; cursor: pointer;
}
.mtab.active { color: var(--pri); border-bottom-color: var(--pri); }
.mclose { background: transparent; border: 0; color: var(--muted); font-size: 1.375rem; cursor: pointer; }

footer { text-align: center; padding: 1.625rem .625rem 2.125rem; font-size: .75rem; }
footer a { color: var(--muted); text-decoration: none; border-bottom: 1px dashed var(--muted); }
.hidden { display: none !important; }

/* ===== 顶栏搜索框 ===== */
.search {
  flex: 1; min-inline-size: 8rem; max-inline-size: 26rem;
  margin: 0; border-radius: 999px;
}

/* ===== 分类筛选条 ===== */
.pillRow { display: flex; gap: .5rem; overflow-x: auto; margin-bottom: .875rem; }
.pill {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: .375rem 1rem; min-height: 2.25rem;
  font-size: .8125rem; cursor: pointer; white-space: nowrap;
}
.pill:hover { color: var(--txt); border-color: rgba(255,255,255,.2); }
.pill.active {
  background: color-mix(in srgb, var(--pri) 15%, transparent);
  border-color: color-mix(in srgb, var(--pri) 45%, transparent);
  color: var(--pri); font-weight: 700;
}

/* ===== 卡片头 / 卡片底 ===== */
.mHead { display: flex; gap: .625rem; align-items: flex-start; margin-bottom: .625rem; }
.mIcon {
  width: 2.25rem; height: 2.25rem; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; color: #fff;
  background: color-mix(in srgb, var(--ic, var(--pri)) 80%, #000);
}
.mHead .q { margin-bottom: 0; flex: 1; min-inline-size: 0; }
.mFoot {
  display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  margin-top: .75rem; padding-top: .625rem;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .75rem;
}

/* ===== 二元题：绿/红双大按钮 ===== */
.biBtns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .5rem; }
.biBtn {
  border-radius: .5rem; padding: .625rem .5rem; min-height: 2.75rem;
  font-weight: 700; font-size: .875rem; cursor: pointer;
  border: 1px solid transparent;
}
.biBtn.up {
  background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up);
  border-color: color-mix(in srgb, var(--up) 35%, transparent);
}
.biBtn.up:hover { background: color-mix(in srgb, var(--up) 28%, transparent); }
.biBtn.down {
  background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down);
  border-color: color-mix(in srgb, var(--down) 35%, transparent);
}
.biBtn.down:hover { background: color-mix(in srgb, var(--down) 28%, transparent); }

/* ===== 动效可达性 / 移动端 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (max-width: 40rem) {
  .topbar { gap: .375rem; padding: .625rem .75rem; }
  .mainNav { order: 3; flex-basis: 100%; }
  .search { order: 4; flex-basis: 100%; max-inline-size: none; }
  .brandName { font-size: .9375rem; }
  main { padding: .5rem .75rem 1.5rem; }
}
