:root {
  --bg: #fdf6ec; --card: #fff; --ink: #2b2a33; --muted: #7a7684; --line: #efe3d3;
  --accent: #f28c5a; --accent-ink: #fff; --good: #58b96a; --warn: #f3b63a; --bad: #e35d6a;
  --shadow: 0 6px 24px rgba(60, 40, 20, .08); --radius: 18px;
  --scene: linear-gradient(180deg, #fde9d4 0%, #f7d6bd 60%, #e8c09e 60%, #d9ad88 100%);
}
:root[data-theme="dark"] { --bg: #1d1b22; --card: #27242e; --ink: #f3eee8; --muted: #a39db0; --line: #3a3542; --shadow: 0 6px 24px rgba(0,0,0,.35); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.app { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
header.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.brand { font-weight: 900; font-size: 20px; letter-spacing: -.5px; }
.wallet { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; box-shadow: var(--shadow); }
main { flex: 1; padding: 0 16px 90px; }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
nav.tabs button { flex: 1; max-width: 160px; border: 0; background: transparent; color: var(--muted); padding: 8px 6px; border-radius: 12px; font-weight: 800; font-size: 13px; }
nav.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.btn { border: 0; border-radius: 14px; padding: 10px 14px; font-weight: 800; background: var(--card); color: var(--ink); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 6px; justify-content: center; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.locked { opacity: .7; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
h1, h2, h3 { margin: 8px 0; }
h2 { font-size: 18px; }
.scene { position: relative; height: 300px; border-radius: var(--radius); overflow: hidden; background: var(--scene); border: 1px solid var(--line); box-shadow: var(--shadow); }
.scene.jardim { --scene: linear-gradient(180deg, #cfe9ff 0%, #e8f6ff 55%, #8fcf7a 55%, #6fb85e 100%); }
.scene.praia { --scene: linear-gradient(180deg, #bfe6ff 0%, #e8f6ff 50%, #58b7c9 50%, #f6e2b6 62%, #e9cf9a 100%); }
.scene .cat-wrap { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); width: 230px; height: 230px; }
.scene .cat-wrap svg { width: 100%; height: 100%; display: block; }
.scene .bubble { position: absolute; top: 14px; left: 14px; right: 14px; background: #fff; color: #2b2a33; border-radius: 16px; padding: 10px 14px; font-weight: 700; box-shadow: var(--shadow); animation: pop .3s ease; }
.scene .bubble::after { content: ""; position: absolute; bottom: -8px; left: 50%; width: 16px; height: 16px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.scene .stage-chip { position: absolute; bottom: 10px; left: 10px; background: rgba(255,255,255,.85); color: #2b2a33; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.scene .mood-chip { position: absolute; bottom: 10px; right: 10px; background: rgba(255,255,255,.85); color: #2b2a33; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.scene .deco { position: absolute; font-size: 40px; bottom: 60px; opacity: .9; }
/* Fase 1: limpinho, sujeira e status */
.scene .clean-chip { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.9); color: #2b2a33; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; animation: pop .3s ease; }
.scene.sparkle { box-shadow: inset 0 0 0 2px rgba(255,220,120,.7), var(--shadow); }
.scene.sparkle::after { content: "✨"; position: absolute; top: 40px; left: 22px; font-size: 22px; animation: sparkle 1.6s ease-in-out infinite; pointer-events: none; }
.scene .mess { position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%); font-size: 30px; animation: pop .3s ease; filter: saturate(.8); }
@keyframes sparkle { 0%,100% { opacity: .3; transform: scale(.8) rotate(-8deg); } 50% { opacity: 1; transform: scale(1.1) rotate(8deg); } }
.care-status { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 12px; font-weight: 700; }
.care-status span { background: var(--chip-bg, #f1efe9); color: #6b675f; padding: 4px 10px; border-radius: 999px; }
.care-status span.warn { background: #ffe9c7; color: #8a5a00; }
.care-status span.bad { background: #ffd9d9; color: #a23; }
.btn.alert, .shop-item.alert { background: #ffe1e1; color: #a22; box-shadow: inset 0 0 0 2px rgba(200,40,40,.3); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.02); } }
.card.hoje { background: linear-gradient(135deg, #fff7e6, #fff); box-shadow: inset 0 0 0 2px rgba(255,210,120,.5), var(--shadow); }
.cat .tail { transform-origin: 128px 176px; animation: tail 2.4s ease-in-out infinite; }
.cat .head { transform-origin: 100px 110px; animation: breathe 3s ease-in-out infinite; }
.cat .body { transform-origin: 100px 190px; animation: breathe 3s ease-in-out infinite; }
.cat.is-sleeping .tail { animation-duration: 6s; }
.cat .zzz { animation: float 2s ease-in-out infinite; }
.cat.mood-radiante .head { animation: bounce .8s ease-in-out infinite; }
.cat.happy-jump { animation: jump .6s ease; }
@keyframes tail { 0%,100% { transform: rotate(0) } 50% { transform: rotate(12deg) } }
@keyframes breathe { 0%,100% { transform: scale(1) } 50% { transform: scale(1.02) } }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes bounce { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-4px) } }
@keyframes jump { 0%,100% { transform: translateY(0) } 40% { transform: translateY(-30px) } }
@keyframes pop { from { transform: scale(.9); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.needs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 12px; }
.need { font-size: 13px; font-weight: 800; }
.need .label { display: flex; justify-content: space-between; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--good); border-radius: 999px; transition: width .4s ease; }
.bar.warn i { background: var(--warn); }
.bar.bad i { background: var(--bad); }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.actions .btn { flex-direction: column; gap: 2px; font-size: 12px; padding: 8px 4px; }
.actions .btn .ico { font-size: 22px; }
.cat-list .item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); width: 100%; text-align: left; margin-bottom: 8px; }
.cat-list .item .thumb { width: 64px; height: 64px; flex: none; }
.cat-list .item.active { outline: 2px solid var(--accent); }
.cat-list .item .meta { flex: 1; }
.cat-list .item .meta small { color: var(--muted); display: block; }
.shop-item { display: flex; flex-direction: column; gap: 6px; }
.shop-item .emoji { font-size: 32px; }
.shop-item .name { font-weight: 800; font-size: 14px; }
.shop-item .price { color: var(--muted); font-size: 13px; }
.segment { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin: 8px 0; }
.segment button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-weight: 800; color: var(--muted); }
.segment button.active { background: var(--accent); color: #fff; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 10, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: var(--card); color: var(--ink); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; animation: up .25s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal h3 { margin-top: 0; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal .modal-actions .btn { flex: 1; }
input[type="text"] { width: 100%; font: inherit; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.swatch.active { border-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13px; color: var(--ink); }
.chip.active { background: var(--accent); color: #fff; border-color: transparent; }
.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 800; z-index: 60; animation: pop .25s ease; max-width: 90vw; text-align: center; }
.toast.error { background: var(--bad); color: #fff; }
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.log li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log li small { color: var(--muted); margin-right: 6px; }
/* mini-jogos */
.mg-top { display: flex; justify-content: space-between; font-weight: 900; margin-bottom: 8px; }
.mg-score::before { content: "⭐ "; }
.mg-arena { position: relative; height: 320px; border-radius: 16px; background: var(--scene); overflow: hidden; touch-action: none; border: 1px solid var(--line); }
.mg-target { position: absolute; width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(255,255,255,.7); font-size: 30px; display: grid; place-items: center; transition: left .7s linear, top .7s linear, transform .15s; box-shadow: var(--shadow); }
.mg-target.laser { width: 36px; height: 36px; font-size: 18px; background: transparent; box-shadow: 0 0 18px 6px rgba(255, 40, 40, .6); transition: none; }
.mg-target.fish { background: rgba(88,183,201,.35); transition: left 1s ease-in-out, top 1s ease-in-out; }
.mg-target.hit { transform: scale(1.35); }
.mg-arena.boxes { display: flex; align-items: center; justify-content: space-around; }
.mg-box { position: relative; width: 90px; height: 110px; border: 0; background: transparent; font-size: 60px; }
.mg-box .lid { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 2; }
.mg-box .peek { position: absolute; left: 50%; bottom: 30px; transform: translate(-50%, 40px); font-size: 44px; transition: transform .2s ease; z-index: 1; }
.mg-box.show .peek { transform: translate(-50%, 0); }
.mg-box.hit .lid { filter: drop-shadow(0 0 10px #58b96a); }
.mg-box.miss .lid { filter: drop-shadow(0 0 10px #e35d6a); }
.pix-box { display: flex; gap: 12px; align-items: center; }
.pix-qr { display: grid; grid-template-columns: repeat(11, 8px); gap: 1px; padding: 6px; background: #fff; border-radius: 8px; flex: none; }
.pix-qr i { width: 8px; height: 8px; background: #fff; display: block; }
.pix-qr i.on { background: #111; }
.pix-code { font-family: monospace; font-size: 10px; word-break: break-all; color: var(--muted); }
.empty { text-align: center; padding: 30px 10px; }
.empty .big { font-size: 64px; }
.badge { display: inline-block; background: var(--line); color: var(--ink); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; }
.badge.gold { background: #ffe9a8; color: #6b4e00; }
@media (prefers-reduced-motion: reduce) { .cat *, .cat { animation: none !important; } }

/* renders fotorrealistas (imagem/vídeo) */
.scene.has-render { --scene: linear-gradient(180deg, #efe4d3 0%, #e6d7c2 100%); }
.scene .cat-wrap.image, .scene .cat-wrap.video { width: 100%; height: 100%; left: 0; bottom: 0; transform: none; }
.scene .cat-render { width: 100%; height: 100%; object-fit: cover; object-position: center 40%; display: block; }
.scene .cat-wrap.image .cat-render { animation: breathe-img 3.2s ease-in-out infinite; transform-origin: 50% 85%; }
.scene .cat-wrap.image .is-sleeping { animation-duration: 5s; }
@keyframes breathe-img { 0%,100% { transform: scale(1) } 50% { transform: scale(1.012) } }
.scene.has-render .bubble { background: rgba(255,255,255,.92); }
.cat-list .thumb img, .cat-list .thumb video { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }

/* missões, foto, álbum */
.missions ul { list-style: none; margin: 8px 0 0; padding: 0; }
.missions li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; font-weight: 700; }
.missions li:last-child { border-bottom: 0; }
.missions li small { color: var(--muted); font-weight: 800; }
.missions li.done { color: var(--muted); text-decoration: line-through; }
.missions li.done small { color: var(--good); text-decoration: none; }
.scene .photo-btn { position: absolute; top: 64px; right: 10px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); font-size: 20px; box-shadow: var(--shadow); }
.album-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.album-grid figure { margin: 0; background: var(--bg); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.album-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.album-grid figcaption { font-size: 12px; font-weight: 800; padding: 6px 8px 0; }
.album-grid figcaption small { color: var(--muted); font-weight: 600; }
.album-grid .row { padding: 4px 6px 6px; justify-content: flex-end; }

#card-brick { margin: 4px -4px; }
.modal .grid .shop-item { min-height: 96px; }

.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr-wrap svg { width: 180px; height: 180px; border-radius: 12px; background: #fff; padding: 8px; box-shadow: var(--shadow); }
.qr-url { font-size: 12px; font-weight: 700; }

/* emotes flutuantes e gracinhas do gato */
.emote { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); font-size: 30px; pointer-events: none; z-index: 5; animation: emote-float 2.1s ease-out forwards; filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); }
@keyframes emote-float { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); } 15% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -90px) scale(1); } }
.scene .bubble.say { animation: bubble-pop .32s ease; }
@keyframes bubble-pop { 0% { transform: scale(.92); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
.cat-wrap > * { transform-origin: 50% 92%; }

/* cada gracinha com um movimento próprio, repetido durante a janela da ação */
.anim-wiggle { animation: a-lick 1s ease-in-out 2; }          /* lamber: cabeça desce e inclina */
.anim-stretch { animation: a-stretch 1.3s ease-in-out 1; }    /* espreguiçar: estica pra frente */
.anim-knead { animation: a-knead .5s ease-in-out 5; }         /* pãozinho: balança ritmado */
.anim-perk { animation: a-perk .9s ease 2; }                  /* observar: orelha/cabeça sobe */
.anim-pounce { animation: a-pounce 1.1s ease 2; }             /* caçar: agacha e dá o bote */
.anim-roll { animation: a-roll 1.2s ease-in-out 1; }          /* rolar: gira pro lado */
.anim-breathe { animation: a-breathe 1.4s ease-in-out 2; }    /* ronronar: respira fundo */
.anim-happy-jump { animation: a-jump .6s ease 1; }            /* presente: pulinho */
@keyframes a-lick { 0%,100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(5px) rotate(-5deg); } 60% { transform: translateY(5px) rotate(5deg); } }
@keyframes a-stretch { 0%,100% { transform: scaleX(1) scaleY(1) translateY(0); } 45% { transform: scaleX(1.14) scaleY(.88) translateY(4px); } }
@keyframes a-knead { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(1.5deg); } }
@keyframes a-perk { 0%,100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-9px) scale(1.02); } }
@keyframes a-pounce { 0% { transform: translateY(0) scaleY(1); } 35% { transform: translateY(8px) scaleY(.86); } 55% { transform: translateY(8px) scaleY(.86); } 75% { transform: translateY(-18px) scaleY(1.06); } 100% { transform: translateY(0) scaleY(1); } }
@keyframes a-roll { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-12deg) translateY(-4px); } }
@keyframes a-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes a-jump { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-28px); } }
/* Fase 2: estados novos e gracinhas virais */
.anim-yawn { animation: a-yawn 1.6s ease-in-out 1; }          /* bocejar: abre bem devagar e relaxa */
.anim-meow { animation: a-meow .5s ease-in-out 3; }           /* miar: cabecinha sobe e desce falando */
.anim-dash { animation: a-dash .4s ease-in-out 5; }           /* zoomies: corre de um lado pro outro */
.anim-cough { animation: a-cough .55s ease-in-out 4; }        /* bola de pelo: contrai e tosse */
.anim-squirm { animation: a-squirm .7s ease-in-out 3; }       /* xixi: remexe inquieto */
.anim-recoil { animation: a-recoil 1s ease-out 2; }           /* caixa suja: recua com nojo */
.anim-shake { animation: a-shake .3s ease-in-out 6; }         /* sujo: se sacode todo */
.anim-heave { animation: a-heave .8s ease-in-out 3; }         /* vômito: contrai e joga a cabeça */
@keyframes a-yawn { 0%,100% { transform: scaleY(1) translateY(0); } 35% { transform: scaleY(1.1) translateY(-3px); } 55% { transform: scaleY(.9) translateY(4px); } }
@keyframes a-meow { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.03); } }
@keyframes a-dash { 0%,100% { transform: translateX(0) scaleX(1); } 25% { transform: translateX(-26px) scaleX(-1); } 75% { transform: translateX(26px) scaleX(1); } }
@keyframes a-cough { 0%,100% { transform: translateY(0) scaleY(1) rotate(0); } 40% { transform: translateY(3px) scaleY(.9) rotate(-3deg); } 70% { transform: translateY(-4px) scaleY(1.06) rotate(2deg); } }
@keyframes a-squirm { 0%,100% { transform: translateX(0) rotate(0); } 30% { transform: translateX(-6px) rotate(-3deg); } 70% { transform: translateX(6px) rotate(3deg); } }
@keyframes a-recoil { 0%,100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-6px) rotate(-6deg) scale(.97); } }
@keyframes a-shake { 0%,100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-5px) rotate(-2deg); } 75% { transform: translateX(5px) rotate(2deg); } }
@keyframes a-heave { 0%,100% { transform: translateY(0) scaleY(1); } 35% { transform: translateY(2px) scaleY(.88); } 60% { transform: translateY(6px) scaleY(.94) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .emote, [class^="anim-"] { animation: none !important; } }
