/* ============ My Pets - Kid Friendly Styles ============ */

:root {
  --pink: #ff6fa5;
  --purple: #8c6bff;
  --blue: #4fc3f7;
  --yellow: #ffd54f;
  --green: #66d9a3;
  --orange: #ff9e5e;
  --dark: #3a3358;
  --card-bg: #ffffff;
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Comic Sans MS', 'Baloo 2', 'Trebuchet MS', 'Segoe UI', sans-serif;
  background: linear-gradient(160deg, #fff2c9 0%, #ffd9ec 35%, #cfe8ff 70%, #d8ffe3 100%);
  color: var(--dark);
  overflow-x: hidden;
}

#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Floating background decor ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.floaty {
  position: absolute;
  font-size: 2.4rem;
  opacity: 0.55;
  animation: floatUp 14s linear infinite;
}
.f1 { left: 6%;  top: 100%; animation-duration: 16s; animation-delay: 0s; }
.f2 { left: 22%; top: 100%; animation-duration: 20s; animation-delay: 2s; font-size: 3rem; }
.f3 { left: 48%; top: 100%; animation-duration: 13s; animation-delay: 4s; }
.f4 { left: 68%; top: 100%; animation-duration: 18s; animation-delay: 1s; }
.f5 { left: 85%; top: 100%; animation-duration: 22s; animation-delay: 3s; font-size: 3.2rem; }
.f6 { left: 36%; top: 100%; animation-duration: 19s; animation-delay: 5s; font-size: 2.6rem; }
.f7 { left: 95%; top: 100%; animation-duration: 17s; animation-delay: 6.5s; font-size: 2.9rem; }
.f8  { left: 14%; top: 100%; animation-duration: 21s; animation-delay: 7.5s; }
.f9  { left: 58%; top: 100%; animation-duration: 15s; animation-delay: 3.5s; }
.f10 { left: 78%; top: 100%; animation-duration: 24s; animation-delay: 9s; }
.f11 { left: 30%; top: 100%; animation-duration: 17s; animation-delay: 11s; }

/* Balloon spans hold an inline SVG rather than emoji text. */
.floaty.balloon {
  display: inline-flex;
}

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-120vh) rotate(25deg); }
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  width: 100%;
  padding: 20px;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(80, 50, 120, 0.18);
  padding: 32px 30px;
  width: 100%;
}

/* ---------- Login screen ---------- */
.login-card {
  max-width: 420px;
  text-align: center;
}
.logo {
  font-size: 2.4rem;
  margin: 0 0 6px;
  color: var(--purple);
  text-shadow: 2px 2px 0 rgba(255, 111, 165, 0.3);
}
.subtitle {
  margin-top: 0;
  color: #7c7594;
  font-size: 1.05rem;
}
.field {
  display: block;
  text-align: left;
  margin: 18px 0;
}
.field span {
  display: block;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--dark);
}
.field input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  border: 3px solid #e6def7;
  border-radius: 16px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.field input:focus {
  border-color: var(--purple);
}
.login-message {
  min-height: 1.4em;
  color: var(--pink);
  font-weight: bold;
}

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-weight: bold;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.94); }

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  box-shadow: 0 8px 18px rgba(140, 107, 255, 0.4);
}
.btn-primary:hover { transform: translateY(-2px); }

.btn-big {
  width: 100%;
  padding: 16px;
  font-size: 1.25rem;
  margin-top: 8px;
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: #f1ecff;
  color: var(--dark);
}
.btn-small:hover { background: #e4d9ff; }

/* ---------- Pet select screen ---------- */
.select-card {
  max-width: 760px;
  text-align: center;
}
.select-card h2 {
  color: var(--purple);
}
.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.pet-card {
  background: #faf7ff;
  border: 3px solid transparent;
  border-radius: 18px;
  padding: 14px 8px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  text-align: center;
}
.pet-card:hover {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--pink);
  background: #fff0f7;
}
.pet-card svg {
  width: 100%;
  height: 90px;
}
.pet-card .pet-label {
  display: block;
  margin-top: 8px;
  font-weight: bold;
  color: var(--dark);
}

/* ---------- Game screen ---------- */
#game-screen.active {
  max-width: 1000px;
  margin: 0 auto;
  align-items: stretch;
}

.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 26px rgba(80, 50, 120, 0.14);
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
}
.player-name {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--purple);
}
.star-count {
  color: #d8a400;
  font-weight: bold;
}

