:root {
  --bg: #05070f;
  --fg: #e9ecf5;
  --dim: #9aa3bd;
  --faint: rgba(233, 236, 245, .45);
  --acc: #f2c879;
  --acc-ink: #1a1306;
  --glass: rgba(14, 18, 34, .62);
  --glass2: rgba(20, 26, 48, .86);
  --line: rgba(255, 255, 255, .1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
html.red {
  --fg: #ff5b4a;
  --dim: #c2382c;
  --faint: rgba(255, 70, 50, .5);
  --acc: #ff3b2b;
  --acc-ink: #200300;
  --glass: rgba(30, 2, 0, .7);
  --glass2: rgba(34, 3, 0, .92);
  --line: rgba(255, 60, 40, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* iOS 26 standalone：html、body 都 100vh 固定，不讓整頁捲動 */
html, body {
  margin: 0; height: 100vh; width: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
  font: 15px/1.55 -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

#cam, #gl, #ov { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#cam { object-fit: cover; background: #000; }
html.red #cam { filter: grayscale(1) sepia(1) saturate(6) hue-rotate(-50deg) brightness(.55); }
#ov { pointer-events: none; }

/* 頁首固定（iOS 26） */
#top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) 8px calc(var(--safe-l) + 10px);
  background: linear-gradient(to bottom, rgba(5, 7, 15, .75), rgba(5, 7, 15, 0));
}
html.red #top { background: linear-gradient(to bottom, rgba(10, 0, 0, .8), rgba(10, 0, 0, 0)); }
.grow { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 11px; border-radius: 17px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 13.5px; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }
.chip.score b { font-size: 15px; color: var(--acc); font-variant-numeric: tabular-nums; }
.chip.score span { color: var(--dim); font-size: 12px; }
.chip.seg { padding: 3px; gap: 0; }
.chip.seg span { padding: 0 9px; line-height: 26px; border-radius: 13px; color: var(--dim); }
.chip.seg span.on { background: var(--acc); color: var(--acc-ink); font-weight: 600; }
.icon { width: 34px; height: 34px; border-radius: 17px; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.icon svg { width: 18px; height: 18px; }
#redBtn.on { background: #6a0d06; color: #ff5b4a; }

/* 底部 */
#bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 18px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 10px);
  background: linear-gradient(to top, rgba(5, 7, 15, .85) 40%, rgba(5, 7, 15, 0));
}
html.red #bottom { background: linear-gradient(to top, rgba(10, 0, 0, .9) 40%, rgba(10, 0, 0, 0)); }
.timebar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tl { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 74px; }
.tl span { font-size: 11px; color: var(--dim); }
.tl b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl.off b { color: var(--acc); }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 30px; background: transparent; touch-action: none; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--line), var(--faint) 50%, var(--line)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9.5px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 0 4px rgba(242, 200, 121, .25); }
input[type=range]::-moz-range-track { height: 3px; background: var(--faint); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--fg); border: 0; }
.pill { height: 32px; padding: 0 14px; border-radius: 16px; background: var(--glass2); border: 1px solid var(--line); font-size: 13.5px; white-space: nowrap; }
.pill.hi { background: var(--acc); color: var(--acc-ink); border-color: transparent; font-weight: 600; }
.pill.big { height: 48px; padding: 0 30px; border-radius: 24px; font-size: 17px; }
.dock { display: flex; justify-content: space-between; }
.dock button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--dim); padding: 4px 0; position: relative; }
.dock button.on { color: var(--acc); }
.dock button i { position: absolute; top: 3px; right: calc(50% - 16px); width: 7px; height: 7px; border-radius: 50%; background: var(--acc); }

/* 準星 */
#reticle { position: fixed; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; z-index: 5; pointer-events: none; }
#reticle svg { width: 60px; height: 60px; stroke-width: 1.2; }
#reticle .ring { stroke: rgba(255, 255, 255, .22); }
#reticle .prog { stroke: var(--acc); stroke-width: 2.2; stroke-dasharray: 150.8; stroke-dashoffset: 150.8; transform: rotate(-90deg); transform-origin: 30px 30px; }
#aimName { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12.5px; color: var(--acc); text-shadow: 0 1px 3px #000; }

/* 提示 */
#banner {
  position: fixed; z-index: 21; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 54px);
  max-width: min(92vw, 460px); padding: 8px 14px; border-radius: 14px; background: var(--glass2); border: 1px solid var(--line);
  font-size: 13px; text-align: center; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#banner button { color: var(--acc); margin-left: 8px; font-weight: 600; }
#toast {
  position: fixed; z-index: 40; left: 50%; top: 42%; transform: translate(-50%, -50%);
  padding: 14px 20px; border-radius: 18px; background: var(--glass2); border: 1px solid var(--acc);
  text-align: center; font-size: 15px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); animation: pop .35s ease-out;
}
#toast .stamp { display: block; font-size: 30px; color: var(--acc); font-weight: 700; letter-spacing: 2px; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.8); opacity: 0; } }

#birthCard {
  position: fixed; z-index: 19; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 56px);
  width: min(92vw, 420px); padding: 12px 16px; border-radius: 16px; background: var(--glass2); border: 1px solid var(--line); text-align: center;
}
.bc-t { font-size: 17px; font-weight: 600; color: var(--acc); }
.bc-s { font-size: 13px; color: var(--dim); margin: 2px 0 10px; }
.bc-row { display: flex; gap: 8px; justify-content: center; }

