/* ============================================================
   AI Town — 极简纯净主题
   纸感底色 / 墨色文字 / 单一暖色点缀 / 细边与留白
   ============================================================ */

:root {
  --paper: #f6f2ea;
  --paper-2: #efe9dd;
  --card: #fffdf8;
  --ink: #2b2a26;
  --ink-2: #6f6a60;
  --ink-3: #a39c90;
  --line: #e4ddcf;
  --line-strong: #d3cabb;
  --accent: #c2542f;
  --accent-soft: #f6e5dc;
  --green: #3f6f5a;
  --gold: #b4823a;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-s: 0 1px 2px rgba(43, 42, 38, .05);
  --shadow-m: 0 2px 6px rgba(43, 42, 38, .05), 0 16px 40px rgba(43, 42, 38, .07);
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: #e9e3d8;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, textarea { outline: none; }
img { max-width: 100%; display: block; }

#app {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(43, 42, 38, .04), 0 30px 80px rgba(43, 42, 38, .08);
  overflow: hidden;
}

/* ---------- 页面 ---------- */
.page {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--paper);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.page.active {
  position: relative;
  display: flex;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.page.enter-left { transform: translateX(-14px); }
.page.enter-right { transform: translateX(14px); }
.page.exit-left { transform: translateX(-14px); opacity: 0; }
.page.exit-right { transform: translateX(14px); opacity: 0; }

/* ---------- 基础元件 ---------- */
.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.display {
  margin: 0 0 14px;
  font-size: 30px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -.01em;
}
.lead {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.75;
}
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.label {
  margin: 18px 0 8px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.hint { margin: 12px 0 0; font-size: 12px; color: var(--ink-3); text-align: center; }
.empty {
  margin: 18px 0;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
  line-height: 1.8;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.985); }
.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fbf7ee;
}
.btn.primary:hover { background: #1f1e1a; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.compact { min-height: 38px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: #a3402a; border-color: #e3c9bd; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }

.link {
  background: none;
  padding: 0;
  color: var(--ink-2);
  font-size: 12.5px;
  border-bottom: 1px solid transparent;
}
.link:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
.link.strong { color: var(--accent); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .86);
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}
.pill.solid { background: var(--ink); color: #fbf7ee; border-color: var(--ink); font-weight: 550; }
.pill.quiet { background: transparent; border-color: var(--line); font-size: 11.5px; color: var(--ink-2); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  transition: background .16s ease;
}
.icon-btn:hover { background: rgba(43, 42, 38, .06); }
.icon-btn.round {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--card);
}

/* ---------- 启动 ---------- */
.splash-screen {
  align-items: center;
  justify-content: center;
  gap: 0;
  background: var(--paper);
  padding: 32px;
}
.splash-mark {
  width: 64px;
  height: 64px;
  color: var(--ink);
  margin-bottom: 26px;
  opacity: .9;
}
.splash-mark svg { width: 100%; height: 100%; }
.splash-title {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: .12em;
}
.splash-slogan {
  margin: 10px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: .04em;
}
.splash-progress {
  width: 132px;
  height: 2px;
  margin-top: 42px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.splash-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width .3s ease;
}
.splash-note { margin-top: 14px; font-size: 11px; color: var(--ink-3); letter-spacing: .08em; }

/* ---------- 引导 ---------- */
.guide-screen { justify-content: center; padding: 40px 32px; }
.guide-body { max-width: 380px; margin: 0 auto; width: 100%; }
.guide-body .display { font-size: 34px; margin-bottom: 18px; }

