/* 【门】M1 前端样式
   移动端优先：375px 起，全部流式宽度，禁止任何固定 px 宽与横向溢出。
   深色底来自 spec 的 #08080C，OLED 上顺带省电（设计文档 §13.5.6）。 */

:root {
  --gold: #E0BD4A;
  --gold-line: #C9A96E;
  --red: #B91C1C;
  --red-dark: #7F1D1D;
  --blue: #3B82F6;
  --blue-dark: #2563EB;
  --bg: #08080C;
  --bg-soft: #0F0F14;
  --card: #101017;
  --text: #F5F5F5;
  --muted: #9CA3AF;
  --dim: #6B7280;
  --green: #16A34A;
  --amber: #CA8A04;
  --line: rgba(201, 169, 110, 0.35);
  --radius: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  word-break: break-word;
}

body { min-height: 100dvh; }

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px calc(140px + env(safe-area-inset-bottom));
}

/* ---------- 通用 ---------- */
.gate-card {
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #0B0B11, #08080C);
  padding: 22px 18px;
  margin: 22px 0;
  box-shadow: 0 0 0 1px rgba(224, 189, 74, 0.06), 0 10px 30px rgba(0, 0, 0, 0.6);
}
.gate-card.red { border-color: var(--red); box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.15), 0 10px 30px rgba(0, 0, 0, 0.6); }

.title-lg { font-size: 30px; letter-spacing: 6px; color: var(--gold); font-weight: 700; margin: 0; }
.title-en { font-size: 10px; letter-spacing: 4px; color: var(--red); margin-top: 2px; }
.rule { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 13px; }
.verse { font-size: 12px; color: var(--red); font-style: italic; margin-top: 2px; }
.verse-cn { font-size: 13px; color: var(--gold); }
.gate-mark { font-size: 11px; letter-spacing: 3px; color: var(--gold); margin-top: 14px; }

.heading { font-size: 17px; color: var(--gold); font-weight: 600; margin: 0 0 4px; }
.sub { font-size: 14px; color: var(--red); margin-bottom: 4px; }

/* ---------- 表单 ---------- */
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--gold); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  font-size: 16px;                 /* iOS 聚焦不缩放 */
  font-family: inherit;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(201, 169, 110, 0.3);
  background: #0A0A0F;
  color: var(--text);
  outline: none;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); }
.field textarea { min-height: 84px; line-height: 1.7; }

