#upsideCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;

  pointer-events: none;
  z-index: 9999;

  background: transparent;
}


#pageWrapper {
  transform-origin: center center;
}

body.inverted #pageWrapper {
  transform: rotate(180deg);
}

#redFade {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 10000;
}

#redFade.active {
  opacity: 1;
}

#grayOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(128,128,128,0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 9998; /* atrás do canvas */
}

body.inverted #grayOverlay {
  opacity: 1;
}

/* Overlay */
#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 10000;
}

/* Modal */
#upsideModal {
  position: fixed;
  top: 50%;
  right: -400px; /* fora da tela */
  transform: translateY(-50%);
  z-index: 10001;
  transition: right 0.6s ease, opacity 0.4s ease;
  opacity: 0;
}

#upsideModal.active {
  right: 20px; /* entra na tela */
  opacity: 1;
}

#upsideModal .modal-content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 1.2rem 1.4rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  max-width: 420px;
}

/* container de texto */
#upsideModal .modal-content > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%; /* 🔥 ESSENCIAL */
}

#upsideModal img {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* sair mundo invertido mobile*/
#exitUpsideBtn {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;

  background: rgba(120, 0, 0, 0.9);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.5px;

  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* aparece só no mundo invertido */
body.inverted #exitUpsideBtn {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* desktop: não mostrar */
@media (min-width: 768px) {
  #exitUpsideBtn {
    display: none;
  }
}
