/* =========================================================================
   Tamagoshi — folha de estilo única.

   Premissa: isto é um app de celular que por acaso roda no navegador.
   Nenhuma tela rola verticalmente por acidente, nada é dimensionado em px
   pensando em desktop, e o alvo de toque mínimo é 44px em todo lugar.

   Índice
     1. Paleta e tokens
     2. Reset e casca do app
     3. Tipografia e botões
     4. Landing e formulários
     5. Onboarding e nascimento
     6. Tela do jogo: topo, quarto, status, navegação
     7. Bottom sheets
     8. Feedback flutuante e partículas
     9. Convite de instalação do PWA
    10. Animações
    11. Desktop e movimento reduzido
   ========================================================================= */

/* ---- 0. Tipografia --------------------------------------------------
   A fonte é empacotada, não buscada no Google Fonts. No app nativo não há
   garantia de rede na primeira abertura, e cair na fonte do sistema mudaria a
   cara do jogo — a tipografia faz parte da identidade aprovada. Empacotada,
   Web e app renderizam exatamente igual, e o site ainda deixa de depender de
   um terceiro para desenhar a primeira tela.
   Baloo 2, SIL Open Font License 1.1.
   ------------------------------------------------------------------- */

@font-face {
    font-family: 'Baloo 2';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/baloo2-500.woff2') format('woff2');
}

@font-face {
    font-family: 'Baloo 2';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/baloo2-700.woff2') format('woff2');
}

@font-face {
    font-family: 'Baloo 2';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('../fonts/baloo2-800.woff2') format('woff2');
}

/* ---- 1. Paleta e tokens --------------------------------------------- */

:root {
    /* As mesmas cores da bíblia de arte. Mudar aqui desalinha da arte gerada. */
    --cream: #FFF3E2;
    --cream-2: #F7E3C8;
    --cream-3: #E8D0AE;
    --peach: #FFC9A3;
    --peach-d: #E09B6E;
    --rose: #F2A2A2;
    --rose-d: #D97C87;
    --red: #E8564F;
    --mint: #A8D8C0;
    --mint-d: #7FB89C;
    --sky: #9CC9F0;
    --lavender: #C9B6E4;
    --wood: #B98A5E;
    --wood-d: #8A6547;
    --brown: #6B4F3A;
    --ink: #3B2A2E;
    --gold: #F5C451;
    --gold-d: #E0A32E;

    --surface: var(--cream);
    --surface-2: #FFFBF4;
    --line: rgba(59, 42, 46, .14);

    --radius: 18px;
    --radius-lg: 26px;
    --radius-pill: 999px;

    --shadow-sm: 0 2px 0 rgba(59, 42, 46, .12);
    --shadow: 0 6px 18px rgba(107, 79, 58, .18);
    --shadow-lg: 0 -10px 34px rgba(59, 42, 46, .22);

    /* Safe areas: valem 0 no navegador comum e ganham valor quando instalado. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Onde a parede encontra o chão na arte do quarto. Toda mobília se apoia nisto. */
    --floor: 40%;

    --tap: 44px;
    --font: "Baloo 2", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- 2. Reset e casca do app ---------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* Nada de rolagem elástica: é um app, não uma página. */
    overscroll-behavior: none;
}

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--brown);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* Toda arte do jogo é pixel art: o navegador nunca deve suavizá-la. */
img.px,
.px img { image-rendering: pixelated; }

img { user-select: none; -webkit-user-drag: none; }

/* A casca. 100dvh e não 100vh: no iOS a barra do Safari some e volta,
   e vh congela no tamanho maior, cortando a navegação inferior. */
