:root {
  --bg: #0b0b0d;
  --panel: #15161a;
  --panel-2: #1c1e24;
  --line: #2a2d35;
  --text: #eef0f4;
  --muted: #8b909c;
  --accent: #e5252a;
  --accent-2: #b81d22;
  --ok: #2fbf71;
  --warn: #e8a33d;
  --info: #4a8cf7;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body { display: flex; justify-content: center; }

.shell {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding-bottom: 76px;
  position: relative;
}

/* ---------- 顶部 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 72%, transparent);
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 17px; letter-spacing: .12em; }
.brand span { font-size: 11px; color: var(--muted); letter-spacing: .18em; }
.topbar .brand strong { font-size: 15px; letter-spacing: .06em; white-space: nowrap; }
.balance-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
.balance-pill b { color: var(--accent); font-size: 15px; }

/* ---------- 卡片与按钮 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 0 14px 12px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }

.btn {
  display: block; width: 100%;
  border: 0; border-radius: 11px;
  padding: 13px 16px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  background: var(--accent); color: #fff; cursor: pointer;
  transition: opacity .15s, transform .06s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.subtle { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--accent-2); }
.btn.sm { padding: 9px 14px; font-size: 13.5px; width: auto; display: inline-block; }

/* ---------- 登录方式切换 / 验证码 ---------- */
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 4px;
}
.segbtn {
  font: inherit; font-size: 13.5px; padding: 9px 6px; cursor: pointer;
  background: none; border: 0; border-radius: 8px; color: var(--muted);
}
.segbtn.on { background: var(--panel); color: var(--text); font-weight: 600; }
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row input { flex: 1; min-width: 0; letter-spacing: .18em; }
.code-row .sendcode {
  flex: none; width: 104px; padding-left: 0; padding-right: 0;
  white-space: nowrap; font-size: 13.5px; font-variant-numeric: tabular-nums;
}

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 13px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text);
  font: inherit; font-size: 15px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: #565b66; }
