*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1a4cff;
  --pink: #ff4da6;
  --yellow: #ffe66d;
  --glow: 0 0 18px #ff4da6, 0 0 40px #1a4cff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: "Fredoka", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 10% -10%, #3a1a6a 0%, transparent 50%),
              radial-gradient(900px 700px at 110% 10%, #1a4cff 0%, transparent 45%),
              linear-gradient(180deg, #070814 0%, #14102a 40%, #1a0a24 100%);
  color: #fff;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#beSky, .graph, .noise, #popLayer, #fxLayer {
  position: fixed; inset: 0; pointer-events: none;
}
#beSky { z-index: 0; width: 100%; height: 100%; }
.graph {
  z-index: 1;
  background-image:
    linear-gradient(rgba(77,163,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77,163,255,.12) 1px, transparent 1px);
  background-size: 28px 28px;
  mix-blend-mode: overlay;
}
.noise {
  z-index: 8; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#popLayer, #fxLayer { z-index: 30; overflow: hidden; }
#fxLayer { z-index: 31; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 8px; align-items: center;
  padding: calc(8px + var(--safe-t)) 10px 8px;
  background: rgba(7,8,20,.78);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--pink);
}
.logo { display: flex; align-items: center; gap: 6px; }
.logo-sheep { width: 28px; height: 28px; object-fit: cover; border-radius: 50%; border: 1.5px solid #fff; }
.logo-word {
  font-family: "Unbounded", sans-serif;
  font-size: 1.05rem; font-weight: 900;
  text-shadow: var(--glow);
}
.ticker { overflow: hidden; white-space: nowrap; min-width: 0; }
.ticker-track {
  display: inline-block;
  font-size: .72rem;
  letter-spacing: .14em;
  opacity: .8;
  will-change: transform;
  animation: marquee 28s linear infinite;
}
.score { font-size: .78rem; white-space: nowrap; }
.score strong { color: var(--yellow); font-family: "Unbounded", sans-serif; }

.splash, .end, .app {
  position: relative; z-index: 3;
  height: 100dvh;
  padding: calc(56px + var(--safe-t)) 16px calc(16px + var(--safe-b));
}

.splash, .end {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 14px;
}
.splash[hidden], .end[hidden], .app[hidden] { display: none; }

.splash {
  z-index: 25;
}
.welcome-card {
  position: relative;
  width: min(88vw, 360px);
  padding: 28px 22px 24px;
  background: linear-gradient(180deg, #fff8fb 0%, #ffe4f2 100%);
  color: #2a1030;
  border-radius: 28px;
  border: 3px solid #fff;
  box-shadow: 10px 14px 0 var(--pink), 0 20px 50px rgba(255, 77, 166, .28);
  animation: cardIn 1s cubic-bezier(.2, 1.3, .3, 1) both;
  transform-origin: center;
}
.welcome-card.go {
  animation: cardOut .65s ease-in forwards;
}
.w-tape {
  position: absolute; top: -10px;
  width: 58px; height: 18px;
  background: rgba(255, 230, 109, .8);
  transform: rotate(-8deg);
}
.w-tape.left { left: 22px; }
.w-tape.right { right: 22px; transform: rotate(10deg); }
.welcome-sheep {
  width: 96px; height: 96px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 8px 0 var(--pink);
  margin-bottom: 10px;
}
.welcome-sun {
  font-family: "Pacifico", cursive;
  color: #ff4da6;
  font-size: 1.35rem;
  margin-bottom: 6px;
}
.welcome-title {
  font-family: "Unbounded", sans-serif;
  font-size: clamp(1.25rem, 6.2vw, 1.7rem);
  line-height: 1.2;
  margin-bottom: 10px;
  color: #1a1024;
}
.welcome-sub {
  opacity: .7;
  font-size: .9rem;
  margin-bottom: 18px;
  color: #5a2a4a;
}
#startBtn[disabled] {
  opacity: .35;
  transform: scale(.92);
}
#startBtn.ready {
  opacity: 1;
  animation: beReady .9s ease-in-out infinite;
}
.splash-hint, .end p { opacity: .85; font-size: .95rem; max-width: 18rem; }
.end-kicker {
  font-weight: 800;
  color: var(--yellow);
  text-shadow: 0 0 14px var(--yellow);
  font-size: 1.12rem;
  line-height: 1.25;
  opacity: 1 !important;
  max-width: 92vw !important;
}
.girl-wrap {
  position: relative;
  width: min(86vw, 340px);
}
.girl-btn {
  display: block;
  width: 100%;
  border-radius: 28px;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 0 28px rgba(255, 77, 166, .45), 8px 10px 0 var(--pink);
  animation: girlBounce 1.8s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.tap-arrow {
  position: absolute;
  z-index: 2;
  font-size: 2rem;
  filter: drop-shadow(0 2px 0 #000);
  pointer-events: none;
  animation: tapPoint .7s ease-in-out infinite;
}
.tap-arrow.up {
  top: -8px; left: 50%;
  animation-name: tapPointDown;
}
@keyframes tapPointDown {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(8px) scale(1.18); }
}
.tap-arrow.left {
  left: -18px; top: 42%;
}
.tap-arrow.right {
  right: -18px; top: 42%;
}
.girl-btn img {
  width: 100%;
  max-height: 52dvh;
  height: auto;
  display: block;
  object-fit: cover;
  object-position: center 20%;
}
.girl-btn:active { transform: scale(.96); }

.app {
  display: flex; flex-direction: column; gap: 10px;
}

.progress {
  display: flex; gap: 4px;
}
.progress i {
  flex: 1; height: 3px; border-radius: 99px;
  background: rgba(255,255,255,.18);
}
.progress i.on { background: var(--yellow); }
.progress i.now { background: var(--pink); box-shadow: 0 0 8px var(--pink); }

.stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y;
}

