:root {
  --sky-1: #c7dcf7;
  --sky-2: #8fb4ec;
  --ink: #141414;
  --paper: #ffffff;
  --yellow: #f7d64a;
  --pink: #f3a6ae;
  --blue: #2f3f8f;
  --muted: #4b5563;
  --sketch: 18px 22px 16px 24px / 22px 16px 24px 18px;
  --font: 'Huninn', 'PingFang TC', 'Noto Sans TC', sans-serif;
  --font-en: 'Luckiest Guy', 'Huninn', sans-serif;
}
* { box-sizing: border-box; }
html { background: #8fb4ec; overflow-x: hidden; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: transparent;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
#app { position: relative; max-width: 480px; margin: 0 auto; padding: 20px 16px 48px; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.center { text-align: center; }

.screen { display: none; animation: fade .35s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.foot { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 28px auto 0; color: var(--ink); text-decoration: none; font-size: 14px; }
.foot img { width: 170px; }

/* 按鈕 */
.btn {
  display: block; width: 100%; margin: 12px 0 0; padding: 15px 16px;
  font: inherit; font-size: 18px; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: var(--sketch); box-shadow: 3px 4px 0 var(--ink);
  cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(3px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--yellow); }
.btn.ghost { background: rgba(255,255,255,.55); }
.link { display: block; margin: 18px auto 0; background: none; border: 0; font: inherit; font-size: 15px; color: var(--ink); text-decoration: underline; cursor: pointer; }

/* 對話 */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.msg { display: flex; gap: 8px; align-items: flex-end; animation: pop .3s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
.msg .avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--paper) center 12% / 150% no-repeat; }
.msg .bubble { max-width: 78%; padding: 10px 14px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 18px 18px 18px 4px; font-size: 16px; line-height: 1.55; }
.msg .who { display: block; font-size: 12px; opacity: .6; margin-bottom: 2px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .bubble { background: var(--yellow); border-radius: 18px 18px 4px 18px; }
.msg.friend .avatar { background: var(--pink); display: grid; place-items: center; font-size: 22px; }
.msg.narr { justify-content: center; }
.msg.narr .bubble { background: transparent; border: 0; font-size: 15px; opacity: .8; text-align: center; padding: 2px; }
.chat-actions .btn { animation: pop .3s ease; }
.notify { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: rgba(255,255,255,.9); border: 2.5px solid var(--ink); border-radius: 16px; font-size: 14px; animation: drop .4s ease; }
.notify b { display: block; font-size: 13px; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

/* 題目 */
.progress { height: 10px; border: 2.5px solid var(--ink); border-radius: 10px; background: var(--paper); overflow: hidden; }
.progress .bar { height: 100%; background: var(--yellow); transition: width .3s; }
.q-no { font-family: var(--font-en); font-size: 20px; margin: 18px 0 0; letter-spacing: 1px; }
.q-title { font-size: 22px; margin: 4px 0 8px; }
.q-ask { font-size: 17px; margin: 4px 0 6px; }
.options .btn { text-align: left; font-size: 16px; line-height: 1.5; padding: 13px 14px 13px 46px; position: relative; }
.options .btn::before { content: attr(data-key); position: absolute; left: 12px; top: 12px; width: 24px; height: 24px; border: 2px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font-family: var(--font-en); font-size: 13px; background: var(--sky-1); }
.options .btn.picked { background: var(--yellow); }

/* Loading */
.loading { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 20px; }
.bolt { font-size: 84px; animation: zap .9s ease-in-out infinite; }
@keyframes zap { 0%,100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.2); } }
.dots { display: flex; gap: 8px; } .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

/* 卡片 */
.card { background: var(--paper); border: 3px solid var(--ink); border-radius: var(--sketch); box-shadow: 4px 5px 0 var(--ink); padding: 20px 18px; margin: 0 0 20px; }
.card h3 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); margin: 0 0 10px; }
.small { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 12px 0 0; }
.reveal { text-align: center; animation: pop .5s ease; }
.kicker { margin: 0; font-size: 18px; }
.r-name { font-size: 34px; margin: 4px 0 8px; }
.r-img { width: 52%; margin: 0 auto; animation: bob 2.4s ease-in-out infinite; }
.r-char { margin: 8px 0 14px; font-size: 15px; color: var(--muted); }
.power { background: var(--sky-1); border: 2.5px dashed var(--ink); border-radius: 14px; padding: 12px 14px; }
.power .label { font-size: 13px; letter-spacing: 1px; }
.power p { margin: 4px 0 0; font-size: 18px; line-height: 1.5; }
.evidence { list-style: none; padding: 0; margin: 0; }
.evidence li { padding: 8px 0 8px 30px; position: relative; line-height: 1.55; border-bottom: 1.5px dashed #c9c9c9; }
.evidence li::before { content: '✓'; position: absolute; left: 4px; top: 7px; font-weight: 700; color: var(--blue); }
.partner { display: flex; gap: 14px; align-items: center; }
.partner img { width: 84px; flex: none; }
.partner b { font-size: 20px; display: block; margin-bottom: 4px; }
.partner p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.share-preview { width: 62%; margin: 10px auto 6px; border: 2.5px solid var(--ink); border-radius: 12px; }

/* 任務 */
.mission h2 { font-size: 22px; margin: 0 0 12px; }
.mission ol { padding-left: 22px; margin: 0; line-height: 1.75; font-size: 16px; }
.mission li { margin-bottom: 8px; }
.m-img { width: 40%; margin: 12px auto 0; }

/* 裝備 */
.gear-title { font-size: 21px; text-align: center; line-height: 1.6; margin: 6px 0 18px; }
.gear { display: grid; gap: 14px; }
.gear a { display: flex; gap: 14px; align-items: center; color: inherit; text-decoration: none; background: var(--paper); border: 3px solid var(--ink); border-radius: var(--sketch); box-shadow: 3px 4px 0 var(--ink); padding: 12px; position: relative; }
.gear a.match { background: #fff8d6; }
.gear .thumb { width: 84px; height: 84px; flex: none; border: 2.5px solid var(--ink); border-radius: 14px; background: var(--sky-1); display: grid; place-items: center; font-size: 40px; overflow: hidden; }
.gear .thumb img { width: 100%; height: 100%; object-fit: cover; }
.gear b { font-size: 18px; }
.gear p { margin: 3px 0 6px; font-size: 14px; line-height: 1.5; }
.gear .fits { font-size: 12px; color: var(--muted); }
.gear .badge { position: absolute; top: -12px; right: 10px; background: var(--yellow); border: 2px solid var(--ink); border-radius: 10px; padding: 1px 8px; font-size: 12px; }

/* 背景：固定天空（iOS 不支援 background-attachment: fixed，改用固定定位層） */
.sky { position: fixed; inset: 0; z-index: -1; background: #8fb4ec url(assets/bg.jpg) center top / cover no-repeat; }

/* 首頁 */
#s-home { position: relative; padding-top: 40px; }
#app { z-index: 1; }
.deco { position: absolute; pointer-events: none; z-index: 0; }
.float-cloud { width: 34%; }
.page-deco { position: absolute; top: 0; left: 0; right: 0; height: 420px; overflow: hidden; pointer-events: none; z-index: 0; display: none; }
body.on-home .page-deco { display: block; }
/* 側邊雲是角落素材：左上角對齊畫面角落 */
.corner-cloud { position: absolute; top: 0; left: 0; width: min(46vw, 260px); }
.page-deco .float-cloud.c1 { position: absolute; width: min(30vw, 170px); top: 120px; right: -4%; animation: drift 7s ease-in-out infinite; }
.float-cloud.c2 { width: 24%; top: 520px; left: -10%; animation: drift 9s ease-in-out infinite reverse; }
@keyframes drift { 50% { transform: translateX(14px) translateY(-6px); } }
#s-home > :not(.deco) { position: relative; z-index: 1; }

.hero-head { text-align: center; padding: 34px 0 6px; position: relative; }
.herotest { width: 92%; margin: 0 auto; filter: drop-shadow(3px 3px 0 var(--ink)) drop-shadow(-1px -1px 0 var(--ink)); animation: pop .6s ease; }
.hero-sub { font-size: 30px; margin: 14px 0 0; letter-spacing: 2px; color: var(--ink);
  text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff; }
.spark { position: absolute; font-size: 30px; animation: zap 1.4s ease-in-out infinite; }
.spark.s1 { left: 0; top: 4px; } .spark.s2 { right: 2px; top: 92px; animation-delay: .5s; font-size: 24px; }

.crew-stage { margin: 18px -4px 0; }
.crew-img { width: 100%; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.intro-card { background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: var(--sketch);
  box-shadow: 4px 5px 0 var(--ink); padding: 20px 18px; margin-top: 4px; text-align: center; font-size: 16px; line-height: 1.8; }
.intro-card p { margin: 0 0 10px; }
.intro-q { font-size: 21px; line-height: 1.6; }
.intro-ready { font-size: 19px; margin: 4px 0 0 !important; }
.btn.big { font-size: 20px; padding: 18px 16px; margin-top: 22px; }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }

.loading { position: relative; }
.float-cloud.c3 { width: 60%; top: 8%; left: 20%; opacity: .9; animation: drift 6s ease-in-out infinite; }
.loading > :not(.deco) { position: relative; z-index: 1; }

/* 裝備 */
.gear-label { font-size: 16px; margin: 0 0 10px; text-align: center; }
#gear-rest { margin-top: 14px; }
.gear .price { font-size: 15px; font-weight: 700; margin-left: 8px; }
.shop-note { margin-top: 14px; font-size: 16px; line-height: 1.7; text-align: center; }
