/* Final Chapter — character, scene, moods, shop, room. */

/* ---------- top bar / fab coin ---------- */
.buddy-mini-side { display: grid; gap: 3px; justify-items: start; }
.coin-mini { font-size: .72rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.coin-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: #F6E3A8; color: #4A3505; font-weight: 800; font-size: .85rem; font-variant-numeric: tabular-nums; }

/* ---------- scene ---------- */
.scene { position: relative; overflow: hidden; border-radius: 18px; background: var(--surface-2); isolation: isolate; }
.scene--room { aspect-ratio: 756 / 500; }
.scene--stage { aspect-ratio: 4 / 4.2; }
.sc-room { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene--stage .sc-room { object-position: 38% 50%; filter: saturate(.9) brightness(.92); }
.sc-item, .sc-pet { position: absolute; height: auto; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.sc-shelf { position: absolute; height: 1.4%; border-radius: 3px; background: linear-gradient(#B07A4A, #7A4E2A); box-shadow: 0 3px 4px rgba(0, 0, 0, .3); transform: translateY(100%); }
.sc-char { position: absolute; }
.sc-char img { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); transform-origin: 50% 100%; }

/* moods */
.mood-happy .sc-char img { animation: hop 2.4s ease-in-out infinite; }
.mood-hungry .sc-char img, .mood-thirsty .sc-char img { transform: translateY(2%) rotate(-1.5deg); }
.mood-tired .sc-char img { filter: grayscale(.35) brightness(.85) drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); animation: sway 4s ease-in-out infinite; }
.mood-cold .sc-char img { animation: shiver .18s linear infinite; }
.mood-studying .sc-char img { animation: nod 3s ease-in-out infinite; }
@keyframes hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-4%); } 88% { transform: translateY(0); } 93% { transform: translateY(-1.5%); } }
@keyframes sway { 0%, 100% { transform: rotate(-1deg); } 50% { transform: rotate(1.5deg) translateY(1%); } }
@keyframes shiver { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-.6%); } 75% { transform: translateX(.6%); } }
@keyframes nod { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(1.2deg); } }

.fx { position: absolute; pointer-events: none; font-size: clamp(14px, 6cqw, 30px); line-height: 1; }
.scene { container-type: inline-size; }
.fx-spark { top: 8%; right: 18%; animation: twinkle 1.6s ease-in-out infinite; }
.fx-spark.fx-2 { top: 20%; right: auto; left: 14%; animation-delay: .8s; font-size: .8em; }
.fx-bubble { top: 6%; right: 6%; padding: .25em .35em; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); animation: float 2.4s ease-in-out infinite; }
.fx-bubble::after { content: ''; position: absolute; left: 0; bottom: -.25em; width: .35em; height: .35em; border-radius: 50%; background: #fff; }
.fx-zzz { top: 10%; right: 18%; font-weight: 800; color: #7B68C9; font-family: var(--font-hand); animation: zzz 2.4s ease-in infinite; opacity: 0; }
.fx-zzz.fx-2 { animation-delay: .8s; } .fx-zzz.fx-3 { animation-delay: 1.6s; font-size: 1.3em; }
.fx-snow { top: -10%; left: 20%; color: #fff; text-shadow: 0 0 4px #7FA7D9; animation: snow 3s linear infinite; }
.fx-snow.fx-2 { left: 55%; animation-delay: 1s; } .fx-snow.fx-3 { left: 80%; animation-delay: 2s; }
.fx-book { bottom: 18%; left: 8%; animation: float 1.6s ease-in-out infinite; }
.fx-pencil { bottom: 26%; left: 26%; animation: scribble .9s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.7) rotate(0); } 50% { opacity: 1; transform: scale(1.1) rotate(20deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12%); } }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(60%, -160%); } }
@keyframes snow { from { transform: translateY(0) rotate(0); opacity: 1; } to { transform: translateY(1200%) rotate(180deg); opacity: 0; } }
@keyframes scribble { 0%, 100% { transform: translate(0, 0) rotate(-10deg); } 50% { transform: translate(30%, 10%) rotate(12deg); } }

