:root {
  color: #17211b;
  background: #eef7ef;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
}

button {
  font: inherit;
}

.page-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 24px);
}

.phone-frame {
  width: min(390px, 100%);
  height: min(780px, calc(100svh - 24px));
  min-height: min(560px, calc(100svh - 24px));
  border-radius: 42px;
  background: #fbfff8;
  box-shadow: 0 24px 80px rgba(41, 75, 49, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-status {
  display: flex;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 16px 24px 8px;
  font-size: 13px;
  font-weight: 700;
}

.app-root {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 12px 18px 18px;
}

.app-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 14px;
}

.screen {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.screen h1 {
  margin: 8px 0 10px;
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: #2f8f52;
  font-size: 13px;
  font-weight: 800;
}

.muted {
  color: #667267;
  line-height: 1.5;
}

.state-grid,
.task-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.state-card,
.task-card {
  width: 100%;
  border: 0;
  border-radius: 22px;
  background: #eef8ec;
  color: #17211b;
  padding: 18px;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.08);
}

.state-card span,
.task-card strong {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.state-card small,
.task-card small {
  display: block;
  margin-top: 6px;
  color: #667267;
}

.state-card.selected,
.task-card.completed {
  background: #ccefcf;
}

.task-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
}

.task-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: #2f8f52;
  font-weight: 900;
}

.reward-banner {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  background: #fff4c7;
}

.reward-banner span {
  color: #735c11;
  font-size: 14px;
}

.reset-button {
  border: 0;
  background: transparent;
  color: #6c766d;
  padding: 8px;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 24px;
  background: #eff6ed;
}

.bottom-nav button {
  border: 0;
  border-radius: 18px;
  background: transparent;
  padding: 12px 4px;
  color: #657166;
  font-weight: 800;
}

.bottom-nav button.active {
  background: #fff;
  color: #2f8f52;
}

.growth-room {
  position: relative;
  min-height: 190px;
  margin-top: 16px;
  border-radius: 26px;
  overflow: hidden;
  background: linear-gradient(#dff4ff 0 42%, #f7ecd1 42%);
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.08);
}