.app {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    height: 100dvh;
    margin-inline: auto;
    background: var(--surface);
    overflow: hidden;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.app--scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- 3. Tipografia e botões ----------------------------------------- */

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: clamp(1.75rem, 8vw, 2.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; line-height: 1.5; }

.muted { color: rgba(59, 42, 46, .6); }
.tiny { font-size: .8rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: var(--tap);
    padding: .85rem 1.4rem;
    border: 0;
    border-radius: var(--radius-pill);
    font: inherit;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--ink);
    background: var(--peach);
    box-shadow: 0 4px 0 var(--peach-d);
    cursor: pointer;
    text-decoration: none;
    transition: transform .08s ease, box-shadow .08s ease;
}

/* O botão afunda ao toque. É pequeno, mas é o que dá sensação de botão físico. */
.btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--peach-d);
}

.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; box-shadow: none; color: var(--brown); text-decoration: underline; }
.btn--mint { background: var(--mint); box-shadow: 0 4px 0 var(--mint-d); }
.btn--mint:active { box-shadow: 0 1px 0 var(--mint-d); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.icon { width: 24px; height: 24px; image-rendering: pixelated; flex: none; }

/* ---- 4. Landing e formulários --------------------------------------- */

.landing {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--safe-top) + 2rem) 1.5rem calc(var(--safe-bottom) + 1.75rem);
    text-align: center;
    background:
        radial-gradient(120% 60% at 50% 0%, var(--peach) 0%, transparent 60%),
        linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
}

.landing__mark { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.landing__logo { width: 104px; height: 104px; border-radius: 30px; box-shadow: var(--shadow); }
.landing__title { font-size: clamp(2.2rem, 11vw, 3rem); color: var(--ink); }
.landing__tag { max-width: 22ch; color: var(--brown); font-weight: 600; }

.landing__eggs { display: flex; align-items: flex-end; justify-content: center; gap: 1rem; }
.landing__egg { width: clamp(56px, 18vw, 82px); height: auto; }
.landing__egg:nth-child(1) { animation: float 3.2s ease-in-out infinite; }
.landing__egg:nth-child(2) { animation: float 3.2s ease-in-out .5s infinite; }
.landing__egg:nth-child(3) { animation: float 3.2s ease-in-out 1s infinite; }

.landing__actions { display: flex; flex-direction: column; gap: .5rem; width: 100%; max-width: 320px; }

.form-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: calc(var(--safe-top) + 1.25rem) 1.5rem calc(var(--safe-bottom) + 1.5rem);
    background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
    overflow-y: auto;
}

.form-screen__head { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; }
.form-screen__mascot { width: 72px; height: 72px; border-radius: 22px; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-weight: 700; font-size: .92rem; color: var(--brown); }

.field input {
    min-height: var(--tap);
    padding: .8rem 1rem;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface-2);
}

.field input:focus { outline: 0; border-color: var(--peach-d); }

.field__error { color: var(--rose-d); font-size: .85rem; font-weight: 700; }

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    background: rgba(242, 162, 162, .25);
    color: var(--rose-d);
    font-weight: 700;
    font-size: .9rem;
}

/* ---- 5. Onboarding e nascimento ------------------------------------- */

.onboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: calc(var(--safe-top) + 1.25rem) 1.25rem calc(var(--safe-bottom) + 1.25rem);
    background: linear-gradient(180deg, var(--cream) 0%, var(--mint) 220%);
    overflow-y: auto;
}

.egg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }

.egg-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    padding: .9rem .4rem;
    border: 3px solid transparent;
    border-radius: var(--radius);
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease;
}

.egg-card img { width: 100%; max-width: 74px; height: auto; }
.egg-card__name { font-weight: 800; font-size: .82rem; text-align: center; }

.egg-card[aria-pressed="true"] {
    border-color: var(--peach-d);
    transform: translateY(-4px);
    background: var(--cream);
}

.egg-card[aria-pressed="true"] img { animation: wiggle 1.4s ease-in-out infinite; }

.egg-hint {
    min-height: 3.2em;
    padding: .8rem 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .55);
    font-size: .92rem;
    font-weight: 600;
    color: var(--brown);
}

