/* 牌神计分板 · 管理后台 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e6e8eb;
  --text: #16181d;
  --text-2: #5c6370;
  --text-3: #8b929e;
  --accent: #07c160;
  --accent-soft: rgba(7, 193, 96, .12);
  --win: #0a9f55;
  --loss: #e5484d;
  --gold: #d99a06;
  --gold-soft: rgba(217, 154, 6, .14);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .10);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f38;
    --text: #eceef2;
    --text-2: #a4abb8;
    --text-3: #717886;
    --accent: #1fd07a;
    --accent-soft: rgba(31, 208, 122, .14);
    --win: #2fd47f;
    --loss: #ff6b6f;
    --gold: #f2b53a;
    --gold-soft: rgba(242, 181, 58, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.pos { color: var(--win); }
.neg { color: var(--loss); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.brand small { font-weight: 500; color: var(--text-3); margin-left: 2px; }
.spacer { flex: 1; }
.live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-3);
}
.live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
}
.live.on { color: var(--win); }
.live.on::before { background: var(--win); box-shadow: 0 0 0 0 var(--win); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--win) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.icon-btn {
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-2); padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- 导航 ---------- */
.tabs {
  max-width: 980px; margin: 0 auto; padding: 16px 20px 0;
  display: flex; gap: 4px;
}
.tabs a {
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 550;
  color: var(--text-2); transition: background .15s, color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--text); color: var(--bg); }
.tabs .count { margin-left: 6px; font-size: 12px; opacity: .7; }

/* ---------- 内容 ---------- */
main { max-width: 980px; margin: 0 auto; padding: 20px 20px calc(48px + env(safe-area-inset-bottom)); }
.section-title {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .4px;
  color: var(--text-3); margin: 28px 2px 10px;
}
.section-title:first-child { margin-top: 4px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.empty {
  text-align: center; color: var(--text-3); padding: 48px 16px;
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.back {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-2); font-size: 14px; margin-bottom: 14px;
}
.back:hover { color: var(--text); }
.back::before { content: "‹"; font-size: 20px; line-height: 1; margin-top: -2px; }
.banner {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  background: var(--gold-soft); color: var(--text); font-size: 14px;
}

/* ---------- 标签 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 550; line-height: 20px;
  padding: 0 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.chip.green { background: var(--accent-soft); color: var(--win); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.red { background: color-mix(in srgb, var(--loss) 14%, transparent); color: var(--loss); }

/* ---------- 头像 ---------- */
.avatar {
  --size: 32px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center;
  background: var(--surface-2); color: #fff;
  font-size: calc(var(--size) * .42); font-weight: 600;
  box-shadow: 0 0 0 2px var(--surface);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.emoji { font-size: calc(var(--size) * .56); color: inherit; }
.avatar.lg { --size: 64px; }
.avatar.md { --size: 44px; }
.avatar.sm { --size: 24px; }

/* ---------- 对局卡片 ---------- */
.game-card { display: block; padding: 16px; transition: transform .15s, box-shadow .15s, border-color .15s; }
.game-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); border-color: transparent; }
.game-card.idle { opacity: .62; }
.game-card.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: var(--shadow); } }
.game-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.room { font-weight: 650; font-size: 17px; letter-spacing: .5px; }
.game-head .time { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.players { display: flex; flex-direction: column; gap: 8px; }
.player-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .score { font-weight: 650; }
.game-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); display: flex; gap: 12px; }

/* ---------- 列表 ---------- */
.list { overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 60px;
  border-top: 1px solid var(--border);
  transition: background .12s;
}
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-2); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.list-item .sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .side { text-align: right; flex: none; }
.list-item .side .big { font-weight: 650; font-size: 16px; }
.list-item.deleted { opacity: .55; }

.search {
  width: 100%; height: 42px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface) no-repeat 12px center / 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b929e' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  color: var(--text); font: inherit; outline: none; margin-bottom: 12px;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 个人页 ---------- */