.card {
  position: relative;
  width: min(100%, 420px);
  height: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: #111;
  border: 3px solid #fff;
  box-shadow: 8px 10px 0 var(--pink);
  transform-origin: center;
  will-change: transform;
}
.card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transform-origin: center;
}
.card img.anim-spin { animation: imgSpin 16s linear infinite; }
.card img.anim-spin-slow { animation: imgSpin 32s linear infinite reverse; }
.card img.anim-bounce { animation: imgBounce 1.35s ease-in-out infinite; }
.card img.anim-sway { animation: imgSway 3.4s ease-in-out infinite; }
.card img.anim-pulse { animation: imgPulse 1.8s ease-in-out infinite; }
.card img.anim-ken { animation: imgKen 7s ease-in-out infinite alternate; }
.card img.anim-wiggle { animation: imgWiggle .7s ease-in-out infinite; }
.card img.anim-float { animation: imgFloat 2.6s ease-in-out infinite; }
.card img.anim-tilt { animation: imgTilt 2.1s ease-in-out infinite; }
.card img.anim-jelly { animation: imgJelly 1.5s ease-in-out infinite; }
.card img.anim-shake { animation: imgShake 2.2s ease-in-out infinite; }
.card img.anim-zoom { animation: imgZoom 2.8s ease-in-out infinite; }
.card img.hit-glitch { animation: hitGlitch .35s steps(2) both; }
.card img.hit-pop { animation: hitPop .4s cubic-bezier(.2,1.6,.3,1) both; }
.card.hit-shake { animation: hitShake .4s ease both; }
.card-cap {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  text-shadow: 0 2px 0 #000, 0 0 16px #ff4da6;
  pointer-events: none;
}
.goal {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 4;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(7, 8, 20, .82);
  border: 2px solid var(--yellow);
  box-shadow: 0 8px 20px rgba(0,0,0,.45);
  pointer-events: none;
  text-align: center;
}
.goal-label {
  width: 100%;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.goal-need {
  width: 100%;
  font-family: "Unbounded", sans-serif;
  font-size: 1.25rem;
  line-height: 1.15;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--yellow);
}
.goal-progress {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ff8ad4;
}
.flies { position: absolute; inset: 0; overflow: hidden; }

.fly {
  position: absolute;
  border: 0; background: transparent;
  color: #fff;
  font-weight: 900;
  font-size: 1.5rem;
  text-shadow: 0 0 10px #1a4cff, 0 2px 0 #000;
  padding: 8px;
  min-width: 56px; min-height: 56px;
}

.mission {
  text-align: center;
  font-size: .82rem;
  opacity: .8;
  min-height: 1.2em;
}

.btn {
  border: 0; border-radius: 999px;
  padding: 12px 22px;
  font: 800 1.1rem "Fredoka", system-ui, sans-serif;
  color: #fff;
}
.btn.neon {
  background: linear-gradient(90deg, var(--pink), var(--blue));
  box-shadow: var(--glow);
}
.btn.fat { min-width: 92px; height: 52px; }
.btn:active { transform: scale(.94) rotate(-4deg); }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%) translateY(140%);
  z-index: 50;
  background: var(--yellow); color: #111;
  font-weight: 800; padding: 10px 16px; border-radius: 999px;
  box-shadow: 5px 5px 0 #000;
  transition: transform .22s;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.float-be {
  position: absolute;
  pointer-events: none;
  font-weight: 900;
}
.float-be.up { animation: floatOut .9s ease-out forwards; }
.float-be.spin { animation: floatSpin .85s ease-out forwards; }
.float-be.drop { animation: floatDrop .8s ease-in forwards; }
.float-be.zoom { animation: floatZoom .7s cubic-bezier(.2,1.7,.3,1) forwards; }

