/* ===================================================================
   时光漫游 · 烟雨江南 —— 独立入口样式
   复用一期品牌色（墨黛/绢/琥珀/青瓷），附 hex 兜底
   =================================================================== */
:root {
  --paper: #edf1ee;            --paper: oklch(0.949 0.007 150);
  --paper-2: #e3e7e3;          --paper-2: oklch(0.924 0.009 150);
  --paper-sink: #d8ddd8;       --paper-sink: oklch(0.893 0.012 150);
  --hair: #c5cbc5;             --hair: oklch(0.838 0.013 150);
  --ink: #22272e;             --ink: oklch(0.255 0.018 235);
  --ink-2: #5a626b;           --ink-2: oklch(0.438 0.020 230);
  --dai: #305a6b;             --dai: oklch(0.404 0.060 222);
  --dai-deep: #1f3742;        --dai-deep: oklch(0.262 0.045 230);
  --ink-hero: #1a2330;        --ink-hero: oklch(0.205 0.024 235);
  --amber: #d98a3c;           --amber: oklch(0.700 0.130 60);
  --amber-soft: #e7b27e;      --amber-soft: oklch(0.800 0.090 65);
  --amber-deep: #936020;      --amber-deep: oklch(0.505 0.115 58);
  --celadon: #5f928a;         --celadon: oklch(0.620 0.055 175);
  --celadon-deep: #356a68;    --celadon-deep: oklch(0.452 0.060 185);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: var(--font-sans); color: var(--ink); background: #cdd9d3; }

.roam { position: fixed; inset: 0; overflow: hidden; }
#world { display: block; width: 100%; height: 100%; touch-action: none; cursor: pointer; }

/* —— HUD —— */
.roam-hud {
  position: absolute; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem clamp(0.9rem, 3vw, 1.8rem);
  color: #eef3f1;
  background: linear-gradient(180deg, rgba(26, 35, 48, 0.62), rgba(26, 35, 48, 0));
  pointer-events: none;
}
.roam-back {
  pointer-events: auto; text-decoration: none; color: #eef3f1; font-size: 0.9rem; font-weight: 700;
  background: rgba(26, 35, 48, 0.4); border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.9rem; border-radius: 999px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background 0.3s var(--ease);
}
.roam-back:hover { background: rgba(26, 35, 48, 0.62); }
.roam-titles { text-align: center; text-shadow: 0 1px 6px rgba(26, 35, 48, 0.6); }
.roam-title { display: block; font-family: var(--font-serif); font-weight: 700; font-size: clamp(1.05rem, 3vw, 1.5rem); letter-spacing: 0.08em; }
.roam-sub { display: block; font-size: 0.72rem; color: var(--amber-soft); letter-spacing: 0.12em; }
.roam-progress { font-size: 0.86rem; background: rgba(26, 35, 48, 0.4); border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.9rem; border-radius: 999px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.roam-progress b { font-family: var(--font-serif); color: var(--amber-soft); font-size: 1.1rem; }

.roam-hint {
  position: absolute; left: 50%; bottom: 1.1rem; transform: translateX(-50%); z-index: 10;
  color: #eef3f1; font-size: 0.8rem; text-align: center; line-height: 1.7;
  background: rgba(26, 35, 48, 0.5); border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 0.5rem 1rem; border-radius: 12px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  max-width: min(92vw, 560px); transition: opacity 0.6s var(--ease);
}
.roam-hint strong { color: var(--amber-soft); }
.roam-hint.is-faded { opacity: 0; }
kbd { font-family: inherit; font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.3); margin: 0 1px; }
.roam-hint .k { margin-right: 0.3rem; }

.roam-prompt {
  position: absolute; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 11;
  color: #1a2330; font-size: 0.92rem; font-weight: 700;
  background: linear-gradient(135deg, var(--amber-soft), var(--amber)); padding: 0.5rem 1.1rem; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(217, 138, 60, 0.45); animation: bob 1.4s var(--ease) infinite;
}
.roam-prompt[hidden] { display: none; }
.roam-prompt kbd { background: rgba(26, 35, 48, 0.85); color: #fff; border-color: transparent; }
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -5px); } }

.roam-loading { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: #1a2330; color: var(--amber-soft); font-family: var(--font-serif); letter-spacing: 0.3em; font-size: 1.1rem;
  transition: opacity 0.6s var(--ease); }
.roam-loading.is-hidden { opacity: 0; pointer-events: none; }

/* —— 触屏方向键 —— */
.dpad { position: absolute; right: 1.1rem; bottom: 1.4rem; z-index: 12;
  display: none; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 6px; }
