/* My Pet (#pet) and the header's gold pill. One job per screen; Visual_Token_Set values. */

/* Header gold pill ---------------------------------------------------------- */
.pet-pill { position: relative; display: flex; align-items: center; gap: 5px; height: 45px; padding: 0 12px; background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius-md); font: inherit; color: var(--ink); cursor: pointer; }
.pet-pill[hidden] { display: none; }
.pet-pill:hover { border-color: var(--yellow); }
.pet-pill:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }
.pet-pill span { font-size: 19px; }
.pet-pill strong { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.pet-pill.needs-care::after { content: ""; position: absolute; top: 5px; right: 5px; width: 10px; height: 10px; border-radius: var(--radius-round); background: var(--coral-strong); border: 2px solid var(--paper); }
body:not(.route-home) .pet-pill { height: 40px; }

/* Page ---------------------------------------------------------------------- */
.pet-shell { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.pet-screen { display: flex; flex-direction: column; gap: var(--space-3); max-width: 1020px; margin: 0 auto; }
.pet-family-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); max-width: 1020px; margin: 0 auto var(--space-2); }
.pet-family-bar .pet-button { font-size: var(--text-small); padding: var(--space-1) var(--space-3); }
.pet-collection-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); list-style: none; padding: 0; margin: 0; }
.pet-collection-tile { display: grid; justify-items: center; width: 100%; padding: var(--space-2); background: var(--paper); color: var(--ink); border: 2px solid var(--line); border-radius: var(--radius-md); font: inherit; cursor: pointer; }
.pet-collection-tile.is-current { border-color: var(--blue-strong); background: var(--cream); }
.pet-collection-tile:hover { border-color: var(--blue); }
.pet-collection-tile:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }
.pet-collection-tile > span:not(.pet-choice-art), .pet-collection-tile small { font-size: var(--text-small); }
.pet-collection-tile small { color: var(--muted); }
.pet-collection-nav { display: flex; justify-content: center; align-items: center; gap: var(--space-3); }
.pet-collection-progress { margin: 0; text-align: center; font-weight: 700; font-size: var(--text-small); }
.pet-collection-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pet-collection-foot p { margin: 0; color: var(--muted); font-size: var(--text-small); }
@media (max-width: 650px) {
  .pet-collection-screen .pet-shop-head { flex-direction: column; align-items: stretch; }
  .pet-collection-screen .pet-head > div { min-width: 0; flex: 1; }
  .pet-collection-screen .pet-head > .pet-link { flex-shrink: 0; white-space: nowrap; }
  .pet-collection-screen .pet-shop-head > .pet-gold { align-self: flex-end; }
  .pet-collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .pet-collection-nav { gap: var(--space-1); }
  .pet-collection-nav .pet-button { padding-inline: var(--space-2); font-size: var(--text-small); }
  .pet-collection-foot { flex-direction: column; align-items: stretch; }
}
.pet-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--elevation-soft); padding: var(--space-5); }
.pet-head { display: flex; align-items: flex-start; gap: var(--space-3); }
.pet-head h1 { font-family: var(--font-display); font-size: clamp(26px, 3vw, 38px); line-height: 1.1; margin: 0; }
.pet-head h1:focus, .pet-head h1:focus-visible { outline: none; }
.pet-sub { margin: var(--space-1) 0 0; color: var(--muted); }
.pet-note { min-height: 1.5em; margin: 0; font-weight: 700; color: var(--muted); }
.pet-note.is-good { color: var(--green-text); }
.pet-note.is-warn { color: var(--coral-text); }
.pet-today { margin: 0; color: var(--muted); font-size: var(--text-small); }

.pet-button { min-height: var(--target-min); border: 2px solid var(--transparent); border-radius: var(--radius-md); padding: var(--space-2) var(--space-5); font: inherit; font-weight: 700; font-size: 17px; cursor: pointer; background: var(--transparent); color: var(--ink); }
.pet-primary { background: var(--blue-strong); color: var(--paper); }
.pet-secondary { background: var(--paper); border-color: var(--line); }
.pet-button:disabled { opacity: .5; cursor: not-allowed; }
.pet-button:focus-visible, .pet-action:focus-visible, .pet-choice:focus-visible, .pet-name:focus-visible, .pet-pick:focus-visible, .pet-tab:focus-visible, .pet-link:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }
.pet-link { min-height: var(--target-min); padding: var(--space-1) var(--space-2); border: 0; background: var(--transparent); color: var(--blue-dark); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.pet-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-3); }

