/* 《南锣来信》视觉规范：复古邮政档案 · 老北京胡同 */
:root {
  --paper: #F3E9D2;
  --paper-deep: #E6D5B0;
  --paper-light: #FAF4E4;
  --ink: #3B2A1E;
  --ink-soft: #6B5643;
  --brown: #5A3A22;
  --red-dark: #8B2E24;
  --vermilion: #C8402F;
  --sage: #7D8B6A;
  --sage-dark: #5E6B4E;
  --gray-paper: #A39B8B;
  --radius: 6px;
  --shadow: 0 2px 0 rgba(59,42,30,.14), 0 8px 18px rgba(59,42,30,.12);
  --ease-stamp: cubic-bezier(.2,1.6,.4,1);
  --ease-paper: cubic-bezier(.22,.8,.3,1);
  --dur: 260ms;
  --font-title: var(--yoroll-font-title, "Taipei Sans TC Beta"), "Songti SC", "Noto Serif CJK SC", serif;
  --font-body: var(--yoroll-font-body, "Source Han Sans SC"), "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --col: 480px;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: #2a2018; }
body {
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  background:
    var(--noise),
    radial-gradient(ellipse at 50% 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,.35) 100%),
    #3a2c20;
}
#game { display: none !important; }

/* 桌面两侧氛围 */
#ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-size: cover; background-position: center;
  filter: sepia(.5) blur(6px) brightness(.55);
  opacity: .6; transform: scale(1.06);
}

#app {
  position: relative; z-index: 1;
  width: 100%; max-width: var(--col); height: 100vh; height: 100dvh;
  margin: 0 auto; overflow: hidden;
  background: var(--noise), linear-gradient(180deg, var(--paper-light), var(--paper) 30%, var(--paper-deep));
  box-shadow: 0 0 0 1px rgba(59,42,30,.35), 0 0 60px rgba(0,0,0,.5);
}
/* 窗棂纹底纹 */
#app::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: .07;
  background-image:
    linear-gradient(var(--brown) 1px, transparent 1px),
    linear-gradient(90deg, var(--brown) 1px, transparent 1px),
    linear-gradient(var(--brown) 1px, transparent 1px),
    linear-gradient(90deg, var(--brown) 1px, transparent 1px);
  background-size: 64px 64px, 64px 64px, 16px 16px, 16px 16px;
  background-position: 0 0, 0 0, 8px 8px, 8px 8px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 60%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 60%);
}

