/* おやくそくペット — 共通スタイル（配色は端末のダーク設定に左右されないよう固定） */
:root { color-scheme: light; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "M PLUS Rounded 1c", "Noto Sans JP", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  background: #fff8ea; color: #2b2233;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
img { max-width: 100%; }

/* ダイアログ */
.modal-wrap { position: fixed; inset: 0; background: rgba(20, 16, 30, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; animation: fadein .15s ease; }
.modal { background: #ffffff; color: #2b2233; border-radius: 24px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 28px 20px 20px; position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-x { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: none; background: #f1ecf5; color: #2b2233; font-size: 26px; line-height: 1; z-index: 2; }
.m-title { margin: 4px 44px 16px 0; font-size: 22px; line-height: 1.4; }
.zoom-modal { max-width: 900px; padding: 12px; background: #111; }
.zoom-img { display: block; width: 100%; border-radius: 12px; }

/* 通知 */
.toast-box { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #2b2233; color: #ffffff; padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 17px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: toastin .25s ease; transition: opacity .3s, transform .3s; text-align: center; }
.toast.good { background: #17663f; color: #ffffff; }
.toast.bad { background: #a3201a; color: #ffffff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px); } }
@keyframes fadein { from { opacity: 0; } }

/* お祝い（コインが降る） */
.celebrate { position: fixed; inset: 0; z-index: 85; pointer-events: auto; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.celebrate .fall { position: absolute; top: -40px; font-size: 34px; animation: fall 1.9s ease-in forwards; }
.cele-msg { background: #ffffff; color: #2b2233; border: 4px solid #ffcf3f; padding: 18px 28px; border-radius: 24px; font-size: 24px; font-weight: 800; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); max-width: 88vw; text-align: center; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ペットのアニメーション */
.pet { display: block; overflow: visible; }
.pet-anim { transform-box: fill-box; transform-origin: 50% 100%; animation: breathe 2.8s ease-in-out infinite; }
.egg-anim { animation: wobble 3.2s ease-in-out infinite; }
.pet.jump .pet-anim { animation: jump .6s ease; }
@keyframes breathe { 50% { transform: scale(1.035, .97); } }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-6deg); } 86% { transform: rotate(6deg); } 94% { transform: rotate(-3deg); } }
@keyframes jump { 30% { transform: translateY(-26px) scale(.96, 1.05); } 60% { transform: translateY(0) scale(1.08, .92); } }
@media (prefers-reduced-motion: reduce) { .pet-anim, .egg-anim, .celebrate .fall { animation: none !important; } }

/* れんらく */
.chat { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 6px 4px 10px; }
.b-row { display: flex; flex-direction: column; align-items: flex-start; max-width: 86%; }
.b-row.mine { align-self: flex-end; align-items: flex-end; }
.b-who { font-size: 13px; color: #574e62; margin: 0 0 3px 8px; font-weight: 700; }
.b-text { background: #f1ecf5; color: #2b2233; padding: 10px 14px; border-radius: 18px 18px 18px 6px; line-height: 1.6; word-break: break-word; }
.b-row.mine .b-text { background: #ffe7a6; color: #2b2233; border-radius: 18px 18px 6px 18px; }
.b-stamp { font-size: 56px; line-height: 1.1; }
.b-time { font-size: 12px; color: #615a6c; margin: 3px 8px 0; }
.b-letter { display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 16px; padding: 14px 22px; border: 2px solid; min-width: 170px; }
.bl-icon { font-size: 34px; }
.bl-title { font-weight: 800; font-size: 17px; }
.b-letter small { font-size: 12px; }

/* おてがみ（便箋） */
.letter { border-radius: 18px; padding: 22px 20px; border: 2px solid; background-image: repeating-linear-gradient(transparent 0 33px, var(--rule) 33px 34px); background-position: 0 14px; }
body .letter input, body .letter textarea { display: block; border-radius: 0; width: 100%; margin: 0; padding: 0; background: transparent; border: none; color: inherit; outline: none; line-height: 34px; font-size: 18px; resize: vertical; }
body .letter input { font-weight: 800; font-size: 20px; line-height: 34px; height: 34px; padding: 0; }
body .letter input::placeholder, body .letter textarea::placeholder { color: var(--ph); opacity: 1; }
.letter.reading .l-title { font-size: 22px; font-weight: 800; line-height: 34px; margin: 0; }
.letter.reading .l-body { font-size: 19px; line-height: 34px; white-space: normal; word-break: break-word; min-height: 136px; }
.letter.reading .l-from { text-align: right; font-weight: 700; margin-top: 10px; line-height: 34px; }
.letter-modal { max-width: 640px; }
.theme-sakura { background-color: #fff0f5; color: #4a2433; border-color: #f2a7bf; --rule: #f6c9d8; --ph: #6e4655; }
.theme-sora { background-color: #eef7ff; color: #1c3557; border-color: #9fcaf7; --rule: #c7e2fb; --ph: #40566f; }
.theme-mori { background-color: #effaf0; color: #1f3d26; border-color: #9fd6a9; --rule: #c9eacd; --ph: #3e5b45; }
.theme-hoshi { background-color: #1f2347; color: #fff8dc; border-color: #5560b0; --rule: #39407a; --ph: #d9d6f2; }
.theme-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.theme-b { border: 3px solid transparent; border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.theme-b.on { border-color: #2b2233; }
.stamp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stamp { font-size: 44px; background: #faf6fc; color: #2b2233; border: 2px solid #eadff2; border-radius: 18px; padding: 10px 0; }

/* にっき */
.diary { border: 2px solid #efe5d3; background: #ffffff; color: #2b2233; border-radius: 18px; padding: 14px 16px; margin-bottom: 12px; }
.d-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-mood { font-size: 30px; }
.d-day { font-weight: 800; }
.d-author { font-size: 14px; color: #574e62; }
.d-body { line-height: 1.8; margin: 8px 0; word-break: break-word; }
.d-photo { display: block; max-height: 320px; border-radius: 12px; cursor: zoom-in; margin: 6px 0; }
.d-comment { display: flex; gap: 10px; align-items: flex-start; background: #fff4d6; color: #3a2d12; border-radius: 14px; padding: 10px 12px; margin-top: 8px; line-height: 1.6; }
.d-stamp { font-size: 32px; line-height: 1; }
.prev-img { display: block; max-height: 220px; border-radius: 12px; margin: 8px 0; }
