/* 掼蛋计分 · 华丽亮色牌桌主题（暖白 + 鎏金） */

:root {
  --bg-0: #efe4c8;
  --bg-1: #f8f2e4;
  --bg-2: #ffffff;
  --panel: #fffdf9;
  --panel-2: #f5efe0;
  --border: #e0d0a4;
  --border-soft: #ece3ca;
  --gold: #b3820e;
  --gold-bright: #d9a91a;
  --gold-dim: #8a6a1f;
  --jade: #178a5e;
  --crimson: #ad2740;
  --text: #2a2014;
  --text-dim: #6d5f47;
  --text-faint: #9c8f76;
  --shadow-lg: 0 16px 40px rgba(120, 92, 40, 0.14), 0 2px 8px rgba(120, 92, 40, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* 防止某些元素的 display:flex/grid 覆盖原生 hidden 属性 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(179, 130, 14, 0.10), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(23, 138, 94, 0.06), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 40%, var(--bg-1));
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.table-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    repeating-linear-gradient(135deg, rgba(179, 130, 14, 0.04) 0 2px, transparent 2px 60px);
  mask-image: radial-gradient(1200px 800px at 50% 0%, black, transparent 75%);
}

::selection { background: rgba(179, 130, 14, 0.25); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddc78e; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ---------------- Header ---------------- */

.app-header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.92), rgba(250, 242, 224, 0.65));
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-suits {
  font-size: 26px;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(179, 130, 14, 0.3);
}
.brand-suits .suit-red { color: var(--crimson); }

.brand-text h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--gold-bright), var(--gold) 60%, var(--gold-dim));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--jade);
  background: rgba(62, 207, 142, 0.1);
  border: 1px solid rgba(62, 207, 142, 0.3);
  padding: 6px 10px;
  border-radius: 999px;
}
.online-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 8px var(--jade);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.ghost-btn {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.ghost-btn:hover { border-color: var(--gold-dim); background: #efe2bd; transform: translateY(-1px); }
.admin-btn { border-color: rgba(232, 196, 106, 0.35); }

/* ---------------- Layout ---------------- */

.app-main {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* ---------------- Cards ---------------- */

.search-card, .my-matches, .leaderboard-card, .grid-card, .rule-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-lg);
}

/* ---------------- Search ---------------- */

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-box:focus-within {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(232, 196, 106, 0.12);
}
.search-icon { font-size: 15px; opacity: 0.7; }
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.search-box input::placeholder { color: var(--text-faint); }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}
.icon-btn:hover { color: var(--text); }

