/* `hidden` always wins: a class that sets `display` (flex, grid…) would otherwise show hidden elements,
   e.g. the parent settings under the password gate. */
[hidden] {
  display: none !important;
}

:root {
  --sky-top: #7dd3fc;
  --sky-bottom: #e0f2fe;
  --hill-back: #86efac;
  --hill-front: #4ade80;
  --card-bg: rgba(255, 255, 255, 0.92);
  --text-main: #2d2a3e;
  --text-muted: #64617a;
  --pink-accent: #ff5c8a;
  --yellow-accent: #ffd166;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-soft: 0 10px 30px rgba(34, 42, 66, 0.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Nunito", "Quicksand", "Comic Sans MS", system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  overflow-x: hidden;
  user-select: none;
}

/* Time-of-day sky themes */
body.time-morning {
  --sky-top: #fda4af;
  --sky-bottom: #fef08a;
  --hill-back: #86efac;
  --hill-front: #4ade80;
}

body.time-afternoon {
  --sky-top: #60a5fa;
  --sky-bottom: #bae6fd;
  --hill-back: #86efac;
  --hill-front: #4ade80;
}

body.time-evening {
  --sky-top: #c084fc;
  --sky-bottom: #fdba74;
  --hill-back: #4ade80;
  --hill-front: #22c55e;
}

body.time-night {
  --sky-top: #1e1b4b;
  --sky-bottom: #312e81;
  --hill-back: #166534;
  --hill-front: #14532d;
}

/* Dojo Mountain Sky Themes */
body.theme-dragon {
  --pink-accent: #e11d48;
}

body.theme-dragon.time-morning {
  --sky-top: #fb7185;
  --sky-bottom: #fed7aa;
  --hill-back: #64748b;
  --hill-front: #475569;
}

body.theme-dragon.time-afternoon {
  --sky-top: #f97316;
  --sky-bottom: #fef08a;
  --hill-back: #64748b;
  --hill-front: #334155;
}

body.theme-dragon.time-evening {
  --sky-top: #7c2d12;
  --sky-bottom: #fb923c;
  --hill-back: #475569;
  --hill-front: #1e293b;
}

body.theme-dragon.time-night {
  --sky-top: #0f172a;
  --sky-bottom: #312e81;
  --hill-back: #1e293b;
  --hill-front: #0f172a;
}

body.theme-dragon .btn-puddle {
  background: #f59e0b;
  box-shadow: 0 5px 0 #b45309;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 65%, var(--hill-front) 100%);
  transition: background 1.2s ease;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 10px;
  z-index: 10;
}

.pet-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
}

.pet-name-label {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--pink-accent);
}

.stage-pill {
  background: #fef3c7;
  color: #b45309;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch,
.theme-switch {
  display: flex;
  background: var(--card-bg);
  padding: 3px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
}

.theme-btn {
  border: none;
  background: transparent;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-btn.active {
  background: var(--yellow-accent);
  transform: scale(1.06);
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--pink-accent);
  color: #fff;
}

.icon-btn {
  position: relative;
  border: none;
  background: var(--card-bg);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--pink-accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* Main Stage */
.stage-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 0 14px 16px;
  gap: 12px;
}

.scene {
  position: relative;
  flex: 1;
  min-height: 310px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 16px;
  box-shadow: inset 0 0 40px rgba(255, 255, 255, 0.25);
}

/* Sun / Moon */
.sky-celestial {
  position: absolute;
  top: 22px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fde047;
  box-shadow: 0 0 36px #fef08a;
  transition: all 1s ease;
}

body.time-morning .sky-celestial {
  background: #fb923c;
  box-shadow: 0 0 40px #fed7aa;
  top: 44px;
}

body.time-evening .sky-celestial {
  background: #f97316;
  box-shadow: 0 0 45px #fdba74;
  top: 48px;
}

body.time-night .sky-celestial {
  background: #fef9c3;
  box-shadow: 0 0 28px #fef08a, inset -12px -4px 0 #cbd5e1;
}

/* Stars */
.stars-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}

body.time-night .stars-layer {
  opacity: 1;
}

.star {
  position: absolute;
  color: #fef08a;
  font-size: 1.1rem;
  animation: twinkle 2.4s infinite ease-in-out;
}
.s1 { top: 14%; left: 12%; animation-delay: 0s; }
.s2 { top: 22%; left: 32%; animation-delay: 0.6s; }
.s3 { top: 10%; left: 58%; animation-delay: 1.2s; }
.s4 { top: 28%; left: 76%; animation-delay: 0.3s; }
.s5 { top: 18%; left: 88%; animation-delay: 1.5s; }

/* Clouds */
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  height: 32px;
  width: 96px;
  pointer-events: none;
}

.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud::before { width: 46px; height: 46px; top: -20px; left: 14px; }
.cloud::after { width: 34px; height: 34px; top: -14px; right: 16px; }

.cloud-1 { top: 28px; left: 10%; animation: drift 28s linear infinite; }
.cloud-2 { top: 68px; left: 55%; transform: scale(0.8); animation: drift 36s linear infinite reverse; }

body.time-night .cloud {
  opacity: 0.25;
}