/* mini avatar reacts too */
[data-mood="hungry"]::before, [data-mood="tired"]::before, [data-mood="cold"]::before, [data-mood="thirsty"]::before {
  position: absolute; top: -6px; right: -6px; font-size: .8rem;
}
[data-buddy-avatar] { position: relative; overflow: visible !important; }
[data-buddy-avatar] img { border-radius: 50%; }
[data-mood="hungry"]::before { content: '🍜'; }
[data-mood="thirsty"]::before { content: '💧'; }
[data-mood="tired"]::before { content: '💤'; }
[data-mood="cold"]::before { content: '❄️'; }
[data-mood="cold"] img { animation: shiver .2s linear infinite; }

/* ---------- character card (sheet / popup) ---------- */
.buddy-head { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.buddy-head .buddy-name { margin: 0; flex: 1; }
.buddy-mood { margin: 2px 0 8px; font-family: var(--font-hand); font-size: 1.25rem; color: var(--muted); }
.needs--full .need { grid-template-columns: 20px 1fr 26px; }
.need-val { font-size: .75rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.pet-row { display: flex; gap: 8px; margin-top: 10px; }
.pet-chip { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.pet-chip img { width: 30px; height: 30px; object-fit: contain; }
.pet-chip .bar { width: 46px; height: 5px; }
.buddy-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.buddy-actions .btn { padding: 0 6px; }
.buddy-card .scene--stage { max-height: 48dvh; margin: 0 auto; }

/* feed sheet */
.feed-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.feed-list li { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; background: var(--surface); }
.feed-list img { width: 44px; height: 44px; object-fit: contain; flex: none; }
.feed-text { flex: 1; display: grid; min-width: 0; }

/* ---------- room & shop (one page) ---------- */
.room-page { display: grid; gap: 18px; }
.room-top { display: grid; gap: 14px; align-items: start; }
@media (min-width: 900px) { .room-top { grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); } }
.room-frame { scroll-margin-top: 90px; }
.room-frame .scene { box-shadow: var(--shadow); }
.room-info { display: grid; gap: 10px; }
.room-info .card-title { margin: 0; }
.room-info p { margin: 0; }
.room-coins { display: flex; align-items: center; gap: 12px; }
.room-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.room-level { display: grid; gap: 3px; text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); }
.room-level img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; filter: grayscale(.8) opacity(.6); }
.room-level.is-on { color: var(--text); }
.room-level.is-on img { filter: none; }
.buddy-panel .buddy-actions .btn { font-size: .78rem; white-space: nowrap; }

.shop { display: grid; gap: 10px; }
.coin-big { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 6px 16px; border-radius: 999px; background: #FFE9A6; color: #4A3505; font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.shop-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; position: sticky; top: 64px; z-index: 5; padding-top: 4px; background: var(--bg); }
@media (min-width: 900px) { .shop-tabs { flex-wrap: wrap; overflow: visible; top: 72px; } }
.shop-tabs .chip { flex: none; }
.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .shop-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; } }
.shop-card { display: grid; gap: 4px; align-content: start; padding: 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.shop-card.is-owned { border-color: color-mix(in srgb, #3F9B62 50%, var(--line)); }
.shop-img { display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.shop-img img { max-width: 82%; max-height: 82%; object-fit: contain; }
.shop-img--tall { aspect-ratio: 3 / 4; }
.shop-img--tall img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.shop-name { font-size: .9rem; line-height: 1.2; }
.shop-act { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; justify-content: space-between; margin-top: 4px; }
.price { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: .85rem; font-variant-numeric: tabular-nums; }
.shop-wide { grid-column: 1 / -1; }

/* coin (CSS, not the 🪙 emoji: many desktop fonts lack it) */
.coin {
  display: inline-block; width: 1.05em; height: 1.05em; border-radius: 50%; vertical-align: -.17em; flex: none;
  background: radial-gradient(circle at 34% 30%, #FFF6C4 0 14%, #FFD54A 34%, #F2B21B 68%, #C9860A 100%);
  box-shadow: inset 0 0 0 .08em #D69712, inset 0 0 0 .15em #FFE68A, 0 .05em .12em rgba(120, 70, 0, .35);
  position: relative;
}
.coin::after { content: ''; position: absolute; inset: 31%; border-radius: 50%; border: .07em solid rgba(160, 100, 0, .55); }