/* ---------- 账号入口 ---------- */
.account-gate-screen { justify-content: center; padding: 32px 24px; }
.access-gate-screen { justify-content: center; padding: 32px 24px; }
.account-gate-body { width: 100%; max-width: 380px; margin: 0 auto; }
.account-gate-body .display { font-size: 30px; margin-bottom: 14px; }
.account-gate-body .lead { margin-bottom: 24px; }
.account-gate-actions { display: flex; flex-direction: column; gap: 10px; }
.account-gate-actions[hidden] { display: none !important; }
.account-gate-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.account-gate-form[hidden] { display: none !important; }
.account-gate-form .field { margin: 0; }
.account-gate-form .field small { font-weight: 400; }
.account-gate-form .btn-col { margin-top: 4px; }
.form-error { min-height: 18px; margin: 0; color: #a3402a; font-size: 12px; }

/* ---------- 顶栏 ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  min-height: 58px;
  border-bottom: 1px solid transparent;
}
.bar-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .01em; }
.bar-space { width: 38px; }
.bar-meta {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- 测试 ---------- */
.quiz-screen { padding-bottom: 24px; }
.progress { height: 2px; background: var(--line); margin: 0 20px; border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.quiz-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px 24px 40px; }
.question {
  margin: 6px 0 26px;
  font-size: 23px;
  line-height: 1.5;
  font-weight: 620;
  letter-spacing: -.005em;
}
.options { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 14.5px;
  text-align: left;
  transition: border-color .16s ease, background .16s ease, transform .12s ease;
}
.option:hover { border-color: var(--line-strong); background: #fffefb; }
.option:active { transform: scale(.992); }
.option.selected { border-color: var(--ink); background: #fffdf7; }
.option-index {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  flex: none;
}
.option.selected .option-index { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- 结果 ---------- */
.result-screen { padding: 26px 24px 34px; }
.result-body { display: flex; flex-direction: column; align-items: center; text-align: center; }
.result-body .display { margin-top: 4px; }
.percent {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--accent);
}
.result-body .lead { max-width: 330px; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 18px; }
.tag {
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--card);
}
.dims { width: 100%; max-width: 330px; margin-top: 26px; display: flex; flex-direction: column; gap: 9px; }
.dim-row { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--ink-2); }
.dim-label { width: 42px; text-align: left; }
.dim-track { flex: 1; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.dim-fill { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.dim-num { width: 22px; text-align: right; font-family: var(--mono); color: var(--ink); }

/* ---------- 外观 ---------- */
.avatar-screen { overflow-y: auto; }
.avatar-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 10px 24px 30px;
}
.avatar-stage {
  width: 176px;
  height: 176px;
  border-radius: 24px;
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1px var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.avatar-stage canvas { image-rendering: pixelated; display: block; }
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--paper-2);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.seg {
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}
.seg.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-s); font-weight: 550; }
.stepper { display: flex; align-items: center; gap: 20px; }
.stepper #avatar-label { min-width: 64px; text-align: center; font-size: 14px; font-weight: 550; }
.presets { display: flex; gap: 9px; overflow-x: auto; max-width: 100%; padding: 2px; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.preset {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preset.active { border-color: var(--ink); }
.preset canvas { width: 56px; height: 56px; image-rendering: pixelated; }
.avatar-mini {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 6px;
}
.avatar-mini canvas { width: 64px; height: 64px; image-rendering: pixelated; }

/* ---------- 表单 ---------- */
.info-screen { overflow-y: auto; }
.form-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 24px 34px;
}
.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  margin-bottom: 16px;
}
.field-label { font-size: 12px; color: var(--ink-2); }
.field input, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 14.5px;
  resize: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(43, 42, 38, .05); }
.counter {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.field textarea + .counter { bottom: 12px; }

/* ---------- 广场 ---------- */
.town-screen { overflow: hidden; }
.town-hud {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.town-hud > * { pointer-events: auto; }
.hud-right { display: flex; align-items: center; gap: 6px; }
.hud-right .pill { padding: 0 9px; }
.net-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 111, 90, .14);
  font-size: 0;
  margin-left: 3px;
}
.net-dot.off { background: var(--accent); box-shadow: 0 0 0 3px rgba(194, 84, 47, .16); }

.town-map {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #a8cf99;
  min-height: 0;
  touch-action: manipulation;
}
.town-map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  inset: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}
.town-feed {
  position: absolute;
  left: 12px;
  top: 50px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 78%;
  pointer-events: none;
}
.event {
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(255, 253, 248, .94);
  border: 1px solid rgba(43, 42, 38, .06);
  box-shadow: var(--shadow-s);
  font-size: 11.5px;
  color: var(--ink-2);
  animation: rise .22s ease;
}
.event.ritual { color: var(--accent); }
.event.friend { color: var(--green); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.town-banner {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translate(-50%, -6px);
  z-index: 5;
  display: none;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 40px);
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #fbf7ee;
  box-shadow: var(--shadow-m);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.town-banner.show { display: flex; animation: rise .25s ease; }
.banner-label {
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 253, 248, .16);
  font-size: 10px;
  letter-spacing: .06em;
}
.banner-desc { color: rgba(251, 247, 238, .7); overflow: hidden; text-overflow: ellipsis; }

