/* 2026 縣市長 網路模擬投票 — 灰階紙本風格加一個紫色引導色，只有淺色版面，只用系統字型 */
:root {
  color-scheme: light;
  --paper: #F6F6F6;
  --paper-2: #FFFFFF;
  --paper-3: #ECECEC;
  --ink: #161616;
  --ink-2: #5E5E5E;
  --hairline: rgba(22, 22, 22, .10);
  --line: rgba(22, 22, 22, .50);
  /* 引導色：按鈕、進度、選取、焦點 */
  --accent: #5B3FD9;       /* 白底對比約 6.7:1 */
  --accent-hover: #4A30C2;
  --accent-soft: #EFEBFF;
  --accent-ink: #3F27A6;   /* 淡紫底上的文字，對比約 8:1 */
  --btn: var(--accent);
  --btn-ink: #FFFFFF;
  --shadow: 0 1px 2px rgba(22, 22, 22, .04), 0 4px 16px rgba(22, 22, 22, .06);
  /* 長條顏色：候選人一律用同一個紫色（--r4），不用任何政黨色；「還沒決定」「不會去投」「其他」用灰色 */
  --c0: #C9C9C9;
  /* 投票原因：淡色兩端，刻意避開政黨色（藍綠白橘黃） */
  --pos: #D1A5DB;    /* 淡藕紫：支持他本人或政見 */
  --pos-2: #98659B;  /* 深藕紫：支持他的政黨 */
  --neg: #C5B974;    /* 淡卡其：不想讓另一位當選 */
  --neu: #E4E4E4;    /* 說不上來 */
  /* 單一紫色由淺到深：候選人（r4）、「誰來填」的年齡 */
  --r1: #C39DFF; --r2: #A982E8; --r3: #8F68CC; --r4: #774FB0; --r5: #5F3695; --r6: #491C7B;
  --g1: #3A3A3A;
  --g2: #8C8C8C;
  --g3: #C9C9C9;
  --g4: #E2E2E2;
  --radius: 14px;
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.7;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
.col { width: 100%; max-width: 520px; margin: 0 auto; padding: 0 16px; }
main { padding-top: 24px; padding-bottom: 56px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.center { text-align: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.top { border-bottom: 1px solid var(--hairline); background: rgba(246,246,246,.9); }
.top .col { min-height: 48px; display: flex; align-items: center; font-size: .9375rem; }

h1 { font-size: 1.875rem; font-weight: 900; line-height: 1.3; margin-top: 24px; text-wrap: balance; }
h2 { font-size: 1.375rem; font-weight: 900; line-height: 1.45; margin: 20px 0 16px; text-wrap: balance; }
h3 { font-size: 1rem; font-weight: 900; margin: 28px 0 10px; }
.lead { margin-top: 12px; font-size: 1.125rem; font-weight: 700; text-wrap: balance; }
.lead span { white-space: nowrap; }
.stamp {
  display: inline-block; margin: 14px 0 22px; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2); font-size: .8125rem; font-weight: 700; line-height: 1.5;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px; border: 0; border-radius: 999px;
  background: var(--btn); color: var(--btn-ink);
  font-size: 1.0625rem; font-weight: 700; letter-spacing: .04em; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 0 18px; font-size: .9375rem; letter-spacing: 0; }
.btn-outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn:not(.btn-outline):not(:disabled):hover { background: var(--accent-hover); }
.btn-outline:hover { background: var(--paper-3); }
.btn:disabled { background: var(--paper-3); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--hairline); cursor: not-allowed; }

/* 首頁：參與人數、各縣市人數、即時動態；「開始投票」黏在畫面底部，捲到哪都按得到 */
.count-line { margin: 4px 0 10px; font-weight: 700; }
.count-line b { margin: 0 4px; font-size: 2rem; font-weight: 900; line-height: 1.2; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0; padding: 6px 2px; border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--paper-2); line-height: 1.35; text-align: center;
}
.tile-name { font-size: .8125rem; font-weight: 700; }
.tile-n { color: var(--ink-2); font-size: .8125rem; }
#intro-live .sec { margin-top: 28px; }
.start-bar { position: sticky; bottom: 12px; z-index: 5; margin-top: 24px; }
.start-bar .btn { box-shadow: 0 6px 20px rgba(63, 39, 166, .28); }
.geo-msg { margin-top: 24px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--paper-2); font-weight: 700; }

