/* ---------- 窗扇 ---------- */
.shutters { position: absolute; perspective: 220px; pointer-events: none; z-index: 3; }
.shutter-light {
  position: absolute; inset: -30%;
  background: radial-gradient(closest-side, rgba(255, 236, 190, .95), rgba(255, 205, 130, .55) 55%, rgba(255, 190, 100, 0));
  opacity: 0;
}
.pane { position: absolute; top: 0; bottom: 0; width: 50%; backface-visibility: hidden; }
.pane.l { left: 0; transform-origin: 0 50%; }
.pane.r { right: 0; transform-origin: 100% 50%; }

/* ---------- 遮罩与明信片 ---------- */
.card-veil {
  position: fixed; inset: 0; z-index: 20;
  background: radial-gradient(ellipse at 50% 45%, rgba(60, 35, 45, .25), rgba(40, 25, 35, .55));
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
@font-face {
  font-family: 'Town Letter'; src: url('../assets/fonts/town-letter.woff2?v=2') format('woff2'); font-style: normal; font-weight: 400 700; font-display: swap;
}
:root { --handwriting: 'Town Letter', 'Kaiti SC', 'STKaiti', serif; }
.card {
  position: fixed; z-index: 21; left: 50%; top: 50%;
  width: min(94vw, 420px); margin-left: calc(min(94vw, 420px) / -2); translate: 0 -50%;
  max-height: calc(100dvh - 24px); overflow: visible;
  padding: 28px 26px 24px; border-radius: 3px; color: #583f30;
  background: #fcf6e8;
  border: 0 solid transparent;
  border-image: var(--letter-paper) 260 fill / 40px / 0 stretch;
  box-shadow: 0 12px 35px #38251d45, 0 2px 5px #38251d2a;
  font-family: 'PingFang SC', 'Hiragino Sans GB', system-ui, sans-serif;
  scrollbar-width: thin; scrollbar-color: #b29c80 #f7eddb;
  --resident-ink: #87443b;
}
.card-x {
  position: absolute; right: 6px; top: 4px; z-index: 2;
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .75); color: #8a6a5a;
  font: 22px/34px system-ui, sans-serif; cursor: pointer;
}
.card-title { margin: 18px 70px 4px 2px; font: 700 18px/1.35 "Songti SC", "STSong", Georgia, serif; color: #6a4330; }
.card-text { margin: 10px 2px 4px; font-size: 15px; line-height: 1.75; white-space: pre-line; }
.card-title + .card-text { margin-top: 6px; }

.story-card { padding: 20px; }
.story-card .card-x { width: 44px; height: 44px; line-height: 44px; }
.card-header { margin: 0 42px 16px 0; }
.card-header .card-title { margin: 0 0 4px; font-size: 21px; }
.card-header time { font-size: 12px; color: #79574a; }
.card-message .card-text { margin: 0; }
.card-speaker { margin: 8px 0 0; text-align: right; font: 600 14px/1.6 "Songti SC", "STSong", Georgia, serif; }
.story-card[data-type="letter"] .card-message,
.story-card[data-type="finale"] .card-message {
  padding: 12px 0;
  border-block: 1px solid rgba(146, 89, 70, .24);
}

.card-art { aspect-ratio: 16 / 9; margin-bottom: 16px; border-radius: 4px; overflow: hidden; }
.card-art > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.art-ph {
  display: grid;
  height: 100%;
  place-items: center;
  color: #594337;
  font-size: 13px;
}
.art-ph[data-tone="bakery"] { background: radial-gradient(ellipse at 27% 20%, #ffeed0, #eac899 78%); }
.art-ph[data-tone="bookshop"] { background: radial-gradient(ellipse at 27% 20%, #e9e8f3, #bac7dd 78%); }

.card-gift { display: grid; gap: 5px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed rgba(150, 110, 90, .35); }
.story-card[data-type="letter"] .card-gift, .story-card[data-type="finale"] .card-gift { border: 0; padding-top: 0; }
.gift-row { display: flex; min-height: 32px; align-items: center; gap: 9px; font-size: 14px; }
.gift-icon { display: grid; place-items: center; flex: none; width: 40px; height: 36px; }
.gift-icon .orn-img { width: 36px; height: 36px; }
.gift-town-mark { position: relative; width: 14px; height: 10px; margin-top: 5px; border: 1px solid #a76e55; border-top: 0; }
.gift-town-mark::before {
  position: absolute; content: ""; width: 10px; height: 10px; left: 1px; bottom: 5px;
  border: solid #a76e55; border-width: 1px 0 0 1px; transform: rotate(45deg);
}
.gift-status { margin: 0 0 3px; font-size: 13px; color: #79574a; }
.gift-take {
  flex: none; border: 0; border-radius: 18px; padding: 9px 18px;
  background: linear-gradient(#e9a35f, #d9894a); color: #fff;
  font: 600 15px/1 "PingFang SC", system-ui, sans-serif;
  box-shadow: 0 3px 8px rgba(200, 120, 60, .35); cursor: pointer;
}
.story-card .gift-take {
  justify-self: end; min-width: 90px; min-height: 44px; margin-top: 5px; border-radius: 22px;
  background: #a05231; color: #fffaf0;
}
.gift-take:disabled { opacity: .5; cursor: default; }
.story-card button:focus-visible { outline: 2px solid #8e4c30; outline-offset: 2px; }
.gift-fly { position: fixed; z-index: 30; pointer-events: none; }

/* ---------- 底部饰品收纳栏（第 8 卡加拖拽） ---------- */
/* 11-17 Ting：左下角宝箱，点开才显示饰品横栏，再点收起 */
#dock {
  position: absolute; left: 50%; z-index: 6;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100vw - 20px), calc(100dvh * var(--scene-ratio) - 20px));
  display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}
#dock { transition: opacity .6s ease, transform .6s ease; }
#dock.pre { opacity: 0; transform: translateX(-50%) translateY(10px); }
#dock.pre * { pointer-events: none !important; }
#chest {
  /* 11-17 Ting 嫌 62px 大而突兀：缩到 40px、阴影减淡；热区用 padding 保持约 48px 好点 */
  flex: none; position: relative; z-index: 1; width: 48px; height: 48px; padding: 4px; margin: -4px 0 -4px -4px; border: 0; background: none;
  pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 1px 2px rgba(60, 30, 30, .22));
  transition: transform .25s cubic-bezier(.2,.9,.25,1.3);
}
#chest img { width: 100%; height: 100%; display: block; pointer-events: none; }
#chest:active { transform: scale(.92); }
#chest[aria-expanded="true"] { transform: translateY(-3px) scale(1.04); }
#chest.bump { animation: chest-bump .55s ease-out; }
@keyframes chest-bump { 0% { transform: scale(1); } 35% { transform: scale(1.18, .9); } 65% { transform: scale(.94, 1.08); } 100% { transform: scale(1); } }
#dock.open #tray { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
#tray {
  flex: 1; min-width: 0;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateX(-24px) scaleX(.85); transform-origin: 0 50%;
  transition: opacity .25s, transform .3s cubic-bezier(.2,.9,.25,1.1), visibility 0s .3s;
  min-height: 56px;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(90, 70, 110, .15);
  overflow-x: auto;
  scrollbar-width: none;
}
#tray::-webkit-scrollbar { display: none; }
#dock.open #tray { transition: opacity .25s, transform .3s cubic-bezier(.2,.9,.25,1.1), visibility 0s; }
#tray .tray-empty { font: 12px "PingFang SC", system-ui, sans-serif; color: #9a8790; }
#tray .tray-item { flex: none; width: 40px; height: 40px; display: grid; place-items: center; }
#tray .tray-end { flex: none; width: 1px; height: 40px; }

/* ---------- 二选一 ---------- */
.choice-tip { margin: 0 0 8px; font-size: 13px; color: #79574a; }
.choice-opts { display: flex; gap: 10px; justify-content: center; }
.choice-opt {
  flex: 1; max-width: 130px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 6px; border-radius: 12px;
  border: 1.5px dashed rgba(170, 130, 110, .45); background: rgba(255, 255, 255, .5);
  font: 13px "PingFang SC", system-ui, sans-serif; color: #6a4330; cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.choice-opt .gift-icon, .choice-opt .orn-img { width: 52px; height: 52px; }
.choice-opt[aria-pressed="true"] { border: 1.5px solid #e9a35f; background: #fff3e2; transform: translateY(-2px); }
.orn-img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* ---------- 树上的饰品与拖拽 ---------- */
.layer-orns { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.orn-on-tree {
  position: absolute; width: 7.5cqw; height: 7.5cqw;
  /* 图片上部约四分之一是挂环，挂点落在放下的位置 */
  transform: translate(-50%, -30%);
  pointer-events: auto; cursor: grab;
  filter: drop-shadow(0 1px 1.5px rgba(40, 30, 30, .35));
}
/* 金星（11-17 换无底座图）：平时不发光，彩灯到顶时（#cam.finale-star）才亮 */
.orn-on-tree.topper { width: 12cqw; height: 12cqw; transform: translate(-50%, -94%); z-index: 2; transition: filter 1s; }
#cam.finale-star .orn-on-tree.topper { filter: brightness(1.12) drop-shadow(0 0 2px rgba(255, 236, 170, .95)) drop-shadow(0 0 6px rgba(255, 210, 120, .7)); }
.orn-on-tree.dragging, .tray-item.dragging { opacity: .25; }
.orn-ghost {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(40, 30, 30, .35)); opacity: .75;
  transition: opacity .15s;
}
.orn-ghost.ok { opacity: 1; }
#tray .tray-item { cursor: grab; touch-action: none; }
#tray .tray-item .orn-img, #tray .tray-item svg { width: 38px; height: 38px; }
.tree-poly-dev { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.tree-poly-dev polygon { fill: rgba(0, 200, 120, .12); stroke: #00c878; stroke-width: .3; }
.tree-poly-dev circle { fill: #ff2fbf; }

/* ---------- 卡片内游戏 ---------- */
.card-game:empty { display: none; }
.card-game { position: relative; margin: 16px 0 0; }
.game-result { margin: 0; padding: 10px 12px; background: #f2e5d6; border-radius: 4px; line-height: 1.55; }
.game-control {
  min-height: 44px; padding: 8px 12px; border: 1px solid #ac8065; border-radius: 5px;
  background: #fffaf2; color: #6a4330; font: inherit; cursor: pointer;
}
.card-skip { display: block; margin: 8px 0 0 auto; border-color: transparent; background: transparent; font-size: 14px; text-decoration: underline; }
.game-instruction { margin: 0 0 10px; color: #704e3e; font-size: 13px; line-height: 1.5; }
/* 手绘物件：糖果、玻璃罐 */
.sort-candies, .sort-jars { display: grid; gap: 8px; }
.sort-candies { position: relative; display: block; width: min(100%, 248px); height: 78px; margin: 4px auto 0; }
.sort-jars { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sort-candy[data-color="red"], .sort-jar[data-color="red"] { --candy: #a44743; --candy-filter: none; }
.sort-candy[data-color="gold"], .sort-jar[data-color="gold"] { --candy: #946012; --candy-filter: sepia(.9) saturate(2.2) hue-rotate(350deg) brightness(1.06); }
.sort-candy[data-color="green"], .sort-jar[data-color="green"] { --candy: #3e694e; --candy-filter: hue-rotate(125deg) saturate(.7); }
.sort-candy {
  display: grid; min-width: 0; min-height: 44px; padding: 0; place-items: center;
  border: 0; border-radius: 8px; background: transparent; touch-action: none; cursor: grab;
  transition: background-color .15s;
}
.sort-candies .sort-candy { position: absolute; width: 82px; height: 44px; left: var(--pile-x); top: var(--pile-y); z-index: var(--pile-order); }
.sort-candy i { width: min(100%, 82px); height: 40px; background: var(--candy-art) center / contain no-repeat; filter: var(--candy-filter); rotate: var(--rest-angle, 0deg); pointer-events: none; }
.sort-candy[aria-pressed="true"] { background: #f0dec4; outline: 1px dashed var(--candy); outline-offset: 0; }
.sort-candies .sort-candy.moving { z-index: 20; cursor: grabbing; }
.sort-candy:disabled { visibility: hidden; }
.sort-flight { position: absolute; z-index: 5; pointer-events: none; }
.sort-jar.game-control {
  position: relative; min-width: 0; min-height: 0; aspect-ratio: 1088 / 1456; padding: 0;
  border: 0; border-radius: 0; background: transparent; transform-origin: 50% 90%;
}
.sort-jar-art { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sort-jar-lid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: var(--candy-filter); clip-path: inset(0 0 65% 0); }
.sort-jar-inside { position: absolute; left: 22%; right: 22%; top: 54%; bottom: 17%; display: flex; align-items: center; justify-content: center; gap: 0; }
.jar-sweet { display: block; width: 26px; height: 40px; background: var(--candy-art) center / contain no-repeat; filter: var(--candy-filter); opacity: 0; transform: rotate(var(--sweet-turn)); transition: opacity .12s; }
.jar-sweet.landed { opacity: 1; }
.sort-count { position: absolute; top: 38%; left: 0; right: 0; color: #704e3e; font: 13px/1 var(--handwriting); }
.sort-count::after { content: '/2'; }
.sort-jar.hint { outline: 1px dashed var(--candy); outline-offset: -2px; border-radius: 35%; animation: jar-hint .7s ease-in-out 2; }
@keyframes jar-hint { 50% { opacity: .55; } }
.memory-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.memory-tile.game-control {
  position: relative; min-height: 62px; padding: 0; border: 0; background: transparent;
  perspective: 440px; color: #765241; font-weight: 600; font-size: 12px;
}
.memory-turn { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .36s cubic-bezier(.16,1,.3,1); }
.memory-back, .memory-face {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid #ab7f66; border-radius: 5px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.memory-back { background: #e7c9a7; }
.memory-back > span { border: 1px dashed #a2795d; border-radius: 50%; padding: 7px; line-height: 1.3; color: #6a4330; }
.memory-face { background: #fff4dd; transform: rotateY(180deg); transition: background-color .22s, border-color .22s; }
.memory-face .orn-img { width: 28px; height: 28px; }
.memory-tile.face-up .memory-turn { transform: rotateY(180deg); }
.memory-tile.matched .memory-face { border-color: #708165; color: #40543d; background: #e5ecd9; }
.memory-tile:disabled { cursor: default; }
.puzzle-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.puzzle-tile {
  aspect-ratio: 1; min-height: 44px; border: 1px solid #b88b6d; border-radius: 3px;
  background: var(--puzzle-art) no-repeat; background-size: 300% 200%; cursor: pointer;
  transition: box-shadow .16s;
}
.puzzle-tile[aria-pressed="true"] { outline: 2px solid #a05231; outline-offset: -3px; box-shadow: 0 3px 7px #704e3e40; }
.puzzle-tile.swapping { position: relative; z-index: 2; }
.puzzle-board[aria-busy="true"] { cursor: wait; }
.puzzle-board[aria-busy="true"] .puzzle-tile { cursor: wait; }
.puzzle-hint { margin-top: 8px; font-size: 13px; }
.puzzle-preview { width: 126px; aspect-ratio: 3 / 2; margin-top: 8px; background: var(--puzzle-art) center / contain no-repeat; }
.game-result { white-space: pre-line; }
.game-replay { display: block; margin: 8px 0 0 auto; font-size: 13px; }
.game-completing .puzzle-board { outline: 2px solid #9b7845; outline-offset: 3px; border-radius: 3px; }
.game-complete-mark {
  position: absolute; right: 4px; bottom: 4px; z-index: 6; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%; background: #e5ecd9; color: #4c6353;
  box-shadow: 0 2px 6px #57412c30; pointer-events: none;
  animation: game-stamp .25s .38s both;
}
.game-complete-mark svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.game-complete-mark path { stroke-dasharray: 30; stroke-dashoffset: 0; animation: game-check .22s .48s both; }
@keyframes game-stamp { from { opacity: 0; transform: scale(1.3) rotate(-10deg); } to { opacity: 1; transform: none; } }
@keyframes game-check { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }
/* 木质保险箱：底图、箱腔、可转动的门分层 */
.safe-case { position: relative; width: min(156px, 65%); aspect-ratio: 1; margin: -6px auto 2px; perspective: 520px; }
.safe-body { width: 100%; height: 100%; display: block; pointer-events: none; }
.safe-cavity, .safe-door { position: absolute; left: 25.7%; top: 22.5%; width: 47.6%; height: 53.2%; }
.safe-cavity { background: #493c2e; border-radius: 2px; box-shadow: inset 3px 2px 9px #211e1880; }
.safe-door { z-index: 1; background: var(--safe-art) 49.05% 48.08% / 210.084% 187.97% no-repeat; transform-origin: 0 50%; }
.safe-wheel { position: absolute; display: block; width: 30%; aspect-ratio: 1; left: 34.6%; top: 28.2%; border-radius: 50%; background: var(--safe-art) 49.3% 43.8% / 700% 700% no-repeat; }
.safe-door.safe-opening { transform: rotateY(-108deg); }
.safe-opening .safe-wheel { transform: rotate(100deg); }
.safe-paper { position: absolute; inset: 12% 15%; display: grid; gap: 5px; align-content: center; padding: 10px; background: #f7e5ba; border: 1px solid #caaa72; opacity: 0; }
.safe-paper.revealed { opacity: 1; }
.safe-paper i { height: 2px; background: #ad8652; }
.safe-paper i:nth-child(2) { margin-right: 8px; }
.safe-paper b { justify-self: center; width: 15px; height: 15px; margin-top: 3px; border: 3px double #a4563e; border-radius: 50%; }
.safe-form { display: flex; gap: 10px; align-items: end; justify-content: center; }
.safe-label { color: #704e3e; text-align: center; font: 15px/1.5 var(--handwriting); }
.safe-dials { position: relative; display: block; width: 162px; height: 52px; margin: 4px auto 0; }
.safe-digits { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.safe-digits b { display: grid; place-items: center; border: 1px solid #ad8d5e; border-radius: 5px; background: #e6c58e; box-shadow: inset 0 3px 6px #6b4d3428; color: #624323; font: 26px/1 var(--handwriting); }
.safe-code { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .01; border: 0; font-size: 24px; caret-color: transparent; }
.safe-dials:focus-within { outline: 2px solid #99513e; outline-offset: 4px; border-radius: 4px; }
.safe-label:has(.safe-code[aria-invalid="true"]) .safe-digits b { border-color: #9b3c32; background: #efd4b5; }
.safe-unlock.game-control { min-width: 108px; background: #5c7356; color: #fff8e9; border: 0; font-family: var(--handwriting); font-size: 16px; }
.safe-status { margin: 8px 0 0; color: #8e392f; text-align: center; font-size: 13px; }
.safe-status:empty { display: none; }
.story-card[data-type="safe"] .game-result { border: 1px solid #c2875c; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .memory-turn, .memory-face, .jar-sweet, .sort-candy, .puzzle-tile { transition: none; }
  .memory-face { transform: none; visibility: hidden; }
  .memory-tile.face-up .memory-turn { transform: none; }
  .memory-tile.face-up .memory-face { visibility: visible; }
  .memory-tile.face-up .memory-back { visibility: hidden; }
  .sort-jar.hint, .game-complete-mark, .game-complete-mark path { animation: none; }
  .safe-door.safe-opening { transform: none; opacity: .12; }
  .safe-opening .safe-wheel { transform: none; }
}

/* ---------- 拆信 ---------- */
/* 真正的水彩信封，透明热区盖在火漆印上 */
.letter-envelope { position: relative; width: 100%; aspect-ratio: 3 / 2; margin: 10px auto 0; }
.letter-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.letter-seal { position: absolute; left: calc(50% - 30px); top: calc(57% - 30px); z-index: 1; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 50%; background: transparent; touch-action: none; cursor: pointer; }
.letter-seal span { position: absolute; inset: 7px; border-radius: 50%; }
.letter-seal.holding span { border: 2px solid #e1c07c; animation: seal-hold .62s linear both; }
@keyframes seal-hold { from { transform: scale(.75); opacity: .2; } to { transform: scale(1.15); opacity: 1; } }
.letter-instruction { margin: 3px 0 12px; color: #795841; text-align: center; font: 17px/1.5 var(--handwriting); }
.letter-fly { position: fixed; z-index: 25; margin: 0; pointer-events: none; }
.story-aside {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 4px;
  background: #f1e4d4; color: #604638; font-size: 14px; line-height: 1.6;
}
.story-question, .story-reply { margin: 0; }
.story-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.story-actions .game-control { flex: 1 1 auto; font-size: 13px; }
.note-input {
  display: block; width: 100%; margin: 6px 0 0; padding: 8px; resize: vertical;
  border: 1px solid #ac8065; border-radius: 4px; background: #fffaf3;
  color: #5b4434; font: inherit; font-size: 16px;
}
.note-submit:disabled { opacity: .5; cursor: default; }
.note-echo { white-space: pre-wrap; overflow-wrap: anywhere; }

/* 每日手札：同一间小镇，不同居民留下的纸与墨 */
.story-card { padding: 38px 24px 24px; }
.card-scroll { max-height: calc(100dvh - 86px); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b29c80 #f7eddb; padding-right: 10px; }
.story-card[data-speaker="小麦"] { --resident-ink: #80572d; }
.story-card[data-speaker="波波"] { --resident-ink: #456953; }
.story-card[data-speaker="林恩"] { --resident-ink: #4b6470; }
.story-card[data-speaker="咕噜"] { --resident-ink: #845435; }
.story-card ::selection { color: #4c382a; background: #e9cf9d; }
.story-card .card-x { top: 8px; right: 10px; width: 44px; height: 44px; line-height: 44px; border-radius: 0; background: transparent; color: #7e604c; }
.card-header { margin: 0 40px 10px 0; padding: 0 0 6px; border-bottom: 1px solid #b79a7c66; }
.card-header .card-title { color: var(--resident-ink); font: 24px/1.25 var(--handwriting); text-wrap: balance; }
.card-header time { display: inline-block; margin-top: 4px; color: #806248; font: 13px/1.3 var(--handwriting); }
.card-message .card-text { font-size: 16px; line-height: 1.55; white-space: normal; }
.story-paragraph { display: block; white-space: pre-line; }
.story-paragraph + .story-paragraph { margin-top: 8px; }
.card-speaker { margin-top: 6px; color: var(--resident-ink); font: 18px/1.4 var(--handwriting); transform: rotate(-2deg); }
.story-card[data-type="letter"] .card-message,
.story-card[data-type="finale"] .card-message { padding: 2px 0 10px; border: 0; }
.story-card[data-type="letter"] .card-text,
.story-card[data-type="finale"] .card-text { font: 17px/1.6 var(--handwriting); color: #4f5d59; }
.card-art { width: min(100%, 280px); margin: 0 auto 10px; aspect-ratio: 16 / 9; border: 6px solid #fffaf0; border-radius: 1px; box-shadow: 0 2px 7px #7b59352b; transform: rotate(-1deg); }
.card-gift { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #b19a7c88; gap: 7px; }
.gift-row { font-size: 14px; line-height: 1.4; gap: 8px; }
.story-card[data-type="ornament"] .gift-row { min-height: 62px; justify-content: center; font-family: var(--handwriting); font-size: 20px; }
.story-card[data-type="ornament"] .gift-row .gift-icon { width: 60px; height: 60px; }
.story-card[data-type="ornament"] .gift-row .orn-img { width: 58px; height: 58px; }
.choice-tip { text-align: center; font: 16px/1.5 var(--handwriting); }
.choice-opt { max-width: 145px; padding: 8px 6px; border: 1px dashed #b6a187; border-radius: 3px; background: #fffaf045; font-family: var(--handwriting); font-size: 16px; }
.choice-opt .gift-icon, .choice-opt .orn-img { width: 60px; height: 60px; }
.choice-opt b { font-weight: 400; }
.choice-opt[aria-pressed="true"] { border: 1px solid #9b6544; background: #f2e2c2; transform: rotate(-2deg); }
.story-card .gift-take { min-width: 100px; border-radius: 5px; background: #914a3e; color: #fff9e8; font: 20px/1 var(--handwriting); box-shadow: 0 2px 4px #68413125; }
.gift-status { font-family: var(--handwriting); font-size: 17px; color: #53704d; }
.game-instruction { font-size: 13px; color: #775940; }
.game-control { border-color: #b9a183; border-radius: 4px; background: #f9efdc; color: #694b35; }
.game-replay, .puzzle-hint, .card-skip { font-family: var(--handwriting); font-size: 16px; }
.game-result { padding: 13px 12px; border-radius: 2px; background: #e9dfc769; color: #5a533e; font: 18px/1.65 var(--handwriting); }
.memory-back { background: #e9d7b7; }
.memory-back > span { font-family: var(--handwriting); font-size: 14px; border-color: #ac8461; }
.memory-face { font-family: var(--handwriting); font-size: 15px; }
.puzzle-board { width: min(100%, 252px); margin-inline: auto; padding: 5px; background: #d7bd96; border: 1px solid #af916c; border-radius: 2px; gap: 3px; }
.puzzle-tile { border-color: #b79d7b; border-radius: 1px; }
.puzzle-neighbor { outline: 1px solid #6d875d; outline-offset: -3px; }
.puzzle-status { min-height: 0; margin: 6px 0 0; font: 15px/1.5 var(--handwriting); color: #8a4f37; }
.puzzle-status:empty { display: none; }
.story-aside { position: relative; margin-top: 10px; padding: 9px 10px 8px; border-radius: 1px; background: #e9dcbc85; font: 16px/1.5 var(--handwriting); color: #64583f; }
.story-aside::before { content: ''; position: absolute; width: 42px; height: 12px; top: -6px; left: 39%; transform: rotate(-5deg); background: #b29a6b55; }
.story-aside .card-speaker { font-size: 18px; }
.story-actions .game-control { font-family: var(--handwriting); font-size: 15px; padding: 6px 8px; }
.note-input { height: 54px; padding: 4px 6px; background: #fffbef99; border-color: #b99d77; font: 16px/1.4 var(--handwriting); caret-color: #754a39; }
.card-ready .card-title { animation: handwriting-ink .55s ease-out both; }
.card-ready[data-type="ornament"] .gift-icon { animation: gift-unfold .6s ease-out both; }
@keyframes handwriting-ink { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes gift-unfold { from { opacity: .3; transform: translateY(9px) rotate(-8deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .card-ready .card-title, .card-ready[data-type="ornament"] .gift-icon, .letter-seal.holding span { animation: none; }
  .choice-opt[aria-pressed="true"], .card-speaker { transform: none; }
}
@media (max-width: 360px) {
  .story-card { padding: 36px 20px 22px; }
  .card-scroll { max-height: calc(100dvh - 82px); }
  .card-header .card-title { font-size: 23px; }

}

/* 游戏区优先容纳在一屏，按内容分组收紧，不缩小点击热区。 */
.card-game { margin-top: 10px; }
.game-instruction { margin-bottom: 6px; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin-top: 4px; }
.card-actions .card-skip { margin: 0; padding: 5px 0; min-height: 44px; font-size: 15px; }
.card-actions .gift-take { margin: 0 0 0 auto; }
.story-card[data-type="game"] .card-gift { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.story-card[data-type="game"] .gift-row { flex: 1 1 45%; min-height: 28px; gap: 5px; font-size: 13px; }
.story-card[data-type="game"] .gift-icon { width: 26px; height: 26px; }
.story-card[data-type="game"] .gift-icon svg { width: 26px; height: 26px; }
.sort-jars { width: min(100%, 268px); margin-inline: auto; }
.letter-envelope { width: min(100%, 270px); margin-top: 0; }
.letter-instruction { margin-bottom: 0; }
@media (max-height: 740px) {
  .story-card { padding-top: 34px; padding-bottom: 20px; }
  .card-scroll { max-height: calc(100dvh - 78px); padding-right: 6px; }
  .card-header { margin-bottom: 8px; }
  .card-header .card-title { font-size: 22px; }
  .card-message .card-text { font-size: 15.5px; line-height: 1.48; }
  .story-card[data-type="letter"] .card-text, .story-card[data-type="finale"] .card-text { font-size: 16px; line-height: 1.45; }
  .story-paragraph + .story-paragraph { margin-top: 5px; }
  .card-speaker { margin-top: 4px; font-size: 17px; }
  .card-art { width: min(100%, 220px); }
  .story-aside { font-size: 15px; padding: 8px; }
  .story-actions { margin-top: 5px; }
  .story-actions .game-control { font-size: 14px; }
  .card-gift { margin-top: 8px; padding-top: 6px; gap: 4px; }
  .choice-tip { margin-bottom: 5px; font-size: 15px; }
  .choice-opt .gift-icon, .choice-opt .orn-img { width: 52px; height: 52px; }
  .choice-opt { padding: 6px; font-size: 15px; }
  .memory-tile.game-control { min-height: 56px; }
  .puzzle-board { width: min(100%, 216px); }
  .puzzle-hint { margin-top: 5px; }
  .puzzle-preview { width: 96px; margin-top: 5px; }
  .safe-case { width: min(136px, 60%); }
  .safe-label { font-size: 13px; }
  .safe-dials { width: 144px; height: 48px; }
  .game-instruction { font-size: 12px; line-height: 1.4; }
  .game-result { font-size: 16px; line-height: 1.45; padding: 8px; }
  .sort-jars { width: min(100%, 240px); }
}

/* 圣诞邮局统一背卡；每次只翻动当前选择的两张。 */
.memory-board { width: min(100%, 256px); margin-inline: auto; }
.memory-tile.game-control { aspect-ratio: 2 / 3; min-height: 0; }
.memory-back { border: 0; background: #f6e9ca var(--memory-back-art) center / 100% 100% no-repeat; }
.memory-back > span { position: absolute; width: 100%; left: 50%; top: 37%; transform: translate(-50%, -50%); padding: 0; border: 0; border-radius: 0; color: #65513a; font: 16px/1.05 var(--handwriting); white-space: nowrap; text-align: center; }
@media (max-height: 740px) {
  .memory-board { width: min(100%, 224px); }
  .memory-back > span { font-size: 14px; }
}

/* 小坏蛋的密码题：线索为主体，箱体仅作小型点缀。 */
.safe-riddle { margin-bottom: 9px; }
.safe-riddle-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.safe-riddle-head h3 { margin: 0; font: 18px/1.4 var(--handwriting); color: #745036; }
.safe-riddle-head .safe-case { width: 58px; margin: 0; flex: none; }
.safe-clues { width: 100%; border-collapse: collapse; table-layout: fixed; }
.safe-clues th { width: 24%; padding: 7px 8px 7px 0; text-align: left; font: 23px/1.2 var(--handwriting); color: #865139; font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.safe-clues td { padding: 7px 0; font: 14px/1.45 var(--handwriting); color: #5b4939; }
.safe-clues tr + tr { border-top: 1px solid #b19a7c77; }
@media (max-height: 740px) {
  .safe-riddle-head h3 { font-size: 16px; }
  .safe-riddle-head .safe-case { width: 48px; }
  .safe-clues th { padding-block: 5px; font-size: 21px; }
  .safe-clues td { padding-block: 5px; font-size: 13px; line-height: 1.4; }
}

/* 三个封闭的水彩包裹，选中后才揭晓礼物。 */
.blind-tip { margin: 2px 0 8px; font-size: 14px; color: #70523b; text-align: center; }
.blind-parcels { display: flex; gap: 3px; align-items: end; }
.blind-parcel { flex: 1; min-width: 0; border: 0; padding: 0 0 6px; background: none; color: #63472f; font: 14px var(--handwriting); cursor: pointer; }
.blind-parcel img { display: block; width: 100%; height: 106px; object-fit: contain; transition: transform .2s; }
.blind-parcel:nth-child(1) img { transform: rotate(-7deg); }
.blind-parcel:nth-child(3) img { transform: rotate(6deg); }
.blind-parcel:hover:not(:disabled) img { transform: translateY(-6px) rotate(0); }
.blind-parcel:disabled:not(.blind-chosen) { opacity: .35; }
.blind-reveal { text-align: center; min-height: 150px; }
.blind-reveal .gift-icon { display: block; margin: 0 auto; width: 100px; height: 100px; }
.blind-reveal b { display: block; font: 21px var(--handwriting); color: #794834; }
.blind-reveal p { margin: 6px 0; font-size: 14px; }
.blind-parcels[hidden], .blind-reveal[hidden] { display: none; }

.souvenir-open { display: block; margin: 6px auto 10px; width: 100%; font: 17px var(--handwriting); color: #795239; background: #e7cf9a4d; border: 1px dashed #ad8d5c; }
.card-scroll[hidden], .postcard-front[hidden], .postcard-back[hidden] { display: none; }
.souvenir-panel { max-height: calc(100dvh - 86px); overflow-y: auto; color: #624831; scrollbar-color: #ad8d5c transparent; }
.souvenir-back { margin: 0 42px 6px 0; font-family: var(--handwriting); }
.souvenir-title { margin: 4px 0 12px; font: 25px/1.3 var(--handwriting); color: #754d32; }
.souvenir-body { font: 17px/1.55 var(--handwriting); }
.souvenir-body h3 { margin: 18px 0 5px; font-size: 20px; color: #566749; }
.recipe-art { width: 100%; max-height: 160px; object-fit: cover; border: 5px solid #fff9ea; box-sizing: border-box; transform: rotate(-1deg); }
.recipe-subtitle { margin: 8px 0; }
.recipe-ingredients { padding: 0; margin: 0; list-style: none; }
.recipe-steps { padding-left: 22px; margin: 0; }
.recipe-steps li { margin-bottom: 8px; padding-left: 3px; }
.recipe-note { font-size: 16px; color: #6e5638; }
.recipe-source, .postcard-private { font: 12px/1.5 system-ui,sans-serif; color: #75563b; }
.recipe-source a { color: #6c4c30; text-underline-offset: 3px; }
.souvenir-body .game-control { margin: 8px 4px 8px 0; font: 17px var(--handwriting); }
.souvenir-output { display: block; width: 100%; height: auto; border: 0; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.souvenir-export-label { font-size: 13px; color: #785645; }
.souvenir-status { color: #874d3b; font-size: 14px; }
.postcard-front { text-align: center; }
.postcard-front img { height: min(36dvh,310px); max-width: 100%; object-fit: contain; border: 5px solid #fffbef; box-shadow: 0 3px 9px #76533033; transform: rotate(-1deg); }
/* 背面就是可书写的纸张：邮票与邮戳成组，祝福直接落在横线上。 */
.postcard-back {
  position: relative; padding: 16px 18px 12px; margin: 6px 0 12px;
  background: #fff6df url('../assets/ui/christmas-letter-paper.webp') center / 300% 300%;
  box-shadow: 0 4px 12px #67462626; color: #654b35;
  transform: rotate(-.2deg);
}
.postcard-mailhead { position: relative; height: 90px; }
.postcard-print { position: absolute; top: 5px; left: 0; color: #53694e; font: 15px/1.2 var(--handwriting); letter-spacing: .12em; }
.postcard-stamp { position: absolute; top: -7px; right: -3px; width: 79px; height: 94px; object-fit: contain; }
.postcard-postmark { position: absolute; top: 20px; right: 37px; width: 134px; height: 78px; color: #8e5145; transform: rotate(-9deg); pointer-events: none; }
.postcard-address { display: flex; align-items: center; gap: 7px; height: 44px; margin: 0 0 6px; }
.postcard-address > span { flex: none; color: #53694e; font: 17px var(--handwriting); }
.postcard-back .postcard-recipient {
  display: block; min-width: 0; width: 100%; box-sizing: border-box; margin: 0; padding: 8px 0 4px;
  border: 0; border-bottom: 1px solid #ae967766; border-radius: 0;
  color: #654b35; background: transparent; font: 17px/1.5 var(--handwriting); caret-color: #8d4f42;
}
.postcard-writing { display: block; position: relative; height: 155px; margin: 2px 0 0; }
.postcard-field-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.postcard-writing > svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: #ae967766; stroke-width: 1; pointer-events: none; }
.postcard-back .postcard-message {
  position: relative; display: block; box-sizing: border-box; width: 100%; height: 155px; max-height: none;
  margin: 0; padding: 3px 0 0; resize: none; border: 0; border-radius: 0; background: transparent;
  color: #654b35; font: 17px/31px var(--handwriting); caret-color: #8d4f42; scrollbar-color: #a88a63 transparent; scrollbar-width: thin;
}
.postcard-back :is(input,textarea)::placeholder { color: #80684b; opacity: 1; }
.postcard-back :is(input,textarea):focus-visible { outline: 1px dashed #87613e; outline-offset: 3px; }
.postcard-signoff { display: flex; align-items: end; justify-content: space-between; min-height: 38px; margin-top: 6px; }
.postcard-signoff img { width: 43px; height: 43px; object-fit: contain; transform: rotate(-18deg); }
.postcard-signoff span { color: #745b41; font: 14px/1.4 var(--handwriting); padding-bottom: 3px; }
.postcard-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; margin: 4px 0 0; }
.souvenir-body .postcard-tools .game-control { margin: 4px 0; padding-inline: 8px; font-size: 16px; }
.postcard-private { margin: 8px 0 0; font-size: 11px; line-height: 1.5; }
@media (max-height:740px) {
  .postcard-back { padding: 12px 15px 10px; }
  .postcard-mailhead { height: 84px; }
  .postcard-stamp { width: 74px; height: 88px; }
  .postcard-postmark { width: 126px; height: 73px; top: 15px; }
  .postcard-signoff { margin-top: 2px; min-height: 31px; }
  .postcard-signoff img { width: 36px; height: 36px; }
}
@media (max-height:740px) { .souvenir-open { margin: 4px auto 7px; } .story-card[data-type="image"]:has(.souvenir-open) .card-art { width: 190px; } }

/* 游戏雪花是新的六枝冰晶，背景飘雪仍保持原来的细白雪点。 */
.snow-field { width: min(100%,290px); height: 196px; margin: 0 auto; position: relative; overflow: hidden; touch-action: none; outline-offset: 3px; border-bottom: 1px solid #9ab8bb; background: linear-gradient(#dbe7e238,#d5e7e65c); }
.snow-field:focus-visible { outline: 2px solid #7c955d; }
.snow-crystal { position: absolute; width: 38px; height: 38px; object-fit: contain; top: 0; pointer-events: none; }
.snow-mitten { position: absolute; width: 64px; height: 64px; object-fit: contain; bottom: 4px; transform: translateX(-50%); pointer-events: none; }
.snow-start { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 18px var(--handwriting); background: #fff2d6; }
.snow-score { margin: 6px 0 0; color: #4e6866; text-align: center; font: 17px var(--handwriting); }
@media (max-height:740px) { .snow-field { height: 164px; } }

.blind-reveal .gift-icon .orn-img { width: 100px; height: 100px; }
.recipe-leaf[hidden] { display: none; }
.recipe-art { height: 130px; }
.recipe-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px; margin-top: 12px; }
.souvenir-panel { overflow-x: hidden; }
@media (max-height:740px) {
  .souvenir-body { font-size: 16px; line-height: 1.45; }
  .recipe-art { height: 112px; }
  .recipe-steps li { margin-bottom: 6px; }
  .recipe-method h3 { margin-top: 3px; }
  .recipe-note { font-size: 15px; margin: 9px 0; }
  .recipe-source { font-size: 11px; }
  .recipe-actions { margin-top: 8px; }
}

.postcard-back.postcard-long .postcard-writing, .postcard-back.postcard-long .postcard-message { height: 186px; }
.postcard-back.postcard-long .postcard-message { font-size: 16px; }

/* 原生横向浏览礼品；纵向拖挂由饰品的方向判断处理。 */
#tray { touch-action: pan-x; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
#tray .orn-img { -webkit-touch-callout: none; }

#tray .tray-item:is(.selected,.pressing) { outline: 1px solid #71855b; outline-offset: 2px; border-radius: 4px; background: #fff4d77a; }

/* 接雪从信纸走进广场，游戏层透明，保持真实小镇与原本的飘雪。 */
.card[hidden], .card-veil[hidden], .shutters[hidden] { display: none; }
.snow-launch { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px 0; }
.snow-launch > img { width: 64px; height: 64px; object-fit: contain; }
.snow-launch .snow-start { position: static; transform: none; font: 18px var(--handwriting); }
.scene-game-active :is(#dock,.music-control,.replay-btn) { display: none; }
.scene-game-active #toast { visibility: hidden; }
.scene-snow-overlay { position: absolute; inset: 0; z-index: 16; background: transparent; }
.scene-snow-field.snow-field {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: min(100vw,100dvh * var(--scene-ratio)); height: 100%; margin: 0;
  background: none; border: 0; overflow: hidden; touch-action: none;
}
.scene-snow-field:focus-visible { outline: 1px dashed #7c955d; outline-offset: -3px; }
.scene-snow-hud { z-index: 2; position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; background: #fcf1dcf2; box-shadow: 0 3px 10px #62462e26; pointer-events: none; }
.scene-snow-hud h2 { margin: 0; color: #705039; font: 20px/1.3 var(--handwriting); }
.scene-snow-hud p { margin: 4px 0 0; color: #72573d; font: 12px/1.4 system-ui,sans-serif; }
.scene-snow-hud .snow-exit { pointer-events: auto; flex: none; padding: 7px 8px; font: 15px var(--handwriting); min-height: 44px; }
.scene-snow-field .scene-snow-score { z-index: 2; position: absolute; top: calc(101px + env(safe-area-inset-top)); left: 0; right: 0; width: max-content; max-width: calc(100% - 36px); margin: 0 auto; padding: 4px 11px; background: #fff6e5ed; color: #4f6761; font: 18px var(--handwriting); }
.scene-snow-field .scene-snow-crystal { width: 44px; height: 44px; }
.scene-snow-field .scene-snow-mitten { width: 74px; height: 74px; bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (max-width:360px) { .scene-snow-hud h2 { font-size: 18px; } .scene-snow-hud { left: 10px; right: 10px; } }


/* 保存页只缩预览，两份高清原图各有自己的下载入口。 */
.postcard-export .souvenir-export-tip { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.souvenir-export-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.souvenir-export-item { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.postcard-export .souvenir-output { width: auto; max-width: 100%; height: min(34dvh,280px); object-fit: contain; }
.postcard-export .souvenir-export-item > .game-control { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; margin: 0; padding: 6px 8px; box-sizing: border-box; }
.postcard-export .souvenir-edit { display: block; width: 100%; min-height: 44px; margin: 12px 0 0; }
.postcard-export .souvenir-status:empty { display: none; }


/* 首日先认识名字，再展开原故事。 */
.nickname-form { padding: 12px 0 8px; }
.nickname-form[hidden], .nickname-edit[hidden], .naming :is(.card-message,.card-gift,.card-actions)[hidden] { display: none; }
.nickname-form > label { display: block; font: 23px/1.4 var(--handwriting); color: var(--resident-ink); }
.nickname-form > p { margin: 10px 0 16px; font-size: 15px; line-height: 1.6; }
.nickname-input { display: block; box-sizing: border-box; width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #b99d77; border-radius: 3px; background: #fffbef99; color: #654b35; font: 17px/1.5 'PingFang SC',system-ui,sans-serif; caret-color: #754a39; }
.nickname-input::placeholder { color: #80684b; opacity: 1; }
.nickname-input:focus-visible { outline: 2px solid #71855b; outline-offset: 2px; }
.nickname-form > .nickname-limit { margin: 6px 0 16px; font-size: 12px; color: #795940; }
.nickname-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nickname-actions > .game-control { flex: 1 1 130px; min-height: 44px; font: 16px var(--handwriting); padding: 8px; }
.nickname-save:disabled { opacity: .5; cursor: default; }
.nickname-edit { margin: 0 0 0 8px; min-height: 44px; padding: 4px 8px; vertical-align: middle; font: 14px var(--handwriting); }
