/* 基礎：版面骨架、按鈕、對話框、分頁列，以及願望／圖鑑頁 */
* { box-sizing: border-box; }
html { height: 100%; touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg-deep); color: var(--ivory);
  font-family: var(--font-body); font-size: 16px; line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--bio-cyan); outline-offset: 3px; }
/* 用手指點的時候不要畫焦點框（iPhone 關掉彈窗後會把焦點還給首頁小湘，畫出一個大框框，11/19 湘回報）；按 Tab 用鍵盤時照樣顯示 */
:root[data-input="pointer"] :is(button, [role="button"], [tabindex]):focus { outline: none; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 背景場景：用「最大視窗高度」固定，瀏覽器網址列收合時不會跟著縮放跳動 */
.scene {
  position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; z-index: -2; pointer-events: none;
  background: var(--bg-deep) url("../assets/scene/home-bg.webp") center / cover no-repeat;
  transition: filter 0.4s ease;
}
.scene::after { /* 四周壓暗、上下加深：把視線收到中央的蛋，並確保文字可讀 */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 46% at 50% 40%, transparent 35%, rgba(12, 8, 10, 0.62) 100%),
    linear-gradient(180deg, rgba(12, 8, 10, 0.7) 0%, transparent 15%),
    linear-gradient(0deg, rgba(12, 8, 10, 0.92) 0%, rgba(12, 8, 10, 0.5) 24%, transparent 40%);
}
body:not([data-view="home"]) .scene { filter: brightness(0.4); }

.app {
  max-width: 480px; margin: 0 auto;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 10px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}