/* Room beside the panel ------------------------------------------------------ */
.pet-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.pet-stage { display: flex; justify-content: center; }
.pet-room { position: relative; width: 100%; aspect-ratio: 360 / 203; border-radius: var(--radius-lg); overflow: hidden; border: 4px solid var(--paper); box-shadow: var(--elevation-raised); background: var(--cream); }
.pet-room img, .pet-layer, .pet-bowl, .pet-item-icon, .pet-action-icon, .pet-bubble-icon, .pet-meal-icon, .pet-toy-icon, .pet-room-swatch { image-rendering: pixelated; }
/* The drawn foods, toys and decorations are larger than they are shown, so they are smoothed down rather than sampled. */
.pet-room img.is-smooth, .pet-item-icon.is-smooth, .pet-action-icon.is-smooth, .pet-bubble-icon.is-smooth, .pet-meal-icon.is-smooth, .pet-toy-icon.is-smooth { image-rendering: auto; }
.pet-room-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Depth: wall and floor pieces, then the pet, then the bowl in the foreground. */
.pet-decor { position: absolute; z-index: 1; height: auto; }
.pet-bowl-food { position: absolute; width: 24%; height: auto; transform: translate(-50%, -50%); pointer-events: none; }
.pet-bowl.is-low::after, .pet-bowl.is-empty::after { content: "!"; position: absolute; left: 50%; top: -34%; transform: translateX(-50%); width: 26%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: var(--coral-strong); color: #fff; font: 700 11px/1 var(--font-display); animation: pet-bowl-nudge 1.1s ease-in-out infinite; }
.pet-bowl.is-empty { filter: drop-shadow(0 0 3px var(--coral-strong)); }
@keyframes pet-bowl-nudge { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.25); } }
.pet-stage-hint.is-urgent { color: var(--coral-strong); font-weight: 700; }
.pet-bowl { position: absolute; z-index: 4; pointer-events: none; left: 2.2%; top: 70.4%; width: 14.2%; aspect-ratio: 1; background-repeat: no-repeat; background-size: 400% 100%; }
.pet-room.is-eating-own-bowl .pet-bowl { visibility: hidden; }
.pet-room.is-night::after { content: ""; position: absolute; inset: 0; z-index: 6; background: var(--ink); opacity: .28; pointer-events: none; }

/* The pet (pet-actor.js). Positions are set in % of the room each frame. */
.pet-actor { position: absolute; z-index: 3; aspect-ratio: 1; padding: 0; margin: 0; border: 0; border-radius: var(--radius-md); background: var(--transparent); color: inherit; font: inherit; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-tap-highlight-color: transparent; }
.pet-actor.is-still { cursor: default; }
.pet-actor.is-at-bowl { z-index: 6; }
.pet-actor:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: -2px; }
.pet-actor-body { position: absolute; inset: 0; display: block; }
.pet-actor.is-flipped .pet-actor-body { transform: scaleX(-1); }
.pet-layer { position: absolute; inset: 0; display: block; width: 100%; height: 100%; background-repeat: no-repeat; pointer-events: none; }
.pet-card-sprite { position: relative; display: block; }

/* Thought bubbles and little effects above the pet. */
.pet-actor-bubble { position: absolute; left: 50%; bottom: 90%; z-index: 7; width: 0; height: 0; pointer-events: none; }
.pet-bubble { position: absolute; left: -6px; bottom: 6px; display: grid; place-items: center; min-width: 40px; min-height: 36px; padding: 3px var(--space-2); background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-md); box-shadow: var(--elevation-soft); animation: pet-pop .28s var(--ease-reveal, ease-out) both; }
.pet-bubble::after { content: ""; position: absolute; left: 8px; bottom: -9px; width: 10px; height: 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-round); }
.pet-bubble-icon { max-width: 30px; max-height: 26px; width: auto; height: auto; }
.pet-bubble-emoji { font-size: 20px; line-height: 1; }
.pet-bubble.is-heart { min-width: 0; min-height: 0; padding: 0; background: none; border: 0; box-shadow: none; font-size: 26px; line-height: 1; animation: pet-heart 1.3s var(--ease-reveal, ease-out) both; }
.pet-bubble.is-heart::after, .pet-bubble.is-zz::after { display: none; }
.pet-actor.is-flipped .pet-bubble { left: auto; right: -6px; }
.pet-actor.is-flipped .pet-bubble::after { left: auto; right: 8px; }
.pet-bubble.is-zz { min-width: 0; min-height: 0; padding: 0; background: none; border: 0; box-shadow: none; display: flex; align-items: flex-end; gap: 1px; font-family: var(--font-display); color: var(--paper); text-shadow: 0 0 3px var(--ink), 0 0 1px var(--ink); animation: none; }
.pet-bubble.is-zz b { display: block; font-size: 15px; line-height: 1; animation: pet-zz 2.4s ease-in-out infinite; opacity: 0; }
.pet-bubble.is-zz b:nth-child(2) { font-size: 19px; animation-delay: .8s; }
.pet-bubble.is-zz b:nth-child(3) { font-size: 24px; animation-delay: 1.6s; }
.pet-actor-fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.pet-fx-layer { position: absolute; inset: 0; display: block; }
.pet-fx-layer.is-sparkles i { position: absolute; font-style: normal; font-size: 18px; line-height: 1; animation: pet-twinkle 1.2s ease-in-out infinite both; }
.pet-fx-layer.is-sparkles i:nth-child(1) { left: 10%; top: 30%; }
.pet-fx-layer.is-sparkles i:nth-child(2) { left: 70%; top: 18%; animation-delay: .3s; }
.pet-fx-layer.is-sparkles i:nth-child(3) { left: 28%; top: 62%; animation-delay: .6s; font-size: 22px; }
.pet-fx-layer.is-sparkles i:nth-child(4) { left: 76%; top: 58%; animation-delay: .9s; }
.pet-fx-layer.is-dust i { position: absolute; bottom: 4%; width: 9px; height: 9px; border-radius: var(--radius-round); background: var(--muted); opacity: 0; animation: pet-dust 1.8s ease-out infinite; }
.pet-fx-layer.is-dust i:nth-child(1) { left: 22%; }
.pet-fx-layer.is-dust i:nth-child(2) { left: 64%; animation-delay: .45s; }
.pet-fx-layer.is-dust i:nth-child(3) { left: 40%; animation-delay: .9s; width: 7px; height: 7px; }
.pet-fx-layer.is-dust i:nth-child(4) { left: 78%; animation-delay: 1.35s; width: 7px; height: 7px; }
.pet-meal { position: absolute; z-index: 5; left: 6.4%; bottom: 20.2%; display: flex; align-items: flex-end; justify-content: center; width: 5.6%; height: 10.8%; pointer-events: none; }
.pet-meal[hidden] { display: none; }
.pet-meal-icon { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; transform-origin: 50% 100%; animation: pet-nibble 3.1s steps(1, end) both; }

