/* 2026政治王慈善大賽：選票紙底、黑色印刷線、印泥紅（依 Claude Design 設計稿） */
:root {
  color-scheme: light;
  --paper: #f4f3ef;
  --sheet: #ffffff;
  --ink: #1a1a1a;
  --muted: #55554f;
  --soft: #6b6b65;
  --hair: #c9c7c0;
  --red: #c21f30;
  --dpp: #1b9431;
  --kmt: #000095;
  --other: #e4e2db;
  --ok-bg: #e4f2e7; --ok-line: #14622a; --ok-ink: #0e5a22; --ok-cell: #d9efdd;
  --err-bg: #fbe8ea; --err-line: #a3152a; --err-ink: #8e1024;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); }
[hidden] { display: none !important; }
a { color: var(--ink); }
a:hover { color: var(--red); }

.wrap {
  max-width: 1120px; margin: 0 auto; padding: 20px 16px 28px;
  display: flex; flex-direction: column; gap: 28px; min-height: 100vh;
}
.stack { display: flex; flex-direction: column; gap: 10px; }
h2 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.5; }
h2.rule { padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.hint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* 頁首 */
.masthead { display: flex; flex-direction: column; gap: 12px; }
.masthead h1 {
  margin: 0; padding-bottom: 10px; border-bottom: 4px double var(--ink);
  font-family: var(--serif); font-weight: 900; font-size: clamp(32px, 6vw, 48px); line-height: 1.15; letter-spacing: .02em;
}
.status {
  background: var(--ink); color: #fff; padding: 10px 12px;
  font-size: 15px; font-weight: 700; line-height: 1.4; font-variant-numeric: tabular-nums;
}

/* 已填名單 */
.roster { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 5px 10px;
  border: 1.5px solid var(--ink); background: var(--sheet); font-size: 14px; font-weight: 500;
}
.chip small { font-size: 11px; color: var(--muted); }

/* 表單 */
.form { gap: 16px; }
.who-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 700; }
input, select {
  height: 48px; width: 100%; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 0;
  background: var(--sheet); color: var(--ink); font: inherit; font-size: 16px;
}
input.pin { letter-spacing: .2em; }
button { font: inherit; cursor: pointer; border-radius: 0; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn-line { height: 48px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); font-size: 15px; font-weight: 700; }
.btn-line:hover { background: var(--other); }
.btn-main {
  height: 54px; border: 0; background: var(--ink); color: #fff;
  font-family: var(--serif); font-size: 20px; font-weight: 900; letter-spacing: .2em;
}
.btn-main:hover { background: #333330; }
.btn-main:disabled { opacity: .55; cursor: wait; }

/* 選票 */
.ballots { display: grid; gap: 14px; }
.ballot { display: flex; min-height: 118px; background: var(--sheet); border: 1.5px solid var(--ink); }
.ballot-title {
  margin: 0; flex: none; width: 36px; writing-mode: vertical-rl; text-align: center; line-height: 36px;
  font-family: var(--serif); font-weight: 900; font-size: 19px; letter-spacing: .24em;
  border-right: 1.5px solid var(--ink);
}
.ballot-grid {
  flex: 1; min-width: 0; display: grid; gap: 8px; padding: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 720px) {
  .ballot-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
.cand-wrap { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cand {
  appearance: none; -webkit-appearance: none; margin: 0; padding: 0; border: 1.5px solid var(--ink);
  background: none; text-align: left; display: flex; align-items: stretch; min-height: 72px; width: 100%; color: #fff;
}
.cand[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.cand:hover .cn { filter: brightness(1.12); }
.cn { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 8px 0 8px 8px; }
.cn-name { font-family: var(--serif); font-weight: 900; font-size: clamp(19px, 5.6vw, 22px); line-height: 1.15; white-space: nowrap; }
.cn-party { font-size: 11px; line-height: 1.3; font-weight: 700; }
.cb { flex: none; display: flex; align-items: center; padding: 0 6px; }
.box {
  width: 44px; height: 44px; background: var(--sheet); border: 1.5px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.stamp {
  width: 32px; height: 32px; border: 3px solid var(--red); border-radius: 50%; color: var(--red);
  font-family: var(--serif); font-weight: 900; font-size: 17px; line-height: 26px; text-align: center;
  transform: rotate(-9deg); opacity: .94;
}
.stamp.is-new { animation: stamp .32s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes stamp {
  0% { opacity: 0; transform: rotate(-9deg) scale(2.4); }
  60% { opacity: 1; transform: rotate(-9deg) scale(.88); }
  100% { opacity: .94; transform: rotate(-9deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .stamp.is-new { animation: none; } }
.cand--dpp .cn, .cand--dpp .cb { background: var(--dpp); }
.cand--kmt .cn, .cand--kmt .cb { background: var(--kmt); }
.cand--kao .cn { background: var(--kmt); }
.cand--kao .cb { background: #fff; }
.cand--oth { color: var(--ink); }
.cand--oth .cn, .cand--oth .cb { background: var(--other); }
.votes { display: flex; flex-direction: column; gap: 3px; font-size: 12px; line-height: 1.5; color: #3a3a36; font-variant-numeric: tabular-nums; }
.bar { display: block; height: 4px; background: #dad8d1; }
.bar-fill { display: block; height: 4px; background: var(--ink); }

/* 送出區 */
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.progress { font-size: 15px; font-weight: 700; }
.pips { display: flex; gap: 4px; }
.pip { width: 14px; height: 14px; border: 1.5px solid var(--ink); background: var(--sheet); }
.pip.is-on { background: var(--ink); }
.msg:empty { display: none; }
.msg { padding: 10px 12px; font-size: 14px; font-weight: 700; line-height: 1.5; border: 1.5px solid; }
.msg.ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }
.msg.err { border-color: var(--err-line); background: var(--err-bg); color: var(--err-ink); }

/* 最輸的人 */
.board { display: flex; flex-wrap: wrap; gap: 20px 40px; }
.loser {
  flex: 1 1 440px; min-width: 0; position: relative; overflow: hidden; background: var(--sheet);
  border: 3px solid var(--ink); padding: 16px 16px 20px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px;
}
.loser .tag { background: var(--ink); color: #fff; padding: 3px 8px; font-size: 13px; font-weight: 700; line-height: 1.5; }
.loser .names {
  position: relative; z-index: 1; max-width: calc(100% - 64px);
  font-family: var(--serif); font-weight: 900; font-size: 56px; line-height: 1.15; color: var(--red);
}
.loser .sub { font-size: 15px; font-weight: 500; line-height: 1.5; }
.seal {
  position: absolute; top: 8px; right: 10px; width: 68px; height: 68px; padding: 6px;
  border: 3px solid var(--red); border-radius: 6px; box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3.5px var(--red);
  color: var(--red); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); place-items: center;
  font-family: var(--serif); font-weight: 900; font-size: 22px; line-height: 1; transform: rotate(11deg); opacity: .9;
}
.loser.is-final { padding-bottom: 22px; gap: 6px; }
.loser.is-final .names { font-size: 96px; max-width: calc(100% - 100px); }
.loser.is-final .sub { font-size: 16px; }
.loser.is-final .seal {
  top: 28px; right: 16px; width: 104px; height: 104px; padding: 10px; border-width: 4px; border-radius: 8px;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px var(--red); font-size: 34px;
}
@media (min-width: 900px) {
  .loser { border-width: 4px; padding: 28px 32px 36px; }
  .loser .tag { font-size: 16px; padding: 4px 12px; }
  .loser.is-final .names { font-size: clamp(96px, 15vw, 200px); max-width: calc(100% - 160px); }
  .loser.is-final .sub { font-size: 22px; }
  .loser.is-final .seal {
    top: 12%; right: 6%; width: 168px; height: 168px; padding: 16px; border-width: 6px; border-radius: 12px;
    box-shadow: inset 0 0 0 5px #fff, inset 0 0 0 8px var(--red); font-size: 56px;
  }
}

/* 排行榜 */
.rank-col { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ranking { margin: 0; padding: 0; list-style: none; }
.rk {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  min-height: 45px; padding: 0 4px; border-bottom: 1px solid var(--ink); font-size: 16px;
}
.rk-no { font-family: var(--serif); font-weight: 900; font-size: 20px; }
.rk-name { font-weight: 700; overflow-wrap: anywhere; }
.rk-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.rk.is-last { color: var(--red); }

/* 大家的預測 */
.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.table-scroll { overflow-x: auto; border: 1.5px solid var(--ink); background: var(--sheet); }
table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 14px; }
th, td {
  height: 43px; padding: 0 6px; text-align: center; white-space: nowrap; background: var(--sheet);
  border-right: 1px solid var(--hair); border-bottom: 1px solid var(--hair); font-weight: 400;
}
thead th { background: var(--ink); color: #fff; font-weight: 700; border-color: var(--ink); min-width: 78px; }
tbody th { position: sticky; left: 0; z-index: 1; text-align: left; font-weight: 700; min-width: 64px; border-right: 1.5px solid var(--ink); }
thead th:first-child { position: sticky; left: 0; z-index: 2; }
tr.winners th, tr.winners td { background: #eceae4; font-family: var(--serif); font-weight: 900; border-bottom: 1.5px solid var(--ink); }
td.hit { background: var(--ok-cell); color: var(--ok-ink); font-weight: 900; }
td.miss { color: var(--soft); text-decoration: line-through; }
td.none { color: var(--soft); }

footer {
  margin-top: auto; padding-top: 14px; border-top: 1.5px solid var(--ink);
  font-size: 12px; line-height: 1.6; color: var(--muted);
}

/* 開票輸入頁 */
.admin-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.admin-sub a { min-height: 44px; display: inline-flex; align-items: center; }
.admin-rows { display: flex; flex-direction: column; gap: 12px; padding: 14px 12px; background: var(--sheet); border: 1.5px solid var(--ink); }
.admin-rows .row { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 10px; }
.admin-rows label { font-family: var(--serif); font-weight: 900; font-size: 17px; }
.admin-rows select { padding: 0 10px; }
.narrow { max-width: 560px; }
.admin-h2 { font-family: var(--serif); font-weight: 900; font-size: 20px; margin: 24px 0 0; }
.admin-players { display: flex; flex-direction: column; gap: 10px; }
.pcard { background: var(--sheet); border: 1.5px solid var(--ink); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.pcard.dup { border-color: #c0392b; box-shadow: inset 4px 0 0 #c0392b; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.phead strong { font-size: 16px; overflow-wrap: anywhere; }
.pmeta { font-size: 12px; opacity: .75; }
.pcard.dup .pmeta { color: #c0392b; opacity: 1; }
.ppicks { font-size: 13px; line-height: 1.6; }
.pdel { min-height: 40px; padding: 0 14px; border: 1.5px solid #c0392b; background: transparent; color: #c0392b; font-weight: 700; flex-shrink: 0; }
.pdel:disabled { opacity: .5; }