.dpad__btn { border: none; border-radius: 12px; font-size: 1.1rem; color: #eef3f1; cursor: pointer;
  background: rgba(26, 35, 48, 0.5); border: 1px solid rgba(255, 255, 255, 0.2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  -webkit-user-select: none; user-select: none; touch-action: none; }
.dpad__btn:active { background: var(--amber); color: #1a2330; }
.dpad__btn.up { grid-area: 1 / 2; } .dpad__btn.left { grid-area: 2 / 1; }
.dpad__btn.act { grid-area: 2 / 2; font-size: 0.72rem; font-weight: 700; background: rgba(217, 138, 60, 0.7); color: #1a2330; }
.dpad__btn.right { grid-area: 2 / 3; } .dpad__btn.down { grid-area: 3 / 2; }
@media (hover: none) and (pointer: coarse) { .dpad { display: grid; } .roam-hint { display: none; } }

/* —— 人物对话框 —— */
dialog.npc { position: relative; width: min(820px, 95vw); max-height: 92vh; padding: 0; border: none; border-radius: 18px;
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 70px -25px rgba(26, 35, 48, 0.6); overflow: hidden; }
dialog.npc.is-roundtable { width: min(1080px, 96vw); }
dialog.npc::backdrop { background: rgba(26, 35, 48, 0.55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.npc__scroll { max-height: 92vh; overflow-y: auto; }
/* 两栏：左立绘舞台 + 右内容 */
.npc__main { display: flex; align-items: stretch; }
.npc__stage { flex: 0 0 240px; display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 1.5rem 1.1rem 1.3rem; color: #eef3f1; background: linear-gradient(165deg, var(--ink-hero), var(--dai-deep)); }
.npc__portrait { width: 200px; height: 284px; border-radius: 14px; background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14); }
.npc__stage .npc__id { text-align: center; }
.npc__role { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2em; color: var(--amber-soft); margin: 0 0 0.3rem; }
.npc__name { font-family: var(--font-serif); font-weight: 700; font-size: clamp(1.35rem, 3.4vw, 1.7rem); margin: 0; }
.npc__where { font-size: 0.8rem; color: #c4cdc9; margin: 0.35rem 0 0; }
.npc__close { position: absolute; top: 0.9rem; right: 0.9rem; z-index: 5; width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.28); color: #eef3f1; font-size: 1.2rem;
  display: grid; place-items: center; transition: background 0.3s var(--ease); }
.npc__close:hover { background: rgba(255, 255, 255, 0.32); }

.npc__body { flex: 1; min-width: 0; padding: 1.4rem 1.6rem 1.7rem; }
/* 圆桌舞台：对话框右侧独立一栏（仅圆桌时出现，不挡聊天） */
.npc__table-wrap { flex: 0 0 300px; display: flex; flex-direction: column; gap: 0.55rem; padding: 1.2rem 1rem;
  border-left: 1px solid var(--hair); background: radial-gradient(120% 70% at 50% 10%, #f6efe0, #e7dcc6); }
.npc__table-wrap[hidden] { display: none; }
.npc__table-title { margin: 0; font-family: var(--font-serif); font-weight: 700; font-size: 0.92rem;
  color: var(--amber-deep, #b9772e); letter-spacing: 0.06em; text-align: center; }
.npc__table { display: block; width: 100%; height: auto; }
/* 语音输入麦克风 */
.npc__mic { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; padding: 0.6rem 0.7rem; background: var(--celadon-deep, #4d7e72); }
.npc__mic.is-rec { background: #e3534a; transform: scale(1.05); box-shadow: 0 0 0 4px rgba(227,83,74,0.2); animation: npc-recpulse 1s ease-in-out infinite; }
@keyframes npc-recpulse { 50% { box-shadow: 0 0 0 8px rgba(227,83,74,0.08); } }
.npc__greet { font-family: var(--font-serif); font-size: 1.05rem; color: var(--dai); line-height: 1.7; margin: 0 0 1.2rem;
  padding-left: 0.9rem; border-left: 2px solid var(--amber); }
.npc__tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--hair); margin: 0 0 1rem; }
.npc__tab { background: none; border: 0; cursor: pointer; font-family: var(--font-sans); font-size: 0.92rem; font-weight: 600;
  color: var(--ink-2); padding: 0.55rem 0.85rem; position: relative; letter-spacing: 0.05em; }
.npc__tab[aria-selected="true"] { color: var(--ink); }
.npc__tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0.6rem; right: 0.6rem; bottom: -1px; height: 2.5px; background: var(--amber); border-radius: 3px; }
.npc__panel { font-size: 0.97rem; line-height: 1.9; color: var(--ink); text-wrap: pretty; min-height: 4.5em; }

.npc__ask { margin: 1.4rem 0 0; padding: 1.1rem; background: var(--paper-2); border: 1px solid var(--hair); border-radius: 12px; }
.npc__ask h4 { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-2); margin: 0 0 0.7rem; }
.npc__ask-form { display: flex; gap: 0.5rem; }
.npc__ask-input { flex: 1; font-family: var(--font-sans); font-size: 0.95rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--hair); border-radius: 7px; padding: 0.6rem 0.8rem; }
.npc__ask-input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217, 138, 60, 0.16); }
.btn-roam { font-family: var(--font-sans); font-weight: 700; cursor: pointer; border: none; border-radius: 7px;
  padding: 0.6rem 1.1rem; font-size: 0.92rem; color: #eef3f1; background: var(--dai); transition: background 0.25s var(--ease), transform 0.25s var(--ease); white-space: nowrap; }
.btn-roam:hover { background: var(--dai-deep); transform: translateY(-1px); }
.btn-roam:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-roam--round { display: flex; align-items: center; justify-content: center; gap: 0.45rem; width: 100%; margin-top: 0.6rem; background: linear-gradient(120deg, var(--amber-deep, #b9772e), var(--dai)); letter-spacing: 0.04em; }
.btn-roam--round:hover { background: linear-gradient(120deg, #a8692a, var(--dai-deep)); }
.ic-svg { display: block; flex: none; pointer-events: none; }
.npc__answer { margin: 1rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; max-height: 240px; overflow-y: auto; padding-right: 2px; }
.npc__answer[hidden] { display: none; }
/* 多轮转录气泡 */
.npc__msg { max-width: 90%; padding: 0.5rem 0.72rem; border-radius: 12px; font-size: 0.93rem; line-height: 1.72; white-space: pre-wrap; word-break: break-word; }
.npc__msg.is-user { align-self: flex-end; background: var(--dai); color: #eef3f1; border-bottom-right-radius: 4px; }
.npc__msg.is-bot { align-self: flex-start; background: var(--paper); border: 1px solid var(--hair); color: var(--ink); border-bottom-left-radius: 4px; }
/* 圆桌发言人名牌 */
.npc__msg-who { display: block; font-family: var(--font-serif); font-weight: 700; font-size: 0.78rem; color: var(--amber-deep, #b9772e); margin-bottom: 0.16rem; letter-spacing: 0.02em; }
/* 字幕式逐字显示：揭示中先藏来源 chip，末尾跟一个轻光标 */
.npc__msg.is-revealing .npc__msg-src { display: none; }
.npc__msg.is-revealing .npc__msg-text::after { content: '▍'; margin-left: 1px; opacity: 0.5; animation: npc-caret 0.9s steps(1) infinite; }
@keyframes npc-caret { 50% { opacity: 0; } }
.npc__msg-src { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.npc__msg-src a, .npc__msg-src span { font-size: 0.68rem; color: var(--dai); border: 1px solid var(--hair); border-radius: 999px; padding: 0.06rem 0.5rem; text-decoration: none; background: var(--paper-2); }
.npc__typing { align-self: flex-start; display: inline-flex; gap: 0.4rem; align-items: center; color: var(--ink-2); font-size: 0.9rem; }
.npc__typing .d { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pl 1.1s var(--ease) infinite; }
.npc__typing .d:nth-child(2) { animation-delay: .18s; } .npc__typing .d:nth-child(3) { animation-delay: .36s; }
.npc__answer .badge-mode { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.6rem; border-radius: 999px; margin-bottom: 0.5rem; }
.npc__answer .badge-mode.llm { color: var(--amber-deep); background: rgba(217, 138, 60, 0.12); border: 1px solid rgba(217, 138, 60, 0.3); }
.npc__answer .badge-mode.off { color: var(--celadon-deep); background: rgba(95, 146, 138, 0.12); border: 1px solid rgba(95, 146, 138, 0.3); }
.npc__answer .txt { font-size: 0.96rem; line-height: 1.9; white-space: pre-wrap; }
.npc__answer .txt p { margin: 0 0 0.7rem; }
.npc__loading { display: inline-flex; gap: 0.5rem; align-items: center; color: var(--ink-2); font-size: 0.9rem; }
.npc__loading .d { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pl 1.1s var(--ease) infinite; }
.npc__loading .d:nth-child(2){animation-delay:.18s}.npc__loading .d:nth-child(3){animation-delay:.36s}
@keyframes pl { 0%,100%{opacity:.25;transform:scale(.8)} 50%{opacity:1;transform:scale(1)} }
.npc__sources { margin: 1.2rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.npc__sources a { font-size: 0.8rem; color: var(--celadon-deep); text-decoration: none; padding: 0.35rem 0.7rem;
  background: var(--paper-2); border: 1px solid var(--hair); border-radius: 999px; }
.npc__sources a:hover { border-color: var(--celadon); }

@media (prefers-reduced-motion: reduce) { .roam-prompt { animation: none; } .npc__loading .d { animation: none; } }
@media (max-width: 640px) {
  .npc__main { flex-direction: column; }
  .npc__stage { flex: none; flex-direction: row; justify-content: center; gap: 1rem; padding: 1.1rem; }
  .npc__portrait { width: 130px; height: 184px; }
  .npc__stage .npc__id { text-align: left; align-self: center; }
  .npc__table-wrap { flex: none; width: 100%; border-left: none; border-top: 1px solid var(--hair); }
}
@media (max-width: 420px) { .npc__ask-form { flex-wrap: wrap; } .npc__ask-input { flex: 1 1 60%; } }
