/* ============================================================
   七百萬分之一 · 樣式
   質感:安靜、紙墨、留白。
   ============================================================ */

:root {
  --bg: #f4f1ea;
  --bg2: #ece7db;
  --card: #fbf9f3;
  --ink: #2c2a25;
  --muted: #8b857a;
  --accent: #a63a2b;
  --accent-soft: rgba(166, 58, 43, 0.08);
  --line: #ddd5c4;
  --good: #4a7c59;
  --warn: #a04030;
  --shadow: 0 2px 24px rgba(60, 50, 30, 0.08);
  --seal: #b03a2e;
}
[data-theme="night"] {
  --bg: #141518;
  --bg2: #1a1c1f;
  --card: #1e2124;
  --ink: #d8d3c6;
  --muted: #7d7869;
  --accent: #d0705f;
  --accent-soft: rgba(208, 112, 95, 0.1);
  --line: #2c2f33;
  --good: #7fae8c;
  --warn: #c77b6b;
  --shadow: 0 2px 24px rgba(0, 0, 0, 0.4);
  --seal: #c05040;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: "Noto Serif TC", "Source Han Serif TC", "PMingLiu", "MingLiU HKSCS", "Microsoft JhengHei", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.9;
  letter-spacing: 0.02em;
  min-height: 100vh;
  touch-action: manipulation; /* 避免撳兩下放大 */
  transition: background 0.5s, color 0.5s;
}

#app { max-width: 760px; margin: 0 auto; padding: 24px 20px 80px; }

.hidden { display: none !important; }
.screen { animation: fadein 0.6s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 標題畫面 ---------- */
#scr-title { text-align: center; padding-top: 8vh; }
.brand { font-size: 44px; margin-bottom: 8px; animation: flicker 4s infinite; }
@keyframes flicker { 0%, 100% { opacity: 1; } 50% { opacity: 0.72; } }

#scr-title h1 {
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: 0.18em;
  margin-bottom: 6px;
}
#scr-title .sub { color: var(--muted); font-size: 15px; letter-spacing: 0.3em; margin-bottom: 22px; }
.menu-slogan {
  font-size: 19px; line-height: 1.75; letter-spacing: 0.06em;
  margin: 0 auto 32px; max-width: 480px; color: var(--ink);
}
.menu-slogan strong { font-weight: 900; }
.lede { font-size: 17px; margin: 0 auto 34px; max-width: 460px; }

.seal-btn {
  font-family: inherit;
  font-size: 22px;
  letter-spacing: 0.4em;
  padding: 14px 46px 14px 52px;
  color: #f6f1e6;
  background: var(--seal);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.seal-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(166, 58, 43, 0.35); }

.foot { margin-top: 52px; font-size: 13px; color: var(--muted); line-height: 2; }
.link {
  background: none; border: none; color: var(--accent);
  font-family: inherit; font-size: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 4px; padding: 0;
}
.link:hover { opacity: 0.75; }