/* Chrome 自动填充会强行刷成浅色底，这里盖回深色 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--panel-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

.code-input {
  letter-spacing: .55em; text-align: center;
  font-size: 26px; font-weight: 700;
  padding: 16px 10px;
}

/* ---------- 场次卡 ---------- */
.event {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px; margin: 0 14px 11px;
  cursor: pointer;
}
.event:active { background: var(--panel-2); }
.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.event h3 { margin: 0; font-size: 16.5px; }
.event-meta { display: flex; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.event-meta b { color: var(--text); font-weight: 600; }

.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.tag.open { color: var(--ok); border-color: rgba(47,191,113,.45); }
.tag.running { color: var(--accent); border-color: rgba(229,37,42,.5); }
.tag.finished { color: var(--muted); }
.tag.registered { color: var(--info); border-color: rgba(74,140,247,.45); }
.tag.in_room { color: var(--ok); border-color: rgba(47,191,113,.45); }
.tag.out { color: var(--warn); border-color: rgba(232,163,61,.45); }
.tag.winner { color: #ffd45e; border-color: rgba(255,212,94,.5); }
.tag.canceled { color: var(--muted); text-decoration: line-through; }

/* ---------- 成员列表 ---------- */
.member {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.member:last-child { border-bottom: 0; }
.seat {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
}
.member .who { flex: 1; min-width: 0; }
.member .who b { display: block; font-size: 14.5px; }
.member .who span { font-size: 11.5px; color: var(--muted); }
.member.out .who b { color: var(--muted); text-decoration: line-through; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 460px; margin: 0 auto;
  display: flex; background: rgba(14,15,18,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px); z-index: 30;
}
.tabbar button {
  flex: 1; background: none; border: 0; color: var(--muted);
  padding: 11px 0 14px; font: inherit; font-size: 11.5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tabbar button.on { color: var(--accent); }
.tabbar .ico { font-size: 17px; line-height: 1; }

/* ---------- 提示 ---------- */
.notice {
  margin: 0 14px 12px; padding: 11px 13px; border-radius: 11px;
  font-size: 13px; line-height: 1.55; border: 1px solid;
}
.notice.info { background: rgba(74,140,247,.1); border-color: rgba(74,140,247,.35); color: #bcd4ff; }
.notice.warn { background: rgba(232,163,61,.1); border-color: rgba(232,163,61,.35); color: #f3d6a5; }
.notice.err  { background: rgba(229,37,42,.12); border-color: rgba(229,37,42,.4); color: #ffb9bb; }
.notice.ok   { background: rgba(47,191,113,.1); border-color: rgba(47,191,113,.35); color: #b0ecc9; }

#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: #24262d; border: 1px solid var(--line); color: #fff;
  padding: 11px 18px; border-radius: 11px; font-size: 13.5px;
  max-width: 320px; text-align: center; z-index: 99;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
#toast.err { border-color: rgba(229,37,42,.55); }

.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 46px 20px; }
.center-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.secret {
  text-align: center; font-size: 30px; font-weight: 700; letter-spacing: .3em;
  padding: 18px 0; color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- 椭圆牌桌可视化 ---------- */
.tviz { position: relative; width: 100%; container-type: inline-size; }
.tviz svg { display: block; width: 100%; height: auto; }
.tviz.is-live svg { filter: drop-shadow(0 0 16px rgba(229, 37, 42, .16)); }

.tviz-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.tviz-label { font-size: 3.1cqw; color: var(--muted); letter-spacing: .16em; }
.tviz-count { display: flex; align-items: baseline; gap: 3px; line-height: 1; margin: 3px 0; }
.tviz-count b { font-size: 9cqw; font-weight: 800; letter-spacing: -.02em; }
.tviz-count span { font-size: 3.8cqw; color: var(--muted); }
.tviz.is-live .tviz-count b { color: var(--accent); }
.tviz-sub {
  font-size: 2.9cqw; color: var(--muted); line-height: 1.4;
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tviz-legend {
  display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center;
  font-size: 11.5px; color: var(--muted); margin-top: 8px;
}
.tviz-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tviz-legend .dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid transparent; flex: none;
}
.tviz-legend .dot.dashed { border-style: dashed; }

/* 桌位卡片 */
.tgrid { display: grid; gap: 12px; }
.tcard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 14px 12px;
}
.tcard.is-live { border-color: rgba(229, 37, 42, .38); }
.tcard.is-idle { opacity: .82; }
.tcard-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px;
}
.tcard-no { font-size: 12px; color: var(--muted); letter-spacing: .1em; }
.tcard-title {
  font-size: 15px; font-weight: 600; margin: 4px 0 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tcard-meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.tcard-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tcard-actions .btn, .tcard-actions button { flex: 1; min-width: 96px; }

/* 牌桌下方的轮次条：轮次 + 小盲/大盲 */
.blindbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 8px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  font-size: 12px; color: var(--muted);
}
.blindbar .lvl { color: var(--text); }
.blindbar .lvl b { color: var(--accent); font-size: 14px; }
.blindbar .blind { display: inline-flex; align-items: baseline; gap: 4px; }
.blindbar .blind i { font-style: normal; color: var(--muted); }
.blindbar .blind b { color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* 分区小标题 */
.sec-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 2px 18px 10px;
}
.sec-head h2 { font-size: 16px; margin: 0; }
.sec-title { font-size: 13.5px; font-weight: 600; margin: 18px 0 8px; }

/* 数值涨跌 */
.up { color: var(--ok); }
.down { color: var(--accent); }

/* ---------- 弹层（赛况） ---------- */
dialog.sheet {
  width: min(440px, 92vw); max-height: 84vh; overflow: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  margin: auto;
}
dialog.sheet::backdrop { background: rgba(0,0,0,.62); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head h2 { font-size: 17px; margin: 0; }
.sheet-head .sub { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.sheet-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
}

.live-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px;
}
.live-grid > div {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px;
}
.live-grid span { display: block; font-size: 11.5px; color: var(--muted); }
.live-grid b { font-size: 17px; letter-spacing: .02em; }

.plist { display: flex; flex-direction: column; }
.prow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.prow:last-child { border-bottom: 0; }
.pseat {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  display: grid; place-items: center; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.pname { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmark {
  flex: none; font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.pmark.alive { color: var(--ok); border-color: rgba(47,191,113,.45); background: rgba(47,191,113,.1); }
.pmark.champ { color: #ffd45e; border-color: rgba(255,212,94,.5); background: rgba(255,212,94,.1); }
.pmark.dead  { color: var(--muted); border-color: var(--line); background: var(--panel-2); }
.pmark.wait  { color: var(--info); border-color: rgba(74,140,247,.45); background: rgba(74,140,247,.1); }
.prow.dead .pname { color: var(--muted); text-decoration: line-through; }

/* ---------- 排行榜 ---------- */
.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.rank-row:last-child { border-bottom: 0; }
.rank-row.me { background: rgba(229,37,42,.07); margin: 0 -16px; padding: 11px 16px; }
.rank-no {
  width: 30px; flex: none; text-align: center; font-size: 14px; font-weight: 700;
  color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.rank-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rank-who b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-size: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- 对局记录 ---------- */
.card.hist { padding: 14px 16px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.hist-head h3 { font-size: 15px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sum { display: flex; gap: 10px; }
.hist-sum > div { flex: 1; min-width: 0; }
.hist-sum span { display: block; font-size: 11.5px; color: var(--muted); }
.hist-sum b { font-size: 19px; }

/* ---------- 我的资产 / 战绩 ---------- */
.asset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.asset {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 12px; text-align: center;
}
.asset i { display: block; font-style: normal; font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.asset b {
  display: inline-block; font-size: 26px; font-weight: 800; margin: 6px 3px 0;
  font-variant-numeric: tabular-nums;
}
.asset span { font-size: 12px; color: var(--muted); }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; align-items: baseline; justify-content: space-between;
}
.stat i { font-style: normal; font-size: 12.5px; color: var(--muted); }
.stat b { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 报名时挑门票 / 积分 ---------- */
.paypick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.payopt {
  font: inherit; cursor: pointer; padding: 10px 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.payopt b { font-size: 14px; font-weight: 600; }
.payopt i { font-style: normal; font-size: 12px; }
.payopt.on { border-color: var(--accent); background: rgba(229, 37, 42, .12); color: var(--text); }
.payopt em {
  font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 999px;
  background: rgba(229, 37, 42, .16); color: var(--accent);
}
.payopt.lack { opacity: .62; }
.payopt.lack.on { border-color: var(--line); background: var(--panel-2); }
