:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --ink: #171a1f;
  --muted: #606a76;
  --line: #d9dfd7;
  --panel: #ffffff;
  --panel-soft: #fafbf8;
  --accent: #c54639;
  --accent-dark: #8e3029;
  --blue: #2867c7;
  --gold: #9b6b18;
  --green: #1f7a5a;
  --danger: #7a2623;
  --team-a: #f29a2e;
  --team-a-soft: #fff2df;
  --team-a-line: #f3c485;
  --team-b: #6456d8;
  --team-b-soft: #efedff;
  --team-b-line: #c4bdf7;
  --team-c: #cf6f8e;
  --team-c-soft: #fff0f6;
  --team-c-line: #efb8ca;
  --team-d: #bd8a20;
  --team-d-soft: #fff6dc;
  --team-d-line: #e7c66d;
  --shadow: 0 14px 36px rgba(31, 38, 48, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fafbf8 0, var(--bg) 360px),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(217, 223, 215, 0.82);
}

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

.page-tabs a,
.page-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 0 15px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.page-tabs a:hover,
.page-tabs button:hover {
  border-color: rgba(40, 103, 199, 0.45);
  background: #f4f8ff;
}

.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(36px, 5vw, 60px);
  line-height: 1.05;
  letter-spacing: 0;
}

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

.status {
  min-width: 180px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(31, 38, 48, 0.06);
}

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

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

.summary-grid,
.podium-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

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

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

.summary-card {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-top: 3px solid var(--blue);
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 8px 20px rgba(31, 38, 48, 0.06);
}

.summary-card:nth-child(2) {
  border-top-color: var(--accent);
}

.summary-card:nth-child(3) {
  border-top-color: var(--gold);
}

.summary-card:nth-child(4) {
  border-top-color: var(--green);
}

.summary-card:nth-child(5) {
  border-top-color: #5b65bd;
}

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