/* Rainbow (shows when happy >= 80) */
.rainbow {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 130px;
  border-radius: 260px 260px 0 0;
  border: 14px solid transparent;
  box-shadow:
    0 0 0 6px rgba(255, 99, 132, 0.35),
    0 0 0 12px rgba(255, 206, 86, 0.35),
    0 0 0 18px rgba(75, 192, 192, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.rainbow.visible {
  opacity: 1;
}

/* Hills */
.hill {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.hill-back {
  width: 130%;
  height: 170px;
  bottom: -60px;
  left: -20%;
  background: var(--hill-back);
}

.hill-front {
  width: 140%;
  height: 150px;
  bottom: -72px;
  right: -25%;
  background: var(--hill-front);
}

/* Muddy Puddle */
.muddy-puddle {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 190px;
  height: 44px;
  background: #8d6e63;
  border-radius: 50%;
  border: 4px solid #6d4c41;
  box-shadow: inset 0 6px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.25s ease;
}

.muddy-puddle.splash {
  transform: translateX(-50%) scale(1.16, 0.92);
}

.puddle-shine {
  position: absolute;
  top: 8px;
  left: 26px;
  width: 48px;
  height: 10px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
}

/* Dojo Pagoda & Whirl Ring */
.dojo-pagoda,
.whirl-ring {
  display: none;
}

body.theme-dragon .muddy-puddle,
body.theme-dragon .rainbow {
  display: none;
}

body.theme-dragon .dojo-pagoda,
body.theme-dragon .whirl-ring {
  display: block;
}

.dojo-pagoda {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 100px;
  opacity: 0.34;
  pointer-events: none;
}

.pagoda-wall {
  position: absolute;
  bottom: 0;
  left: 25px;
  width: 100px;
  height: 54px;
  background: #7f1d1d;
  border-radius: 4px 4px 0 0;
}

.pagoda-door {
  position: absolute;
  bottom: 0;
  left: 60px;
  width: 30px;
  height: 36px;
  background: #fef08a;
  border-radius: 14px 14px 0 0;
}

.pagoda-roof-mid {
  position: absolute;
  bottom: 50px;
  left: 10px;
  width: 130px;
  height: 20px;
  background: #1e293b;
  border-radius: 18px 18px 4px 4px;
}

.pagoda-roof-top {
  position: absolute;
  bottom: 70px;
  left: 28px;
  width: 94px;
  height: 22px;
  background: #0f172a;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.whirl-ring {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 196px;
  height: 46px;
  border-radius: 50%;
  border: 4px dashed #facc15;
  background: radial-gradient(circle, rgba(251, 146, 60, 0.35), rgba(239, 68, 68, 0.15));
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.whirl-ring.splash {
  transform: translateX(-50%) scale(1.18);
  box-shadow: 0 0 28px rgba(250, 204, 21, 0.8);
}

.ring-inner {
  position: absolute;
  inset: 7px 26px;
  border-radius: 50%;
  border: 2px solid rgba(254, 240, 138, 0.7);
}

/* Interactive Meadow Props */
.scene-prop {
  position: absolute;
  border: none;
  background: transparent;
  font-size: 2.1rem;
  cursor: pointer;
  z-index: 4;
  padding: 4px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.14));
}

.scene-prop:active {
  transform: scale(1.25);
}

.prop-flower {
  bottom: 28px;
  left: 12%;
  animation: swayFlower 3.5s ease-in-out infinite;
}

.prop-ball {
  bottom: 24px;
  right: 30%;
}

/* Top Scene Navigation Pills */
.scene-top-pills {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.go-outside-btn,
.invite-visitor-btn,
.car-ride-btn,
.teddy-play-btn {
  border: 2px solid #ffffff;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-main);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.14s ease;
}

.go-outside-btn:active,
.invite-visitor-btn:active,
.car-ride-btn:active,
.teddy-play-btn:active {
  transform: scale(0.95);
}

.teddy-play-btn.active {
  background: #fef08a;
  border-color: #eab308;
}

.go-outside-btn[hidden],
.invite-visitor-btn[hidden],
.car-ride-btn[hidden],
.teddy-play-btn[hidden] {
  display: none;
}

.house-door {
  position: absolute;
  right: 14px;
  bottom: 24px;
  width: 84px;
  height: 76px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s ease;
}

.house-door:hover {
  transform: scale(1.05);
}

.house-roof {
  position: absolute;
  top: 0;
  left: 2px;
  width: 80px;
  height: 30px;
  background: #ef4444;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border-radius: 4px;
}

body.theme-dragon .house-roof {
  background: #1e293b;
}

.house-body {
  position: absolute;
  bottom: 0;
  left: 10px;
  width: 64px;
  height: 48px;
  background: #fef3c7;
  border: 3px solid #d97706;
  border-radius: 4px 4px 6px 6px;
}

.house-window {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  background: #bae6fd;
  border: 2px solid #0284c7;
  border-radius: 4px;
}

.house-portal {
  position: absolute;
  bottom: 0;
  right: 8px;
  width: 20px;
  height: 30px;
  background: #92400e;
  border-radius: 10px 10px 0 0;
}

/* Indoor Rooms System */
.indoor-room {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1;
}

body.room-kitchen .room-kitchen,
body.room-bathroom .room-bathroom,
body.room-bedroom .room-bedroom,
body.room-car .room-car,
body.room-kitchen .indoor-exit-door,
body.room-bathroom .indoor-exit-door,
body.room-bedroom .indoor-exit-door {
  display: block;
}

.indoor-exit-door {
  display: none;
  position: absolute;
  left: 16px;
  bottom: 28%;
  width: 58px;
  height: 100px;
  background: linear-gradient(180deg, #b45309 0%, #92400e 100%);
  border: 4px solid #78350f;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 0;
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  transition: transform 0.15s ease;
}

.indoor-exit-door:hover {
  transform: scale(1.04);
}

.indoor-exit-door:active {
  transform: scale(0.96);
}

.exit-door-window {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 36px;
  background: linear-gradient(180deg, #7dd3fc 0%, #bae6fd 70%, #4ade80 70%);
  border: 3px solid #fef3c7;
  border-radius: 8px 8px 4px 4px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.exit-door-knob {
  position: absolute;
  right: 7px;
  top: 56px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #facc15;
  border: 1.5px solid #a16207;
}

body.room-car .pet-wrapper,
body.room-car .visitor-wrapper {
  display: none;
}

body:not(.room-outdoor) .muddy-puddle,
body:not(.room-outdoor) .whirl-ring,
body:not(.room-outdoor) .scene-prop,
body:not(.room-outdoor) .house-door,
body:not(.room-outdoor) .rainbow,
body:not(.room-outdoor) .hill,
body:not(.room-outdoor) .dojo-pagoda,
body:not(.room-outdoor):not(.room-car) .cloud,
body:not(.room-outdoor):not(.room-car) .sky-celestial,
body:not(.room-outdoor):not(.room-car) .stars-layer {
  display: none;
}

.room-wall {
  position: absolute;
  inset: 0 0 28% 0;
}

.room-floor {
  position: absolute;
  inset: 72% 0 0 0;
  border-top: 4px solid rgba(0, 0, 0, 0.08);
}

.room-window {
  position: absolute;
  top: 22px;
  right: 26px;
  width: 72px;
  height: 60px;
  background: linear-gradient(180deg, #bae6fd, #e0f2fe);
  border: 5px solid #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Kitchen */
.kitchen-wall {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
}
body.theme-dragon .kitchen-wall {
  background: linear-gradient(180deg, #fed7aa 0%, #fdba74 100%);
}
.kitchen-floor {
  background: repeating-linear-gradient(90deg, #fcd34d 0 40px, #fbbf24 40px 80px);
}
.kitchen-shelf {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: #d97706;
  color: #fff;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 1.3rem;
}

.kitchen-table {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 150px;
  height: 62px;
  background: #b45309;
  border-top: 10px solid #d97706;
  border-radius: 12px 12px 4px 4px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: 0;
}

.table-item {
  margin-top: -36px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.85rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

.table-item:active {
  transform: scale(1.16);
}

/* Bathroom */
.bath-wall {
  background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
}
body.theme-dragon .bath-wall {
  background: linear-gradient(180deg, #ccfbf1 0%, #99f6e4 100%);
}
.bath-floor {
  background: repeating-linear-gradient(45deg, #f0f9ff 0 24px, #bae6fd 24px 48px);
}
.bath-mirror {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.3rem;
}

.bath-shower {
  position: absolute;
  top: 24px;
  right: 32px;
  font-size: 2.2rem;
  transform: scaleX(-1);
}

.bathtub-back {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 46px;
  width: 210px;
  height: 54px;
  background: #e0f2fe;
  border: 4px solid #7dd3fc;
  border-radius: 20px 20px 0 0;
  z-index: 2;
}

.bathtub-front {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  width: 220px;
  height: 62px;
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  border: 4px solid #94a3b8;
  border-radius: 12px 12px 42px 42px;
  z-index: 4;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 14px;
}

.bath-bubbles {
  margin-top: -18px;
  font-size: 1.4rem;
}

.bath-duck {
  margin-top: -22px;
  font-size: 1.7rem;
  animation: swayFlower 2.4s ease-in-out infinite;
}

/* Bedroom */
.bedroom-wall {
  background: linear-gradient(180deg, #ede9fe 0%, #ddd6fe 100%);
}
body.theme-dragon .bedroom-wall {
  background: linear-gradient(180deg, #312e81 0%, #1e1b4b 100%);
}
.bedroom-floor {
  background: #fde68a;
}
body.theme-dragon .bedroom-floor {
  background: #78350f;
}
.bedroom-rug {
  position: absolute;
  left: 20%;
  bottom: 14px;
  width: 170px;
  height: 36px;
  background: rgba(244, 114, 182, 0.45);
  border-radius: 50%;
}
.night-window {
  background: #1e1b4b;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
}
.bedroom-lamp {
  position: absolute;
  top: 32px;
  right: 118px;
  font-size: 2rem;
}

/* Family Car Ride Scenery */
.car-mountains-track {
  position: absolute;
  left: 0;
  bottom: 28%;
  width: 200%;
  height: 55%;
  animation: scrollTrack 15s linear infinite;
}

.car-mountains-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.car-scenery-track {
  position: absolute;
  left: 0;
  bottom: 29%;
  width: 200%;
  display: flex;
  animation: scrollTrack 6.5s linear infinite;
}

.car-scenery-half {
  width: 50%;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  font-size: 2.1rem;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12));
}

.car-road {
  position: absolute;
  inset: 70% 0 0 0;
  background: linear-gradient(180deg, #475569 0%, #334155 100%);
  border-top: 8px solid #22c55e;
  overflow: hidden;
}

.car-road-dashes {
  position: absolute;
  top: 44%;
  left: 0;
  width: 200%;
  height: 7px;
  background: repeating-linear-gradient(90deg, #fef08a 0 36px, transparent 36px 76px);
  animation: scrollTrack 1.2s linear infinite;
}

.car-mud-puddle {
  position: absolute;
  left: 115%;
  bottom: 14px;
  width: 190px;
  height: 36px;
  background: radial-gradient(ellipse at center, #8d6e63 0%, #5d4037 78%);
  border: 3px solid #4e342e;
  border-radius: 50%;
  z-index: 2;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.car-mud-puddle.splashing {
  animation: carMudPass 1.4s linear forwards;
}

.car-shower-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  border: 2px solid #ffffff;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #ffffff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 5px 14px rgba(2, 132, 199, 0.35);
  animation: pulseMic 1.1s ease-in-out infinite;
}

.car-shower-btn[hidden] {
  display: none;
}

.family-car-btn {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  outline: none;
}

.family-car-svg {
  width: 304px;
  height: 170px;
  overflow: visible;
  animation: carBounce 0.48s ease-in-out infinite;
}

.family-car-svg.is-splashing {
  animation: carMudBounce 0.6s ease-in-out 2;
}

.car-wheel-spokes {
  transform-box: fill-box;
  transform-origin: center;
  animation: wheelSpin 0.5s linear infinite;
}

.car-mud-spots {
  display: none;
}

.family-car-svg.is-muddy .car-mud-spots {
  display: block;
}

body.theme-piglet .car-family-dragon { display: none; }
body.theme-dragon .car-family-piglet { display: none; }

/* Cozy Teddy Bear Companion */
.teddy-wrapper {
  position: absolute;
  bottom: 22px;
  left: 50%;
  margin-left: -72px;
  width: 144px;
  height: 144px;
  z-index: 3;
  cursor: pointer;
  outline: none;
  transform: translate(74px, 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  animation: popIn 0.3s ease;
}

.teddy-wrapper[hidden] {
  display: none;
}

.teddy-svg {
  width: 138px;
  height: 138px;
  overflow: visible;
  animation: breathe 3.1s ease-in-out infinite;
}

.teddy-svg.anim-bounce {
  animation: happyBounce 0.5s ease-in-out 2;
}

.teddy-thought {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #f472b6;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  animation: teddyFloat 2.2s ease-in-out infinite;
}

body.theme-piglet .toy-dragon-plush { display: none; }
body.theme-dragon .toy-piglet-teddy { display: none; }

body.room-car .teddy-wrapper {
  display: none;
}

.prop-ball.bouncing {
  animation: ballBounce 0.7s ease-in-out 2;
}

.prop-butterfly {
  top: 32%;
  left: 20%;
  font-size: 1.9rem;
  animation: butterflyFloat 9s ease-in-out infinite;
}

/* Cozy Bed */
.pet-bed {
  position: absolute;
  right: 12px;
  bottom: 18px;
  width: 118px;
  height: 56px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s ease;
}

.pet-bed:active {
  transform: scale(0.96);
}

.bed-headboard {
  position: absolute;
  right: 0;
  bottom: 8px;
  width: 16px;
  height: 46px;
  background: #92400e;
  border-radius: 6px 6px 2px 2px;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.15);
}

.bed-mattress {
  position: absolute;
  left: 4px;
  right: 10px;
  bottom: 4px;
  height: 22px;
  background: #fef3c7;
  border: 3px solid #b45309;
  border-radius: 10px;
}

.bed-pillow {
  position: absolute;
  right: 16px;
  bottom: 20px;
  width: 30px;
  height: 15px;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 999px;
}

.bed-blanket {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 68px;
  height: 22px;
  background: linear-gradient(135deg, #f472b6, #fb7185);
  border: 2px solid #e11d48;
  border-radius: 10px 4px 8px 8px;
}

body.theme-dragon .bed-blanket {
  background: linear-gradient(135deg, #ef4444, #f59e0b);
  border-color: #b45309;
}

.pet-wrapper.is-sleeping .pet-svg,
.pet-wrapper.is-sleeping .piglet-svg {
  animation: sleepSnuggle 3.4s ease-in-out infinite;
}

/* Speech Bubble */
.speech-bubble {
  position: relative;
  z-index: 6;
  background: #ffffff;
  border: 3px solid #ffd166;
  border-radius: 22px;
  padding: 12px 42px 12px 18px;
  max-width: 92%;
  margin-bottom: 8px;
  box-shadow: var(--shadow-soft);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  animation: popIn 0.25s ease;
}

.speech-bubble[hidden] {
  display: none;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 12px 10px 0;
  border-style: solid;
  border-color: #ffffff transparent transparent;
}

.speech-bubble p {
  margin: 0;
}

.replay-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: #fef3c7;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Pet SVG & Evolution Visibility */
.pet-wrapper {
  position: relative;
  z-index: 3;
  cursor: pointer;
  outline: none;
  margin-bottom: 6px;
  transition: transform 2.4s cubic-bezier(0.45, 0.05, 0.55, 0.95), opacity 0.3s ease;
  will-change: transform, opacity;
}

.pet-wrapper.is-hidden-pet {
  opacity: 0;
  pointer-events: none;
}

.pet-flip {
  transition: transform 0.25s ease;
}

.pet-flip.facing-right {
  transform: scaleX(-1);
}

.piglet-svg,
.pet-svg,
.visitor-svg {
  width: 210px;
  height: 210px;
  overflow: visible;
  animation: breathe 3s ease-in-out infinite;
}

/* Visitor Friend / Family Overlay */
.visitor-wrapper {
  position: absolute;
  bottom: 22px;
  left: 50%;
  margin-left: -105px;
  width: 210px;
  height: 210px;
  z-index: 3;
  cursor: pointer;
  outline: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transform: translate(260px, 0px);
  opacity: 0;
  transition: transform 1.6s cubic-bezier(0.4, 0.05, 0.45, 0.95), opacity 0.35s ease;
  will-change: transform, opacity;
}

.visitor-wrapper[hidden] {
  display: none;
}

.visitor-wrapper.is-present {
  opacity: 1;
}

.visitor-svg {
  width: 210px;
  height: 210px;
}

.visitor-flip {
  transition: transform 0.25s ease;
}

.visitor-flip.facing-right {
  transform: scaleX(-1);
}

.visitor-tag {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #ffd166;
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

body.theme-piglet .visitor-theme-dragon { display: none; }
body.theme-dragon .visitor-theme-piglet { display: none; }

.visitor-variant { display: none; }
.visitor-svg.role-friend .visitor-variant.role-friend { display: block; }
.visitor-svg.role-brother .visitor-variant.role-brother { display: block; }
.visitor-svg.role-mom .visitor-variant.role-mom { display: block; }
.visitor-svg.role-dad .visitor-variant.role-dad { display: block; }

/* Character theme toggle */
body.theme-piglet .dragon-svg { display: none; }
body.theme-dragon .piglet-svg { display: none; }

.pig-tail {
  transform-origin: 188px 165px;
  animation: tailWag 2.8s ease-in-out infinite;
}

.pig-head {
  transform-origin: 128px 128px;
  transition: transform 0.35s ease;
}

.eye-pupil {
  transition: transform 0.25s ease;
}

.pig-legs {
  transform-origin: 130px 214px;
}

.pet-svg.anim-look-up .pig-head,
.piglet-svg.anim-look-up .pig-head {
  transform: rotate(9deg) translateY(-3px);
}

.pet-svg.anim-look-up .eye-pupil,
.piglet-svg.anim-look-up .eye-pupil {
  transform: translate(-1.5px, -3.5px);
}

.pet-svg.anim-look-feet .pig-head,
.piglet-svg.anim-look-feet .pig-head {
  transform: rotate(-14deg) translateY(5px);
}

.pet-svg.anim-look-feet .eye-pupil,
.piglet-svg.anim-look-feet .eye-pupil {
  transform: translate(-2px, 3px);
}

.pet-svg.anim-look-feet .pig-legs,
.piglet-svg.anim-look-feet .pig-legs {
  animation: footTap 0.45s ease-in-out 3;
}

.pet-svg.anim-admire .arm-left,
.pet-svg.anim-admire .arm-right,
.piglet-svg.anim-admire .arm-left,
.piglet-svg.anim-admire .arm-right {
  animation: armSwing 0.35s ease-in-out 4 alternate;
}

.pet-svg.anim-admire .pig-head,
.piglet-svg.anim-admire .pig-head {
  transform: rotate(-6deg);
}

.eyes-open {
  transform-origin: 126px 82px;
  animation: eyeBlink 4.6s infinite;
}

/* Front-facing Rosie: her own pivots for tail, head turn and blink. */
.piglet-svg .pig-tail { transform-origin: 174px 192px; }
.piglet-svg .pig-head { transform-origin: 130px 138px; }
.piglet-svg .eyes-open { transform-origin: 130px 84px; }
.visitor-theme-piglet .pig-tail { transform-origin: 174px 192px; }
.visitor-theme-piglet .pig-head { transform-origin: 130px 138px; }
.visitor-theme-piglet .eyes-open { transform-origin: 130px 84px; }

.piglet-svg.is-walking,
.dragon-svg.is-walking,
.visitor-svg.is-walking {
  animation: walkWaddle 0.34s ease-in-out infinite;
}

.piglet-svg.is-walking .arm-left,
.piglet-svg.is-walking .arm-right,
.dragon-svg.is-walking .arm-left,
.dragon-svg.is-walking .arm-right,
.visitor-svg.is-walking .arm-left,
.visitor-svg.is-walking .arm-right {
  animation: armSwing 0.34s ease-in-out infinite alternate;
}

/* Evolution visibility rules */
.evo-boots, .evo-scarf, .evo-crown,
.evo-belt, .evo-pads, .evo-wings {
  display: none;
}

.piglet-svg.stage-2 .evo-shoes,
.piglet-svg.stage-3 .evo-shoes,
.piglet-svg.stage-4 .evo-shoes {
  display: none;
}

.piglet-svg.stage-2 .evo-boots,
.piglet-svg.stage-3 .evo-boots,
.piglet-svg.stage-4 .evo-boots,
.dragon-svg.stage-2 .evo-belt,
.dragon-svg.stage-3 .evo-belt,
.dragon-svg.stage-4 .evo-belt,
.dragon-svg.stage-2 .evo-pads,
.dragon-svg.stage-3 .evo-pads,
.dragon-svg.stage-4 .evo-pads {
  display: block;
}

.piglet-svg.stage-3 .evo-scarf,
.piglet-svg.stage-4 .evo-scarf,
.dragon-svg.stage-3 .evo-wings,
.dragon-svg.stage-4 .evo-wings {
  display: block;
}

.piglet-svg.stage-4 .evo-crown,
.dragon-svg.stage-4 .evo-crown {
  display: block;
}

/* Mood & Mud states */
.eyes-closed, .mouth-open, .mud-spots {
  display: none;
}

.piglet-svg.is-muddy .mud-spots,
.dragon-svg.is-muddy .mud-spots {
  display: block;
}

.piglet-svg.mood-sleepy .eyes-open,
.dragon-svg.mood-sleepy .eyes-open {
  display: none;
}
.piglet-svg.mood-sleepy .eyes-closed,
.dragon-svg.mood-sleepy .eyes-closed {
  display: block;
}

.piglet-svg.is-talking .mouth-smile,
.dragon-svg.is-talking .mouth-smile,
.visitor-svg.is-talking .mouth-smile {
  display: none;
}

.mouth-open {
  transform-box: fill-box;
  transform-origin: center;
}

.piglet-svg.is-talking .mouth-open,
.dragon-svg.is-talking .mouth-open,
.visitor-svg.is-talking .mouth-open {
  display: block;
  animation: talkMouth 0.24s infinite alternate;
}

.piglet-svg.anim-jump,
.dragon-svg.anim-jump,
.visitor-svg.anim-jump {
  animation: puddleJump 0.7s ease-in-out 2;
}

.piglet-svg.anim-bounce,
.dragon-svg.anim-bounce,
.visitor-svg.anim-bounce {
  animation: happyBounce 0.5s ease-in-out 2;
}

.dragon-svg.anim-spin,
.piglet-svg.anim-spin {
  animation: whirlMove 0.6s ease-in-out 2;
}

/* Particles */
.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.particle {
  position: absolute;
  font-size: 1.6rem;
  animation: floatUp 1.4s ease-out forwards;
}

/* Stats Panel */
.stats-panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.xp-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.xp-label {
  font-weight: 800;
  font-size: 0.9rem;
  color: #7c3aed;
  white-space: nowrap;
}

.xp-bar-track {
  flex: 1;
  height: 12px;
  background: #ede9fe;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.xp-bar-fill {
  width: 10%; /* main.js sets the real value */
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
}

.xp-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

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

.need-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.need-item.is-low .need-icon {
  animation: pulseMic 1s infinite ease-in-out;
}

.need-item.is-low .need-name {
  color: #e11d48;
}

.need-icon {
  font-size: 1.25rem;
}

.need-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
}

.need-track {
  width: 100%;
  height: 9px;
  background: #e5e7eb;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.need-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.need-fill.hunger { background: #fb7185; }
.need-fill.water { background: #0ea5e9; }
.need-fill.happy { background: #fbbf24; }
.need-fill.energy { background: #818cf8; }
.need-fill.clean { background: #22d3ee; }

/* Controls Panel */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.game-pill {
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-pill);
  padding: 8px 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, background 0.2s ease;
}

.game-pill:active {
  transform: scale(0.95);
}

.game-pill.active {
  background: #fde047;
  border-color: #eab308;
}

/* In-Scene Mini-Games Layer */
.game-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.game-layer[hidden] {
  display: none;
}

.game-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.game-score {
  background: rgba(255, 255, 255, 0.95);
  color: #b45309;
  font-weight: 800;
  font-size: 1rem;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
}

.game-stop-btn {
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.game-targets {
  position: absolute;
  inset: 0;
}

.game-target {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(2px);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  font-size: 2.3rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  transition: transform 0.12s ease;
}

.game-target:active {
  transform: scale(1.22);
}

.hide-bush {
  position: absolute;
  bottom: 24px;
  border: none;
  background: transparent;
  font-size: 4.4rem;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.22));
  transition: transform 0.2s ease;
}

.hide-bush:hover {
  transform: scale(1.08);
}

.hide-bush.shake {
  animation: walkWaddle 0.25s ease-in-out 2;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.25fr 1fr 1fr;
  align-items: center;
  gap: 8px;
}

.action-btn {
  border: none;
  border-radius: 20px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  color: #fff;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.action-btn .btn-emoji {
  font-size: 1.6rem;
}

.action-btn .btn-label {
  font-size: 0.82rem;
}

.btn-feed { background: #fb7185; box-shadow: 0 5px 0 #e11d48; }
.btn-water { background: #0ea5e9; box-shadow: 0 5px 0 #0369a1; }
.btn-puddle { background: #a16207; box-shadow: 0 5px 0 #713f12; }
.btn-wash { background: #06b6d4; box-shadow: 0 5px 0 #0e7490; }
.btn-sleep { background: #818cf8; box-shadow: 0 5px 0 #4f46e5; }

.action-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* Big Center Mic Button */
.mic-btn {
  position: relative;
  border: none;
  border-radius: 50%;
  width: 92px;
  height: 92px;
  margin: 0 auto;
  background: linear-gradient(145deg, #ff5c8a, #f43f5e);
  color: #fff;
  box-shadow: 0 7px 0 #be123c, 0 12px 24px rgba(244, 63, 94, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  transition: transform 0.12s ease;
}

.mic-btn:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #be123c;
}

.mic-icon {
  font-size: 2rem;
}

.mic-label {
  font-size: 0.8rem;
}

.mic-btn.listening {
  background: linear-gradient(145deg, #10b981, #059669);
  box-shadow: 0 7px 0 #047857, 0 0 28px rgba(16, 185, 129, 0.6);
  animation: pulseMic 1.1s infinite ease-in-out;
}

/* Fallback Text Input */
.text-fallback {
  display: flex;
  gap: 8px;
}

.text-fallback input {
  flex: 1;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.text-fallback input:focus {
  border-color: var(--pink-accent);
}

.text-fallback button {
  border: none;
  background: var(--pink-accent);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

/* Dialogs */
.storybook-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 460px;
  width: calc(100% - 28px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  font-family: inherit;
}

.storybook-dialog::backdrop {
  background: rgba(30, 27, 75, 0.55);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #fff1f2;
  border-bottom: 2px solid #ffe4e6;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--pink-accent);
}

.close-dialog {
  border: none;
  background: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 800;
  cursor: pointer;
}

.dialog-body {
  padding: 18px 20px;
  max-height: 70dvh;
  overflow-y: auto;
}

.sticker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.sticker-chip {
  background: #fef3c7;
  color: #92400e;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.88rem;
}

.memory-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-list li {
  font-size: 0.95rem;
  line-height: 1.4;
}

.parent-gate {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-question {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--pink-accent);
}

.gate-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.gate-row input {
  width: 90px;
  padding: 8px 12px;
  font-size: 1.1rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  text-align: center;
}

.gate-error {
  color: #e11d48;
  font-weight: 700;
  margin: 0;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 700;
  font-size: 0.9rem;
}

.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  resize: vertical;
}

.pref-chip {
  background: #e0f2fe;
  color: #0369a1;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.86rem;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.field-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--pink-accent);
}

.field small {
  color: var(--text-muted);
  font-weight: 600;
}

.settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.primary-btn {
  border: none;
  background: var(--pink-accent);
  color: #fff;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
}

.account-password {
  flex: 1 1 160px;
  padding: 8px 12px;
  border: 2px solid #fecaca;
  border-radius: var(--radius-pill);
  font-family: inherit;
}

.danger-btn {
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
}

.secondary-btn {
  border: none;
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
}

.account-status-box {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-line {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

.account-actions,
.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.controls-panel[hidden],
.time-limit-banner[hidden] {
  display: none;
}

.time-limit-banner {
  background: var(--card-bg);
  border: 3px solid #818cf8;
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.time-limit-emoji {
  font-size: 2.2rem;
}

.time-limit-banner h2 {
  margin: 0;
  color: #4f46e5;
  font-size: 1.3rem;
}

.time-limit-banner p {
  margin: 0;
  font-weight: 700;
  color: var(--text-main);
}

.timer-settings-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.timer-settings-row input {
  width: 110px;
}

.auth-warning {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  color: #92400e;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  color: #64748b;
}

.auth-tab.active {
  background: #ffffff;
  color: var(--pink-accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Keyframes */
@keyframes breathe {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-4px) scaleY(1.02); }
}

@keyframes puddleJump {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-46px) rotate(-4deg); }
  65% { transform: translateY(4px) scaleY(0.92); }
}

@keyframes happyBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-22px); }
}

@keyframes talkMouth {
  from { transform: scaleY(0.7); }
  to { transform: scaleY(1.25); }
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  100% { opacity: 0; transform: translateY(-90px) scale(1.3); }
}

@keyframes drift {
  from { transform: translateX(-20px); }
  to { transform: translateX(40px); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.2); }
}

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

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes walkWaddle {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}

@keyframes armSwing {
  from { transform: rotate(-6deg); }
  to { transform: rotate(6deg); }
}

@keyframes tailWag {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(10deg); }
  75% { transform: rotate(-8deg); }
}

@keyframes eyeBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

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

@keyframes ballBounce {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-58px) rotate(120deg); }
}

@keyframes butterflyFloat {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  25% { transform: translate(85px, -28px) rotate(8deg); }
  50% { transform: translate(155px, 12px) rotate(-8deg); }
  75% { transform: translate(60px, 24px) rotate(6deg); }
}

@keyframes whirlMove {
  0% { transform: translateY(0) scaleX(1); }
  50% { transform: translateY(-28px) scaleX(-1); }
  100% { transform: translateY(0) scaleX(1); }
}

@keyframes sleepSnuggle {
  0%, 100% { transform: translateY(8px) rotate(6deg) scale(0.88); }
  50% { transform: translateY(5px) rotate(8deg) scale(0.89); }
}

@keyframes footTap {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px) rotate(-3deg); }
}

@keyframes scrollTrack {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@keyframes carBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes carMudBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(-16px) rotate(-3deg); }
  70% { transform: translateY(4px) rotate(2deg); }
}

@keyframes wheelSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes carMudPass {
  0% { left: 115%; opacity: 0.98; }
  50% { left: 50%; opacity: 1; }
  88% { left: -25%; opacity: 0.95; }
  100% { left: -35%; opacity: 0; }
}

@keyframes teddyFloat {
  0%, 100% { transform: translate(-50%, 0px); }
  50% { transform: translate(-50%, -6px); }
}

@media (max-width: 600px) {
  .piglet-svg,
  .pet-svg { width: 172px; height: 172px; }
  .visitor-svg { width: 172px; height: 172px; }
  .family-car-svg { width: 268px; height: 150px; }
  .action-buttons {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .mic-btn {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 82px;
    height: 82px;
    margin-bottom: 4px;
  }
  .mic-icon { font-size: 1.7rem; }
  .action-btn { padding: 10px 4px; }
  .action-btn .btn-label { font-size: 0.74rem; }
}

/* A visitor noticed a need: the button that helps pulses gently until it's used. */
.hint-glow {
  animation: hintPulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(255, 214, 102, 0.85), 0 0 18px rgba(255, 183, 3, 0.75);
}

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

/* ===== Seasons & special days (body.season-* / body.occasion-*, see src/seasons.js) ===== */
.season-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
body:not(.room-outdoor) .season-decor {
  display: none;
}
.decor {
  display: none;
  position: absolute;
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.15));
}
.decor-fall {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
}

/* Which decorations show when */
body.season-winter .d-snowman,
body:is(.occasion-advent, .occasion-stNicholas, .occasion-christmas) :is(.d-tree, .d-santa),
body.occasion-christmas .d-gifts,
body.occasion-stNicholas :is(.d-boot, .d-sweets),
body.occasion-newYear .d-firework,
body.occasion-threeKings .d-star,
body.occasion-carnival :is(.d-balloon, .d-streamer),
body.occasion-easter :is(.d-egg, .d-bunny),
body.occasion-halloween .d-pumpkin,
body.occasion-stMartin .d-lanterns,
body.season-spring:not(.occasion-easter) .d-flower,
body.season-summer:not([class*="occasion-"]) .d-parasol,
body.season-autumn:not([class*="occasion-"]) .d-leaf,
body:is(.season-winter, .occasion-newYear, .occasion-carnival) .decor-fall {
  display: block;
}
/* The snowman makes room for the bunny, pumpkins and parasol on the left */
body:is(.occasion-easter, .occasion-halloween) .d-snowman {
  display: none;
}

.d-snowman { left: 3%; bottom: 30px; font-size: 3rem; }
.d-tree { right: 104px; bottom: 24px; font-size: 3.8rem; }
.d-gifts { right: 98px; bottom: 16px; font-size: 1.7rem; z-index: 1; }
.d-santa { right: 38px; bottom: 86px; font-size: 2rem; } /* peeking over the roof */
.d-boot { right: 64px; bottom: 16px; font-size: 1.5rem; z-index: 3; }
.d-sweets { right: 60px; bottom: 34px; font-size: 1rem; z-index: 3; }
.d-firework { top: 14%; font-size: 2.6rem; animation: decorTwinkle 1.8s ease-in-out infinite; }
.d-firework.f1 { left: 18%; }
.d-firework.f2 { right: 22%; top: 24%; animation-delay: 0.9s; }
.d-star { top: 6%; left: 58%; font-size: 3rem; filter: drop-shadow(0 0 14px rgba(255, 214, 0, 0.9)); animation: decorTwinkle 2.6s ease-in-out infinite; }
.d-balloon { left: 24%; bottom: 70px; font-size: 2.6rem; animation: decorBob 3s ease-in-out infinite; }
.d-streamer { right: 108px; bottom: 30px; font-size: 2.4rem; }
.d-bunny { left: 4%; bottom: 30px; font-size: 2.4rem; }
.d-pumpkin.p1 { left: 4%; bottom: 28px; font-size: 2.6rem; }
.d-pumpkin.p2 { right: 106px; bottom: 22px; font-size: 2rem; }
.d-flower { font-size: 1.6rem; }
.d-flower.t1 { left: 4%; bottom: 30px; }
.d-flower.t2 { left: 26%; bottom: 14px; }
.d-flower.t3 { right: 108px; bottom: 24px; }
.d-parasol { left: 3%; bottom: 30px; font-size: 3rem; }

/* Colored Easter eggs hidden in the grass */
.d-egg {
  width: 16px;
  height: 21px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  border: 2px solid rgba(0, 0, 0, 0.12);
}
.d-egg.e1 { left: 24%; bottom: 16px; background: repeating-linear-gradient(0deg, #f9a8d4 0 5px, #fff 5px 8px); }
.d-egg.e2 { right: 34%; bottom: 12px; background: radial-gradient(circle, #fff 0 2px, transparent 2.5px) 0 0 / 7px 7px, #93c5fd; }
.d-egg.e3 { right: 110px; bottom: 20px; background: repeating-linear-gradient(90deg, #fde047 0 4px, #a7f3d0 4px 8px); }

/* St Martin: a string of glowing paper lanterns */
.d-lanterns {
  top: 20%;
  left: 6%;
  width: 42%;
  height: 34px;
  border-bottom: 2px solid #8d6e63;
  border-radius: 0 0 50% 50% / 0 0 34px 34px;
}
.d-lanterns i {
  position: absolute;
  top: 28px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff7c2, #fb923c 70%);
  box-shadow: 0 0 16px 6px rgba(253, 186, 116, 0.75);
  animation: decorTwinkle 2.4s ease-in-out infinite;
}
.d-lanterns i:nth-child(1) { left: 14%; background: radial-gradient(circle at 40% 35%, #fff7c2, #f87171 70%); }
.d-lanterns i:nth-child(2) { left: 46%; top: 34px; animation-delay: 0.8s; }
.d-lanterns i:nth-child(3) { left: 78%; background: radial-gradient(circle at 40% 35%, #fff7c2, #facc15 70%); animation-delay: 1.6s; }

/* Autumn leaves drifting down */
.d-leaf { top: -40px; font-size: 1.6rem; animation: decorLeaf 9s linear infinite; }
.d-leaf.l1 { left: 14%; }
.d-leaf.l2 { left: 52%; animation-delay: 3s; }
.d-leaf.l3 { left: 82%; animation-delay: 6s; }

/* Falling snow (winter) or confetti (New Year, carnival): tiled dots scrolled down */
body.season-winter .decor-fall {
  background-image: radial-gradient(circle, #fff 0 2.6px, transparent 3.2px), radial-gradient(circle, rgba(255, 255, 255, 0.8) 0 1.8px, transparent 2.4px);
  background-size: 90px 90px, 55px 55px;
  background-position: 0 0, 25px 35px;
  animation: decorFall 9s linear infinite;
}
body:is(.occasion-newYear, .occasion-carnival) .decor-fall {
  background-image: radial-gradient(circle, #f472b6 0 3px, transparent 3.5px), radial-gradient(circle, #fde047 0 2.5px, transparent 3px),
    radial-gradient(circle, #60a5fa 0 2.5px, transparent 3px);
  background-size: 130px 130px, 97px 97px, 160px 160px;
  background-position: 0 0, 25px 35px, 40px 10px;
  animation: decorConfetti 8s linear infinite;
}

/* Winter: snowy hills (dimmer after dark) */
body.season-winter .hill-back { background: #e3eefa; }
body.season-winter .hill-front { background: #f6faff; }
body.season-winter:is(.time-evening, .time-night) .hill { filter: brightness(0.62); }

/* Summer: a warmer sun */
body.season-summer:not(.time-night) .sky-celestial { box-shadow: 0 0 60px 26px rgba(255, 200, 0, 0.55); }

/* Christmas lights along the house roof (Advent to Christmas) */
.house-lights {
  display: none;
  position: absolute;
  top: 26px;
  left: 4px;
  width: 76px;
  height: 10px;
  z-index: 1;
  background:
    radial-gradient(circle, #ff4d6d 0 3.2px, transparent 3.8px) 0 0 / 21px 10px,
    radial-gradient(circle, #ffd166 0 3.2px, transparent 3.8px) 7px 0 / 21px 10px,
    radial-gradient(circle, #4cc9f0 0 3.2px, transparent 3.8px) 14px 0 / 21px 10px;
  animation: decorTwinkle 1.6s ease-in-out infinite;
}
body:is(.occasion-advent, .occasion-stNicholas, .occasion-christmas) .house-lights {
  display: block;
}

/* Pet hats: one at a time; the stage-4 crown steps aside while a hat is on */
.season-hats > g,
.season-lantern {
  display: none;
}
body:is(.occasion-advent, .occasion-stNicholas, .occasion-christmas) .hat-santa,
body:is(.occasion-newYear, .occasion-carnival) .hat-party,
body.occasion-threeKings .hat-crown,
body.occasion-easter .hat-bunny,
body.occasion-halloween .hat-witch,
body.occasion-stMartin .season-lantern,
body.season-winter:not([class*="occasion-"]) .hat-wool,
body.season-summer:not([class*="occasion-"]) .hat-sun {
  display: inline;
}
body:is(.occasion-advent, .occasion-stNicholas, .occasion-christmas, .occasion-newYear, .occasion-carnival, .occasion-threeKings, .occasion-easter, .occasion-halloween) svg.stage-4 .evo-crown,
body:is(.season-winter, .season-summer):not([class*="occasion-"]) svg.stage-4 .evo-crown {
  display: none;
}

@keyframes decorFall {
  to { background-position: 90px 360px, 80px 420px; }
}
@keyframes decorConfetti {
  to { background-position: 130px 390px, 122px 423px, 200px 330px; }
}
@keyframes decorTwinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.92); }
}
@keyframes decorBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes decorLeaf {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translate(30px, 200px) rotate(160deg); }
  100% { transform: translate(-10px, 420px) rotate(340deg); opacity: 0.9; }
}
@media (prefers-reduced-motion: reduce) {
  .decor-fall, .decor, .house-lights, .d-lanterns i {
    animation: none !important;
  }
}

/* "Tap to update": shown when the server has a newer version than this open tab */
.update-btn {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1000;
  border: none;
  background: var(--pink-accent);
  color: #fff;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 14px 26px;
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  animation: update-pulse 2s ease-in-out infinite;
}

.update-btn[hidden] {
  display: none;
}

@keyframes update-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .update-btn { animation: none; }
}

/* Privacy note link (sign-up and parent settings) */
.privacy-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Phones: the top bar wraps instead of pushing the memory book, sound and settings off-screen
   (the page hides sideways overflow, so they were unreachable). Row 1: pet name; row 2: controls. */
@media (max-width: 600px) {
  .top-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  }
  .pet-badge { min-width: 0; max-width: 100%; }
  .pet-name-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-controls {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px;
  }
  .icon-btn { width: 44px; height: 44px; }
  .lang-btn { padding: 8px 9px; }
  .theme-btn { padding: 6px 9px; }
}

/* Sign-in: "Forgot password?" and info line */
.link-btn { background: none; border: 0; padding: 10px 2px; font: inherit; font-weight: 700; color: var(--pink-accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 44px; }
.auth-info { background: #ecfdf5; color: #047857; border-radius: 12px; padding: 10px 12px; margin: 0; font-weight: 600; }

/* Until the parent confirms their email: a small banner at the bottom, above everything */
.verify-banner { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  width: min(560px, calc(100% - 24px)); display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #fff7ed; color: #9a3412; border: 2px solid #fdba74; border-radius: 18px; padding: 8px 14px; font-weight: 700; font-size: .95rem;
  box-shadow: var(--shadow-soft); }
.verify-banner .link-btn { color: #c2410c; padding: 6px 2px; min-height: 40px; }