/* Nascimento: tela cheia, sem nada além do ovo. */
.hatch {
    position: relative;
    flex: 1;
    display: grid;
    place-items: center;
    padding: calc(var(--safe-top) + 1rem) 1.5rem calc(var(--safe-bottom) + 1.5rem);
    background: radial-gradient(70% 50% at 50% 45%, var(--cream) 0%, var(--wood) 190%);
    text-align: center;
}

.hatch__stage { position: relative; display: grid; place-items: center; width: min(78vw, 300px); aspect-ratio: 1; }
.hatch__egg { width: 58%; height: auto; position: relative; z-index: 2; }
.hatch__pet { width: 58%; height: auto; position: relative; z-index: 2; opacity: 0; }

.hatch__glow {
    position: absolute;
    width: 100%;
    height: auto;
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

.hatch__caption { margin-top: 1rem; font-weight: 700; color: var(--brown); min-height: 3em; }

.hatch.is-shaking .hatch__egg { animation: shake .45s ease-in-out infinite; }
.hatch.is-cracking .hatch__egg { animation: shake .22s ease-in-out infinite; }
.hatch.is-bursting .hatch__glow { animation: burst 1s ease-out forwards; }
.hatch.is-born .hatch__egg { display: none; }
.hatch.is-born .hatch__pet { animation: born .9s cubic-bezier(.34, 1.56, .64, 1) forwards; }

/* ---- 6. Tela do jogo ------------------------------------------------ */

.game {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: linear-gradient(180deg, var(--cream-2) 0%, var(--cream) 100%);
}

/* --- topo --- */
.topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: calc(var(--safe-top) + .6rem) 1rem .6rem;
    background: var(--surface-2);
    border-bottom: 2px solid var(--line);
}

.topbar__id { flex: 1; min-width: 0; }
.topbar__name { font-size: 1.15rem; font-weight: 800; line-height: 1.1; }
.topbar__sub { display: flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; color: var(--brown); }
.topbar__sub img { width: 14px; height: 14px; image-rendering: pixelated; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .6rem;
    border-radius: var(--radius-pill);
    background: var(--cream-2);
    font-size: .82rem;
    font-weight: 800;
}

.pill img { width: 18px; height: 18px; image-rendering: pixelated; }
.pill--level { background: var(--mint); }
.pill--coins { background: var(--gold); }

/* --- o quarto --- */
.stage {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: .5rem;
}

/* O quarto ocupa todo o espaço entre o cabeçalho e os controles. Sem proporção
   fixa: numa tela alta o excesso é cortado do topo da parede, que é liso e não
   perde nada — travar 1:1 aqui deixaria uma faixa morta no meio da tela. */
.room {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: inset 0 0 0 3px rgba(107, 79, 58, .25), var(--shadow);
    image-rendering: pixelated;
    /* Sem isso, um toque longo no cenário abre o menu de imagem do celular. */
    -webkit-touch-callout: none;
    user-select: none;
}

/* Ancorado embaixo: o chão nunca é cortado, só a parede. */
.room__bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center bottom;
}

/* Mobília: posicionada em porcentagem para acompanhar qualquer tamanho de tela.
   Tudo se apoia na mesma linha de chão (--floor), que é o que faz a cena
   parecer um lugar em vez de figuras soltas. */
.room__item { position: absolute; height: auto; z-index: 1; }

.room__item--shelf { left: 1%; bottom: var(--floor); width: 24%; }
.room__item--lamp { left: 25%; bottom: var(--floor); width: 12%; }
.room__item--window { left: 8%; top: 9%; width: 26%; }
.room__item--bed { right: 1%; bottom: calc(var(--floor) - 5%); width: 34%; }
.room__item--plant { right: 37%; bottom: calc(var(--floor) - 3%); width: 11%; }
.room__item--rug { left: 50%; translate: -50% 0; bottom: 4%; width: 52%; }
.room__item--bowl { left: 5%; bottom: 6%; width: 13%; }

