:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --text: #1d1b22;
  --muted: #6b6775;
  --border: #e3e0e8;
  --accent: #d6336c;
  --accent-soft: #fbe4ec;
  --up: #1f8a4c;
  --down: #c0392b;
  --gold: #c9a227;
  --silver: #9aa0a6;
  --bronze: #b0703a;
  --yt: #e62117;
  --nico: #4a4a4a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141217;
    --surface: #1e1b22;
    --text: #ecebef;
    --muted: #a19daa;
    --border: #2f2b35;
    --accent: #f06595;
    --accent-soft: #3a1f2a;
    --up: #4cc47f;
    --down: #ef6b5b;
    --nico: #b8b8b8;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 0; }
.site-header h1 { margin: 0; font-size: 1.4rem; }
.site-header h1 a { text-decoration: none; color: var(--accent); }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.tabs { display: flex; gap: 4px; margin: 20px 0 12px; border-bottom: 2px solid var(--border); }
.tabs button {
  flex: 1; max-width: 140px; padding: 10px 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.controls label { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.controls select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;
}
.period-info { color: var(--muted); font-size: .85rem; margin: 4px 0 12px; }
.badge { display: inline-block; font-size: .75rem; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; }

.ranking { list-style: none; margin: 0 0 32px; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: 52px 128px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.rank { text-align: center; }
.rank .num { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.rank .move { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.rank .move.up { color: var(--up); }
.rank .move.down { color: var(--down); }
.rank .move.new { color: var(--accent); font-weight: 700; }
.item:nth-child(1) .num { color: var(--gold); }
.item:nth-child(2) .num { color: var(--silver); }
.item:nth-child(3) .num { color: var(--bronze); }
.thumb { width: 128px; aspect-ratio: 16 / 9; border-radius: 6px; background: var(--border); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.info { min-width: 0; }
.title { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.title:hover { text-decoration: underline; }
.artist { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: .75rem; }
.links a { text-decoration: none; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
.links a.yt { color: var(--yt); }
.links a.nico { color: var(--nico); }
.links .date { color: var(--muted); }
.score { text-align: right; font-variant-numeric: tabular-nums; }
.score .main { font-size: 1.15rem; font-weight: 800; }
.score .main small { font-size: .7rem; font-weight: 400; color: var(--muted); margin-left: 2px; }
.score .sub { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; padding: 16px 0 32px; }

@media (max-width: 640px) {
  .item { grid-template-columns: 40px 88px 1fr; }
  .thumb { width: 88px; }
  .score { grid-column: 2 / -1; text-align: left; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
  .rank .num { font-size: 1.2rem; }
}