.gem {
  display: inline-block; width: 8px; height: 8px; flex: none; transform: rotate(45deg);
  border: 1px solid var(--rose-light);
  background: linear-gradient(135deg, #ff8a9c, var(--crimson) 45%, var(--crimson-deep));
  box-shadow: 0 0 8px rgba(194, 31, 60, 0.8);
}

/* ---------- 資源列 ---------- */
.topbar { display: flex; align-items: center; gap: 8px; position: relative; z-index: 5; min-height: 36px; }
.chip {
  display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 4px; white-space: nowrap;
  border-radius: 99px; border: 1px solid rgba(210, 163, 145, 0.45);
  background: rgba(20, 13, 17, 0.72);
}
.chip__icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.chip__icon svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#chip-energy .chip__icon { background: radial-gradient(circle at 35% 30%, #ff8a9c, var(--crimson) 60%, var(--crimson-deep)); box-shadow: 0 0 8px rgba(194, 31, 60, 0.7); }
#chip-fossil .chip__icon { background: radial-gradient(circle at 35% 30%, #d9fff8, #5fb3a8 60%, #2c6a63); box-shadow: 0 0 8px rgba(131, 201, 193, 0.5); }
.chip__k { font-size: 11px; color: var(--silver); letter-spacing: 0.08em; }
.chip__v { font-family: var(--font-mono); font-size: 14px; color: var(--ivory); min-width: 2ch; text-align: right; }
.chip.is-bump { animation: bump 0.45s ease; }
@keyframes bump { 35% { transform: scale(1.14); border-color: var(--rose-light); } }
.topbar__brand { margin-left: auto; font-family: var(--font-latin); font-size: 10px; line-height: 1.25; letter-spacing: 0.26em; text-align: right; color: var(--rose-metal); }

/* ---------- 子頁標題 ---------- */
.header { text-align: center; margin-top: 12px; }
.header__title {
  margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: 0.14em; padding-left: 0.14em;
  background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rule { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; }
.rule::before { background: linear-gradient(90deg, transparent, var(--rose-metal)); }
.rule::after { background: linear-gradient(90deg, var(--rose-metal), transparent); }

/* ---------- 分頁內容與轉場 ---------- */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; padding: 12px 0 16px; animation: view-in 0.28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 按鈕 ---------- */
.btn {
  position: relative; min-height: 52px; width: 100%; padding: 0 20px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  border-radius: 99px; border: 1.5px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 45%) padding-box,
    linear-gradient(180deg, #8f2740, #4d0f1f) padding-box,
    var(--metal) border-box;
  box-shadow: 0 6px 22px rgba(109, 15, 34, 0.55);
  font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: 0.3em; padding-left: calc(20px + 0.3em);
  color: var(--ivory);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--quiet { width: auto; min-height: 44px; margin: 0 auto; background: none; border: 1px solid var(--line); box-shadow: none; font-family: var(--font-body); font-weight: 400; font-size: 13px; letter-spacing: 0; padding: 0 18px; color: var(--silver); }

/* ---------- 玻璃卡片 ---------- */
.card {
  border-radius: 18px; border: 1px solid rgba(210, 163, 145, 0.4);
  background: linear-gradient(180deg, rgba(40, 26, 33, 0.82), rgba(20, 13, 17, 0.88));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.fine { margin: 4px 0 0; text-align: center; font-size: 12px; color: var(--silver); line-height: 1.8; }

/* ---------- 圖鑑 ---------- */
.dex__count { margin: 0; text-align: center; font-family: var(--font-display); color: var(--rose-metal); letter-spacing: 0.2em; font-size: 14px; }
.dex__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.dex__card { position: relative; overflow: hidden; padding: 10px 8px 12px; text-align: center; }
.dex__img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.dex__img.is-locked { filter: brightness(0); opacity: 0.75; }
.dex__no { font-family: var(--font-mono); font-size: 11px; color: var(--rose-metal); letter-spacing: 0.14em; }
.dex__power { margin-top: 2px; font-size: 11px; font-weight: 700; color: var(--t-accent, var(--rose-metal)); }
.dex__name { font-family: var(--font-display); font-size: clamp(12px, 3.5vw, 14px); line-height: 1.35; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.dex__modes { display: flex; justify-content: center; gap: 0; margin: 10px auto 14px; border: 1px solid #ad96b14d; border-radius: 999px; width: max-content; padding: 3px; }
.dex__modes button { min-height: 36px; min-width: 72px; padding: 0 10px; border: 0; border-radius: 999px; background: none; color: var(--silver); font: 13px var(--font-display); letter-spacing: 0.06em; }
.dex__modes button[aria-pressed="true"] { background: #e9e2ee; color: #2a2333; }
.dex__section + .dex__section { margin-top: 22px; }
.dex__section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 10px; padding-bottom: 6px; border-bottom: 1px solid #ad96b13d; font: 400 15px var(--font-display); letter-spacing: 0.14em; color: var(--ivory); }
.dex__section-title small { font-family: var(--font-mono); font-size: 11px; color: var(--rose-metal); letter-spacing: 0.1em; }
.dex__tag { position: absolute; z-index: 2; top: 7px; left: 7px; padding: 2px 6px; border-radius: 999px; font: 10px var(--font-display); letter-spacing: 0.08em; line-height: 1.4; color: #2a2333; background: #d9d2e0; }
.dex__tag--weather { background: #bcd3ea; }
.dex__tag--recipe { background: #f0c7a4; }
.dex__tag--date { background: #f2b8c6; }
.dex__tag--memorial { background: #f1d98a; }
.dex__tag--county { background: #b9e0cf; }
.dex__tag--friends { background: #e8cdb0; }
.dex__tag--special { background: #f6b6d6; }
.dex__tag--hero { background: #e3c9a0; }
.dex__tag--animals { background: #f3d98b; }
.dex__tag--holiday { background: #f1a7a7; }

/* ---------- 底部分頁列 ---------- */
.nav {
  position: sticky; bottom: 0; z-index: 10; margin: 0 -16px;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: linear-gradient(180deg, rgba(16, 10, 13, 0.82), rgba(12, 8, 10, 0.97) 55%);
  border-top: 1px solid rgba(210, 163, 145, 0.3);
}
.nav__ink { /* 選中指示：一顆會滑動的光點 */
  position: absolute; top: -1px; left: 8px; width: calc((100% - 16px) / 5); height: 2px; pointer-events: none;
  transform: translateX(calc(var(--i, 0) * 100%)); transition: transform 0.32s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.nav__ink::after { content: ""; position: absolute; left: 30%; right: 30%; top: 0; height: 2px; border-radius: 2px; background: var(--rose-light); box-shadow: 0 0 10px 1px rgba(248, 220, 205, 0.8); }
.nav__item {
  position: relative; min-height: 50px; padding: 0; border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; line-height: 1; letter-spacing: 0.1em; padding-left: 0.1em; color: var(--silver);
  transition: color 0.2s ease;
}
.nav__item svg { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }
.nav__item[aria-current="page"] { color: var(--rose-light); }
.nav__item[aria-current="page"] svg { transform: translateY(-2px) scale(1.12); }
.nav__item:disabled { opacity: 0.32; cursor: default; }
.dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 99px; border: 1px solid var(--rose-light); background: var(--crimson); color: #fff;
  font-family: var(--font-mono); font-size: 10px; line-height: 1; letter-spacing: 0;
}
.nav__item .dot { top: 4px; right: calc(50% - 22px); }

/* ---------- 對話框 ---------- */
.sheet {
  width: min(88vw, 400px); padding: 28px 24px 24px; text-align: center; color: var(--ivory);
  border-radius: 24px; border: 1.5px solid transparent;
  background:
    radial-gradient(90% 50% at 50% 30%, rgba(246, 221, 230, 0.2), transparent 70%) padding-box,
    linear-gradient(180deg, #2a1d23, #171014) padding-box,
    var(--metal) border-box;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.sheet::backdrop { background: rgba(10, 6, 8, 0.82); }
.sheet[open] { animation: sheet-in 0.4s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
.sheet--letter { color: #3a1620; background: linear-gradient(180deg, #fbf3ec, #f1dfd6) padding-box, var(--metal) border-box; }
.sheet__seal { margin: 0 auto 14px; display: flex; align-items: center; gap: 12px; }
.sheet__seal::before, .sheet__seal::after { content: ""; flex: 1; height: 1px; background: #c9a093; }
.sheet__note { font-family: var(--font-display); text-align: left; white-space: pre-line; margin: 0 0 24px; line-height: 2.1; letter-spacing: 0.04em; }
.sheet__en { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.28em; color: var(--hud); margin-bottom: 4px; }
.sheet__img { width: 72%; aspect-ratio: 1; object-fit: contain; }
.sheet__no { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.3em; color: var(--rose-metal); }
.sheet__name { margin: 4px 0; font-family: var(--font-display); font-size: 26px; letter-spacing: 0.12em; background: var(--metal); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sheet__line { margin: 0 0 22px; color: var(--pearl); font-family: var(--font-display); }
.sheet__bonus { margin: -10px 0 20px; font-size: 13px; color: var(--hud); }
.photo__thumb { width: 150px; height: 150px; border-radius: 16px; border: 1.5px solid var(--rose-metal); margin: 6px auto 12px; display: block; }
.photo__meter { position: relative; height: 8px; margin: 0 8px 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); }
.photo__fill { height: 100%; width: 0; border-radius: 99px; }
.photo__mark { position: absolute; left: 25%; top: -4px; bottom: -4px; width: 2px; background: var(--ivory); }

.toast {
  position: fixed; z-index: 40; left: 50%; top: calc(var(--safe-top) + 54px); transform: translate(-50%, -12px);
  max-width: 86vw; padding: 10px 18px; border-radius: 99px; border: 1px solid var(--rose-metal);
  background: rgba(24, 16, 20, 0.95); color: var(--ivory); font-size: 14px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 374px) { .topbar__brand { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.dex__card { cursor: pointer; }
.dex-detail { text-align: center !important; }
.dex-detail__close { position: absolute; top: 12px; right: 12px; }
.dex-detail__img { display: block; width: min(56vw, 220px, 32svh); aspect-ratio: 1; margin: 4px auto 6px; object-fit: contain; }
.dex-detail__img.is-locked { filter: brightness(0); opacity: .8; }
.dex-detail__no { font: 11px var(--font-mono); color: var(--rose-metal); letter-spacing: .1em; }
.dex-detail h2 { margin: 4px 0 8px; font: 400 21px var(--font-display); letter-spacing: .08em; }
.dex-detail__line { margin: 0 0 10px; font: 14px/1.8 var(--font-display); color: var(--ivory); }
.dex-detail__intro { margin: 0 0 12px; padding: 16px 16px 14px; border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 16px; background: color-mix(in srgb, var(--accent) 7%, transparent); font-size: 13.5px; line-height: 1.9; letter-spacing: .03em; color: var(--pearl); text-align: justify; }
.dex-detail__intro:empty { display: none; }
.dex-detail__intro .para + .para { margin-top: .6em; }
.dex-detail__how { margin: 0 0 6px; padding: 8px 10px; border-radius: 8px; background: #ffffff0d; font-size: 12px; color: var(--silver); text-align: left; }
.dex-detail__at { font-size: 11px; color: var(--silver); }
.dex-detail__story { margin: 0 0 10px; padding: 10px 12px; border-left: 2px solid #c9a8ff; border-radius: 4px; background: #c9a8ff12; font: 13px/1.8 var(--font-display); color: var(--ivory); text-align: left; }
.dex-detail__story::before { content: '相遇的故事'; display: block; margin-bottom: 2px; font: 10px var(--font-mono); letter-spacing: .16em; color: var(--rose-metal); }

/* ---------- 圖鑑：切換世界（頁間居民 2.0，湘 11/25：跟著主題色，世界多了也放得下） ---------- */
.dex-realms { display: flex; justify-content: center; width: max-content; max-width: 100%; margin: 0 auto 10px; padding: 3px; border: 1px solid var(--t-line, #ad96b14d); border-radius: 999px; }
.dex-realms[hidden], .dex-worlds[hidden] { display: none; }
.dex-realm { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 96px; min-height: 40px; padding: 0 18px; line-height: 1; border: 0; border-radius: 999px; background: none; color: var(--silver); font: 14px var(--font-display); letter-spacing: 0.12em; }
.dex-realm small { font: 11px var(--font-mono); letter-spacing: 0.04em; color: inherit; }
.dex-realm[aria-selected="true"] { background: var(--t-light, #e9e2ee); color: var(--t-ink, #2a2333); }
.dex-realm[aria-selected="true"] small { color: inherit; }
.dex-worlds { display: flex; gap: 8px; margin: 0 -16px 10px; padding: 2px 16px 4px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.dex-worlds::-webkit-scrollbar { display: none; }
.dex-worlds:has(> :only-child) { justify-content: center; }
.dex-world { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; line-height: 1; min-height: 38px; padding: 0 14px 0 6px; border: 1px solid var(--t-line, #ad96b14d); border-radius: 999px; background: #ffffff0d; color: var(--silver); scroll-snap-align: start; }
.dex-world__seal { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; border: 1px solid currentColor; font: 700 13px var(--font-display); color: var(--t-accent, var(--rose-metal)); }
.dex-world b { font: 400 13px var(--font-display); letter-spacing: 0.08em; white-space: nowrap; }
.dex-world small { font: 11px var(--font-mono); color: inherit; }
.dex-world[aria-selected="true"] { border-color: var(--t-accent, var(--rose-metal)); background: var(--t-light, #e9e2ee); color: var(--t-ink, #2a2333); }
.dex__tag--mohen { background: var(--t-light, #e9e2ee); color: var(--t-ink, #2a2333); box-shadow: inset 0 0 0 1px var(--t-accent, var(--rose-metal)); }

/* 圖鑑：居民檔案／原典 */
.dex-origin { margin: 14px 0 4px; padding: 12px 14px 14px; border: 1px solid var(--t-line, #ad96b14d); border-radius: 14px; background: #ffffff0f; text-align: left; }
.dex-origin__eyebrow { display: block; margin-bottom: 8px; font: 10px var(--font-mono); letter-spacing: 0.22em; color: var(--t-accent, var(--rose-metal)); }
.dex-origin__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; }
.dex-origin__list div { min-width: 0; }
.dex-origin__list dt { font-size: 10px; letter-spacing: 0.14em; color: var(--rose-metal); }
.dex-origin__list dd { margin: 1px 0 0; font: 14px var(--font-display); color: var(--ivory); overflow-wrap: anywhere; }
.dex-origin__quote { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--t-line, #ad96b13d); font-size: 12px; font-style: italic; line-height: 1.8; color: var(--silver); }.dex-world[aria-selected="true"] .dex-world__seal, .dex-world[aria-selected="true"] small { color: inherit; }

.fine.copyright { margin-top: 0; font-size: 10.5px; opacity: .75; letter-spacing: .04em; }
