/* Munchling v1 - cute, warm, playful. Pastel, rounded, soft. */
:root {
  --cream: #fff8f0;
  --peach: #ffe3d3;
  --peach-deep: #ffb98a;
  --coral: #ff8a65;
  --mint: #d9f2e3;
  --mint-deep: #7bc8a4;
  --lavender: #e9e2f7;
  --sky: #d6ecff;
  --sunny: #ffe9a8;
  --ink: #4a3f35;
  --ink-soft: #8a7d70;
  --card: #ffffff;
  --surface: #ffffff;
  --line: #f0e4d8;
  --track: #f3e7db;
  --frame: #ffffff;
  --header-bg: rgba(255, 248, 240, .92);
  --toast-bg: #4a3f35;
  --toast-fg: #fff8f0;
  --accent-text: #c85a2e;
  --gold: #f2b705;
  --gold-deep: #b8860b;
  --shadow: 0 6px 24px rgba(180, 130, 90, .12);
  --radius: 22px;
  --radius-sm: 14px;
}

/* Dark theme - same cozy feel, deep plum night background, soft pastel accents. */
[data-theme="dark"] {
  --cream: #221d2b;
  --peach: #3d2f45;
  --peach-deep: #ff9d6b;
  --coral: #ff8a65;
  --mint: #26443a;
  --mint-deep: #6fbf97;
  --lavender: #37314d;
  --sky: #2b3d55;
  --sunny: #57482a;
  --ink: #f6efe6;
  --ink-soft: #b3a593;
  --card: #2f2839;
  --surface: #3a3145;
  --line: #463a55;
  --track: #453a55;
  --frame: #453a55;
  --header-bg: rgba(34, 29, 43, .92);
  --toast-bg: #f6efe6;
  --toast-fg: #221d2b;
  --accent-text: #ffb98a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Nunito", "Avenir Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
p { margin: 0 0 10px; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 16px; }

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

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-header .inner {
  max-width: 560px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.logo-mark {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; flex: none;
  border: 2px solid var(--frame); box-shadow: var(--shadow);
}
.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  font-size: 1.15rem; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.logo-name { font-size: 1.35rem; font-weight: 900; letter-spacing: .2px; }
.logo-name span { color: var(--coral); }
.header-spacer { flex: 1; }
.streak-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--sunny); border-radius: 999px; padding: 7px 13px;
  font-weight: 800; font-size: .92rem; white-space: nowrap;
}
.streak-pill .flame { font-size: 1rem; line-height: 1; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin: 16px 0;
}
.card h2 { font-size: 1.15rem; font-weight: 900; }
.card .sub { color: var(--ink-soft); font-size: .92rem; margin-bottom: 10px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.space { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---------- critter hero ---------- */
.critter-hero { text-align: center; padding: 22px 18px 18px; }
.critter-img {
  width: 210px; height: 210px; margin: 0 auto 6px;
  border-radius: 50%; object-fit: cover;
  border: 5px solid var(--frame); box-shadow: var(--shadow);
  background: var(--peach);
}
/* Worn accessory badge, overlaid on the critter image. */
.critter-wrap { position: relative; width: fit-content; margin: 0 auto; }
.critter-wrap .critter-img { margin-bottom: 6px; }
.worn-badge {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  background: var(--ink); color: var(--cream);
  border-radius: 999px; padding: 5px 13px;
  font-size: .85rem; font-weight: 800; white-space: nowrap;
  box-shadow: var(--shadow);
}
.coins-row {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  font-weight: 800; font-size: .95rem; margin-top: 10px;
}
.coin-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--mint); border-radius: 999px; padding: 5px 12px;
  font-weight: 800; font-size: .92rem; white-space: nowrap;
}
.wearing-line { color: var(--ink-soft); font-size: .88rem; font-weight: 700; }
.critter-name { font-size: 1.45rem; font-weight: 900; }
.critter-stage {
  display: inline-block; background: var(--lavender); border-radius: 999px;
  padding: 4px 12px; font-size: .85rem; font-weight: 800; margin: 4px 0 10px;
}
.xp-bar {
  height: 14px; background: var(--peach); border-radius: 999px; overflow: hidden;
  margin: 8px 0 4px;
}
.xp-fill {
  height: 100%; background: linear-gradient(90deg, var(--peach-deep), var(--coral));
  border-radius: 999px; transition: width .5s ease;
}
.xp-label { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.coach-quote {
  font-style: italic; color: var(--ink-soft);
  background: var(--cream); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: 12px;
}

/* ---------- stat chips ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat {
  background: var(--cream); border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center;
}
.stat .num { font-size: 1.25rem; font-weight: 900; }
.stat .lbl { font-size: .78rem; color: var(--ink-soft); font-weight: 700; }
.stat .bar { height: 7px; background: var(--track); border-radius: 99px; margin-top: 7px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--mint-deep); border-radius: 99px; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-block; border: none; border-radius: 999px;
  padding: 13px 22px; font-size: 1rem; font-weight: 800;
  background: var(--coral); color: #fff; text-decoration: none;
  box-shadow: 0 4px 14px rgba(255, 138, 101, .4);
  min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--mint); color: var(--ink); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; padding: 10px 14px; min-height: 40px; }
.btn.small { padding: 9px 16px; min-height: 40px; font-size: .92rem; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .5; }

.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 800; font-size: .9rem; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  min-height: 48px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--peach-deep); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 9px 15px; font-weight: 800; font-size: .92rem; min-height: 42px;
}
.chip.on { border-color: var(--coral); background: var(--peach); color: var(--accent-text); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: none; }
.list .grow { min-width: 0; }
.list .t { font-weight: 800; overflow-wrap: anywhere; }
.list .s { font-size: .85rem; color: var(--ink-soft); }
.list .cal { font-weight: 900; white-space: nowrap; }
.icon-btn {
  border: none; background: transparent; font-size: 1.1rem;
  padding: 6px 8px; min-width: 40px; min-height: 40px; color: var(--ink-soft);
}
.empty { color: var(--ink-soft); text-align: center; padding: 14px 6px; font-size: .95rem; }

/* ---------- habits ---------- */
.habit {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
}
.habit:last-child { border-bottom: none; }
.habit input[type="checkbox"] {
  width: 26px; height: 26px; accent-color: var(--mint-deep); flex: none; cursor: pointer;
}
.habit .t { font-weight: 800; }
.habit .s { font-size: .85rem; color: var(--ink-soft); }
.habit.done .t { text-decoration: line-through; color: var(--ink-soft); }

/* ---------- coach chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 18px; line-height: 1.45; }
.msg.coach { background: var(--lavender); border-bottom-left-radius: 6px; align-self: flex-start; }
.msg.user { background: var(--peach); border-bottom-right-radius: 6px; align-self: flex-end; }
.msg .who { display: block; font-size: .72rem; font-weight: 900; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 3px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; min-width: 0; padding: 12px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); }
.quick-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.quick {
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 8px 13px; font-size: .88rem; font-weight: 700; min-height: 38px;
}

/* ---------- critter collection (50) ---------- */
.critter-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.critter-card {
  background: var(--cream); border-radius: var(--radius);
  padding: 12px 8px; text-align: center; position: relative;
  display: flex; flex-direction: column;
}
.critter-card img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; margin: 0 auto 6px; border: 3px solid var(--frame); box-shadow: var(--shadow); }
.critter-card.locked img { filter: grayscale(1) opacity(.45); }
.critter-card .nm { font-weight: 900; font-size: .92rem; line-height: 1.2; }
.critter-card .vibe {
  display: inline-block; background: var(--lavender); border-radius: 999px;
  padding: 2px 8px; font-size: .68rem; font-weight: 800; margin: 3px auto 0;
}
.critter-card .trait { font-size: .72rem; color: var(--ink-soft); line-height: 1.3; margin: 4px 0 2px; min-height: 1.9em; }
.critter-card .st { font-size: .78rem; color: var(--ink-soft); font-weight: 700; margin-bottom: 6px; }
.critter-card .lock-note { font-size: .72rem; color: var(--ink-soft); margin-top: auto; line-height: 1.3; }
.critter-card .btn { width: 100%; padding: 8px 6px; min-height: 38px; font-size: .82rem; margin-top: auto; }
.critter-card.active { outline: 3px solid var(--coral); }
.critter-card.premium-card { outline: 2px solid var(--gold); }
.badge-active {
  position: absolute; top: 6px; right: 6px; background: var(--coral); color: #fff;
  font-size: .6rem; font-weight: 900; letter-spacing: .4px; text-transform: uppercase;
  border-radius: 999px; padding: 3px 7px; z-index: 1;
}
/* Stage growth for Munchlings with one art image: Teen grows a
 * little, Adult grows more and glows. (Honey has separate art.) */