/* 資訊卡（底部抽屜，內部捲動） */
.sheet {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 72vh; display: flex; flex-direction: column;
  background: var(--glass2); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: 0 -10px 40px rgba(0, 0, 0, .5);
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--faint); margin: 8px auto 0; flex: none; }
.close { position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border-radius: 17px; font-size: 24px; line-height: 32px; color: var(--dim); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; padding: 6px 20px calc(var(--safe-b) + 20px); user-select: text; -webkit-user-select: text; }
.sh-kind { font-size: 12px; color: var(--acc); letter-spacing: 1px; margin-top: 6px; }
.sh-title { font-size: 24px; font-weight: 700; margin: 2px 40px 0 0; line-height: 1.25; }
.sh-title small { font-size: 14px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.sh-live { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.sh-live span { font-size: 12.5px; padding: 3px 9px; border-radius: 10px; background: rgba(255, 255, 255, .06); color: var(--dim); }
html.red .sh-live span { background: rgba(255, 40, 20, .08); }
.sh-live span b { color: var(--fg); font-weight: 500; }
.sh-story { font-size: 15.5px; line-height: 1.85; margin: 14px 0; white-space: pre-line; }
.sh-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; padding: 12px 0; border-top: 1px solid var(--line); }
.sh-facts dt { color: var(--dim); }
.sh-facts dd { margin: 0; }
.sh-find { font-size: 13.5px; padding: 10px 12px; border-radius: 12px; background: rgba(242, 200, 121, .08); border: 1px solid rgba(242, 200, 121, .2); margin-bottom: 8px; }
.sh-find b { color: var(--acc); }
.sh-stamp { display: inline-block; margin-top: 8px; padding: 4px 10px; border: 1.5px solid var(--acc); color: var(--acc); border-radius: 8px; font-size: 12.5px; transform: rotate(-3deg); }
.sh-art { display: block; width: 100%; margin: 8px 0; }

/* 全螢幕面板（圖鑑／任務／選單） */
.panel {
  position: fixed; z-index: 35; inset: 0; display: flex; flex-direction: column; background: rgba(5, 7, 15, .94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: fade .2s;
}
html.red .panel { background: rgba(8, 0, 0, .95); }
@keyframes fade { from { opacity: 0; } }
.ph { position: sticky; top: 0; flex: none; display: flex; align-items: center; padding: calc(var(--safe-t) + 12px) 16px 10px; border-bottom: 1px solid var(--line); }
.ph h2 { margin: 0; font-size: 20px; flex: 1; }
.ph .close { position: static; }
.pb { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; padding: 12px 16px calc(var(--safe-b) + 24px); }
.pb h3 { font-size: 14px; color: var(--dim); font-weight: 500; margin: 18px 0 8px; letter-spacing: 1px; }
.pb p { color: var(--dim); font-size: 14px; }
.card { padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); margin-bottom: 10px; }
html.red .card { background: rgba(255, 30, 10, .04); }
.card.done { border-color: var(--acc); }
.card .ct { font-weight: 600; font-size: 15.5px; }
.card .cs { color: var(--dim); font-size: 13px; margin-top: 2px; }
.card .ok { float: right; color: var(--acc); font-size: 13px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.dex { aspect-ratio: 1; border-radius: 14px; border: 1px dashed var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 13px; color: var(--faint); padding: 6px; }
.dex.got { border: 1.5px solid var(--acc); color: var(--fg); background: rgba(242, 200, 121, .06); }
.dex .dd { font-size: 10.5px; color: var(--dim); margin-top: 3px; line-height: 1.3; }
.dex .sym { font-size: 20px; margin-bottom: 2px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; background: var(--acc); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row .rs { color: var(--dim); font-size: 13px; }
.tog { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; }
.tog::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--fg); transition: transform .15s; }
.tog.on { background: var(--acc); }
.tog.on::after { transform: translateX(18px); background: var(--acc-ink); }
.fld { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--dim); }
.fld input, .fld select { font: inherit; font-size: 16px; color: var(--fg); background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; color-scheme: dark; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fine { font-size: 12px; color: var(--faint); }
.credits { font-size: 12px; color: var(--faint); line-height: 1.7; }
.credits a { color: var(--dim); }

/* 開始畫面 */
#start { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 30%, rgba(20, 30, 70, .55), rgba(5, 7, 15, .92) 70%); }
.st-in { text-align: center; padding: 24px; max-width: 360px; }
.logo { font-size: 54px; font-weight: 700; letter-spacing: 10px; margin-bottom: 8px; background: linear-gradient(#fff, var(--acc)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.st-in p { color: var(--dim); font-size: 16px; margin: 0 0 26px; }
.st-in .fine { margin-top: 22px; }
.link { display: block; margin: 16px auto 0; color: var(--dim); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.ver { position: fixed; left: calc(var(--safe-l) + 14px); top: calc(var(--safe-t) + 50px); font-size: 9.5px; color: var(--faint); z-index: 21; pointer-events: none; opacity: .6; }

@media (min-width: 760px) {
  #bottom { padding-left: 20vw; padding-right: 20vw; }
  .dock button { font-size: 12px; }
}
