/* 員工日站來賓頁：手機優先，紅＋金＋米白（中性喜氣，不用萬聖節素材） */
:root {
  --red: #8f1d1d;
  --red-deep: #5c1010;
  --gold: #d4a12a;
  --gold-soft: #f6e3a8;
  --cream: #fbf6ec;
  --ink: #2a1a14;
  --muted: #7a675c;
  --line: #ead9c0;
  --ok: #1f7a4d;
  --err: #b42318;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(92, 16, 16, 0.08);
  font-size: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--cream);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.6;
}
a { color: var(--red); }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--red); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; min-height: 44px; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--gold); color: var(--red-deep); font-weight: 800;
}
.lang-switch {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 999px; color: #fff; text-decoration: none; font-size: 14px;
}
.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
.hero { text-align: center; padding: 28px 8px 8px; }
.eyebrow { margin: 0; color: var(--muted); letter-spacing: 0.1em; }
.hero h1 { margin: 4px 0 8px; font-size: 32px; line-height: 1.2; color: var(--red); letter-spacing: -0.01em; }
.meta { margin: 0; color: var(--muted); }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 8px; font-size: 18px; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
input {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus-visible, .btn:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; padding: 0 20px;
  border: 0; border-radius: 14px; background: var(--red); color: #fff; font-size: 17px; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; }
.btn-line { background: #06c755; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.flash { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--gold-soft); color: var(--ink); font-weight: 600; }
.flash.ok { background: #dcf3e6; color: var(--ok); }
.flash.err { background: #fde8e6; color: var(--err); }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar.ph { display: grid; place-items: center; background: var(--gold-soft); color: var(--red); font-weight: 700; }

/* 通行證 */
.pass {
  background: linear-gradient(160deg, var(--red) 0%, var(--red-deep) 100%); color: #fff;
  border-radius: 20px; padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.pass::before {
  content: ""; position: absolute; inset: 8px; border: 1px solid rgba(246, 227, 168, 0.45); border-radius: 14px; pointer-events: none;
}
.pass-head { display: flex; align-items: center; gap: 12px; }
.pass-head > div { flex: 1; min-width: 0; }
.pass-hello { margin: 0; font-size: 20px; font-weight: 700; }
.pass-sub { margin: 0; color: var(--gold-soft); font-size: 14px; }
.chip { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); font-size: 13px; white-space: nowrap; }
.chip.ok { background: var(--gold); color: var(--red-deep); font-weight: 700; }
.pass .flash { margin-top: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.stat { background: rgba(255, 255, 255, 0.1); border-radius: 14px; padding: 12px; text-align: center; }
.stat.gold { background: var(--gold); color: var(--red-deep); }
.stat-n { display: block; font-size: 36px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 13px; }
.bump { animation: bump 0.5s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }
.rank-line { margin: 12px 0 0; text-align: center; color: var(--gold-soft); font-size: 14px; }
.win-card { border-color: var(--gold); background: #fffbef; }
.win-line { margin: 4px 0; font-weight: 700; color: var(--red); }
.stations { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.station { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.station.done { background: #fffbef; border-color: var(--gold); }
.station-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); flex: none; font-weight: 800; color: var(--red-deep); }
.station.done .station-mark { background: var(--gold); border-color: var(--gold); }
.station-body { flex: 1; min-width: 0; display: grid; }
.station-body span { color: var(--muted); font-size: 13px; }
.station-pts { font-weight: 700; color: var(--red); white-space: nowrap; }
.logout { text-align: center; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; min-height: 44px; font-size: 14px; cursor: pointer; }

/* 結果頁 */
.result { text-align: center; padding: 40px 12px; display: grid; gap: 12px; justify-items: center; }
.result h1 { margin: 0; font-size: 24px; }
.result p { margin: 0; color: var(--muted); }
.result-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; font-size: 36px; font-weight: 800; background: var(--gold-soft); color: var(--red-deep); }
.result.ok .result-icon { background: var(--gold); animation: pop 0.5s ease; }
.result.err .result-icon { background: #fde8e6; color: var(--err); }
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.1); } }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: #fff; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 兌換券：清單 */
.vlist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.vitem {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 56px; padding: 10px 12px;
  border: 1px solid var(--gold); border-radius: 12px; background: #fffbef; color: var(--ink); text-decoration: none;
}
.vitem.redeemed, .vitem.expired, .vitem.void { border-color: var(--line); background: #faf7f2; color: var(--muted); }
.vcat { font-size: 12px; font-weight: 700; color: var(--red); letter-spacing: 0.05em; }
.vchip { padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--red); color: #fff; white-space: nowrap; }
.vchip.redeemed, .vchip.expired, .vchip.void { background: var(--line); color: var(--muted); }

/* 兌換券：券面（票根造型，中間打孔線） */
.ticket {
  position: relative; background: #fff; border: 2px solid var(--gold); border-radius: 20px; padding: 24px 20px; text-align: center; box-shadow: var(--shadow);
}
.ticket h1 { margin: 4px 0 6px; font-size: 26px; line-height: 1.25; color: var(--red); }
.ticket .vcat { margin: 0; }
.ticket-detail { margin: 0; color: var(--muted); }
.ticket-cut { margin: 18px -20px; border-top: 2px dashed var(--line); position: relative; }
.ticket-cut::before, .ticket-cut::after { content: ""; position: absolute; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: var(--cream); border: 2px solid var(--gold); }
.ticket-cut::before { left: -14px; border-left-color: transparent; border-bottom-color: transparent; transform: rotate(45deg); }
.ticket-cut::after { right: -14px; border-right-color: transparent; border-top-color: transparent; transform: rotate(45deg); }
.ticket-qr { width: min(240px, 70vw); margin: 0 auto; }
.ticket-qr svg { width: 100%; height: auto; display: block; }
.ticket-show { margin: 8px 0 0; font-weight: 700; }
.ticket-code { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.ticket-code b { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 18px; color: var(--ink); letter-spacing: 0.12em; }
.ticket-holder { margin: 4px 0 0; font-weight: 700; }
.ticket-stamp {
  display: inline-block; margin: 12px auto; padding: 10px 28px; border: 4px solid var(--red); border-radius: 12px; color: var(--red);
  font-size: 30px; font-weight: 800; letter-spacing: 0.1em; transform: rotate(-8deg); animation: stamp 0.4s ease;
}
.ticket.expired .ticket-stamp, .ticket.void .ticket-stamp { border-color: var(--muted); color: var(--muted); }
@keyframes stamp { 0% { transform: rotate(-8deg) scale(2); opacity: 0; } 100% { transform: rotate(-8deg) scale(1); opacity: 1; } }

/* 核銷頁（工作人員／店家） */
.staffbar { background: #1f2937; }
.staffbar .brand-mark { background: #fbbf24; color: #1f2937; }
.staff-who { margin: 0 0 4px; }
.code-input { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.15em; text-transform: uppercase; font-size: 20px; text-align: center; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plain-list small { display: block; color: var(--muted); }
.staff-v { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; display: grid; gap: 8px; box-shadow: var(--shadow); }
.staff-v h1 { margin: 0; font-size: 26px; color: var(--red); }
.staff-v .vcat { margin: 0; }
.staff-v.ok { border: 3px solid var(--ok); }
.staff-holder { margin: 0; font-size: 22px; font-weight: 800; }
.staff-holder small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }
.staff-big { padding: 16px; border-radius: 14px; font-size: 24px; font-weight: 800; }
.staff-big.ok { background: #dcf3e6; color: var(--ok); animation: pop 0.4s ease; }
.staff-big.err { background: #fde8e6; color: var(--err); }
.btn.btn-big { min-height: 64px; font-size: 22px; background: var(--ok); }
.btn.btn-ghost { background: #fff; color: var(--red); border: 1px solid var(--red); }
/* 通行證上方即時橫幅 */
.banners { display: grid; gap: 8px; }
.banners:empty { display: none; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 10px 14px; border-radius: 12px; font-weight: 700; text-decoration: none; color: var(--ink); background: var(--gold-soft); }
.banner b { flex: none; padding: 6px 14px; border-radius: 99px; background: var(--red); color: #fff; }
.banner.mission { background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.banner.mission b { background: var(--gold); color: var(--red-deep); }
.banner.result { background: #fff; border: 2px solid var(--red); color: var(--red); }
.banner.boost { background: linear-gradient(90deg, var(--gold), #f3c75a); color: var(--red-deep); }
.banner.ann { background: #fff; border: 1px solid var(--line); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(143, 29, 29, 0.18); } }
/* 突發任務頁 */
.mission { text-align: center; }
.m-title { margin: 4px 0 6px; font-size: 26px; line-height: 1.25; color: var(--red); }
.m-q { margin: 0 0 10px; font-size: 18px; font-weight: 600; }
.m-none { margin: 12px 0; font-size: 18px; }
.m-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 12px; }
.m-tags span { padding: 2px 10px; border-radius: 99px; background: var(--gold-soft); font-size: 14px; }
.m-timer { margin: 8px 0 12px; font-size: 40px; font-weight: 800; color: var(--red); font-variant-numeric: tabular-nums; }
.m-timer.hurry { color: var(--err); animation: pulse 0.8s ease-in-out infinite; }
.m-opts { display: grid; gap: 10px; text-align: left; }
.m-opt { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); font: inherit; font-size: 18px; font-weight: 600; cursor: pointer; text-align: left; }
.m-opt b { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--red); color: #fff; }
.m-opt:active { transform: scale(0.98); border-color: var(--red); }
.m-opt:disabled { opacity: 0.5; }
.m-scan { font-size: 20px; font-weight: 700; }
.m-state { display: grid; gap: 6px; }
.m-state p { margin: 0; }
.m-big { font-size: 22px; font-weight: 800; }
.m-big.ok { color: var(--ok); }
.m-won { padding: 14px; border-radius: 14px; background: var(--gold); color: var(--red-deep); font-size: 22px; font-weight: 800; }
.m-winners { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.m-winners li { padding: 8px 12px; border-radius: 10px; background: var(--cream); }
.m-winners li.me { background: var(--gold-soft); outline: 2px solid var(--gold); }
.m-winners small { margin-left: 8px; color: var(--muted); }
.mission h2 { margin: 12px 0 4px; font-size: 18px; }
.banner span { text-align: left; }
/* AR 相框 */
.ar-entry { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.ar-entry-icon { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--gold-soft); font-size: 26px; }
.ar-entry strong { display: block; color: var(--red); font-size: 18px; }
.ar-entry small { color: var(--muted); font-size: 14px; }
.ar { display: grid; gap: 12px; }
.ar-h { margin: 0; font-size: 22px; color: var(--red); text-align: center; }
.ar-stage { position: relative; border-radius: 14px; overflow: hidden; background: #2a1a14; aspect-ratio: 3 / 4; }
.ar-view { display: block; width: 100%; height: 100%; touch-action: none; }
.ar-view.flash { animation: shot .35s ease-out; }
@keyframes shot { from { filter: brightness(2.2); } }
.ar-msg { position: absolute; left: 12px; right: 12px; top: 50%; transform: translateY(-50%); margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 15px; text-align: center; }
.ar-msg[hidden] { display: none; }
.ar-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800; color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,.6); }
.ar-count[hidden] { display: none; }
.ar-label { margin: 0; font-weight: 700; }
.ar-frames { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.ar-frame { flex: none; display: grid; justify-items: center; gap: 4px; width: 84px; padding: 6px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; scroll-snap-align: start; }
.ar-frame canvas { width: 60px; height: 80px; border-radius: 6px; }
.ar-frame span { line-height: 1.3; text-align: center; }
.ar-frame[aria-checked="true"] { border-color: var(--red); background: var(--gold-soft); }
.ar-ctrl { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.ar-ctrl[hidden], .ar-adjust[hidden], .ar-result[hidden] { display: none; }
.ar-round { justify-self: start; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 24px; color: var(--ink); cursor: pointer; }
.ar-shutter { width: 76px; height: 76px; border-radius: 50%; border: 6px solid var(--gold); background: var(--red); cursor: pointer; box-shadow: 0 4px 14px rgba(92,16,16,.3); }
.ar-shutter:active { transform: scale(.94); }
.ar-timer { justify-self: end; display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; }
.ar-adjust { display: grid; gap: 8px; }
.ar-adjust .hint { margin: 0; }
.ar-zoom { display: grid; gap: 4px; font-size: 14px; }
.ar-zoom input { width: 100%; }
.ar-pick { text-align: center; }
.ar-result { display: grid; gap: 10px; }
.ar-result img { width: 100%; border-radius: 12px; display: block; }
.ar-result .hint { margin: 0; text-align: center; }
.ar-actions { display: grid; gap: 8px; }
.ar-actions .btn { text-align: center; }
.ar-mine { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ar-mine img { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; display: block; }
.ar-mine li.hidden { display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: 8px; background: var(--cream); color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }
/* GPS 柵欄定位頁 */
.geo .hint { max-width: 32em; margin-left: auto; margin-right: auto; }
.geo-pin { position: relative; width: 72px; height: 72px; margin: 8px auto 4px; }
.geo-pin span { position: absolute; left: 50%; top: 6px; width: 40px; height: 40px; margin-left: -20px; border-radius: 50% 50% 50% 0; background: var(--red); transform: rotate(-45deg); animation: pin 1.2s ease-in-out infinite; }
.geo-pin span::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: #fff; }
.geo-pin::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 36px; height: 10px; margin-left: -18px; border-radius: 50%; background: rgba(92,16,16,.18); }
@keyframes pin { 50% { transform: rotate(-45deg) translate(6px, -6px); } }
.geo-status { font-weight: 700; }
.geo-slow[hidden] { display: none; }
.geo .btn + .btn { margin-top: 8px; }