.town-help {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255, 253, 248, .9);
  border: 1px solid rgba(43, 42, 38, .06);
  box-shadow: var(--shadow-s);
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
  pointer-events: none;
}

.town-side {
  position: absolute;
  right: 12px;
  bottom: 92px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 253, 248, .92);
  border: 1px solid rgba(43, 42, 38, .08);
  box-shadow: var(--shadow-s);
  font-size: 11.5px;
  color: var(--ink);
  backdrop-filter: blur(8px);
  transition: transform .16s ease;
}
.round-btn:active { transform: scale(.94); }
.round-btn.accent { background: var(--ink); color: #fbf7ee; border-color: var(--ink); font-size: 17px; }

.action-wheel {
  position: absolute;
  right: 12px;
  bottom: 150px;
  z-index: 6;
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 253, 248, .96);
  border: 1px solid rgba(43, 42, 38, .07);
  box-shadow: var(--shadow-m);
  backdrop-filter: blur(10px);
}
.action-wheel.open { display: grid; }
.wheel-item {
  width: 58px;
  padding: 8px 0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 15px;
  color: var(--ink);
}
.wheel-item:hover { background: var(--paper-2); }
.wheel-item small { font-size: 10px; color: var(--ink-2); }

.tabbar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(246, 242, 234, .96);
  backdrop-filter: blur(12px);
  z-index: 7;
}
.tab {
  position: relative;
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-3);
  transition: color .16s ease;
}
.tab span { position: relative; }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
}
.dot {
  position: absolute;
  top: 14px;
  right: 26%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: none;
}
.dot.show { display: block; }

/* ---------- 聊天 ---------- */
.chat-screen, .feed-screen, .profile-screen, .chat-window-screen { overflow: hidden; }
.tabs-line {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-line::-webkit-scrollbar { display: none; }
.tabs-line .seg { border: 1px solid transparent; }
.tabs-line .seg.active { border-color: var(--line); }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 12px 20px; }
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 10px;
  border-radius: 13px;
  text-align: left;
  transition: background .14s ease;
}
.chat-item:hover { background: rgba(43, 42, 38, .035); }
.chat-item + .chat-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 62px;
  right: 10px;
  height: 1px;
  background: var(--line);
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  overflow: hidden;
}
.chat-avatar.icon { font-size: 17px; color: #fbf7ee; }
.chat-avatar .initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbf7ee;
  font-size: 15px;
  font-weight: 600;
}
.chat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-top { display: flex; align-items: baseline; gap: 8px; }
.chat-top b { font-size: 14px; font-weight: 600; }
.chat-top small { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.chat-tag {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--paper-2);
  color: var(--ink-3);
  font-size: 9.5px;
  font-style: normal;
  font-weight: 500;
  vertical-align: 1px;
}
.chat-preview {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-unread {
  position: absolute;
  right: 8px;
  bottom: 12px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-window-screen { background: var(--paper); }
/* 聊天顶栏固定：消息区独立滚动，返回键永远在顶部 */
#page-chat-window > .bar {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: 0 0 auto;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
#page-chat-window > .messages { min-height: 0; }
#cw-more { flex: none; }
#cw-more[hidden], .group-name-field[hidden] { display: none !important; }
.cw-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cw-meta .bar-title { font-size: 15px; }
.cw-status { margin: 0; font-size: 11px; color: var(--ink-3); }
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 82%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-who { font-size: 10.5px; color: var(--ink-3); padding-left: 4px; }
.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--ink); color: #fbf7ee; border-color: var(--ink); }
.msg.typing .bubble { color: var(--ink-3); font-size: 12.5px; }
.system {
  align-self: center;
  margin: 6px 0;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}
.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(246, 242, 234, .96);
  backdrop-filter: blur(10px);
}
.composer.inline { padding: 0 0 14px; border: 0; background: none; }
.composer input {
  flex: 1;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  font-size: 14px;
}
.composer input:focus { border-color: var(--ink-3); }

