:root {
  --primary-color: #3b82f6;
  --bg-color: #0f172a;
  --surface-color: #1e293b;
  --text-color: #f8fafc;
  --text-muted: #94a3b8;
  --border-radius: 12px;
  --input-bg: #334155;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 800px;
  padding: 20px;
}

.card {
  background-color: var(--surface-color);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  text-align: center;
}

h1,
h2 {
  margin-top: 0;
}

input[type="text"] {
  width: 100%;
  padding: 12px;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid #475569;
  background-color: var(--input-bg);
  color: white;
  font-size: 16px;
  box-sizing: border-box;
}

button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s;
  width: 100%;
  margin-top: 10px;
}

button:hover {
  background-color: #2563eb;
}

button:disabled {
  background-color: #475569;
  cursor: not-allowed;
}

#reset-name-btn {
  margin-top: 10px;
  /* Align with input margin */
  background-color: #334155;
  transition: background-color 0.2s, transform 0.1s;
}

#reset-name-btn:hover {
  background-color: #475569;
}

#reset-name-btn:active {
  transform: rotate(180deg);
}

.hidden {
  display: none !important;
}

/* Room UI */
.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.video-container {
  width: 100%;
  background: black;
  border-radius: var(--border-radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(45deg, #1e293b 25%, #0f172a 25%, #0f172a 50%, #1e293b 50%, #1e293b 75%, #0f172a 75%, #0f172a 100%);
  background-size: 40px 40px;
  transition: all 0.3s ease;
}

.video-container.audio-mode {
  aspect-ratio: auto;
  height: 120px;
}

.video-container.audio-mode video {
  height: 54px;
  width: 95%;
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 1;
  border-radius: 27px;
  background: rgba(15, 23, 42, 0.8);
  /* ensure it's on top */
  z-index: 10;
}

/* Visualize audio mode */
.video-container.audio-mode::after {
  content: '🎵 Audio Mode';
  color: var(--text-color);
  font-size: 18px;
  font-weight: bold;
}

/* Landing Page States */
.landing-default #join-section {
  border-top: 1px solid #334155;
  padding-top: 20px;
  margin-top: 20px;
}

.landing-invite #create-room-btn,
.landing-invite .divider-text {
  display: none;
}

.landing-invite #join-room-btn {
  background-color: var(--primary-color);
  font-weight: bold;
  transform: scale(1.05);
}

video {
  width: 100%;
  height: 100%;
  max-height: 500px;
}

.controls-wrapper {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  /* Stack rows vertically */
  gap: 12px;
}

.seek-controls,
.option-controls {
  display: flex;
  gap: 10px;
  width: 100%;
}

.seek-controls button {
  flex: 1;
  /* Expand to fill width */
  margin: 0;
}

.option-controls .toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Center text/checbox */
  background: #334155;
  padding: 0 15px;
  border-radius: 8px;
  height: 44px;
  cursor: pointer;
}

.option-controls input[type="checkbox"] {
  width: auto;
  margin: 0 10px 0 0;
}

.upload-area {
  border: 2px dashed #475569;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.upload-area:hover {
  border-color: var(--primary-color);
}

.user-list {
  margin-top: 20px;
  text-align: left;
}

.user-tag {
  display: inline-block;
  background-color: #334155;
  padding: 5px 10px;
  border-radius: 15px;
  margin-right: 5px;
  font-size: 14px;
}

#status-msg {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 10px;
}

/* Responsive Room Layout */
.room-grid {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  text-align: left;
  max-width: 1200px;
  /* Allow wider layout since we have side panel */
  margin: 0 auto;
}

.main-content {
  flex: 1;
  min-width: 0;
  /* Prevent flex items from overflowing */
  width: 100%;
}

.side-panel {
  width: 280px;
  flex-shrink: 0;
  background: rgba(30, 41, 59, 0.5);
  border-radius: var(--border-radius);
  padding: 15px;
  align-self: stretch;
  /* Match height if possible, or just start at top */
  display: flex;
  flex-direction: column;
}

.joined-users-scroll {
  flex: 1;
  overflow-y: auto;
  max-height: 500px;
  /* Fallback max height */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* User Card Style */
.user-card {
  background-color: var(--input-bg);
  padding: 10px 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #475569;
}

.user-card .avatar {
  width: 32px;
  height: 32px;
  background-color: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
}

.user-card .name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item .remove-btn {
  background: transparent;
  width: auto;
  margin: 0;
  padding: 2px 8px;
  color: var(--text-muted);
  font-size: 18px;
  border-radius: 4px;
  transition: all 0.2s;
  opacity: 0.3;
}

.queue-item:hover .remove-btn {
  opacity: 1;
}

.queue-item .remove-btn:hover {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  /* Let clicks pass through container */
}

.toast {
  background-color: var(--surface-color);
  border-left: 4px solid var(--primary-color);
  padding: 12px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: var(--text-color);
  font-size: 14px;
  min-width: 200px;
  pointer-events: auto;
  animation: slideIn 0.3s ease-out forwards;
  opacity: 0;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .room-grid {
    flex-direction: column;
  }

  .side-panel {
    width: 100%;
    max-height: 300px;
    box-sizing: border-box;
  }

  .joined-users-scroll {
    max-height: 200px;
  }

  .toast-container {
    left: 20px;
    right: 20px;
    bottom: 20px;
    align-items: center;
  }
}

/* Queue UI */
.queue-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 20px;
  border-top: 1px solid #475569;
  padding-top: 15px;
}

.queue-header {
  font-size: 14px;
  font-weight: bold;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  background-color: var(--input-bg);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #475569;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-item .icon {
  color: var(--text-muted);
}

.queue-item .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.queue-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 20px;
  font-style: italic;
}

/* Now Playing Banner */
.now-playing-banner {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid #334155;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.now-playing-banner .icon {
  font-size: 16px;
  opacity: 0.8;
}

.now-playing-banner .title {
  font-weight: 500;
  color: var(--primary-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}