/* Base */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #e6e6e6;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Hide cursor when idle (no UI) */
body.no-cursor,
body.no-cursor * { cursor: none !important; }

/* Stage centers the video and clips overflow */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;          /* critical: clip any transform overflow */
  background: #000;
}

/* Video always sized to viewport box; object-fit handles cover/contain */
#video {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  display: block;
  object-fit: contain;
  object-position: center;
  background: #000;
  transform-origin: center center;
}

/* Fit modes */
body.cover   #video { object-fit: cover;   }
body.contain #video { object-fit: contain; }

/* --- ROTATION LOGIC FIX --- */
/* When 0 or 180, width matches viewport width */
body.rot0   #video,
body.rot180 #video {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  transform: rotate(0deg);
}
body.rot180 #video { transform: rotate(180deg); }

/* When 90 or 270, SWAP dimensions so the 'height' fills the 'width' */
body.rot90  #video,
body.rot270 #video {
  width: 100vh;      /* Width becomes viewport height */
  height: 100vw;     /* Height becomes viewport width */
  max-width: 100vh;
  max-height: 100vw;
}
body.rot90  #video { transform: rotate(90deg); }
body.rot270 #video { transform: rotate(270deg); }
/* -------------------------- */

/* Toolbar: fast fade in/out */
.ui {
  position: fixed;
  right: 12px;
  top: 12px;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s linear;
  z-index: 10;
}
.ui-visible .ui {
  opacity: 1;
  pointer-events: auto;
}
.ui button {
  background: rgba(0,0,0,.55);
  color: #e6e6e6;
  border: 1px solid rgba(255,255,255,.25);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.ui button:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.35);
}

/* Subtle no-JS note */
.noscript {
  position: fixed;
  left: 12px;
  bottom: 12px;
  font-size: 12px;
  color: #bbb;
  background: rgba(0,0,0,.6);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.15);
}

/* Mobile viewport quirk fix */
@supports (height: 100svh) {
  body.rot0   #video, body.rot180 #video { height: 100svh; max-height: 100svh; }
  body.rot90  #video, body.rot270 #video { width: 100svh; max-width: 100svh; }
}