/* Layout: 地図を主役にした一枚もの。上に検索と表示切替、凡例、地図、下に今指している国の情報。
   Color: 宗教ごとに1色(--r0〜--r7)。複数の宗教が混じる国は、割合に応じたグラデーション。
   Type: 本文と見出しは Zen Kaku Gothic New、国コードだけ DM Mono。 */
:root {
  --bg: #edf2f5;
  --surface: #fbfdfe;
  --fg: #13222c;
  --muted: #53656f;
  --line-ui: #cfdbe2;
  --sea: #eef3f7;
  --sea-out: #e4ecf2;
  --sealbl: #3b6a94;
  --grat: rgba(19, 34, 44, 0.08);
  --halo: rgba(255, 255, 255, 0.95);
  --r0: #3a6fe6;
  --r1: #26a65b;
  --r2: #e5546b;
  --r3: #f58a1f;
  --r4: #f2c120;
  --r5: #9b5fe0;
  --r6: #8f6a4b;
  --r7: #16bfd2;
  --rn: #d3dae0;
  --w0: #d7263d;
  --w1: #f4801f;
  --w2: #f2c53d;
  --wn: #dbe4ea;
  --k1: #f2d03b;
  --k2: #f4962b;
  --k3: #e0343f;
  --k4: #7a1030;
  --kn: #dbe4ea;
  --a0: #7fd6c2; --a1: #b9e07a; --a2: #f2e06b; --a3: #f7b84a; --a4: #f0803c; --a5: #d6424a; --a6: #7b1d4f; --an: #dbe4ea;
  --border: #ffffff;
  --hl: #1b2fd6;
  --sel: #13222c;
  --font-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09131a;
    --surface: #122029;
    --fg: #e7eff4;
    --muted: #90a5b2;
    --line-ui: #263a4a;
    --sea: #0f1d28;
    --sea-out: #0b1721;
    --sealbl: #8db6d9;
    --grat: rgba(255, 255, 255, 0.07);
    --halo: rgba(9, 19, 26, 0.92);
    --r0: #5b8cff;
    --r1: #34c06c;
    --r2: #f0647c;
    --r3: #ff9a3a;
    --r4: #f5ca3a;
    --r5: #b07cf5;
    --r6: #a98262;
    --r7: #2cd0e2;
    --rn: #2b3a47; --w0: #f0475b; --w1: #ff9b3d; --w2: #f5cb4a; --wn: #26394a; --k1: #f5d65a; --k2: #ff9f43; --k3: #f0475b; --k4: #b02253; --kn: #26394a; --a0: #5fc7b2; --a1: #a4d667; --a2: #f0d95e; --a3: #f5ad3c; --a4: #ee7a3a; --a5: #e5555c; --a6: #b03a7a; --an: #26394a;
    --border: #0b1721;
    --hl: #f3c44f;
    --sel: #ffffff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09131a;
  --surface: #122029;
  --fg: #e7eff4;
  --muted: #90a5b2;
  --line-ui: #263a4a;
  --sea: #0f1d28;
  --sea-out: #0b1721;
  --sealbl: #8db6d9;
  --grat: rgba(255, 255, 255, 0.07);
  --halo: rgba(9, 19, 26, 0.92);
  --r0: #5b8cff;
  --r1: #34c06c;
  --r2: #f0647c;
  --r3: #ff9a3a;
  --r4: #f5ca3a;
  --r5: #b07cf5;
  --r6: #a98262;
  --r7: #2cd0e2;
  --rn: #2b3a47; --w0: #f0475b; --w1: #ff9b3d; --w2: #f5cb4a; --wn: #26394a; --k1: #f5d65a; --k2: #ff9f43; --k3: #f0475b; --k4: #b02253; --kn: #26394a; --a0: #5fc7b2; --a1: #a4d667; --a2: #f0d95e; --a3: #f5ad3c; --a4: #ee7a3a; --a5: #e5555c; --a6: #b03a7a; --an: #26394a;
  --border: #0b1721;
  --hl: #f3c44f;
  --sel: #ffffff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-jp);
  line-height: 1.6;
  padding-block: 20px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 1240px; margin: 0 auto; display: grid; gap: 14px; }
header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; }
h1 { margin: 0; font-size: clamp(22px, 3.2vw, 30px); font-weight: 700; letter-spacing: 0.01em; text-wrap: balance; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { flex: 1 1 240px; min-width: 0; }
input[type="search"] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-ui); border-radius: 8px;
  background: var(--surface); color: var(--fg);
  font: inherit; font-size: 15px;
}
input[type="search"]::placeholder { color: var(--muted); }
button { font: inherit; color: var(--fg); }
.seg { display: inline-flex; border: 1px solid var(--line-ui); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { height: 38px; padding: 0 14px; border: 0; background: transparent; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line-ui); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 700; }
:focus-visible { outline: 2px solid var(--hl); outline-offset: 2px; }
.msg { margin: -6px 0 0; font-size: 14px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px 0 9px;
  border: 1px solid var(--line-ui); border-radius: 999px; background: var(--surface);
  font-size: 14px; line-height: 1.2; cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); font-weight: 700; }