.critter-img.stage-teen { transform: scale(1.05); }
.critter-img.stage-adult { transform: scale(1.1); filter: drop-shadow(0 0 14px rgba(242, 183, 5, .6)); }
.critter-card img.stage-teen { transform: scale(1.07); }
.critter-card img.stage-adult { transform: scale(1.12); box-shadow: 0 0 0 3px var(--sunny), var(--shadow); }

/* ---------- starter picker ---------- */
.starter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.starter-card {
  border: 2px solid var(--line); background: var(--cream); color: var(--ink);
  border-radius: var(--radius); padding: 12px 8px; text-align: center;
}
.starter-card:active { border-color: var(--coral); }
.starter-card img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; margin: 0 auto 6px; border: 3px solid var(--frame); }
.starter-card .nm { font-weight: 900; }
.starter-card .trait { font-size: .78rem; color: var(--ink-soft); line-height: 1.3; }

/* ---------- progress ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { width: 110px; height: 110px; flex: none; }
.ring .bg { stroke: var(--track); }
.ring .fg { stroke: var(--mint-deep); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring-text { font-size: 1.15rem; font-weight: 900; fill: var(--ink); }
.ring-sub { font-size: .62rem; font-weight: 800; fill: var(--ink-soft); }

/* ---------- toast + modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); color: var(--toast-fg); border-radius: 999px; padding: 11px 18px;
  font-weight: 800; font-size: .95rem; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 60; white-space: nowrap;
  max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(74, 63, 53, .5);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 26px; padding: 26px 22px; text-align: center;
  max-width: 360px; width: 100%; box-shadow: var(--shadow);
}
.modal img { width: 170px; height: 170px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; border: 4px solid var(--sunny); }
.modal h2 { font-size: 1.4rem; }
.modal p { color: var(--ink-soft); }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav .inner {
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(7, 1fr);
}
.nav-btn {
  border: none; background: transparent; padding: 9px 1px 8px;
  font-size: .62rem; font-weight: 800; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 0;
}
.nav-btn .ic { font-size: 1.25rem; line-height: 1; }
.nav-btn span.lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nav-btn.on { color: var(--coral); }

/* ---------- tabs ---------- */
.tab { display: none; }
.tab.on { display: block; }
.tab h1 { font-size: 1.5rem; font-weight: 900; margin: 18px 0 2px; }
.tab .lead { color: var(--ink-soft); margin-bottom: 4px; }

