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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ---- Join Screen ---- */

.join-card {
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  max-width: 380px;
  width: 90%;
}

.join-card h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #ffffff;
}

.subtitle {
  color: #888;
  font-size: 14px;
  margin-bottom: 28px;
}

#name-input,
#password-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #2a2a4a;
  background: #0f0f23;
  color: #e0e0e0;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

#name-input:focus,
#password-input:focus {
  border-color: #5865f2;
}

#password-input {
  margin-bottom: 16px;
}

#join-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #5865f2;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#join-btn:hover {
  background: #4752c4;
}

#join-btn:disabled {
  background: #3a3f7a;
  cursor: not-allowed;
}

.error {
  color: #ed4245;
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ---- Voice Screen ---- */

#voice-screen {
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.voice-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  min-width: 0;
  overflow-y: auto;
}

.voice-header {
  width: 100%;
  text-align: center;
  padding: 8px 0;
}

#peer-count {
  font-size: 14px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#peers-container {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px;
  width: 100%;
  max-width: 600px;
}

.peer-bubble {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #16213e;
  border: 2px solid #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #888;
  transition: border-color 0.3s, box-shadow 0.3s;
  text-align: center;
  padding: 4px;
  word-break: break-word;
  line-height: 1.2;
}

.peer-bubble.speaking {
  border-color: #57f287;
  box-shadow: 0 0 16px rgba(87, 242, 135, 0.3);
}

.peer-bubble.you {
  border-color: #5865f2;
}

.peer-bubble.you.speaking {
  border-color: #57f287;
  box-shadow: 0 0 16px rgba(87, 242, 135, 0.3);
}

.peer-bubble.muted {
  opacity: 0.5;
}

/* ---- Screen Share ---- */

#screen-share-container {
  width: 100%;
  max-width: 800px;
  background: #0f0f23;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.screen-share-label {
  padding: 8px 12px;
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #2a2a4a;
}

#screen-share-video {
  width: 100%;
  display: block;
  background: #000;
}

/* ---- Controls ---- */

.controls {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  flex-wrap: wrap;
  justify-content: center;
  flex-shrink: 0;
  background: #16213e;
  border-top: 1px solid #2a2a4a;
}

.control-btn {
  padding: 10px 20px;
  border-radius: 24px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  background: #2a2a4a;
  color: #e0e0e0;
}

.control-btn:hover {
  background: #3a3a5a;
}

.control-btn.active {
  background: #5865f2;
  color: #fff;
}

.control-btn.active-red {
  background: #ed4245;
  color: #fff;
}

.control-btn-danger {
  background: #ed4245;
  color: #fff;
}

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

/* ---- Chat Panel ---- */

.chat-panel {
  width: 340px;
  min-width: 340px;
  background: #16213e;
  border-left: 1px solid #2a2a4a;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 16px 20px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid #2a2a4a;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 13px;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  background: #0f0f23;
  border-radius: 8px;
  padding: 10px 12px;
  max-width: 100%;
}

.chat-msg-name {
  font-size: 12px;
  font-weight: 600;
  color: #5865f2;
  margin-bottom: 4px;
}

.chat-msg-text {
  font-size: 14px;
  color: #e0e0e0;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg-img {
  max-width: 100%;
  border-radius: 6px;
  margin-top: 6px;
  cursor: pointer;
}

.chat-msg-time {
  font-size: 10px;
  color: #555;
  margin-top: 4px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #2a2a4a;
  align-items: center;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #2a2a4a;
  background: #0f0f23;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  min-width: 0;
}

#chat-input:focus {
  border-color: #5865f2;
}

.chat-img-btn {
  padding: 8px 12px;
  border-radius: 6px;
  background: #2a2a4a;
  color: #888;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
  flex-shrink: 0;
}

.chat-img-btn:hover {
  background: #3a3a5a;
  color: #e0e0e0;
}

#chat-send-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #5865f2;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

#chat-send-btn:hover {
  background: #4752c4;
}

.image-preview {
  padding: 8px 16px;
  position: relative;
  flex-shrink: 0;
  border-top: 1px solid #2a2a4a;
}

.image-preview img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 6px;
  border: 1px solid #2a2a4a;
}

#image-preview-remove {
  position: absolute;
  top: 4px;
  right: 12px;
  background: #ed4245;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 3px;
}

/* ---- Image Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .voice-content {
    flex-direction: column;
  }

  .chat-panel {
    width: 100%;
    min-width: 0;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid #2a2a4a;
  }
}