.chip.nd { cursor: default; color: var(--muted); }
.chip.nd:hover { border-color: var(--line-ui); }
.sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.note { margin: -4px 0 0; font-size: 13px; color: var(--muted); }

.map { position: relative; overflow: hidden; border: 1px solid var(--line-ui); border-radius: 12px; background: var(--sea-out); }
.map svg { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 500; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.map svg.drag { cursor: grabbing; }
.sphere { fill: var(--sea); pointer-events: none; }
.grat { fill: none; stroke: var(--grat); stroke-width: 0.6; vector-effect: non-scaling-stroke; pointer-events: none; }
.land { stroke: var(--border); stroke-width: 0.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: opacity 0.2s; }
.r0 { fill: var(--r0); } .r1 { fill: var(--r1); } .r2 { fill: var(--r2); } .r3 { fill: var(--r3); }
.r4 { fill: var(--r4); } .r5 { fill: var(--r5); } .r6 { fill: var(--r6); } .r7 { fill: var(--r7); } .rn { fill: var(--rn); }
.w0 { fill: var(--w0); } .w1 { fill: var(--w1); } .w2 { fill: var(--w2); } .wn { fill: var(--wn); }
.k1 { fill: var(--k1); } .k2 { fill: var(--k2); } .k3 { fill: var(--k3); } .k4 { fill: var(--k4); } .kn { fill: var(--kn); }
.a0 { fill: var(--a0); } .a1 { fill: var(--a1); } .a2 { fill: var(--a2); } .a3 { fill: var(--a3); } .a4 { fill: var(--a4); } .a5 { fill: var(--a5); } .a6 { fill: var(--a6); } .an { fill: var(--an); }
.land.dim { opacity: 0.14; }
.land.hov { stroke: var(--sel); stroke-width: 1.6; }
.land.sel { stroke: var(--sel); stroke-width: 2.4; }
.ring { fill: none; stroke: var(--sel); stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }

.seas { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.sea { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.sea span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; text-align: center; color: var(--sealbl); font-style: italic; line-height: 1.15; font-weight: 600; text-shadow: 0 0 2px var(--halo), 0 0 2px var(--halo), 0 0 4px var(--halo), 0 0 7px var(--halo); }
.sea.t0 span { font-size: 15px; letter-spacing: 0.3em; }
.sea.t1 span { font-size: 12.5px; letter-spacing: 0.12em; }
.sea.t2 span { font-size: 11.5px; letter-spacing: 0.06em; }
.sea small { display: block; font-size: 0.82em; letter-spacing: 0.04em; opacity: 0.85; }
.caps { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.cap { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; will-change: transform; }
.cap .dot {
  position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg); box-shadow: 0 0 0 2px var(--halo);
}
.cap.hl .dot { width: 11px; height: 11px; left: -5.5px; top: -5.5px; background: var(--hl); box-shadow: 0 0 0 2px var(--halo), 0 0 0 3.5px var(--hl); }
.cap.pt .dot { width: 13px; height: 13px; left: -6.5px; top: -6.5px; background: var(--hl); box-shadow: 0 0 0 2px var(--halo), 0 0 0 4px var(--hl); }

.zoom { position: absolute; right: 10px; top: 10px; z-index: 4; display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--line-ui); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: 20px; line-height: 1;
}
.zoom button.wide { font-size: 12px; font-weight: 700; }
.zoom button:hover { border-color: var(--muted); }

[hidden] { display: none !important; }
.tip {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; max-width: 280px;
  padding: 6px 11px; border-radius: 7px; background: var(--fg); color: var(--bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.tip strong { font-size: 15px; font-weight: 700; line-height: 1.35; }
.tip span { font-size: 12px; opacity: 0.8; line-height: 1.35; }
.tip em { font-size: 12px; font-style: normal; line-height: 1.4; margin-top: 3px; padding-top: 3px; border-top: 1px solid currentColor; border-top-color: color-mix(in srgb, currentColor 30%, transparent); }

.readout { display: grid; gap: 10px; min-height: 150px; align-content: start; padding: 14px 18px; border: 1px solid var(--line-ui); border-radius: 12px; background: var(--surface); }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.names { min-width: 0; flex: 1 1 260px; }
.primary { font-size: clamp(24px, 4vw, 34px); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; text-wrap: balance; }
.primary.idle { font-size: clamp(17px, 2.4vw, 20px); font-weight: 500; color: var(--muted); }
.secondary { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.code {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.08em; color: var(--muted);
  border: 1px solid var(--line-ui); border-radius: 6px; padding: 2px 8px;
}
.code:empty { display: none; }
.capline { font-size: 15px; }
.capline b { font-weight: 700; }
.bar { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; }
.bar span { min-width: 3px; }
.items { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--fg); }
.items .it { display: inline-flex; align-items: center; gap: 6px; }
.items .it i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.items .it small { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.items.nodata { color: var(--muted); }
.warnote { font-size: 15px; line-height: 1.6; }
.credit { margin: 0; font-size: 12px; color: var(--muted); }

@media (max-width: 520px) {
  .seg { width: 100%; }
  .seg button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .land { transition: none; }
}
