
:root {
  color-scheme: dark;
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  --black: #050807;
  --panel: #07100c;
  --line: #246138;
  --soft-line: #162e21;
  --green: #50f387;
  --text: #ddf3e5;
  --muted: #8dab98;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  color: var(--text);
  background: var(--black);
  margin: 0;
  min-width: 300px;
}

.topbar {
  display: grid;
  height: clamp(58px, 7.4vh, 82px);
  place-items: center;
  padding-inline: 14px;
}

h1, h2, p { margin: 0; }

h1 {
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 32px);
  width: min(780px, 100%);
  font-size: clamp(23px, 3.4vw, 46px);
  letter-spacing: 0.11em;
  font-weight: 650;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

h1::before, h1::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--line));
}

h1::after { transform: scaleX(-1); }

.dashboard {
  margin: 0 7px 7px;
  height: calc(100svh - clamp(58px, 7.4vh, 82px) - 7px);
  min-height: 640px;
  display: grid;
  grid-template-rows: minmax(375px, 1fr) clamp(210px, 24vh, 285px);
  border: 1px solid var(--line);
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 48%, #0c1d13 0%, #070f0a 61%, #050907 100%);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 46px;
  padding: 10px clamp(12px, 1.7vw, 26px);
  border-bottom: 1px solid var(--soft-line);
}

.map-head {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  border-bottom: 0;
  min-height: 62px;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: #0a1710;
  color: var(--green);
  font-size: 12px;
  line-height: 1.4;
}

.connection[data-tone="waiting"] { color: #f0d16e; border-color: #685327; }
.connection[data-tone="error"] { color: #ff987e; border-color: #754534; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.map-stage, .map-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-stage { pointer-events: none; }

.map-error {
  position: absolute;
  inset: 48% 0 auto;
  color: #f0d16e;
  text-align: center;
}

.map-meta {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(12px, 1.7vw, 26px);
  color: var(--muted);
  font-size: 11px;
}

.legend { display: flex; align-items: center; gap: 7px; }
.legend-low { color: hsl(135 100% 61%); font-family: var(--mono); }
.legend-high { color: hsl(0 100% 61%); font-family: var(--mono); }

.legend-scale {
  width: clamp(47px, 6.5vw, 100px);
  height: 4px;
  background: linear-gradient(
    90deg, hsl(135 100% 61%), hsl(94 100% 61%) 15%, hsl(53 100% 61%) 30%,
    hsl(26.5 100% 61%) 65%, hsl(0 100% 61%)
  );
}

.details {
  display: grid;
  grid-template-columns: 1.03fr 1fr;
  min-height: 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.rank-panel, .visits-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.rank-panel { border-right: 1px solid var(--line); }

.subtle, .counter { color: var(--muted); font-size: 12px; }
.counter strong { color: var(--green); font: 600 13px var(--mono); }

.rank-body, .list-area {
  min-height: 0;
  overflow-y: auto;
  scrollbar-color: #326346 #07110b;
}

.rank-body { flex: 1; padding: 3px clamp(12px, 1.7vw, 26px) 9px; }
.rank-list { margin: 0; padding: 0; list-style: none; }

.rank-row {
  display: grid;
  grid-template-columns: 2ch minmax(6ch, 1fr) minmax(40px, 2fr) 7ch;
  align-items: center;
  gap: clamp(6px, 1vw, 16px);
  min-height: 30px;
  border-bottom: 1px solid var(--soft-line);
  font-size: 13px;
}

.rank-position, .rank-count { font-family: var(--mono); }
.rank-position { color: var(--muted); }
.rank-count { color: var(--green); text-align: right; }
.rank-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rank-meter { width: 100%; height: 5px; appearance: none; border: 0; background: #142b1d; }
.rank-meter::-webkit-progress-bar { background: #142b1d; }
.rank-meter::-webkit-progress-value { background: #42ba68; }
.rank-meter::-moz-progress-bar { background: #42ba68; }

.latest {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 57px;
  padding: 7px clamp(12px, 1.7vw, 26px);
  background: #0b1810;
  border-bottom: 1px solid var(--soft-line);
}

.latest-address, .latest-score { display: grid; gap: 2px; min-width: 0; }
.latest-score { text-align: right; flex-shrink: 0; }
.ip, .score, .latest time { font-family: var(--mono); }
.latest .ip { font-size: clamp(13px, 1.12vw, 17px); overflow-wrap: anywhere; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.latest .score { color: var(--green); font-size: 20px; line-height: 1; }
.latest time:empty, .latest-address .subtle:empty { display: none; }

.list-area { flex: 1; }
.empty { padding: 13px clamp(12px, 1.7vw, 26px); color: var(--muted); font-size: 13px; }
.rank-body .empty { padding-inline: 0; }

table { width: 100%; text-align: left; border-collapse: separate; border-spacing: 0; font-size: 12px; }
thead { position: sticky; top: 0; z-index: 1; }
th {
  color: var(--muted);
  font-size: 11px;
  background: var(--panel);
  text-wrap: nowrap;
}
th, td { padding: 6px 7px; border-bottom: 1px solid var(--soft-line); }
th:first-child, td:first-child { padding-inline-start: clamp(12px, 1.7vw, 26px); }
th:last-child, td:last-child { padding-inline-end: clamp(12px, 1.7vw, 26px); text-align: right; }
td.ip { overflow-wrap: anywhere; }
td:first-child { width: 8ch; }

@media (max-width: 700px) {
  .dashboard { height: auto; grid-template-rows: clamp(320px, 55svh, 500px) auto; }
  .map-head { min-height: 48px; }
  .details { grid-template-columns: 1fr; }
  .rank-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .rank-body { min-height: 66px; max-height: 190px; }
  .list-area { min-height: 55px; max-height: 245px; }
  .map-meta { align-items: end; }
  .map-credits { text-align: right; }
}
