/* 糯米探遊記（手機版）
   版面：手機一欄。首頁是整張青丘地圖；探遊時像翻開一頁繪本，上面是地方的畫，下面是糯米說的話。
   白天（05:00～19:00）是羊皮紙和墨色，夜裡換成紫夜和狐火的光：跟遊戲裡「夜裡才遇得到」的規則一起換。 */
:root {
  --paper: #f4ead6;
  --paper-2: #e9dbbd;
  --paper-3: #fbf5e8;
  --ink: #3a2b3c;
  --ink-soft: #6d5a6b;
  --line: rgba(58, 43, 60, .16);
  --fire: #ee8d5f;
  --fire-glow: #ffd8a6;
  --jade: #3f9e8c;
  --tassel: #c8463d;
  --gold: #c99632;
  --shade: rgba(40, 26, 44, .55);
  --app-bg: #2a1f30;
  --r-common: #d9cfbd;
  --r-uncommon: #63c2ab;
  --r-rare: #a58be8;
  --r-legend: #f2b84b;
  --f-story: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", serif;
  --f-ui: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --radius: 14px;
  --fog: rgba(240, 231, 214, .88);
  --fog-hi: rgba(255, 252, 244, .9);
  --near: rgba(224, 118, 70, .9);
  color-scheme: light;
}
#app[data-tod="night"] {
  --paper: #2d2238;
  --paper-2: #3b2d49;
  --paper-3: #362a43;
  --ink: #f4e7d4;
  --ink-soft: #c2afc6;
  --line: rgba(244, 231, 212, .16);
  --fire: #ffab73;
  --fire-glow: #ffcf8f;
  --jade: #8fe0d0;
  --tassel: #ec6c61;
  --gold: #f6c35b;
  --shade: rgba(10, 6, 16, .6);
  --fog: rgba(40, 28, 56, .88);
  --fog-hi: rgba(78, 60, 102, .9);
  --near: rgba(255, 192, 122, .9);
  color-scheme: dark;
}

html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--app-bg) radial-gradient(circle at 50% 0%, #3d2c47 0%, var(--app-bg) 70%);
  color: var(--ink);
  font-family: var(--f-ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
* { box-sizing: border-box; }
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; user-select: none; }

#app {
  position: relative;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  transition: background-color .6s, color .6s;
}

