:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a1f2b;
  --muted: #6b7280;
  --border: #e5e9f0;
  --primary: #2563eb;
  --primary-ink: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-ink); }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.main { padding: 28px 20px 60px; min-height: 60vh; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-weight: 700; font-size: 19px; color: var(--text); letter-spacing: .2px; }
.logo:hover { color: var(--text); }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 500;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.active { color: var(--primary); background: #eef4ff; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.site-footer .container { padding: 18px 20px; font-size: 13px; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-title { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
.section-title { font-size: 20px; font-weight: 700; margin: 28px 0 14px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Hero */
.hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.hero h1 { margin: 0 0 6px; font-size: 26px; }
.hero .sub { color: var(--muted); margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { background: #fafbfc; font-weight: 600; color: #374151; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfc; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-ink); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 7px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* Tags / badges */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.tag-male { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.tag-female { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ongoing { background: #fef3c7; color: #92400e; }
.badge-finished { background: #dcfce7; color: #166534; }
.badge-upcoming { background: #e0e7ff; color: #3730a3; }
.badge-waiting { background: #fff7ed; color: #9a3412; }
.badge-score { background: #eef4ff; color: var(--primary); }

/* Season cards */
.season-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.season-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; display: block; color: var(--text); }
.season-card:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 8px 20px rgba(16,24,40,.08); color: var(--text); }
.season-card .season-name { font-size: 17px; font-weight: 700; }
.season-card .season-date { color: var(--muted); font-size: 13px; margin-top: 4px; }
.season-card .champion { margin-top: 12px; font-size: 14px; }
.champion-name { color: var(--warning); font-weight: 700; }

/* Bracket */
.bracket { display: flex; gap: 22px; overflow-x: auto; padding-bottom: 12px; }
.bracket-round { flex: 1 0 220px; }
.bracket-round .round-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.match-node { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.match-node .side { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.match-node .side.winner { font-weight: 700; color: var(--success); }
.match-node .score { color: var(--muted); font-variant-numeric: tabular-nums; }
.match-node .match-meta { color: var(--muted); font-size: 12px; margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 6px; }

/* Admin */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #111827; color: #e5e7eb; flex-shrink: 0; padding: 18px 0; }
.sidebar .brand { padding: 0 18px 16px; font-weight: 700; font-size: 17px; color: #fff; }
.sidebar a { display: block; padding: 10px 18px; color: #cbd5e1; font-size: 14px; }
.sidebar a:hover { background: #1f2937; color: #fff; }
.sidebar a.active { background: #1f2937; color: #fff; border-right: 3px solid var(--primary); }
.sidebar .spacer { height: 14px; }
.admin-main { flex: 1; padding: 24px 28px; overflow-x: hidden; }
.admin-main .topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.admin-main h1 { font-size: 22px; margin: 0; }

@media (max-width: 760px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; }
  .sidebar .brand, .sidebar .spacer { display: none; }
  .sidebar a { padding: 7px 10px; }
}

.hint { color: var(--muted); font-size: 13px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.right { text-align: right; }

/* Player list row */
.player-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.player-row .pname { font-weight: 600; font-size: 15px; }
.player-row .pmeta { color: var(--muted); font-size: 13px; }
.player-row .ppts { text-align: right; }
.player-row .ppts .num { font-size: 17px; font-weight: 700; color: var(--primary); }
.player-row .tags { display: flex; gap: 6px; align-items: center; }

/* 淘汰赛括号 */
.bracket-holder { overflow-x: auto; padding-bottom: 6px; }
.bracket-lines { display: block; }
.bracket-line { fill: none; stroke: #c3ccd8; stroke-width: 2; }
.bracket-node {
  position: absolute; z-index: 1;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 7px 10px;
  display: flex; flex-direction: column; justify-content: center;
}
.bn-side { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; border-radius: 4px; }
.bn-side.is-winner .bn-name { color: var(--success); font-weight: 700; }
.bn-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 600; }
.bn-side.is-winner .bn-score { color: var(--success); }
.bn-meta { margin-top: 5px; padding-top: 5px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }