:root {
  --stone: #f3efe7;
  --stone-2: #e6e0d5;
  --ink: #22303f;
  --ink-2: #4a5a6b;
  --blue: #2f5d8a;
  --blue-deep: #1e3f63;
  --gold: #a8843f;
  --line: rgba(34, 48, 63, 0.14);
  --shadow: 0 18px 48px rgba(30, 45, 62, 0.18);
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;

  /* HUD 设计令牌：所有浮层共用同一套底色/描边/圆角/投影，避免各写各的数值 */
  --hud-bg: rgba(250, 248, 243, 0.92);
  --hud-bg-strong: rgba(250, 248, 243, 0.96);
  --hud-line: rgba(34, 48, 63, 0.14);
  --hud-radius: 14px;      /* 容器级：阶段条、面板 */
  --hud-radius-sm: 12px;   /* 控件级：顶部工具按钮 */
  --hud-radius-pill: 999px;/* 胶囊级：动作条、音乐条 */
  --hud-shadow: 0 10px 28px rgba(30, 45, 62, 0.16);
  --hud-shadow-soft: 0 6px 18px rgba(30, 45, 62, 0.12);
  --hud-blur: blur(10px);

  /* 右下角「操作舱」：音乐条在最下，互动钮叠在它上方，间距由变量推导，不再各写一个魔法数 */
  --dock-right: 22px;
  --dock-bottom: 22px;
  --dock-gap: 10px;
  --music-h: 44px;         /* 30 圆钮 + 上下 6 内边距 + 2 边框 */
  --interact-size: 104px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: #0e141b; font-family: var(--sans); color: var(--ink); overflow: hidden; }
canvas#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ── HUD ── */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
/* 准星与「点击」提示已移除：画面保持干净，走近物件点击即可 */
#crosshair, #interact-hint { display: none; }

#stage-bar {
  position: absolute; left: 22px; top: 22px; width: 232px;
  background: var(--hud-bg); border: 1px solid var(--hud-line); border-radius: var(--hud-radius);
  padding: 10px 14px; box-shadow: var(--hud-shadow); backdrop-filter: var(--hud-blur);
  transition: width .18s ease, padding .18s ease;
}
#stage-bar.collapsed { width: 186px; padding: 8px 12px; }
#stage-bar.collapsed #stage-dots, #stage-bar.collapsed #task-list { display: none; }
.stage-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; cursor: pointer; }
#stage-bar.collapsed .stage-head { margin-bottom: 0; }
#stage-no { font-size: 12px; color: var(--gold); letter-spacing: .08em; font-weight: 700; }
#stage-name { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--blue-deep); }
#stage-dots { display: flex; gap: 5px; margin-bottom: 10px; }
#stage-dots i { flex: 1; height: 4px; border-radius: 2px; background: rgba(47,93,138,.18); }
#stage-dots i.done { background: var(--blue); }
#stage-dots i.cur { background: var(--gold); }
#task-list { list-style: none; margin: 0; padding: 0; max-height: 42vh; overflow: auto; }
#task-list li { display: flex; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--ink-2); padding: 4px 0; }
#task-list li .tick { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid rgba(47,93,138,.35); flex: 0 0 auto; margin-top: 2px; position: relative; }
#task-list li.done .tick { background: var(--blue); border-color: var(--blue); }
#task-list li.done .tick::after { content: "✓"; color: #fff; font-size: 10px; position: absolute; inset: 0; display: grid; place-items: center; }
#task-list li.done span.txt { color: rgba(74,90,107,.55); text-decoration: line-through; }
#task-list li.optional .txt::after { content: "（可选）"; font-size: 11px; color: var(--gold); }
#task-list li .prog { color: var(--gold); font-size: 12px; }

#wear-indicator { position: absolute; left: 22px; bottom: 22px; display: flex; gap: 8px; flex-wrap: wrap; max-width: 40vw; }
#wear-indicator .chip {
  background: rgba(250,248,243,.92); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--ink); box-shadow: 0 6px 18px rgba(30,45,62,.1);
}
#wear-indicator .chip.off { opacity: .38; }

.hud-tools { position: absolute; right: 22px; top: 22px; display: flex; gap: 8px; }
.hud-tools button {
  background: var(--hud-bg-strong); border: 1px solid var(--hud-line); border-radius: var(--hud-radius-sm);
  padding: 8px 14px; min-height: 38px; font-size: 13px; color: var(--blue-deep); box-shadow: var(--hud-shadow-soft);
  transition: background .15s ease, transform .12s ease;
}
.hud-tools button:hover { background: #fff; transform: translateY(-1px); }
.hud-tools button b { color: var(--gold); }

#action-bar { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 70vw; }
#action-bar button {
  background: var(--hud-bg-strong); border: 1px solid var(--hud-line); border-radius: var(--hud-radius-pill);
  padding: 11px 20px; min-height: 42px; font-size: 14px; color: var(--blue-deep); box-shadow: var(--hud-shadow);
  transition: transform .15s, background .15s;
}
#action-bar button:hover { transform: translateY(-2px); background: #fff; }
#action-bar button.primary { background: var(--blue); color: #f7f5ee; border-color: var(--blue); }
#action-bar button.warn { border-color: #b45d4e; color: #96382b; }

#music-mini { position: absolute; right: calc(var(--dock-right) + env(safe-area-inset-right, 0px)); bottom: calc(var(--dock-bottom) + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 8px;
  min-height: var(--music-h); background: var(--hud-bg); border: 1px solid var(--hud-line); border-radius: var(--hud-radius-pill); padding: 6px 12px 6px 6px; box-shadow: var(--hud-shadow); backdrop-filter: var(--hud-blur); }
#music-mini button { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--blue); color: #fff; font-size: 14px; flex: 0 0 auto; transition: transform .15s ease, background .15s ease; }
#music-mini button:hover { background: var(--blue-deep); transform: scale(1.06); }
#music-mini button:active { transform: scale(.94); }
#music-now { font-size: 12px; color: var(--ink-2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#net-status { position: absolute; right: 22px; top: 74px; font-size: 12px; color: #96382b; background: rgba(250,248,243,.9); padding: 5px 10px; border-radius: 8px; }

/* ── 屏幕 / 卡片 ── */
.screen { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(14,20,27,.55); backdrop-filter: blur(6px); overflow: auto; padding: 24px; }
.card {
  width: min(520px, 92vw); background: linear-gradient(180deg, #fbf9f4, #f1ece2);
  border: 1px solid rgba(255,255,255,.6); border-radius: 18px; padding: 34px 36px; box-shadow: var(--shadow);
}
.card.wide { width: min(680px, 94vw); }
.card-mark { color: var(--gold); font-size: 22px; letter-spacing: .2em; }
.card h1, .card h2 { font-family: var(--serif); font-size: 26px; margin: 10px 0 18px; color: var(--blue-deep); font-weight: 600; }
.disc-list { margin: 0 0 18px; padding-left: 18px; color: var(--ink-2); font-size: 14px; line-height: 1.85; }
.disc-list b { color: var(--ink); }
.agree { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 10px 0 18px; }
.agree input { width: 16px; height: 16px; accent-color: var(--blue); }
button.primary {
  width: 100%; padding: 13px 0; border: none; border-radius: 10px; background: var(--blue);
  color: #f8f6ef; font-size: 15px; letter-spacing: .06em; box-shadow: 0 10px 24px rgba(47,93,138,.28);
}
button.primary:disabled { background: #b9c3cc; box-shadow: none; cursor: not-allowed; }
.tiny { font-size: 11.5px; color: rgba(74,90,107,.75); line-height: 1.6; margin-top: 12px; }
.err { color: #a4402f; font-size: 12.5px; min-height: 18px; margin: 6px 0; }

/* ── 主菜单 ── */
.menu-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 34px; width: min(1080px, 94vw); align-items: start; }
.menu-left { background: rgba(250,248,243,.95); border-radius: 20px; padding: 34px 36px; box-shadow: var(--shadow); }
.brand .brand-he { display: block; font-family: var(--serif); color: var(--gold); letter-spacing: .12em; font-size: 14px; }
.brand h1 { font-family: var(--serif); font-size: 32px; margin: 6px 0 4px; color: var(--blue-deep); letter-spacing: .04em; }
.brand p { margin: 0 0 22px; font-size: 13px; color: var(--ink-2); }
.menu-block { margin-bottom: 20px; }
.menu-block h3 { font-size: 12px; letter-spacing: .14em; color: var(--gold); margin: 0 0 10px; font-weight: 700; }
.menu-btn {
  display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 16px; margin-bottom: 9px; transition: border-color .15s, transform .15s;
}
.menu-btn:hover { border-color: var(--blue); transform: translateX(3px); }
.menu-btn b { display: block; font-size: 15px; color: var(--blue-deep); font-family: var(--serif); }
.menu-btn span { font-size: 12px; color: var(--ink-2); }
.gender-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gender-btn { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); }
.gender-btn.on { background: var(--blue); color: #f7f5ee; border-color: var(--blue); }
.view-btn { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); }
.view-btn.on { background: var(--blue); color: #f7f5ee; border-color: var(--blue); }
.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-btn { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: left; transition: .15s; }
.mode-btn:hover { border-color: var(--blue); background: #f7fafd; }
.mode-btn b { display: block; font-size: 14px; color: var(--blue-deep); margin-bottom: 4px; font-family: var(--serif); }
.mode-btn span { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }
.menu-block.inline { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 0; }
.link-btn { background: none; border: none; color: var(--blue); font-size: 13px; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; }
.menu-right { display: flex; flex-direction: column; gap: 14px; }

/* ── 语言切换 / 简化后的登录注册卡 ── */
.lang-btn {
  background: rgba(250,248,243,.94); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; font-size: 13px; color: var(--blue-deep); cursor: pointer;
  font-family: inherit; box-shadow: 0 8px 22px rgba(30,45,62,.12); transition: background .15s;
}
.lang-btn:hover { background: #fff; }
.lang-btn.ghost { background: transparent; box-shadow: none; border-color: rgba(30,45,62,.18); padding: 6px 12px; font-size: 12px; }
/* 三语切换：EN / עברית / 中文 并排，当前语言高亮 */
.lang-switch { display: inline-flex; align-items: stretch; }
.lang-switch .lang-btn { border-radius: 0; border-right-width: 0; padding: 6px 10px; font-size: 12px; line-height: 1.2; }
.lang-switch .lang-btn:first-child { border-radius: 10px 0 0 10px; }
.lang-switch .lang-btn:last-child { border-radius: 0 10px 10px 0; border-right-width: 1px; }
.lang-switch .lang-btn.active { background: var(--blue-deep); color: #fff; border-color: var(--blue-deep); }
.lang-switch .lang-btn.active:hover { background: var(--blue-deep); }
/* 游戏 HUD 的三语切换压在深色场景上，透明底（ghost）会看不见：这里改回实底，非当前项也是浅底深字 */
.hud-tools .lang-switch .lang-btn,
.hud-tools .lang-switch .lang-btn.ghost {
  background: rgba(250,248,243,.94); border: 1px solid var(--line); color: var(--blue-deep);
  box-shadow: 0 8px 22px rgba(30,45,62,.12); padding: 8px 12px; font-size: 12.5px; line-height: 1.2;
}
.hud-tools .lang-switch .lang-btn:hover { background: #fff; }
.hud-tools .lang-switch .lang-btn.active,
.hud-tools .lang-switch .lang-btn.active.ghost {
  background: var(--blue-deep); border-color: var(--blue-deep); color: #fff;
  box-shadow: 0 8px 22px rgba(30,45,62,.22);
}
.menu-right-top { display: flex; justify-content: flex-end; }
.auth-card { width: min(430px, 92vw); }
.ts-slot { margin: 10px 0 2px; min-height: 86px; display: flex; justify-content: center; align-items: flex-start; }
/* 联系我们表单 */
.cf-label { display: block; font-size: 12.5px; color: var(--ink-2); margin: 0 0 10px; }
.cf-label input, .cf-label textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  font-family: inherit; font-size: 14px; line-height: 1.5; resize: vertical;
}
.cf-label input:focus, .cf-label textarea:focus { outline: 2px solid rgba(30,63,99,.25); outline-offset: 1px; }
#cf-msg { min-height: 96px; }
#cf-ts { min-height: 0; margin: 4px 0 8px; }
.auth-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.auth-head h2 { margin: 8px 0 6px; }
.auth-sub { font-size: 13px; color: var(--ink-2); line-height: 1.65; margin: 0 0 16px; }
.auth-note { font-size: 12px; color: var(--ink-2); line-height: 1.6; margin: 12px 0 2px; }
.auth-note.hidden { display: none; }
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.account-box { background: rgba(250,248,243,.95); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.acc-title { font-size: 11px; letter-spacing: .14em; color: var(--gold); }
.acc-name { font-family: var(--serif); font-size: 20px; color: var(--blue-deep); margin: 4px 0 2px; }
.acc-sub { font-size: 12px; color: var(--ink-2); }
.acc-actions { margin-top: 10px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--ink-2); font-size: 12px; }
.note { background: rgba(250,248,243,.96); border-left: 3px solid var(--blue); padding: 12px 16px; border-radius: 0 10px 10px 0; box-shadow: 0 6px 18px rgba(20,30,42,.10); }
.note b { font-size: 12px; color: var(--blue-deep); letter-spacing: .06em; }
.note p { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.7; }

/* ── 表单 ── */
#auth-form label { display: block; margin-bottom: 14px; font-size: 12.5px; color: var(--ink-2); }
#auth-form input {
  display: block; width: 100%; margin-top: 6px; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; font-size: 14px; color: var(--ink); font-family: inherit;
}
#auth-form input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,93,138,.12); }

/* ── 面板 ── */
.panel {
  position: absolute; background: rgba(250, 248, 243, .97); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); backdrop-filter: blur(12px); overflow: hidden;
  display: flex; flex-direction: column;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-family: var(--serif); font-size: 17px; color: var(--blue-deep); }
.panel-head small { color: var(--gold); font-size: 12px; margin-left: 6px; font-family: var(--sans); }

#encyclopedia-panel { right: 22px; top: 74px; width: min(440px, 92vw); max-height: 74vh; }
.enc-tabs { display: flex; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.enc-tabs button { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 0; font-size: 12.5px; color: var(--ink-2); }
.enc-tabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.enc-body { overflow: auto; padding: 14px 18px 20px; }
.enc-item { border-bottom: 1px dashed var(--line); padding: 10px 0; }
.enc-item.locked { opacity: .45; }
.enc-item h4 { margin: 0 0 4px; font-size: 14px; color: var(--blue-deep); font-family: var(--serif); }
.enc-item .orig { color: var(--gold); font-size: 12px; margin-left: 6px; }
.enc-item p { margin: 3px 0; font-size: 12.5px; line-height: 1.65; color: var(--ink-2); }
.enc-item .tag { display: inline-block; font-size: 11px; color: var(--gold); border: 1px solid rgba(168,132,63,.35); border-radius: 4px; padding: 1px 5px; margin-bottom: 4px; }
.enc-item .note { font-size: 11.5px; color: #7a6a4a; background: rgba(168,132,63,.07); padding: 6px 8px; border-radius: 6px; margin-top: 6px; border: none; }

#music-panel { right: 22px; bottom: 74px; width: min(400px, 92vw); max-height: 68vh; }
.bus-controls { padding: 12px 18px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.bus-controls label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.bus-controls input { flex: 1; accent-color: var(--blue); }
.bus-controls span { width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.track-list { overflow: auto; padding: 8px 12px 14px; }
.track { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.track:hover { background: rgba(47,93,138,.06); }
.track.playing { background: rgba(47,93,138,.12); }
.track.disabled { opacity: .45; cursor: default; }
.track .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stone-2); flex: 0 0 auto; }
.track.playing .dot { background: var(--gold); }
.track .info { flex: 1; min-width: 0; }
.track .name { font-size: 13px; color: var(--ink); }
.track .meta { font-size: 11px; color: var(--ink-2); }
.track .nature { font-size: 10.5px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-2); flex: 0 0 auto; }
.track .nature.placeholder { color: #8a6b3a; border-color: rgba(168,132,63,.4); }

/* 聊天框要躲开左下角摇杆与底部动作条：抬到摇杆（22+132）之上，输入行不被压住 */
#chat-panel { left: 22px; bottom: 176px; width: 300px; height: 320px; }
#chat-log { flex: 1; overflow: auto; padding: 10px 14px; font-size: 12.5px; line-height: 1.6; }
#chat-log .msg { margin-bottom: 6px; }
#chat-log .msg b { color: var(--blue); font-weight: 600; }
.chat-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12.5px; }
.chat-input button { border: none; background: var(--blue); color: #fff; border-radius: 8px; padding: 0 14px; font-size: 12.5px; }
.chat-hint { padding: 0 10px 10px; margin-top: 0; }

#room-panel { right: 22px; top: 74px; width: 260px; }
#room-panel #room-info { padding: 12px 16px; font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.mod-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.mod-row button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 9px; font-size: 11.5px; color: var(--ink-2); }

/* ── 大厅 ── */
.lobby-wrap { width: min(1000px, 94vw); background: rgba(250,248,243,.96); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.lobby-head { display: flex; align-items: center; gap: 16px; padding: 22px 28px; border-bottom: 1px solid var(--line); }
.lobby-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; color: var(--blue-deep); }
.lobby-head p { margin: 0; flex: 1; font-size: 12.5px; color: var(--ink-2); }
.lobby-body { display: grid; grid-template-columns: 340px 1fr; gap: 0; }
.lobby-create { padding: 22px 26px; border-right: 1px solid var(--line); }
.lobby-create h3, .lobby-list h3 { font-size: 12px; letter-spacing: .12em; color: var(--gold); margin: 0 0 14px; }
.lobby-create label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--ink-2); }
.lobby-create input, .lobby-create select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: 13px; font-family: inherit; color: var(--ink);
}
.lobby-list { padding: 22px 26px; max-height: 62vh; overflow: auto; }
.room-card {
  display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}
.room-card .rc-main { flex: 1; min-width: 0; }
.room-card .rc-main b { display: block; font-size: 14px; color: var(--blue-deep); font-family: var(--serif); }
.room-card .rc-main span { font-size: 11.5px; color: var(--ink-2); }
.room-card .rc-count { font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }
.room-card button { border: none; background: var(--blue); color: #fff; border-radius: 8px; padding: 7px 14px; font-size: 12.5px; }
.room-card.locked { opacity: .6; }
.empty { color: var(--ink-2); font-size: 12.5px; }

/* ── 弹窗 → 改为右下角非遮挡式抽屉（不挡画面、不接管操作） ── */
.modal {
  position: absolute; right: 16px; top: 148px; left: auto; bottom: auto; inset: 148px 16px auto auto;
  background: none; display: block; padding: 0; backdrop-filter: none;
  z-index: 40; pointer-events: none;
}
.modal.hidden { display: none; }
/* 弹窗（读经 / 词条 / 使用说明）打开时，底部动作条、摇杆、互动键、音乐键一律让位隐藏，
   否则手机竖屏下这些按钮会压在卡片正文上（读经时正文被「Read / Play a hymn」挡住） */
body.modal-open #action-bar,
body.modal-open #btn-interact,
body.modal-open #music-mini,
body.modal-open #joystick,
body.modal-open #joy-zone { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-card {
  position: relative; pointer-events: auto;
  width: min(430px, 90vw); max-height: min(58vh, 520px); overflow: auto;
  background: linear-gradient(180deg,#fbf9f4,#f2ede3);
  border-radius: 14px; padding: 20px 22px; box-shadow: 0 12px 34px rgba(20,26,34,.26);
  border: 1px solid rgba(255,255,255,.7);
  animation: drawer-in .18s ease-out;
}
@keyframes drawer-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-card .modal-x {
  position: absolute; top: 8px; right: 10px; width: 26px; height: 26px; line-height: 1;
  border: none; background: transparent; color: #8b8477; font-size: 18px; cursor: pointer;
}
.modal-card h3 { font-family: var(--serif); font-size: 19px; color: var(--blue-deep); margin: 0 0 12px; }
.modal-card p { font-size: 13.5px; line-height: 1.9; color: var(--ink-2); margin: 6px 0; }
.modal-card .he { font-family: var(--serif); direction: rtl; text-align: right; font-size: 16px; color: var(--gold); line-height: 1.9; }
.modal-card .actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-card .actions button { flex: 1; padding: 10px 0; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 13.5px; color: var(--ink-2); }
.modal-card .actions button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.modal-card .actions button:disabled { opacity: .45; cursor: not-allowed; }
.book-view { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--stone-2); border-radius: 10px; overflow: hidden; }
.book-view > div { background: #fffdf8; padding: 16px; min-height: 190px; font-size: 13px; line-height: 2; color: var(--ink-2); }
.book-view .he-side { direction: rtl; text-align: right; font-family: var(--serif); font-size: 15px; color: var(--ink); }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.mini-grid button { padding: 12px 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 13px; color: var(--ink); }
.mini-grid button.ok { border-color: #4a7c59; background: #eef6ef; color: #35603f; }
.mini-grid button.no { border-color: #b45d4e; background: #fbeeec; color: #96382b; }
.menorah-row { display: flex; gap: 6px; align-items: flex-end; justify-content: center; padding: 12px 0; }
.menorah-row .mb { width: 30px; text-align: center; }
.menorah-row .mb button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: #fff; }
.menorah-row .mb button.lit { background: #ffcf7a; border-color: #e0a94a; box-shadow: 0 0 14px rgba(255,196,96,.6); }
.menorah-row .mb span { display: block; font-size: 10.5px; color: var(--ink-2); margin-top: 4px; }

/* ── 提示 ── */
#toast-root { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(24, 36, 50, .92); color: #f7f3e9; padding: 11px 18px; border-radius: 10px;
  font-size: 13px; line-height: 1.6; max-width: min(560px, 88vw); box-shadow: 0 12px 30px rgba(0,0,0,.25);
  animation: toastIn .32s ease-out; border-left: 3px solid var(--gold);
}
.toast.entry { border-left-color: #7fb3d5; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

#cover-eyes { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(8,10,14,.55), rgba(8,10,14,.92)); z-index: 5; pointer-events: none; transition: opacity .6s; }

#loading { position: absolute; inset: 0; background: #10161d; display: grid; place-items: center; gap: 14px; color: #e8e2d5; font-family: var(--serif); z-index: 90; }
#loading .spinner { width: 34px; height: 34px; border: 2px solid rgba(232,226,213,.25); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.locked #crosshair { border-color: rgba(255,255,255,.8); }

/* ── 响应式 ── */
@media (max-width: 900px) {
  .menu-wrap { grid-template-columns: 1fr; }
  .menu-right { flex-direction: row; flex-wrap: wrap; }
  .lobby-body { grid-template-columns: 1fr; }
  .lobby-create { border-right: none; border-bottom: 1px solid var(--line); }
  #stage-bar { width: min(280px, 46vw); top: 12px; left: 12px; padding: 10px 12px; }
  #task-list { max-height: 26vh; }
  #wear-indicator { display: none; }
  #action-bar { bottom: 14px; max-width: 94vw; gap: 6px; }
  #action-bar button { padding: 9px 14px; font-size: 13px; }
  .mode-row { grid-template-columns: 1fr; }
  #chat-panel { width: 84vw; height: 220px; bottom: 206px; left: 8vw; }
  #encyclopedia-panel, #music-panel { right: 12px; left: 12px; width: auto; }
  .book-view { grid-template-columns: 1fr; }
  .hud-tools { right: 12px; top: 12px; }
  .hud-tools button { padding: 7px 10px; font-size: 12px; }
}

/* ── 触屏操控 ── */
#touch-controls { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
/* 左下整块热区：拇指随便落在哪都能出摇杆，不必看准小圆 */
#joy-zone {
  position: absolute; left: 0; bottom: 0; width: 48%; height: 56%;
  pointer-events: auto; touch-action: none; background: transparent;
}
/* 底部按钮、音乐、阶段条要压在摇杆热区之上，否则触屏时按钮点不到 */
#action-bar, #music-mini, #stage-bar, .hud-tools { z-index: 46; }
#joystick {
  position: absolute; left: 22px; bottom: 26px; width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(247,245,238,.18), rgba(247,245,238,.08));
  border: 1px solid rgba(232,226,213,.45); pointer-events: none; touch-action: none;
  display: grid; place-items: center; opacity: .55;
  transition: opacity .16s ease;
}
#joystick.active { opacity: .95; }
#joystick-knob {
  width: 56px; height: 56px; border-radius: 50%; background: rgba(247,245,238,.85);
  border: 1px solid rgba(60,70,90,.35); box-shadow: 0 3px 10px rgba(0,0,0,.25);
  transition: transform .06s linear;
}
#btn-interact {
  position: absolute; right: calc(var(--dock-right) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--dock-bottom) + env(safe-area-inset-bottom, 0px) + var(--music-h) + var(--dock-gap));
  width: var(--interact-size); height: var(--interact-size); border-radius: 50%;
  background: linear-gradient(160deg, #3a6f9f, #24486d); color: #f7f5ee; border: 2px solid rgba(247,245,238,.75);
  font-family: var(--sans); font-size: 14px; line-height: 1.25; letter-spacing: 0; text-wrap: balance; overflow-wrap: normal; word-break: keep-all;
  padding: 8px; text-align: center;
  pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 10px 26px rgba(20, 34, 52, .34), inset 0 1px 0 rgba(255,255,255,.18);
  transition: opacity .16s ease, transform .12s ease, box-shadow .18s ease;
}
#btn-interact small { font-size: 10px; opacity: .8; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-interact:active { transform: scale(.94); }
#btn-interact:focus-visible, #music-mini button:focus-visible, .hud-tools button:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px;
}
/* 触屏下互动按钮常驻，走近物件时才亮 */
#btn-interact.dim { opacity: .45; }
#btn-interact:not(.dim) { box-shadow: 0 12px 30px rgba(20, 34, 52, .38), 0 0 0 6px rgba(168, 132, 63, .18), inset 0 1px 0 rgba(255,255,255,.22); }
@media (max-width: 720px) {
  /* 手机上把操作舱间距收紧，位置仍由同一套变量推导，不会因为有安全区/e.g. 全新机型而错位 */
  :root { --dock-right: 14px; --dock-bottom: 14px; --dock-gap: 12px; --interact-size: 88px; }
  #joystick { width: 112px; height: 112px; left: 14px; bottom: 18px; }
  #joystick-knob { width: 48px; height: 48px; }
  #btn-interact { font-size: 13px; padding: 6px; }
  /* 底部动作条抬到互动按钮之上，不再和按钮、提示条叠在一起 */
  #action-bar { bottom: 196px; width: 96vw; max-width: 96vw; gap: 6px; }
  #action-bar button { padding: 8px 12px; font-size: 12.5px; }
  #toast-root { bottom: 258px; max-width: 92vw; }
  .toast { font-size: 12.5px; max-width: 92vw; }
  /* 手机竖屏：聊天气泡抬到动作条与提示条之上，输入行永远不被按钮压住 */
  #chat-panel { bottom: 300px; width: 88vw; left: 6vw; height: 44vh; max-height: 300px; }

  /* 竖屏手机：主菜单单列、卡片铺满、说明卡不透明，避免文字压在半透明的暗背景上看不清 */
  .screen { place-items: start center; padding: 12px; }
  .menu-wrap { width: 100%; gap: 12px; }
  .menu-left { padding: 20px 18px; border-radius: 16px; }
  .brand h1 { font-size: 25px; }
  .brand p { font-size: 12.5px; margin-bottom: 16px; }
  .menu-block { margin-bottom: 16px; }
  .menu-right { flex-direction: column; gap: 10px; }
  .menu-right-top { justify-content: flex-start; }
  .menu-right-top .lang-btn { background: rgba(250,248,243,.95); }
  .account-box { padding: 14px 16px; }
  .note { padding: 10px 14px; border-radius: 0 8px 8px 0; }
  .note p { font-size: 12.5px; line-height: 1.65; }
  .mode-btn { padding: 10px 12px; }
  .link-btn { font-size: 12.5px; }
  .card { padding: 18px 16px; }

  /* 游戏 HUD：顶部工具条单独一行，阶段条压到第二行，两者不再叠在一起 */
  .hud-tools { left: 10px; right: 10px; top: 10px; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
  .hud-tools button { padding: 6px 9px; font-size: 11px; white-space: nowrap; }
  #stage-bar { top: 54px; left: 10px; right: 10px; width: auto; padding: 8px 12px; }
  #stage-bar.collapsed { width: auto; }
  #stage-name { font-size: 15px; }
  #stage-dots { margin-bottom: 7px; }
  #task-list { max-height: 22vh; }
  #task-list li { font-size: 12px; padding: 3px 0; }
  #net-status { top: 104px; right: 10px; }
  #music-now { display: none; }
  #music-mini { padding: 6px; gap: 0; }
}

/* 很窄的手机上，顶部工具条只留图标类按钮，语言切换回主菜单里做 */
@media (max-width: 520px) {
  .hud-tools .lang-btn { display: none; }
}

/* ── 墙缝里的祈祷 ── */
.prayer-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.prayer-note {
  background: #fffdf5; border: 1px solid #e2dccb; border-left: 3px solid #d9cfae;
  border-radius: 8px; padding: 10px 12px; box-shadow: 0 2px 6px rgba(60,52,32,.06);
}
.prayer-note.mine { border-left-color: var(--blue); background: #fbfdff; }
.pn-text { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.75; color: #2c2a26; white-space: pre-wrap; word-break: break-word; }
.pn-by { margin: 6px 0 0; font-size: 12px; color: #8a8272; letter-spacing: .02em; }
