* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0d0d;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  color: #eee;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.connect-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
}

.connect-screen h1 {
  font-size: 1.5rem;
}

.connect-screen p {
  color: #888;
  font-size: 0.9rem;
}

.connect-screen button {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  border: 1px solid #444;
  background: #2a2a2a;
  color: #eee;
  cursor: pointer;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  min-width: 120px;
  min-height: 90px;
  z-index: 1;
}

.panel.panel-on-top {
  border-color: rgba(255, 255, 255, 0.35);
}

.panel.panel-hidden {
  display: none;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.35rem 0 0.5rem;
  height: 32px;
  background: rgba(0, 0, 0, 0.75);
  flex-shrink: 0;
  z-index: 3;
  cursor: move;
  touch-action: none;
}

.panel-toolbar-actions {
  display: flex;
  gap: 2px;
}

.panel-label {
  font-size: 0.7rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.panel-front,
.panel-toggle {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #ccc;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  touch-action: manipulation;
}

.panel-front:hover,
.panel-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.panel-video-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

.panel-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
}

.panel-video-wrap.has-video .panel-waiting {
  display: none;
}

.panel-waiting {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #666;
  background: #111;
  pointer-events: none;
}

.panel-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 4;
  background: linear-gradient(
    135deg,
    transparent 50%,
    rgba(255, 255, 255, 0.35) 50%
  );
}

body.panel-dragging {
  user-select: none;
  cursor: move;
}

body.panel-resizing {
  user-select: none;
  cursor: nwse-resize;
}

.hidden-tabs {
  position: fixed;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 100;
}

.hidden-tab {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #444;
  background: rgba(0, 0, 0, 0.85);
  color: #ccc;
  font-size: 0.75rem;
  cursor: pointer;
}

.hidden-tab:hover {
  background: rgba(40, 40, 40, 0.95);
}

.help-hint {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: #555;
  z-index: 50;
  pointer-events: none;
  text-align: center;
  padding: 0 1rem;
}

.av-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.88);
  border-top: 1px solid #333;
}

.av-btn {
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid #444;
  background: #2a2a2a;
  color: #eee;
  font-size: 0.8rem;
  cursor: pointer;
}

.av-btn.primary {
  background: #2d6a4f;
  border-color: #40916c;
}

.av-btn.muted {
  background: #4d1a1a;
  border-color: #663333;
}

.self-preview {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #444;
}

@media (orientation: portrait) and (max-width: 768px) {
  .panel {
    border-radius: 6px;
  }

  .panel-toolbar {
    height: 36px;
  }

  .help-hint {
    font-size: 0.6rem;
    bottom: 64px;
  }

  .av-btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.65rem;
  }
}
