/* site.css -- 官網與網頁客戶端共用樣式。深色、水墨感，金色點綴。 */
:root {
  --bg: #0c0e11; --bg-2: #12151a; --panel: #161a20; --line: #262b34; --line-2: #343b48;
  --text: #d9d4c6; --muted: #a29f95; --faint: #878479;    /* 對比度：faint 在最亮的面板底色上也有 4.6:1（原本 3.2） */
  --gold: #c8a45a; --gold-2: #e2c47e; --gold-dim: #7d6736;
  --red: #c4472f; --jade: #5f9b86; --warn: #d9604c;
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  --sans: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Sarasa Mono TC", "Noto Sans Mono CJK TC", "MingLiU", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 16px; line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- 按鈕 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: 0 1.4em; border-radius: 4px; border: 1px solid var(--line-2);
  background: transparent; color: var(--text); font: inherit; font-size: .95rem; letter-spacing: .08em;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold-2); text-decoration: none; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #17130a; font-weight: 700; }
.btn-primary:hover { background: var(--gold-2); border-color: var(--gold-2); color: #17130a; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- 開發站標示 ---- */
.dev-ribbon {
  position: sticky; top: 0; z-index: 50; padding: 6px 12px; text-align: center;
  background: var(--red); color: #fff; font-size: .85rem; letter-spacing: .15em;
}
.env-badge {
  padding: 2px 10px; border-radius: 3px; background: var(--red); color: #fff;
  font-size: .78rem; letter-spacing: .12em; white-space: nowrap;
}

/* ================= 官網 ================= */
.wrap { width: min(1040px, 100% - 40px); margin-inline: auto; }

.topbar {
  position: sticky; top: 0; z-index: 40; backdrop-filter: blur(8px);
  background: rgba(12, 14, 17, .86); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { font-family: var(--serif); font-size: 1.25rem; letter-spacing: .25em; color: var(--gold-2); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 22px; margin-left: auto; font-size: .92rem; }
.nav a { color: var(--muted); letter-spacing: .1em; }
.nav a:hover { color: var(--gold-2); text-decoration: none; }
.topbar .btn { min-height: 38px; padding: 0 1.1em; }

.hero {
  position: relative; overflow: hidden; padding: 88px 0 96px;
  background:
    radial-gradient(900px 480px at 82% 0%, rgba(200, 164, 90, .13), transparent 70%),
    radial-gradient(700px 420px at 0% 100%, rgba(95, 155, 134, .08), transparent 70%);
  border-bottom: 1px solid var(--line);
}
.hero .wrap { display: grid; grid-template-columns: 1.25fr .75fr; gap: 40px; align-items: center; }
.eyebrow { color: var(--gold); letter-spacing: .3em; font-size: .85rem; margin: 0 0 18px; }
.hero h1 {
  margin: 0; font-family: var(--serif); font-weight: 700; line-height: 1.1;
  font-size: clamp(3rem, 8vw, 5.6rem); letter-spacing: .18em; color: #efe7d3;
}
.hero .en { margin: 10px 0 0; color: var(--faint); letter-spacing: .5em; font-size: .95rem; text-transform: uppercase; }
.hero .lead { margin: 28px 0 0; max-width: 34em; color: var(--text); font-size: 1.08rem; }
.cta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 36px; }
.couplet {
  display: flex; flex-direction: row-reverse; justify-content: center; gap: 1.4rem;
  font-family: var(--serif); color: var(--gold); opacity: .92;
}
.couplet span {
  writing-mode: vertical-rl; font-size: clamp(1.25rem, 2.6vw, 1.9rem); letter-spacing: .38em;
  padding-top: .4em; border-right: 1px solid var(--gold-dim); padding-right: 1.1rem;
}
.couplet span:last-child { border-right: 0; }

.section { padding: 76px 0; border-bottom: 1px solid var(--line); }
.section:nth-of-type(even) { background: var(--bg-2); }
.section h2 {
  margin: 0 0 8px; font-family: var(--serif); font-size: 1.7rem; letter-spacing: .2em; color: #efe7d3;
}
.section h2::after { content: ""; display: block; width: 44px; height: 2px; margin-top: 14px; background: var(--gold); }
.section .sub { margin: 18px 0 0; color: var(--muted); max-width: 40em; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-top: 36px; }
.card { padding: 24px 24px 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; transition: border-color .15s; }
.card:hover { border-color: var(--gold-dim); }
.card h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.15rem; letter-spacing: .15em; color: var(--gold-2); }
.card p { margin: 0; color: var(--text); font-size: .96rem; opacity: .9; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 36px 0 0; display: grid; gap: 14px; }
.steps li { counter-increment: s; position: relative; padding: 4px 0 4px 56px; min-height: 44px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--gold); color: var(--gold-2);
  font-family: var(--serif); font-size: 1.1rem;
}
.steps b { color: #efe7d3; font-weight: 600; }
code, .kbd {
  font-family: var(--mono); font-size: .9em; padding: 1px 7px; border-radius: 3px;
  background: #1d222a; border: 1px solid var(--line-2); color: var(--gold-2);
}

.table-wrap { overflow-x: auto; margin-top: 32px; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; letter-spacing: .12em; font-size: .85rem; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--mono); color: var(--gold-2); white-space: nowrap; }
.note { margin: 22px 0 0; color: var(--muted); font-size: .92rem; }

