:root {
  --sky: #005cec;
  --hill: #7ab707;
  --ink: #11110d;
  --paper-yellow: #ffe56a;
  --tongue: #ff6b8a;
}

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

html,
body {
  min-height: 100%;
  background: var(--sky);
  color: #fff8dc;
  font-family: "Gochi Hand", "Comic Sans MS", cursive, sans-serif;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
}

.scene {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100dvh;
  min-height: 100svh;
  background:
    radial-gradient(140% 38% at 50% 120%, var(--hill) 0 48%, transparent 49%),
    var(--sky);
  overflow-x: hidden;
}

.mast {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  text-align: center;
  padding: max(16px, env(safe-area-inset-top)) 16px 8px;
}

h1 {
  font-family: "Freckle Face", "Comic Sans MS", cursive, sans-serif;
  font-size: clamp(3.2rem, 14vw, 7rem);
  line-height: 0.86;
  letter-spacing: 0.01em;
  color: var(--paper-yellow);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow:
    4px 5px 0 #062a86,
    -2px 0 0 #000,
    0 2px 0 #000;
  transform: rotate(-2.4deg);
}

.tag {
  margin-top: 0.45rem;
  font-size: clamp(1.1rem, 4.2vw, 1.9rem);
  color: #fff4c2;
  text-shadow: 2px 2px 0 #041f66;
  transform: rotate(1.6deg);
}

.hint {
  margin-top: 0.25rem;
  margin-bottom: 0.35rem;
  font-size: clamp(0.85rem, 2.8vw, 1.1rem);
  color: #d7ecff;
  opacity: 0.86;
  transform: rotate(-1deg);
}

.stage {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 100%;
  margin-top: clamp(18px, 3.6vh, 40px);
}

.hero-hit {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  cursor: pointer;
}

.hero {
  display: block;
  width: min(100%, calc((100dvh - 13.5rem) * 1.5));
  height: auto;
  max-height: calc(100dvh - 13.5rem);
  object-fit: contain;
  object-position: center top;
  user-select: none;
  -webkit-user-drag: none;
}

.hero-hit.bleating .hero {
  animation: bleat-jolt 280ms steps(3, end);
}

.grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.16;
  mix-blend-mode: multiply;
  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 type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.herd {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7%;
  height: 32%;
  z-index: 3;
  overflow: visible;
}

.goat {
  position: absolute;
  left: 0;
  bottom: 10%;
  background: none;
  border: 0;
  box-shadow: none;
  will-change: transform;
}

.goat img {
  display: block;
  width: auto;
  height: var(--goat-h, 120px);
  background: transparent;
  border: 0;
  outline: 0;
  box-shadow: none;
  filter: contrast(1.04) saturate(1.05);
  transform-origin: 50% 88%;
  will-change: transform;
}

.g1 {
  --goat-h: clamp(92px, 18vw, 150px);
  bottom: 8%;
  animation: cross-right 9.5s linear infinite;
}

.g1 img {
  animation: gait 0.58s infinite;
}

.g2 {
  --goat-h: clamp(68px, 13vw, 112px);
  bottom: 22%;
  animation: cross-left 12s linear infinite;
  animation-delay: -4s;
}

.g2 img {
  animation: gait 0.5s infinite;
  animation-delay: -0.18s;
}

.g3 {
  --goat-h: clamp(80px, 15vw, 130px);
  bottom: 4%;
  animation: cross-right 14.5s linear infinite;
  animation-delay: -8s;
}

.g3 img {
  animation: gait 0.66s infinite;
  animation-delay: -0.3s;
}

.g4 {
  --goat-h: clamp(58px, 11vw, 96px);
  bottom: 28%;
  animation: cross-left 10.8s linear infinite;
  animation-delay: -2s;
}

.g4 img {
  animation: gait 0.46s infinite;
}

.dock {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  justify-content: center;
  align-items: center;
  width: min(92vw, 560px);
}

.dock[hidden] {
  display: none !important;
}

.buy,
.ca {
  font-family: "Freckle Face", "Gochi Hand", cursive, sans-serif;
  border: 3px solid var(--ink);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 4px 4px 0 #041f66;
  cursor: pointer;
}

.buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  padding: 10px 22px;
  background: var(--paper-yellow);
  font-size: 1.7rem;
  transform: rotate(-2deg);
}

.buy:hover {
  background: #fff19a;
}

.ca {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  max-width: min(92vw, 420px);
  padding: 9px 14px 8px;
  background: #c6f34a;
  font-size: 1.05rem;
  transform: rotate(1.4deg);
}

.ca-label {
  font-family: "Freckle Face", cursive, sans-serif;
  font-size: 1.25rem;
}

.ca-value {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 58vw;
}

.ca-flash {
  display: none;
  position: absolute;
  right: 8px;
  top: -18px;
  background: var(--tongue);
  color: #fff;
  border: 2px solid var(--ink);
  padding: 0 6px;
  font-size: 0.9rem;
  transform: rotate(-8deg);
}

.ca.copied .ca-flash {
  display: block;
}

@keyframes bleat-jolt {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  30% {
    transform: translate(-6px, 3px) rotate(-1.4deg) scale(1.015);
  }
  60% {
    transform: translate(7px, -4px) rotate(1.6deg) scale(1.03);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes cross-right {
  from {
    transform: translateX(-26vw);
  }
  to {
    transform: translateX(112vw);
  }
}

@keyframes cross-left {
  from {
    transform: translateX(112vw) scaleX(-1);
  }
  to {
    transform: translateX(-26vw) scaleX(-1);
  }
}

@keyframes gait {
  0% {
    transform: translateY(0) rotate(-14deg) skewX(12deg) scaleY(1.12);
  }
  18% {
    transform: translateY(-22px) rotate(-6deg) skewX(4deg) scaleY(0.88);
  }
  34% {
    transform: translateY(-34px) rotate(0deg) skewX(0deg) scaleY(0.82);
  }
  50% {
    transform: translateY(0) rotate(13deg) skewX(-12deg) scaleY(1.14);
  }
  68% {
    transform: translateY(-20px) rotate(5deg) skewX(-3deg) scaleY(0.9);
  }
  84% {
    transform: translateY(-30px) rotate(-1deg) skewX(2deg) scaleY(0.84);
  }
  100% {
    transform: translateY(0) rotate(-14deg) skewX(12deg) scaleY(1.12);
  }
}

@media (max-width: 640px) {
  .mast {
    padding: max(12px, env(safe-area-inset-top)) 12px 6px;
  }

  h1 {
    font-size: clamp(2.8rem, 18vw, 4.8rem);
    -webkit-text-stroke: 1.6px var(--ink);
  }

  .stage {
    margin-top: clamp(22px, 4.2vh, 36px);
  }

  .hero {
    width: min(100%, calc((100dvh - 12.5rem) * 1.5));
    max-height: calc(100dvh - 12.5rem);
  }

  .herd {
    height: 36%;
    bottom: 6%;
  }

  .dock {
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .ca-value {
    max-width: 52vw;
  }

  .g1 {
    --goat-h: clamp(70px, 22vw, 114px);
  }

  .g2 {
    --goat-h: clamp(52px, 16vw, 88px);
  }

  .g3 {
    --goat-h: clamp(62px, 19vw, 102px);
  }

  .g4 {
    --goat-h: clamp(46px, 14vw, 80px);
  }
}