.profile { display: flex; align-items: center; gap: 16px; padding: 20px; }
.profile h1 { margin: 0 0 2px; font-size: 22px; font-weight: 700; }
.profile .meta { font-size: 13px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); margin-top: 12px; }
.tile { padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--text-3); }
.tile .value { font-size: 24px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; }
.tile .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.types { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.result { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.result.win { background: var(--accent-soft); color: var(--win); }
.result.loss { background: color-mix(in srgb, var(--loss) 13%, transparent); color: var(--loss); }
.result.draw { background: var(--surface-2); color: var(--text-3); }

/* ---------- 记分板 ---------- */
.board-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.board-head h1 { margin: 0 6px 0 0; font-size: 26px; font-weight: 750; letter-spacing: .5px; }
.scoreboard { display: grid; gap: 10px; grid-template-columns: repeat(var(--cols, 3), 1fr); }
.seat { padding: 16px 12px; text-align: center; position: relative; }
.seat .name { margin-top: 8px; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .total { font-size: 30px; font-weight: 750; letter-spacing: -.5px; margin-top: 2px; transition: color .3s; }
.seat .rank {
  display: table; margin: 0 auto 8px;
  font-size: 11px; font-weight: 650; line-height: 18px; padding: 0 7px; border-radius: 6px;
  color: var(--text-3); background: var(--surface-2); white-space: nowrap;
}
.seat .rank.gold { color: var(--gold); background: var(--gold-soft); }
.seat.mvp { border-color: color-mix(in srgb, var(--gold) 45%, var(--border)); }
.seat .virtual { font-size: 11px; color: var(--text-3); }
.seat .chip { margin-top: 4px; }
.seat-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12.5px; text-align: left;
}
.seat-stats > div { display: flex; justify-content: space-between; }
.seat-stats .k, .lord-line .k { color: var(--text-3); }
.seat-stats .v { font-weight: 600; }
.lord-line { margin-top: 4px; font-size: 12.5px; color: var(--text-2); display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
.lord-line b { font-weight: 650; }

/* ---------- 对局信息条 ---------- */
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin-bottom: 12px; overflow: hidden;
}
.fact { padding: 10px 14px; border-left: 1px solid var(--border); min-width: 0; }
.fact:first-child { border-left: 0; }
.fact .label { font-size: 11.5px; color: var(--text-3); }
.fact .value { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 时间区间 ---------- */
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 24px 0 4px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; cursor: pointer; font-size: 13px; font-weight: 550;
  padding: 6px 11px; border-radius: 8px; color: var(--text-2); white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dates { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.date {
  height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.date:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 对手 ---------- */
.opps { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
.opp { display: block; padding: 16px; transition: transform .15s, box-shadow .15s; }
.opp:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.opp-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.opp-head .main { min-width: 0; }
.opp-head .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-head .sub { font-size: 12.5px; color: var(--text-3); }
.opp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.metric .label { font-size: 11.5px; color: var(--text-3); }
.metric .value { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.metric .hint { font-size: 11px; color: var(--text-3); }
.note { font-size: 12px; color: var(--text-3); margin: 10px 2px 0; line-height: 1.6; }
.list-item .names { overflow: hidden; text-overflow: ellipsis; }
.bump { animation: bump .6s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.12); } 100% { transform: scale(1); } }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.rounds { width: 100%; border-collapse: collapse; font-size: 14px; }
.rounds th, .rounds td { padding: 9px 12px; text-align: right; white-space: nowrap; }
.rounds th { position: sticky; top: 0; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--text-3); border-bottom: 1px solid var(--border); }
.rounds th:first-child, .rounds td:first-child { text-align: left; color: var(--text-3); width: 1%; }
.rounds tbody tr + tr td { border-top: 1px solid var(--border); }
.rounds td.lord { position: relative; }
.rounds td.lord span { background: var(--gold-soft); border-radius: 6px; padding: 1px 6px; }
.rounds tr.new td { animation: rowflash 2s ease-out; }
@keyframes rowflash { from { background: var(--accent-soft); } to { background: transparent; } }
.rounds .time { font-size: 11px; color: var(--text-3); margin-left: 6px; }
.legend { font-size: 12px; color: var(--text-3); margin: 10px 2px 0; display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 3px; background: var(--gold-soft); display: inline-block; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 360px; padding: 32px 28px 28px; text-align: center; }
.login img { width: 52px; height: 52px; border-radius: 14px; }
.login h1 { font-size: 20px; margin: 14px 0 4px; }
.login p { margin: 0 0 22px; color: var(--text-3); font-size: 13px; }
.field {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: inherit; outline: none;
}
.field:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  width: 100%; height: 46px; margin-top: 12px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.error { color: var(--loss); font-size: 13px; min-height: 20px; margin-top: 10px; }

.loading { padding: 64px 0; text-align: center; color: var(--text-3); }
.loading::before {
  content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .topbar-inner, .tabs, main { padding-left: 16px; padding-right: 16px; }
  .brand small { display: none; }
  .grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .types { grid-template-columns: 1fr; }
  .tile .value { font-size: 21px; }
  .profile { padding: 16px; gap: 14px; }
  .avatar.lg { --size: 56px; }
  .profile h1 { font-size: 19px; }
  .seat { padding: 14px 6px; }
  .seat .total { font-size: 24px; }
  .seat .rank { font-size: 10px; padding: 0 5px; margin-bottom: 6px; }
  .seat-stats { grid-template-columns: 1fr; font-size: 11.5px; }
  .lord-line { font-size: 11.5px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .fact:nth-child(odd) { border-left: 0; }
  .fact:nth-child(n+3) { border-top: 1px solid var(--border); }
  .fact:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .opps { grid-template-columns: 1fr; }
  .dates { margin-left: 0; width: 100%; }
  .date { flex: 1; min-width: 0; }
  .board-head h1 { font-size: 22px; }
  .rounds th, .rounds td { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
