* {
  box-sizing: border-box;
}

:root {
  --fur: #a96d3e;
  --fur-dark: #7e4826;
  --fur-soft: #c98a55;
  --cream: #ffd5a6;
  --cream-light: #ffe2bd;
  --ink: #43271a;
  --blush: #ff8fa8;
  --sky: #a8ddff;
  --sky-soft: #e9fbff;
  --grass: #71c96f;
  --grass-dark: #3c9f62;
  --flower: #ffcf5b;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family:
    Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  background:
    linear-gradient(180deg, var(--sky) 0%, var(--sky-soft) 58%, #b8efb2 58%, var(--grass) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  left: -8vw;
  right: -8vw;
  bottom: -10svh;
  height: 33svh;
  pointer-events: none;
  z-index: -2;
}

body::before {
  background:
    radial-gradient(ellipse at 20% 100%, #59ba68 0 46%, transparent 47%),
    radial-gradient(ellipse at 62% 100%, #88db76 0 42%, transparent 43%),
    radial-gradient(ellipse at 92% 100%, #4ebf70 0 38%, transparent 39%);
}

body::after {
  bottom: 0;
  height: 18svh;
  background:
    linear-gradient(160deg, transparent 0 46%, rgba(255, 255, 255, 0.2) 47% 50%, transparent 51%),
    repeating-linear-gradient(95deg, transparent 0 18px, rgba(53, 139, 83, 0.2) 19px 21px);
  opacity: 0.75;
  z-index: -1;
}

.scene {
  position: relative;
  display: flex;
  min-height: 100svh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: clamp(16px, 3svh, 28px);
  padding: 28px 18px 38px;
  isolation: isolate;
}

.bear-stage {
  position: relative;
  display: grid;
  width: min(92vw, 560px);
  place-items: center;
}

.bear-stage.unlocked {
  animation: stageGlow 900ms ease-out;
}

.heart-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 15;
}

.bear {
  --pupil-x: 0px;
  --pupil-y: 0px;
  --head-tilt: 0deg;
  --ear-x: 0px;
  --ear-y: 0px;
  --ear-tilt: 0deg;
  position: relative;
  width: min(76vw, 360px, 56svh);
  aspect-ratio: 360 / 430;
  transform-origin: 50% 84%;
  filter: drop-shadow(0 18px 24px rgba(91, 56, 35, 0.2));
}

.ground-shadow {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 72%;
  height: 10%;
  border-radius: 50%;
  background: rgba(52, 82, 49, 0.2);
  transform: translateX(-50%);
  filter: blur(3px);
}

.ear {
  position: absolute;
  top: 7%;
  width: 27%;
  aspect-ratio: 1;
  border: clamp(4px, 1.4vw, 7px) solid var(--fur-dark);
  border-radius: 50%;
  background: var(--fur);
  transition: transform 90ms ease-out;
  z-index: 2;
}

.ear::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: inherit;
  background: #f0ab7b;
  box-shadow: inset 0 0 0 5px rgba(126, 72, 38, 0.1);
}

.ear-left {
  left: 12%;
  transform: translate(var(--ear-x), var(--ear-y)) rotate(var(--ear-tilt));
  transform-origin: 74% 80%;
}

.ear-right {
  right: 12%;
  transform: translate(var(--ear-x), var(--ear-y)) rotate(var(--ear-tilt));
  transform-origin: 26% 80%;
}

.head {
  position: absolute;
  left: 50%;
  top: 10%;
  width: 72%;
  height: 50%;
  border: clamp(4px, 1.4vw, 7px) solid var(--fur-dark);
  border-radius: 47% 47% 45% 45%;
  background:
    radial-gradient(circle at 33% 28%, rgba(255, 255, 255, 0.22) 0 11%, transparent 12%),
    var(--fur);
  transform: translateX(-50%) rotate(var(--head-tilt));
  transform-origin: 50% 70%;
  transition: transform 90ms ease-out;
  z-index: 6;
}

.eye {
  position: absolute;
  top: 31%;
  width: 18%;
  height: 22%;
  overflow: hidden;
  border: 4px solid #5e351f;
  border-radius: 50%;
  background: #fffaf3;
  box-shadow: inset 0 -7px 0 rgba(80, 50, 30, 0.05);
}

.eye-left {
  left: 27%;
}

.eye-right {
  right: 27%;
}

.glasses {
  position: absolute;
  left: 50%;
  top: 30%;
  display: flex;
  width: 56%;
  height: 25%;
  align-items: center;
  justify-content: center;
  gap: 2%;
  opacity: 0;
  transform: translateX(-50%) scale(0.88) translateY(-6px);
  transform-origin: 50% 50%;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 4;
}

.lens {
  width: 41%;
  height: 78%;
  border: clamp(4px, 1.15vw, 6px) solid #161616;
  border-radius: 38% 38% 45% 45%;
  background: linear-gradient(135deg, #0f0f0f 0 62%, #333333 63% 100%);
  box-shadow:
    inset 6px 7px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 rgba(67, 39, 26, 0.18);
}

.bridge {
  width: 12%;
  height: clamp(5px, 1.2vw, 8px);
  border-radius: 999px;
  background: #161616;
}

.pupil {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #2c1b14;
  transform: translate(calc(-50% + var(--pupil-x)), calc(-50% + var(--pupil-y)));
  transition: transform 60ms ease-out;
}

.pupil::after {
  content: "";
  position: absolute;
  right: 16%;
  top: 15%;
  width: 32%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffffff;
}

.snout {
  position: absolute;
  left: 50%;
  bottom: 13%;
  width: 44%;
  height: 32%;
  border-radius: 46% 46% 52% 52%;
  background: var(--cream);
  transform: translateX(-50%);
  box-shadow: inset 0 -8px 0 rgba(126, 72, 38, 0.08);
}

.nose {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 31%;
  height: 24%;
  border-radius: 46% 46% 55% 55%;
  background: #4d2a1d;
  transform: translateX(-50%);
}

.nose::after {
  content: "";
  position: absolute;
  left: 21%;
  top: 17%;
  width: 18%;
  height: 16%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.mouth {
  position: absolute;
  left: 50%;
  top: 43%;
  width: 53%;
  height: 29%;
  border-bottom: clamp(4px, 1.3vw, 7px) solid #5a3021;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
  transition: height 180ms ease, width 180ms ease, border-color 180ms ease;
}

.tongue {
  position: absolute;
  left: 50%;
  bottom: 9%;
  width: 29%;
  height: 18%;
  border-radius: 0 0 999px 999px;
  background: #ff7d94;
  opacity: 0;
  transform: translateX(-50%) translateY(-3px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.cheek {
  position: absolute;
  top: 56%;
  width: 15%;
  height: 10%;
  border-radius: 50%;
  background: rgba(255, 143, 168, 0.52);
  transform: scale(0.94);
  transition: transform 180ms ease, background 180ms ease;
}

.cheek-left {
  left: 17%;
}

.cheek-right {
  right: 17%;
}

.body {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 66%;
  height: 52%;
  border: clamp(4px, 1.4vw, 7px) solid var(--fur-dark);
  border-radius: 48% 48% 42% 42%;
  background:
    radial-gradient(circle at 34% 18%, rgba(255, 255, 255, 0.18) 0 13%, transparent 14%),
    linear-gradient(180deg, var(--fur-soft), var(--fur) 54%, #985b32);
  transform: translateX(-50%);
  z-index: 4;
}

.suit {
  position: absolute;
  inset: -1% 2% 0;
  overflow: hidden;
  border-radius: 45% 45% 39% 39%;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 240ms ease, transform 240ms ease;
  z-index: 1;
}

.suit::before,
.suit::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: -3%;
  width: 58%;
  background: linear-gradient(180deg, #202020, #080808);
}

.suit::before {
  left: -5%;
  border-radius: 55% 0 0 43%;
  transform: skewX(-12deg);
}

.suit::after {
  right: -5%;
  border-radius: 0 55% 43% 0;
  transform: skewX(12deg);
}

.shirt {
  position: absolute;
  left: 50%;
  top: 0;
  width: 36%;
  height: 86%;
  border-radius: 0 0 999px 999px;
  background: #fff8ec;
  transform: translateX(-50%);
  z-index: 2;
}

.shirt::before,
.shirt::after {
  content: "";
  position: absolute;
  top: 0;
  width: 58%;
  height: 26%;
  background: #ffffff;
  clip-path: polygon(0 0, 100% 0, 48% 100%);
}

.shirt::before {
  left: 0;
}

.shirt::after {
  right: 0;
  transform: scaleX(-1);
}

.tie {
  position: absolute;
  left: 50%;
  top: 18%;
  width: 13%;
  height: 58%;
  background: linear-gradient(180deg, #202020, #050505);
  clip-path: polygon(50% 0, 92% 23%, 68% 100%, 32% 100%, 8% 23%);
  transform: translateX(-50%);
  z-index: 4;
}

.lapel {
  position: absolute;
  top: 4%;
  width: 33%;
  height: 72%;
  background: linear-gradient(180deg, #2b2b2b, #101010);
  clip-path: polygon(0 0, 100% 20%, 50% 100%);
  z-index: 3;
}

.lapel-left {
  left: 15%;
  transform: scaleX(-1);
}

.lapel-right {
  right: 15%;
}

.belly {
  position: absolute;
  left: 50%;
  top: 24%;
  width: 67%;
  height: 61%;
  cursor: pointer;
  border: 0;
  border-radius: 49% 49% 45% 45%;
  background:
    radial-gradient(circle at 34% 25%, rgba(255, 255, 255, 0.52) 0 12%, transparent 13%),
    var(--cream-light);
  box-shadow:
    inset 0 -11px 0 rgba(201, 138, 85, 0.18),
    0 4px 0 rgba(126, 72, 38, 0.2);
  transform: translateX(-50%);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.belly::before,
.belly::after {
  content: "";
  position: absolute;
  left: 50%;
  background: rgba(126, 72, 38, 0.28);
  transform: translateX(-50%);
}

.belly::before {
  top: 52%;
  width: 8%;
  height: 8%;
  border-radius: 50%;
}

.belly::after {
  top: 60%;
  width: 22%;
  height: 12%;
  border-radius: 0 0 999px 999px;
  border-bottom: 3px solid rgba(126, 72, 38, 0.25);
  background: transparent;
}

.belly:hover,
.belly:focus-visible {
  filter: brightness(1.04);
  transform: translateX(-50%) scale(1.025);
}

.belly:focus-visible {
  outline: 4px solid #ffcf5b;
  outline-offset: 5px;
}

.arm {
  position: absolute;
  top: 47%;
  width: 21%;
  height: 35%;
  border: clamp(4px, 1.4vw, 7px) solid var(--fur-dark);
  border-radius: 42% 42% 48% 48%;
  background: linear-gradient(180deg, var(--fur-soft), var(--fur));
  z-index: 3;
}

.arm-left {
  left: 9%;
  transform: rotate(23deg);
  transform-origin: 88% 14%;
}

.arm-right {
  right: 9%;
  transform: rotate(-23deg);
  transform-origin: 12% 14%;
}

.arm::before,
.arm::after {
  content: "";
  position: absolute;
  left: 50%;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 220ms ease;
}

.arm::before {
  bottom: 12%;
  width: 72%;
  height: 14%;
  border-radius: 999px;
  background: #fff8ec;
  z-index: 1;
}

.arm::after {
  bottom: -5%;
  width: 72%;
  height: 27%;
  border: 4px solid var(--fur-dark);
  border-radius: 48% 48% 54% 54%;
  background: linear-gradient(180deg, var(--fur-soft), var(--fur));
  z-index: 2;
}

.foot {
  position: absolute;
  bottom: -8%;
  width: 36%;
  height: 24%;
  border: clamp(4px, 1.4vw, 7px) solid var(--fur-dark);
  border-radius: 48% 48% 55% 55%;
  background: #8f522f;
  z-index: 5;
}

.foot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 27%;
  width: 45%;
  height: 42%;
  border-radius: 50%;
  background: #f0b17e;
  transform: translateX(-50%);
}

.foot-left {
  left: 4%;
  transform: rotate(7deg);
}

.foot-right {
  right: 4%;
  transform: rotate(-7deg);
}

.caption {
  width: min(92vw, 720px);
  text-align: center;
  text-wrap: balance;
}

.caption h1,
.caption p {
  margin: 0;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}

.caption h1 {
  font-size: clamp(1.6rem, 5vw, 2.65rem);
  line-height: 1.05;
  font-weight: 850;
}

.caption p {
  margin-top: 10px;
  color: #5d3a28;
  font-size: clamp(1rem, 3.3vw, 1.35rem);
  font-weight: 750;
  line-height: 1.25;
}

.invite-button {
  position: absolute;
  left: 50%;
  top: 5%;
  z-index: 12;
  min-width: 128px;
  cursor: pointer;
  border: 4px solid #111111;
  border-radius: 999px;
  padding: 12px 22px 13px;
  color: #ffffff;
  font: inherit;
  font-size: clamp(1rem, 3.2vw, 1.24rem);
  font-weight: 900;
  letter-spacing: 0;
  background: #151515;
  box-shadow:
    0 9px 0 rgba(67, 39, 26, 0.28),
    0 16px 24px rgba(67, 39, 26, 0.22);
  transform: translate(-50%, -130%) scale(0.9);
  opacity: 0;
  transition:
    opacity 220ms ease,
    transform 220ms cubic-bezier(0.2, 1.25, 0.34, 1),
    filter 160ms ease;
}

.invite-button::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 22px;
  height: 22px;
  border-right: 4px solid #111111;
  border-bottom: 4px solid #111111;
  background: #151515;
  transform: translateX(-50%) rotate(45deg);
  z-index: -1;
}

.invite-button:hover,
.invite-button:focus-visible {
  filter: brightness(1.12);
  transform: translate(-50%, -130%) scale(1);
}

.invite-button:focus-visible {
  outline: 4px solid #ffcf5b;
  outline-offset: 5px;
}

.invite-button:not([hidden]) {
  opacity: 1;
  transform: translate(-50%, -130%) scale(1);
}

.bear.agent .glasses {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.bear.agent .suit {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.bear.agent .belly {
  opacity: 0;
  transform: translateX(-50%) scale(0.78);
  pointer-events: none;
}

.bear.agent .body {
  border-color: #111111;
  background:
    radial-gradient(circle at 34% 16%, rgba(255, 255, 255, 0.12) 0 12%, transparent 13%),
    linear-gradient(180deg, #1f1f1f, #090909 68%, #030303);
}

.bear.agent .arm {
  border-color: #111111;
  background: linear-gradient(180deg, #1f1f1f, #080808);
  box-shadow: inset 0 -12px 0 rgba(255, 255, 255, 0.04);
}

.bear.agent .arm::before,
.bear.agent .arm::after {
  opacity: 1;
}

.bear.agent .foot {
  border-color: #111111;
  background: linear-gradient(180deg, #1b1b1b, #050505);
}

.bear.agent .foot::after {
  background: linear-gradient(180deg, #2d2d2d, #080808);
}

.bear.agent .cheek {
  background: rgba(255, 116, 147, 0.74);
}

.bear.agent .mouth {
  width: 43%;
  height: 22%;
}

.heart {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--heart-size);
  aspect-ratio: 1;
  border-radius: 25% 25% 9% 25%;
  background: var(--heart-color);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.3);
  animation: heartFloat var(--heart-duration) ease-out forwards;
  box-shadow: 0 10px 18px rgba(145, 57, 76, 0.16);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
}

.heart::before {
  left: -50%;
  top: 0;
}

.heart::after {
  left: 0;
  top: -50%;
}

.bear.tickled {
  animation: happyBounce 520ms ease-in-out 3;
}

.bear.tickled .head {
  transform: translateX(-50%) rotate(var(--head-tilt)) scale(1.025);
}

.bear.tickled .ear-left {
  animation: earWiggleLeft 280ms ease-in-out 5;
}

.bear.tickled .ear-right {
  animation: earWiggleRight 280ms ease-in-out 5;
}

.bear.tickled .arm-left {
  animation: leftArmWave 240ms ease-in-out 7;
}

.bear.tickled .arm-right {
  animation: rightArmWave 240ms ease-in-out 7;
}

.bear.tickled .belly {
  animation: bellyGiggle 300ms ease-in-out 6;
  box-shadow:
    inset 0 -11px 0 rgba(201, 138, 85, 0.14),
    0 0 0 10px rgba(255, 207, 91, 0.18),
    0 7px 0 rgba(126, 72, 38, 0.16);
}

.bear.tickled .cheek {
  background: rgba(255, 116, 147, 0.86);
  transform: scale(1.18);
}

.bear.tickled .mouth {
  width: 63%;
  height: 40%;
  border-color: #43271a;
}

.bear.tickled .tongue {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bear.tickled .pupil {
  transform: translate(calc(-50% + var(--pupil-x)), calc(-50% + var(--pupil-y))) scale(1.08);
}

@keyframes heartFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0.3);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--heart-drift)), calc(-50% + var(--heart-rise)))
      rotate(calc(45deg + var(--heart-spin)))
      scale(1);
  }
}

@keyframes happyBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  45% {
    transform: translateY(-3.5%) scale(1.025);
  }
}

@keyframes bellyGiggle {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  50% {
    transform: translateX(-50%) scale(1.06, 0.96);
  }
}

@keyframes leftArmWave {
  0%,
  100% {
    transform: rotate(23deg);
  }

  50% {
    transform: rotate(39deg) translateY(-2%);
  }
}

@keyframes rightArmWave {
  0%,
  100% {
    transform: rotate(-23deg);
  }

  50% {
    transform: rotate(-39deg) translateY(-2%);
  }
}

@keyframes earWiggleLeft {
  0%,
  100% {
    transform: translate(var(--ear-x), var(--ear-y)) rotate(var(--ear-tilt));
  }

  50% {
    transform: translate(var(--ear-x), var(--ear-y)) rotate(calc(var(--ear-tilt) - 9deg));
  }
}

@keyframes earWiggleRight {
  0%,
  100% {
    transform: translate(var(--ear-x), var(--ear-y)) rotate(var(--ear-tilt));
  }

  50% {
    transform: translate(var(--ear-x), var(--ear-y)) rotate(calc(var(--ear-tilt) + 9deg));
  }
}

@keyframes stageGlow {
  0% {
    filter: drop-shadow(0 0 0 rgba(255, 207, 91, 0));
  }

  45% {
    filter: drop-shadow(0 0 24px rgba(255, 207, 91, 0.72));
  }

  100% {
    filter: drop-shadow(0 0 0 rgba(255, 207, 91, 0));
  }
}

@media (max-height: 640px) {
  .scene {
    gap: 10px;
    padding-block: 16px 22px;
  }

  .bear {
    width: min(68vw, 300px, 50svh);
  }

  .caption h1 {
    font-size: clamp(1.3rem, 4vw, 2rem);
  }

  .caption p {
    font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
