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

:root {
  --bg: #0a0a0f;
  --surface: #141420;
  --surface-2: #1c1c2e;
  --border: #2a2a3e;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --danger: #e34040;
  --radius: 12px;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

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

/* Join screen */
.join-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  gap: 24px;
}

.join-screen h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.join-screen .subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.name-input {
  font-size: 1rem;
  padding: 10px 16px;
  width: 200px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.name-input:focus { border-color: var(--accent); }

.btn {
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-icon:hover { background: var(--accent); color: #000; }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

/* Identity screen — wizard */
.identity-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
}

.identity-screen.active {
  display: flex;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.wizard-progress {
  display: flex;
  gap: 8px;
}

.wizard-progress .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}

.wizard-progress .dot.active {
  background: var(--accent);
}

.wizard-progress .dot.done {
  background: var(--accent);
  opacity: 0.5;
}

.wizard-step h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.btn-skip {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px;
  transition: color 0.15s;
}

.btn-skip:hover { color: var(--text); }

/* Join button — disabled state */
.btn-join {
  padding: 14px 40px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text-dim);
  transition: all 0.3s ease;
  margin-top: 4px;
}

.btn-join:disabled {
  cursor: not-allowed;
}

/* Join button — active/glowing state */
.btn-join.ready {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 20px rgba(29, 185, 84, 0.4), 0 0 40px rgba(29, 185, 84, 0.15);
  animation: glow-pulse 2s ease-in-out infinite;
}

.btn-join.ready:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 25px rgba(29, 185, 84, 0.5), 0 0 50px rgba(29, 185, 84, 0.2);
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(29, 185, 84, 0.4), 0 0 40px rgba(29, 185, 84, 0.15); }
  50% { box-shadow: 0 0 28px rgba(29, 185, 84, 0.55), 0 0 50px rgba(29, 185, 84, 0.25); }
}

.camera-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.camera-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.camera-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.camera-preview video.active { display: block; }

.camera-preview canvas { display: none; }

.camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  position: absolute;
  top: 0;
  left: 0;
}

.camera-preview img.active { display: block; }

.camera-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Album art in queue */
.queue-item .queue-album-art {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Guest photo in queue */
.queue-item .guest-photo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Room view */
.room-view { display: none; }
.room-view.active { display: block; }
.join-screen.hidden { display: none; }

.now-playing {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.now-playing img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.now-playing .np-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--surface-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Skip button */
.skip-btn {
  display: none;
  padding: 8px 20px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.skip-btn.visible { display: block; }
.skip-btn:hover { background: var(--accent-hover); }
.skip-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.np-info { flex: 1; min-width: 0; }
.np-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 4px; }
.np-title { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 0.85rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear;
}

/* Pending notice */
.pending-notice {
  display: none;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
}

.pending-notice.visible { display: block; }

/* Search */
.search-section { margin-bottom: 20px; }

.search-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--accent); }

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-results {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  transition: background 0.1s;
  cursor: pointer;
}

.search-item:hover { background: var(--surface); }
.search-item.disabled { opacity: 0.4; pointer-events: none; }

.search-item-status {
  flex-shrink: 0;
  font-size: 1.2rem;
  color: var(--text-dim);
  width: 36px;
  text-align: center;
}

.search-item img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.search-item-info { flex: 1; min-width: 0; }
.search-item-title { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-artist { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Queue */
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.queue-list { list-style: none; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 6px;
}

.queue-item img:not(.queue-album-art):not(.guest-photo) {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.queue-item-info { flex: 1; min-width: 0; }
.queue-item-title { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-meta { font-size: 0.75rem; color: var(--text-dim); }
.queue-item.playing { border-left: 3px solid var(--accent); }

/* Remove button on guest's own queue items */
.btn-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-remove:hover { background: var(--danger); color: #fff; }
.btn-remove:disabled { opacity: 0.3; cursor: not-allowed; }

.queue-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 32px 0;
  font-size: 0.9rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.5s forwards;
  white-space: nowrap;
}

.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--accent); color: var(--accent); }

@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
