html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #050505;
  font-family: Helvetica, Verdana, Arial, sans-serif;
}

.viewer-root {
  position: fixed;
  inset: 0;
  background: #000;
  color: #fff;
  user-select: none;
}

#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

#video, #audio {
  position: absolute;
  width: 1px;
  height: 1px;
  left: -10000px;
  top: -10000px;
  opacity: 0;
  pointer-events: none;
}

.ui-panel {
  transition: opacity 260ms ease, transform 260ms ease, visibility 260ms ease;
}

.viewer-root.is-idle .ui-panel,
.viewer-root.is-idle .top-bar,
.viewer-root.is-idle .bottom-controls,
.viewer-root.is-idle .dpad,
.viewer-root.is-idle .audio-btn,
.viewer-root.is-idle .debug-line {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 20;
  pointer-events: none;
}

.top-bar > * { pointer-events: auto; }

.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(20,20,20,0.72);
  color: white;
  font-size: 32px;
  line-height: 0;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
}

.round-btn:hover, .control-btn:hover, .modal-btn:hover, .dpad-btn:hover {
  background: rgba(255,255,255,0.18);
}

.status-block {
  max-width: min(62vw, 760px);
  padding: 9px 13px;
  border-radius: 14px;
  background: rgba(20,20,20,0.66);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 8px 22px rgba(0,0,0,0.28);
  text-align: left;
}

.source-label {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-line {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255,255,255,0.72);
}

.dpad {
  position: absolute;
  top: 84px;
  left: 16px;
  z-index: 20;
  width: 142px;
  height: 142px;
  border-radius: 22px;
  background: rgba(20,20,20,0.58);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
}

.dpad-btn {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(0,0,0,0.42);
  color: white;
  cursor: pointer;
}

.dpad-up { left: 50px; top: 8px; }
.dpad-left { left: 8px; top: 50px; }
.dpad-center { left: 50px; top: 50px; }
.dpad-right { right: 8px; top: 50px; }
.dpad-down { left: 50px; bottom: 8px; }

.audio-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(20,20,20,0.72);
  color: white;
  cursor: pointer;
}

.audio-btn img {
  width: 24px;
  height: 24px;
}

.audio-btn.is-on {
  display: none;
}

.bottom-controls {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 24px);
  padding: 9px;
  border-radius: 18px;
  background: rgba(20,20,20,0.66);
  border: 1px solid rgba(255,255,255,0.16);
}

.control-btn, .modal-btn {
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  background: rgba(0,0,0,0.38);
  color: #fff;
  padding: 10px 12px;
  cursor: pointer;
}

.idle-poster {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  background: #000;
  pointer-events: none;
}

.idle-poster.is-visible {
  display: flex;
}

.idle-poster img {
  max-width: min(70vw, 640px);
  max-height: 60vh;
  opacity: 0.9;
}

.caption {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 19;
  max-width: min(82vw, 900px);
  color: #fff;
  background: rgba(0,0,0,0.65);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.debug-line {
  position: absolute;
  right: 16px;
  bottom: 84px;
  z-index: 20;
  max-width: 46vw;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(20,20,20,0.62);
  color: rgba(255,255,255,0.72);
  font-size: 12px;
  text-align: right;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.72);
}

.modal.hidden { display: none; }

.modal-card {
  width: min(92vw, 560px);
  border-radius: 22px;
  background: #171717;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.16);
  padding: 22px;
  box-shadow: 0 18px 64px rgba(0,0,0,0.55);
  text-align: left;
}

.modal-card h2 { margin: 0 0 8px; }
.modal-card p { color: rgba(255,255,255,0.74); line-height: 1.4; }
.modal-card label { display: block; margin-top: 14px; margin-bottom: 6px; color: rgba(255,255,255,0.82); }
.modal-card input {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.22);
  background: #050505;
  color: #fff;
  padding: 12px;
  outline: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.modal-btn.primary { background: #0a66c2; }
.modal-btn.secondary { background: rgba(255,255,255,0.08); }

@media (max-width: 640px) {
  .dpad { transform: scale(0.86); transform-origin: top left; }
  .audio-btn span { display: none; }
  .bottom-controls { bottom: 10px; }
  .debug-line { display: none; }
}
