/* ====================== Little Snacks — styles ====================== */

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Baloo 2", system-ui, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% 0%, #ffe1f1 0%, #ffd0e6 35%, #c9e7ff 100%);
  transition: background 0.4s ease;
}

/* ------------------------- HUD: timer + list ------------------------- */

#hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 20px);
  padding: clamp(8px, 2vw, 16px);
}

#timer {
  flex: 0 0 auto;
  text-align: center;
}

#timer-num {
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 800;
  line-height: 1;
  color: #ff3b86;
  text-shadow: 0 3px 0 #fff, 0 5px 8px rgba(0, 0, 0, 0.15);
  min-width: 1.4em;
}

#timer-num.low {
  color: #e10046;
  animation: pulse 0.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { transform: scale(1.18); }
}

/* Wrong-food penalty: a quick red shake on the countdown number. */
#timer-num.penalty {
  color: #e10046;
  animation: penaltyShake 0.5s ease;
}

@keyframes penaltyShake {
  0% { transform: scale(1.35); color: #ff1f5a; }
  20% { transform: translateX(-7px) scale(1.25); }
  40% { transform: translateX(7px) scale(1.2); }
  60% { transform: translateX(-5px) scale(1.12); }
  80% { transform: translateX(4px) scale(1.06); }
  100% { transform: translateX(0) scale(1); }
}

/* ----------------------- Customize (🎨) button ---------------------- */

#customize-btn {
  flex: 0 0 auto;
  font-size: clamp(22px, 5vw, 32px);
  line-height: 1;
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid #ffb3d6;
  border-radius: 50%;
  width: clamp(44px, 11vw, 58px);
  height: clamp(44px, 11vw, 58px);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(255, 105, 170, 0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  touch-action: manipulation;
}

#customize-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(255, 105, 170, 0.3);
}

#timer-bar {
  margin-top: 4px;
  width: clamp(70px, 16vw, 120px);
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.6);
  overflow: hidden;
}

#timer-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  border-radius: 99px;
  background: linear-gradient(90deg, #7be06a, #ffd23f 60%, #ff5d5d);
  transition: transform 0.12s linear;
}

#list {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(4px, 1.2vw, 10px);
  align-content: center;
  justify-content: center;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 6px;
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid #ffb3d6;
  border-radius: 99px;
  box-shadow: 0 3px 0 rgba(255, 105, 170, 0.3);
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.list-emoji { font-size: clamp(18px, 4vw, 28px); }

.list-name {
  font-size: clamp(11px, 2.4vw, 16px);
  font-weight: 700;
  color: #b03070;
}

.list-check {
  display: none;
  color: #1aa84b;
  font-weight: 800;
  font-size: clamp(14px, 3vw, 20px);
}

.list-item.done {
  background: #d9f7d2;
  border-color: #7be06a;
}

.list-item.done .list-name { color: #3a8a3a; text-decoration: line-through; }
.list-item.done .list-emoji { filter: grayscale(0.2); opacity: 0.7; }
.list-item.done .list-check { display: inline; animation: pop 0.3s ease; }

@keyframes pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* --------------------------- Playfield ------------------------------ */

#playfield {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* While the color picker is open the snacks hold still and can't be tapped. */
#playfield.frozen .snack {
  animation-play-state: paused;
  pointer-events: none;
}

.snack {
  position: absolute;
  font-size: clamp(34px, 9vw, 60px);
  line-height: 1;
  background: none;
  border: none;
  padding: 6px;
  margin: 0;
  cursor: pointer;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.25));
  transform: rotate(var(--rot, 0deg));
  animation: bob var(--bob, 2s) ease-in-out infinite alternate;
  touch-action: manipulation;
}

@keyframes bob {
  from { transform: translateY(0) rotate(var(--rot, 0deg)); }
  to   { transform: translateY(-10px) rotate(calc(var(--rot, 0deg) * -1)); }
}

.snack.pop-in { animation: bob var(--bob, 2s) ease-in-out infinite alternate, popin 0.25s ease; }

@keyframes popin {
  0% { scale: 0; }
  70% { scale: 1.3; }
  100% { scale: 1; }
}

