:root {
  --paper: #f6f4ee;
  --card: #ffffff;
  --ink: #15181c;
  --muted: #5b626a;
  --line: #dcd8cc;
  --blue: #1a3fd0;
  --blue-dark: #122c99;
  --blue-soft: #e9edfc;
  --yellow: #ffdf3d;
  --yellow-soft: #fff6c4;
  --green: #0b7a4b;
  --red: #b3261e;
  --radius: 14px;
  --scroll-offset: 68px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}
h1, h2, h3, p, ol { margin: 0; }
a { color: var(--blue); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.setup-warning { background: var(--red); color: #fff; font-size: 14px; font-weight: 600; padding: 8px 16px; text-align: center; }

/* ---------- 頁首 ---------- */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 800; font-size: 17px; letter-spacing: .02em; text-decoration: none; }
.wordmark-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--blue); color: var(--yellow); font-family: var(--mono); font-size: 16px; font-weight: 800; transform: rotate(-8deg); }
.header-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.header-meta:not(:empty)::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); vertical-align: 1px; }

/* ---------- 首屏 ---------- */
.hero { padding: 26px 0 22px; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--blue); letter-spacing: .06em; }
.hero h1 { margin-top: 8px; font-size: clamp(30px, 8vw, 46px); line-height: 1.2; font-weight: 900; letter-spacing: -.01em; text-wrap: balance; }
.hl { background: linear-gradient(transparent 58%, var(--yellow) 58%); padding: 0 .08em; }
.lede { margin-top: 12px; max-width: 34em; color: var(--muted); font-size: 16px; }