/* ---------- landing ---------- */
.landing-hero { text-align: center; padding: 34px 0 10px; }
.landing-hero .critter-img { width: 190px; height: 190px; }
.landing-hero h1 { font-size: 2.4rem; font-weight: 900; margin: 10px 0 4px; }
.landing-hero h1 span { color: var(--coral); }
.landing-hero p { font-size: 1.08rem; color: var(--ink-soft); max-width: 420px; margin: 0 auto 18px; }
.feature-list { display: grid; gap: 10px; margin: 18px 0; }
.feature {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  text-align: left;
}
.feature .f-ic { font-size: 1.5rem; line-height: 1.2; flex: none; }
.feature .t { font-weight: 900; }
.feature .s { font-size: .9rem; color: var(--ink-soft); }
.critter-strip { display: flex; gap: 12px; justify-content: center; margin: 8px 0 4px; flex-wrap: wrap; }
.critter-strip img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; border: 3px solid var(--frame); box-shadow: var(--shadow); }

/* ---------- accessories shop ---------- */
.shop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shop-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 10px 14px; text-align: center; position: relative;
  box-shadow: var(--shadow);
}
.shop-card .acc-ic { font-size: 2.3rem; line-height: 1.2; }
.shop-card .nm { font-weight: 900; margin-top: 4px; }
.shop-card .blurb { font-size: .82rem; color: var(--ink-soft); margin: 2px 0 10px; min-height: 2.4em; }
.shop-card .pr { font-weight: 800; font-size: .9rem; margin-bottom: 10px; }
.shop-card .btn { width: 100%; }
.shop-card.worn { outline: 3px solid var(--coral); }
.shop-card.owned { outline: 2px solid var(--mint-deep); }
.premium-badge {
  position: absolute; top: 8px; right: 8px;
  background: linear-gradient(135deg, #ffe066, var(--gold));
  color: #5a3d00; font-size: .64rem; font-weight: 900; letter-spacing: .5px; text-transform: uppercase;
  border-radius: 999px; padding: 3px 8px;
}
.premium-note { font-size: .85rem; color: var(--ink-soft); }
.modal .premium-ic { font-size: 2.6rem; line-height: 1.2; }

/* ---------- settings rows ---------- */
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; }
.set-row .t { font-weight: 800; }
.set-row .s { font-size: .85rem; color: var(--ink-soft); }

