/* ---- Egg Friends — soft, calm, kid-friendly ---- */

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #fdf6ec;          /* warm cream */
  --bg-soft: #f7ede0;
  --card: #ffffff;
  --ink: #6b5d52;          /* soft brown text */
  --ink-light: #a3958a;
  --mint: #cfe8d8;
  --mint-deep: #9ecfb2;
  --peach: #f9d9c5;
  --peach-deep: #f0b9a0;
  --lavender: #e3dcf2;
  --lavender-deep: #c3b6e3;
  --butter: #faeec9;
  --butter-deep: #ecd9a0;
  --shadow: rgba(107, 93, 82, 0.12);
  --radius: 22px;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: "Comic Sans MS", "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 16px;
}

/* ---------- top bar ---------- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.level-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 16px;
  box-shadow: 0 4px 12px var(--shadow);
  flex: 1;
  min-width: 0;
  max-width: 200px;
}

.level-star { font-size: 1.5rem; }

.level-info { flex: 1; }

.level-label {
  font-size: 0.95rem;
  font-weight: bold;
  display: block;
  margin-bottom: 4px;
}

.xp-bar {
  height: 10px;
  background: var(--bg-soft);
  border-radius: 6px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mint-deep), var(--mint));
  border-radius: 6px;
  transition: width 0.5s ease;
}

.top-buttons { display: flex; gap: 10px; }

.icon-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 12px var(--shadow);
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s;
}

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

.icon-btn.off { opacity: 0.4; }

/* ---------- hatch area ---------- */
.hatch-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px 0;
}

.hint {
  font-size: 1.35rem;
  font-weight: bold;
  color: var(--ink);
  min-height: 1.8rem;
  text-align: center;
}

.egg-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.egg-wrap {
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
}

#egg-body {
  fill: var(--egg-fill, #fff6e5);
  stroke: var(--egg-stroke, #e8d5b5);
  stroke-width: 4;
}

#egg-spots { fill: var(--egg-spot, #f3e3c3); }

.crack { opacity: 0; transition: opacity 0.2s; }
.crack.show { opacity: 1; }

.egg-shadow {
  width: 150px;
  height: 26px;
  background: var(--shadow);
  border-radius: 50%;
  margin-top: -8px;
  filter: blur(4px);
}

/* wobble on tap */
@keyframes wobble {
  0%   { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(-6deg) scale(1.04); }
  50%  { transform: rotate(5deg) scale(1.05); }
  75%  { transform: rotate(-3deg) scale(1.02); }
  100% { transform: rotate(0deg) scale(1); }
}
.egg-wrap.wobble { animation: wobble 0.4s ease; }

/* hatch pop */
@keyframes hatch-pop {
  0%   { transform: scale(1); opacity: 1; }
  60%  { transform: scale(1.15); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 0; }
}
#egg-svg.hatched { animation: hatch-pop 0.5s ease forwards; }

/* animal reveal */
.animal-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7rem;
  opacity: 0;
  pointer-events: none;
}

@keyframes pop-in {
  0%   { transform: scale(0.2); opacity: 0; }
  70%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.animal-reveal.show {
  opacity: 1;
  animation: pop-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bounce-gentle {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}
.animal-reveal.bounce { animation: bounce-gentle 1.6s ease-in-out infinite; }

/* tap dots */
.tap-dots { display: flex; gap: 10px; min-height: 18px; }

.tap-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 2px solid var(--ink-light);
  transition: background 0.2s, transform 0.2s;
}
.tap-dot.filled {
  background: var(--mint-deep);
  border-color: var(--mint-deep);
  transform: scale(1.15);
}

/* hatched panel */
.hatched-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  min-height: 130px;
}
.hatched-panel.show { opacity: 1; pointer-events: auto; }

.hatched-name { font-size: 1.5rem; font-weight: bold; }

.hatched-rarity {
  font-size: 0.95rem;
  padding: 3px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--ink-light);
  font-weight: bold;
}
.hatched-rarity.common    { background: var(--mint);     color: #4e7a60; }
.hatched-rarity.rare      { background: var(--lavender); color: #6f5fa3; }
.hatched-rarity.epic      { background: var(--peach);    color: #b0704f; }
.hatched-rarity.legendary { background: var(--butter);   color: #a3822f; }

.hatched-new {
  font-size: 1rem;
  color: var(--peach-deep);
  font-weight: bold;
  min-height: 1.3rem;
}

.big-btn {
  margin-top: 6px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--peach), var(--peach-deep));
  color: #7c5136;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: bold;
  padding: 14px 34px;
  cursor: pointer;
  box-shadow: 0 5px 14px var(--shadow);
  transition: transform 0.15s;
}
.big-btn:active { transform: scale(0.94); }

/* ---------- collection ---------- */
.collection {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.collection-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.collection-header h2 { flex: 1; font-size: 1.4rem; }

.collection-count {
  background: var(--card);
  border-radius: 14px;
  padding: 6px 14px;
  font-weight: bold;
  box-shadow: 0 3px 8px var(--shadow);
  font-size: 0.95rem;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  padding-bottom: 24px;
}

.collect-card {
  background: var(--card);
  border-radius: 18px;
  padding: 12px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 3px 10px var(--shadow);
  border: 3px solid transparent;
}
.collect-card.common    { border-color: var(--mint); }
.collect-card.rare      { border-color: var(--lavender-deep); }
.collect-card.epic      { border-color: var(--peach-deep); }
.collect-card.legendary { border-color: var(--butter-deep); }

.collect-emoji { font-size: 2.4rem; line-height: 1.2; }

.collect-card.locked { opacity: 0.6; border-color: transparent; }
.collect-card.locked .collect-emoji { filter: grayscale(1) opacity(0.35); }

.collect-name { font-size: 0.8rem; font-weight: bold; text-align: center; }
.collect-count { font-size: 0.72rem; color: var(--ink-light); }

/* ---------- confetti ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  top: -20px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(540deg); }
}

/* ---------- level toast ---------- */
.level-toast {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  box-shadow: 0 6px 20px var(--shadow);
  z-index: 60;
  animation: toast-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-star { font-size: 1.6rem; }

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