:root {
  --paper: #f1eee7;
  --card: #faf8f3;
  --ink: #23211e;
  --ink-soft: #75706a;
  --cinnabar: #2e2b27;
  --cinnabar-dark: #191715;
  --gold: #8c8579;
  --gold-soft: #b7b0a2;
  --line: #e2ddd2;
  --serif: 'Noto Serif SC', 'STSong', 'SimSun', serif;
  --sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #ececec 100%);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 头部 ===== */
.hero {
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 55%, #2e2e2e 100%);
  color: #f7f0e2;
  text-align: center;
  padding: 56px 20px 60px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 120%, rgba(255,255,255,0.06), transparent 60%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; }
.hero h1 {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--gold-soft);
}
.hero .sub {
  margin-top: 12px;
  font-size: 16px;
  letter-spacing: 2px;
  color: rgba(247, 240, 226, 0.8);
}

/* ===== 布局 ===== */
.container {
  max-width: 860px;
  margin: 20px auto 0;
  padding: 0 16px 64px;
}
/* 首页有 hero：卡片上移覆盖 hero 底部，形成层叠过渡 */
.home .container { margin-top: -28px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(43, 35, 32, 0.08);
  padding: 28px;
  margin-bottom: 28px;
}
.card h2 {
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 2px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.card h2::before {
  content: '';
  display: inline-block;
  width: 6px; height: 20px;
  background: var(--cinnabar);
  border-radius: 3px;
  margin-right: 10px;
  vertical-align: -3px;
}

/* ===== 表单 ===== */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; }

input[type="text"], input[type="date"], input[type="time"] {
  font-family: var(--sans);
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(140,133,121,0.2); }

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1;
  font-family: var(--sans);
  font-size: 15px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.seg button.active {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fff;
  font-weight: 700;
}

/* ===== 按钮 ===== */
.btn {
  font-family: var(--sans);
  font-size: 15px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: 0 4px 12px rgba(43,35,32,0.12); transform: translateY(-1px); }
.btn.primary {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fff;
  font-weight: 700;
}
.btn.primary:hover { background: var(--cinnabar-dark); }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.hint { margin-top: 12px; font-size: 12.5px; color: var(--ink-soft); }

