/* FXクエストのペットの窓・ご飯の映像・今日の一枚・アルバム (2026-10-15・pet_ui.js / pet_movie.js)
   色は town.html の変数 (--solid・--ink・--sub・--line・--accent) を使う = 暗い画面でも読める */

/* ---- ご飯の映像 (画面いっぱい・上に重ねる) ---- */
.pmWrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(8, 6, 4, 0.82); padding: 12px; animation: pmIn 0.22s ease; }
.pmWrap.out { opacity: 0; transition: opacity 0.2s ease; }
@keyframes pmIn { from { opacity: 0; } to { opacity: 1; } }
.pmStage { position: relative; width: min(960px, 100%); aspect-ratio: 16 / 10; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 14px; overflow: hidden; box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6); background: #20140c; }
.pmCanvas { display: block; width: 100%; height: 100%; }
.pmSkip { position: absolute; right: 10px; top: 10px; min-height: 44px; min-width: 88px; padding: 6px 14px; border-radius: 22px; border: 2px solid rgba(255, 255, 255, 0.8); background: rgba(20, 12, 6, 0.55); color: #fff; font: inherit; font-size: 16px; font-weight: bold; cursor: pointer; }
.pmSkip:hover, .pmSkip:focus-visible { background: rgba(20, 12, 6, 0.8); outline: 3px solid #ffd84a; }
/* スマホの縦: 映像は縦長に (場面は真ん中に合わせて描く) */
@media (max-aspect-ratio: 3/4) {
  .pmStage { aspect-ratio: 3 / 4; width: 100%; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
}
/* 本物の絵と動画 (10-16・横長 16:9 の絵なので、スマホの縦でも横長のまま) */
.pmStage.art, .pmStage.art.still { aspect-ratio: 16 / 9; width: min(1040px, 100%); background: #f6eddc; }
@media (max-aspect-ratio: 3/4) { .pmStage.art { aspect-ratio: 16 / 9; } }
.pmArt { position: absolute; inset: 0; }
.pmArt img, .pmArt video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pmArt img { opacity: 0; transition: opacity 0.4s ease; }
.pmArt img.on { opacity: 1; }
.pmArt img.kb { transform: scale(1); transition: opacity 0.4s ease, transform 1.9s ease-out; }
.pmArt img.kb.on { transform: scale(1.07); }
.pmSay { position: absolute; left: 4%; top: 6%; margin: 0; max-width: 60%; padding: 8px 16px; border-radius: 20px; background: #fffaf0; color: #3a2412; border: 3px solid #7a5230; font-size: clamp(16px, 2.6vw, 24px); font-weight: 900; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); opacity: 0; transform: translateY(-6px); transition: opacity 0.25s ease, transform 0.25s ease; overflow-wrap: anywhere; }
.pmSay.on { opacity: 1; transform: none; }
.pmPop { position: absolute; right: 8%; top: 20%; margin: 0; font-size: clamp(22px, 4vw, 40px); font-weight: 900; color: #d4622a; text-shadow: 0 2px 0 #fff, 0 0 8px rgba(255, 255, 255, 0.9); opacity: 0; pointer-events: none; transform: rotate(8deg); }
.pmPop.on { animation: pmPop 0.9s ease both; }
@keyframes pmPop { 0% { opacity: 0; transform: rotate(8deg) scale(0.6); } 20% { opacity: 1; transform: rotate(8deg) scale(1.08); } 75% { opacity: 1; transform: rotate(8deg) translateY(-6px); } 100% { opacity: 0; transform: rotate(8deg) translateY(-14px); } }
.pmCard { position: absolute; left: 50%; bottom: 6%; margin: 0; transform: translate(-50%, 10px); padding: 8px 24px; border-radius: 26px; background: linear-gradient(#fffaf0, #f3e6cc); border: 3px solid #7a5230; color: #3a2412; font-size: clamp(16px, 2.8vw, 26px); font-weight: 900; white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; }
.pmCard.on { opacity: 1; transform: translate(-50%, 0); }
/* おやつ (10-20): 札は金色・字は桃色 (コードの映像のおやつと同じ色) */
.pmCard.rich { background: linear-gradient(#fff3c4, #f6d77a); border-color: #b8862e; }
.pmStage.treat .pmPop { color: #e85a7a; }
@media (prefers-reduced-motion: reduce) { .pmArt img, .pmArt img.kb, .pmSay, .pmCard { transition: none; } .pmArt img.kb.on { transform: none; } .pmPop.on { animation: none; } }

/* ---- ペットの窓 (お世話) ---- */
#petDlg, #petPicDlg { position: fixed; inset: 0; z-index: 14; display: flex; align-items: flex-start; justify-content: center; background: rgba(10, 20, 30, 0.55); padding: 16px; overflow-y: auto; }
#petPicDlg { z-index: 42; align-items: center; background: rgba(8, 6, 4, 0.7); }
#petDlg.hidden, #petPicDlg.hidden { display: none; }
#petCard { max-width: 560px; }
.petHero { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.petHero canvas { width: 200px; height: 180px; border-radius: 14px; background: linear-gradient(#f6eadb, #e9d6bb); flex: 0 0 auto; }
.petHeroInfo { flex: 1 1 200px; min-width: 0; }
.petName { font-size: 26px; font-weight: bold; margin: 0; overflow-wrap: anywhere; }
.petBreed { color: var(--sub); font-size: 15px; margin: 0 0 6px; }
.petTrait { font-size: 15px; margin: 0; color: var(--sub); }
.petLv { margin-top: 8px; font-size: 16px; }
.petLv b { color: #c0506a; }
.petGauge { position: relative; height: 14px; border-radius: 7px; background: color-mix(in srgb, #e85a7a 14%, var(--solid)); border: 1px solid var(--line); overflow: hidden; margin: 4px 0 2px; }
.petGauge > span { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #ff8fa3, #e85a7a); border-radius: 7px; transition: width 0.6s ease; }
.petGaugeNote { font-size: 14px; color: var(--sub); }
.petSec { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px; }
.petSec h3 { font-size: 18px; margin: 2px 0 6px; }
.petBtns { display: flex; gap: 8px; flex-wrap: wrap; }
.petBtns .pbtn { min-height: 48px; font-size: 17px; flex: 1 1 160px; }
.petBtns .pbtn.main { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: bold; }
.petBtns .pbtn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, var(--solid)); border: 2px solid var(--accent); font-weight: bold; }
.petWalk { height: 10px; border-radius: 5px; background: color-mix(in srgb, #4f9a46 14%, var(--solid)); border: 1px solid var(--line); overflow: hidden; margin: 4px 0; }
.petWalk > span { display: block; height: 100%; background: linear-gradient(90deg, #8cc96a, #4f9a46); }
.petTricks { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; padding: 0; list-style: none; }
.petTricks li { padding: 3px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--solid); font-size: 15px; }
.petTricks li.got { background: color-mix(in srgb, #e8a030 18%, var(--solid)); border-color: #d9a030; font-weight: bold; }
.petTricks li.next { color: var(--sub); border-style: dashed; }
.petTricks li.got { padding: 0; }
.petTricks .ptBtn { min-height: 36px; padding: 3px 12px; border: 0; border-radius: 14px; background: transparent; color: inherit; font: inherit; font-weight: bold; cursor: pointer; }
.petTricks .ptBtn:hover, .petTricks .ptBtn:focus-visible { outline: 3px solid var(--accent); }
.paTricks { margin-bottom: 6px; }
.petNote { font-size: 14px; color: var(--sub); margin: 4px 0; }
.petToday { width: 200px; transform: rotate(-1.5deg); }

/* ---- 今日の一枚 ---- */
#petPicCard { max-width: 460px; text-align: center; padding: 16px; }
#petPicCard canvas { width: min(400px, 100%); height: auto; display: block; margin: 4px auto 6px; transform: rotate(-1.2deg); filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
#petPicCard .ppTitle { font-size: 20px; font-weight: bold; margin: 2px 0; }
#petPicCard .ppLines { font-size: 16px; margin: 4px 0 8px; }
#petPicCard .ppLines b { color: #c0506a; }
#petPicCard .ppUp { color: #b8862e; font-weight: bold; }
#petPicCard .petBtns { justify-content: center; }
.ppShine { animation: ppShine 1.4s ease 0.2s 1 both; }
@keyframes ppShine { 0% { transform: rotate(-1.2deg) scale(0.86); opacity: 0; } 60% { transform: rotate(-1.2deg) scale(1.03); opacity: 1; } 100% { transform: rotate(-1.2deg) scale(1); } }
@media (prefers-reduced-motion: reduce) { .ppShine { animation: none; } .pmWrap { animation: none; } }

/* ---- 受付の窓の「ペットを飼う」: 選んだ種類の 3 面図 (10-16・本物の絵がある時だけ) ---- */
.innSheet { margin: 10px 0 6px; padding: 0; }
.innSheet.hidden { display: none; }
.innSheet img { display: block; width: 100%; max-width: 560px; aspect-ratio: 960 / 536; height: auto; border-radius: 12px; border: 1px solid var(--line); background: #f6eddc; }
.innSheet figcaption { font-size: 15px; color: var(--sub); margin-top: 4px; }

/* ---- 受付の窓のペットの一覧 ---- */
.petList { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.petRow { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--solid); }
.petRow canvas { width: 64px; height: 58px; border-radius: 10px; background: linear-gradient(#f6eadb, #e9d6bb); flex: 0 0 auto; }
.petRow .prMain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.petRow .prName { font-weight: bold; font-size: 17px; overflow-wrap: anywhere; }
.petRow .prSub { font-size: 13px; color: var(--sub); }
.petRow .prBtns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.petRow .prBtns .pbtn { min-height: 40px; padding: 2px 10px; font-size: 15px; }
.petRow .prBtns .pbtn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, var(--solid)); border: 2px solid var(--accent); font-weight: bold; }
.petRow.out { border: 2px solid color-mix(in srgb, var(--accent) 60%, var(--line)); }
/* 名前を変える欄 (宿の受付・10-16 夜) */
.petRow .petRename { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.petRow .petRenameIn { flex: 1 1 8em; min-width: 0; min-height: 40px; padding: 4px 10px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--solid); color: var(--ink); }
.petRow .petRename .pbtn { min-height: 40px; padding: 2px 12px; font-size: 15px; }

/* ---- アルバム (航海手帳) ---- */
.paPets { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.paPets button { min-height: 44px; padding: 4px 12px; border-radius: 22px; border: 1px solid var(--line); background: var(--solid); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.paPets button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: bold; }
.paPets canvas { width: 30px; height: 27px; border-radius: 6px; background: #efe2cf; }
.paHead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.paCount { font-size: 16px; }
.paCount b { color: #c0506a; font-size: 20px; }
.paGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 8px; }
.paCell { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 6px 6px 4px; background: #fffdf7; border: 1px solid #e3d6bf; border-radius: 4px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); cursor: pointer; font: inherit; color: #3a2412; text-align: center; transition: transform 0.15s ease; }
.paCell:nth-child(3n + 1) { transform: rotate(-1deg); }
.paCell:nth-child(3n + 2) { transform: rotate(0.8deg); }
.paCell:hover, .paCell:focus-visible { transform: rotate(0) scale(1.03); outline: 3px solid var(--accent); }
.paCell canvas { width: 100%; height: auto; display: block; border-radius: 2px; }
.paCell .paName { font-size: 14px; font-weight: bold; }
.paCell .paDay { font-size: 12px; color: #8a6a4a; }
.paCell.locked { background: #f1e9dc; cursor: default; box-shadow: none; }
.paCell.locked .paName { color: #9a8a74; }
@media (max-width: 520px) { .paGrid { grid-template-columns: repeat(2, 1fr); } .petHero canvas { width: 100%; height: 200px; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .paCell { background: #fbf6ea; }
  :root:not([data-theme="light"]) .petHero canvas, :root:not([data-theme="light"]) .petRow canvas { background: linear-gradient(#e8dcc8, #d6c2a2); }
}