.room-window {
  position: absolute;
  top: 22px;
  left: 24px;
  width: 88px;
  height: 66px;
  border: 8px solid #fff;
  border-radius: 18px;
  background: linear-gradient(#a7dbff, #f9fdff);
}

.avatar-row {
  position: absolute;
  right: 32px;
  bottom: 20px;
  display: flex;
  align-items: flex-end;
}

/* 寵物在房間裡自主行動（位置由行為引擎控制） */
.pet-walker {
  position: absolute;
  left: 8%;
  bottom: 16px;
  z-index: 2;
}

.pet-walker.facing-left .pet-sprite {
  scale: -1 1;
}

.pet-emote {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 12px 12px 12px 3px;
  background: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(41, 75, 49, 0.16);
  animation: bubble-pop 0.25s ease-out;
  white-space: nowrap;
}

.food-bowl {
  position: absolute;
  left: 66%;
  bottom: 12px;
  font-size: 26px;
  animation: bubble-pop 0.3s ease-out;
}

.water-bowl {
  position: absolute;
  left: 72%;
  bottom: 12px;
  font-size: 26px;
  animation: bubble-pop 0.3s ease-out;
}

/* 夜晚模式 */
.growth-room.night {
  background: linear-gradient(#1d2b45 0 42%, #3a3f55 42%);
}

.growth-room.night .room-window {
  background: linear-gradient(#0e1830, #28406b);
}

.pet,
.self-avatar {
  position: relative;
  filter: drop-shadow(0 10px 10px rgba(53, 76, 45, 0.14));
}

.pet {
  width: 86px;
  height: 72px;
  border-radius: 50% 50% 44% 44%;
  background: #ffe58a;
}

.pet::before,
.pet::after {
  content: "";
  position: absolute;
  top: -15px;
  width: 26px;
  height: 30px;
  border-radius: 50%;
  background: #ffe58a;
}

.pet::before {
  left: 13px;
  transform: rotate(-28deg);
}

.pet::after {
  right: 13px;
  transform: rotate(28deg);
}

.self-avatar {
  width: 80px;
  height: 98px;
  border-radius: 42px 42px 24px 24px;
  background: linear-gradient(#ffd8b5 0 36%, #9fd9a8 36%);
}

.self-avatar::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 11px;
  width: 58px;
  height: 40px;
  border-radius: 50%;
  background: #2f3b30;
}

.energy-track {
  height: 14px;
  margin-top: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: #e3eadf;
}

.energy-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63c86d, #ffe07a);
}

.unlock-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.unlock-item {
  min-width: 0;
  border-radius: 18px;
  padding: 10px 8px;
  background: #eef8ec;
}

.unlock-item strong,
.unlock-item small {
  display: block;
}

.unlock-item strong {
  font-size: 12px;
}

.unlock-item small {
  margin-top: 4px;
  color: #667267;
  font-size: 11px;
}

.unlock-item.locked {
  opacity: 0.62;
}

.unlock-item.unlocked {
  background: #fff4c7;
}

.progress-screen {
  display: flex;
  flex-direction: column;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.progress-card {
  min-width: 0;
  border-radius: 20px;
  padding: 14px;
  background: #eef8ec;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.08);
}

.progress-card span {
  display: block;
  color: #667267;
  font-size: 12px;
  font-weight: 800;
}

.progress-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.progress-card.highlight {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #ccefcf;
}

.progress-card.highlight strong {
  font-size: 42px;
}

.chart-card {
  margin-top: 14px;
  border-radius: 24px;
  padding: 18px;
  background: #fff4c7;
  box-shadow: inset 0 0 0 1px rgba(115, 92, 17, 0.08);
}

.chart-bars {
  height: 136px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 10px;
}

.chart-bars span {
  display: block;
  min-height: 18px;
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(180deg, #63c86d, #2f8f52);
}

.onboarding h1 {
  font-size: 24px;
}

.ob-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.ob-form label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  color: #44503f;
}

.ob-form input {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  background: #eff6ed;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.12);
}

.ob-form input:focus {
  outline: 2px solid #63c86d;
}

.ob-optional {
  margin: 8px 0 0;
  color: #2f8f52;
  font-size: 12px;
  font-weight: 800;
}

.ob-submit {
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  background: #2f8f52;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}

.ob-note {
  margin-top: 10px;
  font-size: 12px;
  text-align: center;
}

.eta-note {
  display: block;
  margin-top: 6px;
  color: #2f8f52;
  font-size: 11px;
  font-weight: 800;
}

/* 能量商店 */
.shop-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-radius: 20px;
  padding: 14px;
  background: #fff4c7;
  box-shadow: inset 0 0 0 1px rgba(115, 92, 17, 0.08);
}

.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-head strong {
  font-size: 14px;
}

.shop-head small {
  color: #735c11;
  font-weight: 800;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.shop-item {
  display: grid;
  gap: 2px;
  justify-items: center;
  border: 0;
  border-radius: 14px;
  padding: 10px 4px;
  background: rgba(255, 255, 255, 0.75);
}

.shop-item span {
  font-size: 24px;
}

.shop-item b {
  font-size: 11px;
}

.shop-item small {
  color: #735c11;
  font-size: 10px;
  font-weight: 800;
}

.shop-item.owned {
  box-shadow: inset 0 0 0 1.5px #c9a227;
}

.shop-item.equipped {
  background: #ffe9b3;
  box-shadow: inset 0 0 0 2px #2f8f52;
}

/* 配件戴在頭上，跟著寵物走 */
.pet-accessory {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  z-index: 3;
  pointer-events: none;
}

.pet-sprite {
  position: relative;
}

/* 傳說期：金色光環 */
.pet-emoji.legend .pet-svg {
  filter: drop-shadow(0 0 14px rgba(255, 211, 77, 0.9)) drop-shadow(0 0 28px rgba(255, 211, 77, 0.5));
  animation: legend-pulse 2s ease-in-out infinite;
}

@keyframes legend-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 12px rgba(255, 211, 77, 0.8));
  }
  50% {
    filter: drop-shadow(0 0 26px rgba(255, 211, 77, 1));
  }
}

/* 手錶教學 */
.watch-guide {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border-radius: 18px;
  padding: 14px;
  background: #e8f1fb;
  box-shadow: inset 0 0 0 1px rgba(74, 163, 223, 0.2);
}

.watch-guide strong {
  font-size: 13px;
}

.watch-guide ol {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.7;
  color: #3a4a5a;
}

.watch-guide code {
  font-size: 10px;
  background: #fff;
  padding: 2px 4px;
  border-radius: 6px;
  word-break: break-all;
}

.watch-guide small {
  color: #5a6a7a;
  font-size: 11px;
}

.watch-guide-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.watch-guide-actions button {
  border: 0;
  border-radius: 12px;
  padding: 10px;
  background: #4aa3df;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}

.watch-guide-actions button.ghost {
  background: transparent;
  color: #5a6a7a;
}

.decor-flower {
  position: absolute;
  left: 10px;
  bottom: 12px;
  font-size: 22px;
}

.decor-painting {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
}

.settings-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-radius: 20px;
  padding: 14px;
  background: #eff6ed;
}

.settings-card > strong {
  font-size: 14px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  text-align: left;
}

.settings-row b {
  display: block;
  font-size: 14px;
}

.settings-row small {
  display: block;
  margin-top: 2px;
  color: #667267;
  font-size: 11px;
}

.switch {
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d4ddd2;
  position: relative;
  transition: background 0.2s;
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}

.switch.on {
  background: #2f8f52;
}

.switch.on i {
  left: 21px;
}

.backup-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.backup-row button {
  border: 0;
  border-radius: 14px;
  padding: 12px;
  background: #eff6ed;
  color: #2f8f52;
  font-weight: 800;
  font-size: 13px;
}

.backup-note {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  text-align: center;
}

.ring-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}