/* 題目頁 */
.qhead { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.back { background: none; border: 0; padding: 8px 0; font-weight: 700; cursor: pointer; }
.progress { height: 4px; background: var(--paper-3); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.qnum { display: inline-block; margin-top: 20px; padding: 1px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: .8125rem; font-weight: 700; line-height: 1.7; }
.qnum + h2 { margin-top: 8px; }
.note { margin: -8px 0 14px; }
.opts { display: grid; gap: 10px; }
.opt {
  display: block; width: 100%; min-height: 56px; padding: 10px 16px; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--paper-2);
  font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.opt:active { transform: scale(.985); }
@media (hover: hover) { .opt:hover { border-color: var(--accent); } }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt .hint { display: block; color: var(--ink-2); font-size: .8125rem; font-weight: 400; }
/* 縣市：分成「直轄市」「縣市」兩組的三欄按鈕格 */
.opts-grouped { gap: 0; }
.opt-group { margin: 14px 0 6px; color: var(--ink-2); font-size: .8125rem; font-weight: 700; }
.opt-group:first-child { margin-top: 0; }
.opts.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.opt.opt-grid { min-height: 48px; padding: 6px 4px; border-radius: 12px; text-align: center; line-height: 1.4; }

/* 第 1 題的地圖：先看全台，點縣市放大到那一區，再點一次選取。不用政黨色、不畫任何資料 */
.map-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; margin: -4px 0 4px; }
.map-back { padding: 6px 0; }
.map-svg {
  display: block; width: 100%; max-width: 400px; height: auto; margin: 0 auto; overflow: hidden;
  background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
.map-svg:focus { outline: none; }
.map-svg:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.map-c { --f: var(--g3); cursor: pointer; outline: none; }
.map-shape {
  fill: var(--f); fill-rule: evenodd; stroke: var(--paper-2); stroke-width: 1px; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; transition: fill .15s ease;
}
/* 小島：外框用同一個顏色，放大前也看得到 */
.map-c.is-isle .map-shape { stroke: var(--f); stroke-width: 1.5px; }
.map-frame { fill: transparent; stroke: var(--g3); stroke-width: 1px; vector-effect: non-scaling-stroke; transition: fill .15s ease; }
/* 放大後，別區的縣市淡一點（滑過、選取的顏色仍然蓋過它） */
.map-c.is-out { --f: var(--paper-3); }
@media (hover: hover) {
  .map-c:hover, .map-c.is-hot { --f: var(--r2); }
  .map-c.is-isle:hover .map-frame { fill: var(--accent-soft); }
}
.map-c:focus-visible { --f: var(--r2); }
.map-c:not(.is-isle):focus-visible .map-shape { stroke: var(--ink); stroke-width: 2px; }
.map-c.is-isle:focus-visible .map-frame { fill: var(--accent-soft); stroke: var(--accent); }
.map-c[aria-pressed="true"] { --f: var(--r4); }
.map-c.is-isle[aria-pressed="true"] .map-frame { fill: var(--accent-soft); stroke: var(--r4); }
.map-hit { fill: transparent; cursor: pointer; }
.map-svg:not(.is-zoomed) .map-hit { pointer-events: none; }
.map-label {
  fill: var(--ink); stroke: var(--paper-2); stroke-linejoin: round; paint-order: stroke;
  font-weight: 700; pointer-events: none; opacity: 0;
}
.map-svg.is-zoomed:not(.is-moving) .map-label.is-in { opacity: 1; transition: opacity .15s ease; }
/* 選取的縣市：白字紫底，小縣市（嘉義市、新竹市、基隆市）被名稱蓋住時也看得出選了它 */
.map-label.is-sel { fill: var(--btn-ink); stroke: var(--r4); }
.map-src { margin-top: 6px; color: var(--ink-2); font-size: .75rem; line-height: 1.5; text-align: center; }
.map-go { position: sticky; bottom: 12px; z-index: 5; margin-top: 14px; }
.map-go .btn { box-shadow: 0 6px 20px rgba(63, 39, 166, .28); }
.map h3.map-or { margin: 24px 0 10px; font-size: .9375rem; }
@media (prefers-reduced-motion: reduce) {
  .map-shape, .map-frame, .map-svg.is-zoomed:not(.is-moving) .map-label.is-in { transition: none; }
}

/* 最後一步 */
.terms { margin: 12px 0 20px; font-size: .9375rem; }
.terms summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.terms ol { list-style: decimal; padding-left: 1.4em; display: grid; gap: 6px; margin: 6px 0 10px; }
.ts-box.is-shown { margin-bottom: 12px; }
.msg { min-height: 1.7em; margin-top: 10px; font-weight: 700; text-align: center; }

/* 結果 */
.sec { margin: 36px 0 12px; padding-left: 10px; border-left: 4px solid var(--accent); font-size: 1.125rem; line-height: 1.35; }
.cards { display: grid; gap: 12px; }
.card { padding: 16px; background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; }
.card h3 + .small { margin: -6px 0 10px; }
.card .grp:last-child, .card .bar-row:last-child { margin-bottom: 0; }
.thanks { margin-top: 8px; font-size: 1.25rem; font-weight: 900; }
/* 分享：一個按鈕，下面一行法律提醒 */
.share { display: grid; justify-items: start; gap: 6px; margin: 14px 0 22px; }
.share-end { margin: 32px 0 0; }
.share-in { margin: 12px 0 0; }
.share-text { max-width: 100%; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; background: var(--paper-2); overflow-wrap: anywhere; -webkit-user-select: all; user-select: all; }
.share-law { font-size: .8125rem; line-height: 1.5; }
.mine { margin-left: 6px; padding: 0 6px; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--accent); border-radius: 999px; overflow: hidden; }
.seg button { min-height: 44px; border: 0; background: transparent; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--btn-ink); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 10px; margin-bottom: 10px; font-size: .9375rem; }
.bar-row .track { grid-column: 1 / -1; grid-row: 2; }
.bar-row .pct { grid-column: 2; grid-row: 1; font-size: 1.25rem; font-weight: 900; line-height: 1.3; }
.bar-hint { margin-left: 6px; color: var(--ink-2); font-size: .8125rem; font-weight: 400; }
.track { height: 10px; border-radius: 999px; background: var(--paper-3); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 999px; background: var(--col, var(--g2)); }
.pct { text-align: right; font-weight: 700; }
.stack { display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden; background: var(--paper-3); }
.stack i { display: block; height: 100%; background: var(--col, var(--g2)); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 6px; font-size: .875rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chip { width: 10px; height: 10px; border-radius: 3px; background: var(--col, var(--g2)); flex: none; }
.grp { margin-bottom: 16px; }
.grp-h { display: flex; justify-content: space-between; gap: 10px; font-size: .9375rem; font-weight: 700; margin-bottom: 6px; }
.grp-h span { color: var(--ink-2); font-weight: 400; white-space: nowrap; }
.sup { color: var(--ink-2); font-size: .875rem; }

/* 全國：22 縣市一列一個，點開看各候選人（手風琴） */
.nation-hint { margin: -6px 0 6px; }
.nation { display: grid; }
.nrow { border-top: 1px solid var(--hairline); }
.nrow.is-mine { border-radius: 10px; background: var(--accent-soft); }
.nrow.is-mine, .nrow.is-mine + .nrow { border-top-color: transparent; }
.nrow-btn {
  display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto 12px; align-items: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 8px 6px; border: 0; background: none;
  font-size: .9375rem; line-height: 1.45; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.nr-name { display: flex; flex-direction: column; align-items: flex-start; font-weight: 700; }
.nr-name .mine { margin: 2px 0 0; }
.nr-lead { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.nr-lead.muted { font-size: .875rem; font-weight: 400; }
.nr-n { color: var(--ink-2); font-size: .875rem; white-space: nowrap; text-align: right; }
.nr-chev { justify-self: center; width: 8px; height: 8px; margin-top: -4px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); transition: transform .15s ease; }
.nrow-btn[aria-expanded="true"] .nr-chev { margin-top: 4px; transform: rotate(-135deg); }
@media (hover: hover) { .nrow-btn:hover .nr-name { text-decoration: underline; text-underline-offset: 3px; } }
.nrow-body { padding: 2px 6px 14px; }
.nrow-body > .small { margin-bottom: 8px; }

.disc { margin-top: 40px; padding-top: 4px; border-top: 1px solid var(--hairline); font-size: .875rem; }
.disc .stamp { margin: 14px 0 10px; }
.disc dl { display: grid; grid-template-columns: 6em minmax(0, 1fr); gap: 4px 10px; margin-bottom: 10px; }
.disc dt { color: var(--ink-2); }

/* 桌機：問卷是置中白卡，結果頁加寬並排成兩欄 */
@media (min-width: 900px) {
  main.col { max-width: 600px; padding-top: 48px; }
  #intro, #quiz, #final, #closed {
    padding: 28px 36px 36px; background: var(--paper-2);
    border: 1px solid var(--hairline); border-radius: 20px; box-shadow: var(--shadow);
  }
  #intro > h1:first-child, #closed > h2:first-child { margin-top: 0; }
  #intro .tile { background: var(--paper); }
  body[data-view="results"] .col { max-width: 1072px; }
  .seg { max-width: 420px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 16px; }
  .cards > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .card { padding: 20px 24px; }
  .nation { grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  .nrow:nth-child(2) { border-top-color: transparent; }
}
/* 卡片等高時，小字貼齊卡片底部 */
.card { display: flex; flex-direction: column; }
.card > :nth-last-child(2) { margin-bottom: 12px; }
.figs { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 14px; }
.fig { display: flex; align-items: baseline; gap: 4px; color: var(--ink-2); font-size: .875rem; }
.fig b { margin: 0 2px; color: var(--ink); font-size: 1.5rem; font-weight: 900; line-height: 1.2; }
.pchart { display: flex; align-items: stretch; gap: 2px; height: 88px; border-bottom: 1px solid var(--hairline); }
.pc { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; padding: 0; border: 0; background: transparent; cursor: pointer; }
.pc i { display: block; width: 100%; background: var(--r4); border-radius: 2px 2px 0 0; }
.pc:hover i, .pc:focus-visible i { background: var(--r6); }
.pc:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.pticks { position: relative; height: 1.25rem; margin-top: 4px; color: var(--ink-2); font-size: .75rem; }
.pticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.pticks .now { left: auto; right: 0; transform: none; }
.pulse-read { min-height: 1.5em; margin: 6px 0 0; color: var(--ink-2); }
.card .pulse-sub { margin: 18px 0 2px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.pulse-sub + p { margin-top: 0; }
.pulse-blocked { margin: 14px 0 6px; }
.card-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--hairline); color: var(--ink-2); font-size: .75rem; line-height: 1.5; }
.seg-note { margin-top: 6px; }