.flash {
  position: absolute; inset: 0;
  pointer-events: none;
  animation: flashOut .35s ease-out forwards;
}
.ring {
  position: absolute; width: 24px; height: 24px;
  border: 3px solid #fff; border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ringOut .7s ease-out forwards;
  pointer-events: none;
}
.confetti {
  position: absolute; width: 8px; height: 14px;
  pointer-events: none;
  animation: confettiOut .9s ease-in forwards;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(28px) rotate(-4deg) scale(.92); }
  to { opacity: 1; transform: translateY(0) rotate(-1.2deg) scale(1); }
}
@keyframes cardOut {
  to { opacity: 0; transform: translateY(-40px) rotate(8deg) scale(.8); }
}
@keyframes beReady {
  0%, 100% { transform: scale(1); box-shadow: 0 0 18px #ff4da6, 0 0 40px #1a4cff; }
  50% { transform: scale(1.08); box-shadow: 0 0 28px #ffe66d, 0 0 50px #ff4da6; }
}
@keyframes marquee {
  from { transform: translate3d(0,0,0); }
  to { transform: translate3d(-50%,0,0); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.06); }
}
@keyframes girlBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes tapPoint {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(0, 8px) scale(1.18); }
}
.tap-arrow.left { animation-name: tapPointL; }
.tap-arrow.right { animation-name: tapPointR; }
@keyframes tapPointL {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(8px, 0) scale(1.18); }
}
@keyframes tapPointR {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-8px, 0) scale(1.18); }
}
@keyframes floatOut {
  to { transform: translateY(-80px) scale(1.3) rotate(18deg); opacity: 0; }
}
@keyframes floatSpin {
  to { transform: translate(40px, -90px) rotate(420deg) scale(1.4); opacity: 0; }
}
@keyframes floatDrop {
  to { transform: translateY(90px) rotate(-30deg); opacity: 0; }
}
@keyframes floatZoom {
  0% { transform: scale(.2); opacity: 1; }
  80% { transform: scale(2.4); opacity: 1; }
  100% { transform: scale(2.8); opacity: 0; }
}
@keyframes flashOut { to { opacity: 0; } }
@keyframes ringOut { to { width: 220px; height: 220px; opacity: 0; } }
@keyframes confettiOut {
  to { transform: translate(var(--dx), var(--dy)) rotate(260deg); opacity: 0; }
}
@keyframes imgSpin { to { transform: rotate(360deg) scale(1.12); } }
@keyframes imgBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.06); }
}
@keyframes imgSway {
  0%, 100% { transform: rotate(-7deg); }
  50% { transform: rotate(7deg); }
}
@keyframes imgPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes imgKen {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.22) translate(-4%, 3%); }
}
@keyframes imgWiggle {
  0%, 100% { transform: rotate(-8deg) translateX(-4px); }
  50% { transform: rotate(8deg) translateX(4px); }
}
@keyframes imgFloat {
  0%, 100% { transform: translateY(8px) rotate(-2deg); }
  50% { transform: translateY(-14px) rotate(3deg); }
}
@keyframes imgTilt {
  0%, 100% { transform: perspective(400px) rotateY(-12deg) scale(1.04); }
  50% { transform: perspective(400px) rotateY(12deg) scale(1.04); }
}
@keyframes imgJelly {
  0%, 100% { transform: scale(1, 1); }
  30% { transform: scale(1.12, .9); }
  50% { transform: scale(.92, 1.1); }
  70% { transform: scale(1.06, .96); }
}
@keyframes imgShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-10px) rotate(-4deg); }
  75% { transform: translateX(10px) rotate(4deg); }
}
@keyframes imgZoom {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes hitGlitch {
  0% { transform: translate(0); filter: none; }
  25% { transform: translate(-8px, 3px); filter: hue-rotate(90deg) saturate(2); }
  50% { transform: translate(8px, -3px); filter: hue-rotate(220deg); }
  100% { transform: translate(0); filter: none; }
}
@keyframes hitPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18) rotate(-4deg); }
  100% { transform: scale(1); }
}
@keyframes hitShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px) rotate(-2deg); }
  40% { transform: translateX(12px) rotate(2deg); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}