.snack.pop-out { animation: popout 0.2s ease forwards; pointer-events: none; }

@keyframes popout {
  to { scale: 0; opacity: 0; }
}

.snack.nope { animation: shake 0.35s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(var(--rot, 0deg)); }
  25% { transform: translateX(-8px) rotate(-10deg); }
  75% { transform: translateX(8px) rotate(10deg); }
}

/* The snack copy that flies into the monster's mouth. */
.flier {
  position: fixed;
  z-index: 50;
  font-size: clamp(34px, 9vw, 60px);
  transform: translate(0, 0);
  transition: transform 0.33s cubic-bezier(0.5, -0.2, 0.7, 1), opacity 0.33s ease;
  pointer-events: none;
  margin-left: -0.5em;
  margin-top: -0.5em;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.25));
}

/* ---------------------------- Monster ------------------------------- */

#stage {
  flex: 0 0 auto;
  position: relative;
  height: clamp(150px, 30vh, 280px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#monster {
  --grow: 1;
  /* Body palette — overridden inline by the color picker. */
  --m-light: #9be86f;
  --m-main: #5fc23c;
  --m-dark: #3f9c24;
  position: relative;
  margin-bottom: 6px;
  transition: opacity 0.5s ease;
}

#monster.nom .body { animation: nom 0.26s ease; }

@keyframes nom {
  50% { transform: scale(calc(var(--grow) * 1.06)) translateY(2px); }
}

.body {
  position: relative;
  width: clamp(120px, 26vw, 180px);
  height: clamp(110px, 24vw, 165px);
  background: radial-gradient(circle at 38% 32%, var(--m-light) 0%, var(--m-main) 55%, var(--m-dark) 100%);
  border-radius: 52% 52% 46% 46% / 56% 56% 44% 44%;
  transform: scale(var(--grow));
  transform-origin: bottom center;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: inset -10px -14px 24px rgba(0, 0, 0, 0.18),
              0 10px 18px rgba(0, 0, 0, 0.2);
}

.belly-shine {
  position: absolute;
  left: 20%;
  top: 18%;
  width: 34%;
  height: 30%;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  filter: blur(2px);
}

.eye {
  position: absolute;
  top: 24%;
  width: 26%;
  height: 30%;
  background: #fff;
  border-radius: 50%;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.eye-l { left: 16%; }
.eye-r { right: 16%; }

.pupil {
  width: 42%;
  height: 42%;
  background: #2a1a00;
  border-radius: 50%;
  animation: look 3s ease-in-out infinite;
}

@keyframes look {
  0%, 40% { transform: translate(0, 0); }
  50%, 70% { transform: translate(3px, 2px); }
  80%, 100% { transform: translate(-2px, 1px); }
}

.mouth {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 36%;
  height: 14%;
  background: #5a1020;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  transform: translateX(-50%);
  overflow: hidden;
  transition: height 0.12s ease, width 0.12s ease;
}

.tongue {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 60%;
  height: 60%;
  background: #ff6f8f;
  border-radius: 50% 50% 50% 50%;
  transform: translateX(-50%);
}

#monster.gobbling .mouth {
  height: 34%;
  width: 46%;
  border-radius: 50%;
}

.horn {
  position: absolute;
  top: -6%;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 22px solid var(--m-dark);
  z-index: -1;
}

.horn-l { left: 26%; transform: rotate(-18deg); }
.horn-r { right: 26%; transform: rotate(18deg); }

.foot {
  position: absolute;
  bottom: -4px;
  width: 22%;
  height: 16px;
  background: var(--m-dark);
  border-radius: 50%;
  z-index: -1;
}

.foot-l { left: 22%; }
.foot-r { right: 22%; }

#monster.gone {
  animation: vanish 0.7s ease forwards;
}

@keyframes vanish {
  to { transform: scale(0.2) rotate(20deg); opacity: 0; }
}

#monster.win .body {
  transition: transform 0.6s cubic-bezier(0.34, 1.8, 0.5, 1);
}

/* ---------------------- Speech bubble ("Yum yum!") ------------------- */

