html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  /* Keys are forwarded to Unity; without this the browser's own
     Ctrl+A select-all highlights the whole page blue. */
  user-select: none;
  -webkit-user-select: none;
  /* Touch: gestures belong to the stream — no pull-to-refresh, no rubber
     banding, no long-press callout. */
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

#player {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #000;
}

#Video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#fullscreenButton {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  opacity: 0.35;
}

#fullscreenButton:hover {
  opacity: 1;
}

/* Full-viewport state overlay: shown whenever video isn't actually playing
   (connecting, reconnecting, failed). Sits above the player; display:none
   when hidden so it never intercepts input while streaming. */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.78);
  color: #ddd;
  font-family: "Segoe UI", sans-serif;
  text-align: center;
  z-index: 20;
}

#overlay[hidden] {
  display: none;
}

#overlaySpinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ddd;
  border-radius: 50%;
  animation: overlay-spin 1s linear infinite;
  margin-bottom: 14px;
}

#overlaySpinner[hidden] {
  display: none;
}

@keyframes overlay-spin {
  to {
    transform: rotate(360deg);
  }
}

#overlayHeadline {
  font-size: 18px;
  color: #eee;
}

#overlaySub {
  margin-top: 8px;
  font-size: 13px;
  color: #9a9a9a;
  max-width: 420px;
  line-height: 1.5;
  min-height: 1em;
}

#overlayButton {
  margin-top: 18px;
  padding: 8px 24px;
  font-size: 13px;
  font-family: inherit;
  color: #eee;
  background: transparent;
  border: 1px solid #777;
  border-radius: 4px;
  cursor: pointer;
}

#overlayButton:hover {
  border-color: #eee;
  background: rgba(255, 255, 255, 0.08);
}

#overlayButton[hidden] {
  display: none;
}

#overlayCode {
  margin-top: 20px;
  font-family: Consolas, monospace;
  font-size: 11px;
  color: #666;
}

#overlayCode:empty {
  display: none;
}

#status {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #ccc;
  font-family: sans-serif;
  font-size: 13px;
  pointer-events: none;
  z-index: 10;
}

#stats {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.5);
  color: #0f0;
  font-family: Consolas, monospace;
  font-size: 12px;
  text-align: left;
  white-space: pre;
  pointer-events: none;
  z-index: 10;
}

/* ---------------------------------------------------------------------------
   Touch HUD (tablets) — all controls are local DOM over the stream. The
   container never intercepts touches itself (pointer-events: none); only the
   controls do, so overlay touches never reach the video gesture recognizer.
   Idle: fades after a few seconds, any touch wakes it. */
#touchUi {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  font-family: "Segoe UI", sans-serif;
  transition: opacity 0.4s ease;
}

#touchUi[hidden] {
  display: none;
}

#touchUi.ti-idle {
  opacity: 0.35;
}

.ti-btn {
  pointer-events: auto;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 16px;
  color: #eee;
  font-size: 15px;
  font-family: inherit;
  background: rgba(20, 24, 28, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  touch-action: none;
}

.ti-btn:active {
  background: rgba(70, 110, 200, 0.6);
}

/* Back (Esc): top-left, inset below the system-swipe band. */
#tiBack {
  position: absolute;
  top: 24px;
  left: 16px;
}

/* Mode pill: bottom-center. */
#tiPill {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(20, 24, 28, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  pointer-events: auto;
  touch-action: none;
}

.ti-mode {
  min-width: 84px;
  min-height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #bbb;
  font-size: 15px;
  font-family: inherit;
  touch-action: none;
}

.ti-mode.active {
  background: rgba(70, 110, 200, 0.75);
  color: #fff;
}

/* Fly HUD: joystick bottom-left, up/down rocker bottom-right. */
#tiJoy {
  position: absolute;
  bottom: 84px;
  left: 32px;
  width: 128px;
  height: 128px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(20, 24, 28, 0.45);
  pointer-events: auto;
  touch-action: none;
}

#tiJoy.boost {
  border-color: rgba(120, 190, 255, 0.9);
  box-shadow: 0 0 14px rgba(120, 190, 255, 0.5);
}

#tiJoyKnob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(200, 215, 235, 0.85);
  will-change: transform;
}

#tiRocker {
  position: absolute;
  bottom: 84px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#tiRocker .ti-btn {
  width: 60px;
  height: 60px;
  font-size: 18px;
  padding: 0;
}
