:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #15181d;
  --muted: #5c6776;
  --border: #e2e6eb;
  --grid: #edf0f3;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --panel: #161a21;
    --text: #e7ebf0;
    --muted: #94a0ae;
    --border: #262c35;
    --grid: #1f252d;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.16);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

.site-header,
.page,
.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding-inline: 16px;
}

.site-header {
  padding-block: 20px 8px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand span {
  color: var(--muted);
  font-weight: 500;
}

.site-footer {
  padding-block: 40px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 12px 0 2px;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.muted {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.status {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

.page > .status {
  margin-top: 16px;
}

.back {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.back:hover {
  color: var(--text);
}

/* ---- game list ---- */

.app-list {
  margin: 20px 0 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.app-list li + li {
  border-top: 1px solid var(--border);
}

.app-row {
  display: grid;
  grid-template-columns: 24px 120px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 10px 16px;
  text-decoration: none;
}

.app-row:hover,
.app-row:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

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

.art {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 460 / 215;
  overflow: hidden;
  border-radius: 6px;
  background: var(--grid);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.count small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* ---- game detail ---- */

.app-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin: 12px 0 20px;
}

.app-head .art {
  width: 184px;
  flex: none;
}

.app-head h1 {
  margin-top: 0;
}

.chart-panel {
  padding: 16px;
}

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

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

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

.stat-value {
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.stat-value small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.range-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.range-tabs button {
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.range-tabs button:hover {
  color: var(--text);
}

.range-tabs button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.chart {
  position: relative;
  min-height: 300px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 300px;
  touch-action: pan-y;
}

.chart.loading svg {
  opacity: 0.45;
  transition: opacity 0.15s;
}

.chart .grid line {
  stroke: var(--grid);
}

.chart .axis text {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .area {
  fill: var(--accent-soft);
}

.chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart .dot {
  fill: var(--accent);
}

.chart .cursor line {
  stroke: var(--muted);
  stroke-dasharray: 3 3;
}

.chart .cursor circle {
  fill: var(--panel);
  stroke: var(--accent);
  stroke-width: 2;
}

.tooltip {
  position: absolute;
  top: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

.tooltip strong {
  font-variant-numeric: tabular-nums;
}

.tooltip .muted {
  font-size: 12px;
}

@media (max-width: 560px) {
  .app-row {
    grid-template-columns: 18px 72px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .app-head .art {
    width: 120px;
  }

  .range-tabs {
    width: 100%;
  }

  .range-tabs button {
    flex: 1;
    padding-inline: 0;
  }
}