.ring-item {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.ring span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fbfff8;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.ring-item small {
  text-align: center;
  color: #667267;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.kcal-line {
  margin: 4px 0 0;
  font-size: 13px;
}

.comeback-banner {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  border-radius: 18px;
  padding: 14px;
  background: #ccefcf;
}

.comeback-banner strong {
  font-size: 14px;
}

.comeback-banner small {
  color: #44503f;
  line-height: 1.5;
}

.confetti {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  z-index: 20;
  pointer-events: none;
  animation: confetti-fall 2.2s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0.6;
    transform: translateY(105vh) rotate(540deg);
  }
}

.weekly-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-radius: 20px;
  padding: 14px;
  background: #eef8ec;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.08);
}

.weekly-card > strong {
  font-size: 14px;
}

.weekly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.weekly-grid div {
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.7);
}

.weekly-grid span {
  display: block;
  color: #667267;
  font-size: 11px;
  font-weight: 700;
}

.weekly-grid b {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.coach-line {
  color: #2f8f52;
  font-weight: 800;
  font-size: 12px;
}

.photo-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-radius: 20px;
  padding: 14px;
  background: #eff6ed;
}

.photo-card > strong {
  font-size: 14px;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-grid figure {
  margin: 0;
}

.photo-grid img {
  width: 100%;
  border-radius: 14px;
  display: block;
}

.photo-grid figcaption {
  margin-top: 4px;
  color: #667267;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.photo-placeholder {
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #fff;
  color: #98a399;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  min-height: 120px;
}

.photo-button {
  border: 0;
  border-radius: 14px;
  padding: 12px;
  background: #2f8f52;
  color: #fff;
  font-weight: 800;
}

.reminder-toggle {
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 18px;
  padding: 14px;
  text-align: left;
  background: #eff6ed;
  color: #17211b;
}

.reminder-toggle.on {
  background: #fff4c7;
}

.reminder-toggle span {
  display: block;
  font-weight: 800;
}

.reminder-toggle small {
  display: block;
  margin-top: 4px;
  color: #667267;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  max-width: 85%;
  padding: 12px 18px;
  border-radius: 16px;
  background: #2f3b30;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(41, 75, 49, 0.3);
  animation: toast-in 0.25s ease-out;
  z-index: 10;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.phone-frame {
  position: relative;
}

/* 寵物進化階段 */
.pet.stage-1 {
  width: 62px;
  height: 52px;
}

.pet.stage-2 {
  width: 86px;
  height: 72px;
}

.pet.stage-3 {
  width: 100px;
  height: 84px;
  background: linear-gradient(135deg, #ffe58a, #ffd34d);
  box-shadow: 0 0 24px rgba(255, 213, 77, 0.65);
}

.pet.stage-3::before,
.pet.stage-3::after {
  background: #ffd34d;
}

.evolving {
  animation: evolve 0.9s ease-out;
}

@keyframes evolve {
  0% {
    transform: scale(0.8);
    filter: brightness(1) drop-shadow(0 10px 10px rgba(53, 76, 45, 0.14));
  }
  40% {
    transform: scale(1.18);
    filter: brightness(1.5) drop-shadow(0 0 22px rgba(255, 224, 122, 0.9));
  }
  70% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
    filter: brightness(1) drop-shadow(0 10px 10px rgba(53, 76, 45, 0.14));
  }
}

.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sparkles span {
  position: absolute;
  font-size: 18px;
  animation: sparkle 1.6s ease-in-out infinite;
}

.sparkles span:nth-child(1) {
  top: 18%;
  left: 56%;
}

.sparkles span:nth-child(2) {
  top: 34%;
  left: 78%;
  animation-delay: 0.5s;
}

.sparkles span:nth-child(3) {
  top: 52%;
  left: 42%;
  animation-delay: 1s;
}

@keyframes sparkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.6);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

.pet-emoji {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 10px 10px rgba(53, 76, 45, 0.14));
  transition: font-size 0.4s ease, filter 0.4s ease;
}

