/* ============================================================
   Cookie Monster Game - Styles
   ============================================================ */

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

:root {
  --monster-size: min(40vh, 410px);
  --cookie-size: clamp(55px, 11vw, 95px);
  --bg-color: #fef9f0;
  --text-color: #2d2d2d;
  --cookie-blue-dark: #2E8FC7;
  --cookie-monster-shadow: #1c5a80;
}

html,
body {
  height: 100%;
  font-family: 'sans-serif', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
  background: url('assets/landscape.jpg') center center / cover no-repeat fixed;
  color: var(--text-color);
  overflow: hidden;
  user-select: none;
}

h1 {
  font-family: 'Baloo 2', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
  font-size: 3.6rem;
  line-height: 1.2;
  font-weight: 800;
  color: var(--cookie-blue-dark);
  -webkit-text-stroke: 4px white;
  paint-order: stroke fill;
  text-shadow:
    0 4px 0 var(--cookie-monster-shadow),
    0 6px 14px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.5px;
  text-align: center;
}

.game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.music-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  min-width: 7.5rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid #ffffff;
  border-radius: 0.5rem;
  background-color: #2E8FC7;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.music-toggle:hover {
  background: #1c5a80;
}

.music-toggle:focus-visible {
  outline: 3px solid #ffca3a;
  outline-offset: 3px;
}

/* ---------- MONSTRUO CENTRADO ---------- */
.monster-zone {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

.monster {
  width: var(--monster-size);
  height: auto;
  /* aspect-ratio: 1 / 1; */
  object-fit: contain;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.25));
  transition: transform 0.15s ease-out;
  cursor: grab;
  pointer-events: auto;
}

.monster:active {
  cursor: grabbing;
}

/* ---------- CAPA GALLETAS ---------- */
.cookies-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.cookie {
  position: absolute;
  width: var(--cookie-size);
  height: var(--cookie-size);
  cursor: grab;
  touch-action: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  will-change: transform;
  --cookie-shape: shape(from 94.47% 62.53%,
      curve to 89.00% 70.90% with 93.87% 67.93%,
      smooth to 81.98% 78.94%,
      smooth to 75.47% 87.11%,
      smooth to 66.06% 91.96%,
      smooth to 55.70% 93.83%,
      smooth to 44.94% 95.47%,
      smooth to 34.34% 94.98%,
      smooth to 24.04% 90.97%,
      smooth to 15.65% 84.42%,
      smooth to 9.11% 75.80%,
      smooth to 5.98% 66.09%,
      smooth to 5.47% 55.87%,
      smooth to 7.76% 46.90%,
      smooth to 8.75% 37.99%,
      smooth to 9.33% 29.82%,
      smooth to 13.97% 22.45%,
      smooth to 20.03% 16.92%,
      smooth to 27.39% 13.05%,
      smooth to 34.83% 11.14%,
      smooth to 42.44% 10.30%,
      smooth to 50.15% 6.25%,
      smooth to 59.03% 3.09%,
      smooth to 68.38% 4.30%,
      smooth to 76.71% 8.74%,
      smooth to 83.42% 15.62%,
      smooth to 88.46% 23.73%,
      smooth to 91.01% 32.81%,
      smooth to 93.39% 42.24%,
      smooth to 95.14% 52.04%,
      smooth to 94.47% 62.53%);
  clip-path: none;
}


.galleta {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 30% 30%, #e0a458, #c78b3d 70%);
  border-radius: 50%;
  box-shadow: inset -8px -8px 15px rgba(0, 0, 0, 0.25),
    inset 8px 8px 15px rgba(255, 255, 255, 0.2),
    5px 10px 15px rgba(0, 0, 0, 0.3);
  clip-path: var(--cookie-shape);
  pointer-events: none;
}

.chispa {
  position: absolute;
  width: 8%;
  height: 8%;
  background: #4b2e1e;
  border-radius: 50% 50% 40% 60% / 60% 40% 60% 40%;
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.5),
    inset 2px 2px 3px rgba(255, 255, 255, 0.15);
}

.chispa:nth-child(1) {
  top: 14%;
  left: 23%;
  transform: rotate(20deg);
}

.chispa:nth-child(2) {
  top: 27%;
  left: 59%;
  transform: rotate(-15deg);
}

.chispa:nth-child(3) {
  top: 45%;
  left: 18%;
  width: 6%;
  height: 6%;
  transform: rotate(40deg);
}

.chispa:nth-child(4) {
  top: 64%;
  left: 45%;
  transform: rotate(-30deg);
}

.chispa:nth-child(5) {
  top: 41%;
  left: 73%;
  width: 7%;
  height: 7%;
  transform: rotate(10deg);
}

.chispa:nth-child(6) {
  top: 73%;
  left: 27%;
  width: 7%;
  height: 7%;
  transform: rotate(60deg);
}

.chispa:nth-child(7) {
  top: 18%;
  left: 45%;
  width: 6%;
  height: 6%;
  transform: rotate(-50deg);
}

.chispa:nth-child(8) {
  top: 77%;
  left: 68%;
  width: 6%;
  height: 6%;
  transform: rotate(25deg);
}

.cookie-vowel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-bottom: 4%;
  z-index: 2;
  color: #5d3a1a;
  font-size: calc(var(--cookie-size) * 0.55);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}

/* Estado arrastrando */
.cookie.dragging {
  cursor: grabbing;
  z-index: 10000;
  transform: scale(1.15) rotate(3deg);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.25));
  transition: none;
}

/* ---------- COMER ---------- */
@keyframes eaten {
  0% {
    transform: scale(1.15) rotate(3deg);
    opacity: 1;
  }

  100% {
    transform: scale(0) rotate(180deg);
    opacity: 0;
  }
}

.cookie.eaten {
  animation: eaten 0.35s ease-in forwards;
  pointer-events: none;
  z-index: 5;
}

/* ---------- CONFETI ---------- */
.confetti-container {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 1px;
  z-index: 100;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  transform: rotate(var(--angle));
  animation: confetti-burst 1.6s ease-out forwards;
}

@keyframes confetti-burst {
  0% {
    opacity: 1;
    transform: rotate(var(--angle)) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateY(calc(var(--distance) * -1)) rotate(720deg) scale(0.7);
  }
}

/* ---------- SCORE ---------- */
/* .score {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  color: #5d3a1a;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  z-index: 50;
  backdrop-filter: blur(4px);
}

.score span {
  color: #1a73e8;
  font-size: 1.2em;
} */

/* ---------- RESPONSIVE ---------- */
@media (max-width: 830px) {
  :root {
    --monster-size: 35vh;
  }

  h1 {
    font-size: 3rem;
  }
}

@media (max-width: 480px) {
  :root {
    --monster-size: 25vh;
    --cookie-size: 14vw;
  }

  h1 {
    font-size: 2.4rem;
  }

  .music-toggle {
    top: 0.75rem;
    right: 0.75rem;
    min-width: 6.75rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.9rem;
  }
}

/* ---------- ACCESIBILIDAD ---------- */
@media (prefers-reduced-motion: reduce) {
  .cookie {
    animation: none !important;
  }
}

.cookie:focus-visible,
.monster-zone:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 4px;
}