/* A toy thrown into the room. */
.pet-toy { position: absolute; z-index: 4; top: 82.8%; width: 5%; transition: left .25s var(--ease-standard, ease); pointer-events: none; animation: pet-toy-drop .45s cubic-bezier(.3, 1.4, .6, 1) both; }
.pet-toy[hidden] { display: none; }
.pet-toy-icon { display: block; width: 100%; height: auto; transform-origin: 50% 100%; }
.pet-toy.is-bouncing .pet-toy-icon { animation: pet-toy-bounce .42s ease-in-out infinite alternate; }
.pet-sound-toggle { position: absolute; z-index: 8; top: 27%; right: 1.6%; display: grid; place-items: center; width: var(--target-min); height: var(--target-min); padding: 0; border: 2px solid var(--line); border-radius: var(--radius-round); background: var(--paper); color: var(--ink); font-size: 20px; cursor: pointer; box-shadow: var(--elevation-soft); }
.pet-sound-toggle[aria-pressed="true"] { border-color: var(--blue-dark); }
.pet-sound-toggle:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }
.pet-stage { flex-direction: column; align-items: stretch; gap: var(--space-1); width: 100%; }
.pet-stage-hint { margin: 0; color: var(--muted); font-size: var(--text-caption); }

@keyframes pet-pop { from { opacity: 0; transform: translateY(6px) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes pet-heart { 0% { opacity: 0; transform: translateY(8px) scale(.5); } 25% { opacity: 1; transform: translateY(0) scale(1.15); } 70% { opacity: 1; transform: translateY(-10px) scale(1); } 100% { opacity: 0; transform: translateY(-22px) scale(.9); } }
@keyframes pet-zz { 0% { opacity: 0; transform: translate(0, 6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(8px, -16px); } }
@keyframes pet-twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1.1) rotate(20deg); } }
@keyframes pet-dust { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 25% { opacity: .55; } 100% { opacity: 0; transform: translate(6px, -22px) scale(1.4); } }
@keyframes pet-nibble { 0% { transform: scale(1); } 30% { transform: scale(.78); } 55% { transform: scale(.55); } 80% { transform: scale(.3); } 95%, 100% { transform: scale(0); } }
@keyframes pet-toy-drop { from { transform: translateY(-260%) rotate(-40deg); opacity: 0; } 30% { opacity: 1; } to { transform: none; } }
@keyframes pet-toy-bounce { from { transform: translateY(0) scaleY(.9); } to { transform: translateY(-70%) rotate(25deg); } }

.pet-panel { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.pet-panel.pet-card { padding: var(--space-4) var(--space-5); }
.pet-panel .pet-gold { align-self: flex-start; }
.pet-panel-top .pet-gold { align-self: auto; }
.pet-panel-top, .pet-shop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.pet-gold { display: inline-flex; align-items: center; gap: var(--space-1); margin: 0; padding: var(--space-1) var(--space-3); border-radius: var(--radius-md); background: var(--cream); border: 1px solid var(--line); white-space: nowrap; }
.pet-gold span { font-size: 20px; }
.pet-gold strong { font-family: var(--font-display); font-size: 24px; }
.pet-gold small { color: var(--muted); font-weight: 700; }
.pet-status { margin: 0; font-family: var(--font-display); font-size: 22px; }
.pet-status-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.pet-hearts { display: inline-flex; gap: 2px; margin: 0; font-size: 18px; line-height: 1; white-space: nowrap; }
.pet-hearts i { font-style: normal; }
.pet-hearts .is-empty { opacity: .55; }
.pet-hearts.is-low .is-full { animation: pet-heart-beat 1.2s ease-in-out infinite; }
@keyframes pet-heart-beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .pet-hearts.is-low .is-full { animation: none; } }
.pet-status.is-sick, .pet-status.is-starving { color: var(--coral-text); }
.pet-warning { margin: 0; padding: var(--space-1) var(--space-3); border-radius: var(--radius-md); background: var(--cream); border: 2px solid var(--coral); font-weight: 700; }