/* 動畫掛在內層 sprite，按鈕本體不動，點擊判定才穩定 */
.pet-sprite {
  display: inline-block;
  transform-origin: bottom center;
  animation: idle-okay 3s ease-in-out infinite;
}

/* SVG 寵物：部位各自動畫 */
.pet-svg {
  display: block;
  width: 84px;
  height: auto;
  overflow: visible;
}

.pet-emoji.stage-1 .pet-svg {
  width: 64px;
}

.pet-emoji.stage-3 .pet-svg {
  width: 100px;
}

.pet-svg * {
  transform-box: fill-box;
}

.p-body {
  transform-origin: center bottom;
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(1.035);
  }
}

.p-eye {
  transform-origin: center;
  animation: blink 4.5s infinite;
}

@keyframes blink {
  0%, 92%, 100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.08);
  }
}

.p-tail {
  transform-origin: right bottom;
  animation: tail-wag 1.1s ease-in-out infinite;
}

@keyframes tail-wag {
  0%, 100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(16deg);
  }
}

.pet-emoji.health-thriving .p-tail {
  animation-duration: 0.45s;
}

.pet-emoji.health-weak .p-tail,
.pose-sleeping .p-tail {
  animation: none;
}

/* 走路踏步：前後腳交替 */
.p-leg,
.p-foot {
  transform-origin: center top;
}

.pose-walking .p-leg.a,
.pose-walking .p-foot.a {
  animation: step 0.4s ease-in-out infinite;
}

.pose-walking .p-leg.b,
.pose-walking .p-foot.b {
  animation: step 0.4s ease-in-out infinite reverse;
}

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

/* 企鵝走路左右搖擺 */
.pose-walking .pet-svg.penguin .p-body {
  transform-origin: center bottom;
  animation: waddle 0.5s ease-in-out infinite;
}

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

.p-wing {
  transform-origin: center top;
}

.pose-walking .p-wing {
  animation: step 0.5s ease-in-out infinite;
}

/* 姿勢（由行為引擎切換） */
.pet-sprite.pose-walking {
  animation: idle-good 0.5s ease-in-out infinite;
}

.pet-emoji.health-thriving .pet-sprite.pose-walking {
  animation: idle-thriving 0.45s ease-in-out infinite;
}

.pet-sprite.pose-sitting {
  animation: none;
  transform: scaleY(0.85);
}

.pet-sprite.pose-lying {
  animation: idle-weak 5s ease-in-out infinite;
}

.pet-sprite.pose-sleeping {
  animation: idle-weak 6s ease-in-out infinite;
  opacity: 0.85;
}

/* 物種習性姿勢 */
.pose-sniffing .p-head {
  transform-origin: left center;
  animation: sniff 0.7s ease-in-out infinite;
}

@keyframes sniff {
  0%, 100% {
    transform: rotate(16deg) translateY(6px);
  }
  50% {
    transform: rotate(20deg) translateY(8px);
  }
}

.pet-sprite.pose-shaking {
  animation: shake-fur 0.14s linear infinite;
}

@keyframes shake-fur {
  0%, 100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(6deg);
  }
}

.pose-grooming .p-head {
  transform-origin: center bottom;
  animation: groom 1.2s ease-in-out infinite;
}

@keyframes groom {
  0%, 100% {
    transform: rotate(24deg) translate(-6px, 10px);
  }
  50% {
    transform: rotate(30deg) translate(-8px, 13px);
  }
}

.pet-sprite.pose-stretching {
  transform-origin: center bottom;
  animation: none;
  transform: scaleX(1.2) scaleY(0.78);
  transition: transform 0.5s ease;
}

.daynight-toggle {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 4;
  border: 0;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.55);
  font-size: 16px;
  cursor: pointer;
}

/* 蛋階段 */
.egg-walker {
  left: 38%;
}

.pet-svg.egg {
  width: 70px;
}

.egg-sprite {
  display: inline-block;
  transform-origin: center bottom;
}