@media (max-width: 380px) {
  .critter-img { width: 180px; height: 180px; }
  .stat-grid { gap: 8px; }
  .btn { padding: 12px 18px; }
  /* The header is crowded at 360px (logo + name + two round buttons
   * + streak pill). Tighten it so its min-content fits the viewport -
   * otherwise mobile Chrome expands the layout viewport and the fixed
   * bottom nav ends up below the visible area. */
  .app-header .inner { gap: 6px; padding: 10px 12px; }
  .logo-mark { width: 34px; height: 34px; }
  .logo-name { font-size: 1.15rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .theme-toggle { width: 36px; height: 36px; font-size: 1rem; }
  .streak-pill { padding: 5px 9px; font-size: .85rem; }
}

/* ---------- Munchling's home (room scene) ----------
 * The room is ONE cohesive 3D image (the home scene) - furniture and
 * toys are small transparent images placed on the floor with a soft
 * drop shadow, at fixed spots, so nothing looks pasted on. */
.room-card { padding: 0; overflow: hidden; }
.room-scene {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--peach);
}
.room-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.room-items { position: absolute; inset: 0; pointer-events: none; }
.room-item { position: absolute; display: block; }
.room-item img { width: 100%; display: block; filter: drop-shadow(0 5px 5px rgba(60, 35, 20, .35)); }
.room-item.toy img { filter: drop-shadow(0 4px 4px rgba(60, 35, 20, .35)); }
/* The rug lies flat on the floor: squash it vertically. */
.room-item.squash img { transform: scaleY(.55); transform-origin: bottom center; filter: drop-shadow(0 3px 3px rgba(60, 35, 20, .25)); }
.room-critter {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  text-align: center; width: 30%; z-index: 2;
}
.room-critter-img {
  width: 100%; aspect-ratio: 1; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--frame); box-shadow: var(--shadow);
  background: var(--peach);
  filter: drop-shadow(0 6px 8px rgba(60, 35, 20, .3));
}
.room-critter-img.stage-teen { transform: scale(1.06); }
.room-critter-img.stage-adult { transform: scale(1.12); filter: drop-shadow(0 0 14px rgba(242, 183, 5, .7)); }
.room-critter-name {
  font-weight: 900; font-size: 1rem; color: #fff;
  text-shadow: 0 1px 6px rgba(60, 35, 20, .7);
  margin-top: -6px; position: relative;
}
.room-info { padding: 16px 18px 18px; text-align: center; }
.room-info .xp-bar { margin-top: 10px; }
.room-home-name {
  display: inline-block; background: var(--mint); border-radius: 999px;
  padding: 4px 12px; font-size: .85rem; font-weight: 800; margin: 4px 0 0;
}
.worn-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.worn-chip {
  display: inline-block; background: var(--lavender); border-radius: 999px;
  padding: 4px 11px; font-size: .82rem; font-weight: 800; white-space: nowrap;
}
.placed-list { display: flex; gap: 8px; flex-wrap: wrap; }
.placed-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cream); border-radius: 999px; padding: 6px 8px 6px 12px;
  font-size: .85rem; font-weight: 800;
}
.mini-x {
  border: none; background: var(--peach); color: var(--ink);
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 1rem; line-height: 1; padding: 0; font-weight: 900;
}

/* ---------- shop: item photos + slots ---------- */
.shop-card .acc-img {
  width: 100%; height: 92px; object-fit: contain;
  background: #fff; border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.shop-card .home-img {
  width: 100%; height: 128px; object-fit: cover;
  border-radius: var(--radius-sm); margin-bottom: 6px;
}
.shop-card.wide { grid-column: 1 / -1; }
.shop-card .slot-tag {
  display: inline-block; background: var(--mint); border-radius: 999px;
  padding: 2px 9px; font-size: .7rem; font-weight: 800; margin: 2px 0 4px;
}
.shop-card .blurb { min-height: 2.4em; }

/* ---------- critter life: movement + sounds ----------
 * Munchlings bob gently while idle, bounce when happy, wiggle when
 * tapped, and celebrate big when they evolve or a new friend joins.
 * Motion is CSS-only. The idle loop lives on the room wrapper (not
 * the image) so it never fights the stage scale on the image itself.
 * Sounds are Web Audio in app.js - no audio files. */
.room-critter { animation: munch-bob 3.4s ease-in-out infinite; cursor: pointer; }
@keyframes munch-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}
/* Sleepy: late at night, or a Munchling with history that hasn't
 * heard from you yet today. Slow breathing, plus a "Z z z" bubble. */
