:root {
  --green: #46ff8c;
  --green-dim: rgba(70, 255, 140, .35);
  --red: #ff2a2a;
  --bg: #000;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: #dfe; overflow: hidden;
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
button { font: inherit; cursor: pointer; border: 0; }
.hidden { display: none !important; }

#view { position: fixed; inset: 0; display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; color: var(--green); font-family: var(--mono);
  text-shadow: 0 0 6px rgba(70, 255, 140, .6); }
#hud button { pointer-events: auto; }
.top { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: center; }
.rec { font-size: 14px; letter-spacing: 1px; color: #fff; text-shadow: 0 0 4px #000; }
.rec .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  margin-right: 6px; vertical-align: -1px; animation: blink 1s steps(1) infinite; box-shadow: 0 0 8px var(--red); }
.top-btns { display: flex; gap: 8px; }
.chip { background: rgba(0, 0, 0, .45); color: var(--green); border: 1px solid var(--green-dim); border-radius: 14px;
  padding: 5px 12px; font-size: 13px; font-family: var(--mono); }

.meter { position: absolute; right: 14px; top: 50%; transform: translateY(-55%); width: 52px; text-align: center;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--green-dim); border-radius: 8px; padding: 8px 6px; }
.meter-label { font-size: 11px; opacity: .8; }
.bars { display: flex; flex-direction: column-reverse; gap: 3px; margin: 6px 0; }
.bars i { display: block; height: 7px; border-radius: 2px; background: rgba(70, 255, 140, .12); }
.bars i.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.bars i.on.mid { background: #ffd23a; box-shadow: 0 0 6px #ffd23a; }
.bars i.on.hi { background: var(--red); box-shadow: 0 0 8px var(--red); }
.val { font-size: 15px; font-weight: bold; }
.unit { font-size: 10px; opacity: .7; }
.temp { font-size: 11px; margin-top: 8px; color: #8ff; }

.bottom { position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex; align-items: flex-end; gap: 14px; }
#radar { width: 112px; height: 112px; flex: none; border-radius: 50%; background: rgba(0, 20, 8, .55);
  box-shadow: 0 0 0 1px var(--green-dim), 0 0 18px rgba(70, 255, 140, .25); }
.panel { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.status { font-size: 14px; line-height: 1.4; min-height: 40px; background: rgba(0, 0, 0, .45); padding: 8px 10px;
  border-left: 3px solid var(--green); border-radius: 4px; }
.status.warn { color: #ffd23a; border-color: #ffd23a; text-shadow: 0 0 6px rgba(255, 210, 58, .6); }
.status.danger { color: var(--red); border-color: var(--red); text-shadow: 0 0 8px rgba(255, 42, 42, .7); animation: shake .15s infinite; }
.scan { background: rgba(70, 255, 140, .15); color: var(--green); border: 2px solid var(--green); border-radius: 10px;
  padding: 14px; font-size: 18px; font-weight: bold; letter-spacing: 4px; font-family: inherit;
  box-shadow: 0 0 14px rgba(70, 255, 140, .35), inset 0 0 14px rgba(70, 255, 140, .2); }
.scan:disabled { opacity: .55; animation: pulse 1s infinite; }

.alert { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s;
  box-shadow: inset 0 0 0 4px var(--red), inset 0 0 90px rgba(255, 0, 0, .55); }
.alert.on { opacity: 1; animation: blink .25s steps(1) infinite; }

/* ---------- 進站 / 結果 ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 25, 10, .55), rgba(0, 0, 0, .92)); overflow-y: auto; }
.intro-box { max-width: 420px; width: 100%; text-align: center; }
.warn-tag { display: inline-block; color: var(--red); border: 1px solid var(--red); padding: 4px 12px; font-size: 13px;
  letter-spacing: 2px; animation: blink 1.2s steps(1) infinite; }
h1 { font-size: clamp(30px, 9vw, 44px); margin: 22px 0 8px; color: #e8fff0; letter-spacing: 2px; }
.sub { color: #9cb; margin: 0 0 24px; }
.tips { list-style: none; padding: 0; margin: 0 auto 28px; text-align: left; display: inline-block; color: #8a9; font-size: 14px; }
.tips li::before { content: "▸ "; color: var(--green); }
.tips li { margin: 6px 0; }
.start { display: block; width: 100%; background: #0c1f12; color: var(--green); border: 2px solid var(--green); border-radius: 12px;
  padding: 16px; font-size: 20px; font-weight: bold; letter-spacing: 6px;
  box-shadow: 0 0 22px rgba(70, 255, 140, .35); animation: pulse 2s infinite; }
.disclaimer { color: #566; font-size: 12px; margin-top: 18px; }

.glitch { position: relative; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; overflow: hidden; }
.glitch::before { color: #f22; transform: translate(-2px, 0); clip-path: inset(0 0 60% 0); animation: gl1 2.5s infinite steps(1); opacity: .7; }
.glitch::after { color: #2ff; transform: translate(2px, 0); clip-path: inset(55% 0 0 0); animation: gl2 3s infinite steps(1); opacity: .7; }

.card { width: 100%; max-width: 420px; background: #070c09; border: 1px solid #1c3324; border-radius: 14px; padding: 14px;
  box-shadow: 0 0 40px rgba(0, 0, 0, .8); margin: auto; }
.res-tag { color: var(--red); font-weight: bold; letter-spacing: 2px; text-align: center; margin-bottom: 10px; font-size: 15px; }
#resImg { display: block; width: 100%; max-height: 52vh; object-fit: contain; border-radius: 8px; border: 1px solid #1c3324; background: #000; }
.res-head { display: flex; gap: 8px; margin-top: 12px; }
.rarity, .cat { font-size: 12px; padding: 3px 10px; border-radius: 10px; border: 1px solid currentColor; }
.cat { color: #8a9; }
#resName { margin: 8px 0 4px; font-size: 26px; color: #f2fff6; }
.danger { color: #a99; font-size: 14px; }
#resDanger { color: var(--red); letter-spacing: 2px; }
.desc { color: #bcc; line-height: 1.7; font-size: 15px; margin: 10px 0 4px; }
.res-btns { display: flex; gap: 10px; margin-top: 14px; }
.res-btns button { flex: 1; padding: 13px; border-radius: 10px; font-size: 16px; font-weight: bold; }
.btn-save { background: var(--green); color: #031; }
.btn-again { background: transparent; color: var(--green); border: 1px solid var(--green) !important; }

.toast { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); background: rgba(0, 0, 0, .85); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 86vw; text-align: center; border: 1px solid #333; z-index: 9; }

@keyframes blink { 50% { opacity: .15; } }
@keyframes pulse { 50% { box-shadow: 0 0 6px rgba(70, 255, 140, .15); } }
@keyframes shake { 0% { transform: translate(1px, 0); } 50% { transform: translate(-1px, 1px); } 100% { transform: translate(0, -1px); } }
@keyframes gl1 { 0%, 88% { transform: translate(-2px, 0); } 90% { transform: translate(-6px, -2px); } 94% { transform: translate(4px, 1px); } }
@keyframes gl2 { 0%, 82% { transform: translate(2px, 0); } 85% { transform: translate(7px, 2px); } 90% { transform: translate(-4px, 0); } }

/* ---------- 正能量（神佛／精靈） ---------- */
.status.holy { color: #ffd56a; border-color: #ffd56a; text-shadow: 0 0 8px rgba(255, 213, 106, .7); }
.alert.holy { box-shadow: inset 0 0 0 3px #ffd56a, inset 0 0 120px rgba(255, 200, 90, .45); animation: glowpulse 1.2s ease-in-out infinite; }
.card.holy { border-color: #6b5520; box-shadow: 0 0 40px rgba(255, 200, 90, .22); }
#resDanger.holy { color: #ffd56a; }
.bless { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; line-height: 1.6; font-size: 15px;
  color: #ffe7a8; background: rgba(255, 200, 90, .08); border: 1px solid rgba(255, 213, 106, .35); }
@keyframes glowpulse { 50% { opacity: .55; } }

/* ---------- 時辰氣場 ---------- */
.aura-tag { position: absolute; top: calc(env(safe-area-inset-top) + 50px); left: 16px; font-size: 12px; padding: 3px 10px;
  border-radius: 10px; background: rgba(0, 0, 0, .45); border: 1px solid var(--green-dim); color: #bfe; }
.aura-tag.yin { color: #ff8a8a; border-color: rgba(255, 80, 80, .5); text-shadow: 0 0 6px rgba(255, 40, 40, .6); }
.aura-tag.yang { color: #ffd56a; border-color: rgba(255, 213, 106, .5); text-shadow: 0 0 6px rgba(255, 200, 80, .6); }
.intro-aura { margin: -12px 0 20px; font-size: 14px; color: #9cb; }
.intro-aura.yin { color: #ff7070; }
.intro-aura.yang { color: #ffd56a; }
.scan.out { opacity: .5; border-color: #577; color: #8aa; box-shadow: none; }

/* ---------- 神明指示 ---------- */
.btn-oracle, .btn-purify { display: block; width: 100%; margin-top: 14px; padding: 14px; border-radius: 10px; font-size: 17px; font-weight: bold; letter-spacing: 1px; }
.btn-oracle { background: linear-gradient(135deg, #5a3d07, #a27412); color: #fff3cf; box-shadow: 0 0 18px rgba(255, 200, 90, .35); }
.oracle { margin-top: 14px; padding: 16px; border-radius: 10px; text-align: center; background: radial-gradient(ellipse at top, rgba(255, 210, 110, .22), rgba(255, 200, 90, .05));
  border: 1px solid rgba(255, 213, 106, .5); animation: reveal .8s ease-out; }
.oracle-who { color: #ffd56a; font-weight: bold; letter-spacing: 2px; margin-bottom: 8px; }
.oracle-text { color: #fff6dc; font-size: 18px; line-height: 1.7; }
@keyframes reveal { from { opacity: 0; transform: scale(.92); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* ---------- 光域金字塔化解 ---------- */
.btn-purify { background: linear-gradient(135deg, #3b1a6b, #8c4bd6 55%, #e3b04b); color: #fff; box-shadow: 0 0 20px rgba(170, 110, 255, .45); }
.btn-purify:disabled { opacity: .6; box-shadow: none; }
.purify { position: fixed; inset: 0; z-index: 20; background: #05030a; display: flex; flex-direction: column; align-items: center; overflow-x: hidden; overflow-y: auto; }
/* 上方：影片 → 光域金字塔橫幅 → 再次淨化 */
.pmedia { position: relative; z-index: 2; flex: none; margin-top: calc(env(safe-area-inset-top) + 4vh); width: min(100vw, 560px);
  display: flex; flex-direction: column; align-items: center; gap: 12px; }
#pvid { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #000; border-radius: 10px;
  box-shadow: 0 0 40px rgba(170, 110, 255, .55), 0 0 90px rgba(255, 200, 90, .25); }
.pbanner { display: block; width: 100%; aspect-ratio: 3 / 1; object-fit: cover; border-radius: 10px; box-shadow: 0 0 30px rgba(255, 200, 90, .3);
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.pagain { padding: 10px 30px; border-radius: 24px; font-size: 16px; font-weight: bold; letter-spacing: 2px; color: #fff;
  background: linear-gradient(135deg, #3b1a6b, #8c4bd6 55%, #e3b04b); box-shadow: 0 0 20px rgba(170, 110, 255, .45); }
.pstage { position: relative; flex: none; margin-top: auto; width: 100%; max-width: 460px; padding: 18px 18px calc(env(safe-area-inset-bottom) + 22px); text-align: center;
  }
.pdone { background: none; }
.ptitle { color: #ffd56a; font-size: 18px; font-weight: bold; letter-spacing: 3px; text-shadow: 0 0 12px rgba(255, 200, 80, .7); }
.psub { color: #d9cfee; font-size: 14px; margin-top: 6px; }
.hz { font-size: 56px; font-weight: 800; color: #fff; margin-top: 6px; text-shadow: 0 0 22px rgba(190, 140, 255, .9); font-family: var(--mono); }
.hz small { font-size: 20px; margin-left: 4px; color: #cdb8ff; }
.hz.big { font-size: 64px; }
.hz small.pre { font-family: -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif; font-size: 20px; font-weight: bold; color: #ffd56a; letter-spacing: 2px; margin: 0 10px 0 0; vertical-align: middle; }
.hzname { color: #e8dcff; font-size: 16px; letter-spacing: 2px; }
.hzname.big { font-size: 26px; color: #ffd56a; font-weight: bold; letter-spacing: 6px; }
.hzbar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); margin: 14px 0; overflow: hidden; }
.hzbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2bd4c4, #4f6bff, #9b4dff, #e3b04b); box-shadow: 0 0 10px #9b4dff; }
.pskip { background: transparent; color: #a99cc4; border: 1px solid #5a4a7a !important; border-radius: 16px; padding: 6px 16px; font-size: 13px; }
.ptable { width: 100%; margin: 14px 0 6px; border-collapse: collapse; font-size: 15px; }
.ptable th { color: #b9a6e6; font-weight: normal; text-align: left; padding: 8px 6px; width: 30%; border-bottom: 1px solid #2d2445; }
.ptable td { color: #fff; text-align: left; padding: 8px 6px; border-bottom: 1px solid #2d2445; }
.pslogan { color: #e3c47a; font-size: 13px; margin: 12px 0 14px; letter-spacing: 1px; }
.pdone .btn-save { width: 100%; padding: 13px; border-radius: 10px; font-size: 16px; font-weight: bold; }
.play-tap { position: absolute; z-index: 2; top: 28vh; left: 50%; transform: translateX(-50%); padding: 14px 26px; border-radius: 30px;
  font-size: 17px; font-weight: bold; color: #fff; background: linear-gradient(135deg, #6a35c2, #e3b04b); box-shadow: 0 0 24px rgba(170, 110, 255, .6); }
/* 擋住影片本身：手機長按、電腦右鍵都點不到「儲存影片」 */
#pvid { pointer-events: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.vshield { position: absolute; inset: 0; z-index: 1; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.pstage { z-index: 2; }
.play-tap { z-index: 3; }

/* ---------- App 內建瀏覽器提醒 ---------- */
.inapp { margin: 0 0 18px; padding: 14px; border-radius: 10px; text-align: left; background: rgba(255, 180, 40, .1); border: 1px solid #c98a12; }
.inapp-title { color: #ffc24a; font-weight: bold; margin-bottom: 6px; }
.inapp-text { color: #f1e2c0; font-size: 14px; line-height: 1.7; }
.inapp-copy { margin-top: 10px; width: 100%; padding: 11px; border-radius: 8px; font-size: 16px; font-weight: bold; background: #ffc24a; color: #2a1a00; }