.egg-sprite.egg-wobble {
  animation: egg-wobble 0.7s ease-in-out;
}

@keyframes egg-wobble {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-7deg);
  }
  50% {
    transform: rotate(6deg);
  }
  75% {
    transform: rotate(-3deg);
  }
}

/* 房間擺設（隨等級進化） */
.decor-rug {
  position: absolute;
  left: 30%;
  bottom: 8px;
  width: 44%;
  height: 26px;
  border-radius: 50%;
  background: #e7c9a4;
  box-shadow: inset 0 0 0 3px #dcb88c;
}

.decor-item {
  position: absolute;
  font-size: 24px;
  filter: drop-shadow(0 3px 4px rgba(53, 76, 45, 0.18));
}

.decor-plant {
  left: 5%;
  bottom: 14px;
}

.decor-ball {
  right: 8%;
  bottom: 12px;
  font-size: 20px;
}

.decor-bed {
  right: 4%;
  bottom: 40%;
  font-size: 28px;
}

.decor-lights {
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 14px;
}

/* Sprite sheet 模式（USE_SPRITE_SHEETS = true 時生效）
   素材規格：assets/sprites/<petType>.png，橫向 4 幀走路循環，每幀 96x96 */
.pet-sheet {
  display: block;
  width: 96px;
  height: 96px;
  background-size: 384px 96px;
  image-rendering: pixelated;
}

.pet-sheet-dog { background-image: url("../assets/sprites/dog.png"); }
.pet-sheet-cat { background-image: url("../assets/sprites/cat.png"); }
.pet-sheet-penguin { background-image: url("../assets/sprites/penguin.png"); }
.pet-sheet-lion { background-image: url("../assets/sprites/lion.png"); }

.pose-walking .pet-sheet {
  animation: sheet-walk 0.6s steps(4) infinite;
}

@keyframes sheet-walk {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -384px 0;
  }
}

/* 便便與清理 */
.dropping {
  position: absolute;
  bottom: 12px;
  border: 0;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  filter: drop-shadow(0 3px 4px rgba(53, 76, 45, 0.25));
  animation: bubble-pop 0.3s ease-out;
  z-index: 3;
}

.clean-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-radius: 18px;
  padding: 14px;
  background: #ffe3d6;
  box-shadow: inset 0 0 0 1px rgba(180, 90, 50, 0.15);
}

.clean-panel strong {
  font-size: 14px;
}

.rep-dots {
  display: flex;
  gap: 8px;
}

.rep-dots span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px #e2654a;
}

.rep-dots span.filled {
  background: #e2654a;
}

.rep-button {
  border: 0;
  border-radius: 14px;
  padding: 14px;
  background: #e2654a;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.rep-cancel {
  border: 0;
  background: transparent;
  color: #9a6a57;
  font-size: 13px;
  padding: 4px;
}

@keyframes idle-weak {
  0%, 100% {
    transform: scaleY(0.92) rotate(-4deg);
  }
  50% {
    transform: scaleY(0.96) rotate(-4deg);
  }
}

@keyframes idle-okay {
  0%, 100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(1.04) scaleX(0.98);
  }
}

@keyframes idle-good {
  0%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
  50% {
    transform: translateY(0) scaleY(0.94) scaleX(1.04);
  }
  65% {
    transform: translateY(0) scaleY(1);
  }
}

@keyframes idle-thriving {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-12px) rotate(-6deg);
  }
  50% {
    transform: translateY(0) scaleY(0.92) scaleX(1.06);
  }
  75% {
    transform: translateY(-12px) rotate(6deg);
  }
}

/* 摸摸反應：蓋過待機動畫 */
.pet-emoji.patted .pet-sprite {
  animation: pat-jump 0.55s ease-out;
}