.room-critter.sleepy { animation: munch-sleepy 5.5s ease-in-out infinite; }
@keyframes munch-sleepy {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-2px); }
}
.zzz-bubble {
  display: none; position: absolute; top: -10px; right: -4px;
  font-weight: 900; font-size: .8rem; color: var(--ink);
  background: var(--surface); border-radius: 999px; padding: 2px 9px;
  box-shadow: var(--shadow);
}
.room-critter.sleepy .zzz-bubble { display: block; animation: munch-zzz 3s ease-in-out infinite; }
@keyframes munch-zzz {
  0%, 100% { opacity: .6; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}
.tap-hint {
  font-size: .72rem; font-weight: 800; color: #fff; opacity: .9;
  text-shadow: 0 1px 4px rgba(60, 35, 20, .7); margin-top: 2px;
}
/* Happy bounce and tap wiggle (defined after .sleepy so they win when
 * both classes are present - a sleepy Munchling still jumps for joy). */
.room-critter.critter-happy { animation: munch-happy .9s ease; }
@keyframes munch-happy {
  0% { transform: translateX(-50%) scale(1, 1); }
  25% { transform: translateX(-50%) translateY(-14px) scale(.94, 1.08); }
  45% { transform: translateX(-50%) translateY(0) scale(1.12, .86); }
  65% { transform: translateX(-50%) translateY(-7px) scale(.97, 1.04); }
  100% { transform: translateX(-50%) translateY(0) scale(1, 1); }
}
.room-critter.critter-wiggle { animation: munch-wiggle .6s ease; }
@keyframes munch-wiggle {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  20% { transform: translateX(-50%) rotate(-7deg) translateY(-4px); }
  40% { transform: translateX(-50%) rotate(6deg); }
  60% { transform: translateX(-50%) rotate(-5deg) translateY(-3px); }
  80% { transform: translateX(-50%) rotate(3deg); }
}
/* The active Munchling's collection card bobs gently too; the rest
 * stay still so a grid of 50 doesn't turn into a dance floor. */
.critter-card.active .critter-wrap { animation: munch-bob-card 3.8s ease-in-out infinite; }
@keyframes munch-bob-card {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
/* Tapping a collection card gives its Munchling a little squash. */
.critter-card img.critter-squash { animation: munch-squash .5s ease; }
@keyframes munch-squash {
  0%, 100% { transform: scale(1, 1); }
  30% { transform: scale(1.14, .86); }
  60% { transform: scale(.96, 1.05); }
}
/* Landing page critters bob gently as well. */
.landing-hero .critter-img { animation: munch-bob-card 3.4s ease-in-out infinite; }
.critter-strip img { animation: munch-bob-card 3.8s ease-in-out infinite; }
.critter-strip img:nth-child(2) { animation-delay: .6s; }
.critter-strip img:nth-child(3) { animation-delay: 1.2s; }
/* Evolution / new-friend celebration: the critter spins and grows,
 * and sparkles burst out of the modal. */
.modal { position: relative; }
.modal img.critter-celebrate { animation: munch-celebrate 1s ease; }
@keyframes munch-celebrate {
  0% { transform: scale(.55) rotate(-14deg); }
  40% { transform: scale(1.12) rotate(7deg); }
  70% { transform: scale(1) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles span {
  position: absolute; left: 50%; top: 24%;
  font-size: 1.15rem; color: var(--gold); opacity: 0;
}
.modal-backdrop.celebrating .sparkles span { animation: munch-sparkle .95s ease-out forwards; }
.sparkles span:nth-child(1) { --dx: -95px; --dy: -75px; }
.sparkles span:nth-child(2) { --dx: 90px; --dy: -80px; animation-delay: .05s; }
.sparkles span:nth-child(3) { --dx: -110px; --dy: 10px; animation-delay: .08s; }
.sparkles span:nth-child(4) { --dx: 105px; --dy: 5px; animation-delay: .03s; }
.sparkles span:nth-child(5) { --dx: -60px; --dy: -110px; animation-delay: .1s; }
.sparkles span:nth-child(6) { --dx: 65px; --dy: -105px; animation-delay: .12s; }
.sparkles span:nth-child(7) { --dx: -30px; --dy: 55px; animation-delay: .06s; }
.sparkles span:nth-child(8) { --dx: 35px; --dy: 60px; animation-delay: .15s; }
@keyframes munch-sparkle {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(0deg); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.25) rotate(140deg); }
}
/* Respect users who prefer reduced motion: no loops, no bounces. */
@media (prefers-reduced-motion: reduce) {
  .room-critter, .room-critter.sleepy, .room-critter.critter-happy,
  .room-critter.critter-wiggle, .critter-card.active .critter-wrap,
  .critter-card img.critter-squash, .landing-hero .critter-img,
  .critter-strip img, .modal img.critter-celebrate,
  .modal-backdrop.celebrating .sparkles span {
    animation: none !important;
  }
}