/* O pet fica à frente de tudo: a sobreposição parcial com a mobília é o que
   dá profundidade ao quarto. */
.room__pet {
    position: absolute;
    left: 50%;
    bottom: 6%;
    width: 26%;
    height: auto;
    translate: -50% 0;
    z-index: 3;
    transform-origin: 50% 100%;
    animation: breathe 3.4s ease-in-out infinite;
    transition: width .6s ease;
}

/* Crescer tem que ser visível no tamanho, não só no desenho. Um filhote do
   tamanho da cama estragaria a escala do quarto inteiro. */
.room__pet[data-stage="egg"] { width: 20%; }
.room__pet[data-stage="baby"] { width: 21%; }
.room__pet[data-stage="child"] { width: 26%; }
.room__pet[data-stage="teen"] { width: 30%; }
.room__pet[data-stage="adult"] { width: 35%; }
.room__pet[data-stage="special"] { width: 37%; }

.room__pet.is-happy { animation: hop .5s ease-in-out 2; }
.room__pet.is-eating { animation: munch .34s ease-in-out 4; }
.room__pet.is-playing { animation: hop .38s ease-in-out 3; }
.room__pet.is-sleeping { animation: snooze 4s ease-in-out infinite; }

/* Sujeira: quantas aparecem vem da higiene, calculada no servidor. */
.room__dirt { position: absolute; bottom: 4%; width: 9%; height: auto; z-index: 2; opacity: .95; }
.room__dirt--1 { left: 24%; }
.room__dirt--2 { right: 26%; bottom: 10%; }
.room__dirt--3 { left: 40%; bottom: 2%; }
.room__dirt.is-leaving { animation: poof .45s ease-in forwards; }

/* Noite: dormir escurece o quarto em vez de trocar a arte. */
.room__night {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: linear-gradient(180deg, rgba(40, 32, 66, .62), rgba(24, 20, 44, .74));
    opacity: 0;
    pointer-events: none;
    transition: opacity .6s ease;
}

.room.is-night .room__night { opacity: 1; }

.room__fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }

/* --- indicadores --- */
.status {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .3rem;
    padding: .55rem .6rem;
    background: var(--surface-2);
    border-top: 2px solid var(--line);
}

/* Compacto de propósito: seis barras grandes comeriam metade da tela. */
.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .22rem;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
    min-height: 40px;
}

.stat img { width: 24px; height: 24px; image-rendering: pixelated; }

.stat__bar {
    width: 100%;
    height: 9px;
    border-radius: var(--radius-pill);
    /* Trilho escuro o bastante para a barra cheia se destacar dele a 9px de
       altura num celular — a 6px sobre creme claro os dois se confundiam. */
    background: var(--cream-3);
    box-shadow: inset 0 0 0 1px rgba(59, 42, 46, .12);
    overflow: hidden;
}

.stat__fill {
    /* Precisa ser block: é um span dentro de um span, e um elemento inline
       ignora width e height — sem isto a barra nunca enche. */
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--mint-d);
    transition: width .45s cubic-bezier(.34, 1.3, .64, 1), background-color .3s ease;
}

/* O nível crítico não depende só de cor: o ícone pulsa junto, para quem
   não distingue o vermelho do verde. */
.stat[data-level="low"] .stat__fill { background: var(--gold-d); }
.stat[data-level="critical"] .stat__fill { background: var(--rose-d); }
.stat[data-level="critical"] img { animation: pulse 1.1s ease-in-out infinite; }

.stat.is-bumped .stat__bar { animation: bump .5s ease-out; }

/* --- navegação inferior --- */
.nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: .1rem;
    padding: .35rem .3rem calc(var(--safe-bottom) + .35rem);
    background: var(--surface-2);
    border-top: 2px solid var(--line);
}

.nav__btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    min-height: var(--tap);
    padding: .3rem .1rem;
    border: 0;
    border-radius: var(--radius);
    background: none;
    font: inherit;
    font-size: .68rem;
    font-weight: 800;
    color: var(--brown);
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease;
}