.meters {
  display: flex;
  gap: 14px;
  flex: 1;
  min-width: 220px;
  justify-content: center;
}
.meter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.meter {
  width: 70px;
  height: 14px;
  background: #eee6ff;
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 40%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.meter-fill.happy  { background: linear-gradient(90deg, #ffd54f, #ff9e5e); }
.meter-fill.hunger { background: linear-gradient(90deg, #66d9a3, #4fc3f7); }
.meter-fill.clean  { background: linear-gradient(90deg, #4fc3f7, #8c6bff); }

.header-buttons {
  display: flex;
  gap: 8px;
}

.game-main {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.pet-stage {
  position: relative;
  flex: 1 1 320px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(80, 50, 120, 0.14);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
  overflow: hidden;
}

/* Pet sits centered in its own row (order: 1 keeps it visually on top/in
   the middle regardless of source order); avatar sits in a separate row
   below it (order: 2), so the two are stacked in normal document flow and
   can never overlap, no matter how big the pet is or what shape it is. */
.pet-display {
  order: 1;
  width: 84%;
  max-width: 320px;
  transition: transform 0.15s;
  position: relative;
  z-index: 2;
}
.pet-display svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.pet-display.bounce { animation: bounce 0.5s ease; }
.pet-display.wiggle { animation: wiggle 0.5s ease; }
.pet-display.happy-spin { animation: happySpin 0.6s ease; }

/* The kid's avatar stands in its own row below the pet and reacts along
   with it - stacked rather than overlapped, so it's never covered. */
.avatar-display {
  order: 2;
  position: relative;
  align-self: flex-start;
  margin-left: 8%;
  width: 22%;
  max-width: 95px;
  z-index: 1;
  transition: transform 0.15s;
}
.avatar-display svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.avatar-display.bounce { animation: bounce 0.5s ease; }
.avatar-display.wiggle { animation: wiggle 0.5s ease; }
.avatar-display.happy-spin { animation: happySpin 0.6s ease; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-18px); }
  55% { transform: translateY(0); }
  75% { transform: translateY(-8px); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
@keyframes happySpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

.pet-speech-bubble {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: white;
  border: 3px solid var(--purple);
  border-radius: 16px;
  padding: 8px 16px;
  font-weight: bold;
  white-space: nowrap;
  transition: transform 0.25s ease;
  pointer-events: none;
}
.pet-speech-bubble.show {
  transform: translateX(-50%) scale(1);
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.fx-item {
  position: absolute;
  font-size: 1.6rem;
  animation: fxPop 0.9s ease forwards;
}
@keyframes fxPop {
  0%   { transform: translateY(0) scale(0.6); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translateY(-70px) scale(1.2); opacity: 0; }
}

.activity-panel {
  flex: 1 1 320px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(80, 50, 120, 0.14);
  padding: 16px;
  min-height: 380px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.tab-btn {
  flex: 1;
  padding: 10px 6px;
  border: none;
  border-radius: 14px;
  background: #f1ecff;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s, transform 0.15s;
}
.tab-btn:hover { transform: translateY(-2px); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.tab-hint {
  color: #7c7594;
  margin-top: 0;
  font-size: 0.95rem;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 10px;
}
.swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 0 2px #e6def7;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.selected {
  box-shadow: 0 0 0 3px var(--dark);
  transform: scale(1.12);
}

.items-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.item-btn {
  border: none;
  background: #fff3e0;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 1.8rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}
.item-btn:hover { transform: translateY(-3px) scale(1.05); }
.item-btn:active { transform: scale(0.9); }
.item-btn.used { opacity: 0.35; pointer-events: none; }

#sponge-btn {
  font-size: 1.3rem;
  padding: 16px 26px;
}

/* ---------- Celebration overlay ---------- */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(60, 40, 90, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.celebration.hidden { display: none; }
.celebration-card {
  background: white;
  border-radius: 26px;
  padding: 36px 40px;
  text-align: center;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  animation: popIn 0.35s ease;
}
.celebration-card h2 {
  color: var(--pink);
  font-size: 1.8rem;
  margin-top: 0;
}
@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .card { padding: 22px 18px; }
  .game-header { justify-content: center; text-align: center; }
  .meters { order: 3; }
  .header-buttons { order: 2; }
}