.hero-tickets { display: grid; gap: 14px; margin-top: 22px; }
.ticket { display: grid; background: var(--card); border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.ticket-body { padding: 18px 18px 16px; }
.ticket-kicker { font-size: 13px; font-weight: 700; color: var(--blue); }
.ticket-title { margin-top: 4px; font-size: 22px; line-height: 1.3; font-weight: 800; }
.ticket-title strong { font-size: 1.25em; font-weight: 900; }
.ticket-meta { margin-top: 6px; font-size: 14px; color: var(--muted); }
.ticket-stub { position: relative; display: grid; gap: 10px; padding: 16px 18px 18px; border-top: 2px dashed var(--ink); background: var(--yellow-soft); }
.ticket-stub::before, .ticket-stub::after { content: ""; position: absolute; top: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
.ticket-stub::before { left: -11px; }
.ticket-stub::after { right: -11px; }
.ticket--featured { background: var(--blue); border-color: var(--blue-dark); color: #fff; }
.ticket--featured .ticket-kicker { color: var(--yellow); }
.ticket--featured .ticket-meta { color: #d5dcfa; }
.ticket--featured .ticket-title { font-size: 26px; }
.ticket--featured .ticket-stub { background: var(--yellow); color: var(--ink); border-top-color: var(--blue-dark); }
.ticket--featured .ticket-stub::before, .ticket--featured .ticket-stub::after { border-color: var(--blue-dark); }
.ticket--featured .claim { background: var(--ink); }
.ticket--featured .claim:hover { background: #000; }
.ticket--featured .offer-code { background: #fff; }
.ticket .offer-code { justify-self: stretch; font-size: 20px; min-height: 48px; }
.ticket .offer-navigation { grid-column: auto; padding: 0; }

.steps { display: grid; gap: 8px; margin-top: 20px; padding: 0; list-style: none; font-size: 14px; font-weight: 600; }
.steps li { display: flex; align-items: center; gap: 10px; }
.steps span { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; font-family: var(--mono); }
.disclosure { margin-top: 16px; font-size: 12.5px; color: var(--muted); max-width: 46em; }

/* ---------- 代碼與按鈕 ---------- */
.offer-code {
  display: flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 6px 12px;
  border: 1.5px dashed var(--ink); border-radius: 10px;
  background: var(--paper);
  font-family: var(--mono); font-size: 16px; font-weight: 700; letter-spacing: .08em;
  overflow-wrap: anywhere; text-align: center;
}
.offer-code.revealed { background: var(--yellow); border-style: solid; user-select: all; -webkit-user-select: all; }
.claim {
  min-height: 44px; padding: 8px 16px;
  border: 0; border-radius: 10px;
  background: var(--blue); color: #fff;
  font-weight: 800; font-size: 15px; white-space: nowrap;
  transition: background-color .15s, transform .05s;
}
.claim:hover { background: var(--blue-dark); }
.claim:active { transform: translateY(1px); }
.claim.copied, .ticket--featured .claim.copied { background: var(--green); }
.claim:disabled { opacity: .55; cursor: default; }
.claim--lg { min-height: 52px; font-size: 17px; }
.offer-navigation { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.offer-navigation a { font-weight: 700; }

/* ---------- 分類列 ---------- */
.catbar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.catbar .wrap { padding: 0; }
#category-nav { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; position: relative; }
#category-nav::-webkit-scrollbar { display: none; }
#category-nav a {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 4px 14px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
#category-nav a small { font-family: var(--mono); font-size: 12px; color: var(--muted); }
#category-nav a:hover { border-color: var(--ink); }
#category-nav a[aria-current] { background: var(--ink); border-color: var(--ink); color: #fff; }
#category-nav a[aria-current] small { color: var(--yellow); }

/* ---------- 搜尋與篩選 ---------- */
.offer-tools { padding: 18px 0 4px; }
.search-field { position: relative; }
#offer-search {
  width: 100%; min-height: 48px; padding: 10px 76px 10px 14px;
  border: 1.5px solid var(--ink); border-radius: 12px; background: var(--card);
  font-size: 16px;
}
#offer-search::placeholder { color: #868c93; }
#clear-search { position: absolute; right: 6px; top: 6px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--paper); font-size: 14px; font-weight: 600; }
.filter-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-filters button { min-height: 36px; padding: 4px 14px; border: 1.5px solid var(--line); border-radius: 8px; background: transparent; font-size: 14px; font-weight: 600; }
.quick-filters button[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-dark); }
#offer-results { font-size: 13px; color: var(--muted); }
.search-empty { margin-top: 18px; padding: 28px 18px; border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.search-empty .empty-title { color: var(--ink); font-weight: 800; font-size: 18px; }
.search-empty button { margin-top: 12px; min-height: 44px; padding: 8px 18px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--card); font-weight: 700; }
.empty-state { padding: 28px 0; color: var(--muted); }

/* ---------- 優惠清單 ---------- */
.offer-section { margin-top: 30px; scroll-margin-top: var(--scroll-offset); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-heading h2 { font-size: 20px; font-weight: 800; line-height: 1.35; }
.section-count { flex: none; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.offer-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.offer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 16px; }
.offer-row + .offer-row { border-top: 1px solid var(--line); }
.offer-description { grid-column: 1 / -1; min-width: 0; }
.offer-label { font-size: 13px; font-weight: 700; color: var(--blue); }
.offer-name { margin-top: 2px; font-size: 17px; line-height: 1.45; font-weight: 600; }
.offer-name strong { font-weight: 900; }
.offer-extra { margin-top: 2px; font-size: 13.5px; color: var(--muted); }
.offer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.offer-tag { padding: 1px 8px; border-radius: 6px; background: var(--blue-soft); color: var(--blue-dark); font-size: 12px; font-weight: 700; }
.offer-row .offer-code { grid-column: 1; grid-row: 2; justify-self: start; min-width: 132px; }
.offer-row .claim { grid-column: 2; grid-row: 2; min-width: 108px; }
.offer-expiry { grid-column: 1 / -1; grid-row: 3; font-size: 13px; color: var(--muted); }
.offer-expiry.soon { color: var(--red); font-weight: 700; }
.offer-row.is-expired .offer-description, .offer-row.is-expired .offer-code { opacity: .5; }

/* ---------- FAQ 與頁尾 ---------- */
.faq { margin-top: 44px; scroll-margin-top: var(--scroll-offset); }
.faq h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.faq-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.faq details + details { border-top: 1px solid var(--line); }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 12px 16px; font-weight: 700; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; font-family: var(--mono); font-size: 20px; color: var(--blue); }
.faq details[open] summary::after { content: "−"; }
.faq-answer { padding: 0 16px 16px; color: #3c4249; font-size: 15px; }
.site-footer { margin-top: 48px; padding: 24px 0 36px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.footer-line { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.footer-line a { color: var(--muted); }

/* ---------- 政策頁 ---------- */
.header-back { font-size: 14px; font-weight: 600; white-space: nowrap; }
.legal { max-width: 760px; padding-top: 32px; }
.legal h1 { font-size: clamp(28px, 7vw, 38px); line-height: 1.25; font-weight: 900; }
.legal-intro { margin-top: 12px; color: var(--muted); }
.legal-date { margin-top: 8px; font-size: 13px; color: var(--muted); }
.legal section { margin-top: 28px; }
.legal h2 { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.legal section p + p { margin-top: 10px; }
.legal dl { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.legal dl > div { padding: 14px 16px; }
.legal dl > div + div { border-top: 1px solid var(--line); }
.legal dt { font-weight: 700; }
.legal dd { margin: 2px 0 0; color: #3c4249; font-size: 15px; }
.legal code { font-family: var(--mono); font-size: .92em; background: var(--blue-soft); padding: 1px 5px; border-radius: 4px; }
.legal a { overflow-wrap: anywhere; }
.legal-button { display: inline-block; margin-top: 20px; padding: 10px 18px; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 800; text-decoration: none; }
.footer-line a[aria-current] { color: var(--ink); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 40;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 28px rgb(0 0 0 / .25);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 平板以上 ---------- */
@media (min-width: 720px) {
  .wrap { padding: 0 24px; }
  .hero { padding: 44px 0 30px; }
  .lede { font-size: 17px; }
  .hero-tickets { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: stretch; }
  .ticket { grid-template-rows: 1fr auto; }
  .steps { grid-template-columns: repeat(3, auto); justify-content: start; gap: 8px 28px; }
  #category-nav { padding: 10px 24px; }
  .offer-row { grid-template-columns: minmax(0, 1fr) 176px 124px; gap: 6px 20px; padding: 16px 20px; }
  .offer-description { grid-column: 1; grid-row: 1 / span 2; }
  .offer-row .offer-code { grid-column: 2; grid-row: 1; justify-self: stretch; min-width: 0; }
  .offer-row .claim { grid-column: 3; grid-row: 1; min-width: 0; }
  .offer-expiry { grid-column: 2 / -1; grid-row: 2; text-align: right; }
  .offer-row .offer-navigation { grid-row: 3; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast, .claim { transition: none; }
}