/* ---------- 动态 / 公告板 ---------- */
.feed-compose {
  display: flex;
  gap: 8px;
  padding: 6px 16px 14px;
}
.feed-compose input {
  flex: 1;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  font-size: 13.5px;
}
.feed-scroll { flex: 1; overflow-y: auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.note {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-s);
}
.note-head { display: flex; align-items: baseline; gap: 8px; }
.note-head b { font-size: 13px; font-weight: 600; }
.note-head small { margin-left: auto; font-size: 10.5px; color: var(--ink-3); }
.note-text { margin: 7px 0 0; font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.note-actions { display: flex; gap: 14px; margin-top: 10px; }
.board-list { display: flex; flex-direction: column; gap: 9px; max-height: 46vh; overflow-y: auto; }

/* ---------- 我的 ---------- */
.profile-scroll { flex: 1; overflow-y: auto; padding: 6px 20px 32px; display: flex; flex-direction: column; gap: 18px; }
.profile-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px 0 4px; }
.profile-avatar {
  width: 92px;
  height: 92px;
  border-radius: 22px;
  background: var(--paper-2);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line);
  margin-bottom: 8px;
}
.profile-avatar canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.profile-name { margin: 0; font-size: 20px; font-weight: 650; }
.profile-type { margin: 0; font-size: 12px; color: var(--accent); letter-spacing: .04em; }
.profile-bio { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); max-width: 300px; }
.profile-birthday { margin: 2px 0 0; font-size: 11.5px; }

.stats {
  display: flex;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  overflow: hidden;
}
.stat { flex: 1; padding: 13px 0; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font-size: 18px; font-weight: 600; font-family: var(--mono); }
.stat span { font-size: 10.5px; color: var(--ink-3); letter-spacing: .06em; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 14px 16px 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.friend-list { display: flex; flex-direction: column; gap: 2px; }
.friend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 2px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.friend-row:last-child { border-bottom: 0; }
.friend-row.clickable:hover { background: rgba(43, 42, 38, .03); }
.friend-row b { font-size: 13px; font-weight: 550; }
.friend-row .muted, .friend-row .small { margin-left: auto; }
.friend-row .link + .link { margin-left: 10px; }
.gift-list { display: flex; flex-direction: column; gap: 6px; }
.gift-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.gift-row:last-child { border-bottom: 0; }
.gift-row b { display: block; font-size: 12.5px; font-weight: 550; }
.gift-row small { font-size: 10.5px; color: var(--ink-3); }
.gift-icon { font-size: 18px; width: 24px; text-align: center; color: var(--accent); flex: none; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(32, 29, 24, .32);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.mask.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(32, 29, 24, .16);
  transform: translateY(14px);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  overflow: hidden;
}
.mask.open .sheet { transform: none; }
.sheet.narrow { max-width: 460px; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
}
.sheet-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.sheet-x {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-body { padding: 4px 20px calc(22px + env(safe-area-inset-bottom)); overflow-y: auto; }

.person { display: flex; align-items: center; gap: 14px; padding: 4px 0 10px; }
.person h3 { margin: 0 0 3px; font-size: 17px; font-weight: 620; }
.person .muted { margin: 0 0 6px; font-size: 12px; }
.portrait {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--paper-2);
  flex: none;
}
.portrait canvas { width: 76px; height: 76px; image-rendering: pixelated; }
.memory {
  margin: 6px 0 2px;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
}
.invite-text { margin: 6px 0 18px; font-size: 15px; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  font-size: 12.5px;
  color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}
.chip:hover { border-color: var(--ink-3); background: #fffefb; }

.map-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.map-item:last-child { border-bottom: 0; }
.map-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--ink-2);
  flex: none;
}
.map-body { display: flex; flex-direction: column; gap: 1px; }
.map-body b { font-size: 13.5px; font-weight: 550; }
.map-body small { font-size: 11px; color: var(--ink-3); }