.summary-card strong {
  display: block;
  font-size: clamp(21px, 2vw, 26px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.podium-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 10px 28px rgba(31, 38, 48, 0.08);
}

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

.podium-card strong {
  display: block;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.podium-card em {
  display: block;
  margin-top: 8px;
  color: var(--accent-dark);
  font-style: normal;
  font-size: 20px;
  font-weight: 900;
}

.podium-card-1 {
  border-top: 4px solid var(--gold);
}

.podium-card-2 {
  border-top: 4px solid var(--blue);
}

.podium-card-3 {
  border-top: 4px solid var(--green);
}

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

.team {
  overflow: hidden;
}

.team-card-team-1 {
  border-color: var(--team-a-line);
  background: var(--team-a-soft);
}

.team-card-team-2 {
  border-color: var(--team-b-line);
  background: var(--team-b-soft);
}

.team-card-team-3 {
  border-color: var(--team-c-line);
  background: var(--team-c-soft);
}

.team-card-team-4 {
  border-color: var(--team-d-line);
  background: var(--team-d-soft);
}

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

.team-card-team-1 .team-head {
  background: linear-gradient(180deg, #fff8ee, var(--team-a-soft));
}

.team-card-team-2 .team-head {
  background: linear-gradient(180deg, #f8f7ff, var(--team-b-soft));
}

.team-card-team-3 .team-head {
  background: linear-gradient(180deg, #fff8fb, var(--team-c-soft));
}

.team-card-team-4 .team-head {
  background: linear-gradient(180deg, #fffbed, var(--team-d-soft));
}

.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: clamp(30px, 4vw, 42px);
  line-height: 1;
  white-space: nowrap;
}

.team-card-team-1 .team-score,
.team-card-team-1 .player-row .metric strong,
.team-card-team-1 .player-name:hover {
  color: #a65a08;
}

.team-card-team-2 .team-score,
.team-card-team-2 .player-row .metric strong,
.team-card-team-2 .player-name:hover {
  color: #5243c4;
}

.team-card-team-3 .team-score,
.team-card-team-3 .player-row .metric strong,
.team-card-team-3 .player-name:hover {
  color: #b94f73;
}

.team-card-team-4 .team-score,
.team-card-team-4 .player-row .metric strong,
.team-card-team-4 .player-name:hover {
  color: #9b6f12;
}

.players {
  display: grid;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, auto);
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 14px 20px;
  border-top: 1px solid rgba(217, 223, 215, 0.76);
  transition: background 0.14s ease;
}

.team-card-team-1 .player-row {
  border-top-color: rgba(243, 196, 133, 0.65);
}

.team-card-team-2 .player-row {
  border-top-color: rgba(196, 189, 247, 0.75);
}

.team-card-team-3 .player-row {
  border-top-color: rgba(239, 184, 202, 0.72);
}

.team-card-team-4 .player-row {
  border-top-color: rgba(231, 198, 109, 0.68);
}

.player-row:hover {
  background: #f8faf6;
}

.player-row.is-live {
  background: #eaf5ef;
  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(--blue);
}

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

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

.player-row .metric {
  text-align: right;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.player-row .metric strong {
  color: var(--accent-dark);
  font-size: clamp(24px, 3vw, 32px);
}

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

.admin-workbench {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.player-sidebar {
  box-shadow: 0 8px 24px rgba(31, 38, 48, 0.08);
}

.score-editor {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 20px;
}

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

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(40, 103, 199, 0.22);
  border-color: var(--blue);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

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: #f4f8ff;
}

.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: 560px;
  background: var(--panel);
}

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

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

tbody tr.rank-row-team-1 {
  background: var(--team-a-soft);
}

tbody tr.rank-row-team-2 {
  background: var(--team-b-soft);
}

tbody tr.rank-row-team-3 {
  background: var(--team-c-soft);
}

tbody tr.rank-row-team-4 {
  background: var(--team-d-soft);
}

tbody tr.rank-row-team-1 td {
  border-bottom-color: rgba(243, 196, 133, 0.65);
}

tbody tr.rank-row-team-2 td {
  border-bottom-color: rgba(196, 189, 247, 0.75);
}

tbody tr.rank-row-team-3 td {
  border-bottom-color: rgba(239, 184, 202, 0.72);
}

tbody tr.rank-row-team-4 td {
  border-bottom-color: rgba(231, 198, 109, 0.68);
}

td a {
  color: var(--blue);
  font-weight: 700;
  text-decoration-color: rgba(40, 103, 199, 0.32);
  text-underline-offset: 4px;
}

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

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

.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: clamp(32px, 4vw, 44px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.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: 0 8px 24px rgba(31, 38, 48, 0.08);
}

.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 {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.score-form label {
  margin-bottom: 0;
}

.score-form .message {
  grid-column: 1 / -1;
}

.admin-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.admin-toggle-row button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.compact-tabs {
  margin-bottom: 0;
}

.collapsible-panel {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.process-list {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 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);
}

.super-player-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(110px, 0.45fr) minmax(220px, 1.4fr) minmax(120px, 0.45fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.super-player-row label {
  margin-bottom: 0;
}

.super-player-name {
  display: grid;
  gap: 4px;
  align-self: center;
}

.super-player-name span {
  color: var(--muted);
  font-size: 12px;
}

.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: var(--danger);
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .detail-grid,
  .live-info-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 680px);
    padding-top: 20px;
  }

  .topbar,
  .admin-grid,
  .admin-workbench {
    display: grid;
    align-items: start;
  }

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

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

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

  .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,
  .score-form,
  .super-player-row {
    grid-template-columns: 1fr 1fr;
  }

  .admin-nav {
    display: grid;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 34px;
  }

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

  .score-form,
  .super-player-row {
    grid-template-columns: 1fr;
  }

  .player-row .metric {
    text-align: left;
  }

  .team-head,
  .section-head,
  .admin-nav {
    align-items: flex-start;
  }

  .team-head,
  .section-head {
    display: grid;
  }

  .team-score {
    white-space: normal;
  }

  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
