html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  height: 100%;
}

.stage {
  position: relative;
  width: min(96vmin, 900px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  isolation: isolate;

  /* NEU: gesamtes Motiv nach unten */
  padding-top: 90px;
  box-sizing: border-box;
}


.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Hand wippt nur wenn Opa wach ist */
#hand {
  transform: translateY(0);
  transform-origin: 50% 50%;
  will-change: transform;
}

.awake #hand {
  animation: handBob 4.5s ease-in-out infinite;
}

@keyframes handBob {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-1.2%); }
  100% { transform: translateY(0); }
}

/* Sprechblase passt sich an Text an */
.bubble{
  position: absolute;
  left: 50%;
  top: 2%;                    /* höher als vorher */
  transform: translateX(-50%);
  width: fit-content;
  max-width: min(86%, 760px);
  padding: 16px 18px 20px;    /* unten etwas mehr Luft */
  background: rgba(255,255,255,0.96);
  border: 2px solid rgba(0,0,0,0.25);
  border-radius: 18px;
  font-family: system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.25;
  color: #111;
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
  pointer-events: none;
  white-space: pre-wrap;
  z-index: 999;

  /* WICHTIG: Abstand zum Kopf erzwingen */
  margin-bottom: 80px;
}


.bubble::after{
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;              /* nicht mehr so tief */
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(255,255,255,0.96);
  filter: drop-shadow(0 -1px 0 rgba(0,0,0,0.25));
}

/* Mund lebt minimal, wenn Opa wach aber still ist */
.idle-mouth #mund-zu{
  animation: mouthBob 3.8s ease-in-out infinite;
  transform-origin: 50% 60%;
}

@keyframes mouthBob{
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-0.35%); }
  100% { transform: translateY(0); }
}

/* Hundmund sicher vor Lou */
#hund { z-index: 10; }
#hund-mund-zu, #hund-mund-auf {
  z-index: 50;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: opacity, transform;
}

/* Schnarch Texte: genau da, wo die Bubble sitzt */
.snore{
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(18px, 3.2vmin, 34px);
  color: rgba(0,0,0,0.75);
  text-shadow: 0 3px 10px rgba(0,0,0,0.10);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  white-space: nowrap;
}

.snore.pop {
  animation: snorePop 1.4s ease-out forwards;
}

@keyframes snorePop{
  0%   { opacity: 0; transform: translateX(-50%) scale(0.85); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(-10px) scale(1.02); }
  70%  { opacity: 0.95; transform: translateX(-50%) translateY(-28px) scale(1.02); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-42px) scale(1.00); }
}

@media (max-width: 600px){
  .stage{
    padding-top: 120px;
  }
}