.gift-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px; }
.gift {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.gift:hover { border-color: var(--line-strong); }
.gift.selected { border-color: var(--ink); background: #fffdf7; }
.gift b { font-size: 13px; font-weight: 600; margin-top: 4px; }
.gift small { font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }
.gift .gift-icon { font-size: 20px; width: auto; }
#gift-note {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  font-size: 13.5px;
  margin-bottom: 12px;
}
.wish-list { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.wish {
  margin: 0;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.6;
}
.wish small { display: block; margin-top: 4px; font-size: 10px; color: var(--ink-3); }
.photo { width: 100%; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 12px; }

/* ---------- 提示与转场 ---------- */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translate(-50%, -6px);
  z-index: 60;
  max-width: min(86vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(43, 42, 38, .94);
  color: #fbf7ee;
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #8f3a22; }

.transition {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.transition.active { opacity: 1; }

/* ---------- 小屏适配 ---------- */
@media (max-width: 420px) {
  .display { font-size: 27px; }
  .question { font-size: 20.5px; }
  .splash-title { font-size: 29px; }
  .tab { font-size: 12.5px; }
  .round-btn { width: 43px; height: 43px; }
}

@media (min-width: 561px) {
  #app { min-height: 100dvh; }
}

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

/* ===== 微信式聊天：媒体 / 表情 / 账号 ===== */
.emoji-panel { display: none; border-top: 1px solid var(--line); background: var(--card); padding: 10px 12px; max-height: 210px; overflow-y: auto; }
.emoji-panel.open { display: block; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.emoji-row button { width: 36px; height: 36px; font-size: 21px; line-height: 1; border-radius: 8px; }
.emoji-row button:hover { background: var(--paper-2); }
.emoji-row.sticker button { width: 46px; height: 46px; font-size: 30px; }
.emoji-title { font-size: 10.5px; color: var(--ink-3); letter-spacing: .08em; margin: 2px 0 6px; }
.chat-composer .icon-btn { width: 34px; height: 34px; font-size: 17px; color: var(--ink-2); flex: none; }
.msg .media-img, .msg .media-video { max-width: min(240px, 68vw); border-radius: 12px; border: 1px solid var(--line); display: block; }
.msg .media-video { background: #000; }
.bubble.sticker { font-size: 54px; line-height: 1.05; background: none; border: 0; padding: 2px 0; }
.bubble.emoji { font-size: 26px; line-height: 1.2; }
.msg-time { align-self: center; margin: 8px 0 2px; font-size: 10.5px; color: var(--ink-3); }
.field.tight { margin-bottom: 8px; }
.field.tight input { min-height: 40px; padding: 9px 12px; font-size: 13.5px; }
.account-switch { margin-top: 8px; }
#account-name-line { margin: 0 0 4px; }

/* ===== 附近语音 ===== */
.voice-panel { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: 0 14px 42px rgba(40,38,32,.18); display: none; }
.voice-panel.open { display: block; }
.voice-panel .panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.voice-panel .panel-head h3 { margin: 0; font-size: 14px; }
.voice-panel .hint { margin: 8px 0 0; }
#town-voice.live { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#voice-mic.on { background: var(--ink); color: var(--paper); }
#voice-audio { display: none; }

/* ===== 响应式：手机铺满 / 桌面加宽 ===== */
@media (max-width: 600px) {
  #app { max-width: none; width: 100%; box-shadow: none; }
  .display { font-size: clamp(24px, 7.2vw, 30px); }
  .question { font-size: clamp(19px, 5.2vw, 23px); }
  input, textarea, select { font-size: 16px; } /* 避免 iOS 聚焦时自动放大 */
  .field.tight input { font-size: 16px; }
  .tabbar { height: 60px; }
  .round-btn { min-width: 44px; min-height: 44px; }
  .voice-panel { left: 8px; right: 8px; bottom: 70px; }
  .msg .media-img, .msg .media-video { max-width: min(220px, 62vw); }
}

@media (min-width: 900px) {
  body { background: #e4ded2; }
  #app { max-width: 1120px; min-height: 100vh; margin: 0 auto; box-shadow: 0 0 0 1px rgba(43,42,38,.05), 0 24px 70px rgba(43,42,38,.10); }
  .page, .page.active { min-height: 100vh; }
  .guide-body, .quiz-body, .result-body, .avatar-body, .form-body { width: 100%; max-width: 680px; margin-left: auto; margin-right: auto; }
  .profile-scroll { width: 100%; max-width: 820px; margin: 0 auto; }
  .chat-list { width: 100%; max-width: 820px; margin: 0 auto; }
  #page-chat-window .bar,
  #page-chat-window .messages,
  #page-chat-window .emoji-panel,
  #page-chat-window .composer { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
  .feed-compose, .feed-scroll { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
  .town-hud { left: 24px; right: 24px; top: 16px; }
  .town-help { left: 24px; bottom: 18px; }
  .town-feed { left: 24px; }
  .voice-panel { left: 50%; right: auto; transform: translateX(-50%); width: min(720px, calc(100% - 48px)); bottom: 78px; }
  .display { font-size: clamp(30px, 3.3vw, 40px); }
  .question { font-size: clamp(22px, 2.4vw, 30px); }
  .tabbar { max-width: none; margin: 0; width: 100%; }
}

/* ===== 电玩城 ===== */
.arcade-modal { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; padding: 12px; background: rgba(24, 21, 17, .58); }
.arcade-modal.open { display: grid; }
.arcade-card { width: min(420px, 100%); max-height: 94dvh; overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 18px; box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.arcade-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.arcade-head h2 { margin: 0; font-size: 18px; letter-spacing: .04em; }
.arcade-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.arcade-tabs .seg { flex: 1; padding: 7px 0; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--ink-2); }
.arcade-tabs .seg.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.arcade-stage { position: relative; display: flex; justify-content: center; margin: 6px 0 10px; }
.arcade-stage canvas { width: 100%; max-width: 320px; height: auto; border-radius: 10px; background: #22211e; image-rendering: pixelated; }
.grid2048 { width: 100%; max-width: 320px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px; background: #cbbda1; border-radius: 10px; }
.grid2048 .cell { display: grid; place-items: center; border-radius: 8px; background: #e6dcc9; color: #5a4a36; font-weight: 700; font-size: clamp(16px, 5vw, 24px); }
.grid2048 .cell[data-v="2"] { background: #eee4d2; }
.grid2048 .cell[data-v="4"] { background: #e8d4b0; }
.grid2048 .cell[data-v="8"] { background: #e2b47a; color: #fff8ec; }
.grid2048 .cell[data-v="16"] { background: #d9975a; color: #fff8ec; }
.grid2048 .cell[data-v="32"] { background: #cc7b4e; color: #fff8ec; }
.grid2048 .cell[data-v="64"] { background: #b85f3e; color: #fff8ec; }
.grid2048 .cell[data-v="128"], .grid2048 .cell[data-v="256"], .grid2048 .cell[data-v="512"], .grid2048 .cell[data-v="1024"], .grid2048 .cell[data-v="2048"] { background: #8f3f2c; color: #fff8ec; }
.arcade-dpad { position: absolute; left: 0; right: 0; bottom: -8px; display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); justify-content: center; gap: 4px; }
.arcade-dpad button { background: rgba(255,253,248,.9); border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.arcade-dpad button[data-dir="up"] { grid-column: 2; grid-row: 1; }
.arcade-dpad button[data-dir="left"] { grid-column: 1; grid-row: 2; }
.arcade-dpad button[data-dir="down"] { grid-column: 2; grid-row: 2; }
.arcade-dpad button[data-dir="right"] { grid-column: 3; grid-row: 2; }
.arcade-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 13px; font-weight: 600; }
.arcade-foot .btn { padding: 6px 14px; }
#arcade-canvas + .arcade-dpad { bottom: -4px; }

/* ===== 建筑内部 ===== */
.interior-modal { position: fixed; inset: 0; z-index: 92; display: none; place-items: center; padding: 12px; background: rgba(24, 21, 17, .62); }
.interior-modal.open { display: grid; }
.interior-card { width: min(760px, 100%); max-height: 94dvh; overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 18px; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.interior-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.interior-head h2 { margin: 0; font-size: 18px; letter-spacing: .04em; }
#interior-canvas { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); image-rendering: pixelated; background: #d9c3a0; }
.interior-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.interior-actions .btn { min-width: 92px; }

/* ===== 室内移动控制 ===== */
.interior-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.interior-dpad { display: grid; grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(2, 34px); gap: 4px; }
.interior-dpad button { border: 1px solid var(--line); border-radius: 7px; background: var(--card); font-size: 13px; touch-action: none; }
.interior-dpad button[data-dir="w"] { grid-column: 2; grid-row: 1; }
.interior-dpad button[data-dir="a"] { grid-column: 1; grid-row: 2; }
.interior-dpad button[data-dir="s"] { grid-column: 2; grid-row: 2; }
.interior-dpad button[data-dir="d"] { grid-column: 3; grid-row: 2; }
#interior-use { min-width: 96px; }
.arcade-modal { z-index: 96; }

/* ===== 整页建筑内部 ===== */
.building-page { background: #d9c3a0; overflow: hidden; align-items: center; }
#building-canvas { display: block; width: 100%; max-width: 1120px; max-height: calc(100dvh - 130px); object-fit: contain; image-rendering: pixelated; margin-top: 58px; }
.building-hud { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: linear-gradient(rgba(43,42,38,.55), rgba(43,42,38,0)); color: #fbf7ef; }
.building-hud .pill { background: rgba(255,253,248,.92); color: var(--ink); flex: none; }
.building-title h2 { margin: 0; font-size: 16px; letter-spacing: .04em; }
.building-title p { margin: 2px 0 0; font-size: 11px; opacity: .82; }
.building-controls { position: absolute; left: 0; right: 0; bottom: 18px; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 18px; pointer-events: none; }
.building-controls > * { pointer-events: auto; }
body.inside-building { background: #d9c3a0; }
body.inside-building #app { max-width: none; box-shadow: none; }
@media (min-width: 900px) {
  #building-canvas { margin-top: 64px; }
  .building-controls { padding: 0 32px; }
}

/* 整页室内：画布下方延续地板纹理 */
.building-page { background-color: #d9c3a0; background-image: repeating-linear-gradient(0deg, rgba(60,45,30,.10) 0 2px, transparent 2px 40px), repeating-linear-gradient(90deg, rgba(60,45,30,.10) 0 2px, transparent 2px 60px); }
.building-page::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(43,42,38,.10)); }

/* 整页室内：画布按窗口比例铺满 */
.building-page { height: 100dvh; min-height: 100dvh; justify-content: flex-start; padding: 0; }
#building-canvas { width: 100%; height: auto; max-height: none; margin-top: 0; }

/* ===== 整页建筑：户外同款 HUD + 聊天抽屉 ===== */
.building-hud { align-items: flex-start; justify-content: space-between; }
.building-hud-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.building-hud-right .pill { background: rgba(255,253,248,.9); color: var(--ink); font-size: 12px; padding: 0 9px; }
.building-side { position: absolute; right: 14px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); z-index: 8; display: flex; flex-direction: column; gap: 8px; }
.building-side .round-btn { background: rgba(255,253,248,.94); color: var(--ink); }
.building-side .building-use { background: var(--accent); color: #fff; }
.building-use { width: 62px; height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-width: 2px; }
.building-use .use-e { font-size: 18px; font-weight: 800; line-height: 1; font-family: "Courier New", monospace; }
.building-use .use-label { font-size: 10px; line-height: 1; font-weight: 700; }
.building-chat-panel { position: absolute; right: 14px; bottom: 150px; z-index: 7; width: min(330px, calc(100vw - 28px)); max-height: 48dvh; display: none; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 40px rgba(40,38,32,.2); overflow: hidden; }
.building-chat-panel.open { display: flex; }
.building-chat-panel header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.building-chat-list { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.building-chat-line { display: flex; gap: 6px; align-items: baseline; line-height: 1.45; }
.building-chat-line b { color: var(--ink-2); font-size: 11px; flex: none; }
.building-chat-line span { word-break: break-word; }
.building-chat-line.mine span { color: var(--accent); }
.building-chat-compose { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.building-chat-compose input { flex: 1; min-width: 0; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--card); font-size: 16px; }
.building-chat-compose .btn { padding: 0 14px; }
@media (max-width: 600px) {
  .building-hud { padding: 8px 10px; }
  .building-title h2 { font-size: 14px; }
  .building-title p { display: none; }
  .building-side { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); right: 10px; }
  .building-use { width: 64px; height: 64px; }
  .building-chat-panel { right: 8px; bottom: 84px; width: calc(100vw - 16px); max-height: 45dvh; }
}

/* 整页室内：画布绝对铺满视口 */
#building-canvas { position: absolute; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; object-fit: fill; }

/* 室内互动提示固定在左下，不再挡住人物 */
.building-hint { position: absolute; left: 14px; bottom: 92px; z-index: 6; padding: 7px 12px; border-radius: 9px; background: rgba(255,253,248,.95); border: 1px solid var(--line); font-size: 12px; color: var(--ink); pointer-events: none; }
.building-hint:empty { display: none; }
@media (max-width: 600px) {
  .building-hint { left: 10px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); font-size: 12px; }
}

/* 广场手机 E 互动按钮 */
.town-use { width: 62px; height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-width: 2px; background: var(--accent); color: #fff; }
.town-use .use-e { font-size: 18px; font-weight: 800; line-height: 1; font-family: "Courier New", monospace; }
.town-use .use-label { font-size: 10px; line-height: 1; font-weight: 700; }
@media (max-width: 600px) {
  .town-side { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
}

/* 实时地图 */
.live-map-wrap { padding: 10px 14px 16px; border-top: 1px solid var(--line); }
#live-map { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; background: #8cc27c; image-rendering: pixelated; }
#live-map-caption { text-align: center; margin-top: 6px; }

/* AI 替身离线汇报 */
.ai-report-sheet { max-height: 70dvh; }
.ai-report-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; line-height: 1.5; }
.ai-report-item:last-child { border-bottom: 0; }
.ai-report-time { flex: none; width: 48px; color: var(--ink-2); font-size: 11px; font-family: "Courier New", monospace; }
.ai-report-text { flex: 1; }
.ai-report-scene { color: var(--accent); font-size: 11px; margin-left: 6px; }

/* 群聊 */
.chat-group-actions { display: flex; gap: 8px; padding: 8px 16px 0; flex-wrap: wrap; }
.chat-group-actions .btn { min-height: 34px; }

/* 群聊成员选择 / 群信息 */
.group-name-field { margin-bottom: 12px; }
.group-pick-list { display: flex; flex-direction: column; gap: 7px; max-height: 38dvh; overflow-y: auto; padding: 2px 0 4px; }
.group-pick {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 9px;
  border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.35);
  cursor: pointer; text-align: left;
}
.group-pick input { width: 17px; height: 17px; flex: none; accent-color: var(--accent); }
.group-pick-main { flex: 1; min-width: 0; }
.group-pick-name { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.group-pick-sub { display: block; margin-top: 1px; font-size: 10.5px; color: var(--ink-3); }
.group-pick-empty { padding: 20px 4px; text-align: center; color: var(--ink-3); font-size: 12px; }
.group-avatar, .group-info-mark {
  flex: none; display: grid; place-items: center; border-radius: 50%;
  width: 36px; height: 36px; color: #fff; font-size: 13px; font-weight: 700;
}
.group-avatar.small { width: 28px; height: 28px; font-size: 11px; }
.group-info-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; border-bottom: 1px solid var(--line); }
.group-info-mark { width: 48px; height: 48px; font-size: 20px; border-radius: 14px; background: var(--accent); }
.group-info-name { margin: 0; font-size: 17px; }
.group-info-note { margin: 10px 0 12px; padding: 8px 10px; border-radius: 9px; background: rgba(0,0,0,.035); color: var(--ink-2); font-size: 12px; line-height: 1.6; }
.group-member-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; max-height: 36dvh; overflow-y: auto; padding: 2px 0 4px; }
.group-member-card { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; text-align: center; }
.group-member-card .group-avatar { width: 40px; height: 40px; }
.group-member-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--ink-2); }
.group-member-tag { font-size: 9px; color: var(--ink-3); }
.group-info-actions { margin-top: 14px; }
@media (max-width: 390px) { .group-member-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* 管理员模式 */
.admin-body { min-height: 100dvh; background: var(--paper); }
.admin-shell { width: 100%; max-width: 920px; margin: 0 auto; padding: 40px 24px 64px; }
.admin-login { max-width: 420px; margin: 12vh auto 0; }
.admin-login .display { font-size: 34px; margin: 10px 0 12px; }
.admin-login .lead { margin-bottom: 24px; }
.admin-login-form { display: flex; flex-direction: column; gap: 12px; }
.admin-login[hidden], .admin-dashboard[hidden] { display: none !important; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.admin-head .display { font-size: 30px; margin: 6px 0 0; }
.admin-status { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.admin-stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.35); }
.admin-stat span { display: block; color: var(--ink-3); font-size: 11px; }
.admin-stat b { display: block; margin-top: 4px; font-size: 20px; font-variant-numeric: tabular-nums; }
.admin-panel { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.35); }
.admin-title { margin: 0 0 14px; font-size: 17px; }
.admin-toggle { display: flex; gap: 11px; align-items: flex-start; padding: 11px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.admin-toggle input { width: 18px; height: 18px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.admin-toggle span { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.admin-toggle small { color: var(--ink-3); font-size: 11.5px; line-height: 1.55; }
.admin-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.admin-field-grid .field { margin: 0; }
.admin-field-grid .field:first-child { grid-column: 1 / -1; }
.admin-actions { margin-top: 14px; flex-wrap: wrap; }
.admin-actions .btn { flex: 0 1 auto; }
.admin-saved { margin: 8px 0 0; color: #3d7a4a; font-size: 12px; }
.admin-saved[hidden] { display: none !important; }
.admin-note { margin-top: 14px; }
@media (max-width: 640px) {
  .admin-shell { padding: 26px 16px 48px; }
  .admin-status { grid-template-columns: 1fr 1fr; }
  .admin-field-grid { grid-template-columns: 1fr; }
  .admin-field-grid .field:first-child { grid-column: auto; }
}