/* ---------- 出生證明 ---------- */
#scr-birth { padding-top: 4vh; text-align: center; }
.cert {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  outline: 1px solid var(--line);
  outline-offset: 5px;
  padding: 30px 34px 38px;
  max-width: 520px;
  margin: 0 auto 26px;
  text-align: left;
  box-shadow: var(--shadow);
}
.cert-head { font-size: 24px; font-weight: 700; letter-spacing: 0.3em; text-align: center; }
.cert-head small { font-size: 12px; color: var(--muted); letter-spacing: 0.1em; font-weight: 400; }
.cert-no { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: 0.15em; margin: 6px 0 18px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.cert-rows { display: grid; gap: 7px; }
.crow { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; border-bottom: 1px dashed var(--line); padding-bottom: 5px; }
.crow .ck { color: var(--muted); flex-shrink: 0; }
.crow .cv { text-align: right; font-weight: 600; }
.crow.rv { opacity: 0; transform: translateY(4px); }
.crow.rv.on { animation: rowin 0.5s ease forwards; }
@keyframes rowin { to { opacity: 1; transform: none; } }
.cert .seal {
  position: absolute; right: 18px; bottom: 14px;
  width: 64px; height: 64px; border: 2.5px solid var(--seal);
  border-radius: 50%;
  color: var(--seal);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; letter-spacing: 0.1em;
  transform: rotate(-12deg); opacity: 0.55;
}

.namebox { margin: 6px auto 22px; max-width: 380px; font-size: 14px; }
.namebox label { display: block; color: var(--muted); margin-bottom: 6px; }
.namebox input {
  width: 100%; font-family: inherit; font-size: 17px; text-align: center;
  padding: 9px 12px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 3px;
}
.namebox input:focus { outline: none; border-color: var(--accent); }

.big-btn {
  font-family: inherit; font-size: 17px; letter-spacing: 0.25em;
  padding: 12px 40px 12px 44px;
  background: var(--accent); color: #f6f1e6;
  border: none; border-radius: 3px; cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.big-btn:hover { transform: translateY(-1px); opacity: 0.92; }
.big-btn.lit, .big-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
#scr-birth .link { display: block; margin: 14px auto 0; font-size: 14px; }

/* ---------- 人生畫面 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0 8px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.agebox { position: relative; min-width: 130px; }
#lv-age { font-size: 30px; font-weight: 900; margin-right: 8px; }
#lv-year { font-size: 14px; color: var(--muted); }
#lv-progress {
  position: absolute; left: 0; bottom: -9px; height: 2px; width: 0;
  background: var(--accent); opacity: 0.55; transition: width 0.12s linear;
}
.ctrl { display: flex; gap: 6px; flex-wrap: wrap; }
.cbtn {
  font-family: inherit; font-size: 13px; padding: 5px 10px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 3px; cursor: pointer;
  transition: border-color 0.15s;
}
.cbtn:hover { border-color: var(--accent); }
.cbtn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 26px; margin: 16px 0 6px; }
.stat { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.s-l { width: 3.2em; color: var(--muted); flex-shrink: 0; }
.s-bar { flex: 1; height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.s-bar i { display: block; height: 100%; width: 50%; border-radius: 4px; transition: width 0.6s ease; }
#b-health { background: var(--good); }
#b-happy { background: #c99a4b; }
#b-know { background: #5a7a9a; }
#b-social { background: #9a6f8e; }
.s-v { width: 2em; text-align: right; font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.chip {
  font-size: 12.5px; padding: 3px 10px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--line); line-height: 1.7;
}
.chip i { font-style: normal; color: var(--muted); margin-right: 6px; }

#log {
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
  padding: 18px 22px; max-height: 44vh; overflow-y: auto; box-shadow: var(--shadow);
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
#log .yr { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: 0.35em; margin: 14px 0 8px; }
#log .yr:first-child { margin-top: 0; }
#log .ev { font-size: 15px; margin-bottom: 7px; animation: fadein 0.7s ease; }
#log .ev.ms { color: var(--accent); font-weight: 600; padding-left: 10px; border-left: 2.5px solid var(--accent); }
#log .ev.heavy { color: var(--warn); }
#log .ev.surv { color: var(--muted); font-size: 13px; text-align: center; margin: 10px 0; }

/* 人生地圖 */
.mapwrap { margin: 20px 0 8px; }
.maplegend { font-size: 12px; color: var(--muted); letter-spacing: 0.15em; margin-bottom: 6px; }
#map { display: flex; flex-wrap: wrap; gap: 3px; }
#map i { width: 9px; height: 9px; background: var(--bg2); border-radius: 1px; }
[data-theme="night"] #map i { background: #3a3d42; }
#map i.on.st-baby { background: #d9b8a6; } #map i.on.st-kid { background: #d9c88f; }
#map i.on.st-child { background: #c9cf9a; } #map i.on.st-teen { background: #a8c2a0; }
#map i.on.st-youth { background: #9ab8ac; } #map i.on.st-adult { background: #8fa9b3; }
#map i.on.st-mid { background: #9a94b3; } #map i.on.st-old { background: #b398ab; }
#map i.on.st-elder { background: #b3a18f; }
#map i.m-hi { box-shadow: 0 0 0 1.5px var(--good) inset; }
#map i.m-lo { box-shadow: 0 0 0 1.5px var(--warn) inset; }

/* 同一秒出世的人 */
#npc { margin-top: 20px; }
#npc summary { cursor: pointer; font-size: 15px; font-weight: 600; letter-spacing: 0.1em; color: var(--ink); padding: 6px 0; }
#npc summary:hover { color: var(--accent); }
.npc { border-top: 1px dashed var(--line); padding: 10px 2px 4px; }
.npc-head { font-size: 14px; margin-bottom: 4px; }
.npc-head b { margin-right: 8px; }
.npc-head span { color: var(--muted); font-size: 12.5px; }
.npc-ln { font-size: 13.5px; color: var(--muted); margin: 3px 0; }
.npc-ln.new { color: var(--ink); animation: fadein 1s ease; }

/* ---------- 模態 ---------- */
#modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 18, 14, 0.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadein 0.3s ease;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
#modal-card {
  background: var(--card); border: 1px solid var(--line);
  max-width: 480px; width: 100%; padding: 30px 32px;
  border-radius: 4px; box-shadow: var(--shadow);
  margin: auto; /* 高過螢幕時仍可捲動,唔會截頂 */
  animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.m-kicker { font-size: 12px; color: var(--accent); letter-spacing: 0.3em; margin-bottom: 8px; }
.m-title { font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.m-desc { font-size: 15px; color: var(--ink); margin-bottom: 18px; }
.m-desc p { margin: 8px 0 0; }
.m-quote { font-size: 16.5px; line-height: 2.1; margin: 6px 0 22px; }
.opts { display: grid; gap: 8px; }
.opt {
  font-family: inherit; text-align: left; font-size: 15px;
  padding: 12px 16px; cursor: pointer;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 3px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.opt:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateX(3px); }
.opt em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.opt.solo { justify-content: center; background: var(--accent); color: #f6f1e6; border: none; letter-spacing: 0.2em; }
.reflect-opts { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.reflect-opts .opt.solo { letter-spacing: 0.14em; padding: 13px 10px; }
.reflect-opts .opt.share-now {
  justify-content: center; text-align: center; font-weight: 600;
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.reflect-opts .opt.share-now:hover { background: var(--accent); color: #f6f1e6; }

/* ---------- 死亡 / 追思 ---------- */
#scr-death { text-align: center; padding-top: 6vh; }
.deathmark { font-size: 40px; margin-bottom: 12px; animation: flicker 5s infinite; }
#d-title { font-size: 26px; font-weight: 700; margin-bottom: 14px; }
.epitaph { color: var(--muted); font-size: 16px; margin-bottom: 30px; }
.dsum { text-align: left; max-width: 480px; margin: 0 auto 24px; background: var(--card); border: 1px solid var(--line); padding: 18px 22px; border-radius: 4px; }
.kv { display: flex; justify-content: space-between; gap: 18px; font-size: 14px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.kv span { color: var(--muted); flex-shrink: 0; }
.kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.dms { text-align: left; max-width: 480px; margin: 0 auto 30px; }
.msline { font-size: 13.5px; color: var(--muted); padding: 3px 0; border-left: 2px solid var(--line); padding-left: 12px; margin-bottom: 4px; }
.d-actions { display: grid; gap: 12px; justify-items: center; }
.d-actions > div { display: flex; gap: 18px; align-items: center; }

#scr-hall { padding-top: 6vh; text-align: center; }
#scr-hall h2 { font-size: 26px; letter-spacing: 0.3em; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 14px; }
#hall-list { max-width: 520px; margin: 26px auto; text-align: left; display: grid; gap: 14px; }
.rec { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 14px 18px; display: flex; gap: 14px; align-items: flex-start; }
.rec-avatar { width: 52px; height: 52px; image-rendering: pixelated; border-radius: 6px; border: 1px solid var(--line); flex-shrink: 0; }
.rec-body { flex: 1; min-width: 0; }
.rec-head { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; flex-wrap: wrap; }
.rec-head span { color: var(--muted); font-size: 12.5px; }
.rec-ep { color: var(--muted); font-size: 13.5px; margin: 6px 0 10px; }
.candle {
  font-family: inherit; font-size: 13px; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 20px;
  color: var(--ink); padding: 4px 14px;
}
.candle:hover { border-color: var(--accent); }
.candle.lit { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
#btn-back { margin-top: 10px; font-size: 14px; }

/* ---------- 像素頭像 ---------- */
.cert-avatar-wrap { text-align: center; margin: 0 0 14px; }
#cert-avatar {
  width: 88px; height: 88px;
  image-rendering: pixelated;
  border-radius: 8px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
#scr-death #d-avatar {
  width: 96px; height: 96px;
  image-rendering: pixelated;
  border-radius: 8px; border: 1px solid var(--line);
  margin-bottom: 8px;
}
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
#lv-avatar {
  width: 46px; height: 46px;
  image-rendering: pixelated;
  border-radius: 6px; border: 1px solid var(--line);
  display: block; flex-shrink: 0;
}
.npc-avatar {
  width: 30px; height: 30px;
  image-rendering: pixelated;
  border-radius: 4px; border: 1px solid var(--line);
  vertical-align: -9px; margin-right: 8px;
}

/* ---------- 出世年份選擇 ---------- */
.yearpick { margin: 0 0 30px; font-size: 14px; color: var(--muted); }
.yearpick label { display: block; margin-bottom: 8px; letter-spacing: 0.25em; }
.yearpick select {
  font-family: inherit; font-size: 18px; padding: 9px 18px;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 3px; cursor: pointer;
}
.yearpick select:hover { border-color: var(--accent); }
.yearhint { display: block; margin-top: 8px; font-size: 12.5px; letter-spacing: 0.06em; }

.hkdata { max-width: 520px; margin: 28px auto 0; text-align: left; font-size: 13px; color: var(--muted); }
.hkdata summary { cursor: pointer; letter-spacing: 0.08em; color: var(--ink); font-weight: 600; }
.hkdata-inner { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); background: rgba(255,255,255,0.35); }
.hkdata-note { margin: 0 0 12px; line-height: 1.65; font-size: 12px; }
.hkdata-h { margin: 16px 0 8px; font-size: 12px; letter-spacing: 0.12em; font-weight: 600; color: var(--ink); }
.hkdata-grid, .hkdata-src { display: flex; flex-direction: column; gap: 6px; }
.drow { display: grid; grid-template-columns: 1fr 1.1fr; gap: 8px; line-height: 1.5; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.drow span { color: var(--muted); }
.drow b { font-weight: 600; color: var(--ink); font-size: 12.5px; }
.drow.src span { text-transform: capitalize; font-size: 11px; }
[data-theme="night"] .hkdata-inner { background: rgba(0,0,0,0.25); }

/* ---------- 年代大事 / 分享 ---------- */
#log .ev.era { color: var(--accent); padding-left: 10px; border-left: 2px dashed var(--accent); }
.share-img { width: 100%; max-width: 300px; display: block; margin: 4px auto 14px; border: 1px solid var(--line); border-radius: 6px; }
.share-cap { font-size: 13px; color: var(--muted); line-height: 1.8; border: 1px dashed var(--line); border-radius: 4px; padding: 10px 14px; margin-bottom: 14px; overflow-wrap: anywhere; }

/* 按鈕唔好俾人長按揀中文字(分享文字就照可揀) */
.cbtn, .opt, .big-btn, .seal-btn, .candle, .spd { -webkit-user-select: none; user-select: none; }
.link { -webkit-user-select: none; user-select: none; }

/* ---------- 響應式(手機) ---------- */
@media (max-width: 600px) {
  #app { padding: 16px 14px 64px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  #scr-title { padding-top: 4vh; }
  #scr-title h1 { letter-spacing: 0.12em; }
  .menu-slogan { font-size: 17px; margin-bottom: 26px; }
  .lede { font-size: 15.5px; }
  .foot { font-size: 12px; }
  .link { display: inline-block; padding: 6px 4px; }

  .cert { padding: 20px 16px 28px; }
  #cert-avatar { width: 76px; height: 76px; }
  .crow { font-size: 14px; }

  /* 頂欄:上下兩行,照樣黏住頂部 */
  .topbar { position: sticky; top: 0; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 0 6px; }
  .who { justify-content: space-between; min-width: 0; }
  #lv-age { font-size: 26px; }
  #lv-avatar { width: 40px; height: 40px; }
  .ctrl { gap: 5px; }
  .cbtn { font-size: 12.5px; padding: 9px 10px; min-height: 44px; line-height: 1.2; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 12px 0 4px; }
  .stat { font-size: 13px; gap: 7px; }
  .s-l { width: 2.8em; }
  .s-v { font-size: 12px; width: 1.8em; }

  .chips { gap: 5px; margin: 8px 0 12px; }
  .chip { font-size: 12px; padding: 3px 9px; }

  #log { padding: 14px 15px; max-height: 46vh; }
  #log .ev { font-size: 14.5px; margin-bottom: 6px; }
  .maplegend { font-size: 11px; }
  #map { gap: 3px; }
  #map i { width: 10px; height: 10px; }

  /* 模態:選項直排、字級收細 */
  #modal { padding: 12px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #modal-card { padding: 20px 18px; border-radius: 6px; }
  .m-title { font-size: 20px; }
  .m-desc { font-size: 14px; }
  .m-quote { font-size: 15.5px; }
  .opt { flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 14px; }
  .opt em { white-space: normal; font-size: 11.5px; }
  .opt.solo { padding: 13px; }
  .reflect-opts { grid-template-columns: 1fr 1fr; }
  .reflect-opts .opt { font-size: 14px; padding: 12px 8px; }

  .share-img { max-width: 235px; }
  .share-cap { font-size: 12px; padding: 8px 10px; }

  .d-actions > div { flex-direction: column; gap: 10px; }
  .candle { padding: 9px 18px; }
  .rec { padding: 12px 14px; gap: 10px; }
  .rec-avatar { width: 44px; height: 44px; }
  #hall-list { margin: 18px auto; gap: 10px; }
}
@media (max-height: 700px) and (max-width: 600px) {
  #scr-title { padding-top: 1.5vh; }
  .lede br + br { display: none; }
}
/* 橫向手機(矮視窗):日誌畫大啲,唔好得返一條 */
@media (max-height: 500px) {
  #log { max-height: 62vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 人生重播(分享連結) ---------- */
.replay-bar {
  font-size: 13.5px; line-height: 1.8; color: var(--muted);
  background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 4px;
  padding: 8px 14px; margin: 0 0 14px; text-align: center;
}
.replay-bar b { color: var(--accent); }
.opt.chosen {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft) inset;
}
.share-note { font-size: 13px; color: var(--muted); line-height: 1.8; margin-bottom: 12px; }

/* ============================================================
   v2:年代、挑戰、經濟、分享、成就
   ============================================================ */
.vs-banner {
  max-width: 520px; margin: 0 auto 22px; padding: 14px 18px; text-align: center;
  background: var(--accent-soft); border: 2px solid var(--accent); border-radius: 10px;
  font-size: 15px; line-height: 1.8;
}
.vs-banner b { color: var(--accent); }
.vs-banner span { font-weight: 700; }
.era-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 620px; margin: 0 auto 12px; }
.era {
  font-family: inherit; cursor: pointer; text-align: center; padding: 10px 6px; line-height: 1.4;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; gap: 3px; transition: border-color .15s, transform .15s;
}
.era b { font-size: 15px; }
.era small { font-size: 11px; color: var(--muted); letter-spacing: 0; }
.era:hover { border-color: var(--accent); transform: translateY(-1px); }
.era.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.cert-verdict { text-align: center; font-weight: 900; font-size: 19px; color: var(--accent); margin: -4px 0 12px; letter-spacing: .06em; }
.ghost-btn {
  font-family: inherit; font-size: 15px; letter-spacing: .08em; padding: 10px 22px; margin: 12px auto 0; display: block;
  background: transparent; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 30px; cursor: pointer;
}
.ghost-btn:hover { background: var(--accent-soft); }
.ghost-btn.lit { opacity: .6; }
.focusrow { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; flex-wrap: wrap; font-size: 13px; }
.focus-bar { display: flex; gap: 5px; flex-wrap: wrap; }
.focus-bar .cbtn { font-size: 12.5px; padding: 4px 9px; }
.econ-bar {
  display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted);
  padding: 7px 12px; margin: -8px 0 14px; border: 1px dashed var(--line); border-radius: 6px; background: var(--card);
}
.econ-bar b { color: var(--ink); font-weight: 600; }
#log .ev.pop { color: #7a5a9a; padding-left: 10px; border-left: 2px solid #b39ad0; }
[data-theme="night"] #log .ev.pop { color: #c3a9e0; }
#log .ev.econ { color: #4f6f8f; padding-left: 10px; border-left: 2px solid #8fa9c3; font-size: 14.5px; }
[data-theme="night"] #log .ev.econ { color: #9fbbd8; }
#map i.abroad { outline: 1px dashed var(--accent); outline-offset: -1px; }
.m-auto { font-size: 12.5px; color: var(--muted); margin-top: 12px; text-align: center; }
.rec-title { font-size: 13px; color: var(--accent); margin-top: 2px; }

.d-badges { max-width: 520px; margin: 0 auto 20px; }
.title-badge {
  display: inline-block; font-size: 22px; font-weight: 900; letter-spacing: .08em;
  padding: 8px 26px; border-radius: 40px; background: var(--accent); color: #f6f1e6; margin-bottom: 16px;
}
.bignums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.bignums div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 6px; display: flex; flex-direction: column; }
.bignums b { font-size: 30px; font-weight: 900; color: var(--accent); line-height: 1.2; }
.bignums span { font-size: 12px; color: var(--muted); line-height: 1.5; }
.achs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.ach { font-size: 13px; padding: 3px 12px; border-radius: 20px; background: var(--bg2); border: 1px solid var(--line); }
.vs-result { padding: 12px 14px; border-radius: 10px; font-weight: 700; font-size: 16px; }
.vs-result.win { background: rgba(74, 124, 89, .12); border: 1.5px solid var(--good); color: var(--good); }
.vs-result.lose { background: var(--accent-soft); border: 1.5px solid var(--accent); color: var(--accent); }
.vs-result small { font-weight: 400; color: var(--muted); }
.d-actions.top { margin-bottom: 24px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.segb { font-family: inherit; font-size: 13px; padding: 6px 12px; border-radius: 20px; cursor: pointer; background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.segb.on { background: var(--accent); color: #f6f1e6; border-color: var(--accent); }
.share-img.story { max-width: 230px; }
.social { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 12px; }
.sbtn { text-align: center; font-size: 12.5px; padding: 9px 4px; border-radius: 8px; color: #fff; text-decoration: none; font-weight: 600; }
.sbtn.wa { background: #25a35a; } .sbtn.th { background: #111; } .sbtn.fb { background: #1877f2; } .sbtn.x { background: #333; } .sbtn.tg { background: #2a9fd8; }
.sbtn:hover { opacity: .88; }
textarea.share-cap { width: 100%; font-family: inherit; resize: vertical; background: var(--bg); color: var(--ink); }

@media (max-width: 600px) {
  .era-grid { grid-template-columns: repeat(2, 1fr); }
  .bignums b { font-size: 24px; }
  .social { grid-template-columns: repeat(3, 1fr); }
  .title-badge { font-size: 18px; }
}

/* ============================================================
   v3:手機優先嘅人生畫面
   頂欄黏住(年歲 + 四項屬性 + 控制 + 分頁),日記最新一年擺最頂
   ============================================================ */
#scr-life .topbar {
  position: sticky; top: 0; z-index: 30; display: block;
  background: var(--bg); padding: 8px 0 0; border-bottom: 1px solid var(--line);
  margin: 0 -2px; box-shadow: 0 6px 12px -10px rgba(0,0,0,.25);
}
#scr-life .who { display: flex; align-items: center; gap: 10px; }
#scr-life .agebox { flex: 1; min-width: 0; position: relative; }
#scr-life #lv-age { font-size: 30px; font-weight: 900; margin-right: 2px; line-height: 1.1; }
#scr-life .sui { font-size: 14px; margin-right: 4px; }
#scr-life #lv-year { font-size: 14px; color: var(--muted); }
.lv-head { font-size: 13.5px; color: var(--accent); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; }
#scr-life #lv-progress { bottom: -4px; }
.share-mini { font-size: 18px !important; padding: 6px 10px !important; }
#scr-life .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 6px; }
#scr-life .stat { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 4px; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 7px 6px; }
#scr-life .s-l { width: auto; color: var(--muted); white-space: nowrap; overflow: hidden; }
#scr-life .s-v { width: auto; font-size: 16px; font-weight: 800; color: var(--ink); }
#scr-life .s-bar { grid-column: 1 / -1; height: 5px; margin-top: 3px; }
#scr-life .ctrl { display: flex; gap: 5px; margin-bottom: 6px; }
#scr-life .ctrl .cbtn { flex: 1; padding: 6px 4px; font-size: 13px; min-height: 36px; }
#scr-life .ctrl .skip { flex: 2.2; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; white-space: nowrap; font-family: inherit; font-size: 13.5px; padding: 8px 6px 9px; cursor: pointer;
  background: none; border: none; border-bottom: 3px solid transparent; color: var(--muted); position: relative;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab.dot::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.panel { padding-top: 12px; animation: fadein .25s ease; }
.panel-h { font-size: 13px; color: var(--muted); margin: 18px 0 8px; letter-spacing: .1em; font-weight: 600; }
.small-note { font-size: 12px; margin: 10px 0; line-height: 1.7; }
.logbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12.5px; }
.seg.small { margin: 0; }
.seg.small .segb { font-size: 12.5px; padding: 4px 11px; }

/* 日記:一年一張卡 */
#scr-life #log { background: none; border: none; box-shadow: none; padding: 0; max-height: none; overflow: visible; }
.yg { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 6px; margin-bottom: 10px; }
.yg h4 { font-size: 12.5px; color: var(--muted); letter-spacing: .2em; font-weight: 600; margin-bottom: 4px; }
.yg.cur { border-color: var(--accent); box-shadow: 0 2px 14px rgba(166, 58, 43, .12); }
.yg.cur h4 { color: var(--accent); }
.yg.cur h4::after { content: " · 今年"; letter-spacing: 0; }
.yg:not(.cur) { opacity: .82; }
#log .ev { font-size: 15.5px; line-height: 1.75; margin-bottom: 8px; }
#log .ev.ms { font-weight: 700; }
#log .ev.surv { font-size: 12.5px; text-align: left; margin: 4px 0 8px; }
#log.only-key .ev:not(.ms):not(.heavy) { display: none; }
#log.only-key .yg:not(:has(.ms, .heavy)) { display: none; }

/* 狀況 / 香港 */
.kvlist { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; }
.kvlist .kv { font-size: 14.5px; padding: 8px 0; }
.kvlist .kv:last-child { border-bottom: none; }
.econ-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tiles-h { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.tile span { font-size: 12px; color: var(--muted); }
.tile b { font-size: 21px; font-weight: 800; line-height: 1.35; }
.tile em { font-style: normal; font-size: 12px; font-weight: 700; }
.tile em.up { color: var(--good); } .tile em.down { color: var(--warn); }
.panel #map i { width: 12px; height: 12px; }

.to-latest {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(80px);
  z-index: 40; font-family: inherit; font-size: 14px; font-weight: 700; padding: 10px 20px; border-radius: 30px; border: none;
  background: var(--accent); color: #f6f1e6; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer; transition: transform .25s; 
}
.to-latest.show { transform: translateX(-50%) translateY(0); }

/* 出世紙:開始按鈕黏喺底 */
.birth-actions {
  position: sticky; bottom: 0; z-index: 20; background: linear-gradient(transparent, var(--bg) 22%);
  padding: 22px 0 calc(10px + env(safe-area-inset-bottom)); text-align: center;
}
.birth-actions .big-btn { width: 100%; max-width: 380px; font-size: 19px; padding: 14px; }
.birth-sub { margin-top: 8px; font-size: 14px; color: var(--muted); }
#scr-birth .birth-sub .link { display: inline; margin: 0; }
#scr-birth .cert-rows .crow { font-size: 14px; }

/* 離世畫面:摘要摺埋 */
.dsum-wrap { max-width: 520px; margin: 0 auto 14px; text-align: left; }
.dsum-wrap summary { cursor: pointer; font-weight: 700; padding: 8px 2px; color: var(--ink); }
.dsum-wrap .dsum, .dsum-wrap .dms { margin: 6px 0 0; }

@media (max-width: 600px) {
  #app { padding-top: 0; }
  #scr-life .stat { padding: 3px 6px 5px; }
  #scr-life .s-l { font-size: 11px; }
  .tab { font-size: 13px; padding: 8px 4px 9px; }
  #log .ev { font-size: 15px; }
  .cert { margin-bottom: 0; }
  #scr-title .lede br + br { display: none; }
  .bignums b { font-size: 22px; }
}

/* 決定入面嘅數字表 */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 2px; }
.facts div { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; }
.facts span { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.facts b { font-size: 16px; font-weight: 800; line-height: 1.4; }
@media (max-width: 600px) { #modal { align-items: flex-end; } #modal-card { border-radius: 14px 14px 6px 6px; } .opt { min-height: 48px; } }

/* 名人模式 */
.famous-toggle { margin: 4px auto 10px; }
.famous-grid { grid-template-columns: repeat(2, 1fr); }
.famous-grid .era b { font-size: 14px; }

/* 真人起點 */
.cert-real { background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; font-size: 13.5px; line-height: 1.75; }
.cert-real b { color: var(--accent); }
.cert-real p { margin: 4px 0 6px; }
.cert-real small { color: var(--muted); font-size: 11.5px; line-height: 1.6; display: block; }
.famous-sec { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); text-align: left; margin-top: 4px; letter-spacing: .1em; }

.fiction-note { font-size: 12.5px; line-height: 1.7; color: var(--accent); background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

/* 意見評分 */
.stars { display: flex; gap: 6px; justify-content: center; margin: 4px 0 12px; }
.stars button { font-size: 32px; background: none; border: none; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px; }
.stars button.on { color: #d9a400; }

/* 人生模式(正常 / 🎢 大起大落):標題喺上,說明喺下 */
.opt.mode-opt { flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; }
.opt.mode-opt span { font-size: 17px; font-weight: 700; }
.opt.mode-opt em { text-align: left; }

/* 🧭 人生行動、👀 睇狀態、▶ 繼續上次人生 */
.act-btn { display: block; width: 100%; margin: 8px 0 4px; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.act-btn.hidden { display: none; }
.peek-btn { display: block; margin: 10px auto 0; background: none; border: none; color: inherit; opacity: .7; font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
.peek-back { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 120; padding: 12px 18px; border-radius: 999px; border: none; background: var(--accent); color: #fff; font: inherit; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.25); cursor: pointer; max-width: calc(100% - 32px); }
.peek-back.hidden { display: none; }
.resume-bar { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--accent); text-align: center; }
.resume-bar button { margin: 0 4px; font-weight: 700; }

/* 💰 身家排名 */
.wealth-rank { margin: 10px 0; font-weight: 700; }
.wealth-rank small { font-weight: 400; }

/* 🐾 寵物模式 */
.pet-top { display: flex; gap: 14px; align-items: center; margin: 8px 0 12px; }
.pet-top img { width: 110px; height: 110px; object-fit: cover; border-radius: 16px; flex: none; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.pet-name { font-size: 20px; font-weight: 700; }
.pet-sub { font-size: 14px; opacity: .75; margin-top: 4px; }
.pet-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 10px; }
.pet-log { margin-top: 10px; }
.pet-ln { padding: 10px 12px; border-bottom: 1px solid rgba(0,0,0,.08); line-height: 1.6; }
.pet-ln small { display: block; opacity: .6; font-size: 12px; }
.pet-ln.ms { font-weight: 700; }
.pet-ln.heavy { color: var(--accent); font-weight: 700; }
.pet-end { text-align: center; padding: 14px; margin: 10px 0; border: 1.5px solid var(--accent); border-radius: 14px; }
.pet-end.hidden { display: none; }
.pet-end-img { width: 160px; height: 160px; object-fit: cover; border-radius: 50%; }
.pet-end-title { display: inline-block; margin: 6px 0; padding: 4px 12px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; }
.pet-ep { font-style: italic; }
.pet-end .kv { text-align: left; }
.pet-end-acts { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 12px; }
.pet-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.pet-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; border: 1px solid rgba(0,0,0,.12); border-radius: 12px; background: transparent; font: inherit; cursor: pointer; color: inherit; }
.pet-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 9px; }
.pet-card small { font-size: 11px; opacity: .7; line-height: 1.3; }
@media (max-width: 600px) { .pet-pick { grid-template-columns: repeat(2, 1fr); } .pet-top img { width: 90px; height: 90px; } }
.pet-note { font-size: 12px; text-align: center; }
.pet-stats .s-l { width: auto; white-space: nowrap; }
.pet-stats .s-bar i { background: var(--accent); }
.pet-card { cursor: default; transition: transform .12s, box-shadow .12s, opacity .12s; }
.pet-pick:has(.pet-card.on) .pet-card:not(.on) { opacity: .45; }
.pet-card.on { transform: scale(1.06); box-shadow: 0 0 0 3px var(--accent); opacity: 1; }

/* 📖 逐句出 + 決定框狀態列 */
#log p.ev.pending { display: none; }
#log p.ev.reveal { animation: lineIn .45s ease; }
@keyframes lineIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.m-status { margin: 4px 0 10px; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.05); font-size: 13px; font-weight: 700; line-height: 1.5; }