.nav__btn img { width: 26px; height: 26px; image-rendering: pixelated; transition: transform .15s ease; }
.nav__btn:active img { transform: scale(.88); }
.nav__btn[aria-current="page"] { background: var(--cream-2); color: var(--ink); }

.nav__badge {
    position: absolute;
    top: .15rem;
    right: 22%;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 2px var(--surface-2);
}

/* ---- 7. Bottom sheets ----------------------------------------------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(59, 42, 46, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 41;
    width: min(100%, 480px);
    max-height: 78dvh;
    translate: -50% 0;
    display: flex;
    flex-direction: column;
    padding: .6rem 1rem calc(var(--safe-bottom) + 1.1rem);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface-2);
    box-shadow: var(--shadow-lg);
    transform: translateY(102%);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
}

.sheet.is-open { transform: translateY(0); }

.sheet__grip {
    width: 42px;
    height: 5px;
    margin: 0 auto .7rem;
    border-radius: var(--radius-pill);
    background: var(--cream-3);
}

.sheet__title { margin-bottom: .75rem; font-size: 1.1rem; }
.sheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Lista de ações: alvos grandes, arte à esquerda. */
.action-list { display: flex; flex-direction: column; gap: .5rem; }

.action {
    display: flex;
    align-items: center;
    gap: .9rem;
    width: 100%;
    min-height: 62px;
    padding: .7rem .9rem;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--cream);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform .08s ease;
}

.action:active { transform: scale(.98); }
.action[disabled] { opacity: .45; pointer-events: none; }
.action img { width: 40px; height: 40px; image-rendering: pixelated; flex: none; }
.action__text { flex: 1; min-width: 0; }
.action__name { font-weight: 800; font-size: .98rem; }
.action__meta { font-size: .8rem; color: var(--brown); }

.action__qty {
    padding: .2rem .55rem;
    border-radius: var(--radius-pill);
    background: var(--cream-3);
    font-size: .8rem;
    font-weight: 800;
}

.action__price { display: inline-flex; align-items: center; gap: .25rem; font-weight: 800; }
.action__price img { width: 18px; height: 18px; }

.sheet__empty { padding: 1.5rem 1rem; text-align: center; color: var(--brown); font-weight: 600; }

/* Recompensa diária */
.daily-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }

.daily-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .5rem .2rem;
    border: 2px solid var(--line);
    border-radius: 14px;
    background: var(--cream);
    font-size: .72rem;
    font-weight: 800;
}

.daily-day img { width: 24px; height: 24px; image-rendering: pixelated; }
.daily-day.is-claimed { opacity: .45; }
.daily-day.is-today { border-color: var(--gold-d); background: var(--gold); animation: pulse 1.6s ease-in-out infinite; }

/* ---- 8. Feedback flutuante e partículas ----------------------------- */

/* Substitui alert(): aparece sobre o quarto e some sozinho. */
.toast-layer {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + 92px);
    z-index: 50;
    width: min(92%, 420px);
    translate: -50% 0;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    pointer-events: none;
}

.toast {
    padding: .7rem 1rem;
    border-radius: var(--radius);
    background: var(--ink);
    color: var(--cream);
    font-weight: 700;
    font-size: .92rem;
    text-align: center;
    box-shadow: var(--shadow);
    animation: toast-in .25s ease-out, toast-out .3s ease-in 2.4s forwards;
}

.toast--error { background: var(--rose-d); }

.toast__deltas { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem .6rem; margin-top: .3rem; font-size: .82rem; opacity: .92; }
.toast__delta--up { color: var(--mint); }
.toast__delta--down { color: var(--peach); }

.fx-sprite {
    position: absolute;
    width: 26px;
    height: 26px;
    image-rendering: pixelated;
    pointer-events: none;
    animation: rise 1.25s ease-out forwards;
}

