:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --ink: #17212b;
  --muted: #66727f;
  --line: #dce2e7;
  --green: #0b6f68;
  --green-soft: #dff0ed;
  --gold: #d49a2a;
  --red: #b6404d;
  --blue: #2f6ea5;
  --shadow: 0 18px 44px rgba(20, 33, 43, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 920px;
  font-size: clamp(34px, 4.8vw, 66px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
}

.top-actions,
.status-copy,
.detail-badges,
.position-filter,
.quick-chips {
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-pill,
.status-label {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.icon-button,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  box-shadow: 0 6px 18px rgba(20, 33, 43, 0.07);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.icon-button:hover,
.ghost-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

svg {
  width: 18px;
  height: 18px;
}

.status-band {
  display: grid;
  grid-template-columns: 1fr 230px;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

#statusText {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

progress {
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e6ebef;
}

progress::-webkit-progress-bar {
  background: #e6ebef;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--green), var(--gold));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(160px, 0.8fr) minmax(220px, 1fr) 96px minmax(150px, 0.8fr) minmax(150px, 0.8fr);
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 33, 43, 0.06);
}

.search-panel label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.search-panel label > span,
.panel-head span,
.meta,
.detail-stat span,
.title-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(11, 111, 104, 0.14);
}

.position-filter {
  grid-column: 1 / -1;
  flex-wrap: wrap;
}

.segmented {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.segmented.active,
.segmented:hover {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

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

.metric,
.detail-stat {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric strong,
.detail-stat strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 28px;
  line-height: 1;
}

.metric b,
.detail-stat b {
  color: var(--green);
  font-size: 12px;
}

.metric.tone-1 strong {
  color: var(--blue);
}

.metric.tone-2 strong {
  color: var(--gold);
}

.metric.tone-3 strong {
  color: var(--red);
}

.leaderboards-panel {
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.leaderboard-card {
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.leaderboard-card:nth-child(4n) {
  border-right: 0;
}

.leaderboard-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.leaderboard-title h3 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.leaderboard-list {
  padding: 6px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
}

.leaderboard-row:hover {
  border-color: var(--green);
  background: #eef8f6;
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.leader-name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.leader-name strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-name small,
.leaderboard-row b small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.leaderboard-row b {
  color: var(--green);
  font-size: 18px;
  text-align: right;
  white-space: nowrap;
}

.leaderboard-row b small {
  margin-left: 3px;
}

.compact-empty {
  padding: 18px 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(0, 2fr);
  gap: 14px;
  align-items: start;
}

.player-list-panel,
.detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.player-list-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

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

.panel-head > div {
  min-width: 0;
}

.quick-chips {
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.chip {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 0 10px;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.chip:hover {
  border-color: var(--gold);
  background: #fff7e5;
}

.player-list {
  overflow: auto;
  padding: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 70px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.player-row:hover,
.player-row.active {
  border-color: var(--green);
  background: #eef8f6;
}

.avatar,
.portrait {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #dce8ed, #f7fafb);
  color: var(--green);
  font-weight: 900;
}

button.avatar,
button.portrait {
  border: 0;
  padding: 0;
  cursor: zoom-in;
}

button.avatar:hover,
button.portrait:hover {
  outline: 3px solid rgba(11, 111, 104, 0.22);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.avatar img,
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 24px;
}

.photo-modal.open {
  display: grid;
}

.photo-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 22, 30, 0.72);
}

.photo-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: min(760px, 100%);
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.photo-dialog img {
  width: 100%;
  max-height: min(78vh, 760px);
  border-radius: 8px;
  object-fit: contain;
  background: #edf2f4;
}

.photo-dialog figcaption {
  color: var(--ink);
  font-weight: 850;
  text-align: center;
}

.photo-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  background: rgba(23, 33, 43, 0.76);
  color: #fff;
  cursor: pointer;
}

.photo-close:hover {
  background: var(--green);
}

.player-row-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.player-row-main strong,
.leader-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-row-main span,
.row-stats small {
  color: var(--muted);
  font-size: 12px;
}

.mini-flag {
  width: 18px;
  height: 13px;
  margin-right: 5px;
  border: 1px solid rgba(23, 33, 43, 0.14);
  border-radius: 2px;
  object-fit: cover;
  vertical-align: -2px;
}

.row-stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 4px;
  color: var(--green);
  font-size: 12px;
  text-align: right;
}

.row-stats b {
  font-size: 15px;
}

.player-detail {
  min-height: 680px;
}

.empty-detail {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 44px 22px;
  color: var(--muted);
  text-align: center;
}

.empty-detail svg {
  width: 38px;
  height: 38px;
  color: var(--green);
}

.empty-detail p {
  max-width: 560px;
  line-height: 1.7;
}

.detail-hero {
  display: grid;
  grid-template-columns: 134px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.portrait {
  width: 134px;
  height: 134px;
  border-radius: 8px;
  font-size: 38px;
}

.detail-title {
  min-width: 0;
}

.detail-title h2 {
  margin: 6px 0 12px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.detail-badges {
  flex-wrap: wrap;
}

.detail-badges span {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.detail-stat {
  min-height: 124px;
  border-width: 0 1px 0 0;
  border-radius: 0;
}

.detail-stat:last-child {
  border-right: 0;
}

.event-breakdown-section {
  border-bottom: 1px solid var(--line);
}

.event-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.breakdown-row:nth-child(4n) {
  border-right: 0;
}

.breakdown-row strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-row span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.breakdown-row b {
  min-width: 42px;
  color: var(--green);
  font-size: 24px;
  text-align: right;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: 0;
}

.detail-section {
  min-width: 0;
}

.detail-section + .detail-section {
  border-left: 1px solid var(--line);
}

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

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

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

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

tbody tr:hover {
  background: #f8fbfb;
}

.event-stack {
  max-height: 560px;
  overflow: auto;
  padding: 8px 0;
}

.event-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.event-minute {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 30px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.event-row p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.event-row b {
  color: var(--blue);
  font-size: 12px;
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
}

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

  .metric-grid,
  .detail-stats {
    grid-template-columns: repeat(3, 1fr);
  }

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

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

  .leaderboard-card:nth-child(4n) {
    border-right: 1px solid var(--line);
  }

  .leaderboard-card:nth-child(2n) {
    border-right: 0;
  }

  .breakdown-row:nth-child(4n) {
    border-right: 1px solid var(--line);
  }

  .breakdown-row:nth-child(2n) {
    border-right: 0;
  }

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

  .player-list-panel {
    position: static;
    max-height: none;
  }

  .player-list {
    max-height: 520px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1540px);
    padding-top: 18px;
  }

  .topbar {
    flex-direction: column;
    gap: 14px;
  }

  .status-band,
  .search-panel,
  .metric-grid,
  .detail-stats,
  .leaderboard-grid,
  .event-breakdown,
  .detail-grid,
  .detail-hero {
    grid-template-columns: 1fr;
  }

  .leaderboard-card,
  .leaderboard-card:nth-child(2n),
  .leaderboard-card:nth-child(4n) {
    border-right: 0;
  }

  .breakdown-row,
  .breakdown-row:nth-child(2n),
  .breakdown-row:nth-child(4n) {
    border-right: 0;
  }

  h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .detail-section + .detail-section {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .portrait {
    width: 110px;
    height: 110px;
  }

  .player-row {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .row-stats {
    grid-column: 2;
    grid-template-columns: repeat(4, auto);
    justify-content: start;
  }
}
