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

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #05060a;
  position: fixed;
  inset: 0;
  touch-action: none;
}

#scene {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: default;
}

.bubble {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, calc(-100% - 12px)) scale(0.6);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  background: #f4e8c8;
  color: #1a1210;
  border: 4px solid #1a1210;
  padding: 14px 18px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(8px, 2.8vw, 16px);
  line-height: 1.45;
  letter-spacing: 0.02em;
  white-space: nowrap;
  image-rendering: pixelated;
  box-shadow:
    4px 4px 0 #1a1210,
    inset 0 0 0 2px #c9b896;
  animation: bubble-pop 4.5s ease-in-out infinite;
  will-change: transform, opacity;
  max-width: min(90vw, 320px);
}

.bubble-tail {
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 16px;
  height: 16px;
  background: #f4e8c8;
  border-right: 4px solid #1a1210;
  border-bottom: 4px solid #1a1210;
  transform: translateX(-50%) rotate(45deg);
}

.bubble-text {
  display: block;
  position: relative;
  z-index: 1;
}

@keyframes bubble-pop {
  0%,
  12% {
    opacity: 0;
    transform: translate(-50%, calc(-100% + 6px)) scale(0.55);
  }
  22%,
  72% {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 12px)) scale(1);
  }
  82%,
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 22px)) scale(0.9);
  }
}

@media (max-width: 700px) {
  .bubble {
    padding: 10px 12px;
    border-width: 3px;
    box-shadow:
      3px 3px 0 #1a1210,
      inset 0 0 0 1px #c9b896;
    white-space: normal;
    text-align: center;
  }

  .bubble-tail {
    width: 12px;
    height: 12px;
    bottom: -10px;
    border-right-width: 3px;
    border-bottom-width: 3px;
  }
}

@media (max-width: 400px) {
  .bubble {
    padding: 8px 10px;
    font-size: clamp(7px, 3.4vw, 11px);
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .bubble {
    padding: 6px 10px;
    font-size: clamp(7px, 2.2vh, 12px);
  }
}