.page {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: calc(12px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  animation: pageIn var(--dur) var(--ease-paper) both;
}
.page.leaving { animation: pageOut 180ms ease-in both; pointer-events: none; }
@keyframes pageIn { from { opacity: 0; transform: translateX(18px) rotate(.4deg); } to { opacity: 1; transform: none; } }
@keyframes pageOut { to { opacity: 0; transform: translateX(-14px); } }

/* ---------- 文字 ---------- */
.t-title { font-family: var(--font-title); font-weight: 700; letter-spacing: .08em; }
.t-hand { font-family: var(--font-body); color: var(--red-dark); transform: rotate(-1.5deg); }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
p { margin: 0 0 .6em; line-height: 1.75; }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 档案编号条 (code) ---------- */
.topbar {
  display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 8px;
  padding: 6px 0 10px; margin-bottom: 12px;
  border-bottom: 3px double rgba(59,42,30,.55);
  position: sticky; top: calc(-12px - var(--safe-top)); z-index: 5;
  background: linear-gradient(var(--paper-light), var(--paper-light) 85%, rgba(250,244,228,0));
}
.topbar .tb-title { min-width: 0; }
.topbar .tb-title b { display: block; font-family: var(--font-title); font-size: 17px; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .tb-title span { display: block; font-size: 11px; color: var(--ink-soft); letter-spacing: .12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid rgba(59,42,30,.55); background: var(--paper);
  color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 2px 0 rgba(59,42,30,.18);
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.score-chip {
  font-size: 12px; padding: 4px 8px; border: 1px dashed var(--brown); border-radius: 3px;
  color: var(--brown); white-space: nowrap; background: rgba(255,255,255,.3);
}

/* ---------- 按钮 ---------- */
.btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px; border: 0; cursor: pointer; user-select: none;
  font-family: var(--font-title); font-weight: 700; letter-spacing: .14em;
  transition: transform 90ms ease, filter 120ms ease, box-shadow 120ms;
  touch-action: manipulation;
}
.btn > .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(2px) scale(.99); }
.btn:disabled { cursor: not-allowed; filter: grayscale(.7) opacity(.6); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible { outline: 2px dashed var(--vermilion); outline-offset: 3px; }

/* 主按钮：CSS 兜底（朱红印章板） */
.btn-primary {
  width: 100%; min-height: 58px; font-size: 19px; color: #FFF4E6;
  background: radial-gradient(ellipse at 50% 40%, #D04A37, var(--vermilion) 55%, var(--red-dark));
  border-radius: 14px / 50%;
  box-shadow: inset 0 0 0 3px rgba(255,236,214,.18), inset 0 0 0 5px var(--red-dark), 0 3px 0 #5f1d16, 0 8px 16px rgba(139,46,36,.3);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.btn-primary:active:not(:disabled) { box-shadow: inset 0 0 0 3px rgba(255,236,214,.18), inset 0 0 0 5px var(--red-dark), 0 1px 0 #5f1d16; }
/* 次按钮：CSS 兜底（纸签） */
.btn-tag {
  min-height: 48px; font-size: 15px; color: var(--ink); padding: 0 18px;
  background: var(--noise), linear-gradient(var(--paper-light), var(--paper-deep));
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(59,42,30,.45), inset 0 0 0 4px var(--paper-light), inset 0 0 0 5px rgba(59,42,30,.35), 0 2px 0 rgba(59,42,30,.25);
}
.btn-ghost {
  min-height: 44px; font-size: 14px; color: var(--brown); background: transparent;
  border: 1px dashed rgba(90,58,34,.6); border-radius: 4px; letter-spacing: .08em; padding: 0 14px;
}

/* 生成外壳就绪后切换为 9-slice（JS 在图片加载成功后加 .skin-*）*/
body.skin-primary .btn-primary {
  background: none; box-shadow: none; border-radius: 0;
  border-style: solid; border-color: transparent;
  border-width: var(--bp-bw, 16px 40px);
  border-image: var(--bp-img) var(--bp-slice, 44 80 44 80) fill / var(--bp-bw, 16px 40px) / 0 stretch;
  padding: 0 4px;
  filter: drop-shadow(0 3px 4px rgba(139,46,36,.28));
}
body.skin-tag .btn-tag {
  background: none; box-shadow: none; border-radius: 0;
  border-style: solid; border-color: transparent;
  border-width: var(--bt-bw, 13px 11px 8px 11px);
  border-image: var(--bt-img) var(--bt-slice, 64 56 40 56) fill / var(--bt-bw, 13px 11px 8px 11px) / 0 stretch;
  min-height: 54px; padding: 0 8px; font-size: 14px; line-height: 1.2; letter-spacing: .08em;
  filter: drop-shadow(0 2px 2px rgba(59,42,30,.22));
}
/* 悬停 / 按下状态 */
.btn:hover:not(:disabled) { filter: brightness(1.06); }
body.skin-primary .btn-primary:hover:not(:disabled) { filter: drop-shadow(0 4px 6px rgba(139,46,36,.35)) brightness(1.06); }
body.skin-tag .btn-tag:hover:not(:disabled) { filter: drop-shadow(0 3px 3px rgba(59,42,30,.3)) brightness(1.04); }
.btn-ghost:hover { background: rgba(90,58,34,.06); }
.btn-ghost:active { transform: translateY(1px); background: rgba(90,58,34,.12); }
.icon-btn:hover { background: var(--paper-light); border-color: var(--vermilion); color: var(--vermilion); }
.linkish:hover { text-decoration: underline; }
.linkish:active { opacity: .7; }
.letter-item:hover:not(.locked) { background: rgba(255,251,240,.95); box-shadow: 3px 3px 0 rgba(200,64,47,.25); }
.task:hover:not(:disabled) { background: rgba(200,64,47,.05); }
.task:active:not(:disabled) { background: rgba(200,64,47,.1); }
.laowu-row:hover .bubble { border-color: var(--vermilion); }
.laowu-row:active .bubble { transform: translateY(1px); }
.dial button:hover { background: #4a3a2c; }
.envelope-wrap:hover { filter: brightness(1.04); }
.fan button:hover img { filter: drop-shadow(0 8px 12px rgba(200,64,47,.35)); }
.fan button:active { opacity: .85; }

/* ---------- 档案卡 ---------- */
.panel {
  position: relative; padding: 18px 18px 16px; margin: 0 0 14px;
  background: var(--noise), linear-gradient(170deg, var(--paper-light), #F1E4C6);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(59,42,30,.4), inset 0 0 0 5px rgba(250,244,228,.9), inset 0 0 0 6px rgba(59,42,30,.28), var(--shadow);
}
body.skin-panel .panel {
  background: none; box-shadow: none; border-radius: 0;
  border-style: solid; border-color: transparent;
  border-width: var(--pa-bw, 22px);
  border-image: var(--pa-img) var(--pa-slice, 64) fill / var(--pa-bw, 22px) / 0 stretch;
  padding: 6px 8px 4px;
  filter: drop-shadow(0 6px 10px rgba(59,42,30,.16));
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid rgba(59,42,30,.25);
}
.panel-head h3 { margin: 0; font-family: var(--font-title); font-size: 17px; letter-spacing: .1em; min-width: 0; }
.panel-head .no { font-size: 11px; color: var(--ink-soft); letter-spacing: .1em; white-space: nowrap; }

/* 旧报纸栏线说明 */
.newsprint { border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink); padding: 10px 2px 4px; margin: 0 0 12px; }
.newsprint .kicker { font-size: 11px; letter-spacing: .3em; color: var(--red-dark); margin-bottom: 4px; }
.newsprint p { font-size: 15px; text-align: justify; }

/* ---------- 首页 ---------- */
.home { padding-top: 0; padding-left: 0; padding-right: 0; }
.home-hero { position: relative; height: 42vh; min-height: 250px; max-height: 380px; overflow: hidden; }
.home-hero img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; display: block; filter: sepia(.15); }
.home-hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 46%; background: linear-gradient(rgba(243,233,210,0), var(--paper)); }
.home-hero .hero-fallback { width: 100%; height: 100%; background: linear-gradient(160deg, #cfc2a4, #a99a7c); }
.seal-title {
  position: absolute; left: 16px; top: calc(16px + var(--safe-top)); z-index: 2;
  writing-mode: vertical-rl; font-family: var(--font-title); font-weight: 700;
  font-size: clamp(38px, 11vw, 52px); letter-spacing: .12em; color: var(--ink);
  text-shadow: 0 0 12px rgba(250,244,228,.95), 0 0 2px rgba(250,244,228,1);
}
.seal-chop {
  display: inline-block; writing-mode: horizontal-tb; margin-top: 8px;
  font-size: 13px; letter-spacing: .1em; color: #FFF0E0; background: var(--vermilion);
  padding: 4px 5px; border-radius: 3px; box-shadow: inset 0 0 0 2px rgba(255,240,224,.5);
}
.archive-tag {
  position: absolute; right: 14px; top: calc(14px + var(--safe-top)); z-index: 2;
  background: rgba(250,244,228,.92); border: 1px solid rgba(59,42,30,.5); padding: 6px 10px; font-size: 11px; line-height: 1.5;
  letter-spacing: .08em; box-shadow: 2px 2px 0 rgba(59,42,30,.2);
}
.home-body { padding: 0 16px; margin-top: -40px; position: relative; z-index: 2; }
.tagline { text-align: center; font-size: 15px; letter-spacing: .1em; color: var(--brown); margin: 0 0 14px; }
.tagline::before, .tagline::after { content: "—"; margin: 0 8px; color: var(--gray-paper); }

.postmarks { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 4px; align-items: center; margin: 4px 0 10px; }
.pm {
  aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; text-align: center;
  border: 2px dashed rgba(163,155,139,.8); color: var(--gray-paper); font-size: 11px; line-height: 1.2; position: relative;
}
.pm b { font-family: var(--font-title); font-size: 18px; display: block; }
.pm.done {
  border: 2.5px solid var(--vermilion); color: var(--vermilion);
  box-shadow: inset 0 0 0 3px var(--paper-light), inset 0 0 0 4.5px var(--vermilion);
  transform: rotate(-8deg);
}
.pm.current { border-color: var(--brown); color: var(--brown); border-style: solid; animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); } }
.progress-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.progress-line a, .linkish { color: var(--red-dark); cursor: pointer; background: none; border: 0; font: inherit; padding: 6px 0; min-height: 36px; }
.meter { height: 6px; background: rgba(59,42,30,.12); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--vermilion); width: 0; transition: width .8s var(--ease-paper); }

.btn-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin: 12px 0 16px; }
.btn-row .btn { padding: 0 6px; font-size: 14px; letter-spacing: .06em; }

.laowu-row { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 10px; align-items: end; cursor: pointer; }
.avatar {
  width: 92px; height: 92px; border-radius: 50%; overflow: hidden; flex: none;
  border: 3px solid var(--paper-light); box-shadow: 0 0 0 1.5px var(--brown), var(--shadow);
  background: radial-gradient(circle at 50% 35%, #EADCBC, #CDBB95);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; transform: scale(1.15); transform-origin: 50% 20%; }
.avatar.sm { width: 64px; height: 64px; }
.avatar.lg { width: 120px; height: 120px; }
.avatar .av-fallback { width: 100%; height: 100%; display: grid; place-items: center; font-family: var(--font-title); font-size: 28px; color: var(--brown); }
.bubble {
  position: relative; background: #FFFBF0; border: 1.5px solid rgba(59,42,30,.6); border-radius: 14px;
  padding: 10px 14px 12px; font-size: 15px; line-height: 1.7; box-shadow: 2px 3px 0 rgba(59,42,30,.15); min-width: 0;
  overflow-wrap: anywhere;
}
.bubble::before {
  content: ""; position: absolute; left: -9px; bottom: 18px; width: 14px; height: 14px; background: #FFFBF0;
  border-left: 1.5px solid rgba(59,42,30,.6); border-bottom: 1.5px solid rgba(59,42,30,.6); transform: rotate(45deg);
}
.bubble .who { position: absolute; right: 10px; bottom: -12px; background: var(--paper-deep); color: var(--red-dark); font-size: 12px; padding: 1px 8px; border: 1px solid rgba(59,42,30,.4); transform: rotate(-3deg); }
.bubble.pop { animation: pop 320ms var(--ease-stamp) both; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- 谜题页 ---------- */
.scene-card {
  position: relative; margin: 6px 4px 18px; padding: 8px 8px 26px; background: #FBF7EC;
  box-shadow: var(--shadow); transform: rotate(-1deg);
}
.scene-card img, .scene-card .scene-fallback { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; filter: sepia(.12) contrast(.98); background: #cdbf9f; }
.scene-card figcaption { position: absolute; left: 12px; right: 12px; bottom: 4px; font-size: 12px; color: var(--ink-soft); letter-spacing: .1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tape { position: absolute; width: 74px; height: 20px; background: rgba(214,200,160,.75); top: -8px; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.tape.l { left: 18px; transform: rotate(-8deg); } .tape.r { right: 18px; transform: rotate(7deg); }

.form { display: grid; gap: 14px; }
.field { display: grid; grid-template-columns: 84px minmax(0,1fr) 28px; align-items: end; gap: 8px; }
.field label { font-family: var(--font-title); font-size: 15px; letter-spacing: .08em; padding-bottom: 10px; white-space: nowrap; }
.field input {
  width: 100%; min-width: 0; height: 46px; border: 0; border-bottom: 2px solid rgba(59,42,30,.6); background: transparent;
  font-family: var(--font-body); font-size: 18px; color: var(--ink); padding: 8px 4px 4px; border-radius: 0;
  background-image: linear-gradient(transparent 95%, rgba(59,42,30,.08) 95%);
}
.field input:focus { outline: none; border-bottom-color: var(--vermilion); background-color: rgba(200,64,47,.04); }
.field input::placeholder { color: rgba(107,86,67,.45); font-size: 15px; }
.field .mark { font-size: 18px; padding-bottom: 10px; text-align: center; font-weight: 700; }
.field.wrong input { border-bottom-color: var(--gray-paper); color: var(--ink-soft); }
.field.wrong .mark { color: var(--gray-paper); }
.field.right input { border-bottom-color: var(--sage); }
.field.right .mark { color: var(--sage-dark); }
.field.single { grid-template-columns: minmax(0,1fr) 28px; }
.field.single label { display: none; }
.field.single input { font-size: 24px; text-align: center; letter-spacing: .2em; }

.form-msg { min-height: 22px; font-size: 14px; text-align: center; color: var(--ink-soft); }
.form-msg.err { color: var(--red-dark); }
.actions { display: grid; grid-template-columns: minmax(0,1fr) 112px; gap: 10px; margin-top: 16px; align-items: center; }

.shake { animation: shake 420ms ease both; }
@keyframes shake { 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }

.solved-banner { display: grid; grid-template-columns: 76px minmax(0,1fr); gap: 12px; align-items: center; }
.solved-banner .answers { font-size: 14px; line-height: 1.8; }
.solved-banner .answers b { color: var(--red-dark); }

/* 转轮锁 */
.diary-lock {
  margin: 4px auto 6px; padding: 18px 14px 16px; max-width: 340px;
  background: linear-gradient(160deg, #7a2a22, #5b1f19); border-radius: 10px 14px 14px 10px;
  box-shadow: inset 6px 0 0 #4a1713, inset 0 0 0 2px rgba(255,220,180,.15), 0 8px 18px rgba(59,42,30,.3);
  position: relative;
}
.diary-lock .strap { position: absolute; left: 50%; top: -10px; transform: translateX(-50%); width: 60px; height: 14px; background: #c9a35a; border-radius: 3px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }
.dials { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; background: linear-gradient(#d8b46a, #a9833d); padding: 8px; border-radius: 8px; box-shadow: inset 0 2px 3px rgba(0,0,0,.35); }
.dial { display: grid; grid-template-rows: 36px 56px 36px; background: #2b211a; border-radius: 6px; overflow: hidden; }
.dial button { border: 0; background: #3b2e24; color: #e9d6aa; font-size: 16px; cursor: pointer; touch-action: manipulation; }
.dial button:active { background: #54412f; }
.dial .digit { display: grid; place-items: center; font-family: var(--font-title); font-size: 30px; color: #f5e7c8; background: linear-gradient(#1d1611, #3a2d22 50%, #1d1611); }
.dial .digit.roll { animation: roll 160ms ease-out; }
@keyframes roll { from { transform: translateY(-30%); opacity: .3; } }
.lock-cap { text-align: center; color: #f0dcb4; font-size: 12px; letter-spacing: .3em; margin-top: 10px; }

/* 冷却 */
.cooldown { text-align: center; padding: 6px 0 2px; }
.cooldown .cd-num { font-family: var(--font-title); font-size: 34px; color: var(--red-dark); }

/* ---------- 盖章 ---------- */
.stamp {
  width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  color: var(--vermilion); border: 4px solid var(--vermilion); position: relative;
  box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 6px var(--vermilion);
  font-family: var(--font-title); transform: rotate(-12deg);
  -webkit-mask-image: var(--noise), radial-gradient(#000, #000);
}
.stamp .s-top { font-size: 11px; letter-spacing: .2em; }
.stamp .s-main { font-size: 26px; letter-spacing: .1em; line-height: 1.1; }
.stamp .s-bot { font-size: 11px; letter-spacing: .1em; }
.stamp.gray { color: #8a8378; border-color: #8a8378; box-shadow: inset 0 0 0 6px #8a8378; }
.stamp.sm { width: 76px; height: 76px; border-width: 3px; }
.stamp.sm .s-main { font-size: 17px; } .stamp.sm .s-top, .stamp.sm .s-bot { font-size: 9px; letter-spacing: .05em; }
.stamp.slam { animation: slam 520ms var(--ease-stamp) both; }
@keyframes slam { 0% { transform: scale(2.6) rotate(-30deg); opacity: 0; } 55% { transform: scale(.92) rotate(-12deg); opacity: 1; } 100% { transform: scale(1) rotate(-12deg); } }

/* ---------- 信件 ---------- */
.letter-list { display: grid; gap: 14px; }
.letter-item {
  display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 12px; align-items: center; padding: 10px; cursor: pointer;
  background: rgba(255,251,240,.6); border: 1px solid rgba(59,42,30,.35); box-shadow: 2px 2px 0 rgba(59,42,30,.12);
  text-align: left; color: inherit; font: inherit; width: 100%;
}
.letter-item:active { transform: translateY(1px); }
.letter-item.locked { cursor: default; opacity: .75; }
.env-thumb { width: 96px; aspect-ratio: 4/3; position: relative; display: grid; place-items: center; }
.env-thumb img { width: 100%; height: 100%; object-fit: contain; }
.env-thumb .env-fallback { width: 92%; height: 76%; background: #e7d5ad; border: 1px solid #b59d73; position: relative; }
.env-thumb .env-fallback::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom right, transparent 49%, #b59d73 50%, transparent 51%), linear-gradient(to bottom left, transparent 49%, #b59d73 50%, transparent 51%); background-size: 100% 60%; background-repeat: no-repeat; }
.env-thumb .lock-badge { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; filter: grayscale(1); }
.letter-meta { min-width: 0; }
.letter-meta b { display: block; font-family: var(--font-title); font-size: 17px; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.letter-meta span { display: block; font-size: 12px; color: var(--ink-soft); letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-block; font-size: 11px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 2px; margin-top: 4px; }
.chip.red { color: var(--vermilion); } .chip.sage { color: var(--sage-dark); } .chip.gray { color: var(--gray-paper); }

.envelope-stage { display: grid; place-items: center; min-height: 52vh; position: relative; }
.envelope-wrap { position: relative; width: min(82%, 340px); cursor: pointer; transition: transform .5s var(--ease-paper), opacity .5s; }
.envelope-wrap img, .envelope-wrap .env-fallback-big { width: 100%; display: block; filter: drop-shadow(0 12px 18px rgba(59,42,30,.3)); }
.envelope-wrap .env-fallback-big { aspect-ratio: 4/3; background: #e7d5ad; border: 1px solid #b59d73; }
.envelope-wrap .env-label {
  position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%) rotate(-2deg); background: rgba(250,244,228,.92);
  padding: 4px 12px; border: 1px solid rgba(59,42,30,.45); font-size: 13px; letter-spacing: .1em; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis;
}
.envelope-wrap.idle { animation: float 2.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-.6deg); } }
.envelope-wrap.opening { animation: openEnv 700ms ease-in both; }
@keyframes openEnv { 30% { transform: scale(1.04) rotate(2deg); } 100% { transform: translateY(40px) scale(.9); opacity: 0; } }
.tap-hint { margin-top: 14px; font-size: 13px; color: var(--ink-soft); letter-spacing: .2em; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

.sheet {
  position: relative; margin: 4px 2px 18px; padding: 24px 20px 26px; color: #2c2017;
  background: var(--noise), linear-gradient(#FBF5E6, #F2E6CB);
  box-shadow: 0 1px 0 rgba(59,42,30,.2), 0 14px 26px rgba(59,42,30,.18);
  animation: unfold 650ms var(--ease-paper) both; transform-origin: 50% 0;
}
@keyframes unfold { from { transform: translateY(40px) scaleY(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .s-archive { font-size: 11px; color: var(--ink-soft); letter-spacing: .14em; margin-bottom: 14px; display: flex; justify-content: space-between; gap: 8px; }
.sheet .salute { font-size: 17px; margin: 0 0 10px; font-weight: 700; }
.sheet .body p { font-size: 16px; line-height: 2; text-indent: 2em; text-align: justify; }
.sheet .sign { text-align: right; margin-top: 18px; font-size: 16px; line-height: 1.9; }
.sheet .corner-stamp { position: absolute; right: 12px; top: 34px; opacity: .85; }
/* 奏折纸：竖向红栏 */
.sheet.memorial { background: var(--noise), repeating-linear-gradient(90deg, transparent 0 31px, rgba(139,46,36,.16) 31px 32px), linear-gradient(#F6EBD0, #EBDCB8); border-top: 6px solid #9b3a2e; border-bottom: 6px solid #9b3a2e; }
/* 公函笺：顶部红色抬头双线 */
.sheet.letterhead { padding-top: 40px; }
.sheet.letterhead::before { content: "故 宫 博 物 院 用 笺"; position: absolute; left: 20px; right: 20px; top: 12px; text-align: center; color: #a33b2f; font-family: var(--font-title); letter-spacing: .3em; font-size: 13px; border-bottom: 3px double #a33b2f; padding-bottom: 4px; }
/* 方格稿纸 */
.sheet.grid .body p { background-image: linear-gradient(transparent 31px, rgba(125,139,106,.45) 31px), linear-gradient(90deg, transparent 31px, rgba(125,139,106,.25) 31px); background-size: 32px 32px; line-height: 32px; }
.sheet.grid { border-left: 4px solid rgba(125,139,106,.55); }
.annotation {
  position: relative; margin: -4px 10px 18px; padding: 12px 14px 12px 14px; background: #FFF6C9; color: #5a3a22;
  transform: rotate(-1.2deg); box-shadow: 2px 4px 8px rgba(59,42,30,.18); font-size: 14px; line-height: 1.8;
  border-left: 3px solid var(--vermilion); overflow-wrap: anywhere;
}
.annotation::before { content: ""; position: absolute; top: -9px; left: 40%; width: 64px; height: 18px; background: rgba(214,200,160,.8); transform: rotate(4deg); }
.read-done-wrap { padding: 4px 0 8px; }

/* 故事页 */
.story-meaning { display: grid; gap: 8px; }
.story-meaning div { display: grid; grid-template-columns: 82px minmax(0,1fr); gap: 8px; align-items: baseline; font-size: 14px; padding: 8px 0; border-bottom: 1px dashed rgba(59,42,30,.25); }
.story-meaning b { font-family: var(--font-title); color: var(--red-dark); letter-spacing: .06em; }

/* 进度页 */
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.task {
  display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 10px 4px;
  border-bottom: 1px dashed rgba(59,42,30,.25); min-height: 56px; cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; font: inherit; color: inherit;
}
.task:disabled { cursor: default; }
.task .ck { width: 28px; height: 28px; border: 1.5px solid var(--brown); display: grid; place-items: center; font-size: 18px; color: var(--vermilion); font-weight: 700; }
.task .tx { min-width: 0; }
.task .tx b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .tx span { display: block; font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task.done .tx b { text-decoration: line-through; text-decoration-color: rgba(200,64,47,.6); }
.task.locked { opacity: .55; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; text-align: center; }
.stat-grid div { padding: 8px 2px; border: 1px solid rgba(59,42,30,.25); background: rgba(255,251,240,.5); }
.stat-grid b { display: block; font-family: var(--font-title); font-size: 22px; color: var(--red-dark); }
.stat-grid span { font-size: 12px; color: var(--ink-soft); }
.pack-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.pack { padding: 10px 6px; text-align: center; border: 1.5px dashed var(--gray-paper); font-size: 13px; color: var(--gray-paper); min-width: 0; }
.pack.open { border-style: solid; border-color: var(--sage); color: var(--sage-dark); background: rgba(125,139,106,.08); }
.pack b { display: block; font-family: var(--font-title); font-size: 15px; }

/* 规则页 */
.rule { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 10px; padding: 10px 0; border-bottom: 1px dashed rgba(59,42,30,.22); }
.rule .n { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--vermilion); color: var(--vermilion); display: grid; place-items: center; font-family: var(--font-title); font-size: 14px; }
.rule b { font-family: var(--font-title); letter-spacing: .06em; font-size: 15px; }
.rule p { font-size: 14px; margin: 2px 0 0; }

/* 老吴对话页 */
.dialog-log { display: grid; gap: 14px; }
.dlg { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 10px; align-items: start; }
.dlg .bubble::before { top: 20px; bottom: auto; }
.dlg-tag { font-size: 11px; color: var(--ink-soft); letter-spacing: .12em; margin: 0 0 4px 74px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: absolute; inset: 0; z-index: 50; background: rgba(43,31,22,.55); display: grid; place-items: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); animation: fadeIn 180ms ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 420px; max-height: 100%; display: grid; grid-template-rows: auto minmax(0,1fr) auto; margin: 0;
  animation: rise 300ms var(--ease-stamp) both;
}
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }
.modal .m-body { overflow-y: auto; min-height: 0; padding: 2px 2px 6px; }
.modal .m-actions { display: grid; gap: 10px; padding-top: 10px; }
.modal .m-actions.two { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.modal .close-x { position: absolute; right: 6px; top: 6px; z-index: 3; width: 40px; height: 40px; font-size: 18px; }
.modal .m-title { font-family: var(--font-title); font-size: 18px; letter-spacing: .1em; margin: 0 40px 10px 0; }
.hint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hint-list li { padding: 10px 12px; border-left: 3px solid var(--sage); background: rgba(125,139,106,.08); font-size: 14px; line-height: 1.75; }
.hint-list li .lv { display: block; font-size: 11px; letter-spacing: .2em; color: var(--sage-dark); margin-bottom: 2px; }
.pack-callout { margin-top: 10px; padding: 10px 12px; border: 2px dashed var(--vermilion); color: var(--red-dark); font-size: 14px; display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 8px; align-items: center; }
.pack-callout .ic { font-size: 22px; }
.success-stage { display: grid; place-items: center; gap: 10px; padding: 8px 0 4px; text-align: center; }

/* 纸屑 */
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 12px; opacity: .9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .8; } }

/* ---------- 结局 ---------- */
.ending { padding-left: 0; padding-right: 0; padding-top: 0; }
.ending-hero { position: relative; height: 34vh; min-height: 200px; max-height: 320px; overflow: hidden; }
.ending-hero img, .ending-hero .hero-fallback { width: 100%; height: 100%; object-fit: cover; object-position: 50% 60%; display: block; }
.ending-hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 55%; background: linear-gradient(rgba(243,233,210,0), var(--paper)); }
.ending-body { padding: 0 16px; margin-top: -60px; position: relative; z-index: 2; }
.ending-quote { text-align: center; font-family: var(--font-title); font-size: clamp(18px, 5.4vw, 22px); line-height: 1.7; letter-spacing: .1em; color: var(--ink); margin: 0 6px 16px; text-shadow: 0 0 10px var(--paper); }
.fan { position: relative; height: 150px; margin: 4px 0 14px; }
.fan button { position: absolute; left: 50%; top: 10px; width: 112px; border: 0; background: none; padding: 0; cursor: pointer; transform-origin: 50% 120%; }
.fan button img, .fan button .env-fallback-big { width: 100%; display: block; filter: drop-shadow(0 6px 8px rgba(59,42,30,.3)); }
.fan button .env-fallback-big { aspect-ratio: 4/3; background: #e7d5ad; border: 1px solid #b59d73; }
.fan button span { display: block; font-size: 12px; margin-top: 2px; color: var(--brown); letter-spacing: .06em; white-space: nowrap; }
.fan button:nth-child(1) { transform: translateX(-140%) rotate(-14deg); animation: fly1 .8s .1s var(--ease-paper) both; }
.fan button:nth-child(2) { transform: translateX(-50%) translateY(-8px); animation: fly2 .8s .3s var(--ease-paper) both; }
.fan button:nth-child(3) { transform: translateX(40%) rotate(14deg); animation: fly3 .8s .5s var(--ease-paper) both; }
@keyframes fly1 { from { transform: translateX(-140%) translateY(80px) rotate(-40deg); opacity: 0; } }
@keyframes fly2 { from { transform: translateX(-50%) translateY(90px); opacity: 0; } }
@keyframes fly3 { from { transform: translateX(40%) translateY(80px) rotate(40deg); opacity: 0; } }
.memorial-row { display: grid; grid-template-columns: 140px minmax(0,1fr); gap: 14px; align-items: center; }
.big-stamp { width: 132px; height: 132px; }
.achv { display: grid; gap: 8px; }
.achv div { display: grid; grid-template-columns: 22px minmax(0,1fr); gap: 6px; font-size: 13px; align-items: start; }
.achv div.off { opacity: .4; }
.achv div i { font-style: normal; color: var(--vermilion); }
.rank { font-family: var(--font-title); font-size: 16px; color: var(--red-dark); letter-spacing: .1em; }
.ending-actions { display: grid; gap: 10px; margin: 6px 0 10px; }
.ending-actions .two { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }

.toast {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); z-index: 70;
  background: rgba(59,42,30,.92); color: #FBF2DE; padding: 10px 16px; border-radius: 4px; font-size: 14px; max-width: 86%;
  animation: rise 240ms ease both; pointer-events: none; text-align: center;
}
.sound-btn { position: absolute; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 40; width: 40px; height: 40px; font-size: 16px; opacity: .85; }

/* ---------- 批次2 新增 ---------- */
.pz-grid { display: block; }
.pz-left, .pz-right { min-width: 0; }
.next-tip {
  margin: 10px 0 0; padding: 8px 10px; font-size: 14px; line-height: 1.7; color: var(--red-dark);
  border: 1px dashed rgba(200,64,47,.55); background: rgba(200,64,47,.05); text-align: left; overflow-wrap: anywhere;
}
.success-stage .next-tip { width: 100%; }
.flow-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.flow-list li { padding: 6px 0; border-bottom: 1px dashed rgba(59,42,30,.2); overflow-wrap: anywhere; }
.flow-list b { font-family: var(--font-title); color: var(--red-dark); }
.pro-avatar { display: grid; place-items: center; margin: 6px 0 12px; }
.scroll-thumb img { object-fit: cover !important; border: 3px solid #FBF7EC; box-shadow: 0 2px 4px rgba(59,42,30,.25); }
.hint-list li.fresh { animation: pop 320ms var(--ease-stamp) both; }
.pm.just { animation: slam 520ms var(--ease-stamp) both; }
.ending-locked { padding: calc(12px + var(--safe-top)) 16px 20px; }

@media (min-width: 700px) {
  .home-hero { height: 36vh; }
}

/* ---------- 手机横屏 / 矮屏宽屏：双栏，插画与操作同屏可见 ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  #app { max-width: 920px; }
  .page { padding-left: calc(16px + env(safe-area-inset-left, 0px)); padding-right: calc(16px + env(safe-area-inset-right, 0px)); }
  .pz-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
  .pz-left { position: sticky; top: 64px; }
  .pz-left .scene-card img, .pz-left .scene-card .scene-fallback { aspect-ratio: 16/9; }
  .pz-left .newsprint p { font-size: 14px; line-height: 1.6; }
  .actions { margin-top: 10px; }
  .topbar { margin-bottom: 8px; padding-bottom: 6px; }
  /* 首页：左插画右档案 */
  .home { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); grid-template-rows: minmax(0, 1fr); padding: 0 !important; overflow: hidden; }
  .home-hero { height: 100%; max-height: none; min-height: 0; }
  .home-hero::after { inset: 0 0 0 auto; width: 30%; height: 100%; background: linear-gradient(90deg, rgba(243,233,210,0), var(--paper)); }
  .home-body { margin-top: 0; overflow-y: auto; height: 100%; padding: calc(10px + var(--safe-top)) calc(16px + env(safe-area-inset-right, 0px)) calc(16px + var(--safe-bottom)) 12px; }
  .home .tagline { margin-bottom: 8px; }
  .home .panel { margin-bottom: 10px; }
  .home .btn-row { margin: 8px 0 10px; }
  .laowu-row { grid-template-columns: 64px minmax(0,1fr); }
  .laowu-row .avatar { width: 64px; height: 64px; }
  .seal-title { font-size: clamp(30px, 8vh, 44px); }
  /* 信件 / 结局 */
  .envelope-stage { min-height: 56vh; }
  .envelope-wrap { width: min(46%, 300px); }
  .letter-wrap { max-width: 640px; margin: 0 auto; }
  .ending-hero { height: 44vh; }
  .ending-body { max-width: 640px; margin-left: auto; margin-right: auto; }
  .modal-mask { padding-top: 8px; padding-bottom: 8px; }
  .modal { max-width: 560px; }
}
@media (max-height: 640px) {
  .home-hero { height: 34vh; min-height: 200px; }
  .envelope-stage { min-height: 44vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .confetti { display: none; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
body.reduce-motion .confetti { display: none; }
