/* Shared look for the JuegaPop games for 3 to 5 year olds (public/juegos/_peque).
   Big targets, no text needed, lots of movement. Each game sets --sky1, --sky2,
   --hill1, --hill2 and --pipo on <body>. */
:root {
  --ink: #2a1f5c;
  --font: "Baloo 2", ui-rounded, "Trebuchet MS", system-ui, sans-serif;
  --sky1: #6fd3ff;
  --sky2: #c7f1ff;
  --hill1: #7ed957;
  --hill2: #4cbf4a;
  --pipo: #ff8a3d;
  --pipo2: #ffb36b;
  --gold: #ffd23f;
  /* Size of one big target: fits 3 in a row on a phone, grows on tablets. */
  --pick: min(27vw, 21vh, 170px);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 70%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  overscroll-behavior: none;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}
button:focus {
  outline: none;
}
button:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 3px;
}
.emo {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  line-height: 1;
}

/* ---------- Living background ---------- */
.pq-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.pq-sun {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 190px;
  height: 190px;
  animation: pq-spin 40s linear infinite;
}
.pq-sun-face {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 104px;
  height: 104px;
  animation: pq-breathe 4s ease-in-out infinite;
}
.pq-cloud {
  position: absolute;
  left: -200px;
  width: 170px;
  opacity: 0.95;
  animation: pq-drift linear infinite;
}
.pq-hills {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 26vh;
}
.pq-bubble {
  position: absolute;
  bottom: -60px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.95) 0 12%, rgba(255, 255, 255, 0.25) 13% 60%, rgba(255, 255, 255, 0.55) 61% 66%, transparent 67%);
  animation: pq-rise linear infinite;
}
.pq-flower {
  position: absolute;
  bottom: 3vh;
  font-size: 30px;
  transform-origin: 50% 100%;
  animation: pq-sway 3s ease-in-out infinite;
}

