:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --ink: #1b1d1f;
  --muted: #6c7076;
  --line: #ded8cf;
  --panel: #fffdf8;
  --accent: #b8442d;
  --accent-dark: #822e20;
  --green: #25745a;
  --shadow: 0 18px 50px rgba(28, 25, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.page-tabs a,
.page-tabs button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
}

.page-tabs a.active,
.page-tabs button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

.status {
  min-width: 180px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
}

.status span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 14px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.summary-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
}

.team,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.team {
  overflow: hidden;
}

.team-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.team-head h2 {
  margin: 4px 0 0;
}

.rank {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.team-score {
  color: var(--accent-dark);
  font-size: 36px;
}

.players {
  display: grid;
}

.player-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 0.8fr;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid rgba(222, 216, 207, 0.68);
}

.player-row.is-live {
  background: rgba(37, 116, 90, 0.1);
  box-shadow: inset 4px 0 0 var(--green);
}

.player-row:first-child {
  border-top: 0;
}

.player-name {
  color: var(--ink);
  font-weight: 800;
  text-decoration-color: rgba(184, 68, 45, 0.35);
  text-underline-offset: 4px;
}

.player-name:hover {
  color: var(--accent-dark);
}

.player-subinfo {
  margin-top: 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

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

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 20px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.link-button:hover {
  background: var(--accent-dark);
}

.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.secondary:hover {
  background: #f1ece3;
}

.message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--green);
}

.hidden {
  display: none;
}

.runs-table {
  display: grid;
  gap: 8px;
}

.data-table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

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

td a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration-color: rgba(184, 68, 45, 0.35);
  text-underline-offset: 4px;
}

.table-sort {
  min-height: auto;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.table-sort:hover {
  background: transparent;
  color: var(--accent-dark);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat-panel {
  min-height: 132px;
  display: grid;
  align-content: space-between;
}

.stat-panel span,
.section-head span,
.run-note {
  color: var(--muted);
}

.stat-panel strong {
  color: var(--accent-dark);
  font-size: 44px;
  line-height: 1;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin-bottom: 0;
}

.detail-runs {
  display: grid;
}

.run-row {
  display: grid;
  grid-template-columns: 1fr 0.8fr 0.6fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-run-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 2fr;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.detail-run-row:last-child,
.run-row:last-child {
  border-bottom: 0;
}

.empty {
  margin: 12px 0 0;
  color: var(--muted);
}

.clips-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.clip-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}

.clip-card h2 {
  margin-bottom: 8px;
}

.clip-card p {
  color: var(--muted);
}

.login-grid,
.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.score-form {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: auto;
}

.login-grid button {
  align-self: end;
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-nav span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-stats div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.mini-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mini-stats strong {
  display: block;
  font-size: 22px;
}

.admin-run-row {
  display: grid;
  grid-template-columns: 0.8fr 1.7fr 0.7fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.live-info-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.live-info-list div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.live-info-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.live-info-list strong,
.live-info-list a {
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.admin-run-row:last-child {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.danger {
  background: #6f2320;
}

@media (max-width: 760px) {
  .topbar,
  .admin-grid {
    display: grid;
  }

  .scoreboard {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .clips-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-row,
  .run-row,
  .detail-run-row,
  .login-grid,
  .form-row,
  .admin-run-row,
  .live-info-list {
    grid-template-columns: 1fr 1fr;
  }

  .admin-nav {
    display: grid;
  }
}
