:root {
  --bg: #0b0f14;
  --panel: #121821;
  --text: #e7edf5;
  --muted: #94a3b8;
  --accent: #2dd4bf;
  --danger: #ef4444;
  --ring: #334155;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.room {
  display: flex;
  gap: 10px;
  align-items: center;
}

#roomLabel { color: var(--muted); }
#roomId { background: #0f172a; padding: 2px 6px; border-radius: 6px; }

button {
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--ring);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.danger { border-color: var(--danger); }

.videos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.videoWrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--ring);
  border-radius: 14px;
  overflow: hidden;
  min-height: 280px;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  padding: 4px 8px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.help {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 800px) {
  .videos { grid-template-columns: 1fr; }
}

/* Fullstage layout */
.stage {
  position: relative;
  width: 100%;
  height: calc(100vh - 220px); /* leaves room for header + controls; tweak if needed */
  background: #000;
  border-radius: 14px;
  border: 1px solid var(--ring);
  overflow: hidden;
}

/* Remote = nearly full-screen */
.remote {
  width: 100%;
  height: 100%;
  object-fit: contain; /* maintain aspect ratio without cropping */
}

/* Picture-in-picture (your feed) */
.pip {
  position: fixed;          /* fixed to viewport by default */
  right: 16px;
  bottom: 16px;
  width: 260px;
  max-width: 35vw;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--ring);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  z-index: 999;             /* make sure it stays on top */
}

/* When stage is fullscreen, pip becomes absolute to stage */
.stage:fullscreen .pip {
  position: absolute;
}

.local {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pipLabel {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0,0,0,0.45);
  border-radius: 8px;
  padding: 3px 6px;
}

/* Hide old grid if it still exists */
.videos, .videoWrap { display: none; }

/* Responsive: shrink PiP a bit on small screens */
@media (max-width: 640px) {
  .stage { height: calc(100vh - 260px); }
  .pip { width: 180px; max-width: 45vw; }
}

/* Recording indicator */
.recording-indicator {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.95);
  color: white;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.recording-indicator.active {
  display: flex;
}

.recording-dot {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
