/* ═══════════════════════════════════════════
   Ending overlay & blackout
   ═══════════════════════════════════════════ */

#scene-container.scene-ending-dim::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 9997;
}

/* ── Full-screen backdrop ── */
#ending-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  z-index: 20000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  user-select: none;
}

#ending-overlay::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

#ending-overlay.visible {
  display: flex;
  animation: overlayEnter 0.8s ease-out forwards;
}

@keyframes overlayLeave {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes endingContentLeave {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(14px); }
}

#ending-overlay.leaving {
  display: flex;
  pointer-events: none;
  animation: overlayLeave 0.76s ease forwards;
}

#ending-overlay.leaving #ending-video-container,
#ending-overlay.leaving #ending-close-btn {
  animation: endingContentLeave 0.58s ease forwards;
}

#ending-overlay.visible #ending-video-container {
  animation: videoSlideIn 0.7s ease-out 0.25s both;
}

#ending-overlay.visible #ending-close-btn {
  animation: videoSlideIn 0.5s ease-out 0.5s both;
}

/* ── Video container ── */
#ending-video-container {
  position: relative;
  width: 85vw;
  background: #000;
  border-radius: 1.2vmin;
  overflow: hidden;
  box-shadow: 0 0 6vmin rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(180, 151, 77, 0.5);
}

/* ── Video element ── */
#ending-video {
  width: 100%;
  display: block;
  max-height: 80vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

#ending-video::-webkit-media-controls-panel {
  background: rgba(0, 0, 0, 0.8);
}

/* ── Next Day button ── */
#ending-close-btn {
  margin-top: 2vh;
  padding: 1vh 3.6vw;
  font-size: 1.5vmin;
  font-weight: 600;
  color: #B4974D;
  background: transparent;
  border: 2px solid rgba(180, 151, 77, 0.5);
  border-radius: 0.8vmin;
  cursor: pointer;
  letter-spacing: 0.05vmin;
  transition: all 0.3s ease;
}

#ending-close-btn:hover {
  background: rgba(180, 151, 77, 0.15);
  border-color: #B4974D;
}

/* ── Fullscreen button ── */
#custom-fullscreen-btn {
  position: absolute;
  bottom: 1vmin;
  right: 1vmin;
  width: 4vmin;
  height: 4vmin;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 0.6vmin;
  color: #FFF;
  font-size: 2vmin;
  cursor: pointer;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  transition: background 0.2s;
}

#custom-fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* ── Blackout (hard reset / scene cover) ── */
#blackout {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 30000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.85s ease-in-out;
}

#blackout.active {
  opacity: 1;
  pointer-events: all;
}