/* ---------- 頂部：狐火、銅錢、圖鑑 ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--paper-3);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.hud-fire, .hud-coins, .hud-dex {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 4px 6px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.hud-fire:active, .hud-coins:active, .hud-dex:active { background: var(--line); }
.hud-fire { flex: 1; min-width: 0; }
.hud-fire b, .hud-coins b, .hud-dex b { font-size: 16px; }
.hud-fire small { display: block; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.hud-sound {
  border: 0; background: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-soft);
}
.flame {
  display: inline-block; width: 22px; height: 28px; flex: none;
  background: radial-gradient(ellipse at 50% 72%, #fff 0 14%, var(--flame, #f4efe6) 34%, #f3a26f 60%, rgba(238, 141, 95, 0) 74%);
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  filter: drop-shadow(0 0 5px rgba(238, 141, 95, .55));
  animation: flicker 2.4s ease-in-out infinite;
}
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.06, .96) rotate(2deg); } }
.coin {
  width: 18px; height: 18px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe7a3, #d4a03c 60%, #a8781f);
  position: relative; box-shadow: inset 0 0 0 1.5px rgba(120, 80, 20, .5);
}
.coin::after {
  content: ""; position: absolute; inset: 6px; background: var(--paper-3);
  box-shadow: inset 0 0 0 1px rgba(120, 80, 20, .5);
}
.book-ico { width: 22px; height: 22px; flex: none; }

/* ---------- 分頁 ---------- */
.views { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; overflow: hidden; }
.view.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--paper-3);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 5;
}
.tabs button {
  border: 0; background: none; padding: 8px 0 10px; display: grid; justify-items: center; gap: 2px;
  font-size: 12px; color: var(--ink-soft); cursor: pointer;
}
.tabs button img { width: 34px; height: 34px; object-fit: contain; opacity: .55; transition: opacity .2s, transform .2s; }
.tabs button[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabs button[aria-current="page"] img { opacity: 1; transform: translateY(-2px); }
#app.in-trip .hud, #app.in-trip .tabs { display: none; }

/* ---------- 地圖 ---------- */
.map-viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; background: #d9c9a6; cursor: grab; }
.map-layer { position: absolute; left: 0; top: 0; width: 1536px; height: 1024px; transform-origin: 0 0; will-change: transform; }
.map-layer.glide { transition: transform .7s cubic-bezier(.3, .7, .3, 1); }
.map-img { position: absolute; inset: 0; width: 1536px; height: 1024px; max-width: none; transition: filter .8s; }
#app[data-tod="night"] .map-img { filter: brightness(.58) saturate(.8) hue-rotate(-14deg); }
.mist { position: absolute; inset: 0; width: 1536px; height: 1024px; pointer-events: none; }
.node {
  position: absolute; transform: translate(-50%, -50%);
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; padding: 0;
}
.node.open { box-shadow: 0 0 0 3px rgba(255, 216, 150, .0); animation: node-glow 2.8s ease-in-out infinite; }
@keyframes node-glow { 0%, 100% { box-shadow: 0 0 0 2px rgba(255, 210, 140, .35), 0 0 14px 2px rgba(255, 190, 110, .35); } 50% { box-shadow: 0 0 0 3px rgba(255, 220, 160, .7), 0 0 26px 6px rgba(255, 190, 110, .55); } }
.node.locked { background: rgba(50, 36, 56, .28); }
.node .count {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px);
  font: 700 15px/1 var(--f-ui); color: #fff; white-space: nowrap;
  background: rgba(58, 43, 60, .78); padding: 4px 8px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.node .count.full { background: linear-gradient(90deg, #c99632, #e9b955); color: #3a2b3c; }
.node .lock {
  position: absolute; right: -10px; top: -12px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(58, 43, 60, .85); display: grid; place-items: center;
}
.node .lock::before {
  content: ""; width: 10px; height: 8px; border-radius: 2px; background: #f4e7d4; margin-top: 5px;
  box-shadow: 0 -6px 0 -2px transparent;
}
.node .lock::after {
  content: ""; position: absolute; width: 8px; height: 8px; border: 2px solid #f4e7d4; border-bottom: 0;
  border-radius: 5px 5px 0 0; top: 5px;
}
.lantern-glow {
  position: absolute; width: 260px; height: 260px; transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(circle, rgba(255, 196, 120, .55), rgba(255, 160, 90, .12) 45%, transparent 70%);
  mix-blend-mode: screen; opacity: 0; transition: opacity .8s;
}
#app[data-tod="night"] .lantern-glow { opacity: 1; }
.map-nuomi {
  position: absolute; width: 92px; height: 92px; transform: translate(-50%, -100%);
  pointer-events: none; z-index: 3; filter: drop-shadow(0 6px 6px rgba(40, 26, 44, .35));
  transition-property: left, top; transition-timing-function: linear;
}
.map-nuomi img { width: 100%; height: 100%; }
.map-nuomi.face-right img { transform: scaleX(-1); }
.map-nuomi.walking img { animation: hop .32s ease-in-out infinite alternate; }
@keyframes hop { from { translate: 0 0; } to { translate: 0 -7px; } }
.map-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: var(--shade); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px;
  white-space: nowrap; pointer-events: none; z-index: 4;
}
.map-tools { position: absolute; right: 12px; top: 12px; display: grid; gap: 8px; z-index: 4; }
.map-tools button {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--paper-3); color: var(--ink); box-shadow: 0 2px 8px rgba(40, 26, 44, .3); font-size: 20px; font-weight: 700;
}
.tod-chip {
  position: absolute; left: 12px; top: 12px; z-index: 4; padding: 6px 12px; border-radius: 999px;
  background: var(--paper-3); font-size: 12px; box-shadow: 0 2px 8px rgba(40, 26, 44, .25); color: var(--ink-soft);
}

/* ---------- 底部面板、彈窗、提示 ---------- */
.sheet-back { position: absolute; inset: 0; background: var(--shade); z-index: 20; opacity: 0; transition: opacity .25s; }
.sheet-back.show { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 86%; overflow-y: auto;
  background: var(--paper-3); border-radius: 20px 20px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.3, .8, .3, 1);
  box-shadow: 0 -8px 30px rgba(20, 10, 30, .3);
}
.sheet.show { transform: none; }
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.modal {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
  background: var(--shade); opacity: 0; transition: opacity .25s;
}
.modal.show { opacity: 1; }
.modal-card {
  width: 100%; max-width: 380px; max-height: 100%; overflow-y: auto; background: var(--paper-3); border-radius: 20px;
  padding: 20px; text-align: center; box-shadow: 0 10px 40px rgba(20, 10, 30, .4);
  transform: scale(.92); transition: transform .3s cubic-bezier(.3, 1.4, .5, 1);
}
.modal.show .modal-card { transform: none; }
.modal-card .speaker { text-align: left; }
/* 登入：還沒用 /手機探遊 的連結登入時擋在最前面，關不掉 */
.modal.gate { z-index: 60; background: var(--paper); }
.modal.gate .modal-card { box-shadow: 0 6px 30px rgba(20, 10, 30, .18); display: grid; gap: 10px; justify-items: center; }
.modal.gate .guide { justify-self: stretch; }
.gate-note {
  margin: 0; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5;
  color: var(--tassel); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line);
}
/* 行囊的雲端存檔狀態 */
.cloud-status { flex: none; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-soft); white-space: nowrap; }
.cloud-status[data-s="saved"] { color: #2f8a7a; }
.cloud-status[data-s="offline"], .cloud-status[data-s="error"] { color: var(--tassel); }
.toast-wrap { position: absolute; left: 0; right: 0; top: 64px; display: grid; justify-items: center; gap: 6px; z-index: 40; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(20, 10, 30, .3); animation: toast 2.6s ease forwards; max-width: 90%; text-align: center;
}
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- 共用：按鈕、標題、進度 ---------- */
h2, h3 { font-family: var(--f-story); font-weight: 700; text-wrap: balance; margin: 0; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
.muted { color: var(--ink-soft); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 13px 16px; cursor: pointer; font-size: 16px; font-weight: 700;
  background: var(--ink); color: var(--paper-3); transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn.fire { background: linear-gradient(180deg, #f6a46e, #e07a4a); color: #3a1d14; box-shadow: 0 4px 0 #b65a33; }
.btn.fire:active { box-shadow: 0 1px 0 #b65a33; transform: translateY(3px); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn small { font-weight: 400; opacity: .8; font-size: 13px; }
:focus-visible { outline: 3px solid var(--fire); outline-offset: 2px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--fire), var(--gold)); border-radius: 4px; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: grid; gap: 12px; }

/* 地方卡 */
.place-head { display: flex; gap: 14px; align-items: center; }
.place-head img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; flex: none; }
.place-head .zone { font-size: 12px; color: var(--ink-soft); }
.place-desc { font-family: var(--f-story); font-size: 15px; line-height: 1.7; margin: 0; }
.label { font-size: 12px; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 6px; }
.routes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.routes.four { grid-template-columns: repeat(2, 1fr); }
.route {
  border: 0; border-radius: 12px; padding: 8px 4px 10px; cursor: pointer; display: grid; justify-items: center; gap: 2px;
  background: var(--paper-2); box-shadow: inset 0 0 0 1.5px transparent; font-size: 14px;
}
.route img { width: 46px; height: 46px; }
.route span { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.route[aria-pressed="true"] { box-shadow: inset 0 0 0 2.5px var(--fire); background: var(--paper-3); font-weight: 700; }
.route-desc { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; min-height: 1.4em; }
.sprites { display: flex; gap: 10px; }
.sprite-btn {
  flex: 1; border: 0; border-radius: 12px; background: var(--paper-2); padding: 6px 4px 8px; cursor: pointer;
  display: grid; justify-items: center; font-size: 12px; opacity: .55; transition: opacity .2s;
}
.sprite-btn img { width: 44px; height: 44px; }
.sprite-btn[aria-pressed="true"] { opacity: 1; box-shadow: inset 0 0 0 2px var(--jade); }
.note { font-size: 12px; color: var(--ink-soft); margin: 6px 0 0; line-height: 1.5; }
.locked-box { background: var(--paper-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.6; }

/* ---------- 探遊（繪本的一頁） ---------- */
.trip { display: flex; flex-direction: column; background: var(--paper); }
.trip-top {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--paper-3);
  border-bottom: 1px solid var(--line); min-height: 50px;
}
.trip-top .where { flex: 1; min-width: 0; font-family: var(--f-story); font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-top .where small { font-family: var(--f-ui); font-weight: 400; font-size: 12px; color: var(--ink-soft); margin-left: 6px; }
.trip-top .fire-mini { display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; font-weight: 700; }
.trip-top .fire-mini .flame { width: 16px; height: 20px; }
.icon-btn { border: 0; background: var(--paper-2); border-radius: 10px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.scene { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 46dvh; overflow: hidden; flex: none; background: #1e1626; touch-action: none; transition: max-height .45s ease; }
.scene.compact { max-height: 26dvh; }
.scene.compact .walker { width: 22%; }
.scene-img { position: absolute; inset: -4%; width: 108%; height: 108%; max-width: none; object-fit: cover; transition: filter .6s; }
.scene.night-tint .scene-img { filter: brightness(.55) saturate(.8) hue-rotate(-18deg); }
.scene.walking .scene-img { animation: pan 1.5s ease-in-out; }
@keyframes pan { from { transform: translateX(3%) scale(1.02); } to { transform: none; } }
.scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(30, 20, 36, .35));
}
.walker { position: absolute; left: 50%; bottom: 4%; width: 34%; max-width: 150px; transform: translateX(-50%); z-index: 3; pointer-events: none; filter: drop-shadow(0 8px 8px rgba(20, 10, 30, .4)); }
.walker img { width: 100%; display: block; }
.walker.in { animation: walk-in 1.5s ease-out; }
.walker.in img { animation: hop .3s ease-in-out infinite alternate; }
@keyframes walk-in { from { left: -20%; } to { left: 50%; } }
.walker.small { width: 24%; left: 82%; bottom: 3%; }
.buddies { position: absolute; left: 4%; top: 6%; display: flex; gap: 2px; z-index: 3; pointer-events: none; }
.buddies img { width: 46px; height: 46px; animation: bob 2.2s ease-in-out infinite; }
.buddies img:nth-child(2) { animation-delay: -.7s; }
.buddies img:nth-child(3) { animation-delay: -1.4s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.trail { display: flex; gap: 5px; padding: 6px 14px 0; flex-wrap: wrap; }
.trail i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.trail i.done { background: var(--fire); }
.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; align-content: start; gap: 10px; }
.speaker { display: flex; gap: 10px; align-items: flex-end; }
.speaker img { width: 60px; height: 60px; flex: none; }
.bubble {
  position: relative; flex: 1; min-width: 0; background: var(--paper-3); border-radius: 16px 16px 16px 4px; padding: 10px 14px;
  font-family: var(--f-story); font-size: 16px; line-height: 1.6; box-shadow: 0 1px 0 var(--line), inset 0 0 0 1px var(--line);
}
.bubble b { display: block; font-size: 12px; color: var(--tassel); font-family: var(--f-ui); margin-bottom: 2px; letter-spacing: .06em; }
.narr { font-family: var(--f-story); font-size: 16px; line-height: 1.75; margin: 0; }
.narr.result { color: var(--ink-soft); }
.choices { display: grid; gap: 8px; }
.choice {
  border: 0; border-radius: 14px; padding: 12px 14px; text-align: left; cursor: pointer; background: var(--paper-3);
  box-shadow: inset 0 0 0 1.5px var(--line); font-size: 15px; display: flex; align-items: center; gap: 10px;
}
.choice:active { transform: scale(.99); background: var(--paper-2); }
.choice .kind { margin-left: auto; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.choice .kind.care { color: var(--tassel); }
.choice .kind.tease { color: var(--jade); }
.loot { display: flex; flex-wrap: wrap; gap: 8px; }
.loot-item { width: 64px; display: grid; justify-items: center; gap: 2px; font-size: 11px; text-align: center; line-height: 1.25; }
.loot-item .new { color: var(--tassel); font-weight: 700; }
.dex-art {
  display: block; width: 100%; aspect-ratio: 1; background-repeat: no-repeat; border-radius: 12px;
  background-color: var(--paper-2);
}
.loot-item .dex-art { width: 56px; border: 2px solid var(--rc, var(--line)); }
.r0 { --rc: var(--r-common); } .r1 { --rc: var(--r-uncommon); } .r2 { --rc: var(--r-rare); } .r3 { --rc: var(--r-legend); }
.summary { background: var(--paper-3); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; box-shadow: inset 0 0 0 1px var(--line); }
.summary .stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.summary .unlock { font-size: 13px; color: var(--ink-soft); }
.route-switch { display: flex; gap: 6px; }
.route-switch button {
  flex: 1; border: 0; border-radius: 10px; padding: 6px 2px; background: var(--paper-2); font-size: 12px; cursor: pointer;
  display: grid; justify-items: center;
}
.route-switch button img { width: 30px; height: 30px; }
.route-switch button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--fire); background: var(--paper-3); font-weight: 700; }

/* ---------- 迷霧棋盤 ---------- */
.board-wrap {
  position: relative; flex: none; width: min(100%, calc(60dvh * 5 / 6)); aspect-ratio: 5 / 6; margin: 0 auto;
  overflow: hidden; background: #1e1626; touch-action: manipulation; user-select: none;
}
.board-wrap .scene-img { inset: 0; width: 100%; height: 100%; }
.board-wrap.night-tint .scene-img { filter: brightness(.55) saturate(.8) hue-rotate(-18deg); }
.board-wrap.cleared .scene-img { animation: cleared 1.4s ease-out; }
@keyframes cleared { 0% { filter: brightness(1.6) saturate(1.3); } 100% { filter: none; } }
.board {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(6, 1fr); transition: opacity .3s;
}
.board-wrap.gaming .board { opacity: 0; pointer-events: none; }
.cell {
  position: relative; border: 0; padding: 0; margin: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: inherit; min-width: 0; min-height: 0;
}
.cell::before { content: ""; position: absolute; inset: 0; pointer-events: none; transition: opacity .3s, transform .35s; }
.cell.fog::before, .cell.blk::before {
  inset: -4px; border-radius: 16px;
  background: radial-gradient(circle at 50% 45%, var(--fog-hi), var(--fog) 80%);
  box-shadow: 0 0 14px 6px var(--fog);
  animation: drift 7s ease-in-out infinite alternate; animation-delay: calc(var(--i, 0) * -.9s);
}
@keyframes drift { from { transform: translate(-1.5px, 1px) scale(1); } to { transform: translate(1.5px, -1px) scale(1.04); } }
.cell.fog.clearing::before { opacity: 0; transform: scale(1.35); animation: none; }
.cell.open { box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .22); }
.cell.near::after {
  content: ""; position: absolute; inset: 6px; border-radius: 10px; pointer-events: none;
  border: 2px dashed var(--near); animation: near 1.8s ease-in-out infinite;
}
@keyframes near { 50% { opacity: .4; } }
.cell.nope { animation: shake .35s; }
.cell:focus-visible { outline-offset: -4px; }
.glyph {
  position: relative; z-index: 1; font: 700 24px/1 var(--f-story); color: var(--hc, var(--ink-soft));
  text-shadow: 0 0 8px var(--fog-hi), 0 0 2px var(--fog-hi); animation: glyph-in .4s ease-out;
}
@keyframes glyph-in { from { opacity: 0; transform: scale(.4); } }
.h-item { --hc: #d6577f; }
.h-hoard { --hc: #c98a12; }
.h-coin { --hc: #b0801f; }
.h-stir { --hc: #3f7fb4; }
.h-trap { --hc: #c8463d; }
.h-clue { --hc: #8455c4; }
.h-empty { --hc: rgba(58, 43, 60, .4); }
#app[data-tod="night"] .h-item { --hc: #ff9cc0; }
#app[data-tod="night"] .h-hoard { --hc: #ffd060; }
#app[data-tod="night"] .h-coin { --hc: #f0c35c; }
#app[data-tod="night"] .h-stir { --hc: #8cc8ff; }
#app[data-tod="night"] .h-trap { --hc: #ff8a7e; }
#app[data-tod="night"] .h-clue { --hc: #c9a6ff; }
#app[data-tod="night"] .h-empty { --hc: rgba(244, 231, 212, .4); }
.cell.hinted.h-hoard .glyph, .cell.hinted.h-clue .glyph { animation: glyph-in .4s ease-out, shimmer 2.4s ease-in-out .4s infinite; }
@keyframes shimmer { 50% { text-shadow: 0 0 12px var(--hc), 0 0 2px var(--fog-hi); } }
/* 大石頭、樹叢：霧裡看得到影子，過不去 */
.cell.blk { cursor: default; }
.blk-shape {
  position: relative; z-index: 1; width: 62%; height: 50%; margin-top: 14%;
  border-radius: 48% 52% 42% 46% / 62% 58% 42% 38%;
  background: linear-gradient(160deg, #a2959f, #5c4e60); opacity: .62;
  box-shadow: inset -5px -7px 0 rgba(0, 0, 0, .16), 0 4px 0 rgba(0, 0, 0, .1);
}
.cell.bush .blk-shape {
  width: 68%; height: 60%; margin-top: 4%; border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 35% 30%, #98c290, #4f7d58 72%);
}
#app[data-tod="night"] .blk-shape { filter: brightness(.8); opacity: .7; }
/* 散了霧的格子上：撿到的東西 */
.cell .mini-art { width: 56%; border-radius: 10px; border: 2px solid var(--rc); background-color: rgba(255, 250, 240, .88); box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.cell .mini-icon { width: 56%; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
.cell .flame.mini { width: 26px; height: 32px; }
.mark {
  position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%); z-index: 1;
  display: flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1.3; white-space: nowrap;
  background: rgba(30, 20, 36, .72); color: #fff;
}
.mark.count { left: auto; right: 5%; transform: none; }
.mark.start { background: rgba(255, 250, 240, .85); color: #3a2b3c; }
.cell.here .mark.start { opacity: 0; }
.mark.ok, .mark.kind-tease { background: rgba(47, 138, 122, .92); }
.mark.bad, .mark.kind-care { background: rgba(196, 66, 58, .92); }
.mark.coin-mark { position: static; transform: none; font-size: 12px; }
.mark .coin { width: 14px; height: 14px; }
.mark .coin::after { inset: 4.5px; }
/* 糯米 */
.token {
  position: absolute; width: 20%; height: calc(100% / 6); z-index: 3; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: center;
  transition: left .17s linear, top .17s linear;
}
.token > img { width: 116%; max-width: none; margin-bottom: 2%; filter: drop-shadow(0 5px 4px rgba(20, 10, 30, .45)); }
.token.face-right > img { transform: scaleX(-1); }
.token.walking > img { animation: hop .17s ease-in-out infinite alternate; }
.token .buddies { position: absolute; left: -22%; top: -18%; gap: 0; }
.token .buddies img { width: 24px; height: 24px; }
.token.sniffing::after {
  content: ""; position: absolute; left: 50%; top: 55%; width: 100%; aspect-ratio: 1; border-radius: 50%;
  border: 3px solid var(--near); transform: translate(-50%, -50%) scale(.3); animation: sniff-wave .9s ease-out forwards;
}
@keyframes sniff-wave { to { transform: translate(-50%, -50%) scale(5); opacity: 0; } }
.board-wrap.gaming .token { left: 74% !important; top: 72% !important; width: 26%; height: 26%; transition: none; }
.float-num {
  position: absolute; z-index: 6; transform: translate(-50%, -50%); pointer-events: none;
  font: 700 19px/1 var(--f-ui); color: #ffe08a; text-shadow: 0 1px 3px rgba(0, 0, 0, .75);
  animation: float-up 1.1s ease-out forwards;
}
@keyframes float-up { to { transform: translate(-50%, -170%); opacity: 0; } }
.board-info {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 14px;
  font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line);
}
.board-info .clues { display: flex; align-items: center; gap: 2px; }
.board-info .clues i { width: 9px; height: 9px; margin-left: 5px; border-radius: 2px; transform: rotate(45deg); background: var(--line); }
.board-info .clues i.on { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.result { display: grid; gap: 6px; }
.got-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; font-weight: 700; }
.tools { display: flex; gap: 8px; }
.tools .btn { padding: 9px 10px; font-size: 14px; }
.tools .btn img { width: 26px; height: 26px; }
.hint-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; margin: 2px 0 8px 1.2em; }
.hint-legend b { font-family: var(--f-story); margin-right: 5px; font-size: 18px; color: var(--hc); }
.board-progress { display: flex; gap: 12px; align-items: center; background: var(--paper-2); border-radius: 12px; padding: 10px 12px; }
.board-progress img { width: 46px; height: 46px; flex: none; }

/* ---------- 小遊戲 ---------- */
.stage { position: absolute; inset: 0; z-index: 5; }
.stage-msg {
  position: absolute; left: 10px; right: 10px; top: 10px; text-align: center; color: #fff; font-size: 14px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6); pointer-events: none;
}
.timer { position: absolute; right: 10px; top: 40px; width: 42px; height: 42px; pointer-events: none; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5)); }
.timer circle { fill: none; stroke-width: 5; }
/* 過關：看準時機按一下 */
.track {
  position: absolute; left: 8%; right: 8%; bottom: 18%; height: 30px; border-radius: 15px;
  background: rgba(30, 20, 36, .55); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5);
}
.track .zone { position: absolute; top: 3px; bottom: 3px; border-radius: 12px; background: linear-gradient(90deg, #8fe0d0, #c3f2e6); box-shadow: 0 0 12px #8fe0d0; }
.track .mark { position: absolute; top: -12px; width: 8px; height: 54px; margin-left: -4px; border-radius: 4px; background: #fff; box-shadow: 0 0 10px #fff; }
.track.hit .zone { background: #ffe08a; box-shadow: 0 0 20px #ffd060; }
.track.miss { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
/* 尋寶：用手指聞聞看 */
.sniff-ring {
  position: absolute; width: 74px; height: 74px; margin: -37px 0 0 -37px; border-radius: 50%; pointer-events: none;
  border: 3px solid rgba(255, 255, 255, .85); box-shadow: 0 0 16px var(--warm, #fff), inset 0 0 14px var(--warm, #fff);
  transition: border-color .15s; opacity: 0;
}
.sniff-ring.on { opacity: 1; }
.spot { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 0; padding: 0; background: none; cursor: pointer; }
.spot::before {
  content: ""; position: absolute; inset: 18px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 20%, var(--rc) 45%, transparent 70%); opacity: 0; transform: scale(.4);
}
.spot.twinkle::before { animation: twinkle 1s ease-out; }
@keyframes twinkle { 0% { opacity: 0; transform: scale(.3); } 30% { opacity: .95; transform: scale(1.1) rotate(20deg); } 100% { opacity: 0; transform: scale(.5) rotate(45deg); } }
.spot.revealed::before { opacity: 1; transform: none; animation: beat .8s ease-in-out infinite; inset: 6px; }
@keyframes beat { 0%, 100% { transform: scale(.9); } 50% { transform: scale(1.12); } }
.spot.revealed::after {
  content: "點我"; position: absolute; left: 50%; top: 100%; transform: translate(-50%, -4px);
  font-size: 11px; color: #fff; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); white-space: nowrap;
}
.spot.got { pointer-events: none; animation: got .6s ease-in forwards; }
@keyframes got { to { transform: translateY(-60px) scale(.2); opacity: 0; } }
.pop-item {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 8; width: 150px; padding: 10px;
  background: var(--paper-3); border-radius: 16px; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  animation: pop-in .35s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none;
}
.pop-item .dex-art { width: 96px; margin: 0 auto 6px; border: 3px solid var(--rc); }
.pop-item b { display: block; font-family: var(--f-story); font-size: 16px; }
.pop-item small { color: var(--ink-soft); }
.pop-item .new { color: var(--tassel); font-weight: 700; font-size: 12px; }
@keyframes pop-in { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }
/* 捕野狐火 */
/* 場景壓暗一點，野狐火在亮的白天場景上也看得清楚 */
.wisp-stage { background: radial-gradient(ellipse at 50% 55%, rgba(24, 14, 36, .28), rgba(24, 14, 36, .55)); }
.wisp {
  position: absolute; width: 66px; height: 66px; margin: -33px 0 0 -33px; border: 0; padding: 0; background: none; cursor: pointer;
  display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
/* 外圈光暈（顏色跟著這團野狐火） */
.wisp::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--flame) 0 22%, transparent 68%); opacity: .7;
  animation: wisp-glow .9s ease-in-out infinite alternate;
}
@keyframes wisp-glow { to { transform: scale(1.22); opacity: 1; } }
/* <i> 預設是 inline，不設 display 寬高會是 0（之前就是這樣才看不到） */
.wisp .flame {
  position: relative; display: block; width: 36px; height: 46px; pointer-events: none;
  filter: drop-shadow(0 0 6px var(--flame)) drop-shadow(0 0 2px #fff);
}
.wisp.caught { animation: caught .4s ease-out forwards; pointer-events: none; }
@keyframes caught { to { transform: scale(1.8); opacity: 0; } }
.jar-count {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; background: rgba(30, 20, 36, .6);
  color: #fff; padding: 4px 10px 4px 4px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.jar-count img { width: 34px; height: 34px; }

/* ---------- 圖鑑 ---------- */
.dex-view { padding: 14px 16px 24px; display: grid; gap: 14px; align-content: start; }
.dex-head { display: flex; align-items: center; gap: 12px; }
.dex-head .flame { width: 28px; height: 36px; }
.dex-total { font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--paper-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 8px 4px; cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: var(--paper-3); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(40, 26, 44, .15); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--paper-2); cursor: pointer; font-size: 13px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper-3); }
.chip.dim { opacity: .5; }
.book {
  border-radius: 16px; padding: 14px; background: var(--paper-3) url("img/book.jpg") center / cover;
  box-shadow: inset 0 0 0 1px var(--line), 0 2px 10px rgba(40, 26, 44, .12);
}
#app[data-tod="night"] .book { background: var(--paper-3); }
.book-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; color: #3a2b3c; }
#app[data-tod="night"] .book-title { color: var(--ink); }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { border: 0; background: none; padding: 0; cursor: pointer; display: grid; gap: 3px; justify-items: center; font-size: 11px; line-height: 1.25; color: #3a2b3c; text-align: center; }
#app[data-tod="night"] .tile { color: var(--ink); }
.tile .dex-art { border: 2px solid var(--rc); background-color: rgba(255, 250, 240, .75); }
.tile.unknown .dex-art { filter: brightness(0) opacity(.22); border-color: transparent; }
.tile.unknown { color: rgba(58, 43, 60, .55); }
#app[data-tod="night"] .tile.unknown { color: var(--ink-soft); }
#app[data-tod="night"] .tile.unknown .dex-art { filter: brightness(0) invert(1) opacity(.18); }
.legend-card { display: flex; gap: 12px; align-items: center; border: 0; width: 100%; text-align: left; cursor: pointer; background: var(--paper-2); border-radius: 14px; padding: 10px; }
.legend-card img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; }
.legend-card.locked img { filter: grayscale(1) blur(2px) opacity(.5); }
.legend-art { width: 100%; border-radius: 14px; margin-bottom: 12px; }
.legend-text { font-family: var(--f-story); font-size: 16px; line-height: 1.85; text-align: left; margin: 10px 0; }
.big-art { width: 160px; margin: 0 auto 10px; border: 3px solid var(--rc); }
.stars { color: var(--rc); letter-spacing: 2px; }

/* ---------- 行囊 ---------- */
.bag-view { padding: 14px 16px 28px; display: grid; gap: 16px; align-content: start; }
.card { background: var(--paper-3); border-radius: 16px; padding: 14px; box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 10px; }
.nuomi-card { display: flex; gap: 12px; align-items: center; }
.nuomi-card img { width: 84px; height: 84px; flex: none; }
.aff-meter { position: relative; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #7ab9c9, var(--line) 40% 60%, #f19aa6); }
.aff-meter i { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { display: grid; justify-items: center; gap: 4px; font-size: 12px; text-align: center; }
.badge img { width: 72px; height: 72px; }
.badge.off img { filter: grayscale(1) opacity(.3); }
.ks-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ks { border: 0; background: var(--paper-2); border-radius: 12px; padding: 6px 2px; cursor: pointer; display: grid; justify-items: center; font-size: 10px; line-height: 1.2; text-align: center; }
.ks img { width: 48px; height: 48px; }
.ks.off img { filter: brightness(0) opacity(.2); }
.ks.off { color: var(--ink-soft); }
.stat-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
.stat-list dt { color: var(--ink-soft); }
.stat-list dd { margin: 0; font-weight: 700; text-align: right; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; }
.toggle { border: 0; border-radius: 999px; width: 50px; height: 30px; background: var(--line); position: relative; cursor: pointer; flex: none; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle[aria-pressed="true"] { background: var(--jade); }
.toggle[aria-pressed="true"]::after { left: 23px; }
.mini-seg { display: flex; gap: 4px; }
.mini-seg button { border: 0; border-radius: 8px; padding: 6px 12px; background: var(--paper-2); cursor: pointer; font-size: 14px; }
.mini-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper-3); }
textarea { width: 100%; min-height: 90px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 12px/1.4 ui-monospace, monospace; padding: 8px; }
.guide { font-size: 14px; line-height: 1.75; margin: 0; padding-left: 1.2em; }

/* 營地 */
.camp-title { font-family: var(--f-story); font-size: 20px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