/* Item voando até a boca do pet ao alimentar. */
.fx-item {
    position: absolute;
    width: 20%;
    height: auto;
    image-rendering: pixelated;
    pointer-events: none;
    animation: feed-in 1.15s cubic-bezier(.4, 0, .5, 1) forwards;
}

/* Comemoração de evolução */
.evolution {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 2rem;
    background: radial-gradient(60% 45% at 50% 45%, rgba(255, 243, 226, .97), rgba(107, 79, 58, .95));
    text-align: center;
}

.evolution__pet { width: min(48vw, 190px); height: auto; image-rendering: pixelated; animation: born 1s cubic-bezier(.34, 1.56, .64, 1); }
.evolution__title { margin-top: 1rem; font-size: 1.6rem; }
.evolution__sub { color: var(--brown); font-weight: 700; }

/* ---- 9. Convite de instalação do PWA -------------------------------- */

/* Aparece depois que o jogador já cuidou do bichinho — nunca de cara. */
.install {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + 84px);
    z-index: 45;
    width: min(92%, 420px);
    translate: -50% 0;
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1rem;
    border-radius: var(--radius);
    background: var(--ink);
    color: var(--cream);
    box-shadow: var(--shadow);
    animation: slide-up .35s ease-out;
}

.install img { width: 44px; height: 44px; border-radius: 12px; flex: none; }
.install__text { flex: 1; min-width: 0; }
.install__title { font-weight: 800; font-size: .95rem; }
.install__body { font-size: .8rem; opacity: .85; line-height: 1.35; }

.install__go {
    min-height: 38px;
    padding: .5rem .9rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--gold);
    font: inherit;
    font-weight: 800;
    font-size: .88rem;
    color: var(--ink);
    cursor: pointer;
}

.install__close {
    position: absolute;
    top: -10px;
    right: -6px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: var(--cream-3);
    color: var(--ink);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

/* Instruções do iOS: o Safari não oferece prompt, então sobra explicar. */
.ios-steps { display: flex; flex-direction: column; gap: .6rem; padding: .3rem 0 .6rem; }
.ios-step { display: flex; align-items: center; gap: .7rem; font-size: .92rem; font-weight: 600; }

.ios-step__n {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 50%;
    background: var(--mint);
    font-weight: 800;
    font-size: .82rem;
}

/* ---- perfil --- */
.profile { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; overflow-y: auto; }

.card {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
}

.card__title { margin-bottom: .6rem; font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brown); }

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--brown); font-weight: 600; }
.kv__v { font-weight: 800; }

.trait-list { display: flex; flex-wrap: wrap; gap: .4rem; }

.trait {
    padding: .35rem .75rem;
    border-radius: var(--radius-pill);
    background: var(--lavender);
    font-size: .85rem;
    font-weight: 800;
}

/* Barra de tempo do modo desenvolvedor. */
.devbar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.devbar button { min-height: 36px; padding: .35rem .7rem; border: 2px dashed var(--wood); border-radius: var(--radius-pill); background: var(--cream); font: inherit; font-size: .8rem; font-weight: 800; cursor: pointer; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- 10. Animações --------------------------------------------------- */

@keyframes breathe {
    0%, 100% { transform: translateY(0) scaleY(1); }
    50% { transform: translateY(-1.5%) scaleY(1.025); }
}

@keyframes hop {
    0%, 100% { transform: translateY(0) scaleY(1); }
    30% { transform: translateY(-14%) scaleY(1.06); }
    60% { transform: translateY(0) scaleY(.94); }
}

@keyframes munch {
    0%, 100% { transform: scale(1, 1); }
    50% { transform: scale(1.05, .95); }
}

@keyframes snooze {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(1%) scale(1.015); }
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-9px) rotate(2deg); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-3%) rotate(-4deg); }
    75% { transform: translateX(3%) rotate(4deg); }
}

