:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --bar-other: #d6d5ce;
  --no-data: #e8e7e2;
  --up: #006300;
  --down: #b42f2f;

  --hover-stroke: #0b0b0b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255,255,255,0.10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --bar-other: #3a3a37;
    --no-data: #2a2a28;
    --up: #0ca30c;
    --down: #e66767;

    --hover-stroke: #ffffff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10); --accent: #3987e5;
  --accent-ink: #86b6ef; --bar-other: #3a3a37; --no-data: #2a2a28; --up: #0ca30c; --down: #e66767;
  --hover-stroke: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji";
  font-size: 14px; line-height: 1.5;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 40px; }
header h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: .02em; }
header p { margin: 0; color: var(--ink-2); font-size: 13px; }
header .tagline { font-size: 16px; font-weight: 600; color: var(--ink); margin: 2px 0 4px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); vertical-align: 3px; margin-left: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; margin: 18px 0 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; border: 0; background: transparent; color: var(--ink-2); padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.notice { font-size: 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid #fab219; border-radius: 6px; padding: 6px 10px; margin-bottom: 14px; display: none; }
.notice.show { display: block; }

.grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 960px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 2px; }
.card .sub { font-size: 12px; color: var(--muted); margin: 0 0 10px; }

#map svg { width: 100%; height: auto; display: block; }
#map .tile { cursor: pointer; outline: none; }
#map .tile rect { stroke: var(--surface); stroke-width: 0; }
#map .tile:hover rect, #map .tile:focus-visible rect { stroke: var(--hover-stroke); stroke-width: 1.5; }
#map .tile.selected rect { stroke: var(--hover-stroke); stroke-width: 2.5; }
#map .tn { font-size: 12px; font-weight: 600; }
#map .tv { font-size: 10.5px; font-variant-numeric: tabular-nums; }
.map-top { font-size: 12px; color: var(--ink-2); margin: 0 0 8px; display: grid; gap: 2px; }
.map-top .k { display: inline-block; min-width: 5.5em; font-weight: 600; color: var(--ink); }
.map-top .k.up { color: var(--up); } .map-top .k.down { color: var(--down); }
.legend { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend .ramp { height: 10px; width: 220px; border-radius: 3px; }
.legend .ticks { display: flex; justify-content: space-between; width: 220px; font-variant-numeric: tabular-nums; }
.legend .chip { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: 12px; }
.flag { width: 16px; height: 12px; vertical-align: -1px; margin-right: 4px; border-radius: 1px; box-shadow: 0 0 0 0.5px rgba(0,0,0,.25); object-fit: cover; }
.legend .chip[data-key] { cursor: pointer; border-radius: 6px; padding: 2px 6px; margin: -2px -6px; }
.legend .chip[data-key]:hover { background: var(--page); }
.legend .chip.on { font-weight: 700; color: var(--ink); background: var(--page); box-shadow: inset 0 0 0 1px var(--border); }
.legend .chip.dim { opacity: .45; }
.legend .chip i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .nd { display: inline-flex; align-items: center; gap: 4px; }
.legend .nd i { width: 12px; height: 10px; background: var(--no-data); border-radius: 2px; display: inline-block; }

.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel-head button { font: inherit; font-size: 12px; background: none; border: 1px solid var(--border); color: var(--ink-2); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 10px 0 16px; }
.tile { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile .k { font-size: 11px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 650; margin-top: 2px; }
.tile .v .flag { width: 26px; height: 19.5px; vertical-align: -2px; margin-right: 6px; }
.tile .k .flag { width: 14px; height: 10.5px; margin-right: 3px; }
.grid2 .tiles { margin: 0 0 14px; }
.tile .d { font-size: 12px; color: var(--ink-2); }
.up { color: var(--up); } .down { color: var(--down); }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr 1fr; } .tile .v { font-size: 18px; } }

.section-title { font-size: 13px; font-weight: 600; margin: 4px 0 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-title .seg button { padding: 2px 10px; font-size: 12px; }
svg text { fill: var(--ink-2); font-size: 11px; }
svg .axis text { fill: var(--muted); font-variant-numeric: tabular-nums; }
svg .axis path, svg .axis line { stroke: var(--axis); }
svg .gridline line { stroke: var(--grid); }
svg .gridline path { display: none; }
.bar-row { cursor: pointer; }
.bar-row:hover .bar-hit { fill: var(--grid); }

.tooltip { position: fixed; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); opacity: 0; transition: opacity .1s; z-index: 10; max-width: 260px; }
.tooltip b { font-size: 13px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.tooltip .row span:first-child { color: var(--ink-2); }

.rank { margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th { font-size: 11px; color: var(--muted); font-weight: 500; }
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--page); }
tbody tr.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.table-scroll { overflow-x: auto; }
.lowp { color: var(--muted); font-size: 11px; }
.more { margin-top: 8px; font: inherit; font-size: 12px; background: none; border: 1px solid var(--border); color: var(--ink-2); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.rank-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }

