/* ひだまり市 選挙シミュレーター ― 共通スタイル
   レイアウト: 開票速報ボード。上に固定の操作帯（投票率）、下に「結果」と「なぜそうなるか」の2列。 */
:root {
  --bg: #eef1f5;        /* ページの地 */
  --surface: #fcfcfd;   /* パネル（グラフの地） */
  --surface-2: #f3f5f8; /* くぼみ・入力欄 */
  --ink: #151a23;       /* 本文 */
  --ink-2: #4a5263;     /* 補足 */
  --muted: #6f7888;     /* 軸・注記 */
  --line: #dde2ea;      /* 罫線 */
  --axis: #b8c0cc;
  --win: #c21f3a;       /* 当選の赤（バラ） */
  --win-soft: #fbe9ec;
  --s1: #2a78d6;        /* 固定票型 */
  --s2: #eb6834;        /* 生活型 */
  --s3: #1baf7a;        /* 新風型 */
  --l1: #3d4656;        /* いつも行く層 */
  --l2: #7a8496;        /* ときどき行く層 */
  --l3: #a7b0bf;        /* めったに行かない層 */
  --font-display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --font-body: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1015; --surface: #171a20; --surface-2: #20242d; --ink: #f3f5f9; --ink-2: #c1c7d3;
    --muted: #949cab; --line: #2a2f39; --axis: #3b4250; --win: #ff7a8f; --win-soft: #3a1a22;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --l1: #d5dae3; --l2: #8e97a8; --l3: #586172;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1015; --surface: #171a20; --surface-2: #20242d; --ink: #f3f5f9; --ink-2: #c1c7d3;
  --muted: #949cab; --line: #2a2f39; --axis: #3b4250; --win: #ff7a8f; --win-soft: #3a1a22;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --l1: #d5dae3; --l2: #8e97a8; --l3: #586172;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.75;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.35; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--s1); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 全体の枠 ---------- */
.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 900; font-size: 1.05rem; }
.brand svg { width: 30px; height: 30px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-left: auto; font-size: 0.875rem; }
.nav a { padding: 4px 10px; border-radius: 999px; text-decoration: none; color: var(--ink-2); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--surface); font-weight: 700; }
main.wrap { padding-block: 24px 56px; display: grid; gap: 20px; }
.page-head { display: grid; gap: 8px; }
.eyebrow { font-size: 0.8125rem; font-weight: 700; color: var(--win); letter-spacing: 0.08em; }
.page-head h1 { font-size: clamp(1.45rem, 1.1rem + 1.6vw, 2.1rem); font-weight: 900; }
.lead { max-width: 44em; color: var(--ink-2); }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8125rem; }
.site-footer .wrap { padding-block: 18px 28px; display: grid; gap: 4px; }

/* ---------- 操作帯（画面上部に固定） ---------- */
.control {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; display: grid; gap: 10px;
  box-shadow: 0 6px 18px -12px rgba(21, 26, 35, 0.45);
}
.turnout { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.turnout input[type="range"] { flex: 1 1 200px; width: auto; min-width: 0; }
.turnout .play { flex: none; }
.turnout-read { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-display); font-weight: 900; }
.turnout-read small { font-size: 0.8125rem; font-weight: 700; color: var(--ink-2); }
.turnout-read output { font-size: 2.1rem; line-height: 1; min-width: 2.6ch; text-align: right; }
.turnout-read output + span { font-size: 1.1rem; }
.turnout-sub { flex: 1 1 100%; font-size: 0.8125rem; color: var(--ink-2); }
.settings { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: 0.875rem; padding-inline: 2px; }
.settings .group { display: flex; align-items: center; gap: 8px; }
.settings label, .settings .label { color: var(--ink-2); font-weight: 700; }

input[type="range"] { width: 100%; height: 28px; margin: 0; background: transparent; accent-color: var(--ink); cursor: pointer; -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: linear-gradient(to right, var(--ink) var(--fill, 50%), var(--line) var(--fill, 50%)); }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: 50%; background: var(--surface); border: 4px solid var(--ink); box-shadow: 0 1px 4px rgba(21, 26, 35, 0.35); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 4px solid var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 4px 14px; border-radius: 999px; border: 1px solid var(--axis); background: var(--surface);
  font-weight: 700; font-size: 0.875rem; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--axis); border-radius: 999px; overflow: hidden; background: var(--surface); }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; font-weight: 700; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.stepper button:hover { background: var(--surface-2); }
.stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.stepper output { min-width: 3.2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- ボード（結果とその理由） ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.col { display: grid; gap: 20px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel > h2 { font-size: 1.05rem; font-weight: 900; }
.panel > h2 small { display: block; font-family: var(--font-body); font-size: 0.8125rem; font-weight: 400; color: var(--ink-2); }
.hint { font-size: 0.8125rem; color: var(--ink-2); }
.scroll-x { overflow-x: auto; }
@media (max-width: 880px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .control { padding: 8px 12px; }
  .turnout input[type="range"] { flex-basis: calc(100% - 9em); }
  .turnout-sub { flex: 1 1 9em; order: 3; line-height: 1.4; }
  .turnout .play { order: 4; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