.search-results {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: all 0.12s ease;
}
.search-result-item:hover { border-color: var(--gold-dim); transform: translateX(2px); }
.sr-name { font-weight: 700; }
.sr-meta { font-size: 12.5px; color: var(--text-dim); }
.sr-code {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(232, 196, 106, 0.12);
  border: 1px solid rgba(232, 196, 106, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
}
.search-empty { padding: 14px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

.identity-bar {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.identity-bar strong { color: var(--gold); }
.link-btn {
  border: 0;
  background: none;
  color: var(--jade);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 0 0 0 6px;
  text-decoration: underline;
}

/* ---------------- My matches ---------------- */

.my-pair-score { font-size: 13.5px; color: var(--gold); font-weight: 700; }

.my-matches-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.match-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}
.match-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.match-card.done { border-color: rgba(62, 207, 142, 0.35); }

.mc-top { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-dim); }
.mc-opp { font-weight: 700; color: var(--text); }
.mc-status { font-size: 12px; }
.mc-status.pending { color: var(--text-faint); }
.mc-status.done { color: var(--jade); }
.mc-score { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.mc-score .num { font-size: 20px; font-weight: 800; }
.mc-score .lv { font-size: 12px; color: var(--text-faint); }

/* ---------------- Leaderboard ---------------- */

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.progress-stat { font-size: 12.5px; font-weight: 500; color: var(--text-dim); margin-left: auto; margin-right: 8px; }
.chevron { transition: transform 0.2s ease; color: var(--text-faint); }
.leaderboard-card.collapsed .chevron { transform: rotate(-90deg); }
.leaderboard-panel {
  margin-top: 14px;
  display: grid;
  gap: 6px;
}
.leaderboard-card.collapsed .leaderboard-panel { display: none; }

.leaderboard-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
}
.lb-row.me { border-color: var(--gold-dim); background: rgba(232, 196, 106, 0.08); }
.lb-rank { font-weight: 800; color: var(--text-faint); text-align: center; }
.lb-rank.top1 { color: #c9970f; }
.lb-rank.top2 { color: #7c8896; }
.lb-rank.top3 { color: #a1652a; }
.lb-name { font-weight: 700; }
.lb-meta { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.lb-pts { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px; color: var(--gold); }
.lb-unit { font-size: 11px; font-weight: 600; color: var(--gold-dim); margin-left: 2px; }

/* ---------------- Round tabs ---------------- */

.round-tabs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.round-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.round-tab {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.round-tab:hover { border-color: var(--gold-dim); color: var(--text); }
.round-tab.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--gold);
  color: #1a1406;
}
.gen-round-btn { margin-left: auto; }

/* ---------------- Pairing list（第 2 轮起：瑞士制配对） ---------------- */

.pairing-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.pairing-card { cursor: pointer; }
.mc-table { font-size: 11.5px; font-weight: 700; color: var(--gold-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.mc-pairing-row { display: flex; align-items: center; gap: 8px; }
.mc-pairing-side { flex: 1; min-width: 0; font-weight: 700; font-size: 13px; }
.mc-pairing-side .mc-org { display: block; font-size: 11px; font-weight: 400; color: var(--text-faint); }
.mc-vs { font-size: 11px; font-weight: 800; color: var(--text-faint); flex-shrink: 0; }
.mc-round {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold-dim);
  background: rgba(179, 130, 14, 0.1);
  border: 1px solid rgba(179, 130, 14, 0.25);
  padding: 1px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
  align-self: flex-start;
}
.bye-card { cursor: default; opacity: 0.85; }
.bye-card:hover { transform: none; box-shadow: none; }

/* ---------------- Grid ---------------- */

.lock-banner {
  font-size: 12.5px;
  color: var(--crimson);
  background: rgba(226, 88, 106, 0.1);
  border: 1px solid rgba(226, 88, 106, 0.3);
  padding: 5px 10px;
  border-radius: 999px;
}

.grid-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  max-height: 72vh;
}

.score-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}

.score-grid th, .score-grid td {
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 0;
  white-space: nowrap;
}

.corner-cell {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  background: var(--bg-2);
  min-width: 128px;
  padding: 10px !important;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
}

.col-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel-2);
  padding: 8px 10px !important;
  text-align: center;
  min-width: 92px;
}
.col-head .ch-code { font-weight: 800; color: var(--gold); font-size: 13px; }
.col-head .ch-org { font-size: 10.5px; color: var(--text-faint); margin-left: 4px; }
.col-head .ch-players { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.col-head.total-head {
  background: linear-gradient(180deg, rgba(179,130,14,0.16), rgba(179,130,14,0.06));
  color: var(--gold-dim);
}

.row-head {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel-2);
  padding: 8px 12px !important;
  text-align: left;
  min-width: 128px;
  cursor: pointer;
}
.row-head .rh-code { font-weight: 800; color: var(--gold); font-size: 13px; }
.row-head .rh-org { font-size: 10.5px; color: var(--text-faint); margin-left: 4px; }
.row-head .rh-players { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.row-head.total-row { background: linear-gradient(90deg, rgba(179,130,14,0.14), rgba(179,130,14,0.05)); }

tr:nth-child(even) .cell-body { background: rgba(120, 90, 30, 0.025); }

.score-grid td.cell {
  text-align: center;
  cursor: pointer;
  transition: background 0.12s ease;
  padding: 6px 4px !important;
  min-width: 92px;
  height: 56px;
}
.score-grid td.cell:hover { background: rgba(179, 130, 14, 0.08); }
.score-grid td.cell.empty { color: var(--text-faint); }
.score-grid td.cell.skipped { cursor: default; color: var(--text-faint); background: repeating-linear-gradient(135deg, rgba(120,90,30,0.07) 0 6px, transparent 6px 12px); }
.score-grid td.cell.skipped:hover { background: repeating-linear-gradient(135deg, rgba(120,90,30,0.07) 0 6px, transparent 6px 12px); }
.cell-plus { font-size: 16px; opacity: 0.35; }
.cell-levels { font-weight: 800; font-size: 13.5px; }
.cell-levels .win { color: var(--gold-dim); }
.cell-levels .lose { color: var(--text-dim); font-weight: 600; }
.cell-score { font-size: 11px; color: var(--text-faint); margin-top: 2px; font-variant-numeric: tabular-nums; }
.cell-tie .cell-levels { color: var(--text); }

.total-cell {
  background: rgba(179, 130, 14, 0.07);
  font-weight: 800;
  text-align: center;
  min-width: 76px;
}
.total-cell .tc-pts { font-size: 17px; color: var(--gold); }
.total-cell .tc-unit { font-size: 10px; font-weight: 600; color: var(--gold-dim); margin-left: 1px; }
.total-cell .tc-sub { font-size: 10.5px; color: var(--text-faint); font-weight: 500; }

.corner-stat { font-size: 11px; }

.highlight-row, .highlight-col { background: rgba(23, 138, 94, 0.09) !important; }
.row-head.highlight-row, .col-head.highlight-col { box-shadow: inset 0 0 0 2px var(--jade); }

/* ---------------- Rule card ---------------- */

.rule-card { padding: 14px 18px; }
.rule-card summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--text-dim); }
.rule-body { margin-top: 10px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
.rule-body p { margin: 0; }

/* ---------------- Footer ---------------- */

.app-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 24px 20px 40px;
  position: relative;
  z-index: 1;
}