.footer { padding: 36px 0 52px; color: var(--faint); font-size: .85rem; text-align: center; }
.footer a { color: var(--muted); }

@media (max-width: 820px) {
  .topbar .wrap { flex-wrap: wrap; gap: 0 16px; min-height: 0; padding-top: 8px; }
  .brand { line-height: 44px; }
  .topbar .btn { margin-left: auto; }
  .nav { order: 3; flex: 0 0 100%; margin-left: 0; gap: 4px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; flex: 0 0 auto; }
  .nav a[hidden] { display: none; }
  .section, .hero[id] { scroll-margin-top: 100px; }
  .hero { padding: 56px 0 64px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 36px; }
  .couplet { justify-content: flex-start; }
  .section { padding: 56px 0; }
}

/* 江湖一瞥（終端機畫面預覽） */
.term {
  margin: 28px 0 0; padding: 18px 20px; background: #07090b; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: .92rem; line-height: 1.75; color: #c9ccd1;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.term .cmd { color: #7d8590; }
.term .room { color: #f0c75e; font-weight: 700; }
.term .exits { color: #4fd1d9; }
.term .npc { color: #f3f4f6; }
.term .id { color: #8b929c; }
.term .say { color: #7fd28a; }
.term .chan { color: #d68be8; }
.term .hp { color: #ff7b72; }
.term .mp { color: #6cb6ff; }
.term-cap { margin: 14px 0 0; color: var(--muted); font-size: .92rem; }
@media (max-width: 560px) { .term { padding: 14px; font-size: .84rem; } }

/* 江湖導覽頁（guide.html） */
.hero-sm { padding: 64px 0 56px; }
.hero-sm .wrap { grid-template-columns: 1fr; }
.group-title { margin: 44px 0 0; font-family: var(--serif); font-size: 1.2rem; letter-spacing: .2em; color: var(--gold-2); font-weight: 600; }
.cards.sects { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 20px; }
.cards.sects .card { padding: 16px 18px; }
.cards.sects .card h3 { font-size: 1.05rem; margin-bottom: 2px; }
.card .loc { margin: 0 0 8px; color: var(--faint); font-size: .8rem; letter-spacing: .05em; }
.card p + p { margin-top: 0; }
.section .cta { margin-top: 32px; }
.more { margin: 28px 0 0; }

/* ================= 網頁客戶端 ================= */
body.play { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; line-height: 1.4; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 12px; min-height: 52px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.bar .brand { font-size: 1.05rem; letter-spacing: .2em; }
.bar .spacer { flex: 1; }
.bar button, .quick button, .inputbar button {
  min-height: 36px; min-width: 36px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer;
}
.bar button:hover, .quick button:hover:not(:disabled), .inputbar button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); }
.bar button[aria-expanded="true"] { border-color: var(--gold-dim); color: var(--gold-2); }
button:disabled { opacity: .4; cursor: not-allowed; }
.bar button, .bar .btn { white-space: nowrap; }

.pill { padding: 3px 12px; border-radius: 999px; font-size: .8rem; letter-spacing: .1em; border: 1px solid var(--line-2); white-space: nowrap; }
.pill-ok { color: #8fd3a0; border-color: #3c6a4a; background: rgba(95, 155, 134, .12); }
.pill-wait { color: var(--gold-2); border-color: var(--gold-dim); }
.pill-bad { color: #ff9b8a; border-color: #7a3a30; background: rgba(217, 96, 76, .1); }
.pill-off { color: var(--muted); }

.stage { flex: 1; min-height: 0; padding: 8px 6px 6px 10px; background: var(--term-bg, #0b0d10); overflow-x: auto; overflow-y: hidden; }
#terminal { height: 100%; }
.xterm-viewport { background-color: var(--term-bg, #0b0d10) !important; }

.quick {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 22px; padding: 10px 12px;
  background: var(--bg-2); border-top: 1px solid var(--line);
}
.compass { display: grid; grid-template-columns: repeat(3, 56px); grid-auto-rows: 38px; gap: 4px; }
.updown { display: grid; grid-template-rows: repeat(2, 38px); gap: 4px; }
.updown button { width: 56px; }
.cmds { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; max-width: 460px; }
.quick button.center { border-color: var(--gold-dim); color: var(--gold-2); }

.inputbar { display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--bg-2); border-top: 1px solid var(--line); }
.inputbar input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--line-2);
  background: #0b0d10; color: var(--text); font-family: var(--mono); font-size: 16px; /* 16px：避免 iOS 聚焦時自動放大 */
}
.inputbar input:focus { border-color: var(--gold); outline: none; }
/* 輸入列的灰字預覽：蓋在輸入框上面，前半（已打的字）透明、只露出後面「按 Tab 會補成什麼」；字型、內距和輸入框一致才對得齊 */
.cmdwrap { position: relative; flex: 1; min-width: 0; display: flex; }
.cmdghost { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 15px; font-family: var(--mono); font-size: 16px; white-space: pre; overflow: hidden; pointer-events: none; }
.cmdghost[hidden] { display: none; }
.cmdghost .t { color: transparent; }
.cmdghost .g { color: var(--faint); pointer-events: auto; cursor: pointer; }
.inputbar input::placeholder { color: var(--faint); }
.inputbar button { min-height: 44px; padding: 0 22px; background: var(--gold); border-color: var(--gold); color: #17130a; font-weight: 700; letter-spacing: .1em; }
.inputbar button:disabled { background: var(--panel); border-color: var(--line-2); color: var(--text); }

@media (pointer: coarse) {
  .bar button, .quick button { min-height: 44px; min-width: 44px; }
  .compass { grid-template-columns: repeat(3, 62px); grid-auto-rows: 46px; }
  .updown { grid-template-rows: repeat(2, 46px); }
}
@media (max-width: 720px) {
  .bar .brand { display: none; }
  .quick { gap: 10px 14px; }
}

/* 設定視窗 */
.settings { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 20px 22px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; }
.settings::backdrop { background: rgba(0, 0, 0, .65); }
.settings h2 { margin: 0 0 12px; font-family: var(--serif); letter-spacing: .2em; color: var(--gold-2); font-size: 1.2rem; }
.settings fieldset { margin: 0 0 14px; padding: 10px 14px 12px; border: 1px solid var(--line); border-radius: 6px; }
.settings legend { padding: 0 8px; color: var(--muted); font-size: .85rem; letter-spacing: .1em; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0; font-size: .92rem; }
.settings label.chk { justify-content: flex-start; align-items: flex-start; line-height: 1.5; }
.settings label.chk input { margin-top: 5px; flex: none; }
.settings select, .settings textarea { background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font: inherit; }
.settings select { min-height: 36px; padding: 0 8px; }
.settings textarea { width: 100%; padding: 8px 10px; font-family: var(--mono); font-size: 14px; resize: vertical; }
.settings textarea:focus, .settings select:focus { border-color: var(--gold); outline: none; }
.settings input[type=text] { background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font: inherit; min-height: 36px; padding: 0 10px; width: 60%; }
.settings input[type=text]:focus { border-color: var(--gold); outline: none; }
#edText { min-height: 40vh; font-size: 15px; line-height: 1.5; }
#fbMsg.err { color: var(--danger, #f0806c); }
#fbMsg.ok { color: var(--ok, #9be09e); }
.settings .hint { margin: 4px 0 8px; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.settings .row { display: flex; flex-wrap: wrap; gap: 8px; }
.settings .row.end { justify-content: flex-end; margin-top: 4px; }
.settings button { min-height: 40px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; }
.settings button:hover { border-color: var(--gold); color: var(--gold-2); }
.settings button.primary { background: var(--gold); border-color: var(--gold); color: #17130a; font-weight: 700; }

/* 狀態列（GMCP Char.Vitals） */
.vitals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 14px; padding: 6px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); font-size: .82rem; }
.vbar { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 0 8px; align-items: center; min-width: 0; }
.vbar .vl { color: var(--muted); letter-spacing: .1em; }
.vbar .vn { grid-column: 2; grid-row: 1; justify-self: end; font-family: var(--mono); color: var(--text); white-space: nowrap; }
.vbar .vt { grid-column: 1 / 3; grid-row: 2; position: relative; height: 8px; border-radius: 4px; background: #1d222a; overflow: hidden; }
.vbar .vt i { position: absolute; left: 0; top: 0; bottom: 0; transition: width .35s ease; }
.vbar .vt .eff { background: #3a2f2f; }
.vbar[data-k="qi"] .cur { background: #d9604c; }
.vbar[data-k="jing"] .cur { background: #d8b25a; }
.vbar[data-k="neili"] .cur { background: #5f8fe0; }
.vbar[data-k="jingli"] .cur { background: #6fbf7a; }
.vbar.low .cur { animation: vlow 1s steps(2) infinite; }
@keyframes vlow { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .vbar .vt i { transition: none; } .vbar.low .cur { animation: none; } }
@media (max-width: 720px) { .vitals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 定時器列 */
.timerbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.timerbar button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer;
}
.timerbar button .tc { font-family: var(--mono); color: var(--faint); }
.timerbar button.on { border-color: #3c6a4a; color: #8fd3a0; background: rgba(95, 155, 134, .12); }
.timerbar button.on .tc { color: #8fd3a0; }
.timerbar button:disabled { opacity: .4; cursor: not-allowed; }
@media (pointer: coarse) { .timerbar button { min-height: 40px; } }

/* 分頁（自動化視窗） */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.settings .tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; background: none; color: var(--muted); min-height: 38px; }
.settings .tabs button[aria-selected="true"] { color: var(--gold-2); border-bottom-color: var(--gold); }
.tabpanel .hint { margin: 0 0 8px; color: var(--muted); font-size: .86rem; line-height: 1.6; }
.tabpanel textarea { width: 100%; padding: 8px 10px; background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font-family: var(--mono); font-size: 14px; resize: vertical; min-height: 120px; }
.tabpanel textarea:focus { border-color: var(--gold); outline: none; }
.tabpanel { margin-bottom: 14px; }

.varlist { margin: 0 0 10px; padding: 8px 10px; max-height: 160px; overflow: auto; background: #0b0d10; border: 1px solid var(--line-2); border-radius: 4px; color: var(--text); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }

.bar button[aria-pressed="true"] { border-color: var(--gold-dim); color: var(--gold-2); }
@media (max-width: 720px) {
  .bar { gap: 5px 6px; padding: 6px 8px; min-height: 0; }
  .bar button, .bar .btn { padding: 0 9px; }
  .bar .bar-site { display: none; }           /* 窄螢幕：官網連結讓位（品牌名稱同樣隱藏，回官網用瀏覽器上一頁） */
}

/* 聊天面板 */
.workarea { flex: 1; min-height: 0; display: flex; position: relative; }
.workarea .stage { min-width: 0; }
.chat { flex: none; position: relative; width: var(--chat-w, 340px); display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border-left: 1px solid var(--line); }
.chat[hidden] { display: none; }
/* 側欄下半部：聊天｜物品 */
.dock { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dock[hidden], .dock-view[hidden] { display: none; }
.dock-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-tabs { padding-top: 6px; }
.side-tabs button[role=tab] { font-size: .92rem; letter-spacing: .08em; }
.side-tabs kbd { margin-left: 4px; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--faint); font: .7rem var(--mono); letter-spacing: 0; }
.side-tabs .dot { right: -2px; }
.dock-view .chat-tabs { padding-top: 2px; }
.chat-tabs { display: flex; align-items: center; gap: 2px; padding: 4px 6px 0; border-bottom: 1px solid var(--line); }
.chat-tabs button { position: relative; min-height: 34px; padding: 0 10px; border: 0; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; background: none; color: var(--muted); font: inherit; font-size: .86rem; cursor: pointer; }
.chat-tabs button[aria-selected="true"] { color: var(--gold-2); border-bottom-color: var(--gold); }
.chat-tabs .spacer { flex: 1; }
.chat-tabs .chat-x { padding: 0 8px; }
.chat .dot { position: absolute; top: 5px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: #e0584a; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 10px; font-size: .88rem; line-height: 1.5; word-break: break-word; overscroll-behavior: contain; }
.chat-log .msg { padding: 1px 0; }
.chat-log .msg .tm { margin-right: 6px; color: var(--faint); font-family: var(--mono); font-size: .76rem; }
.chat-log .msg.reply { cursor: pointer; }
.chat-log .msg.reply:hover { background: rgba(200, 164, 90, .08); }
.chat-log .empty { color: var(--faint); padding: 14px 4px; }
.chat-foot { display: flex; align-items: center; gap: 8px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.chat-foot .chk { display: flex; gap: 6px; align-items: flex-start; flex: 1; line-height: 1.4; }
.chat-foot button { min-height: 32px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; }
#chatCount { margin-left: 6px; padding: 0 6px; border-radius: 999px; background: #e0584a; color: #fff; font-size: .72rem; font-weight: 600; }
/* 左邊緣的拖曳把手（只有寬螢幕；窄螢幕的面板是浮在下方，沒有寬度可拉） */
.chat-grip { position: absolute; left: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 6; touch-action: none; }
.chat-grip:hover, .chat-grip.drag, .chat-grip:focus-visible { background: rgba(200, 164, 90, .35); outline: 0; }
/* 窄螢幕：面板浮在遊戲畫面下半部，不佔用寬度（否則適寬的字級會被迫更小） */
@media (max-width: 900px) {
  .chat-grip { display: none; }
  .chat { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 46%; border-left: 0; border-top: 1px solid var(--gold-dim); box-shadow: 0 -6px 18px rgba(0, 0, 0, .45); z-index: 5; }
}

/* 輸入列旁的輔助按鈕與指令歷史 */
.inputwrap { position: relative; }
.inputbar .aux { flex: none; min-height: 44px; padding: 0 12px; background: var(--panel); border: 1px solid var(--line-2); color: var(--text); font-weight: 400; letter-spacing: 0; font-size: .88rem; }
.inputbar .aux:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); }
.inputbar .aux[aria-pressed="true"], .inputbar .aux[aria-expanded="true"] { border-color: var(--gold-dim); color: var(--gold-2); }
.inputbar #chatCount { margin-left: 5px; }
.histpop { position: absolute; left: 12px; bottom: 100%; width: min(460px, calc(100vw - 24px)); max-height: min(50vh, 360px); display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--gold-dim); border-radius: 6px 6px 0 0; box-shadow: 0 -6px 18px rgba(0, 0, 0, .45); z-index: 8; }
.histpop[hidden] { display: none; }
.hist-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.hist-head input { flex: 1; min-width: 0; min-height: 36px; padding: 0 10px; background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font-family: var(--mono); font-size: 16px; }
.hist-head input:focus { border-color: var(--gold); outline: none; }
.hist-head button { min-height: 36px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; font-size: .84rem; cursor: pointer; }
.hist-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; overscroll-behavior: contain; }
.hist-list li { display: flex; align-items: stretch; }
.hist-list .h-cmd { flex: 1; min-width: 0; padding: 8px 12px; background: none; border: 0; color: var(--text); font-family: var(--mono); font-size: .9rem; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-list .h-cmd:hover, .hist-list .h-cmd:focus-visible { background: rgba(200, 164, 90, .1); color: var(--gold-2); outline: none; }
.hist-list .h-go { flex: none; width: 44px; background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.hist-list .h-go:hover:not(:disabled) { color: var(--gold-2); background: rgba(200, 164, 90, .1); }
.hist-list .h-go:disabled { opacity: .35; cursor: not-allowed; }
.hist-empty { padding: 14px 12px; color: var(--faint); font-size: .88rem; }
@media (max-width: 720px) { .inputbar { gap: 6px; padding-left: 8px; padding-right: 8px; } .inputbar .aux { padding: 0 9px; } .inputbar button[type=submit] { padding: 0 14px; } }

/* 設定視窗裡的字體大小列 */
.settings .fontrow { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: .92rem; }
.settings .fontrow .grow { flex: 1; }
.settings .fontrow button[aria-pressed="true"] { border-color: var(--gold-dim); color: var(--gold-2); }

/* 設定檢查結果 */
.val { margin: 6px 0 0; font-size: .84rem; line-height: 1.5; }
.val .ok { color: #8fd3a0; }
.val .warn { color: #e6b567; }
.val ul { margin: 4px 0 0; padding-left: 1.3em; color: var(--muted); }
.val ul li { margin: 2px 0; }
.val code { font-size: .92em; }
.val-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.val-actions .example { min-height: 30px; padding: 0 10px; font-size: .8rem; }

/* 連線中斷提示條 */
.connbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: rgba(217, 96, 76, .12); border-top: 1px solid #7a3a30; color: #ffb4a6; font-size: .9rem; }
.connbar[hidden] { display: none; }
.connbar span { flex: 1; min-width: 0; line-height: 1.5; }
.connbar button { flex: none; min-height: 36px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--gold); background: var(--gold); color: #17130a; font: inherit; font-weight: 700; cursor: pointer; }

/* 往上捲了之後的「回到最新」 */
.tobottom { position: absolute; right: 26px; bottom: 14px; z-index: 6; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--gold-dim);
  background: rgba(18, 21, 26, .94); color: var(--gold-2); font: inherit; font-size: .86rem; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.tobottom[hidden] { display: none; }
@media (min-width: 901px) { .chat:not([hidden]) ~ .tobottom { right: calc(var(--chat-w, 340px) + 26px); } }
@media (max-width: 900px) { .chat:not([hidden]) ~ .tobottom { bottom: calc(46% + 12px); } }

/* 觸控裝置：新元件的點擊範圍至少 44px */
@media (pointer: coarse) {
  .chat-tabs button, .chat-foot button, .hist-head button, .hist-head input { min-height: 44px; }
  .hist-list .h-cmd, .hist-list .h-go { min-height: 44px; }
  .settings button, .settings select, .connbar button, .tobottom { min-height: 44px; }
  .settings .tabs button { min-height: 44px; }
  .val-actions .example { min-height: 40px; }
}

/* 登入輔助列 */
.loginbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 8px 12px; background: rgba(200, 164, 90, .08); border-top: 1px solid var(--gold-dim); font-size: .88rem; color: var(--text); }
.loginbar[hidden] { display: none; }
.loginbar .lb-text { flex: 1 1 260px; line-height: 1.5; }
.loginbar .lb-text b { color: var(--gold-2); font-weight: 600; }
.loginbar .lb-text a { margin-left: 8px; color: var(--gold-2); }
.loginbar .lb-lang { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.loginbar button { min-height: 34px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; font-size: .86rem; cursor: pointer; }
.loginbar button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); }
.loginbar .lb-x { min-width: 34px; padding: 0 8px; border: 0; background: none; color: var(--muted); }
@media (pointer: coarse) { .loginbar button { min-height: 44px; } }

/* 回捲搜尋 */
.searchbar { position: absolute; top: 8px; right: 26px; z-index: 7; display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: rgba(18, 21, 26, .97);
  border: 1px solid var(--gold-dim); border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); }
.searchbar[hidden] { display: none; }
.searchbar input { width: min(240px, 46vw); min-height: 34px; padding: 0 10px; background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font-family: var(--mono); font-size: 16px; }
.searchbar input:focus { border-color: var(--gold); outline: none; }
.searchbar .sc { min-width: 4.2em; text-align: center; color: var(--muted); font-size: .8rem; font-family: var(--mono); white-space: nowrap; }
.searchbar button { min-height: 34px; min-width: 34px; padding: 0 8px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; }
.searchbar button:hover { border-color: var(--gold); color: var(--gold-2); }
@media (min-width: 901px) { .chat:not([hidden]) ~ .searchbar { right: calc(var(--chat-w, 340px) + 26px); } }
@media (pointer: coarse) { .searchbar input, .searchbar button { min-height: 44px; min-width: 44px; } }

/* 表單式規則編輯器 */
.modebar { display: inline-flex; margin: 0 0 8px; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; }
.modebar button { min-height: 32px; padding: 0 14px; border: 0; background: var(--panel); color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer; }
.modebar button[aria-pressed="true"] { background: rgba(200, 164, 90, .16); color: var(--gold-2); }
.rules { display: grid; gap: 8px; margin: 0 0 6px; }
.rules[hidden] { display: none; }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto auto; gap: 6px; align-items: center; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.rule.raw { grid-template-columns: minmax(0, 1fr) auto; }
.rule.bad { border-color: #7a5a30; }
.rule input, .rule select { min-width: 0; min-height: 36px; padding: 0 8px; background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font-family: var(--mono); font-size: 14px; }
.rule select { font-family: var(--sans); font-size: .84rem; }
.rule input:focus, .rule select:focus { border-color: var(--gold); outline: none; }
.rule .rule-raw { color: var(--muted); }
.rule .rule-aux { min-height: 36px; padding: 0 10px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 4px; color: var(--text); font-size: .84rem; cursor: pointer; }
.rule .rule-del { min-height: 36px; min-width: 36px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--panel); color: var(--muted); cursor: pointer; }
.rule .rule-del:hover { border-color: #9a4a3a; color: #ff9b8a; }
.rule .rule-msg { grid-column: 1 / -1; color: #e6b567; font-size: .8rem; line-height: 1.4; }
.rule .rule-msg:empty { display: none; }
.rule-empty { padding: 10px 4px; color: var(--faint); font-size: .88rem; }
.rule-add { justify-self: start; min-height: 36px; padding: 0 14px; border-radius: 4px; border: 1px dashed var(--gold-dim); background: none; color: var(--gold-2); font: inherit; font-size: .88rem; cursor: pointer; }
.rule-add:hover { background: rgba(200, 164, 90, .08); }
/* 觸發：左清單、右詳細欄位、下測試 */
#automation.settings { width: min(760px, calc(100vw - 24px)); }
.trg { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(0, 1.7fr); gap: 10px; }
.trg-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.trg-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; padding: 4px; background: #0b0d10; border: 1px solid var(--line-2); border-radius: 4px; }
.trg-item { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 8px; text-align: left; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--text); font-family: var(--mono); font-size: 13px; cursor: pointer; }
.trg-item:hover { background: var(--panel); }
.trg-item.sel { border-color: var(--gold); background: rgba(200, 164, 90, .1); }
.trg-item.off .trg-pat { color: var(--faint); text-decoration: line-through; }
.trg-item.bad .trg-pat::before { content: '⚠ '; color: #e6b567; }
.trg-pat { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trg-tag { flex: none; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--muted); font-family: var(--sans); font-size: .74rem; }
.trg-btns { display: flex; gap: 6px; }
.trg-btns button { flex: 1; white-space: nowrap; }
.trg-btns button, .trg-test button { min-height: 32px; padding: 0 10px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 4px; color: var(--text); font-size: .84rem; cursor: pointer; }
.trg-detail { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.settings label.trg-row, .trg-row { display: grid; grid-template-columns: 3em minmax(0, 1fr); align-items: center; justify-content: stretch; gap: 6px; margin: 0; font-size: .88rem; }
.trg-row > span { white-space: nowrap; color: var(--muted); }
.trg-row input[type=text] { min-width: 0; width: 100%; min-height: 34px; padding: 0 8px; background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; font-family: var(--mono); font-size: 14px; }
.trg-row input:focus { border-color: var(--gold); outline: none; }
.trg-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-left: calc(3em + 6px); font-size: .86rem; }
.trg-opts select { min-height: 32px; background: #0b0d10; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; }
.trg-chk { display: inline-flex !important; align-items: center; gap: 4px; margin: 0 !important; white-space: nowrap; }
.trg-test { margin-top: 10px; }
.settings .trg-test .trg-row, .trg-test .trg-row { grid-template-columns: minmax(0, 1fr) auto; }
.trg-test button { white-space: nowrap; }
.trg-result { margin-top: 6px; font-size: .86rem; line-height: 1.6; }
.trg-result .yes { padding: 4px 8px; margin-bottom: 4px; border-left: 3px solid var(--gold); background: rgba(200, 164, 90, .06); }
.trg-result .no { color: var(--muted); }
.auto-help { margin: 6px 0 10px; font-size: .86rem; line-height: 1.6; color: var(--muted); }
.auto-help summary { cursor: pointer; color: var(--gold-2); }
.auto-help ul { margin: 4px 0; padding-left: 1.2em; }
@media (max-width: 600px) { .trg { grid-template-columns: 1fr; } .trg-opts { padding-left: 0; } }
@media (max-width: 560px) { .rule { grid-template-columns: minmax(0, 1fr) auto; } .rule .rule-val { grid-column: 1 / -1; grid-row: 2; } }
@media (pointer: coarse) { .rule input, .rule select, .rule .rule-aux, .rule .rule-del, .rule-add, .modebar button { min-height: 44px; } }

.chat-foot .chat-note { flex: 1; color: var(--faint); font-size: .78rem; line-height: 1.4; }

/* 官網即時狀態與公告 */
.live { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 26px 0 0; color: var(--muted); font-size: .95rem; }
.live[hidden] { display: none; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #6fbf7a; box-shadow: 0 0 0 4px rgba(111, 191, 122, .15); }
.live.stale .dot { background: var(--faint); box-shadow: none; }
.live b { color: var(--gold-2); font-weight: 600; font-family: var(--mono); }
.notices[hidden] { display: none; }
.notice-list { margin: 28px 0 0; padding-left: 1.4em; display: grid; gap: 14px; max-width: 46em; }
.notice-list li { padding-left: 6px; line-height: 1.8; }
.notice-list li::marker { color: var(--gold); font-family: var(--serif); }

/* 戰鬥對手血條（Char.Combat）：輸入列正上方的一條，比狀態列粗、有底色，打字時就看得到 */
.enemy { display: grid; grid-template-columns: auto auto 1fr auto; gap: 0 10px; align-items: center; padding: 7px 12px;
  background: rgba(196, 71, 47, .12); border-top: 1px solid #7a3a30; font-size: .9rem; }
.enemy[hidden] { display: none; }
.enemy .en-label { color: #ff9b8a; letter-spacing: .12em; font-weight: 600; }
.enemy .en-name { color: #f3e6dc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14em; }
.enemy .vt { position: relative; height: 12px; border-radius: 6px; background: #1d222a; overflow: hidden; }
.enemy .vt i { position: absolute; left: 0; top: 0; bottom: 0; transition: width .35s ease; }
.enemy .vt .eff { background: #4a3232; }
.enemy .vt .cur { background: #d9604c; }
.enemy .en-pct { font-family: var(--mono); color: #ffb4a6; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .enemy .vt i { transition: none; } }

/* 地圖 */
.mappanel { flex: none; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); }
.mappanel[hidden] { display: none; }
.mp-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.mp-head b { color: var(--gold-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-head span { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.mp-head .mp-layer { color: var(--faint); }
.mp-head button { margin-left: auto; min-width: 30px; min-height: 30px; border: 0; background: none; color: var(--muted); cursor: pointer; }
#mpSvg { display: block; width: 100%; height: 140px; background: #0b0d10; border: 1px solid var(--line); border-radius: 4px; }
#mpSvg .edge { stroke: #4a5260; stroke-width: 2; }
#mpSvg .stub { stroke: #4a5260; stroke-width: 2; stroke-dasharray: 3 3; }
#mpSvg .room { fill: #1d222a; stroke: #5b6474; stroke-width: 1.5; }
#mpSvg .room.cur { fill: var(--gold); stroke: var(--gold-2); }
#mpSvg .ud { fill: var(--gold-2); font-size: 10px; }
.mp-note { margin: 6px 0 0; color: var(--faint); font-size: .78rem; }
.mp-note[hidden] { display: none; }
/* 快捷鍵的方向鍵：這個房間沒有的出口變暗（還是可以按） */
.quick button.noexit { opacity: .35; }
@media (pointer: coarse) { .mp-head button { min-width: 44px; min-height: 44px; } }
/* 人物狀態（狀態列第二行）與身上物品面板 */
.vstats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 16px; color: var(--muted); font-size: .8rem; }
.vstats[hidden] { display: none; }
.vstats b { margin-left: 4px; color: var(--text); font-family: var(--mono); font-weight: 400; }
.vstats .low b { color: #ff9b8a; }
.itempanel { padding: 4px 8px 8px; }
.itempanel[hidden] { display: none; }
.itempanel .mp-head { margin: 0; align-items: center; }
.ip-list { flex: 1; list-style: none; margin: 4px 0 0; padding: 0; overflow-y: auto; min-height: 0; font-size: .86rem; }
.ip-list li { display: flex; align-items: baseline; gap: 6px; }
.ip-list button { flex: 1; min-width: 0; padding: 3px 4px; border: 0; border-radius: 3px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.ip-list button:hover { background: rgba(200, 164, 90, .1); }
.ip-list .ipn { color: var(--muted); font-family: var(--mono); font-size: .8rem; }
.ip-list .ipeq { color: var(--gold-2); font-size: .74rem; white-space: nowrap; }
.ip-list .ip-empty { color: var(--faint); padding: 6px 4px; }
#mpSvg .label { fill: #a29f95; font-size: 10px; text-anchor: middle; }
#mpSvg .label.cur { fill: var(--gold-2); font-weight: 600; }
#mpSvg .ghost { fill: none; stroke: #3a414d; stroke-width: 1; stroke-dasharray: 2 2; }

/* 門派詳細介紹 sects.html */
.toc-links { margin: 18px 0 0; line-height: 2; color: var(--muted); }
.toc-links a { white-space: nowrap; }
.sect-detail { margin: 10px 0; border: 1px solid var(--line-2); border-radius: 6px; background: #0b0d10; }
.sect-detail summary { cursor: pointer; padding: 10px 14px; color: var(--text); }
.sect-pre { margin: 0; padding: 4px 14px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 14px; line-height: 1.7; color: var(--text); }
.card h3 a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.req-table td:first-child { white-space: nowrap; }
.sect-detail .table-wrap { margin: 0 14px; }
.sect-detail .note { margin: 10px 14px 14px; }
