/* 町（ui05 → ui09）。町は 1180×820 のワールド。背の低い画面（900×470）では横いっぱいに広げ（--tws＝900/1180）、
   場所の見開きは空を切って地面と人を見せ、地図は上下に動かせる（左右の無地の帯を出さない）。絵は地図1枚と場所の見開き（art_final9） */
.town { --tws: 1; overflow: hidden; background: #4f625b; }
.compact .town { --tws: .7627; --mk: 1.17; } /* --mk：地図の印の大きさ（iPhone は字 19×1.17×.7627≒17px） */
.tw-pan { position: absolute; inset: 0; overflow: hidden; }
.compact .town[data-view=map] .tw-pan { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.compact .town[data-view=map] .tw-pan::-webkit-scrollbar { display: none; }
.compact .town[data-view=map] .tw-pan::after { content: ''; display: block; height: 625.4px; } /* 820×.7627：ワールドの高さぶん動かせる */

/* 開いた本：布の表紙の上のページ（まん中は綴じ目の影） */
.tw-world { position: absolute; left: 0; top: 0; width: 1180px; height: 820px; transform-origin: 0 0; overflow: hidden; border-radius: 12px; isolation: isolate; background: #3d4d47; } /* 天気の層を上の帯（もどる・名前・日付）より上に出さない */
.compact .tw-world { transform: scale(var(--tws, 1)); }
.compact .town[data-view=place] .tw-world { transform: translateY(-155.4px) scale(var(--tws, 1)); } /* 625.4−470：空の上を切る */
/* 綴じ目：絵のまん中の色の境目を、開いた本の折り目として見せる（左右とも同じ影と光） */
.tw-world::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 30;
  background: linear-gradient(90deg, transparent 45.5%, rgba(60,40,20,.07) 48%, rgba(60,40,20,.2) 49.75%, rgba(255,250,235,.16) 50.25%, rgba(60,40,20,.07) 52%, transparent 54.5%);
  box-shadow: inset 0 0 0 10px #4f625b, inset 0 0 0 13px rgba(255,250,235,.25), inset 0 0 40px rgba(40,25,10,.25); border-radius: 12px; }
.tw-entrance { position: absolute; inset: 0; width: 100%; height: 100%; }
.tw-zoom { position: absolute; background: center / 100% 100% no-repeat; }
.tw-folk, .tw-hits, .tw-wx { position: absolute; inset: 0; }
.tw-folk, .tw-wx { pointer-events: none; }
.town[data-period=night] .tw-folk { filter: url(#tw-night); } /* town.js の NIGHT_FILTER：暗く青く */
.town[data-period=evening] .tw-folk { filter: url(#tw-eve); } /* 夕焼け：橙寄りで少し暗く（town.js の NIGHT_FILTER の中） */
.tw-who.flip > img { transform: scaleX(-1); }
.tw-who { position: absolute; }
.tw-who > img { display: block; width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;
  filter: drop-shadow(1.5px 0 0 #fbf6ea) drop-shadow(-1.5px 0 0 #fbf6ea) drop-shadow(0 -1.5px 0 #fbf6ea) drop-shadow(3px 3px 0 rgba(70,45,25,.2)); }
.tw-shadow { position: absolute; height: 16px; border-radius: 50%; background: radial-gradient(closest-side, rgba(60,40,20,.26), rgba(60,40,20,.08) 70%, rgba(60,40,20,0)); } /* 切り抜きの台に見えないよう、うすい接地の影 */

/* 押す所：地図は建物ごと、ページは人と地面の紙 */
.tw-place, .tw-hit, .tw-note { position: absolute; padding: 0; border: 0; background: transparent; border-radius: 18px; }
.tw-place:focus-visible, .tw-hit:focus-visible, .tw-note:focus-visible { outline: 4px solid #fff8e8; }
/* 地図の印：建物の前の道（足もと）に名前の札。上に住民の顔、まだの所は下に「じゅんび中」「うわさ」。z-index で手前の建物の押す所より上に */
.tw-mark { position: absolute; z-index: 2; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: calc(4px * var(--mk, 1)); pointer-events: none; }
/* final4：子どもは名前の札・顔を押す。札は場所の押す所（箱）の外にはみ出すので、札と顔も押せるようにする（その場所のボタンの中なので、その場所へ行く） */
.tw-mark > .tw-tag, .tw-mark > .tw-faces, .tw-mark > .tw-soon { pointer-events: auto; }
.tw-place:active .tw-tag { transform: translateY(3px); }
.tw-tag { position: relative; display: flex; align-items: center; gap: calc(4px * var(--mk, 1)); padding: calc(6px * var(--mk, 1)) calc(16px * var(--mk, 1)); white-space: nowrap;
  font-size: calc(19px * var(--mk, 1)); font-weight: 800; color: #24575a; background: var(--grain), #fffaf0; border-radius: 999px;
  box-shadow: inset 0 0 0 calc(2px * var(--mk, 1)) #2f6f73, 0 calc(3px * var(--mk, 1)) 0 #c9b48f, 0 8px 12px -6px rgba(30,20,10,.45); transition: transform .18s cubic-bezier(.3,1.7,.5,1); }
.tw-place.soon .tw-tag { color: #6b5640; box-shadow: inset 0 0 0 calc(2px * var(--mk, 1)) #b39a72, 0 calc(3px * var(--mk, 1)) 0 #c9b48f, 0 8px 12px -6px rgba(30,20,10,.35); background: var(--grain), #f6eedd; }
.tw-soon { display: flex; align-items: center; gap: calc(4px * var(--mk, 1)); margin-top: calc(-2px * var(--mk, 1)); padding: calc(3px * var(--mk, 1)) calc(10px * var(--mk, 1)); white-space: nowrap;
  font-size: calc(14px * var(--mk, 1)); font-weight: 700; color: #6b5640; background: #f4e3bd; border-radius: calc(6px * var(--mk, 1)); box-shadow: 0 calc(2px * var(--mk, 1)) 0 #c9b48f; transform: rotate(-3deg); }
.tw-soon svg { width: calc(18px * var(--mk, 1)); height: calc(18px * var(--mk, 1)); }
.tw-faces { display: flex; justify-content: center; gap: calc(2px * var(--mk, 1)); min-width: calc(124px * var(--mk, 1)); min-height: calc(48px * var(--mk, 1)); } /* 人がいない時も段を取る（名前の札が動かない） */
.tw-face { position: relative; display: block; } /* 切り抜きの上半身（.bust）。丸い枠・住民ごとのふちの色は使わない（ui14） */
.tw-face .bust { --edge: 1.6px; }
.tw-new-star { position: absolute; right: -6px; top: -6px; width: calc(18px * var(--mk, 1)); height: calc(18px * var(--mk, 1)); filter: drop-shadow(0 1px 0 rgba(120,90,40,.4)); }
.tw-story { width: calc(22px * var(--mk, 1)); height: calc(24px * var(--mk, 1)); }
.tw-spark { position: absolute; width: 38px; height: 38px; right: 6%; top: 4%; filter: drop-shadow(0 0 6px rgba(255,230,160,.95)); }
.tw-mark > .tw-spark { width: calc(30px * var(--mk, 1)); height: calc(30px * var(--mk, 1)); right: calc(-18px * var(--mk, 1)); top: auto; bottom: calc(22px * var(--mk, 1)); }
.tw-note .tw-spark { width: 30px; height: 30px; right: -6px; top: -14px; }
.tw-note .tw-spark + .tw-spark { width: 20px; height: 20px; right: auto; left: 2px; top: -4px; }
@media (prefers-reduced-motion: no-preference) {
  .tw-spark { animation: twinkle 1.8s ease-in-out infinite; }
  .tw-spark + .tw-spark { animation-delay: .7s; }
  .tw-hit .tw-label { animation: bob 2.2s ease-in-out infinite; }
  .tw-face.new .tw-new-star { animation: twinkle 1.8s ease-in-out infinite; }
}
@keyframes twinkle { 0%,100% { transform: scale(.7) rotate(0); opacity: .65; } 50% { transform: scale(1.1) rotate(25deg); opacity: 1; } }
@keyframes welcome { 0%,100% { transform: none; } 50% { transform: translateY(-3px); } }
.tw-hit .tw-label { position: absolute; left: 50%; top: calc(100% + 10px); transform: translateX(-50%); padding: calc(6px / var(--tws, 1)) calc(12px / var(--tws, 1)); white-space: nowrap;
  font-size: calc(16px / var(--tws, 1)); font-weight: 700; color: #24575a; background: #fffaf2; border: calc(2px / var(--tws, 1)) solid #2f6f73; border-radius: 18px; box-shadow: 0 2px 0 #c9b48f; }
.tw-hit.give .tw-label { color: #fff; background: #c9773f; border-color: #a35f30; box-shadow: 0 3px 0 #7d4a28; }
.tw-hit.above .tw-label { top: auto; bottom: calc(100% + 8px); }
.tw-note { width: 100px; height: 86px; } /* 大きさは town.js の noteSize（iPhone は大きく） */
.tw-note > svg:not(.tw-spark) { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(3px 4px 0 rgba(70,45,25,.22)); }
.tw-note > svg:not(.tw-spark):nth-of-type(2) { transform: translate(10px, -8px) rotate(7deg); }
.tw-note > svg:not(.tw-spark):nth-of-type(3) { transform: translate(-8px, -12px) rotate(-6deg); }
.tw-note.read > svg:not(.tw-spark) { opacity: .75; }
.talked-mark { position: absolute; left: 50%; top: 4%; width: calc(40px / var(--tws, 1)); height: calc(36px / var(--tws, 1)); margin-left: calc(-20px / var(--tws, 1)); filter: drop-shadow(0 2px 0 rgba(120,90,40,.35)); }
.talked-mark svg { display: block; width: 100%; height: 100%; }

/* 天気：雨・雪は人の上、押す所（場所の札・お話しする・紙）の下（動きを減らす時は止まった絵） */
.tw-wx { z-index: 4; }
.tw-hits { z-index: 5; }
.town[data-wx=rain] .tw-wx::after, .wx-fall.rain { content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(104deg, transparent 0 22px, rgba(120,150,175,.45) 22px 24px, transparent 24px 46px); background-size: 100% 60px; }
.town[data-wx=snow] .tw-wx::after, .wx-fall.snow { content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle 3.5px, #fff 96%, transparent) 0 0 / 70px 70px, radial-gradient(circle 2.5px, #fff 96%, transparent) 35px 30px / 90px 90px; }
@media (prefers-reduced-motion: no-preference) {
  .town[data-wx=rain] .tw-wx::after, .wx-fall.rain { animation: rain .55s linear infinite; }
  .town[data-wx=snow] .tw-wx::after, .wx-fall.snow { animation: snow 6s linear infinite; }
}
@keyframes rain { to { background-position: -14px 60px; } }
@keyframes snow { to { background-position: 30px 70px, 5px 120px; } }
/* 窓の外（お店） */
[data-wx] > .wx-sky { position: absolute; inset: 0; pointer-events: none; }
[data-wx=cloudy] > .wx-sky, [data-wx=rain] > .wx-sky { background: linear-gradient(rgba(150,160,168,.55), rgba(200,205,205,.25)); mix-blend-mode: multiply; }
[data-wx=snow] > .wx-sky { background: linear-gradient(rgba(220,228,236,.6), rgba(255,255,255,.2)); }
[data-wx] > .wx-fall { pointer-events: none; }
.wx-icon { width: 30px; height: 30px; margin-left: 8px; vertical-align: -7px; }
.compact .wx-icon { width: 24px; height: 24px; vertical-align: -6px; }

/* 上の帯：もどる・場所の名前・日付 */
.tw-ui { position: absolute; inset: 0; pointer-events: none; }
.tw-ui > *, .tw-ui button { pointer-events: auto; }
.tw-nav { position: absolute; left: 22px; top: 18px; display: flex; gap: 12px; }
.tw-nav button { min-height: 56px; padding: 0 22px; border: 0; border-radius: 28px; font-size: 19px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  transition: transform .18s cubic-bezier(.3,1.7,.5,1), box-shadow .18s ease; }
.tw-home { color: #fff; background: var(--teal); box-shadow: inset 0 2px 0 rgba(220,250,245,.35), 0 5px 0 var(--teal2), 0 10px 14px -4px rgba(20,50,50,.3); }
.tw-map { color: var(--teal2); background: var(--grain), #fffaf0; box-shadow: inset 0 0 0 2px #2f6f73, 0 4px 0 #c9b48f, 0 10px 14px -6px rgba(30,20,10,.4); }
.tw-nav button:active { transform: translateY(3px); }
.tw-title { position: absolute; left: 50%; top: 20px; transform: translateX(-50%); padding: 10px 34px; font-size: 24px; font-weight: 800; letter-spacing: .08em; color: #3b2f2a; pointer-events: none;
  background: var(--grain), linear-gradient(#fffcf5, #f6ead2); box-shadow: inset 0 0 0 1px rgba(160,120,70,.2), 0 3px 0 #e2cfab, 0 12px 16px -8px rgba(30,20,10,.45);
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%); }
.tw-date { top: 18px; right: 22px; }
.compact .tw-nav { left: 12px; top: 8px; gap: 8px; }
.compact .tw-nav button { min-height: 54px; padding: 0 16px; font-size: 16px; }
.compact .tw-title { top: 10px; font-size: 18px; padding: 8px 26px; }
.compact .tw-date { top: 8px; right: 12px; }

/* 会話は shop.js と同じ部品。町では返事を、話す人と反対の側にたてにならべる（足と体を返事でかくさない） */
.tw-talk { position: absolute; inset: 0; pointer-events: none; }
.tw-talk > * { pointer-events: auto; }
.town[data-mode=talk] .tw-tag, .town[data-mode=talk] .tw-label { visibility: hidden; }
.tw-talk .reply-options { left: auto; right: auto; bottom: 104px; width: 400px; flex-direction: column; align-items: stretch; gap: 12px; }
.tw-talk .reply-option { justify-content: center; }
.tw-talk[data-side=right] .reply-options { right: 28px; }
.tw-talk[data-side=left] .reply-options { left: 28px; }
.tw-talk .talk-close { bottom: 30px; }
.tw-talk[data-side=right] .talk-close { right: 28px; left: auto; }
.tw-talk[data-side=left] .talk-close { left: 28px; right: auto; }
.compact .tw-talk .reply-options { left: auto; right: auto; bottom: 78px; width: 290px; gap: 8px; }
.compact .tw-talk[data-side=right] .reply-options { right: 14px; }
.compact .tw-talk[data-side=left] .reply-options { left: 14px; }
.compact .tw-talk .reply-option { min-height: 56px; }
.compact .tw-talk .talk-close { bottom: 14px; }
.compact .tw-talk[data-side=right] .talk-close { right: 14px; left: auto; }
.compact .tw-talk[data-side=left] .talk-close { left: 14px; right: auto; }

/* 見つけた紙・かばん：めくれて開く */
.tw-find-veil { position: absolute; inset: 0; background: rgba(40,30,20,.28); }
.tw-find, .tw-bag-panel { position: absolute; left: 50%; top: 50%; width: 540px; margin: -150px 0 0 -270px; padding: 26px 34px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--grain), linear-gradient(#fffcf5, #f8eedb); border-radius: 6px 6px 16px 16px; transform-origin: 50% 100%;
  box-shadow: inset 0 0 0 1px rgba(160,120,70,.2), 0 4px 0 #e2cfab, 0 5px 0 rgba(140,100,55,.3), 0 22px 30px -12px rgba(40,25,10,.55); }
.tw-find::before { content: ''; position: absolute; right: 0; top: 0; width: 46px; height: 46px; background: linear-gradient(225deg, #e8d6b2 50%, transparent 50%); border-radius: 0 6px 0 0; }
.tw-kind { padding: 4px 18px; border-radius: 999px; background: #f4e3bd; color: #7d5f30; font-size: 16px; font-weight: 800; letter-spacing: .06em; }
.tw-find p, .tw-bag-panel p { margin: 0; font-size: 23px; line-height: 1.6; text-align: center; word-break: keep-all; overflow-wrap: break-word; line-break: strict; }
.tw-find-ok, .tw-bag-back { margin-top: 8px; min-width: 140px; min-height: 54px; padding: 0 26px; border: 0; border-radius: 27px; color: #fff; background: var(--teal); font-size: 19px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: inset 0 2px 0 rgba(220,250,245,.35), 0 5px 0 var(--teal2); }
.tw-bag-back { color: var(--teal2); background: var(--grain), #fffaf0; box-shadow: inset 0 0 0 2px #2f6f73, 0 4px 0 #c9b48f; }
.compact .tw-find, .compact .tw-bag-panel { width: 700px; margin: -110px 0 0 -350px; padding: 12px 24px 14px; gap: 6px; } /* 横長にして背を低く（住民の頭より上に開けるように） */
.compact .tw-find p, .compact .tw-bag-panel p { font-size: 18px; line-height: 1.5; }
.compact .tw-kind { font-size: 14px; padding: 4px 14px; }
.tw-bag-panel { margin-top: -200px; max-height: 420px; }
.compact .tw-bag-panel { top: 72px; margin-top: 0; max-height: 386px; }
.tw-items { display: flex; flex-direction: column; gap: 10px; width: 100%; max-height: 260px; overflow-y: auto; padding: 4px; }
.compact .tw-items { max-height: 220px; gap: 6px; }
.tw-item { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 6px 16px; border: 0; border-radius: 14px; text-align: left; color: #3b2f2a;
  background: var(--grain), #fffaf0; box-shadow: inset 0 0 0 2px #e2cfab, 0 3px 0 #dcc59c; }
.tw-item svg, .tw-item .tw-item-art { width: 48px; height: 48px; flex: none; object-fit: contain; }
.tw-item span { display: flex; flex-direction: column; gap: 2px; }
.tw-item b { font-size: 20px; }
.tw-item small { font-size: 15px; color: #7d6a52; }
.tw-item:active { transform: translateY(2px); }
.tw-bag-hint { font-size: 18px !important; color: #7d6a52; }
.tw-bag-row { display: flex; gap: 14px; }
/* かばん（落とし物を持っている時だけ）：左下 */
.tw-bag { position: absolute; left: 22px; bottom: 22px; width: 76px; height: 76px; padding: 4px; border: 0; border-radius: 22px; background: var(--grain), #fffaf0;
  box-shadow: inset 0 0 0 2px #c9a24a, 0 4px 0 #c9b48f, 0 10px 14px -6px rgba(30,20,10,.45); }
.tw-bag svg { width: 100%; height: 100%; }
.tw-bag b { position: absolute; right: -6px; top: -6px; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px; background: #c9773f; color: #fff; font-size: 17px; line-height: 28px; box-shadow: 0 0 0 3px #fffaf0; }
.tw-bag:active { transform: translateY(3px); }
.compact .tw-bag { left: 12px; bottom: 12px; width: 64px; height: 64px; }
/* わたす相手を選ぶ間の帯（上） */
.tw-give-bar { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 8px 10px 8px 26px; max-width: 760px;
  font-size: 21px; font-weight: 800; color: #3b2f2a; background: var(--grain), #fffaf0; border-radius: 999px; box-shadow: inset 0 0 0 2px #c9773f, 0 4px 0 #c9b48f, 0 12px 16px -8px rgba(30,20,10,.45); }
.tw-give-bar span { word-break: keep-all; overflow-wrap: break-word; line-break: strict; }
.tw-give-bar button { flex: none; min-height: 52px; min-width: 104px; padding: 0 20px; border: 0; border-radius: 26px; color: var(--teal2); font-size: 18px; font-weight: 800;
  background: var(--grain), #fffaf0; box-shadow: inset 0 0 0 2px #2f6f73, 0 3px 0 #c9b48f; }
.compact .tw-give-bar { top: 70px; font-size: 17px; padding: 4px 6px 4px 18px; max-width: 640px; }
.compact .tw-give-bar button { min-height: 56px; font-size: 16px; }
/* 続いている話の札（場所の見開きの左下、かばんの右） */
.tw-story-tag { position: absolute; left: 112px; bottom: 30px; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 18px; border: 0; border-radius: 16px;
  font-size: 18px; font-weight: 800; color: #6b4f2a; background: var(--grain), #f4e3bd; box-shadow: inset 0 0 0 2px #c9a24a, 0 4px 0 #c9b48f, 0 10px 14px -6px rgba(30,20,10,.4); }
.tw-story-tag .tw-story { width: 26px; height: 30px; margin: 0; }
.tw-story-tag:active { transform: translateY(3px); }
.compact .tw-story-tag { left: 88px; bottom: 14px; min-height: 56px; font-size: 16px; }
.tw-ui:not(:has(.tw-bag)) .tw-story-tag { left: 22px; }
.compact .tw-ui:not(:has(.tw-bag)) .tw-story-tag { left: 12px; }
/* まだの場所を押した時の小さな紙 */
.tw-hint { width: max-content; max-width: 360px; padding: 12px 20px; font-size: 19px; z-index: 6; }
.compact .tw-hint { font-size: 16px; max-width: 320px; }

/* ページをめくる紙 */
.tw-leaf { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; z-index: 50; transform-origin: 0 50%; pointer-events: none;
  background: var(--grain), linear-gradient(90deg, #efe4cc, #fbf5e6 30%, #f4ead4); box-shadow: -10px 0 30px rgba(40,25,10,.25); }

/* お店の扉から町へ（扉の絵に重ねる紙の札） */
.town-door { position: absolute; z-index: 11; padding: 0; border: 0; background: transparent; border-radius: 12px; }
.town-door span { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 7px 14px; white-space: nowrap; font-size: 17px; font-weight: 800; color: #fff;
  background: var(--teal); border-radius: 999px; box-shadow: inset 0 2px 0 rgba(220,250,245,.35), 0 3px 0 var(--teal2), 0 8px 12px -6px rgba(20,50,50,.5); }
.town-door:focus-visible { outline: 4px solid #fff8e8; }
.town-door:active span { transform: translateX(-50%) translateY(2px); }
.compact .town-door span { font-size: 15px; padding: 6px 12px; }
/* 帳の右のページ：はじめの画面へ・夜の町へ */
.ledger2 .lp-actions { margin-top: auto; display: flex; gap: 12px; justify-content: center; }
.ledger2 .lp-actions .to-home { margin-top: 0; }
.to-town { min-height: 56px; padding: 0 22px; border: 0; border-radius: 16px; font-size: 19px; font-weight: 700; color: var(--teal2); background: var(--grain), #fffaf0;
  box-shadow: inset 0 0 0 2px #2f6f73, 0 4px 0 #c9b48f; display: flex; align-items: center; justify-content: center; }
.compact .to-town { min-height: 54px; font-size: 17px; padding: 0 16px; }
/* 夜の仕込みの夜景に重ねる天気 */
.night-wx { position: absolute; inset: 0; pointer-events: none !important; }
.night-wx > .wx-fall { position: absolute; inset: 0; }
.night-wx[data-wx=cloudy] { background: linear-gradient(rgba(60,66,80,.35), transparent 60%); }
.tw-ui [hidden] { display: none !important; }
/* 雨・雪は art_final7 のくり返しの絵（--fall）。粒は大きめのくり返しでまばらに、うすく（字と顔を読みにくくしない） */
.town[style*="--fall"] .tw-wx::after { background: var(--fall) 0 0 / 400px 400px repeat; opacity: .5; }
.town[style*="--fall"][data-wx=snow] .tw-wx::after { opacity: .5; background-size: 460px 460px; }
@media (prefers-reduced-motion: no-preference) {
  .town[style*="--fall"][data-wx=rain] .tw-wx::after { animation: fall-rain .7s linear infinite; }
  .town[style*="--fall"][data-wx=snow] .tw-wx::after { animation: fall-snow 9s linear infinite; }
}
@keyframes fall-rain { to { background-position: -62px 400px; } }
@keyframes fall-snow { to { background-position: 52px 460px; } }
.wx-fall[style*="--fall-img"] { background: var(--fall-img) 0 0 / 300px 300px repeat; opacity: .7; }
@media (prefers-reduced-motion: no-preference) {
  .wx-fall.rain[style*="--fall-img"] { animation: fall-rain2 .7s linear infinite; }
  .wx-fall.snow[style*="--fall-img"] { animation: fall-snow2 9s linear infinite; }
}
@keyframes fall-rain2 { to { background-position: -45px 300px; } }
@keyframes fall-snow2 { to { background-position: 36px 300px; } }
/* 天気の空（town.js の skyLayer）：絵の空だけを、くもり・雨・雪の空に替える（朝やけ・夕日・月と星を出さない）。雲は紙の切り絵の重なり */
.tw-sky { position: absolute; pointer-events: none; --c1: #b4bec7; --c2: #dde2e4; --cl: rgba(238,241,243,.95); --cd: rgba(150,160,172,.7);
  background: var(--grain),
    radial-gradient(5.6% 2.8% at 12.1% 12.6%, var(--cl) 97%, transparent),
    radial-gradient(7.2% 3.6% at 17.0% 11.6%, var(--cl) 97%, transparent),
    radial-gradient(5.9% 3.0% at 22.4% 12.5%, var(--cl) 97%, transparent),
    radial-gradient(9.5% 3.8% at 17.4% 13.1%, var(--cd) 97%, transparent),
    radial-gradient(5.0% 2.5% at 47.6% 8.1%, var(--cl) 97%, transparent),
    radial-gradient(6.4% 3.2% at 52.0% 7.1%, var(--cl) 97%, transparent),
    radial-gradient(5.3% 2.6% at 56.8% 8.0%, var(--cl) 97%, transparent),
    radial-gradient(8.4% 3.4% at 52.4% 8.6%, var(--cd) 97%, transparent),
    radial-gradient(6.2% 3.1% at 76.5% 11.6%, var(--cl) 97%, transparent),
    radial-gradient(8.0% 4.0% at 82.0% 10.6%, var(--cl) 97%, transparent),
    radial-gradient(6.6% 3.3% at 88.0% 11.5%, var(--cl) 97%, transparent),
    radial-gradient(10.5% 4.2% at 82.4% 12.1%, var(--cd) 97%, transparent),
    linear-gradient(var(--c1), var(--c2) 22%); background-size: 180px 180px, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto; }
.town[data-wx=rain] .tw-sky { --c1: #8f9ba6; --c2: #c4cbd0; --cl: rgba(205,211,216,.85); --cd: rgba(118,130,142,.6); }
.town[data-wx=snow] .tw-sky { --c1: #c6ced8; --c2: #eef1f4; --cl: rgba(250,251,252,.92); --cd: rgba(186,196,208,.55); }
.town[data-period=evening] .tw-sky { --c1: #8e8290; --c2: #d2b6a6; --cl: rgba(222,200,190,.85); --cd: rgba(128,112,124,.55); }
.town[data-period=night] .tw-sky { --c1: #1b2233; --c2: #39435b; --cl: rgba(70,80,104,.85); --cd: rgba(32,40,58,.7); }
/* 天気の日は町の色も少し落とす（晴れと見分けがつくように）。窓の明かりは絵のまま */
.town[data-wx=cloudy] :is(.tw-entrance, .tw-zoom) { filter: saturate(.8) brightness(.97); }
.town[data-wx=rain] :is(.tw-entrance, .tw-zoom) { filter: saturate(.7) brightness(.9); }
.town[data-wx=snow] :is(.tw-entrance, .tw-zoom) { filter: saturate(.78) brightness(1.02); }
.town[data-period=night]:not([data-wx=sunny]) :is(.tw-entrance, .tw-zoom) { filter: saturate(.85) brightness(.94); }

/* 手紙箱（お店の扉の左のかべ） */
/* final4：来店の一言・答えの吹き出しを手紙箱・町への札より上に（数の札が文字にかぶっていた） */
.paper-shop > .shop-ui > .shop-bubble { z-index: 13; } /* お店の見開きだけ（作業台の吹き出しは数字キーより下のまま） */
.mailbox { position: absolute; z-index: 11; padding: 0; border: 0; background: transparent; }
.mailbox svg { width: 100%; height: 100%; filter: drop-shadow(3px 4px 0 rgba(70,45,25,.25)); }
.mailbox b { position: absolute; right: -4px; top: -6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: #c9773f; color: #fff; font-size: 16px; line-height: 26px; box-shadow: 0 0 0 3px #fffaf0; }
.mailbox:focus-visible { outline: 4px solid #fff8e8; border-radius: 10px; }
.mailbox:active { transform: translateY(2px); }
.mail-box { position: absolute; z-index: 30; left: 50%; top: 50%; width: 560px; margin: -230px 0 0 -280px; padding: 22px 30px 22px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--grain), linear-gradient(#f3e2c2, #e9d2a8); border-radius: 18px; box-shadow: inset 0 0 0 3px #b98c52, inset 0 0 0 7px #f6e9cf, 0 6px 0 #a67c45, 0 24px 30px -12px rgba(40,25,10,.55); }
.mail-box h2 { margin: 0; font-size: 22px; color: #6b4f2a; letter-spacing: .1em; }
.mail-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-height: 300px; overflow-y: auto; padding: 4px; }
.mail-item { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 6px 16px; border: 0; border-radius: 12px; text-align: left; color: #3b2f2a; font-size: 20px; font-weight: 700;
  background: var(--grain), #fffaf0; box-shadow: 0 3px 0 #d8c6a4, 0 8px 10px -6px rgba(40,25,10,.4); }
.mail-item img { width: 52px; height: 40px; object-fit: contain; flex: none; }
.mail-item span { display: flex; flex-direction: column; gap: 4px; line-height: 1.25; }
.mail-item small { display: block; font-size: 15px; font-weight: 500; color: #7d6a52; }
.mail-item.new { box-shadow: inset 0 0 0 2px #e8c169, 0 3px 0 #d8c6a4, 0 8px 10px -6px rgba(40,25,10,.4); }
.mail-empty { margin: 10px 0; font-size: 19px; color: #6b5640; text-align: center; }
.mail-close { min-width: 140px; min-height: 54px; padding: 0 26px; border: 0; border-radius: 27px; color: #fff; background: var(--teal); font-size: 19px; font-weight: 800; box-shadow: inset 0 2px 0 rgba(220,250,245,.35), 0 5px 0 var(--teal2); }
.compact .mail-box { width: 600px; top: 14px; margin: 0 0 0 -300px; padding: 12px 22px; gap: 8px; }
.compact .mail-list { max-height: 270px; gap: 6px; }
.compact .mail-item { min-height: 56px; font-size: 17px; }

/* 吹き出しを返事からよけた時、しっぽは話す人を指したまま（town.js の dodge） */
.tw-talk .shop-bubble.talk::after { left: calc(148px + var(--tail, 0px)); }

/* ==== ui09：町の暮らし ==== */
/* 地図の P1（いる場所の印の横。押せない） */
.tw-me { pointer-events: none; }
/* まだ開いていない建物：工事中（絵が届くまでは、その建物だけ色と明るさを落として柵） */
.tw-build { position: absolute; background-repeat: no-repeat; background-size: 1180px 820px; filter: saturate(.25) brightness(.78) sepia(.18); pointer-events: none;
  -webkit-mask-image: radial-gradient(64% 62% at 50% 52%, #000 72%, transparent 100%); mask-image: radial-gradient(64% 62% at 50% 52%, #000 72%, transparent 100%); }
.town[data-period=night] .tw-build { filter: saturate(.25) brightness(.62) sepia(.18); }
.tw-build-art { position: absolute; object-fit: contain; object-position: 50% 100%; pointer-events: none; }
.tw-fence { position: absolute; pointer-events: none; }
.tw-fence svg { display: block; width: 100%; height: auto; filter: drop-shadow(2px 3px 0 rgba(70,45,25,.3)); }
/* 品をわたす一コマ（品の絵が P1 の手から住民の手へ） */
.tw-gift { position: absolute; z-index: 3; pointer-events: none; filter: drop-shadow(0 6px 4px rgba(60,35,15,.3)); }
.tw-gift > * { width: 100%; height: 100%; object-fit: contain; display: block; }
.tw-gift > svg { background: #fffaf0; border-radius: 14px; box-shadow: inset 0 0 0 2px #c9a24a; padding: 8px; box-sizing: border-box; }
@media (prefers-reduced-motion: no-preference) { .tw-gift.held { animation: welcome 2s ease-in-out infinite; } }
/* 仲が進んだ時の小さな帯（上のまん中） */
.tw-bond { position: absolute; left: 50%; top: 86px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 22px; white-space: nowrap;
  font-size: 18px; font-weight: 800; color: #6b3f3f; background: var(--grain), #fff6f0; border-radius: 999px; box-shadow: inset 0 0 0 2px #e8a9a0, 0 3px 0 #dcc59c, 0 10px 14px -8px rgba(30,20,10,.4); pointer-events: none; }
.tw-bond svg { width: 24px; height: 22px; }
.tw-bond small { font-size: 15px; font-weight: 700; color: #8a6a5a; }
.compact .tw-bond { top: 70px; font-size: 16px; padding: 6px 16px; }
/* まだの場所の紙：しっぽを押した札へ（town.js の soonNote が向きを決める） */
.tw-hint::after { content: ''; position: absolute; border: 10px solid transparent; }
.tw-hint[data-tail=down]::after { left: calc(var(--tx) - 10px); bottom: -18px; border-top-color: #fffaf0; border-bottom: 0; height: 9px; }
.tw-hint[data-tail=up]::after { left: calc(var(--tx) - 10px); top: -18px; border-bottom-color: #fffaf0; border-top: 0; height: 9px; }
.tw-hint[data-tail=right]::after { top: calc(var(--tx) - 10px); right: -18px; border-left-color: #fffaf0; border-right: 0; width: 9px; }
.tw-hint[data-tail=left]::after { top: calc(var(--tx) - 10px); left: -18px; border-right-color: #fffaf0; border-left: 0; width: 9px; }
/* 雪の日：地面と屋根に、うすく雪（上の空は雲の層）。きらりは金でふちどって雪の粒と見分ける */
.tw-snowcover { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(transparent 18%, rgba(250,252,255,.34) 40%, rgba(250,252,255,.42)); mix-blend-mode: screen; }
.town[data-wx=snow] .tw-spark path { fill: #f2c25c; stroke: #b9802c; }
/* かばんの品の絵 */
.tw-bag-head { display: flex; align-items: center; gap: 12px; }
.tw-bag-head .tw-item-big { width: 72px; height: 72px; object-fit: contain; }
.compact .tw-bag-head .tw-item-big { width: 52px; height: 52px; }
.town[data-period=night] .tw-world::after { background: linear-gradient(90deg, transparent 45.5%, rgba(10,10,25,.1) 48%, rgba(10,10,25,.26) 49.75%, rgba(200,200,230,.06) 50.25%, rgba(10,10,25,.1) 52%, transparent 54.5%); } /* 夜は光の筋を弱く */

/* ui13 → ui14：通り。道しるべの見開き（広場のはしの絵に、石だたみの道しるべの柱と板）。通りの見開きは地図と同じ印 */
.tw-pole { position: absolute; left: 583px; top: 570px; width: 22px; height: 236px; border-radius: 6px; background: linear-gradient(90deg, #6f5230, #9a774a 45%, #7a5a34); box-shadow: 0 0 0 3px #fffaf0, 0 30px 0 -8px rgba(60,40,20,.0); }
.tw-pole::before { content: ''; position: absolute; left: -8px; top: -16px; width: 38px; height: 18px; background: #5b4024; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tw-pole::after { content: ''; position: absolute; left: -46px; bottom: -12px; width: 114px; height: 22px; border-radius: 50%; background: radial-gradient(closest-side, rgba(60,40,20,.32), rgba(60,40,20,0)); }
/* 道しるべの板（押す所 300×64 以上。iPhone の縮みでも 44pt 以上） */
.tw-board { position: absolute; width: 248px; height: 70px; padding: 0 30px 0 22px; border: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 26px; font-weight: 800; color: #4a3218; background: var(--grain), linear-gradient(#f6e2b6, #e8c98f);
  clip-path: polygon(0 0, 88% 0, 100% 50%, 88% 100%, 0 100%); filter: drop-shadow(0 5px 0 rgba(90,60,30,.35)); transition: transform .18s cubic-bezier(.3,1.7,.5,1); }
.tw-board.left { padding: 0 22px 0 30px; clip-path: polygon(12% 0, 100% 0, 100% 100%, 12% 100%, 0 50%); }
.tw-board b { font-weight: 800; }
.tw-board small { font-size: 16px; font-weight: 700; color: #7d6a52; padding: 2px 10px; border-radius: 8px; background: rgba(255,250,240,.7); }
.tw-board.soon { color: #7d6a52; background: var(--grain), linear-gradient(#efe6d4, #ddd0b6); }
.tw-board[data-street=plaza] { color: #fff; background: linear-gradient(#3b8287, #2f6f73); }
.tw-board:active { transform: translateY(3px); }
.tw-board:focus-visible, .tw-card:focus-visible { outline: 4px solid #fff8e8; }
.compact .tw-board { font-size: 28px; } /* 縮み .7627 で字 21px */
/* 札：顔の段（人がいない時も段を取る）＋板。板の下に杭 */
  background: var(--grain), #fffaf0; border-radius: 14px; box-shadow: inset 0 0 0 2.5px #2f6f73, 0 4px 0 #c9b48f, 0 12px 16px -8px rgba(30,20,10,.45); transition: transform .18s cubic-bezier(.3,1.7,.5,1); }
/* 旅人：「荷物を見る」と荷物の紙 */
.tw-hit.guest .tw-label { color: #6b3f1c; background: #fff4dc; border-color: #c9773f; }
.tw-guest { gap: 8px; }
.tw-guest-head { display: flex; align-items: center; gap: 16px; }
.tw-guest-head b { display: block; font-size: 26px; color: #3b2f2a; }
.tw-guest-head small { display: block; font-size: 17px; color: #7d6a52; }
.tw-guest-head .bust { --edge: 2.5px; }
.tw-brings-title { font-size: 16px; font-weight: 800; color: #8a6a3c; letter-spacing: .1em; }
.tw-brings { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0; padding: 0; list-style: none; }
.tw-brings li { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 16px 4px 8px; border-radius: 24px; background: #fff; box-shadow: inset 0 0 0 2px #e2cfab; font-size: 19px; font-weight: 700; color: #4a3218; }
.tw-brings li svg { width: 34px; height: 34px; }
.compact .tw-guest { gap: 4px; }
.compact .tw-guest-head b { font-size: 21px; }
.compact .tw-brings li { min-height: 44px; font-size: 16px; }
/* 地図・通りの右下のめくり（iPhone は少し小さく） */
.tw-turn span { right: 10px; bottom: 16px; }
.compact .tw-turn { width: 124px; height: 108px; }
.compact .tw-turn span { width: 84px; font-size: 15px; right: 8px; bottom: 12px; }

/* ui13：住民の帳（お店の棚の上の本から） */
.people-book-door { position: absolute; z-index: 11; padding: 0; border: 0; background: transparent; }
.people-book-door svg { width: 100%; height: 100%; filter: drop-shadow(3px 4px 0 rgba(70,45,25,.25)); }
.people-book-door:active { transform: translateY(2px); }
.people-book-door:focus-visible { outline: 4px solid #fff8e8; border-radius: 10px; }
.people-book { position: absolute; z-index: 40; left: 50%; top: 50%; width: 760px; margin: -330px 0 0 -380px; padding: 20px 32px 22px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--grain), linear-gradient(#fffcf5, #f6ead2); border-radius: 8px 8px 18px 18px; box-shadow: inset 0 0 0 1px rgba(160,120,70,.2), 0 4px 0 #e2cfab, 0 24px 34px -12px rgba(40,25,10,.55); }
.people-book::before { content: ''; position: absolute; left: 50%; top: 64px; bottom: 84px; width: 2px; margin-left: -1px; background: linear-gradient(transparent, rgba(160,120,70,.25), transparent); }
.people-book h2 { margin: 0; font-size: 26px; letter-spacing: .12em; color: #3b2f2a; }
.pb-tabs { display: flex; gap: 10px; }
.pb-tab { min-width: 140px; min-height: 50px; padding: 0 20px; border: 0; border-radius: 25px; font-size: 19px; font-weight: 800; color: var(--teal2); background: #fffaf0; box-shadow: inset 0 0 0 2px #c9b48f; }
.pb-tab[aria-selected=true] { color: #fff; background: var(--teal); box-shadow: 0 4px 0 var(--teal2); }
.pb-grid { display: grid; grid-template-columns: repeat(4, 160px); grid-auto-rows: 158px; gap: 16px 22px; justify-content: center; min-height: 332px; padding-top: 6px; }
/* 紙の切れはし：いつもの場所の絵の上に、その場所らしい姿の切り絵。上の2つの角にマスキングテープ、下に紙のラベル */
.pb-card { position: relative; display: block; width: 160px; height: 150px; padding: 8px 8px 30px; border: 0; background: #fffdf6; transform: rotate(var(--tilt, 0deg));
  box-shadow: 0 1px 0 rgba(160,120,70,.25), 2px 5px 8px -3px rgba(60,40,20,.35); }
button.pb-card:active { transform: rotate(var(--tilt, 0deg)) translateY(2px); }
.pb-photo { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; background: #efe5d2 50% 74% / 300% auto no-repeat; }
.pb-cut { position: absolute; left: 50%; max-width: none; filter: drop-shadow(1.5px 0 0 #fffaf0) drop-shadow(-1.5px 0 0 #fffaf0) drop-shadow(0 -1.5px 0 #fffaf0) drop-shadow(2px 3px 1px rgba(60,40,20,.35)); }
.pb-tape { position: absolute; top: -9px; width: 46px; height: 18px; background: repeating-linear-gradient(90deg, rgba(232,193,105,.75) 0 6px, rgba(240,210,140,.75) 6px 12px); box-shadow: 0 1px 1px rgba(80,60,30,.15); }
.pb-tape.a { left: -10px; transform: rotate(-32deg); }
.pb-tape.b { right: -10px; transform: rotate(28deg); background: repeating-linear-gradient(90deg, rgba(150,190,180,.75) 0 6px, rgba(175,210,200,.75) 6px 12px); }
.pb-label { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%) rotate(-1.5deg); padding: 1px 12px; white-space: nowrap; font-size: 17px; font-weight: 800; color: #3b2f2a; background: #f4e3bd; clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 50%, calc(100% - 6px) 100%, 6px 100%, 0 50%); }
.pb-card.empty { background: transparent; box-shadow: none; }
.pb-card.empty .pb-photo { background: rgba(160,130,90,.08); outline: 2px dashed rgba(160,130,90,.28); outline-offset: -2px; }
.pb-card.empty .pb-cut { filter: brightness(0) opacity(.16); }
/* 「はじめまして」の押し印（本人のページを開くと消える） */
.pb-stamp { position: absolute; right: -8px; top: 10px; padding: 3px 8px; font-size: 14px; font-style: normal; font-weight: 900; color: #c2463a; border: 2.5px solid #c2463a; border-radius: 6px; background: rgba(255,250,240,.75); transform: rotate(12deg); letter-spacing: .05em; }
.pb-empty { margin: 0; font-size: 19px; color: #7d6a52; word-break: keep-all; overflow-wrap: break-word; line-break: strict; }
.pb-row { display: flex; gap: 16px; align-items: center; }
.pb-row button { min-width: 64px; min-height: 56px; padding: 0 22px; border: 0; border-radius: 28px; font-size: 20px; font-weight: 800; color: var(--teal2); background: #fffaf0; box-shadow: inset 0 0 0 2px #2f6f73, 0 4px 0 #c9b48f; }
.pb-row .pb-close, .pb-row .pb-back { min-width: 140px; color: #fff; background: var(--teal); box-shadow: 0 5px 0 var(--teal2); }
.pb-row button:disabled { opacity: .35; }
.pb-detail { display: flex; align-items: center; gap: 34px; min-height: 360px; }
.pb-card.big { width: 340px; height: 320px; padding: 12px 12px 44px; }
.pb-card.big .pb-label { font-size: 24px; bottom: 8px; padding: 2px 18px; }
.pb-card.big .pb-tape { width: 70px; height: 24px; top: -11px; }
.pb-text small { display: block; font-size: 20px; color: #7d6a52; }
.pb-text p { margin: 14px 0 0; max-width: 300px; font-size: 21px; line-height: 1.6; word-break: keep-all; overflow-wrap: break-word; line-break: strict; }
.pb-text .pb-like { font-size: 18px; color: #5b4630; }
.pb-text .pb-met { font-size: 17px; color: #8a6a3c; }
.compact .people-book { width: 820px; top: 6px; margin: 0 0 0 -410px; padding: 6px 22px 8px; gap: 5px; }
.compact .people-book h2 { font-size: 20px; }
.compact .pb-tab { min-height: 54px; font-size: 17px; } /* iPhone 844×390 の縮み .83 でも 44pt */
.compact .pb-grid { grid-template-columns: repeat(4, 150px); grid-auto-rows: 116px; gap: 10px 26px; min-height: 242px; }
.compact .pb-card { width: 150px; height: 112px; padding: 6px 6px 24px; }
.compact .pb-label { font-size: 15px; }
.compact .pb-row button { min-width: 64px; min-height: 54px; font-size: 17px; }
.compact .people-book::before { top: 52px; bottom: 64px; }
.compact .pb-detail { min-height: 270px; gap: 24px; }
.compact .pb-card.big { width: 260px; height: 240px; }

/* ui14：切り抜きの上半身のシール（art.js の bust）。丸い枠は使わない。白いふちは絵の線にそう（下だけ、ゆるい弧で切る） */
.bust { position: relative; display: inline-block; flex: none; transform: rotate(var(--tilt, -4deg));
  filter: drop-shadow(var(--edge, 2px) 0 0 #fffaf0) drop-shadow(calc(-1 * var(--edge, 2px)) 0 0 #fffaf0) drop-shadow(0 var(--edge, 2px) 0 #fffaf0) drop-shadow(0 calc(-1 * var(--edge, 2px)) 0 #fffaf0) drop-shadow(2px 3px 1.5px rgba(70,45,25,.32)); }
.bust > i { position: absolute; inset: 0; overflow: hidden; -webkit-mask-image: radial-gradient(95% 100% at 50% 0%, #000 98%, transparent 100%); mask-image: radial-gradient(95% 100% at 50% 0%, #000 98%, transparent 100%); }
.bust img { position: absolute; max-width: none; }
