:root {
  --ink: #3a3340;
  --ink-soft: #6b6272;
  --paper: #fffcf6;
  --gold: #c9a55a;
  --nun: #2b2630;
  --fox: #7a63ad;
  --scene-bg: #e7ded1;
  --font: "jf-openhuninn-2.0", "jf open 粉圓 2.0", "Huninn", "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}
/* 日文：用日文字形（直、骨、今……和繁中寫法不同） */
html:lang(ja) {
  --font: "Zen Maru Gothic", "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Meiryo", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--scene-bg);
  font-family: var(--font);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; }
#view, #view canvas { position: fixed; inset: 0; display: block; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse 75% 70% at 50% 46%, transparent 55%, rgba(70, 52, 36, 0.24) 100%);
}

/* ------------------------------------------------------------ 3D 位置標籤 */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.wlabel, .emote { position: absolute; left: 0; top: 0; will-change: transform; }
.wlabel > span {
  display: inline-flex; align-items: center; gap: 6px;
  transform: translate(-50%, -100%);
  margin-top: -6px;
  white-space: nowrap;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 16px; font-weight: 700;
  background: rgba(255, 252, 246, 0.94);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(40, 28, 20, 0.18);
}
.wlabel.exit > span { background: rgba(43, 38, 48, 0.78); color: #fff; font-size: 15px; padding: 4px 13px 4px 10px; transform: translate(-50%, 45%); margin-top: 0; }
.wlabel.exit i { font-style: normal; color: var(--gold); }
.wlabel.hover > span { margin-top: -30px; animation: pop-in .18s ease-out; }
.wlabel.prompt > span {
  margin-top: -34px;
  background: var(--nun); color: #fff; font-size: 15px; padding: 5px 14px 5px 6px;
  animation: pop-in .2s ease-out;
}
.wlabel kbd {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 6px;
  background: var(--gold); color: var(--nun);
  font: 800 13px/1 var(--font);
  box-shadow: 0 2px 0 #8e7337;
}

.emote .bubble {
  transform: translate(-50%, -100%) translateY(-14px);
  width: 56px; height: 50px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--nun);
  font: 900 30px/1 var(--font);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  animation: emote-pop .38s cubic-bezier(.2, 1.7, .4, 1);
  position: relative;
}
.emote .bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -10px; width: 12px; height: 12px;
  background: #fff; border-right: 3px solid var(--nun); border-bottom: 3px solid var(--nun);
  transform: translateX(-50%) rotate(45deg);
}
.emote .bubble span { position: relative; z-index: 1; }
.emote .bubble.out { animation: emote-out .25s ease-in forwards; }
.emote .ex { color: #e5484d; }
.emote .q { color: #3a7bd5; }
.emote .note { color: #e0609e; }
.emote .dots { color: #777; font-size: 22px; }
.emote .heart { color: #e5487a; font-size: 22px; }
.emote .anger { color: #e5484d; background: #fff1f1; font-size: 20px; }
.emote .sweat { color: #3a9bd5; font-size: 20px; }
.emote .zzz { color: var(--fox); font-size: 16px; letter-spacing: 1px; }
.emote .spark { color: #d9a63a; }
@keyframes emote-pop { from { transform: translate(-50%, -100%) translateY(-6px) scale(0.2); } }
@keyframes emote-out { to { transform: translate(-50%, -100%) translateY(-26px) scale(0.6); opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -80%) scale(0.85); } }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#scene-title {
  position: absolute; top: 20px; left: 24px;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px 9px 10px;
  background: rgba(255, 252, 246, 0.92);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(40, 28, 20, 0.16);
  opacity: 0;
}
#scene-title.show { animation: title-in .7s cubic-bezier(.2, 1.2, .4, 1) forwards; }
#scene-title .st-no {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--nun); color: var(--gold);
  font-weight: 800; font-size: 17px; letter-spacing: .04em;
}
#scene-title .st-name { font-size: 28px; font-weight: 800; letter-spacing: .14em; line-height: 1.15; }
#scene-title .st-en { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-soft); }
@keyframes title-in { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

#party { position: absolute; top: 20px; right: 24px; display: flex; gap: 10px; pointer-events: auto; }
.party-card {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 16px 5px 5px;
  background: rgba(255, 252, 246, 0.92);
  border: 2px solid transparent;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(40, 28, 20, 0.14);
  color: var(--ink);
  text-align: left;
  transition: transform .15s, border-color .2s;
}
.party-card.player { border-color: var(--gold); }
button.party-card { cursor: pointer; }
button.party-card:hover { transform: translateY(-2px); }
.party-card.following { border-color: var(--fox); }
.party-card .face { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; background: #efe8dc; flex: none; }
.party-card .face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; transform: scale(2.3); transform-origin: 50% 40%; }
.party-card .info { display: flex; flex-direction: column; line-height: 1.2; }
.party-card .info span { font-weight: 800; font-size: 17px; letter-spacing: .08em; }
.party-card .info em { font-style: normal; font-size: 13px; color: var(--ink-soft); }
.party-card.following .info em { color: var(--fox); font-weight: 700; }

#round-btns { position: absolute; left: 24px; bottom: 24px; display: flex; gap: 14px; pointer-events: auto; }
#round-btns button {
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: #1f1d22;
  display: grid; place-items: center;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform .15s;
}
#round-btns button:hover { transform: translateY(-2px) scale(1.05); }
#round-btns svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

#toast {
  position: absolute; top: 88px; left: 50%;
  transform: translate(-50%, -8px);
  max-width: min(760px, 90vw);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(43, 38, 48, 0.88);
  color: #fff; font-size: 17px; text-align: center;
  opacity: 0; transition: opacity .3s, transform .3s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ 任務追蹤 / 通知 */
#quest-track {
  position: absolute; top: 96px; left: 24px;
  display: flex; flex-direction: column; gap: 6px;
  max-width: min(460px, 60vw);
  pointer-events: auto; cursor: pointer;
  transition: opacity .3s;
}
#quest-track.empty { display: none; }
#quest-track.dim { opacity: 0; pointer-events: none; }
#quest-track.pulse .qt-row { animation: qt-pulse .8s ease-out; }
.qt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 18px 7px 8px;
  background: rgba(255, 252, 246, 0.92);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(40, 28, 20, 0.14);
  width: fit-content;
  transition: transform .15s;
}
#quest-track:hover .qt-row { transform: translateX(3px); }
.qt-tag {
  flex: none; padding: 3px 11px; border-radius: 999px;
  font-size: 14px; font-weight: 800; letter-spacing: .1em;
  background: var(--nun); color: var(--gold);
}
.qt-row.side .qt-tag { background: #e9e0f5; color: var(--fox); }
.qt-text { font-size: 19px; font-weight: 700; letter-spacing: .05em; }
.qt-row.side .qt-text { font-size: 17px; font-weight: 600; color: var(--ink-soft); }
@keyframes qt-pulse { 0% { transform: scale(1); } 30% { transform: scale(1.07); box-shadow: 0 0 0 4px var(--gold); } 100% { transform: scale(1); } }

#notices {
  position: fixed; top: 96px; right: 24px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  z-index: 25; pointer-events: none;
}
.notice {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 22px 9px 9px;
  background: rgba(43, 38, 48, 0.92); color: #fff;
  border: 2px solid var(--gold);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  animation: notice-in .4s cubic-bezier(.2, 1.4, .4, 1);
  transition: opacity .4s, transform .4s;
}
.notice.out { opacity: 0; transform: translateX(30px); }
.notice .n-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: #fffaf0; font-size: 26px; color: var(--nun);
}
.notice.done .n-icon { background: var(--gold); color: var(--nun); font-size: 24px; font-weight: 900; }
.notice.quest { border-color: #b9a4e0; }
.notice .n-head { font-size: 15px; letter-spacing: .14em; color: var(--gold); font-weight: 700; }
.notice.quest .n-head { color: #cdbcf0; }
.notice .n-text { font-size: 20px; font-weight: 800; letter-spacing: .06em; }
@keyframes notice-in { from { opacity: 0; transform: translateX(40px) scale(.9); } }

/* ------------------------------------------------------------ 對話（視覺小說） */
#vn { position: fixed; inset: 0; z-index: 20; }
#vn.hidden { display: none; }

.vn-portrait {
  position: absolute; bottom: 0;
  height: min(78vh, 920px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease, transform .4s cubic-bezier(.2, 1, .3, 1), filter .35s ease;
  filter: drop-shadow(0 10px 20px rgba(30, 20, 30, 0.28));
  z-index: 1;
}
.vn-portrait { display: grid; grid-template-rows: 100%; }
.vn-portrait img { grid-area: 1 / 1; height: 100%; width: auto; display: block; transform-origin: 50% 100%; animation: breathe 3.4s ease-in-out infinite; opacity: 0; }
/* 換表情：新的一張疊在上面淡入，舊的等淡入完再收掉（避免半透明交疊時變淡） */
.vn-portrait img.on { opacity: 1; }
.vn-portrait img.top { z-index: 1; transition: opacity .14s ease-out; }
.vn-portrait.left { left: 1vw; transform: translateX(-60px); }
.vn-portrait.right { right: 1vw; transform: translateX(60px); }
.vn-portrait.shown { opacity: 1; transform: none; }
.vn-portrait.listening { filter: brightness(0.62) saturate(0.8) drop-shadow(0 10px 20px rgba(30, 20, 30, 0.2)); }
.vn-portrait.left.listening { transform: translateX(-16px) scale(0.955); transform-origin: 50% 100%; }
.vn-portrait.right.listening { transform: translateX(16px) scale(0.955); transform-origin: 50% 100%; }
.vn-portrait.talking { z-index: 2; }
@keyframes breathe { 0%, 100% { scale: 1 1; } 50% { scale: 1.005 1.013; } }

.vn-portrait.react-startle img { animation: r-startle .6s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-jump img { animation: r-jump .7s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-hop img { animation: r-hop .4s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-happy img { animation: r-happy .7s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-shake img { animation: r-shake .5s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-tremble img { animation: r-tremble .9s linear, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-nod img { animation: r-nod .55s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-sad img { animation: r-sad .9s ease-out, breathe 3.4s ease-in-out infinite; }
.vn-portrait.react-spin img { animation: r-spin .6s ease-in-out, breathe 3.4s ease-in-out infinite; }
@keyframes r-startle { 0% { translate: 0 0; } 22% { translate: 0 -48px; } 50% { translate: 0 0; } 66% { translate: 0 -12px; } 100% { translate: 0 0; } }
@keyframes r-jump { 0% { translate: 0 0; } 30% { translate: 0 -70px; } 60% { translate: 0 0; } 75% { translate: 0 -10px; } 100% { translate: 0 0; } }
@keyframes r-hop { 0%, 100% { translate: 0 0; } 40% { translate: 0 -26px; } }
@keyframes r-happy { 0%, 50%, 100% { translate: 0 0; } 22%, 72% { translate: 0 -26px; } }
@keyframes r-shake { 0%, 100% { translate: 0 0; } 20% { translate: -14px 0; } 40% { translate: 12px 0; } 60% { translate: -8px 0; } 80% { translate: 5px 0; } }
@keyframes r-tremble { 0%, 100% { translate: 0 0; } 10%, 30%, 50%, 70%, 90% { translate: -4px 0; } 20%, 40%, 60%, 80% { translate: 4px 0; } }
@keyframes r-nod { 0%, 100% { translate: 0 0; } 25%, 75% { translate: 0 12px; } 50% { translate: 0 0; } }
@keyframes r-sad { 0% { translate: 0 0; } 40%, 80% { translate: 0 22px; } 100% { translate: 0 0; } }
@keyframes r-spin { to { rotate: y 360deg; } }

.vn-box {
  position: absolute; left: 50%; bottom: 3vh;
  transform: translateX(-50%);
  width: min(1160px, 92vw);
  height: clamp(172px, 26vh, 250px);
  padding: 36px 54px 18px;
  background: linear-gradient(180deg, rgba(255, 254, 250, 0.97), rgba(252, 247, 239, 0.95));
  border: 2px solid var(--na, var(--gold));
  border-radius: 20px;
  box-shadow: 0 14px 36px rgba(40, 28, 20, 0.3), inset 0 0 0 6px rgba(255, 255, 255, 0.75), inset 0 0 0 7px rgba(201, 165, 90, 0.35);
  z-index: 3;
  transition: opacity .25s, transform .3s cubic-bezier(.2, 1, .3, 1);
}
.vn-box.empty { opacity: 0; transform: translateX(-50%) translateY(24px); pointer-events: none; }
.vn-name {
  position: absolute; top: -26px; left: 38px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 28px 8px 16px;
  background: var(--nc, var(--nun));
  border: 2px solid var(--na, var(--gold));
  border-radius: 14px 14px 14px 4px;
  color: #fff; font-size: 24px; font-weight: 800; letter-spacing: .14em;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.22);
}
.vn-name-mark { color: var(--na, var(--gold)); font-size: 18px; }
.vn-box.narration .vn-name { display: none; }
.vn-box.narration .vn-text { color: var(--ink-soft); }
.vn-text { font-size: clamp(21px, 1.95vw, 31px); line-height: 1.7; letter-spacing: .05em; color: var(--ink); }
.vn-text .rest { opacity: 0; }
/* 日中對照：日文下面的中文（打完字才出現） */
.vn-sub { font-size: clamp(17px, 1.5vw, 24px); line-height: 1.45; margin-top: 2px; color: var(--ink-soft); font-family: "jf-openhuninn-2.0", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif; letter-spacing: .04em; }
.vn-sub:empty { display: none; }
.vn-choice small.sub, .log-line small.sub { display: block; font-size: .72em; opacity: .7; font-family: "jf-openhuninn-2.0", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif; }
.vn-next { position: absolute; right: 30px; bottom: 14px; color: var(--na, var(--gold)); font-size: 18px; opacity: 0; }
.vn-next.show { opacity: 1; animation: bob .9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(5px); } }
.vn-tools { position: absolute; right: 22px; top: -34px; display: flex; gap: 6px; }
.vn-tools button {
  border: none; cursor: pointer;
  padding: 5px 13px; border-radius: 999px;
  background: rgba(43, 38, 48, 0.72); color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .12em;
}
.vn-tools button:hover { background: rgba(43, 38, 48, 0.9); }
.vn-tools button.on { background: var(--gold); color: var(--nun); }

.vn-choices {
  position: absolute; left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; gap: 14px;
  min-width: min(620px, 88vw);
  z-index: 4;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.vn-choices.show { opacity: 1; pointer-events: auto; }
.vn-choice {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 32px 15px 16px;
  background: rgba(255, 252, 246, 0.96);
  border: 2px solid var(--gold);
  border-radius: 999px;
  color: var(--ink); font-size: 24px; letter-spacing: .06em; text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(40, 28, 20, 0.22);
  transition: transform .15s, background .15s, color .15s;
  animation: choice-in .3s ease-out backwards;
}
.vn-choice:nth-child(2) { animation-delay: .05s; }
.vn-choice:nth-child(3) { animation-delay: .1s; }
.vn-choice .num {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--nun); color: #fff; font-size: 16px; font-weight: 800;
}
.vn-choice.sel { background: var(--nun); color: #fff; transform: scale(1.03); }
.vn-choice.sel .num { background: var(--gold); color: var(--nun); }
@keyframes choice-in { from { opacity: 0; transform: translateY(10px); } }
#vn.ui-hidden .vn-box, #vn.ui-hidden .vn-portrait, #vn.ui-hidden .vn-choices { opacity: 0 !important; }

/* ------------------------------------------------------------ 對話紀錄 */
#log {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(24, 18, 28, 0.66);
  backdrop-filter: blur(4px);
}
#log.hidden { display: none; }
.log-inner {
  width: min(820px, 92vw); max-height: 76vh; overflow: auto;
  background: var(--paper); border-radius: 18px; padding: 22px 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  user-select: text;
}
.log-line { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px dashed #e6dece; font-size: 20px; line-height: 1.6; }
.log-line b { text-align: right; letter-spacing: .08em; }
.log-empty { color: var(--ink-soft); text-align: center; padding: 30px; }
.log-hint { position: absolute; bottom: 5vh; color: #fff; opacity: .7; font-size: 14px; }

/* ------------------------------------------------------------ 選單 */
#menu {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(36, 28, 22, 0.42);
  backdrop-filter: blur(3px);
}
#menu.hidden, .menu-panel.hidden { display: none; }
.menu-panel {
  width: min(900px, 94vw);
  max-height: 92vh; overflow: auto;
  background: #fbf7ef;
  border-radius: 22px;
  padding: 24px 30px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: panel-in .3s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes panel-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.menu-head { display: flex; align-items: center; justify-content: space-between; }
.menu-head h2 { margin: 0; font-size: 27px; letter-spacing: .16em; }
.menu-head .close { width: 38px; height: 38px; border-radius: 50%; border: none; background: #ece4d6; cursor: pointer; font-size: 16px; }
.scene-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 18px 0 20px; }
.scene-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 12px 14px 12px 12px;
  background: #fff;
  border: 2px solid #eee4d3; border-left: 7px solid var(--sc, var(--gold));
  border-radius: 14px;
  cursor: pointer; text-align: left; color: var(--ink);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.scene-card:hover { transform: translateY(-3px); border-color: var(--sc); box-shadow: 0 8px 18px rgba(40, 28, 20, 0.12); }
.scene-card .no { font-size: 13px; font-weight: 800; color: #a3978a; }
.scene-card b { font-size: 21px; letter-spacing: .1em; }
.scene-card i { font-style: normal; font-size: 12px; letter-spacing: .08em; color: #a3978a; text-transform: uppercase; }
.scene-card.cur { background: var(--nun); color: #fff; border-color: var(--nun); border-left-color: var(--sc); }
.menu-opts { display: flex; gap: 10px; flex-wrap: wrap; }
.menu-opts button {
  padding: 10px 20px; border-radius: 999px; border: 2px solid #e4d9c6;
  background: #fff; color: var(--ink); font-size: 17px; cursor: pointer;
}
.menu-opts button:hover { border-color: var(--gold); }
.menu-opts [data-opt="reset"] { margin-left: auto; color: #b5452a; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 28px; margin: 18px 0 22px; }
.help-grid > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 17px; }
.help-grid span { color: var(--ink-soft); margin-left: 4px; }
.help-grid .sep { grid-column: 1 / -1; font-weight: 800; color: var(--gold); letter-spacing: .12em; margin-top: 6px; }
.help-grid kbd, .menu-panel kbd {
  display: inline-block; padding: 3px 9px; border-radius: 7px;
  background: #fff; border: 1px solid #ddd2bf; box-shadow: 0 2px 0 #ddd2bf;
  font: 700 15px/1.4 var(--font);
}

/* ------------------------------------------------------------ 背包 */
.bag-body { display: grid; grid-template-columns: 1fr 280px; gap: 22px; margin: 18px 0 6px; min-height: 300px; }
.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; align-content: start; }
.bag-cell {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px 10px;
  background: #fff; border: 2px solid #eee4d3; border-radius: 16px;
  cursor: pointer; color: var(--ink);
  transition: transform .15s, border-color .15s;
}
.bag-cell:hover { transform: translateY(-2px); border-color: var(--gold); }
.bag-cell.sel { border-color: var(--nun); box-shadow: 0 0 0 3px rgba(201, 165, 90, 0.5); }
.bag-cell .bi { font-size: 40px; line-height: 1.1; }
.bag-cell .bn { font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.bag-cell .bc { position: absolute; top: 6px; right: 9px; font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.bag-cell.key::after { content: "★"; position: absolute; top: 5px; left: 9px; font-size: 13px; color: var(--gold); }
.bag-empty { grid-column: 1 / -1; color: var(--ink-soft); font-size: 18px; padding: 40px; text-align: center; }
.bag-detail {
  background: #fff; border-radius: 18px; padding: 22px;
  border: 2px solid #eee4d3;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.bag-detail .bd-icon { font-size: 72px; line-height: 1.2; }
.bag-detail .bd-name { font-size: 24px; font-weight: 800; letter-spacing: .08em; margin-top: 6px; }
.bag-detail .bd-name small { font-size: 16px; color: var(--ink-soft); }
.bag-detail .bd-key { margin-top: 6px; padding: 2px 12px; border-radius: 999px; background: var(--nun); color: var(--gold); font-size: 13px; font-weight: 700; letter-spacing: .1em; }
.bag-detail p { font-size: 18px; line-height: 1.7; color: var(--ink-soft); margin: 14px 0 0; text-align: left; }

/* ------------------------------------------------------------ 任務 */
.q-list { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 6px; }
.q-card { background: #fff; border: 2px solid #eee4d3; border-left: 7px solid var(--gold); border-radius: 16px; padding: 16px 22px; }
.q-card.side { border-left-color: var(--fox); }
.q-card.fin { opacity: .62; }
.q-head { display: flex; align-items: center; gap: 12px; }
.q-head b { font-size: 23px; letter-spacing: .08em; }
.q-tag { padding: 3px 11px; border-radius: 999px; background: var(--nun); color: var(--gold); font-size: 14px; font-weight: 800; letter-spacing: .1em; }
.q-card.side .q-tag { background: #e9e0f5; color: var(--fox); }
.q-fin { margin-left: auto; color: #3f8f5a; font-weight: 800; font-size: 16px; letter-spacing: .1em; }
.q-card p { margin: 8px 0 10px; font-size: 17px; color: var(--ink-soft); line-height: 1.6; }
.q-card ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.q-card li { display: flex; align-items: center; gap: 10px; font-size: 18px; color: #a3978a; }
.q-card li .ck { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: #f1ebe0; font-size: 13px; }
.q-card li.done { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: rgba(107, 98, 114, 0.4); }
.q-card li.done .ck { background: #3f8f5a; color: #fff; }
.q-card li.cur { color: var(--ink); font-weight: 800; }
.q-card li.cur .ck { background: var(--gold); color: var(--nun); }
.q-more { text-align: center; color: var(--ink-soft); font-size: 16px; padding: 6px; }

/* ------------------------------------------------------------ 字幕 / 轉場 / 載入 */
#caption {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(to bottom, transparent 34%, rgba(28, 22, 32, 0.55) 43%, rgba(28, 22, 32, 0.55) 57%, transparent 66%);
  opacity: 0; transition: opacity .6s;
}
#caption.show { opacity: 1; }
#caption .cap-main { color: #fff; font-size: clamp(32px, 3.8vw, 54px); font-weight: 900; letter-spacing: .24em; text-shadow: 0 3px 14px rgba(0, 0, 0, 0.4); }
#caption .cap-sub { color: #f2e6cf; font-size: clamp(16px, 1.5vw, 21px); margin-top: 10px; letter-spacing: .2em; }

#fade { position: fixed; inset: 0; z-index: 60; background: var(--scene-bg); opacity: 0; pointer-events: none; transition: opacity .35s ease; }
#fade.on { opacity: 1; }

#loading {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #e7ded1; color: #6b5a48; font-size: 18px; letter-spacing: .1em;
  transition: opacity .6s;
}
#loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid #d6c8b4; border-top-color: var(--nun); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ 窄螢幕 */
@media (max-width: 760px) {
  #scene-title { top: 12px; left: 12px; padding: 6px 14px 6px 6px; }
  #scene-title .st-no { width: 32px; height: 32px; font-size: 12px; }
  #scene-title .st-name { font-size: 18px; }
  #party { top: auto; bottom: 16px; right: 12px; }
  .party-card .info { display: none; }
  .party-card { padding: 4px; }
  #round-btns { left: 12px; bottom: 16px; gap: 10px; }
  #round-btns button { width: 46px; height: 46px; }
  .vn-box { padding: 26px 22px 14px; height: clamp(140px, 26vh, 200px); }
  .vn-portrait { height: 58vh; }
  .scene-list { grid-template-columns: repeat(2, 1fr); }
  .help-grid { grid-template-columns: 1fr; }
  #quest-track { top: 60px; left: 12px; max-width: 70vw; }
  .qt-text { font-size: 16px; }
  .qt-row.side .qt-text { font-size: 15px; }
  #notices { top: 60px; right: 12px; }
  .notice .n-text { font-size: 17px; }
  .bag-body { grid-template-columns: 1fr; }
  .bag-grid { grid-template-columns: repeat(3, 1fr); }
}
