:root {
  --bg: #f4f1ff;
  --card: #ffffff;
  --text: #2d2a3e;
  --muted: #7a7590;
  --brand: #6c5ce7;
  --brand-2: #a29bfe;
  --ok: #00b894;
  --warn: #fdcb6e;
  --bad: #e17055;
  --line: #e6e1f5;
  --radius: 18px;
  --shadow: 0 4px 18px rgba(80, 60, 160, .10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17152a; --card: #222039; --text: #eeeaff; --muted: #a9a3c7;
    --line: #34315a; --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.topbar .coins { background: rgba(255,255,255,.2); padding: 3px 10px; border-radius: 99px; font-weight: 700; }
.who { opacity: .85; }
.logout { color: #fff; opacity: .8; background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card.narrow { max-width: 440px; margin: 24px auto; }
.center { text-align: center; }
h1 { margin: .2em 0 .4em; font-size: 1.6rem; }
h2 { margin: 0 0 .6em; font-size: 1.15rem; }
.muted, .empty { color: var(--muted); }
.empty { font-style: italic; }
.count { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 9px; font-size: .85rem; vertical-align: middle; }

.flash, .error { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.flash { background: #dff9ef; color: #036b52; }
.error { background: #ffe4dc; color: #a33a1c; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select {
  font: inherit; padding: 11px 12px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--bg); color: var(--text); width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--brand); }
.row-form { flex-direction: row; margin-top: 8px; }
.row-form input { flex: 1; min-width: 0; }
form.inline { display: inline-flex; gap: 6px; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 12px;
  padding: 10px 16px; background: var(--line); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; margin-top: 8px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.big { padding: 14px; font-size: 1.1rem; }
.btn.small { padding: 7px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; }

/* Login / adopt */
.hero-pets { font-size: 2.6rem; letter-spacing: 6px; }
.species-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.species { cursor: pointer; position: relative; }
.species input { position: absolute; opacity: 0; }
.species > span:last-child { text-align: center; }
.species {
  border: 3px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex !important; flex-direction: column; align-items: center; gap: 4px;
}
.species:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.species-emoji { font-size: 3.4rem; line-height: 1.1; }

/* Pet */
.pet-card { text-align: center; }
.pet-stage {
  position: relative; height: 220px; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(#bfe9ff 0 62%, #8fd694 62% 100%);
}
.mood-sick .pet-stage, .pet-stage.mood-sick { filter: saturate(.55); }
.pet-emoji {
  position: absolute; left: 50%; bottom: 34px; font-size: 6.5rem; line-height: 1;
  transform: translateX(-50%); animation: bob 2.4s ease-in-out infinite;
}
.mood-happy .pet-emoji { animation: hop 1.2s ease-in-out infinite; }
.mood-sick .pet-emoji, .mood-sad .pet-emoji { animation: sway 3.5s ease-in-out infinite; filter: grayscale(.4); }
.pet-face {
  position: absolute; left: calc(50% + 46px); bottom: 130px; font-size: 2rem;
  background: #fff; border-radius: 50%; padding: 2px 4px; box-shadow: var(--shadow);
}
.poops { position: absolute; left: 12px; right: 12px; bottom: 8px; display: flex; justify-content: space-between; font-size: 1.8rem; pointer-events: none; }
.poops span:nth-child(odd) { margin-top: 6px; }
.dirt {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 30% 70%, rgba(110,80,40,.35) 0 8%, transparent 9%),
              radial-gradient(circle at 65% 60%, rgba(110,80,40,.30) 0 6%, transparent 7%),
              radial-gradient(circle at 50% 80%, rgba(110,80,40,.30) 0 7%, transparent 8%);
  transition: opacity .6s;
}
.pet-name { margin-top: 12px; margin-bottom: 0; }
.pet-mood { margin-top: 2px; color: var(--muted); font-weight: 600; min-height: 1.4em; }

@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }
@keyframes hop { 0%,100% { transform: translate(-50%, 0); } 40% { transform: translate(-50%, -22px); } 60% { transform: translate(-50%, -18px); } }
@keyframes sway { 0%,100% { transform: translateX(-50%) rotate(-4deg); } 50% { transform: translateX(-50%) rotate(4deg); } }
.pet-emoji.bounce { animation: big-hop .6s ease-out; }
@keyframes big-hop { 0% { transform: translate(-50%, 0) scale(1); } 40% { transform: translate(-50%, -40px) scale(1.12); } 100% { transform: translate(-50%, 0) scale(1); } }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 14px 0; text-align: left; }
.stat-label { font-size: .85rem; font-weight: 700; }
.bar { height: 12px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 3px; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--ok); transition: width .6s, background .6s; }
.bar-fill.mid { background: var(--warn); }
.bar-fill.low { background: var(--bad); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.action { flex-direction: column; padding: 12px 8px; gap: 0; }
.btn.action small { font-weight: 500; color: var(--muted); }

.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.shop-item {
  font: inherit; color: var(--text); cursor: pointer; border: 2px solid var(--line); border-radius: 14px;
  background: var(--bg); padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .85rem; font-weight: 600;
}
.shop-item:active { transform: scale(.95); }
.shop-emoji { font-size: 2rem; }
.price { color: var(--brand); font-weight: 800; }

/* Chores */
.chores { list-style: none; padding: 0; margin: 0; }
.chore { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.chore:last-child { border-bottom: 0; }
.chore.inactive { opacity: .5; }
.chore-icon { font-size: 1.6rem; }
.chore-title { flex: 1; min-width: 0; font-weight: 600; }
.chore-title small { display: block; color: var(--muted); font-weight: 500; }
.chore-coins { font-weight: 800; color: var(--brand); white-space: nowrap; }
.badge { padding: 5px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge.wait { background: #fff3cd; color: #8a6100; }
.badge.ok { background: #dff9ef; color: #036b52; }

/* Parent */
.kids { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.kid { border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.kid summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.kid summary::-webkit-details-marker { display: none; }
.kid-pet { font-size: 2rem; }
.kid-name { flex: 1; font-weight: 700; }
.kid-name small { display: block; font-weight: 500; color: var(--muted); }
.kid .coins { font-weight: 800; color: var(--brand); }
.mini-stats { margin: 10px 0 2px; font-size: .9rem; color: var(--muted); }
details.add > summary { list-style: none; margin-top: 8px; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 12px; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick label { cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick span { display: block; font-size: 1.5rem; padding: 4px 6px; border-radius: 10px; border: 2px solid transparent; }
.icon-pick input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }

.ledger { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.ledger li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ledger li > span:nth-child(2) { flex: 1; }
.ledger small { color: var(--muted); white-space: nowrap; }
.plus, .minus { font-weight: 800; min-width: 38px; }
.plus { color: var(--ok); }
.minus { color: var(--bad); }

/* Toast + confirm dialog */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  background: var(--text); color: var(--card); padding: 12px 18px; border-radius: 14px; font-weight: 600;
  max-width: calc(100% - 32px); opacity: 0; transition: .25s; z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal { background: var(--card); border-radius: var(--radius); padding: 20px; max-width: 360px; width: 100%; text-align: center; }
.modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.coin-pop { position: fixed; font-size: 1.6rem; pointer-events: none; animation: pop 1s ease-out forwards; z-index: 40; }
@keyframes pop { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-70px); } }

/* Chore kid tick boxes + inline edit */
.kid-picks { border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px 10px; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.kid-picks legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.form .tick { flex-direction: row; align-items: center; gap: 0; cursor: pointer; font-weight: 600; }
.tick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tick span { display: inline-block; padding: 8px 12px; border-radius: 99px; border: 2px solid var(--line); background: var(--bg); }
.tick span::before { content: '☐ '; }
.tick input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.tick input:checked + span::before { content: '☑ '; }
.tick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.chore-edit { list-style: none; padding: 12px; margin: 4px 0 10px; border: 2px dashed var(--brand-2); border-radius: 14px; }
.chore-edit h3 { margin: 0 0 10px; font-size: 1rem; }
.kid-row { display: flex; align-items: center; gap: 10px; }

/* Avatars & pet art */
.pet-art { bottom: 10px !important; width: 180px; height: 180px; font-size: 0 !important; }
.pet-art svg { width: 100%; height: 100%; display: block; }
.pet-face { left: calc(50% + 58px); bottom: 150px; }
.looks-link { text-decoration: none; font-size: 1.2rem; vertical-align: middle; }
.who-avatar { display: inline-block; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: #fff; }
.who-avatar svg, .kid-avatar svg, .kid-petart svg { width: 100%; height: 100%; display: block; }
.kid-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; overflow: hidden; }
.kid-petart { width: 38px; height: 38px; flex: none; margin-left: -14px; margin-top: 16px; background: #bfe9ff; border-radius: 50%; border: 2px solid var(--card); }
.looks-btn { margin-top: 10px; text-decoration: none; }
.look-editor { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.look-editor .form { width: 100%; }
.look-preview { width: 170px; height: 170px; border-radius: 50%; background: #e9e4ff; }
.look-preview.pet { border-radius: 20px; background: #bfe9ff; }
.swatches { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.swatches legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; padding: 0; }
.swatches label { cursor: pointer; }
.swatches input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); box-shadow: inset 0 0 0 2px #fff; }
.swatches input:checked + span { border-color: var(--brand); transform: scale(1.12); }
.swatches input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.photo-btn { background: linear-gradient(135deg, var(--brand), #fd79a8); color: #fff; cursor: pointer; }
.small-print { font-size: .85rem; text-align: center; }
.photo-busy { position: fixed; inset: 0; background: rgba(0,0,0,.5); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-weight: 700; z-index: 70; font-size: 1.1rem; }
.photo-busy .spin { font-size: 3rem; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.topbar .coins, .logout, .who { white-space: nowrap; }
.who-avatar { flex: none; }
@media (max-width: 440px) {
  .brand { font-size: 1rem; }
  .topbar-right { gap: 7px; }
  .who-avatar + .who { display: none; }
}
.wrap > p > a { color: var(--brand-2); font-weight: 600; text-decoration: none; }
.art-img { width: 100%; height: 100%; display: block; object-fit: cover; }
.pet-art .art-img { object-fit: contain; }
.kid-petart .art-img { object-fit: contain; }
.pic-note { font-size: .85rem; color: var(--muted); text-align: center; margin: 0; }
.pet-art .art-img { border-radius: 28px; }
.topnav { display: flex; gap: 4px; }
.topnav a { text-decoration: none; font-size: 1.15rem; padding: 3px 8px; border-radius: 10px; background: rgba(255,255,255,.12); }
.topnav a.on { background: rgba(255,255,255,.35); }
.row-links { display: flex; gap: 8px; flex-wrap: wrap; }
.tick.adult span { border-style: dashed; }
@media (max-width: 440px) {
  .topbar:has(.topnav) .brand-text { display: none; }
  .topbar:has(.topnav) .brand { font-size: 1.4rem; }
}

/* ---- Back yard: the pet roams around ---------------------------------------- */
.yard { position: relative; height: 330px; border-radius: var(--radius); overflow: hidden; background: #8ed46a; touch-action: manipulation; }
.yard-bg { position: absolute; inset: 0; }
.yard-bg svg, .yard-bg img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center bottom; }
.yard-svg .cloud { animation: drift 60s linear infinite alternate; }
.yard-svg .c2 { animation-duration: 45s; }
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(60px); } }
.yard-ground { position: absolute; left: 7%; right: 7%; bottom: 2%; height: 29%; }
.walker {
  position: absolute; left: 50%; bottom: 25%; width: 130px; height: 130px;
  transform: translateX(-50%) scale(var(--s, .85)); transform-origin: 50% 100%; z-index: var(--z, 50);
}
.walker-shadow { position: absolute; left: 16%; right: 16%; bottom: -4px; height: 18px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0,0,0,.35), rgba(0,0,0,0)); }
.walker-flip { position: absolute; inset: 0; transition: transform .25s; }
.walker.left .walker-flip { transform: scaleX(-1); }
.walker-bob { width: 100%; height: 100%; transform-origin: 50% 100%; }
.walker-bob svg, .walker-bob .art-img { width: 100%; height: 100%; display: block; object-fit: contain; }
.walker.walking .walker-bob { animation: trot .32s ease-in-out infinite; }
.walker.eating .walker-bob { animation: munch .28s ease-in-out infinite; }
.walker.jump .walker-bob { animation: hop-big .55s ease-out 2; }
@keyframes trot { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-9px) rotate(3deg); } }
@keyframes munch { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(7px) rotate(5deg) scaleY(.96); } }
@keyframes hop-big { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-38px) scale(1.06); } }
.yard.mood-sick .walker-bob { filter: grayscale(.55) saturate(.6); transform: rotate(-10deg) translateY(10px); }
.yard.mood-sad .walker-bob, .yard.mood-hungry .walker-bob { filter: saturate(.85); }
.yard .dirt { position: absolute; inset: 18% 18% 6% 18%; pointer-events: none; border-radius: 40%; }
.yard .pet-face { position: absolute; right: -8px; top: -8px; left: auto; bottom: auto; font-size: 1.6rem; background: #fff; border-radius: 50%; padding: 1px 4px; box-shadow: var(--shadow); }
.yard .poops { position: absolute; inset: 0; pointer-events: none; }
.poop, .prop {
  position: absolute; transform: translateX(-50%) scale(var(--s, 1)); transform-origin: 50% 100%; z-index: var(--z, 40);
  font-size: 1.9rem; line-height: 1; transition: opacity .4s, transform .4s;
}
.poop.gone, .prop.gone { opacity: 0; transform: translate(-50%, -24px) scale(.3); }
.prop.toss { transition: left .7s cubic-bezier(.2,.7,.4,1), bottom .7s cubic-bezier(.2,.7,.4,1), transform .7s; }
.fx { position: absolute; z-index: 999; pointer-events: none; font-size: 1.4rem; animation: fx-up 1.3s ease-out forwards; }
@keyframes fx-up { from { opacity: 1; transform: translate(-50%, 0) scale(.7); } to { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -80px) scale(1.2); } }
.yard-thumb { height: 150px; border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.yard-thumb svg, .yard-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center bottom; }
@media (prefers-reduced-motion: reduce) { .walker, .walker * , .yard-svg .cloud { animation: none !important; transition: none !important; } }

/* ---- Rig gaits: the side-view pet that appears while walking/running ---------------- */
.walker-rig { position: absolute; left: -24%; width: 148%; bottom: -8px; display: none; pointer-events: none; }
.walker-rig svg { width: 100%; height: auto; display: block; overflow: visible; }
.walker.moving .walker-rig { display: block; }
.walker.moving .walker-bob, .walker.moving .walker-shadow, .walker.moving .dirt { display: none; }
.rig .rig-leg, .rig .rig-shin, .rig .rig-ear, .rig .rig-arm { transform-box: fill-box; transform-origin: 50% 0; }
.rig .rig-tail { transform-box: fill-box; transform-origin: 100% 100%; }
.rig .rig-head { transform-box: fill-box; transform-origin: 15% 90%; }
.rig .rig-wing { transform-box: fill-box; transform-origin: 100% 0; }
.rig .rig-body, .rig .rig-hop { transform-box: view-box; transform-origin: 100px 110px; }

/* Dog & cat — walk: diagonal pairs (near-back with far-front) */
.walker.walking .rig-quad .rig-leg { animation: q-leg .72s linear infinite; }
.walker.walking .rig-quad .rig-shin { animation: q-shin .72s linear infinite; }
.walker.walking .rig-quad .nf, .walker.walking .rig-quad .fb,
.walker.walking .rig-quad .nf .rig-shin, .walker.walking .rig-quad .fb .rig-shin { animation-delay: -.36s; }
.walker.walking .rig-quad .rig-body { animation: q-body .36s ease-in-out infinite; }
.walker.walking .rig-quad .rig-head { animation: q-head .72s ease-in-out infinite; }
.walker.walking .rig-quad .rig-tail, .walker.running .rig-quad .rig-tail { animation: wag .32s ease-in-out infinite; }
.walker.walking .rig-quad .rig-ear { animation: ear .36s ease-in-out infinite; }
/* Dog & cat — run: a gallop (front pair, then back pair), body rocking */
.walker.running .rig-quad .rig-leg { animation: q-gallop .42s linear infinite; }
.walker.running .rig-quad .rig-shin { animation: q-gallop-shin .42s linear infinite; }
.walker.running .rig-quad .ff, .walker.running .rig-quad .ff .rig-shin { animation-delay: -.04s; }
.walker.running .rig-quad .nb, .walker.running .rig-quad .nb .rig-shin { animation-delay: -.21s; }
.walker.running .rig-quad .fb, .walker.running .rig-quad .fb .rig-shin { animation-delay: -.25s; }
.walker.running .rig-quad .rig-body { animation: q-rock .42s ease-in-out infinite; }
.walker.running .rig-quad .rig-ear { animation: ear .21s ease-in-out infinite; }

@keyframes q-leg { 0% { transform: rotate(24deg); } 50% { transform: rotate(-22deg); } 100% { transform: rotate(24deg); } }
@keyframes q-shin { 0% { transform: rotate(0); } 22% { transform: rotate(48deg); } 45%, 100% { transform: rotate(0); } }
@keyframes q-body { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes q-head { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes wag { 0%, 100% { transform: rotate(-16deg); } 50% { transform: rotate(16deg); } }
@keyframes ear { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(14deg); } }
@keyframes q-gallop { 0% { transform: rotate(38deg); } 45% { transform: rotate(-36deg); } 100% { transform: rotate(38deg); } }
@keyframes q-gallop-shin { 0% { transform: rotate(10deg); } 20% { transform: rotate(70deg); } 45%, 100% { transform: rotate(0); } }
@keyframes q-rock { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-8px) rotate(5deg); } }

/* Dinosaur — big alternating steps, stomping body, swinging tail */
.walker.walking .rig-dino .rig-leg { animation: d-leg .9s ease-in-out infinite; }
.walker.walking .rig-dino .rig-shin { animation: d-shin .9s ease-in-out infinite; }
.walker.walking .rig-dino .fb, .walker.walking .rig-dino .fb .rig-shin { animation-delay: -.45s; }
.walker.walking .rig-dino .rig-body { animation: d-body .45s ease-in-out infinite; }
.walker.walking .rig-dino .rig-tail { animation: d-tail .9s ease-in-out infinite; }
.walker.walking .rig-dino .rig-head { animation: q-head .9s ease-in-out infinite; }
.walker.walking .rig-dino .rig-arm, .walker.running .rig-dino .rig-arm { animation: ear .45s ease-in-out infinite; }
.walker.running .rig-dino .rig-leg { animation: d-leg-run .5s ease-in-out infinite; }
.walker.running .rig-dino .rig-shin { animation: d-shin .5s ease-in-out infinite; }
.walker.running .rig-dino .fb, .walker.running .rig-dino .fb .rig-shin { animation-delay: -.25s; }
.walker.running .rig-dino .rig-body { animation: d-body-run .25s ease-in-out infinite; }
.walker.running .rig-dino .rig-tail { animation: d-tail .5s ease-in-out infinite; }
@keyframes d-leg { 0%, 100% { transform: rotate(26deg); } 50% { transform: rotate(-24deg); } }
@keyframes d-leg-run { 0%, 100% { transform: rotate(36deg); } 50% { transform: rotate(-34deg); } }
@keyframes d-shin { 0% { transform: rotate(0); } 25% { transform: rotate(38deg); } 50%, 100% { transform: rotate(0); } }
@keyframes d-body { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-5px) rotate(1.5deg); } }
@keyframes d-body-run { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-9px) rotate(2deg); } }
@keyframes d-tail { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

/* Bird — hops; flaps when in a hurry */
.walker.walking .rig-bird .rig-hop { animation: b-hop .5s ease-in-out infinite; }
.walker.walking .rig-bird .rig-leg { animation: b-legs .5s ease-in-out infinite; }
.walker.walking .rig-bird .rig-wing { animation: b-flutter .5s ease-in-out infinite; }
.walker.running .rig-bird .rig-hop { animation: b-hop-run .34s ease-in-out infinite; }
.walker.running .rig-bird .rig-leg { animation: b-legs .34s ease-in-out infinite; }
.walker.running .rig-bird .rig-wing { animation: b-flap .17s ease-in-out infinite; }
@keyframes b-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-14px) rotate(-4deg); } }
@keyframes b-hop-run { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(-22px) rotate(-6deg); } }
@keyframes b-legs { 0%, 100% { transform: rotate(0); } 45% { transform: rotate(35deg); } }
@keyframes b-flutter { 0%, 100% { transform: rotate(0); } 45% { transform: rotate(-18deg); } }
@keyframes b-flap { 0%, 100% { transform: rotate(10deg); } 50% { transform: rotate(-60deg); } }
.yard .pet-face { transition: opacity .2s; } .walker.moving .pet-face { opacity: 0; }