.speech {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translate(-50%, 10px) scale(0.8);
  background: #fff;
  color: #b03070;
  font-weight: 800;
  font-size: clamp(18px, 4.5vw, 30px);
  padding: 8px 18px;
  border-radius: 99px;
  border: 4px solid #ffb3d6;
  box-shadow: 0 6px 0 rgba(255, 105, 170, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  z-index: 30;
}

.speech::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #ffb3d6;
}

.speech.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: speechPop 0.3s ease;
}

@keyframes speechPop {
  0% { transform: translate(-50%, 0) scale(0.6); }
  60% { transform: translate(-50%, 0) scale(1.15); }
  100% { transform: translate(-50%, 0) scale(1); }
}

/* --------------------------- FX canvas ------------------------------ */

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

/* ---------------------------- Overlays ------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(40, 10, 40, 0.45);
  backdrop-filter: blur(3px);
}

.overlay.show { display: flex; }
.overlay.win { background: rgba(255, 220, 120, 0.35); }
.overlay.lose { background: rgba(60, 40, 80, 0.5); }

.card {
  background: #fff;
  border-radius: 28px;
  border: 6px solid #ffb3d6;
  box-shadow: 0 16px 0 rgba(255, 105, 170, 0.25), 0 24px 40px rgba(0, 0, 0, 0.3);
  padding: clamp(20px, 5vw, 40px);
  max-width: 440px;
  width: 100%;
  text-align: center;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardIn {
  from { transform: scale(0.6) translateY(30px); opacity: 0; }
}

.card-emoji {
  font-size: clamp(46px, 12vw, 72px);
  line-height: 1;
  margin-bottom: 6px;
}

.card h1 {
  margin: 6px 0 12px;
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 800;
  color: #ff3b86;
}

.overlay.win .card h1 { color: #ff9500; }
.overlay.lose .card h1 { color: #8a4fd0; }

.card p {
  margin: 8px 0;
  font-size: clamp(15px, 3.6vw, 19px);
  font-weight: 500;
  color: #5a3a52;
}

.card p.small { font-size: clamp(13px, 3vw, 16px); color: #9a7a92; }

.big-btn {
  margin-top: 18px;
  font-family: inherit;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ff77b3, #ff3b86);
  border: none;
  border-radius: 99px;
  padding: 14px 34px;
  cursor: pointer;
  box-shadow: 0 6px 0 #c91f63, 0 10px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.big-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c91f63, 0 4px 10px rgba(0, 0, 0, 0.25);
}

/* ---------------------- Color picker (palette) ---------------------- */

.palette {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(12px, 4vw, 28px);
  /* Light wash so the monster stays visible at the bottom while you pick. */
  background: rgba(40, 10, 40, 0.28);
  backdrop-filter: blur(2px);
}

.palette.show { display: flex; }

.palette-card {
  background: #fff;
  border-radius: 24px;
  border: 6px solid #ffb3d6;
  box-shadow: 0 14px 0 rgba(255, 105, 170, 0.25), 0 20px 36px rgba(0, 0, 0, 0.3);
  padding: clamp(16px, 4vw, 26px);
  max-width: 460px;
  width: 100%;
  text-align: center;
  animation: cardIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.paused-tag {
  display: inline-block;
  background: #ffe1f1;
  color: #c91f63;
  font-weight: 800;
  font-size: clamp(13px, 3vw, 16px);
  padding: 4px 14px;
  border-radius: 99px;
  border: 2px solid #ffb3d6;
}

.palette-card h2 {
  margin: 10px 0 14px;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  color: #ff3b86;
}

.palette-row {
  margin: 12px 0;
}

.palette-label {
  display: block;
  font-size: clamp(13px, 3vw, 16px);
  font-weight: 700;
  color: #b03070;
  margin-bottom: 8px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 2.4vw, 14px);
  justify-content: center;
}

.swatch {
  width: clamp(40px, 10vw, 52px);
  height: clamp(40px, 10vw, 52px);
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px rgba(176, 48, 112, 0.25), 0 4px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.swatch:active { transform: scale(0.92); }

.swatch.active {
  box-shadow: 0 0 0 4px #ff3b86, 0 4px 8px rgba(0, 0, 0, 0.25);
  transform: scale(1.08);
}

.resume-btn { margin-top: 16px; }