.modes { margin: 16px 0 0; }
.rank-pick select { min-width: 90px; }
.modes button { padding: 8px 16px; font-weight: 600; }
body[data-mode="in"] .only-dom, body[data-mode="dom"] .only-in { display: none !important; }
#rank-card, #vol-card { margin-top: 16px; }
#vol-card .seg button { padding: 3px 12px; font-size: 12px; }
#map3 svg { width: 100%; height: auto; display: block; }
#map3 .tile { cursor: pointer; outline: none; }
#map3 .tile:hover rect, #map3 .tile:focus-visible rect { stroke: var(--hover-stroke); stroke-width: 1.5; }
#map3 .tile.selected rect { stroke: var(--hover-stroke); stroke-width: 2.5; }
#map3 .tn { font-size: 12px; font-weight: 600; }
#map3 .tv { font-size: 10.5px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }
.rank-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
#map2 svg { width: 100%; height: auto; display: block; }
#map2 .tile { cursor: pointer; outline: none; }
#map2 .tile:hover rect, #map2 .tile:focus-visible rect { stroke: var(--hover-stroke); stroke-width: 1.5; }
#map2 .tile.selected rect { stroke: var(--hover-stroke); stroke-width: 2.5; }
#map2 .tn { font-size: 12px; font-weight: 600; }
#map2 .tv { font-size: 10.5px; }
.jump { font: inherit; font-size: 12px; margin-top: 4px; justify-self: start; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); border-radius: 999px; padding: 3px 12px; cursor: pointer; }
.jump:hover { background: var(--accent); color: #fff; }
#map .tx { font-size: 10px; font-variant-numeric: tabular-nums; }
footer { margin-top: 20px; font-size: 11px; color: var(--muted); line-height: 1.7; }
footer a { color: inherit; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: inherit; }
.pagetabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; }
.pagetabs a { text-decoration: none; font-weight: 600; font-size: 14px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); }
.pagetabs a[aria-current] { background: var(--accent); color: #fff; border-color: var(--accent); }
.hub { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }
.hub a { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: block; }
.hub a:hover { border-color: var(--accent); }
.hub h2 { font-size: 18px; margin: 0 0 6px; }
.hub p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.hub .go { display: inline-block; margin-top: 10px; color: var(--accent); font-weight: 600; font-size: 13px; }
.donut-wrap { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 16px; align-items: center; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { width: 100%; max-width: 220px; height: auto; display: block; }
.donut-legend { display: grid; gap: 4px; width: 100%; }
.dl { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 8px; align-items: center; font-size: 13px; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.dl:hover { background: var(--page); }
.dl.other { cursor: default; color: var(--ink-2); }
.dl.on { font-weight: 700; background: var(--page); }
.dl i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dl .s { font-variant-numeric: tabular-nums; font-weight: 600; }
.dl .v { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 4.5em; text-align: right; }
.rank-table { max-height: 560px; overflow: auto; border: 1px solid var(--grid); border-radius: 8px; }
.rank-table table { font-size: 12px; }
.rank-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; text-align: left; }
.rank-table td, .rank-table th { text-align: left; padding: 5px 6px; }
.rank-table tbody tr { cursor: pointer; }
.rank-table tbody tr:hover { background: var(--page); }
.rank-table tr.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.rank-table tr.nation td { border-bottom: 2px solid var(--axis); }
.rank-table th.cur { color: var(--accent); font-weight: 700; }
.rank-table td.cur { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.rc { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.rc i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.rc .flag { width: 14px; height: 10.5px; margin-right: 0; }
.rc { align-items: flex-start; }
.rc i { margin-top: 4px; }
.rc small { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.2; }
[data-emoji]::before { content: attr(data-emoji); margin-right: .35em; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; font-weight: 400; }
#mixu button { padding: 3px 12px; font-size: 12px; }
svg .gridline line { stroke: var(--grid); }
/* 切り替えボタンは縮めない（スマホで「月次」が縦書きのようにつぶれないように）。入らないときは見出しの下に回す */
.seg { flex-shrink: 0; }
.seg button { white-space: nowrap; }
.section-title, .rank-head { flex-wrap: wrap; }
.rank-head .seg button { padding: 2px 10px; font-size: 12px; }