/* ---- AI-drawn frames (flipbook) for photo pets ---- */
.walker-sprite { display: none; position: absolute; bottom: 0; left: 50%; height: 100%; width: auto; transform: translateX(-50%); transform-origin: 50% 100%; }
.walker.has-sprites .walker-sprite { display: block; }
.walker.has-sprites .walker-bob, .walker.has-sprites .walker-rig { display: none !important; }
.walker.has-sprites.moving .walker-shadow { display: block; }
.walker.has-sprites.moving .walker-sprite { height: 92%; }
.walker.has-sprites.running .walker-sprite { animation: sprite-bound .3s ease-in-out infinite; }
.walker.has-sprites.eating .walker-sprite { animation: sprite-munch .28s ease-in-out infinite; }
.walker.has-sprites.jump .walker-sprite { animation: sprite-hop .55s ease-out 2; }
.yard.mood-sick .walker-sprite { filter: grayscale(.55) saturate(.6); }
@keyframes sprite-bound { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
@keyframes sprite-munch { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(6px) rotate(4deg); } }
@keyframes sprite-hop { 0%, 100% { transform: translateX(-50%) translateY(0); } 40% { transform: translateX(-50%) translateY(-36px); } }
.anim-preview { display: flex; gap: 6px; width: 100%; }
.anim-preview img { flex: 1; min-width: 0; border-radius: 10px; background: repeating-conic-gradient(#e9e4ff 0 25%, #fff 0 50%) 0 0 / 16px 16px; }

/* Facing towards / away from you */
.walker.moving[data-dir="towards"]:not(.has-sprites) .walker-rig { display: none; }
.walker.moving[data-dir="towards"]:not(.has-sprites) .walker-bob { display: block; animation: trot .3s ease-in-out infinite; }
.walker.moving[data-dir="towards"]:not(.has-sprites) .walker-shadow { display: block; }
.walker.has-sprites.moving[data-dir="towards"] .walker-sprite, .walker.has-sprites.moving[data-dir="away"] .walker-sprite { height: 100%; }
.carried { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); font-size: 1.4rem; z-index: 5; pointer-events: none; }
.walker[data-dir="away"] .carried { display: none; }
.yard { cursor: pointer; }

/* ---- Parent home: profile circles ---- */
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 14px 8px; }
.profile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--text); text-align: center; }
.pf-circle { width: 78px; height: 78px; border-radius: 50%; overflow: hidden; background: #e9e4ff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--brand-2); transition: transform .15s, box-shadow .15s; }
.pf-circle svg, .pf-circle .art-img { width: 100%; height: 100%; display: block; object-fit: cover; }
.profile:hover .pf-circle, .profile:focus-visible .pf-circle { transform: scale(1.06); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--brand); }
.profile:active .pf-circle { transform: scale(.96); }
.pf-pet { position: absolute; top: 46px; left: calc(50% + 14px); width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: #bfe9ff; border: 3px solid var(--card); }
.pf-pet svg, .pf-pet .art-img { width: 100%; height: 100%; display: block; object-fit: contain; }
.pf-mood { position: absolute; top: -4px; left: calc(50% + 18px); font-size: 1.2rem; background: var(--card); border-radius: 50%; padding: 0 2px; }
.pf-name { font-weight: 700; font-size: .95rem; margin-top: 4px; line-height: 1.2; }
.pf-name small { font-weight: 500; color: var(--muted); }
.pf-coins { font-size: .8rem; font-weight: 700; color: var(--brand); }
.profile.add .pf-circle { background: transparent; border: 3px dashed var(--brand-2); box-shadow: none; font-size: 2rem; color: var(--brand-2); }
.hub-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.hub-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); font-weight: 700; }
.hub-btn:active { transform: scale(.97); }
.hub-icon { font-size: 2rem; }
.back-link { margin: 0 0 10px; }
.back-link a { color: var(--brand-2); font-weight: 700; text-decoration: none; }
.person-head { text-align: center; }
.person-head h1 { margin: 10px 0 0; }
.person-head .muted { margin: 2px 0 6px; }
.pf-circle.big { width: 120px; height: 120px; margin: 0 auto; font-size: 3rem; }
.person-coins { font-size: 1.3rem; font-weight: 800; color: var(--brand); margin: 0 0 12px; }
.person-pet { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.person-pet-art { width: 110px; height: 110px; flex: none; border-radius: 18px; background: #bfe9ff; overflow: hidden; }
.person-pet-art svg, .person-pet-art .art-img { width: 100%; height: 100%; display: block; object-fit: contain; }
.person-pet-info { flex: 1; min-width: 0; }
.person-pet-info .stats { margin: 6px 0 0; grid-template-columns: 1fr; gap: 6px; }
.person-pet-info .pet-mood { margin: 0; text-align: left; }
.danger-zone { text-align: center; }
.add-circle { margin-bottom: 8px; }
.waiting { border: 2px solid var(--warn); }
.card p a { color: var(--brand-2); font-weight: 600; }
.card.narrow > h2, .card.narrow > p.muted { text-align: center; }