button {
  font-family: inherit;
  font-size: 16px;
  min-height: 44px;                /* 触摸目标 */
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--gold-line);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}
button:active { background: rgba(224, 189, 74, 0.12); }
button.primary { background: rgba(224, 189, 74, 0.14); }
button.danger { border-color: var(--red); color: #FCA5A5; }
button:disabled { opacity: 0.45; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row button { flex: 1 1 auto; }

/* ---------- 天赋卡 ---------- */
.talent-card { border-radius: var(--radius); padding: 18px; border: 2px solid var(--gold); background: #0B0B11; }
.talent-card.F { border-color: var(--red); }
.talent-label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.talent-name { font-size: 20px; color: var(--text); margin: 2px 0 8px; font-weight: 600; }
.talent-tier { font-size: 34px; font-weight: 800; line-height: 1.1; color: var(--gold); }
.talent-card.F .talent-tier { color: var(--red); }
.talent-effect { font-size: 15px; color: var(--text); }
.talent-cost { font-size: 13px; color: #FCA5A5; margin-top: 6px; }

/* ---------- 副本卡 ---------- */
.dungeon-card { border: 1px solid var(--gold-line); border-radius: var(--radius); padding: 16px; background: #0B0B11; margin-top: 14px; }
.dungeon-name { font-size: 19px; font-weight: 600; }
.stars { color: var(--gold); letter-spacing: 2px; }
.kv { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.tagline { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* ---------- 叙事流 ---------- */
#stream { margin-top: 10px; }
.turn-block { margin: 18px 0; }
.turn-head { font-size: 12px; color: var(--dim); letter-spacing: 1px; margin-bottom: 8px; }
.turn-user {
  border-left: 2px solid var(--blue);
  padding: 6px 10px;
  margin: 10px 0 14px;
  color: #DBEAFE;
  font-size: 15px;
  background: rgba(59, 130, 246, 0.06);
  border-radius: 0 8px 8px 0;
}
.narration { color: #E5E7EB; font-size: 16px; margin: 8px 0; }
.dialogue { margin: 8px 0; font-size: 16px; }
.dialogue .who { color: var(--gold); }
.dialogue .say { color: var(--text); }
.system-line { color: var(--blue); font-size: 14px; margin: 8px 0; }
.scene-line { color: var(--gold-line); font-size: 14px; margin: 8px 0; }
.delta-line { color: var(--dim); font-size: 12px; margin-top: 8px; }

/* ---------- 弹幕 ---------- */
.danmaku { margin-top: 12px; border-top: 1px dashed rgba(107, 114, 128, 0.35); padding-top: 8px; }
.dm { font-size: 13px; line-height: 1.6; }
.dm .n { margin-right: 6px; }
.dm.collapsed { display: none; }
.dm-toggle { font-size: 12px; color: var(--dim); margin-top: 4px; }

/* ---------- 顶部状态条 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  margin: 0 -14px; padding: 8px 14px;
  background: rgba(8, 8, 12, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(201, 169, 110, 0.18);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
#topbar .clock { color: var(--gold); font-weight: 600; }
#topbar .sep { color: #374151; }
#topbar .spacer { flex: 1 1 auto; }
.stat { display: inline-flex; gap: 3px; align-items: baseline; }
.stat b { font-weight: 600; }

/* ---------- 菜单栏 ---------- */
.menubar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.menubar button { font-size: 13px; min-height: 34px; padding: 5px 12px; border-radius: 999px; border-color: rgba(201, 169, 110, 0.35); color: var(--muted); }
.menubar button.on { color: var(--gold); border-color: var(--gold); }

/* ---------- 输入栏 ---------- */
#inputbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(8, 8, 12, 0.75), #08080C 40%);
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}
#inputbar .inner { max-width: 720px; margin: 0 auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: 0 0 auto; font-size: 13px; min-height: 34px; padding: 5px 12px; border-radius: 999px; border-color: rgba(201, 169, 110, 0.3); color: var(--muted); }
.row { display: flex; gap: 8px; align-items: flex-end; }
#input {
  flex: 1 1 auto; min-width: 0;
  font-size: 16px; font-family: inherit; line-height: 1.6;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid rgba(201, 169, 110, 0.3);
  background: #0A0A0F; color: var(--text); outline: none;
  resize: none; max-height: 120px; overflow-y: auto;
}
#input:focus { border-color: var(--gold); }
#send { flex: 0 0 auto; padding: 10px 18px; border-radius: 12px; }

/* ---------- 面板（全屏 sheet，手机优先） ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 4, 8, 0.75);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .body {
  width: 100%; max-width: 720px; max-height: 88dvh; overflow-y: auto;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  animation: slideup 160ms ease-out;
}
@keyframes slideup { from { transform: translateY(18px); opacity: 0.6 } to { transform: none; opacity: 1 } }
.sheet h3 { margin: 0 0 10px; font-size: 16px; color: var(--gold); font-weight: 600; }
.sheet .close { position: sticky; top: 0; float: right; font-size: 13px; min-height: 34px; padding: 4px 12px; }

.panel-white {
  background: #FFFFFF; color: #111827; border: 2px solid var(--blue);
  border-radius: 10px; padding: 14px;
}
.panel-white .t { color: var(--blue-dark); font-size: 13px; font-weight: 700; }
.panel-white .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.panel-white .k { font-size: 11px; color: #6B7280; }
.panel-white .v { font-size: 20px; font-weight: 700; }
.panel-white hr { border: 0; border-top: 1px solid #E5E7EB; margin: 10px 0; }
.panel-white .slot { font-size: 13px; margin: 4px 0; }

.rowline { display: flex; gap: 8px; font-size: 14px; padding: 6px 0; border-bottom: 1px solid rgba(107, 114, 128, 0.15); }
.rowline .lb { color: var(--muted); flex: 0 0 auto; min-width: 62px; }
.rowline .vl { flex: 1 1 auto; }

/* ---------- 结算 ---------- */
.settle-grade { font-size: 56px; font-weight: 800; line-height: 1; color: var(--gold); }
.settle-grade.F { color: var(--red); }
.settle-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 5px 0; border-bottom: 1px solid rgba(107, 114, 128, 0.15); }
.settle-row .k { color: var(--muted); }
.settle-row .v { text-align: right; }

/* ---------- 死亡 ---------- */
.death { text-align: center; padding: 40px 16px; }
.death .big { font-size: 30px; letter-spacing: 8px; color: var(--red); font-weight: 700; }
.death .lines { margin: 22px 0; color: #FCA5A5; font-size: 14px; line-height: 2.1; }

/* ---------- toast / 错误 ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(150px + env(safe-area-inset-bottom));
  background: rgba(185, 28, 28, 0.95); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: 90vw; z-index: 60; display: none;
}
.center-block { text-align: center; padding: 40px 0; }

/* ---------- 微信等内置浏览器提示 ---------- */
.warnbar {
  margin: 14px 0; padding: 10px 12px;
  border: 1px solid var(--amber);
  border-radius: 10px;
  background: rgba(202, 138, 4, 0.1);
  color: #FDE68A; font-size: 14px; line-height: 1.65;
}

/* ---------- 顶栏小按钮 ---------- */
#topbar .mini {
  min-height: 28px; padding: 2px 10px; font-size: 12px;
  border-radius: 999px; border-color: rgba(201, 169, 110, 0.3); color: var(--muted);
}

/* ---------- 存档列表 ---------- */
.saverow {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid rgba(107, 114, 128, 0.15);
}
.saverow .si { flex: 1 1 auto; min-width: 0; }
.saverow .sn { font-size: 15px; color: var(--text); }
.saverow .sd { font-size: 12px; color: var(--dim); line-height: 1.5; }
.saverow .sb { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.saverow .sb button { min-height: 34px; padding: 4px 12px; font-size: 13px; }

/* ---------- 弹幕折叠 ---------- */
.dm.hide { display: none; }

/* ---------- 流式光标 ---------- */
.cursor::after { content: '▍'; color: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0 } }

/* ---------- 桌面微调（先移动后桌面） ---------- */
@media (min-width: 720px) {
  #app { padding: 0 20px calc(150px + env(safe-area-inset-bottom)); }
  .gate-card { padding: 28px 26px; }
  .sheet { align-items: center; }
  .sheet .body { border-radius: 18px; max-height: 82dvh; }
  .saverow .sb { flex-direction: row; }
}