.pet-meters { display: grid; gap: var(--space-2); }
.pet-meter { display: grid; grid-template-columns: 96px minmax(0, 1fr) 36px; align-items: center; gap: var(--space-3); }
.pet-meter-label { font-weight: 700; }
.pet-meter-track { display: block; height: 16px; border-radius: var(--radius-sm); background: var(--cream); border: 1px solid var(--line); overflow: hidden; }
.pet-meter-track i { display: block; height: 100%; border-radius: var(--radius-sm); transition: width var(--motion-reveal, .3s) var(--ease-standard, ease); }
.pet-meter-food i { background: var(--coral); }
.pet-meter-fun i { background: var(--blue); }
.pet-meter-clean i { background: var(--green); }
.pet-meter-energy i { background: var(--yellow); }
.pet-meter-value { font-weight: 700; text-align: right; }
/* Level and XP to the next level (pet-levels.js). */
.pet-level { display: grid; grid-template-columns: auto minmax(48px, 1fr) auto; align-items: center; gap: var(--space-1); font-size: var(--text-caption); }
.pet-level-badge { padding: 0 var(--space-1); border-radius: var(--radius-sm); background: var(--blue-dark); color: var(--paper); font-weight: 700; white-space: nowrap; }
.pet-level .pet-meter-track { height: 8px; }
.pet-level .pet-meter-track i { background: var(--blue-dark); }
.pet-level-xp { font-weight: 700; white-space: nowrap; }
.pet-level.is-max { grid-template-columns: auto auto; justify-content: start; }
.pet-meter.is-low .pet-meter-label, .pet-meter.is-low .pet-meter-value { color: var(--coral-text); }

.pet-action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.pet-action { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) var(--space-3); border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; font-size: 18px; text-align: left; cursor: pointer; }
.pet-action:hover { border-color: var(--blue); }
.pet-action span { display: grid; }
.pet-action small { color: var(--muted); font-size: var(--text-small); font-weight: 400; }
.pet-action.is-urgent { grid-column: 1 / -1; border-color: var(--coral-strong); background: var(--cream); }
.pet-action-icon { width: 40px; height: auto; max-height: 40px; object-fit: contain; }

