:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1b1f23;
  --panel-2: #22272c;
  --line: #343b42;
  --text: #edf1f3;
  --muted: #9da7ae;
  --accent: #44c27f;
  --accent-2: #4fb3d8;
  --warn: #e0b45c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid #405047;
}

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

h1 {
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0;
}

#subline {
  margin-top: 4px;
  color: var(--muted);
}

.toolbar button,
.controls input,
.controls select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
}

.toolbar button {
  padding: 0 14px;
  cursor: pointer;
}

.toolbar button:hover {
  border-color: var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

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

.metric {
  min-height: 88px;
  padding: 13px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.bar {
  height: 7px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #2a3035;
}

.bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--warn));
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 56px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-subline {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.controls input {
  width: min(260px, 34vw);
  padding: 0 10px;
}

.controls select {
  padding: 0 8px;
}

.table-wrap {
  max-height: 861px;
  min-height: 861px;
  overflow: auto;
}

.load-more-wrap {
  min-height: 48px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

#load-more {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

#load-more:hover:not(:disabled) {
  border-color: var(--accent);
}

#load-more:disabled {
  color: var(--muted);
  cursor: wait;
}

#load-more[hidden] {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid #293037;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #181c20;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

td.name {
  white-space: normal;
  min-width: 160px;
  font-weight: 650;
}

tr {
  cursor: pointer;
}

tr:hover,
tr.selected {
  background: #202a26;
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.players {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail {
  padding-bottom: 14px;
}

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

.side-stats > div {
  min-height: 76px;
  padding: 12px 14px;
  background: var(--panel);
}

.side-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

#history-chart {
  width: 100%;
  height: 240px;
  display: block;
  background: #171b1f;
  border-bottom: 1px solid var(--line);
}

.history-meta {
  min-height: 42px;
  padding: 10px 14px;
  color: var(--muted);
}

.peak-list {
  margin: 8px 0 0;
  padding: 0 14px 0 42px;
}

.peak-list li {
  padding: 7px 0;
  border-bottom: 1px solid #293037;
}

.peak-list strong {
  color: var(--accent-2);
}

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

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

  .table-wrap {
    max-height: none;
    min-height: 480px;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .controls {
    width: 100%;
  }

  .controls input,
  .controls select {
    width: 100%;
  }

  .side-stats {
    grid-template-columns: 1fr;
  }
}