/* ---------- Screens ---------- */
.pq-scr {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 2;
}
#pq-fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* Home */
.pq-home {
  align-items: center;
  justify-content: space-evenly;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.pq-corner {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex;
  gap: 10px;
}
.pq-corner.l {
  left: 12px;
}
.pq-corner.r {
  right: 12px;
}
.pq-title {
  margin: 0;
  font-size: min(13vw, 64px);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  letter-spacing: 1px;
  padding-top: 40px;
}
.pq-title .word {
  display: inline-block;
  white-space: nowrap;
  margin: 0 0.12em;
}
.pq-title .word span {
  display: inline-block;
  color: #fff;
  -webkit-text-stroke: 2px rgba(42, 31, 92, 0.25);
  text-shadow: 0 5px 0 var(--c, #ff5fa2), 0 9px 14px rgba(42, 31, 92, 0.3);
  animation: pq-wave 2.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.09s);
}
.pq-hero {
  width: min(46vw, 30vh, 230px);
  cursor: pointer;
}
.pq-stages {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: min(4vw, 22px);
  width: 100%;
  max-width: 640px;
}
.pq-stage-btn {
  position: relative;
  width: min(28vw, 150px);
  aspect-ratio: 1;
  border-radius: 34%;
  background: linear-gradient(180deg, #fff, #f1ecff);
  box-shadow: 0 8px 0 var(--sh, #b9a9ff), 0 14px 22px rgba(42, 31, 92, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pq-in 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both, pq-float 3.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.12s), calc(var(--i) * 0.5s);
  transition: transform 0.12s;
}
/* Phone held sideways: the three stage buttons must fit the short height. */
@media (orientation: landscape) and (max-height: 480px) {
  .pq-title {
    font-size: min(11vh, 48px);
    padding-top: 6px;
  }
  .pq-hero {
    width: min(26vh, 120px);
  }
  .pq-stage-btn {
    width: min(26vh, 120px);
  }
}
.pq-stage-btn:active {
  transform: translateY(6px) scale(0.96);
  box-shadow: 0 2px 0 var(--sh, #b9a9ff);
}
.pq-stage-btn .art {
  width: 78%;
  height: 78%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pq-stage-btn .art svg {
  width: 100%;
  height: 100%;
}
.pq-stage-btn .stars {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1px;
  font-size: 17px;
  background: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  box-shadow: 0 3px 0 rgba(42, 31, 92, 0.18);
  white-space: nowrap;
}
.pq-stage-btn .stars:empty {
  display: none;
}
.pq-round-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 0 rgba(42, 31, 92, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  position: relative;
  transition: transform 0.1s;
}
.pq-round-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(42, 31, 92, 0.25);
}
.pq-round-btn svg {
  width: 62%;
  height: 62%;
}
.pq-round-btn .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 26px;
  height: 26px;
  border-radius: 13px;
  background: #ff4f7b;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.pq-round-btn.speak {
  animation: pq-pulse 1.6s ease-in-out infinite;
}

/* Game */
.pq-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 4px;
  position: relative;
  z-index: 5;
}
.pq-progress {
  display: flex;
  gap: min(1.6vw, 8px);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: inset 0 2px 0 rgba(42, 31, 92, 0.08);
}
.pq-progress span {
  display: flex;
}
.pq-progress svg {
  width: min(8vw, 38px);
  height: min(8vw, 38px);
  transition: transform 0.3s;
}
.pq-progress .on {
  animation: pq-star-get 0.7s cubic-bezier(0.3, 1.8, 0.5, 1);
}
.pq-progress .now {
  animation: pq-breathe 1.2s ease-in-out infinite;
}
.pq-play {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 10px 8px;
  min-height: 0;
}
.pq-dock {
  position: absolute;
  left: 6px;
  bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  width: min(24vw, 15vh, 120px);
  z-index: 6;
}
.pq-dock .pq-pipo {
  width: 100%;
}

/* Round transitions */
.pq-round {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(3vh, 22px);
  padding: 0 10px calc(min(15vh, 110px) + env(safe-area-inset-bottom, 0px));
}
.pq-round.out {
  animation: pq-round-out 0.5s ease-in forwards;
}
.pq-pop-in {
  animation: pq-in 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both;
  /* Waits for the previous round to fade out. */
  animation-delay: calc(var(--d, 0) * 1s + 0.25s);
}
.pq-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: min(4vw, 24px);
}

/* A big tappable thing that floats gently. */
.pq-pick {
  position: relative;
  width: var(--pick);
  height: var(--pick);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 30%;
  background: #fff;
  box-shadow: 0 8px 0 var(--sh, rgba(42, 31, 92, 0.18)), 0 14px 20px rgba(42, 31, 92, 0.18);
  touch-action: none;
}
.pq-pick > .bob {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pq-float 2.8s ease-in-out infinite;
  animation-delay: calc(var(--d, 0) * -1.7s);
}
.pq-pick.bare {
  background: none;
  box-shadow: none;
}
.pq-pick:active {
  transform: scale(0.94);
}
.pq-shake {
  animation: pq-shake 0.55s ease-in-out !important;
}
.pq-good {
  animation: pq-good 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) forwards !important;
  z-index: 3;
}
.pq-hint::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: inherit;
  border: 6px solid var(--gold);
  animation: pq-ring 1s ease-out infinite;
  pointer-events: none;
}
.pq-dim {
  opacity: 0.35;
  filter: grayscale(0.6);
  transition: opacity 0.4s, filter 0.4s;
  pointer-events: none;
}
.pq-dragging {
  z-index: 40 !important;
  transition: none !important;
  filter: drop-shadow(0 16px 12px rgba(42, 31, 92, 0.3));
}
.pq-dragging > .bob {
  animation: none;
  transform: scale(1.15) rotate(-6deg);
}
.pq-big-emo {
  font-size: calc(var(--pick) * 0.62);
}

/* Shown when the device has no voice: the instruction as a picture-free hint. */
.pq-caption {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 18px;
  padding: 4px 16px;
  font-size: min(5.4vw, 26px);
  font-weight: 800;
  text-align: center;
  max-width: 92%;
}

