:root {
  --ink: #0a0a0a;
  --paper: #ffffff;
  --mute: #6b6b6b;
  --line: #0a0a0a;
  --soft: #f1f1f1;
  --accent: #ff5a1f;
  --accent-ink: #0a0a0a;
  --gutter: clamp(16px, 4vw, 56px);
  --display: "Anton", "Noto Sans TC", Impact, sans-serif;
  --sans: "Noto Sans TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--accent); color: var(--ink); }

/* ── 頂部進度 ───────────────────────────── */
.progress { position: fixed; inset: 0 0 auto 0; height: 6px; background: var(--soft); z-index: 50; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .35s cubic-bezier(.2,.8,.2,1); }
.counter {
  position: fixed; top: 14px; right: var(--gutter); z-index: 50;
  background: var(--ink); color: var(--paper);
  font-family: var(--display); font-size: 15px; letter-spacing: .06em;
  padding: 4px 10px; opacity: 0; transform: translateY(-8px);
  transition: opacity .3s, transform .3s;
}
.counter.show { opacity: 1; transform: none; }
.test-banner {
  position: sticky; top: 6px; z-index: 40; background: var(--accent); color: var(--ink);
  font-weight: 700; padding: 8px var(--gutter); font-size: 14px;
}

/* ── 封面 ───────────────────────────── */
.hero {
  min-height: 100svh;
  background: var(--ink); color: var(--paper);
  padding: 28px var(--gutter) 32px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.hero-top {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-family: var(--display); letter-spacing: .08em; font-size: 14px;
  border-bottom: 3px solid var(--paper); padding-bottom: 10px;
}
.hero-title { margin: 0; display: flex; flex-direction: column; line-height: .82; }
.hero-word {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(120px, 34vw, 420px); letter-spacing: -.01em;
  color: var(--paper);
}
.hero-sub {
  font-weight: 900; font-size: clamp(48px, 13vw, 160px); letter-spacing: -.02em;
  color: var(--accent); margin-top: .08em;
}
.hero-bottom {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end;
  border-top: 3px solid var(--paper); padding-top: 16px;
}
.lede { margin: 0; font-size: clamp(17px, 2.2vw, 22px); font-weight: 700; max-width: 34em; }
.hero-meta { font-size: 15px; text-align: right; line-height: 1.3; }
.hero-meta b { font-family: var(--display); font-weight: 400; font-size: 40px; color: var(--accent); }

/* ── 題目 ───────────────────────────── */
main { padding: 0 var(--gutter); }
.q {
  border-top: 6px solid var(--line);
  padding: 28px 0 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  position: relative;
}
.q-head { display: grid; grid-template-columns: auto 1fr; gap: 0 20px; align-items: end; margin-bottom: 22px; }
.q-no {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(96px, 22vw, 260px); line-height: .78;
  color: var(--ink);
  -webkit-text-stroke: 0;
  transform-origin: left bottom;
}
.q-no.done { color: var(--accent); }
.q-meta { padding-bottom: 6px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.q-tag {
  font-family: var(--display); letter-spacing: .1em; font-size: 13px;
  background: var(--ink); color: var(--paper); padding: 2px 8px;
}
.q-tag.opt { background: var(--paper); color: var(--ink); outline: 2px solid var(--ink); outline-offset: -2px; }
.q-title {
  margin: 0 0 8px; font-weight: 900;
  font-size: clamp(24px, 4.4vw, 46px); line-height: 1.22; letter-spacing: -.01em;
  max-width: 22em;
}
.q-hint { margin: 0 0 22px; color: var(--mute); font-size: 15px; font-weight: 500; max-width: 40em; }
.q-err {
  display: none; margin: 14px 0 0; font-weight: 700; font-size: 15px;
  background: var(--ink); color: var(--accent); padding: 8px 12px;
}
.q.invalid .q-err { display: block; }
.q.invalid .q-title { text-decoration: underline 4px var(--accent); text-underline-offset: 6px; }

/* 文字輸入 */
.field {
  width: 100%; border: 3px solid var(--line); background: var(--paper);
  padding: 14px 16px; font-size: 18px; font-weight: 500; outline: none;
  appearance: none;
}
.field:focus { box-shadow: 8px 8px 0 var(--accent); }
textarea.field { min-height: 150px; resize: vertical; line-height: 1.6; }
.field::placeholder { color: #a5a5a5; }

/* 選項 */
.opts { display: grid; gap: 10px; }
.opt { position: relative; display: block; cursor: pointer; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt-box {
  display: grid; grid-template-columns: 28px 1fr; gap: 14px; align-items: start;
  border: 3px solid var(--line); background: var(--paper);
  padding: 14px 16px; min-height: 58px;
  font-weight: 700; font-size: 17px; line-height: 1.45;
  transition: background .15s, color .15s, transform .15s, box-shadow .15s;
}
.opt-mark {
  width: 24px; height: 24px; border: 3px solid currentColor; margin-top: 1px;
  display: grid; place-items: center; flex: none;
}
.opt-mark::after { content: ""; width: 10px; height: 10px; background: var(--accent); transform: scale(0); transition: transform .15s; }
.opt-step { font-family: var(--display); font-weight: 400; letter-spacing: .06em; color: var(--mute); margin-right: 8px; }
.opt:hover .opt-box { box-shadow: 6px 6px 0 var(--ink); transform: translate(-2px, -2px); }
.opt input:focus-visible + .opt-box { box-shadow: 6px 6px 0 var(--accent); }
.opt input:checked + .opt-box { background: var(--ink); color: var(--paper); }
.opt input:checked + .opt-box .opt-mark { border-color: var(--accent); }
.opt input:checked + .opt-box .opt-mark::after { transform: scale(1); }
.opt input:checked + .opt-box .opt-step { color: var(--accent); }
.opt.exclusive .opt-box { border-style: dashed; }
.opt.exclusive input:checked + .opt-box { border-style: solid; }
.other-wrap { margin-top: -2px; display: none; }
.other-wrap.show { display: block; }

/* 階梯題：由簡到難，左側漸增色條 */
.ladder .opt-box { grid-template-columns: 28px 1fr; position: relative; padding-left: 26px; }
.ladder .opt-box::before {
  content: ""; position: absolute; left: 0; top: -3px; bottom: -3px;
  width: calc(var(--rung) * 2px + 2px); background: var(--accent);
}

/* 訂閱題 */
.sub-grid { display: grid; gap: 10px; margin-top: 10px; max-width: 860px; }
.sub-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 200px 200px; gap: 10px; align-items: stretch;
}
.sub-brand {
  display: flex; align-items: center; font-weight: 900; font-size: 18px;
  border-bottom: 3px solid var(--line); padding: 6px 0;
}
.sub-row .opt-box { grid-template-columns: 24px 1fr; align-items: center; font-family: var(--display); font-weight: 400; font-size: 19px; letter-spacing: .03em; height: 100%; white-space: nowrap; }
.sub-row .opt-mark { margin-top: 0; }
.sub-or {
  margin: 18px 0 8px; font-family: var(--display); letter-spacing: .12em; font-size: 14px; color: var(--mute);
  display: flex; align-items: center; gap: 12px;
}
.sub-or::before, .sub-or::after { content: ""; height: 3px; background: var(--ink); flex: 1; }

/* ── 送出 ───────────────────────────── */
.submit-zone { border-top: 6px solid var(--line); padding: 40px 0 96px; }
.submit-btn {
  width: 100%; border: 0; cursor: pointer;
  background: var(--ink); color: var(--paper);
  display: flex; justify-content: space-between; align-items: center;
  padding: 26px 28px; font-weight: 900; font-size: clamp(28px, 6vw, 64px); letter-spacing: -.01em;
  transition: background .2s, color .2s;
}
.submit-btn .arrow { font-family: var(--display); font-weight: 400; transition: transform .2s; }
.submit-btn:hover, .submit-btn:focus-visible { background: var(--accent); color: var(--ink); outline: none; }
.submit-btn:hover .arrow { transform: translateX(10px); }
.submit-btn[disabled] { opacity: .6; cursor: progress; }
.submit-note { margin: 0 0 14px; font-weight: 700; background: var(--accent); color: var(--ink); padding: 10px 14px; }
.fine { color: var(--mute); font-size: 14px; margin: 14px 0 0; }

/* ── 印章畫面 ───────────────────────────── */
.stamp-screen {
  position: fixed; inset: 0; z-index: 100; background: var(--paper);
  overflow-y: auto; padding: 48px var(--gutter);
  display: grid; place-items: center;
}
.stamp-screen[hidden] { display: none; }
.stamp-inner { width: min(560px, 100%); text-align: center; }
.stamp-kicker { margin: 0 0 32px; font-weight: 900; font-size: clamp(22px, 5vw, 30px); }
.stamp {
  --tilt: -7deg;
  display: inline-flex; flex-direction: column; align-items: center;
  border: 8px solid var(--accent); outline: 3px solid var(--accent); outline-offset: 6px;
  color: var(--accent); padding: 18px 34px 22px; transform: rotate(var(--tilt));
  background: var(--paper);
}
.stamp-top { font-family: var(--display); letter-spacing: .14em; font-size: 13px; }
.stamp-code { font-family: var(--display); font-size: clamp(120px, 34vw, 180px); line-height: .95; }
.stamp-name { font-weight: 900; font-size: clamp(26px, 7vw, 38px); color: var(--ink); letter-spacing: .04em; }
.stamp.hit { animation: thud .55s cubic-bezier(.2,.9,.25,1.15) both; }
@keyframes thud {
  0% { transform: rotate(-16deg) scale(2.6); opacity: 0; }
  55% { transform: rotate(var(--tilt)) scale(.94); opacity: 1; }
  75% { transform: rotate(var(--tilt)) scale(1.03); }
  100% { transform: rotate(var(--tilt)) scale(1); }
}
.stamp-screen.shake .stamp-inner { animation: shake .3s .3s linear both; }
@keyframes shake { 25% { transform: translate(3px, -2px); } 50% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, 1px); } }
.stamp-desc { margin: 36px auto 22px; font-size: 18px; font-weight: 700; max-width: 26em; }
.stamp-ladder { list-style: none; padding: 0; margin: 0 0 28px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; align-items: end; }
.stamp-ladder li { border: 3px solid var(--ink); padding: 8px 4px; font-size: 13px; font-weight: 700; line-height: 1.3; display: flex; flex-direction: column; justify-content: flex-end; }
.stamp-ladder li b { font-family: var(--display); font-weight: 400; font-size: 22px; display: block; }
.stamp-ladder li.on { background: var(--ink); color: var(--paper); }
.stamp-ladder li.me { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.stamp-foot { color: var(--mute); font-size: 15px; margin: 0 0 20px; }
.ghost-btn {
  border: 3px solid var(--ink); background: var(--paper); padding: 12px 22px; font-weight: 900; cursor: pointer;
}
.ghost-btn:hover { background: var(--ink); color: var(--paper); }

/* ── 雜誌式捲動動態 ───────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .q-no {
      animation: no-in linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 45%;
    }
    .q-title, .q-hint {
      animation: title-in linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 35%;
    }
    .q { animation: rule-in linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
    .hero-word { animation: hero-out linear both; animation-timeline: scroll(root); animation-range: 0 100svh; }
    .hero-sub { animation: hero-sub-out linear both; animation-timeline: scroll(root); animation-range: 0 100svh; }
    @keyframes no-in {
      from { transform: translateX(-38%) scale(.7); opacity: 0; letter-spacing: .2em; }
      60% { opacity: 1; }
      to { transform: none; opacity: 1; letter-spacing: 0; }
    }
    @keyframes title-in {
      from { transform: translateY(36px); opacity: 0; clip-path: inset(0 0 100% 0); }
      to { transform: none; opacity: 1; clip-path: inset(0 0 0 0); }
    }
    @keyframes rule-in { from { border-top-color: transparent; } to { border-top-color: var(--line); } }
    @keyframes hero-out { to { transform: translateX(-18%) skewX(-6deg); letter-spacing: .08em; } }
    @keyframes hero-sub-out { to { transform: translateX(14%); } }
  }

  /* 不支援 scroll-driven 的瀏覽器：進入畫面時才動一次 */
  @supports not (animation-timeline: view()) {
    .js .q-no { transform: translateX(-30%) scale(.75); opacity: 0; transition: transform .8s cubic-bezier(.2,.8,.2,1), opacity .6s; }
    .js .q-title, .js .q-hint { transform: translateY(30px); opacity: 0; transition: transform .7s .12s cubic-bezier(.2,.8,.2,1), opacity .6s .12s; }
    .js .q.in .q-no, .js .q.in .q-title, .js .q.in .q-hint { transform: none; opacity: 1; }
  }
  /* 進場動畫放在外層 h1，捲動動畫放在內層字，兩者才不會互相覆蓋 */
  .hero-title { animation: rise .9s cubic-bezier(.2,.8,.2,1) both; }
  @keyframes rise { from { transform: translateY(40px); opacity: 0; } }
}

/* ── 手機 ───────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding-top: 22px; }
  .hero-bottom { grid-template-columns: 1fr; gap: 12px; }
  .hero-meta { text-align: left; }
  .hero-meta br { display: none; }
  .hero-meta .sep { display: inline-block; width: 14px; }
  .hero-word { font-size: 44vw; }
  .hero-sub { font-size: 21vw; }
  .hero-meta b { font-size: 30px; }
  .q { padding: 20px 0 44px; }
  .q-head { gap: 0 12px; margin-bottom: 16px; }
  .opt-box { padding: 13px 14px; gap: 12px; font-size: 16px; }
  .sub-row { grid-template-columns: 1fr 1fr; }
  .sub-brand { grid-column: 1 / -1; font-size: 17px; }
  .submit-btn { padding: 22px 20px; }
  .stamp { padding: 14px 22px 18px; }
  .stamp-ladder li { font-size: 12px; }
}