/* ---------------- Modal / dialog ---------------- */

dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(560px, 92vw);
  width: 100%;
  border-radius: var(--radius);
  overflow: visible;
}
dialog.modal::backdrop {
  background: rgba(42, 32, 18, 0.55);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  background: linear-gradient(180deg, #fffdf9, #f8efd9);
  border: 1px solid rgba(179, 130, 14, 0.3);
  border-radius: var(--radius);
  padding: 26px 24px 20px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(120, 90, 30, 0.06);
  animation: modal-pop 0.18s ease;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: var(--panel-2);
  color: var(--text-dim);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
}
.modal-close:hover { color: var(--text); }

.modal-title {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 800;
  color: var(--gold-dim);
}

.match-vs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}
.side-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.side-label { font-weight: 800; font-size: 14px; color: var(--gold); }
.side-players { font-size: 12.5px; color: var(--text-dim); }
.vs-sep { align-self: center; font-weight: 800; color: var(--text-faint); font-size: 13px; padding-top: 22px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 0;
  width: 38px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.pill:hover { border-color: var(--gold-dim); }
.pill.selected {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1406;
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(232, 196, 106, 0.35);
}
.pill.top { width: 46px; }

.result-preview {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(232, 196, 106, 0.06);
  border: 1px solid rgba(232, 196, 106, 0.25);
  border-radius: var(--radius-sm);
}
.rp-diff { font-size: 12.5px; color: var(--text-dim); }
.rp-diff strong { color: var(--gold); font-size: 15px; }
.rp-score { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rp-colon { color: var(--text-faint); margin: 0 4px; }
.rp-winner { font-size: 12.5px; color: var(--jade); font-weight: 700; }

.identity-picker { margin-top: 16px; }
.ip-label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.selected { border-color: var(--jade); background: rgba(62, 207, 142, 0.15); color: var(--jade); font-weight: 700; }

.modal-lock-notice {
  margin-top: 14px;
  font-size: 13px;
  color: var(--crimson);
  background: rgba(226, 88, 106, 0.1);
  border: 1px solid rgba(226, 88, 106, 0.3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.modal-msg {
  margin-top: 12px;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(226, 88, 106, 0.1);
  border: 1px solid rgba(226, 88, 106, 0.3);
  color: var(--crimson);
}
.modal-msg.ok { background: rgba(62, 207, 142, 0.1); border-color: rgba(62, 207, 142, 0.3); color: var(--jade); }
.modal-msg.warn { background: rgba(232, 196, 106, 0.1); border-color: rgba(232, 196, 106, 0.3); color: var(--gold); }

.modal-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.save-status { font-size: 12.5px; color: var(--jade); margin-right: auto; min-height: 1em; }

.primary-btn {
  border: 0;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-dim));
  color: #1a1406;
  font: inherit;
  font-weight: 800;
  font-size: 13.5px;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(232, 196, 106, 0.3); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.danger-btn {
  border: 1px solid rgba(226, 88, 106, 0.4);
  background: rgba(226, 88, 106, 0.08);
  color: var(--crimson);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.danger-btn:hover { background: rgba(226, 88, 106, 0.18); }

/* ---------------- Admin panel ---------------- */

#adminModal { max-width: min(720px, 94vw); }
.admin-card { max-width: min(720px, 94vw); }
.admin-login { display: flex; flex-direction: column; gap: 12px; max-width: 320px; }
.admin-login input {
  background: var(--bg-1); border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: var(--radius-sm); font: inherit; font-size: 14px;
}
.muted { color: var(--text-dim); font-size: 13px; margin: 0; }

.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; padding-bottom: 2px; }
.tab-btn {
  border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 14px; cursor: pointer; border-radius: 8px 8px 0 0; position: relative;
}
.tab-btn.active { color: var(--gold-dim); }
.tab-btn.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -3px; height: 2px; background: var(--gold);
}

.admin-tab-panel { display: flex; flex-direction: column; gap: 12px; max-height: 58vh; overflow-y: auto; padding-right: 4px; }
.admin-tab-panel label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.admin-tab-panel hr { width: 100%; border: 0; border-top: 1px solid var(--border-soft); margin: 2px 0; }
.admin-tab-panel input[type="text"], .admin-tab-panel input[type="password"], .admin-tab-panel textarea {
  background: var(--bg-1); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: var(--radius-sm); font: inherit; font-size: 13.5px; font-weight: 400;
  resize: vertical;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.switch-row input { width: auto; }

.pairs-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.pairs-col, .pair-item { min-width: 0; }
.pairs-col h4 { margin: 0 0 8px; font-size: 13px; color: var(--gold); }
.pairs-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.pair-item {
  background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
.pair-item-top { display: flex; align-items: center; gap: 6px; }
.pair-item-top .pi-code { font-weight: 800; color: var(--gold); font-size: 12.5px; min-width: 26px; }
.pair-item-top input.pi-org { width: 54px; min-width: 0; font-size: 12px; padding: 5px 6px; }
.pair-item-top input.pi-player { flex: 1; min-width: 36px; font-size: 12px; padding: 5px 6px; }
.pair-item-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.mini-btn {
  border: 1px solid var(--border); background: var(--bg-1); color: var(--text-dim);
  font-size: 11px; padding: 4px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { color: var(--text); border-color: var(--gold-dim); }
.mini-btn.danger { color: var(--crimson); border-color: rgba(226,88,106,0.3); }
.add-pair-btn {
  width: 100%; border: 1px dashed var(--border); background: none; color: var(--text-dim);
  padding: 9px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 12.5px;
}
.add-pair-btn:hover { border-color: var(--gold-dim); color: var(--gold); }

.rounds-admin-list { display: flex; flex-direction: column; gap: 8px; }
.round-admin-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.round-admin-item .ra-label {
  font-weight: 700; font-size: 13px; width: 110px; flex-shrink: 0;
  background: var(--bg-1); border: 1px solid var(--border); color: var(--text);
  padding: 6px 9px; border-radius: 8px; font-family: inherit;
}
.round-admin-item .ra-meta { flex: 1; min-width: 140px; font-size: 12.5px; color: var(--text-dim); }

.import-box { border-top: 1px solid var(--border-soft); padding-top: 12px; }
.import-box summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--text-dim); }
.import-box textarea { width: 100%; margin-top: 8px; font-family: ui-monospace, monospace; font-size: 12px; }
.import-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 12.5px; }
.import-actions label { flex-direction: row !important; align-items: center; gap: 5px !important; font-weight: 400; }

.data-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.data-row:last-of-type { border-bottom: 0; }
.data-row p { margin: 2px 0 0; }
.danger-row strong { color: var(--crimson); }
.file-btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.file-btn:hover { border-color: var(--gold-dim); }

.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item { font-size: 12.5px; color: var(--text-dim); border-bottom: 1px dashed var(--border-soft); padding-bottom: 8px; }
.log-item .lg-time { color: var(--text-faint); margin-right: 8px; }
.log-item .lg-by { color: var(--gold-dim); font-weight: 600; }
.log-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 20px; }

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: #fffdf9;
  border: 1px solid rgba(179, 130, 14, 0.35);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
}
.toast.err { border-color: rgba(173, 39, 64, 0.5); color: #8a1f30; }
.toast.ok { border-color: rgba(23, 138, 94, 0.5); color: #147253; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- Responsive ---------------- */

@media (max-width: 720px) {
  .header-inner { padding: 14px 16px; }
  .brand-text h1 { font-size: 18px; }
  .app-main { padding: 16px 12px 48px; gap: 14px; }
  .match-vs { grid-template-columns: 1fr; }
  .vs-sep { padding-top: 0; }
  .pairs-cols { grid-template-columns: minmax(0, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .my-matches-list { grid-template-columns: 1fr; }
  .pairing-list { grid-template-columns: 1fr; }
  .gen-round-btn { margin-left: 0; width: 100%; }
  .header-actions { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------- 列数多（比如 10 对 10）时的紧凑表格 ---------------- */
.score-grid.dense .col-head { min-width: 68px; padding: 6px 4px !important; }
.score-grid.dense .col-head .ch-players { white-space: normal; line-height: 1.25; }
.score-grid.dense .col-head .ch-org { display: none; }
.score-grid.dense td.cell { min-width: 68px; height: 48px; padding: 4px 2px !important; }
.score-grid.dense .total-cell { min-width: 64px; }
.score-grid.dense .row-head, .score-grid.dense .corner-cell { min-width: 100px; padding: 6px 8px !important; }
.score-grid.dense .row-head .rh-players { white-space: normal; line-height: 1.25; }

/* ---------------- 两队总比分 ---------------- */
.team-card {
  background: linear-gradient(180deg, #fffaf0, #f6ecd2);
  border: 1px solid rgba(179, 130, 14, 0.35);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-lg);
}
.ts-title { font-weight: 800; font-size: 15px; color: var(--gold-dim); margin-bottom: 10px; }
.ts-board { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; }
.ts-side { text-align: center; padding: 10px 6px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.6); border: 1px solid var(--border-soft); }
.ts-side.lead { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(179, 130, 14, 0.18); }
.ts-name { font-weight: 800; font-size: 15px; }
.ts-crown { font-size: 11px; font-weight: 700; color: #fff; background: var(--crimson); padding: 1px 6px; border-radius: 999px; vertical-align: 2px; }
.ts-major { font-size: 38px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1.15; margin: 2px 0; }
.ts-unit { font-size: 12px; font-weight: 700; color: var(--gold-dim); margin-left: 3px; }
.ts-sub { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ts-vs { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-faint); font-weight: 800; }
.ts-vs small { font-size: 11px; font-weight: 500; white-space: nowrap; }
.ts-note { margin-top: 10px; font-size: 11.5px; color: var(--text-faint); text-align: center; }
@media (max-width: 720px) { .ts-major { font-size: 30px; } .ts-sub { font-size: 11px; } }