/* ===== 命盘 ===== */
.bazi-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.badge {
  background: #f1eee5;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.badge b { color: var(--cinnabar); font-family: var(--serif); }

.pillars-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  margin-bottom: 20px;
}
.pillars-table th, .pillars-table td {
  padding: 10px 6px;
  border-bottom: 1px dashed var(--line);
}
.pillars-table thead th {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 2px;
}
.pillars-table td.stem, .pillars-table td.branch {
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1.2;
  color: var(--ink);
}
.pillars-table td.branch { color: #4a3f37; }
.pillars-table td.god { font-size: 14px; color: var(--cinnabar); }
.pillars-table td.nayin { font-size: 12px; color: var(--ink-soft); }
.pillars-table td.day { color: var(--cinnabar); }

.sub-title {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 2px;
  margin: 18px 0 12px;
  color: var(--ink);
}

.elem-bars { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.elem-row { display: flex; align-items: center; gap: 12px; }
.elem-name { width: 28px; text-align: center; font-family: var(--serif); font-size: 16px; }
.elem-name.day { color: var(--cinnabar); font-weight: 700; }
.elem-bar { flex: 1; height: 16px; background: #e8e4da; border-radius: 8px; overflow: hidden; }
.elem-fill { height: 100%; border-radius: 8px; transition: width .4s ease; }
.e0 { background: #7a9484; }
.e1 { background: #9a6f66; }
.e2 { background: #a8996b; }
.e3 { background: #9c9172; }
.e4 { background: #6f8494; }
.elem-count { width: 20px; text-align: center; font-size: 14px; color: var(--ink-soft); }

.luck-row { display: flex; flex-wrap: wrap; gap: 10px; }
.luck-chip {
  flex: 1 1 92px;
  background: #f1eee5;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.luck-age { font-size: 12px; color: var(--ink-soft); }
.luck-gz { font-family: var(--serif); font-size: 22px; color: var(--cinnabar); }
.luck-nayin { font-size: 11px; color: var(--ink-soft); }

/* ===== 灵兽卡片 ===== */
.card-desc { color: var(--ink-soft); margin-bottom: 12px; }
.gold { color: var(--cinnabar); font-family: var(--serif); font-weight: 700; }
.card-wrap {
  display: flex;
  justify-content: center;
  background: #f2efe8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
#card-img { max-width: 100%; width: min(420px, 100%); border-radius: 10px; box-shadow: 0 8px 24px rgba(43,35,32,0.16); }
.card-tag { margin-top: 12px; font-size: 13px; color: var(--ink-soft); text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: center; }

/* ===== 人生模拟 ===== */
.life-top { margin-bottom: 14px; }
.life-age { font-family: var(--serif); font-size: 18px; color: var(--cinnabar); font-weight: 700; letter-spacing: 1px; }

.life-stats { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.stat-row { display: flex; align-items: center; gap: 12px; }
.stat-name { width: 34px; font-size: 13px; color: var(--ink-soft); }
.stat-bar { flex: 1; height: 12px; background: #e8e4da; border-radius: 6px; overflow: hidden; }
.stat-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cinnabar), var(--gold));
  border-radius: 6px;
  transition: width .35s ease;
}
.stat-val { width: 26px; text-align: right; font-size: 13px; color: var(--ink-soft); }

.life-log {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  background: #f6f4ee;
}
.log-item { margin-bottom: 14px; }
.log-item:last-child { margin-bottom: 0; }
.log-title { font-family: var(--serif); font-size: 14px; color: var(--cinnabar); margin-bottom: 3px; }
.log-item.period .log-title { color: var(--gold); font-weight: 700; }
.log-item.choice .log-title { color: var(--ink); font-weight: 700; }
.log-item.outcome .log-title { color: var(--cinnabar-dark); }
.log-item.ending .log-title { color: var(--cinnabar); font-size: 17px; }
.log-text { font-size: 14.5px; color: var(--ink); }

.options { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.option { flex: 1 1 140px; }

.life-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ===== 页脚 ===== */
.footer { text-align: center; padding: 28px 16px 40px; color: var(--ink-soft); font-size: 13px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%; bottom: 34px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #f7f0e2;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 99;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.hidden { display: none !important; }

/* ===== 响应式 ===== */
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; letter-spacing: 5px; }
  .pillars-table td.stem, .pillars-table td.branch { font-size: 32px; }
  .card { padding: 20px; }

  /* 游戏页：手机端给对话区腾空间、输入框放大，避免挤成一团 */
  .play-page .container { margin-top: 6px; }
  .play-page .card { padding: 14px 12px; }
  .play-card { height: auto; min-height: calc(100vh - 104px); min-height: calc(100dvh - 104px); }
  .play-page .chat-log { min-height: 320px; }
  .play-page .life-stats { gap: 5px; margin: 0 0 10px; padding-top: 8px; }
  .chat-meta { flex-wrap: wrap; }
}

/* ===== 通用：顶部小导航 ===== */
.topbar {
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 55%, #2e2e2e 100%);
  color: #f7f0e2;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-family: var(--serif); font-size: 20px; letter-spacing: 3px; color: var(--gold-soft); text-decoration: none; }
.topbar .brand small { display: block; font-family: var(--sans); font-size: 11px; letter-spacing: 1px; color: rgba(247,240,226,.6); }
.topbar a.link { color: rgba(247,240,226,.85); text-decoration: none; font-size: 14px; }
.topbar a.link:hover { color: var(--gold-soft); }

/* ===== 首页 ===== */
.hero .cta { margin-top: 22px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .cta .btn { font-size: 16px; padding: 13px 26px; border-radius: 12px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.feature .f-ico { font-size: 30px; }
.feature h3 { font-family: var(--serif); font-size: 18px; margin: 10px 0 6px; letter-spacing: 1px; }
.feature p { font-size: 13.5px; color: var(--ink-soft); }

/* ===== 模式选择 ===== */
.mode-select { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 6px 0 4px; }
.mode-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: #fff; cursor: pointer; text-align: center; transition: all .15s;
}
.mode-card:hover { box-shadow: 0 4px 12px rgba(43,35,32,.12); }
.mode-card.active { border-color: var(--cinnabar); background: #edeae1; box-shadow: 0 0 0 2px rgba(169,50,38,.15); }
.mode-card .m-ico { font-size: 26px; }
.mode-card .m-name { font-family: var(--serif); font-size: 16px; margin-top: 6px; }
.mode-card .m-desc { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; line-height: 1.4; }

/* ===== 分步向导 · 灵兽命格确认 ===== */
.beast-line { font-size: 15px; color: var(--ink); margin-bottom: 16px; line-height: 1.6; }
.beast-line .gold { font-family: var(--serif); font-size: 16px; }

/* ===== 修仙/游戏 聊天界面 ===== */
.play-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.realm-badge {
  font-family: var(--serif); font-size: 15px; color: var(--cinnabar); font-weight: 700;
  background: #f1eee5; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
}
.realm-badge b { color: var(--gold); }
.status-bar { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.status-left { display: flex; align-items: center; gap: 12px; }
.status-bar .avatar { font-size: 34px; line-height: 1; }
.status-bar .who { font-family: var(--serif); font-weight: 700; font-size: 16px; }
.status-bar .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.status-bar .realm-badge { margin-left: auto; }

.scene-box { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; border-radius: 14px; background: linear-gradient(135deg, #f6f2e8, #efe8d8); border: 1px solid var(--line); }
.scene-beast { font-size: 44px; line-height: 1; }
.scene-body { flex: 1; min-width: 0; }
.scene-realm { font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--cinnabar); letter-spacing: 1px; margin-bottom: 6px; }
.scene-text { font-size: 14px; color: var(--ink); line-height: 1.6; }
.chat-log {
  height: 70vh; min-height: 440px; overflow-y: auto; padding: 14px;
  background: #f6f4ee; border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px;
}
.bubble { max-width: 85%; padding: 12px 16px; border-radius: 14px; font-size: 16px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.bubble.ai { align-self: flex-start; background: #2a2723; color: #f5f2ea; font-family: var(--serif); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; max-width: 70%; background: linear-gradient(135deg, #f7e7c1, #efd9a0); color: #4a3408; font-family: var(--sans); border-bottom-right-radius: 4px; }
.bubble.sys { align-self: center; background: #e8e4da; color: var(--ink-soft); font-size: 12.5px; border-radius: 999px; padding: 4px 14px; font-family: var(--sans); }
.typing { align-self: flex-start; color: var(--ink-soft); font-size: 13px; padding: 8px 14px; }
.typing::after { content: '…'; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

.options { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
.btn.option { flex: 1 1 150px; background: #fff; border: 1px solid var(--gold-soft); color: var(--ink); font-size: 14px; }
.btn.option:hover { border-color: var(--cinnabar); background: #edeae1; }

.chat-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chat-toolbar .toolbar-label { font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; }
.model-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.model-btn { font-family: var(--sans); font-size: 13px; padding: 8px 18px; border: none; background: transparent; color: var(--ink-soft); cursor: pointer; transition: all .15s; }
.model-btn + .model-btn { border-left: 1px solid var(--line); }
.model-btn.active { background: linear-gradient(135deg, #33302c, #1c1a18); color: #f5f2ea; }

.chat-bar { display: flex; gap: 12px; align-items: flex-end; margin-top: 4px; }
.chat-bar textarea { flex: 1; padding: 13px 16px; font-size: 16px; line-height: 1.7; font-family: var(--sans); border: 1.5px solid var(--gold-soft); border-radius: 14px; background: #fff; color: var(--ink); resize: none; min-height: 108px; max-height: 240px; transition: border-color .15s, box-shadow .15s; }
.chat-bar textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(140,133,121,0.2); }
.chat-meta { display: flex; gap: 8px; margin-top: 10px; justify-content: center; }

/* ===== 结局卡片 ===== */
.ending-panel { text-align: center; }
.ending-title { font-family: var(--serif); font-size: 28px; color: var(--cinnabar); letter-spacing: 2px; margin-bottom: 8px; }
.ending-sub { color: var(--ink-soft); font-size: 15px; margin-bottom: 6px; }
.ending-summary { font-size: 15px; color: var(--ink); max-width: 520px; margin: 0 auto 18px; }
.timeline { text-align: left; max-width: 520px; margin: 6px auto 16px; }
.tl-item { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.tl-item:last-child { border-bottom: none; }
.tl-stage { flex-shrink: 0; font-family: var(--serif); color: var(--cinnabar); font-weight: 700; min-width: 56px; }
.tl-text { color: var(--ink); line-height: 1.6; }
#img-status { font-size: 14px; color: var(--cinnabar); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.realm-final { display: inline-block; font-family: var(--serif); font-size: 16px; color: var(--gold); font-weight: 700; background: #f1eee5; border: 1px solid var(--line); border-radius: 999px; padding: 6px 18px; margin-bottom: 16px; }

/* ===== 顶部导航 ===== */
.topbar .nav { display: flex; gap: 18px; align-items: center; }
.topbar .nav .link.active { color: var(--gold-soft); font-weight: 700; }

/* ===== 历史记录 ===== */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item { display: flex; flex-direction: column; align-items: stretch; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: all .15s; overflow: hidden; }
.history-item:hover { border-color: var(--cinnabar); box-shadow: 0 4px 12px rgba(43,35,32,.1); }
.h-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.h-chart-toggle { align-self: flex-start; margin: 0 16px 14px; font-size: 13px; padding: 6px 14px; }
.h-chart { padding: 14px 16px; border-top: 1px dashed var(--line); background: #f6f4ee; }
.h-name { font-weight: 700; font-family: var(--serif); font-size: 15px; }
.h-mode { font-size: 12px; color: var(--ink-soft); font-family: var(--sans); margin-left: 6px; font-weight: 400; }
.h-title { font-size: 13px; color: var(--cinnabar); margin-top: 3px; }
.h-right { text-align: right; flex-shrink: 0; }
.h-status { font-size: 12px; padding: 3px 12px; border-radius: 999px; display: inline-block; }
.h-status.done { background: #edeae1; color: var(--cinnabar); border: 1px solid var(--gold-soft); }
.h-status.ongoing { background: #e8e4da; color: var(--ink-soft); border: 1px solid var(--line); }
.h-time { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }

/* ===== 命格图鉴 ===== */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.gallery-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-decoration: none; color: var(--ink); transition: all .15s; overflow: hidden; }
.gallery-item:hover { border-color: var(--cinnabar); box-shadow: 0 4px 12px rgba(43,35,32,.1); transform: translateY(-2px); }
.g-emoji { font-size: 64px; line-height: 1; text-align: center; padding: 16px 0; background: #f6f4ee; border-radius: 10px; }
.g-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #f6f4ee; }
.g-name { font-family: var(--serif); font-weight: 700; font-size: 15px; }
.g-who { font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--ink-soft); margin-left: 4px; }
.g-title { font-size: 12px; color: var(--cinnabar); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 剧情成就 ===== */
.achieve-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 12px; }
.achieve-list .badge { background: #edeae1; border-color: var(--gold-soft); color: var(--cinnabar); font-family: var(--serif); font-size: 13px; }

/* ===== 沉浸式游戏页（play）：固定区 + 唯一滚动对话流 ===== */
.play-page .container { max-width: 1000px; margin-top: 12px; }
.play-page .card { padding: 22px 26px; }
.play-card { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 560px; }
.play-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.play-main { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

.play-topbar { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-shrink: 0; }
.play-topbar .back { flex-shrink: 0; padding: 6px 14px; font-size: 13px; }
.play-id { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.play-id .avatar { font-size: 32px; line-height: 1; }
.play-id .who { font-family: var(--serif); font-weight: 700; font-size: 16px; }
.play-id .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-topbar .realm-badge { flex-shrink: 0; }

.play-page .chat-log { height: auto; flex: 1 1 auto; min-height: 280px; margin-bottom: 14px; }
.play-page .life-stats { margin: 0 0 12px; padding-top: 12px; border-top: 1px solid var(--line); flex-shrink: 0; }
.play-page .options { margin-bottom: 10px; flex-shrink: 0; }
.play-page .chat-toolbar { margin-bottom: 12px; flex-shrink: 0; }
.play-page .chat-bar { flex-shrink: 0; }
.play-page .chat-meta { flex-shrink: 0; }
.play-page .footer { display: none; }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; flex-shrink: 0; }
.chip { font-family: var(--sans); font-size: 13.5px; padding: 7px 14px; border: 1px solid var(--gold-soft); border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--cinnabar); background: #edeae1; }

/* 右侧角色卡 */
.play-side { display: none; }
.role-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 18px; background: #f6f4ee; border: 1px solid var(--line); border-radius: 16px; text-align: center; }
.role-beast { font-size: 72px; line-height: 1; }
.role-title { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--ink); }
.role-day { font-size: 13px; color: var(--ink-soft); }
.role-sub { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; margin-top: 10px; }
.role-stats { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.role-realm { font-size: 13px; color: var(--cinnabar); font-weight: 700; }

@media (min-width: 900px) {
  .play-body { flex-direction: row; gap: 18px; }
  .play-side { display: block; width: 250px; flex-shrink: 0; }
  .play-page .life-stats { display: none; }
}

/* ===== AI 加载进度 ===== */
.loading { align-self: center; width: 92%; max-width: 420px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: 16px; text-align: center; box-shadow: 0 6px 18px rgba(43,35,32,.06); }
.loading-title { font-family: var(--serif); font-size: 15px; color: var(--ink); margin-bottom: 12px; letter-spacing: 1px; }
.loading-bar { height: 8px; background: #ece8de; border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.loading-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--cinnabar)); border-radius: 4px; transition: width .5s ease; }
.loading-text { font-size: 12.5px; color: var(--ink-soft); }

/* 移动端专属组件：桌面默认隐藏（移动端在下方 @media 里用 display 覆盖） */
.play-stats-mini { display: none; }
.topbar-right { display: none; }
.bottom-tab { display: none; }

/* ============================================================
 * 移动端排版改版（≤768px）——只改手机端，桌面端保持现状
 * 原则：功能逻辑不变，仅布局 / 尺寸 / 交互样式；沿用水墨配色变量
 * ============================================================ */
@media (max-width: 768px) {
  /* —— 通用尺寸 —— */
  body { line-height: 1.65; }
  .container { max-width: 100%; margin-top: 12px; padding: 0 16px 112px; }
  .home .container { margin-top: -18px; }
  .card { padding: 18px 16px; border-radius: 14px; margin-bottom: 16px; }
  .card h2 { font-size: 20px; margin-bottom: 14px; }

  /* 主按钮 52px / 普通按钮 ≥44px / 输入 48px */
  .btn.primary, .btn.big { min-height: 52px; display: flex; align-items: center; justify-content: center; }
  .btn { min-height: 44px; }
  input[type="text"], input[type="date"], input[type="time"] { height: 48px; font-size: 16px; padding: 0 14px; }
  .seg button { min-height: 48px; font-size: 16px; }

  /* 单列 */
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .features { grid-template-columns: 1fr; gap: 14px; }
  .mode-select { grid-template-columns: 1fr; gap: 10px; }

  /* —— 顶部导航：只留品牌，隐藏 ①②③ 与语言切换 —— */
  .topbar { padding: 12px 16px; }
  .topbar .brand { font-size: 18px; letter-spacing: 2px; }
  .topbar .nav { display: none; }

  /* 右上角登录/次数胶囊（auth.js 注入） */
  .nav-capsule {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 7px 14px; border-radius: 999px;
    background: rgba(247, 240, 226, 0.12);
    border: 1px solid rgba(247, 240, 226, 0.28);
    color: var(--gold-soft); font-size: 13px; text-decoration: none;
  }
  .nav-capsule:active { background: rgba(247, 240, 226, 0.2); }
  .topbar-right { display: flex; align-items: center; gap: 8px; }

  /* —— 底部三 Tab（auth.js 注入到 body） —— */
  .bottom-tab {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; align-items: stretch;
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .bottom-tab .tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 56px; text-decoration: none;
    color: var(--ink-soft); font-size: 11px; letter-spacing: 1px;
  }
  .bottom-tab .tab-item .tab-ico { font-size: 20px; line-height: 1; }
  .bottom-tab .tab-item.active { color: var(--cinnabar); font-weight: 700; }

  /* —— 首页：三世界卡片 + 第 1 步表单 —— */
  .hero { padding: 40px 16px 44px; }
  .hero h1 { font-size: 32px; letter-spacing: 5px; }
  .home-section { padding: 0; }

  /* —— 世界 / 身份 / 模板 大卡 —— */
  .mode-card { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; }
  .mode-card .m-ico { font-size: 30px; flex-shrink: 0; }
  .mode-card .m-name { margin-top: 0; font-size: 17px; }
  .mode-card .m-desc { margin-top: 2px; }

  /* —— 第 3 步：命格大字展示 + 阶段进度 + 属性预览 —— */
  .beast-show { text-align: center; padding: 20px 12px; background: #f6f4ee; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 16px; }
  .beast-show .beast-emoji { font-size: 80px; line-height: 1; }
  .beast-show .beast-title { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--cinnabar); margin-top: 10px; letter-spacing: 2px; }
  .beast-show .beast-day { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
  .beast-show .beast-verdict { font-size: 15px; color: var(--ink); margin-top: 10px; line-height: 1.8; }
  /* —— 游戏页：沉浸式三段布局（隐藏站内导航，只留 顶栏身份+1数值 / 中间滚动故事 / 底部固定选项）—— */
  body.play-page .topbar, body.play-page .bottom-tab, body.play-page .footer { display: none; }
  .play-page .container { margin-top: 0; padding: 0; max-width: 100%; height: 100dvh; display: flex; flex-direction: column; }
  .play-page .card { padding: 0; overflow: hidden; flex: 1; display: flex; flex-direction: column; min-height: 0; border-radius: 0; }
  .play-card { height: auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .play-body { flex: 1; min-height: 0; }
  .play-main { flex: 1; min-height: 0; }
  .play-topbar { flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; align-items: center; flex-shrink: 0; border-bottom: 1px solid var(--line); }
  .play-topbar .back { padding: 8px 12px; font-size: 14px; flex-shrink: 0; }
  .play-id { flex: 1 1 auto; min-width: 0; }
  .play-id .avatar { font-size: 24px; }
  .play-id .who { font-size: 14px; }
  .play-id .sub { font-size: 11px; max-width: 120px; }
  .play-stats-mini { flex: 1 1 100%; display: flex; align-items: center; }
  .play-stats-mini .ps-row { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
  .play-stats-mini .ps-row b { color: var(--cinnabar); font-weight: 700; }
  .play-topbar .realm-badge { display: none; }

  /* 视觉小说：手机三段固定高度（上半屏看戏，下半屏操作） */
  .vn-stage { height: 65dvh; min-height: 0; margin-bottom: 10px; }
  .vn-scene { height: 36dvh; flex: none; min-height: 0; }
  .vn-dialogue { height: 22dvh; flex: none; min-height: 0; max-height: none; }
  .vn-stats { height: 5dvh; min-height: 40px; flex: none; }
  .vn-char { width: 55%; max-width: 300px; height: 82%; }
  .vn-char img { max-width: 44vw; }

  /* 中间故事区：滚动；隐藏全属性条与建议 */
  .play-page .chat-log { flex: 1 1 auto; min-height: 0; padding: 14px; overflow-y: auto; }
  .play-page .life-stats, .play-page .suggestions { display: none; }
  .bubble { max-width: 88%; font-size: 15px; padding: 11px 14px; }

  /* 底部：选项固定 52px 竖排；输入框常驻（textarea+发送，和原来一样）；模型/结束一行 */
  .play-page .options { flex-direction: column; gap: 10px; flex-shrink: 0; padding: 0 14px 10px; }
  .btn.option { flex: none; width: 100%; min-height: 52px; font-size: 15px; }
  .play-page .chat-bar { gap: 10px; display: flex; flex-shrink: 0; padding: 0 14px 10px; }
  .chat-bar textarea { min-height: 48px; max-height: 120px; padding: 12px 14px; font-size: 16px; }
  .chat-bar #btn-send { min-height: 48px; padding: 0 20px; }
  .play-page .chat-meta { margin: 0 0 10px; flex-shrink: 0; }

  /* —— 结局页 —— */
  .ending-panel .actions { flex-direction: column; }
  .ending-panel .actions .btn { width: 100%; min-height: 52px; }

  /* —— 我的页 —— */
  .mine-head { display: flex; align-items: center; gap: 14px; padding: 16px; background: #f6f4ee; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 16px; }
  .mine-head .mh-avatar { font-size: 44px; line-height: 1; }
  .mine-head .mh-name { font-size: 17px; font-weight: 700; color: var(--ink); }
  .mine-head .mh-sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
  .mine-list { display: flex; flex-direction: column; }
  .mine-item { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 4px; border-bottom: 1px solid var(--line); font-size: 16px; text-decoration: none; color: var(--ink); }
  .mine-item:last-child { border-bottom: none; }
  .mine-item .mi-arrow { color: var(--ink-soft); }

  /* —— 图鉴 —— */
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .gallery-item { padding: 8px; }
  .g-emoji { font-size: 44px; padding: 10px 0; }

  /* 页脚在移动端隐藏（避免与底部 Tab 重复） */
  .footer { display: none; }
}

/* ===== 全局：属性变化飘字（桌面与移动端共用） ===== */
.float-delta {
  position: fixed; left: 50%; top: 34%;
  transform: translate(-50%, 0);
  z-index: 60; pointer-events: none;
  font-size: 15px; color: var(--cinnabar); font-weight: 700;
  background: #fff; border: 1px solid var(--gold-soft);
  padding: 8px 16px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(43, 35, 32, 0.18);
  animation: floatUp 1.4s ease forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 12px); }
  20% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -26px); }
}

/* ===== 全局：阶段进度条（桌面与移动端共用） ===== */
.realm-progress { margin: 16px 0 4px; }
.realm-progress .rp-label { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.realm-progress .rp-track { height: 8px; background: #e8e4da; border-radius: 4px; overflow: hidden; }
.realm-progress .rp-fill { height: 100%; background: linear-gradient(90deg, var(--cinnabar), var(--gold)); border-radius: 4px; transition: width .4s ease; }

/* ===== 视觉小说表现模式 ===== */
.vn-stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 320px;
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(180deg, #2a2723, #4a3f37);
  margin-bottom: 12px;
}
.vn-scene { position: relative; flex: 1 1 auto; min-height: 180px; overflow: hidden; }
.vn-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(0.88); }
.vn-char {
  position: absolute; bottom: 0;
  width: 52%; max-width: 360px;
  height: 86%;
  display: flex;
  pointer-events: none; z-index: 1;
  transition: opacity .3s, transform .3s;
}
.vn-char-left { left: 0; justify-content: flex-start; }
.vn-char-right { right: 0; justify-content: flex-end; }
.vn-char img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; }
/* 旁白：叠在场景底部，斜体浅灰，无气泡框 */
.vn-narrator {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 48px 20px 14px;
  max-height: 70%;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.7));
  font-style: italic; font-size: 14px; line-height: 1.6;
  color: #f5f2ea;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85);
  z-index: 2;
}
/* 对话区：角色名 + 台词 */
.vn-dialogue {
  padding: 12px 16px;
  background: linear-gradient(180deg, #3a3530, #2e2a26);
  color: #f5f2ea;
  border-top: 1px solid rgba(212, 175, 55, 0.22);
  min-height: 110px;
  max-height: 140px;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.vn-speaker {
  font-family: var(--serif);
  font-weight: 700; font-size: 14px;
  color: var(--gold-soft);
  margin-bottom: 6px; letter-spacing: 1px;
}
.vn-text { font-size: 16px; line-height: 1.6; text-shadow: 0 1px 3px rgba(0,0,0,0.8); flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.vn-delta { min-height: 16px; line-height: 16px; font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--gold-soft); }
/* 视觉小说·故事流：旁白 + NPC 台词 */
.vn-narration { font-style: italic; color: var(--ink-soft); margin: 0 0 12px; line-height: 1.75; }
.vn-npc { margin: 0 0 12px; line-height: 1.75; color: var(--ink); }
.vn-npc-name { color: var(--cinnabar); font-weight: 700; margin-right: 6px; }
/* 数值区：对话与选项之间，紧凑展示当前状态 */
.vn-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 12px;
  background: #1f1d1a;
  border-top: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}
.vn-stats .vs-item { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.vn-stats .vs-item b { color: var(--gold-soft); font-weight: 700; }

/* 3 步进度条：纯文字 + 连接线，当前步骤高亮（桌面与移动端共用） */
.step-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.step-bar .step { font-size: 13px; color: var(--ink-soft); white-space: nowrap; letter-spacing: 1px; }
.step-bar .step.on { color: var(--cinnabar); font-weight: 700; }
.step-bar .step-line { flex: 1; height: 1px; background: #e8e4da; }
.step-bar .step-line.done { background: var(--cinnabar); }

/* 像素图鉴缩略图行 */
.px-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.px-thumb { width: 52px; height: 52px; border-radius: 8px; border: 1px solid rgba(212,175,55,0.4); object-fit: cover; image-rendering: pixelated; }