@keyframes pat-jump {
  0% {
    transform: scale(1);
  }
  30% {
    transform: translateY(-20px) scale(1.15) rotate(-8deg);
  }
  60% {
    transform: translateY(0) scaleY(0.88) scaleX(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.float-heart {
  position: absolute;
  bottom: 46%;
  font-size: 20px;
  pointer-events: none;
  animation: heart-up 1.3s ease-out forwards;
}

@keyframes heart-up {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-70px) scale(1.2) rotate(12deg);
  }
}

.pet-bubble {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 78%;
  padding: 8px 14px;
  border-radius: 16px 16px 16px 4px;
  background: #fff;
  color: #2f3b30;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(41, 75, 49, 0.18);
  animation: bubble-pop 0.25s ease-out;
  z-index: 5;
}

@keyframes bubble-pop {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

.pat-hint {
  color: #98a399;
  font-weight: 700;
  font-size: 12px;
}

.pet-emoji.stage-1 {
  font-size: 48px;
}

.pet-emoji.stage-3 {
  font-size: 78px;
}

.pet-emoji.health-weak {
  filter: grayscale(0.85) opacity(0.7);
}

.pet-emoji.health-okay {
  filter: grayscale(0.4);
}

.pet-emoji.health-thriving {
  filter: drop-shadow(0 0 18px rgba(255, 213, 77, 0.85));
}

.health-note {
  margin: 4px 0 0;
  font-size: 13px;
}

.companion-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border-radius: 18px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #fff4c7, #ffe9b3);
  box-shadow: inset 0 0 0 1px rgba(115, 92, 17, 0.1);
}

.companion-row {
  display: grid;
  gap: 2px;
}

.companion-row span {
  font-size: 12px;
  font-weight: 800;
  color: #735c11;
}

.companion-row strong {
  font-size: 14px;
}

.companion-card small {
  color: #735c11;
  font-size: 11px;
}

.xp-track span {
  background: linear-gradient(90deg, #ffd34d, #f5a623);
}

.goal-trackers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.goal-card {
  display: grid;
  gap: 8px;
  border-radius: 18px;
  padding: 12px;
  background: #eef8ec;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.08);
}

.goal-card > span {
  font-size: 13px;
  font-weight: 800;
}

.unit-note {
  display: block;
  margin-top: 2px;
  color: #8a958b;
  font-size: 10px;
  font-weight: 700;
}

.goal-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e3eadf;
}

.goal-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63c86d, #2f8f52);
}

.goal-card button {
  border: 0;
  border-radius: 12px;
  padding: 8px;
  background: #2f8f52;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.pet-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.pet-picker button {
  border: 0;
  border-radius: 14px;
  padding: 8px 0;
  font-size: 24px;
  background: #eff6ed;
}

.pet-picker button.selected {
  background: #ccefcf;
  box-shadow: inset 0 0 0 2px #2f8f52;
}

.meal-cam {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  border-radius: 20px;
  padding: 14px;
  background: #fff4c7;
  box-shadow: inset 0 0 0 1px rgba(115, 92, 17, 0.08);
}

.meal-cam > strong {
  font-size: 14px;
}

.meal-cam-button {
  border: 0;
  border-radius: 14px;
  padding: 12px;
  background: #2f8f52;
  color: #fff;
  font-weight: 800;
}

#meal-result img {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 14px;
}

.meal-list {
  display: grid;
  gap: 6px;
}

.meal-row {
  display: flex;
  justify-content: space-between;
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 700;
}

.meal-row small {
  color: #735c11;
}

.kcal-track.over span {
  background: linear-gradient(90deg, #f0a04b, #e2654a);
}

.kcal-over-note {
  color: #b35430;
  font-weight: 700;
  font-size: 12px;
}

.diet-guide {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  border-radius: 20px;
  padding: 14px;
  background: #eef8ec;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.08);
}

.diet-guide > strong {
  font-size: 14px;
}

.diet-tip {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 8px;
}

.diet-tip span {
  font-size: 14px;
  font-weight: 800;
}

.diet-tip small {
  color: #44503f;
}

.diet-note {
  margin-top: 4px;
  color: #2f8f52;
  font-weight: 700;
  font-size: 12px;
}

.pet-stage-tag {
  margin: 10px 0 0;
  color: #2f8f52;
  font-size: 13px;
  font-weight: 800;
}

.weight-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

.weight-form input {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  background: #eff6ed;
  box-shadow: inset 0 0 0 1px rgba(62, 116, 70, 0.12);
}

.weight-form input:focus {
  outline: 2px solid #63c86d;
}

.weight-form button {
  border: 0;
  border-radius: 16px;
  padding: 12px 20px;
  background: #2f8f52;
  color: #fff;
  font-weight: 800;
}

.chart-note {
  display: block;
  margin-top: 10px;
  color: #735c11;
  font-size: 12px;
  text-align: center;
}

@media (max-height: 700px) {
  .growth-room {
    min-height: 160px;
  }

  .screen h1 {
    font-size: 24px;
  }

  .progress-grid {
    margin-top: 12px;
  }

  .progress-card {
    padding: 12px;
  }

  .progress-card.highlight strong {
    font-size: 36px;
  }

  .chart-bars {
    height: 104px;
  }
}