/* Pickers and the shop -------------------------------------------------------- */
.pet-picks, .pet-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--space-3); list-style: none; padding: 0; margin: 0; }
.pet-pick, .pet-shop-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: var(--space-3); align-items: center; min-height: 76px; padding: var(--space-2) var(--space-3); border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--paper); color: var(--ink); font: inherit; text-align: left; }
.pet-pick { width: 100%; cursor: pointer; }
.pet-pick:hover { border-color: var(--blue); }
.pet-pick .pet-item-icon, .pet-shop-item .pet-item-icon { grid-row: 1 / span 2; justify-self: center; max-width: 60px; max-height: 60px; width: auto; height: auto; }
.pet-pick-name { font-weight: 700; }
.pet-pick small, .pet-shop-item small { color: var(--muted); font-size: var(--text-small); }
.pet-shop-item { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-rows: auto auto; min-height: 64px; }
.pet-shop-item .pet-item-icon { grid-row: 1 / span 2; max-width: 52px; max-height: 52px; }
.pet-shop-item .pet-pick-name { grid-column: 2; }
.pet-shop-item small { grid-column: 2; }
.pet-shop-item .pet-button, .pet-shop-item .pet-owned { grid-column: 3; grid-row: 1 / span 2; justify-self: end; min-height: 40px; padding: var(--space-1) var(--space-3); }
.pet-shop { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--space-2); }
.pet-owned { justify-self: start; margin-top: var(--space-1); min-height: 40px; padding: var(--space-1) var(--space-4); }
.pet-owned { color: var(--green-text); font-weight: 700; display: inline-flex; align-items: center; }
.pet-room-swatch, .pet-shop-item .pet-room-swatch { display: block; width: 62px; height: 35px; max-width: none; max-height: none; border-radius: var(--radius-sm); background-size: cover; background-position: center; border: 1px solid var(--line); }
.pet-tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.pet-tab { min-height: var(--target-min); padding: var(--space-2) var(--space-5); border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.pet-tab.is-on { border-color: var(--blue-dark); background: var(--cream); }

/* Adoption ------------------------------------------------------------------ */
.pet-choices { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.pet-choices > li { display: grid; }
.pet-choice { position: relative; display: grid; grid-template-rows: auto 1fr auto; align-items: start; justify-items: center; gap: var(--space-1); width: 100%; padding: var(--space-3) var(--space-2); border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--cream); color: var(--ink); font: inherit; cursor: pointer; }
.pet-choice:hover { border-color: var(--blue); }
.pet-choice.is-picked { border-color: var(--blue-dark); background: var(--paper); box-shadow: var(--elevation-soft); }
.pet-choice.is-locked .pet-choice-art { opacity: .55; }
/* The sprite stands on the card's floor, centred, even when its frame is wider or taller than the box
   (a dog's 99px frame is mostly empty sky): a grid would pin an oversized frame to the top left and crop the pet. */
.pet-saved { margin: 0; color: var(--muted); font-size: var(--text-caption); }
.pet-blurb { margin: 0; color: var(--muted); font-size: var(--text-small); }
.pet-choice-art { position: relative; display: block; width: 100%; height: 94px; overflow: hidden; }
.pet-choice-art .pet-card-sprite { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); }
.pet-choice-art.is-big { height: 150px; }
/* A soft outline so pale coats (the Snow Bunny) still read on the cream card. */
.pet-choice-art .pet-card-sprite { filter: drop-shadow(0 0 1px var(--muted)); }
.pet-choice-name { font-weight: 700; font-size: 15px; line-height: 1.2; text-align: center; }
.pet-chip { padding: 2px var(--space-2); border-radius: var(--radius-sm); background: var(--ink); color: var(--paper); font-size: var(--text-caption); font-weight: 700; }
.pet-chip.is-free { background: var(--green-strong); }
.pet-adopt-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-3); }
.pet-adopt-foot .pet-actions { margin-top: 0; }
.pet-lock { flex: 1 1 320px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--cream); border: 2px solid var(--yellow); }
.pet-lock p { margin: 0 0 var(--space-2); }
.pet-name-card { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-5); align-items: center; }
.pet-name-preview { display: grid; justify-items: center; gap: var(--space-2); }
.pet-name-shown { margin: 0; font-family: var(--font-display); font-size: 28px; }
.pet-names { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.pet-name { min-height: var(--target-min); padding: var(--space-1) var(--space-4); border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.pet-name.is-picked { border-color: var(--blue-dark); background: var(--cream); }
.pet-home-dots { display: flex; gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.pet-home-dots li { width: 28px; height: 28px; border-radius: var(--radius-round); border: 3px solid var(--line); background: var(--paper); }
.pet-home-dots li.is-done { background: var(--green-strong); border-color: var(--green-strong); }

/* Short laptop screens: keep the whole care panel in view. */
@media (max-height: 760px) and (min-width: 761px) {
  .pet-panel .pet-sub { display: none; }
  .pet-action { min-height: 46px; }
  .pet-meters { gap: 2px; }
  .pet-meter-track { height: 12px; }
  .pet-panel { gap: var(--space-2); }
  .pet-choice { padding-block: var(--space-2); }
}

.pet-shop-note { margin: 0 0 var(--space-3); color: var(--muted); }
.pet-shop-item.is-in-use { border-color: var(--green-strong); }

@media (prefers-reduced-motion: reduce) {
  .pet-bubble, .pet-bubble.is-heart, .pet-bubble.is-zz b, .pet-fx-layer i, .pet-meal-icon, .pet-toy, .pet-toy-icon { animation: none !important; opacity: 1; }
  .pet-toy { transition: none; }
  .pet-meter-track i { transition: none; }
}

/* Tablet and phone ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .pet-choices { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .pet-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pet-choice-art { height: 84px; }
}
@media (max-width: 760px) {
  .pet-split { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .pet-card { padding: var(--space-4); }
  .pet-name-card { grid-template-columns: minmax(0, 1fr); }
  .pet-meter { grid-template-columns: 98px minmax(0, 1fr) 32px; gap: var(--space-2); }
  .pet-action { font-size: 16px; gap: var(--space-2); }
  .pet-action-icon { width: 32px; }
  .pet-pill { padding-inline: 9px; }
}
@media (max-width: 330px) {
  .pet-action-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Four tabs in the header nav: each stays on one line. */
@media (min-width: 961px) {
  .main-nav .nav-tab { white-space: nowrap; }
}
@media (min-width: 961px) and (max-width: 1400px) {
  .main-nav { gap: var(--space-4); }
}
@media (min-width: 961px) and (max-width: 1040px) {
  .main-nav { gap: var(--space-3); }
  .player-bar { gap: 6px; }
  .pet-pill { padding-inline: 9px; }
}
/* The home page's roomier header: with a fourth tab, the level pill shows just its orb (as on every other page). */
@media (min-width: 961px) and (max-width: 1500px) {
  body.route-home .level-pill { min-width: 0; width: auto; grid-template-columns: auto; padding: 5px; }
  body.route-home .level-pill > div, body.route-home .level-pill > small { display: none; }
  body.route-home .site-header { gap: var(--space-5); }
}
@media (min-width: 961px) and (max-width: 1100px) {
  body.route-home .score-pill small, body.route-home .streak-pill small, body.route-home .account-button small { display: none; }
  body.route-home .site-header { gap: var(--space-4); }
  body.route-home .main-nav { gap: var(--space-3); }
}
@media (min-width: 961px) and (max-width: 1010px) {
  body.route-home .pet-pill { display: none; }
}

/* ------------------------------------------------------------------ the quiz pet (quiz-pet.js)
   A thin floor under the quiz box. Its height is set in script to the room the page has spare. */
.quiz-pet { position: relative; display: block; width: 100%; margin: 0; pointer-events: none; }
.quiz-pet[hidden] { display: none; }
.quiz-pet-floor { position: absolute; left: 12px; right: 12px; bottom: 4px; height: 6px; border-radius: 999px; background: rgba(23, 35, 63, 0.07); }
.quiz-pet-actor { position: absolute; left: 0; bottom: 6px; display: block; pointer-events: auto; cursor: pointer; will-change: transform; }
.quiz-pet-body { position: absolute; inset: 0; display: block; }
.quiz-pet-actor.is-flipped .quiz-pet-body { transform: scaleX(-1); }
.quiz-pet-body .pet-layer { image-rendering: pixelated; }
/* Thought bubbles sit beside the head, inside the strip, so they never cover the quiz. */
.quiz-pet-bubble { position: absolute; left: calc(var(--head-x, 50%) + 14px); bottom: calc(var(--head-y, 90%) - 30px); width: 0; height: 0; }
.quiz-pet-actor.is-flipped .quiz-pet-bubble { left: auto; right: calc(var(--head-x, 50%) + 14px); }
.quiz-pet-actor.is-flipped .quiz-pet-bubble .pet-bubble { left: auto; right: -6px; }
.quiz-pet-actor.is-flipped .quiz-pet-bubble .pet-bubble::after { left: auto; right: 8px; }
.quiz-pet-bubble .pet-bubble { min-width: 34px; min-height: 30px; white-space: nowrap; }
.quiz-pet-bubble .pet-bubble.is-heart { min-width: 0; min-height: 0; }
.quiz-pet-gold { font-family: var(--font-display); font-weight: 800; font-size: 16px; }
.quiz-pet-hide, .quiz-pet-show { position: absolute; right: 4px; bottom: 6px; pointer-events: auto; border: 1px solid var(--line); background: var(--paper, #fff); color: var(--ink); font: inherit; cursor: pointer; }
.quiz-pet-hide { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border-radius: var(--radius-round, 99px); font-size: 13px; opacity: .72; }
.quiz-pet-hide:hover, .quiz-pet-hide:focus-visible { opacity: 1; }
.quiz-pet-show { min-height: 32px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .quiz-pet-actor { will-change: auto; } }

/* ------------------------------------------------------------------ pets on the landing page (pet-sprites.js) */
.pet-sprite-anim { display: block; background-repeat: no-repeat; background-position: 0% var(--row-y, 0%); image-rendering: pixelated; animation: pet-sprite-frames var(--dur, 1s) steps(var(--frames, 1)) infinite; }
@keyframes pet-sprite-frames { from { background-position-x: 0%; } to { background-position-x: var(--end-x, 0%); } }

/* The dog runs across (0-40%, 50-90% of a trip) and stands at each end, where the
   running sprite hides and an idle one shows, so it never runs on the spot. A trip
   is timed so it covers ground at the room's pace (about half its length a second):
   a 96px dog runs its 221px track in 5s, a 72px one its 135px phone track in 4s. */
.hero-pet { --hero-size: 96px; --trip: 12.5s; position: absolute; z-index: 3; left: 16%; bottom: -8px; width: 58%; height: 96px; pointer-events: none; }
.hero-pet-walk { position: absolute; left: 0; bottom: 0; display: block; width: var(--hero-size); height: var(--hero-size); animation: hero-pet-walk var(--trip) linear infinite; }
.hero-pet-sprite, .hero-pet-idle { position: absolute; inset: 0; width: 100%; height: 100%; animation-name: pet-sprite-frames, hero-pet-turn, hero-pet-running; animation-duration: var(--dur, 1s), var(--trip), var(--trip); animation-timing-function: steps(var(--frames, 1)), step-end, step-end; animation-iteration-count: infinite, infinite, infinite; }
.hero-pet-idle { animation-name: pet-sprite-frames, hero-pet-turn, hero-pet-standing; }
@keyframes hero-pet-walk { 0% { left: 0; } 40%, 50% { left: calc(100% - var(--hero-size)); } 90%, 100% { left: 0; } }
@keyframes hero-pet-turn { 0% { transform: scaleX(1); } 45% { transform: scaleX(-1); } 95% { transform: scaleX(1); } }
@keyframes hero-pet-running { 0% { visibility: visible; } 40% { visibility: hidden; } 50% { visibility: visible; } 90%, 100% { visibility: hidden; } }
@keyframes hero-pet-standing { 0% { visibility: hidden; } 40% { visibility: visible; } 50% { visibility: hidden; } 90%, 100% { visibility: visible; } }

.pet-promo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; gap: 56px; padding-block: 90px; }
.pet-promo h2 { margin: 0 0 14px; font: 700 clamp(30px, 4vw, 46px)/1.08 "Fredoka", sans-serif; letter-spacing: -.01em; }
.pet-promo-lede { margin: 0 0 22px; color: var(--muted); font-size: 17px; max-width: 540px; }
.pet-promo-list { display: grid; gap: 12px; margin: 0 0 26px; padding: 0; list-style: none; }
.pet-promo-list li { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; gap: 12px; }
.pet-promo-list li > span { width: 44px; height: 44px; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; font-size: 22px; box-shadow: var(--soft-shadow, 0 4px 12px rgba(23, 35, 63, .06)); }
.pet-promo-list strong { display: block; font: 600 17px/1.25 "Fredoka", sans-serif; }
.pet-promo-list small { display: block; color: var(--muted); font-size: 14px; line-height: 1.4; }
.pet-promo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.pet-promo-actions p { flex: 1 1 240px; margin: 0; color: var(--muted); font-size: 13px; }
.pet-promo-visual { display: grid; justify-items: center; gap: 18px; }
.pet-promo-card { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; width: min(520px, 100%); padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 22px 45px rgba(31, 40, 75, .13); transform: rotate(1deg); }
.pet-promo-room { position: relative; aspect-ratio: 180 / 320; border-radius: 16px; overflow: hidden; background: #dff3ea; }
.pet-promo-room img { position: absolute; image-rendering: pixelated; }
.pet-promo-bg { inset: 0; width: 100%; height: 100%; }
.pet-promo-plant { left: 6.7%; bottom: 22%; width: 22%; }
.pet-promo-pet { position: absolute; left: 22%; bottom: 6.25%; width: 71%; aspect-ratio: 1; }
.pet-promo-panel { display: grid; align-content: center; gap: 10px; }
.pet-promo-panel p { margin: 0; }
.pet-promo-name strong { font: 700 26px "Fredoka", sans-serif; }
.pet-promo-name small { color: var(--muted); font-weight: 700; }
.pet-promo-gold { justify-self: start; padding: 3px 12px; background: var(--cream); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.pet-promo-gold strong { font: 700 20px "Fredoka", sans-serif; }
.pet-promo-hearts { font-size: 20px; letter-spacing: 1px; }
.pet-promo-meter { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.pet-promo-meter i { display: block; height: 12px; background: #eef0f5; border-radius: 99px; overflow: hidden; }
.pet-promo-meter b { display: block; height: 100%; background: var(--green, #3aa56b); border-radius: 99px; }
.pet-promo-status { font: 600 18px "Fredoka", sans-serif; color: #246f4a; }
.pet-promo-parade { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 0; padding: 0; list-style: none; }
.pet-promo-parade li { display: grid; justify-items: center; gap: 2px; }
.pet-promo-parade li { align-content: end; }
.pet-promo-parade .pet-sprite-anim { width: calc(60px * var(--pet-scale, 1)); height: calc(60px * var(--pet-scale, 1)); }
.pet-promo-parade small { color: var(--muted); font-size: 12px; font-weight: 700; }
@media (max-width: 960px) {
  .pet-promo { grid-template-columns: 1fr; gap: 36px; padding-block: 64px; }
  .pet-promo-copy { text-align: left; }
}
@media (max-width: 520px) {
  .pet-promo-card { grid-template-columns: 118px minmax(0, 1fr); gap: 12px; padding: 12px; transform: none; }
  .pet-promo-name strong { font-size: 22px; }
  .pet-promo-meter { grid-template-columns: 66px minmax(0, 1fr); font-size: 13px; }
  .hero-pet { --hero-size: 72px; --trip: 10s; left: 6%; width: 70%; height: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .pet-sprite-anim, .hero-pet-walk, .hero-pet-sprite { animation: none; }
  .hero-pet-idle { display: none; }
}
/* The narrowest phones: the gold pill is a fourth control in the header, so the pills tighten to keep all four on screen. */
@media (max-width: 380px) {
  .player-bar { gap: 3px; }
  .player-bar .score-pill { gap: 5px; padding-inline: 7px; }
  .player-bar .pet-pill, .player-bar .streak-pill { gap: 3px; padding-inline: 6px; }
}

/* The games link sits beside the gold pill; on a narrow phone the row wraps instead of overflowing. */
.pet-panel-top { flex-wrap: wrap; }
.pet-games-link { white-space: nowrap; margin-left: auto; }
.pet-games-link .pet-section-icon { width: 20px; height: 20px; vertical-align: middle; }

/* ------------------------------------------------------------------ the game-style home screen
   The wide room is the whole stage; the name, needs and gold float over its wall like a game's HUD, and the care
   buttons sit in a dock under it. Wide as the page allows, but never so tall that the dock leaves the screen. */
.pet-hud-screen { --chrome: 296px; max-width: none; width: 100%; gap: var(--space-2); }
.pet-hud { position: relative; width: min(100%, calc((100vh - var(--chrome)) * 360 / 203)); margin: 0 auto; }
.pet-hud .pet-stage { display: block; }
.pet-hud .pet-room { border-width: 3px; }
.pet-hud-top { position: absolute; z-index: 9; inset: 2.4% 1.6% auto 1.6%; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); pointer-events: none; }
.pet-hud-card { pointer-events: auto; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: rgba(255, 255, 255, .9); border: 2px solid var(--paper); box-shadow: var(--elevation-soft); backdrop-filter: blur(4px); min-width: 0; }
.pet-hud-name { display: grid; gap: 2px; max-width: 32%; }
.pet-hud-name .pet-head h1 { font-size: clamp(20px, 2.2vw, 28px); }
.pet-hud-name .pet-sub { margin: 0; font-size: var(--text-caption); }
.pet-hud-name .pet-status { font-size: clamp(14px, 1.5vw, 18px); }
.pet-hud-name .pet-status-row { gap: 0 var(--space-2); }
.pet-hud-name .pet-hearts { font-size: 15px; }
.pet-hud-meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px var(--space-3); flex: 0 1 34%; }
.pet-hud-meters .pet-meter { grid-template-columns: auto minmax(0, 1fr) 24px; gap: var(--space-1); font-size: var(--text-caption); }
.pet-hud-meters .pet-meter-label { white-space: nowrap; }
.pet-hud-meters .pet-meter-track { height: 10px; }
.pet-hud-side { display: grid; justify-items: end; gap: 0; }
.pet-hud-side .pet-gold { padding: 0 var(--space-2); border: 0; background: transparent; }
.pet-hud-side .pet-gold strong { font-size: 20px; }
.pet-hud-side .pet-link { min-height: 32px; padding: 0 var(--space-1); font-size: var(--text-small); }
.pet-hud .pet-stage-hint { position: absolute; z-index: 9; left: 50%; bottom: 2.6%; transform: translateX(-50%); max-width: 70%; padding: 2px var(--space-3); border-radius: var(--radius-round); background: rgba(255, 255, 255, .88); text-align: center; pointer-events: none; }
.pet-hud-screen.has-warning { --chrome: 332px; }
.pet-hud-urgent { position: absolute; z-index: 9; left: 1.6%; top: 36%; }
.pet-hud-urgent .pet-action { background: var(--paper); box-shadow: var(--elevation-soft); }
.pet-dock { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: var(--space-2); width: min(100%, 1020px); margin: 0 auto; }
.pet-dock .pet-action { justify-content: center; min-height: 52px; }
.pet-dock .pet-action.is-urgent { grid-column: auto; }
.pet-action-icon.section-icon { width: 40px; height: 40px; }
.pet-hud-screen .pet-note, .pet-hud-screen .pet-today, .pet-hud-screen .pet-warning { width: min(100%, calc((100vh - var(--chrome)) * 360 / 203)); margin-inline: auto; }
.pet-hud-screen .pet-note { min-height: 1.3em; }
.pet-hud-screen .pet-today { width: min(100%, 1020px); font-size: var(--text-caption); }
.pet-hud-screen .pet-today .pet-link { min-height: 28px; padding: 0 var(--space-1); }
.pet-hud-screen .pet-warning { padding-block: 2px; }

/* The tricks screen ------------------------------------------------------------ */
.pet-tricks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.pet-trick { display: grid; grid-template-columns: 40px minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: var(--space-2); align-items: center; width: 100%; min-height: 64px; padding: var(--space-2); border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--paper); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.pet-trick:hover { border-color: var(--blue); }
.pet-trick:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }
.pet-trick-icon { grid-row: 1 / span 3; width: 32px; height: 32px; justify-self: center; object-fit: contain; }
.pet-trick-name { font-weight: 700; }
.pet-trick small { color: var(--muted); font-size: var(--text-caption); line-height: 1.25; }
.pet-trick-state { font-size: var(--text-caption); font-weight: 700; color: var(--blue-dark); }
.pet-trick.is-known, .pet-trick.is-learned, .pet-trick.is-mastered { background: var(--cream); }
.pet-trick.is-mastered { border-color: var(--yellow); }
.pet-trick.is-mastered .pet-trick-state, .pet-trick.is-learned .pet-trick-state, .pet-trick.is-known .pet-trick-state { color: var(--green-text); }
.pet-pips { display: flex; gap: 3px; margin-top: 2px; }
.pet-pips i { width: 12px; height: 6px; border-radius: 3px; background: var(--line); }
.pet-pips i.is-on { background: var(--blue-strong); }
.pet-pips i.is-goal { margin-right: 4px; }
.pet-train .pet-today { font-size: var(--text-caption); }

@media (max-width: 760px) {
  .pet-hud { width: 100%; }
  .pet-hud-top { position: static; flex-direction: column; align-items: stretch; margin-bottom: var(--space-2); }
  .pet-hud-card { backdrop-filter: none; background: var(--paper); border-color: var(--line); }
  .pet-hud-name { max-width: none; }
  .pet-hud-meters { flex: none; }
  .pet-hud-side { display: flex; justify-content: space-between; align-items: center; }
  .pet-hud .pet-stage-hint { position: static; transform: none; max-width: none; margin-top: var(--space-1); background: transparent; }
  .pet-hud-urgent { position: static; order: 1; margin-bottom: var(--space-2); }
  .pet-dock, .pet-hud-screen .pet-note, .pet-hud-screen .pet-today, .pet-hud-screen .pet-warning { width: 100%; }
  .pet-tricks { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) { .pet-hud { display: flex; flex-direction: column; } .pet-hud .pet-stage { order: 2; } .pet-hud .pet-stage-hint { order: 3; } }

/* What the pet is asking for: its hint says so and the button that answers it pulses. */
.pet-hud .pet-stage-hint.is-wanted { background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: var(--elevation-soft); }
.pet-dock .pet-action.is-wanted { border-color: var(--blue-dark); background: var(--cream); animation: pet-wanted 1.2s ease-in-out infinite; }
@keyframes pet-wanted { 0%, 100% { box-shadow: 0 0 0 0 rgba(66, 90, 220, .35); } 50% { box-shadow: 0 0 0 6px rgba(66, 90, 220, 0); } }
@media (prefers-reduced-motion: reduce) { .pet-dock .pet-action.is-wanted { animation: none; } }