/* ---------- Mascot ---------- */
.pq-pipo {
  display: block;
  overflow: visible;
}
.pq-pipo * {
  transform-box: fill-box;
}
.pq-pipo .whole {
  transform-origin: 50% 100%;
  animation: pq-idle 2.6s ease-in-out infinite;
}
.pq-pipo .lid {
  transform-origin: 50% 0;
  transform: scaleY(0);
  transition: transform 0.08s;
}
.pq-pipo.blink .lid {
  transform: scaleY(1);
}
.pq-pipo .pupil {
  transition: transform 0.15s ease-out;
}
.pq-pipo .mouth-o {
  transform-origin: 50% 50%;
  transform: scale(0);
}
.pq-pipo.talk .mouth-o {
  animation: pq-talk 0.26s ease-in-out infinite alternate;
}
.pq-pipo.talk .smile {
  opacity: 0;
}
.pq-pipo .antenna {
  transform-origin: 50% 100%;
  animation: pq-sway 2.2s ease-in-out infinite;
}
.pq-pipo .arm {
  transform-origin: 50% 20%;
}
.pq-pipo.cheer .whole {
  animation: pq-jump 0.9s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.pq-pipo.cheer .arm.l {
  animation: pq-wave-l 0.3s ease-in-out 3 alternate;
}
.pq-pipo.cheer .arm.r {
  animation: pq-wave-r 0.3s ease-in-out 3 alternate;
}
.pq-pipo.cheer .smile {
  opacity: 0;
}
.pq-pipo.cheer .mouth-o {
  transform: scale(1.2);
  animation: none;
}
.pq-pipo.oops .whole {
  animation: pq-tilt 0.7s ease-in-out;
}
.pq-pipo.wave .arm.r {
  animation: pq-wave-r 0.35s ease-in-out 4 alternate;
}

/* ---------- Prize ---------- */
.pq-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(42, 20, 90, 0.72);
  animation: pq-fade 0.3s ease-out;
  padding: 16px;
}
.pq-rays {
  position: absolute;
  width: 170vmax;
  height: 170vmax;
  left: 50%;
  top: 42%;
  margin: -85vmax 0 0 -85vmax;
  background: repeating-conic-gradient(rgba(255, 230, 120, 0.22) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%;
  animation: pq-spin 16s linear infinite;
  pointer-events: none;
}
.pq-pack {
  position: relative;
  width: min(54vw, 34vh, 240px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pq-envelope {
  position: absolute;
  inset: 8%;
  animation: pq-pack-shake 0.25s ease-in-out infinite alternate;
}
.pq-envelope.open {
  animation: pq-pack-open 0.45s ease-in forwards;
}
.pq-sticker {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff 0 55%, #fff4c2 56% 100%);
  box-shadow: 0 0 0 8px #fff, 0 0 0 13px var(--gold), 0 18px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  animation: pq-sticker-in 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.pq-sticker .emo {
  font-size: min(30vw, 19vh, 130px);
  animation: pq-breathe 1.6s ease-in-out infinite;
}
.pq-sticker::after {
  content: "";
  position: absolute;
  top: -20%;
  left: -60%;
  width: 40%;
  height: 140%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: rotate(25deg);
  animation: pq-shine 2.4s ease-in-out 0.9s infinite;
}
.pq-actions {
  display: flex;
  gap: 18px;
  align-items: center;
  position: relative;
}
.pq-go {
  width: min(28vw, 120px);
  height: min(28vw, 120px);
  border-radius: 50%;
  background: linear-gradient(180deg, #8cf57a, #2fbf4f);
  box-shadow: 0 8px 0 #1d8a37, 0 14px 24px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pq-breathe 1.4s ease-in-out infinite;
}
.pq-go svg {
  width: 52%;
  height: 52%;
  margin-left: 8%;
}
.pq-go:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #1d8a37;
}

/* ---------- Album ---------- */
.pq-album {
  width: min(94vw, 560px);
  max-height: 86vh;
  overflow-y: auto;
  touch-action: pan-y;
  background: linear-gradient(180deg, #fffaf0, #ffeccc);
  border-radius: 30px;
  padding: 18px 16px 22px;
  box-shadow: 0 10px 0 #e0b56a, 0 20px 40px rgba(0, 0, 0, 0.35);
  position: relative;
  animation: pq-in 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.pq-album-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.pq-album-count {
  font-size: 28px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pq-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.pq-slot {
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px dashed rgba(160, 110, 40, 0.35);
  background: rgba(255, 255, 255, 0.5);
}
.pq-slot .emo {
  font-size: min(15vw, 70px);
}
.pq-slot.got {
  border: 0;
  background: #fff;
  box-shadow: 0 0 0 5px #fff, 0 0 0 8px var(--gold), 0 8px 12px rgba(0, 0, 0, 0.2);
  transform: rotate(var(--r, 0deg));
}
.pq-slot.got.new {
  animation: pq-sticker-in 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.pq-slot.got:active .emo {
  animation: pq-jiggle 0.5s;
}
.pq-slot.miss .emo {
  filter: grayscale(1) brightness(0.2);
  opacity: 0.16;
}

/* ---------- Keyframes ---------- */
@keyframes pq-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pq-breathe {
  50% {
    transform: scale(1.07);
  }
}
@keyframes pq-drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(100vw + 420px));
  }
}
@keyframes pq-rise {
  0% {
    transform: translate(0, 0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translate(26px, -55vh);
  }
  100% {
    transform: translate(-10px, -115vh);
    opacity: 0.8;
  }
}
@keyframes pq-sway {
  50% {
    transform: rotate(-10deg);
  }
  0%,
  100% {
    transform: rotate(8deg);
  }
}
@keyframes pq-wave {
  0%,
  60%,
  100% {
    transform: translateY(0) rotate(0);
  }
  30% {
    transform: translateY(-12px) rotate(-4deg);
  }
}
@keyframes pq-float {
  50% {
    transform: translateY(-7px) rotate(1.5deg);
  }
}
@keyframes pq-in {
  0% {
    transform: scale(0) rotate(-12deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}
@keyframes pq-round-out {
  to {
    transform: translateY(-30px) scale(0.85);
    opacity: 0;
  }
}
@keyframes pq-shake {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  20% {
    transform: translateX(-14px) rotate(-6deg);
  }
  40% {
    transform: translateX(12px) rotate(5deg);
  }
  60% {
    transform: translateX(-8px) rotate(-3deg);
  }
  80% {
    transform: translateX(5px) rotate(2deg);
  }
}
@keyframes pq-good {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.3) rotate(-8deg);
  }
  55% {
    transform: scale(0.95) rotate(5deg);
  }
  100% {
    transform: scale(1.12) rotate(0);
  }
}
@keyframes pq-ring {
  from {
    transform: scale(0.92);
    opacity: 1;
  }
  to {
    transform: scale(1.18);
    opacity: 0;
  }
}
@keyframes pq-pulse {
  0%,
  100% {
    box-shadow: 0 5px 0 rgba(42, 31, 92, 0.25), 0 0 0 0 rgba(255, 210, 63, 0.9);
  }
  60% {
    box-shadow: 0 5px 0 rgba(42, 31, 92, 0.25), 0 0 0 14px rgba(255, 210, 63, 0);
  }
}
@keyframes pq-star-get {
  0% {
    transform: scale(0.3) rotate(-90deg);
  }
  60% {
    transform: scale(1.5) rotate(15deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}
@keyframes pq-idle {
  0%,
  100% {
    transform: scale(1, 1);
  }
  50% {
    transform: scale(1.03, 0.97);
  }
}
@keyframes pq-talk {
  from {
    transform: scale(0.35, 0.25);
  }
  to {
    transform: scale(1, 1);
  }
}
@keyframes pq-jump {
  0% {
    transform: translateY(0) scale(1, 1);
  }
  15% {
    transform: translateY(0) scale(1.15, 0.82);
  }
  45% {
    transform: translateY(-28%) scale(0.9, 1.12);
  }
  75% {
    transform: translateY(0) scale(1.12, 0.88);
  }
  100% {
    transform: translateY(0) scale(1, 1);
  }
}
@keyframes pq-wave-l {
  to {
    transform: rotate(50deg);
  }
}
@keyframes pq-wave-r {
  to {
    transform: rotate(-50deg);
  }
}
@keyframes pq-tilt {
  25% {
    transform: rotate(-9deg);
  }
  50% {
    transform: rotate(7deg);
  }
  75% {
    transform: rotate(-4deg);
  }
}
@keyframes pq-fade {
  from {
    opacity: 0;
  }
}
@keyframes pq-pack-shake {
  from {
    transform: rotate(-7deg) scale(1);
  }
  to {
    transform: rotate(7deg) scale(1.06);
  }
}
@keyframes pq-pack-open {
  to {
    transform: scale(1.6);
    opacity: 0;
  }
}
@keyframes pq-sticker-in {
  0% {
    transform: scale(0) rotate(-200deg);
  }
  70% {
    transform: scale(1.15) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(var(--r, 0deg));
  }
}
@keyframes pq-shine {
  0% {
    left: -60%;
  }
  40%,
  100% {
    left: 130%;
  }
}
@keyframes pq-jiggle {
  25% {
    transform: rotate(-14deg) scale(1.15);
  }
  75% {
    transform: rotate(12deg) scale(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pq-cloud,
  .pq-bubble,
  .pq-sun,
  .pq-rays {
    animation: none !important;
  }
}
