:root {
  color-scheme: light;
  --cream: #fff2dc;
  --amber: #ffb400;
  --amber-dark: #d98400;
  --gray: #78736d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button {
  font: inherit;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--cream);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#dog {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 76px 24px 96px;
}

#dog-card {
  position: relative;
  width: min(76vw, 440px);
  aspect-ratio: 1;
  transform-origin: 50% 86%;
  filter: drop-shadow(0 18px 28px rgba(98, 90, 79, .18));
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

#dog-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

#dog-open {
  position: absolute;
  inset: 0;
  opacity: 0;
}

#dog-card.is-speaking #dog-open {
  opacity: 1;
}

#dog-card.is-speaking #dog-close {
  opacity: 0;
}

#dog-card.is-tapped {
  animation: dog-tap .28s ease-out;
}

#dog-card:focus-visible {
  filter:
    drop-shadow(0 18px 28px rgba(98, 90, 79, .18))
    drop-shadow(0 0 0 5px rgba(255, 180, 0, .34));
}

@keyframes dog-tap {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  42% {
    transform: translateY(-12px) scale(1.025);
  }
  72% {
    transform: translateY(2px) scale(.995);
  }
}

#sound-bubble {
  position: absolute;
  top: 18%;
  right: -1%;
  color: var(--amber-dark);
  font: 900 clamp(30px, 8vw, 52px)/1 Georgia, serif;
  opacity: 0;
  transform: translateY(10px) rotate(7deg) scale(.75);
  pointer-events: none;
}

#sound-bubble.is-visible {
  animation: bubble-pop .38s ease-out;
}

@keyframes bubble-pop {
  0% {
    opacity: 0;
    transform: translateY(10px) rotate(7deg) scale(.75);
  }
  34% {
    opacity: 1;
    transform: translateY(0) rotate(7deg) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px) rotate(7deg) scale(.94);
  }
}

.signature {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 10;
  width: 150px;
  text-align: right;
  color: rgba(120, 115, 109, .62);
  pointer-events: none;
}

.signature span {
  display: block;
  font-size: 9px;
}

.signature strong {
  display: block;
  margin-top: 4px;
  color: var(--amber-dark);
  font-size: 17px;
}

#start-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 242, 220, .86);
  cursor: pointer;
  transition: opacity .32s ease, visibility .32s;
}

#start-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#start-overlay h1 {
  margin: 0;
  color: var(--amber);
  font-size: clamp(40px, 12vw, 68px);
  font-weight: 950;
}

#start-overlay h1 em {
  color: var(--gray);
  font-style: normal;
}

#start-overlay p {
  margin: 18px 0 8px;
  color: var(--gray);
  font-size: 14px;
}

#start-overlay small {
  color: rgba(120, 115, 109, .68);
  font-size: 12px;
}

#status {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 15;
  max-width: calc(100% - 48px);
  padding: 9px 14px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .9);
  color: var(--gray);
  font-size: 12px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

#status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 520px) {
  #dog {
    padding-inline: 18px;
  }

  #dog-card {
    width: min(82vw, 360px);
  }

  .signature {
    width: 132px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