@keyframes burst {
    0% { opacity: 0; transform: scale(.3) rotate(0); }
    45% { opacity: 1; transform: scale(1.25) rotate(90deg); }
    100% { opacity: 0; transform: scale(1.9) rotate(180deg); }
}

@keyframes born {
    0% { opacity: 0; transform: scale(.25) translateY(18%); }
    60% { opacity: 1; transform: scale(1.12) translateY(-4%); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes rise {
    0% { opacity: 0; transform: translateY(0) scale(.6); }
    20% { opacity: 1; transform: translateY(-14px) scale(1); }
    100% { opacity: 0; transform: translateY(-64px) scale(.85); }
}

@keyframes feed-in {
    0% { opacity: 0; transform: translate(0, -46px) scale(.7); }
    25% { opacity: 1; transform: translate(0, -20px) scale(1); }
    75% { opacity: 1; transform: translate(0, 0) scale(.9); }
    100% { opacity: 0; transform: translate(0, 4px) scale(.3); }
}

@keyframes poof {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.7) translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.14); }
}

@keyframes bump {
    0%, 100% { transform: scaleY(1); }
    40% { transform: scaleY(1.9); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(-8px); }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- 11. Desktop e movimento reduzido -------------------------------- */

/* No desktop o jogo não vira um app de desktop: continua um aparelhinho
   vertical, centralizado, sobre um fundo decorativo. */
@media (min-width: 560px) and (min-height: 620px) {
    body {
        display: grid;
        place-items: center;
        background:
            radial-gradient(90% 60% at 50% 0%, var(--wood) 0%, transparent 65%),
            var(--brown);
    }

    .app {
        height: min(100dvh - 3rem, 900px);
        border-radius: 34px;
        box-shadow: 0 30px 70px rgba(0, 0, 0, .42);
        border: 6px solid rgba(255, 243, 226, .12);
    }
}

/* Instalado como PWA a moldura desaparece: o app é o aparelho. */
@media (display-mode: standalone) {
    .app { max-width: none; border: 0; border-radius: 0; height: 100dvh; box-shadow: none; }
    body { background: var(--surface); display: block; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }

    /* A sequência de nascimento é contada por eventos de animação. Zerar a
       duração ainda dispara os eventos, então o fluxo termina — só que
       instantâneo, que é exatamente o pedido. */
    .sheet { transition: none; }
}

/* =========================================================================
   Barra de tempo (só em Development).

   Discreta de propósito: é ferramenta de quem constrói, não parte do jogo.
   Fica entre o quarto e a faixa de status, sem empurrar nenhuma das duas.
   ========================================================================= */
.devbar {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .6rem;
    background: rgba(59, 42, 46, .06);
    border-top: 1px dashed var(--line);
    font-size: .72rem;
}

.devbar__label {
    margin-right: auto;
    color: var(--brown);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.devbar__label strong { color: var(--ink); }

.devbar__btn {
    padding: .2rem .5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.devbar__btn:disabled { opacity: .5; }

.devbar__btn--reset { color: var(--brown); }

/* =========================================================================
   Convite de notificação.

   Mesma linguagem dos cartões do jogo: creme, cantos arredondados e o ícone
   pixelado à esquerda. Discreto de propósito — é um pedido, não um alerta.
   ========================================================================= */
.optin {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .85rem;
    margin: 0 0 .75rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.optin__icone { flex: 0 0 auto; }

.optin__texto { flex: 1 1 auto; min-width: 0; }

.optin__texto strong {
    display: block;
    font-size: .92rem;
    color: var(--ink);
}

.optin__texto p { margin: .15rem 0 0; }

.optin--ok { background: rgba(168, 216, 192, .22); }

.btn--sm {
    flex: 0 0 auto;
    padding: .4rem .8rem;
    font-size: .82rem;
}

/* O convite no quarto respira nas laterais; no Perfil já vem dentro de um cartão. */
.optin-faixa { padding: 0 .75rem; }
