* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #18191a;
  overflow: hidden;
  height: 100vh;
}

/* Pre-call screen */
#preCallScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1877f2 0%, #0e4f9e 100%);
}

.pre-call-container {
  background: white;
  border-radius: 16px;
  padding: 48px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.pre-call-container h1 {
  font-size: 28px;
  color: #050505;
  margin-bottom: 12px;
}

.pre-call-container p {
  color: #65676b;
  margin-bottom: 32px;
  font-size: 15px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 2px solid #e4e6eb;
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
}

.input-field:focus {
  outline: none;
  border-color: #1877f2;
}

.input-field::placeholder {
  color: #8a8d91;
}

.help-text {
  margin-top: 16px;
  font-size: 13px;
  color: #65676b;
  line-height: 1.4;
}

#joinBtn {
  background: #1877f2;
  color: white;
  border: none;
  padding: 16px 48px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

#joinBtn:hover {
  background: #166fe5;
}

#joinBtn:active {
  transform: scale(0.98);
}

/* Call screen */
#callScreen {
  display: none;
  height: 100vh;
  position: relative;
}

#callScreen.active {
  display: block;
}

/* Video grid */
.video-grid {
  height: 100vh;
  display: grid;
  gap: 8px;
  padding: 8px;
  background: #18191a;
}

.video-grid.participants-1 {
  grid-template-columns: 1fr;
}

.video-grid.participants-2 {
  grid-template-columns: repeat(2, 1fr);
}

.video-grid.participants-3,
.video-grid.participants-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.video-grid.participants-5,
.video-grid.participants-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.video-grid.participants-7,
.video-grid.participants-8,
.video-grid.participants-9 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.video-container {
  position: relative;
  background: #242526;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.video-container.camera-off {
  background: #3a3b3c;
}

.camera-off-placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #b0b3b8;
}

.video-container.camera-off .camera-off-placeholder {
  display: flex;
}

.video-container.camera-off video {
  display: none;
}

.avatar-circle {
  width: 80px;
  height: 80px;
  background: #1877f2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: white;
  font-weight: 600;
  margin-bottom: 12px;
}

.participant-name {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2;
}

.participant-status {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.status-icon {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.status-icon.muted {
  background: rgba(244, 67, 54, 0.9);
}

/* Controls bar */
.controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.control-btn {
  min-width: 70px;
  height: 48px;
  border-radius: 24px;
  border: none;
  background: #3a3b3c;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 20px;
}

.control-btn:hover {
  background: #4e4f50;
  transform: scale(1.05);
}

.control-btn:active {
  transform: scale(0.95);
}

.control-btn.active {
  background: #e4e6eb;
  color: #050505;
}

.control-btn.danger {
  background: #f02849;
}

.control-btn.danger:hover {
  background: #d91d3c;
}

.control-btn-text {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.control-btn-label {
  position: absolute;
  bottom: -28px;
  font-size: 12px;
  color: white;
  white-space: nowrap;
  font-weight: 500;
}

.participants-sidebar {
  position: absolute;
  right: -320px;
  top: 0;
  width: 320px;
  height: 100vh;
  background: #242526;
  transition: right 0.3s ease;
  z-index: 20;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
}

.participants-sidebar.open {
  right: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #3a3b3c;
}

.sidebar-header h2 {
  color: #e4e6eb;
  font-size: 18px;
  margin-bottom: 8px;
}

.sidebar-header p {
  color: #b0b3b8;
  font-size: 14px;
}

.participants-list {
  overflow-y: auto;
  height: calc(100vh - 80px);
  padding: 12px;
}

.participant-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: #3a3b3c;
}

.participant-avatar {
  width: 40px;
  height: 40px;
  background: #1877f2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  margin-right: 12px;
  font-size: 16px;
}

.participant-info {
  flex: 1;
}

.participant-info-name {
  color: #e4e6eb;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 2px;
}

.participant-info-status {
  color: #b0b3b8;
  font-size: 13px;
}

.participant-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #4e4f50;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #5a5b5c;
}

.action-btn.muted {
  background: #f02849;
}

/* Toast notifications */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.toast.show {
  opacity: 1;
}

/* Connection status */
.connection-status {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #31a24c;
  animation: pulse 2s infinite;
}

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

@media (max-width: 768px) {
  .pre-call-container {
    padding: 32px 24px;
    max-width: 340px;
  }

  .pre-call-container h1 {
    font-size: 24px;
  }

  .pre-call-container p {
    font-size: 14px;
    margin-bottom: 24px;
  }

  .video-grid {
    padding: 4px;
    gap: 4px;
    height: calc(100vh - 100px);
  }

  .video-grid.participants-2,
  .video-grid.participants-3,
  .video-grid.participants-4 {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .video-grid.participants-5,
  .video-grid.participants-6,
  .video-grid.participants-7,
  .video-grid.participants-8,
  .video-grid.participants-9 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }

  .avatar-circle {
    width: 60px;
    height: 60px;
    font-size: 24px;
    margin-bottom: 8px;
  }

  .participant-name {
    bottom: 8px;
    left: 8px;
    padding: 4px 8px;
    font-size: 12px;
  }

  .participant-status {
    top: 8px;
    left: 8px;
    gap: 4px;
  }

  .status-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  /* Controls bar */
  .controls-bar {
    padding: 16px 8px;
    gap: 8px;
  }

  .control-btn {
    min-width: 60px;
    height: 40px;
    font-size: 12px;
    padding: 0 12px;
  }

  .control-btn-text {
    font-size: 12px;
  }

  .control-btn-label {
    display: none;
  }

  /* Participants sidebar - full width on mobile */
  .participants-sidebar {
    right: -100%;
    width: 100%;
  }

  .sidebar-header {
    padding: 16px;
  }

  .sidebar-header h2 {
    font-size: 16px;
  }

  /* Connection status */
  .connection-status {
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 12px;
  }

  .status-dot {
    width: 6px;
    height: 6px;
  }

  /* Toast */
  .toast {
    top: 12px;
    max-width: calc(100vw - 40px);
    font-size: 13px;
    padding: 10px 20px;
  }
}

@media (max-width: 480px) {
  /* Extra small screens */
  .pre-call-container {
    padding: 24px 20px;
  }

  .pre-call-container h1 {
    font-size: 20px;
  }

  #joinBtn {
    padding: 14px 32px;
    font-size: 15px;
  }

  /* Controls - even more compact */
  .controls-bar {
    padding: 12px 4px;
    gap: 6px;
  }

  .control-btn {
    min-width: 55px;
    height: 36px;
    font-size: 11px;
    padding: 0 10px;
  }

  .control-btn-text {
    font-size: 11px;
  }

  .control-btn-label {
    display: none;
  }

  /* Video grid */
  .video-grid {
    padding: 2px;
    gap: 2px;
  }

  .video-container {
    border-radius: 8px;
  }

  .avatar-circle {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .participant-item {
    padding: 10px;
  }

  .participant-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .participant-info-name {
    font-size: 14px;
  }

  .participant-info-status {
    font-size: 12px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  /* Landscape mode on small screens */
  .video-grid {
    height: calc(100vh - 80px);
  }

  .controls-bar {
    padding: 8px;
  }

  .control-btn {
    min-width: 50px;
    height: 32px;
    font-size: 11px;
    padding: 0 10px;
  }

  .control-btn-text {
    font-size: 11px;
  }

  .control-btn-label {
    display: none;
  }

  .connection-status {
    top: 8px;
    left: 8px;
    padding: 4px 10px;
    font-size: 11px;
  }
}
