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

:root {
  --bg: #0a0a0f;
  --surface: #16161e;
  --surface2: #1e1e2a;
  --border: #2a2a3a;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --text: #e4e4e7;
  --text-dim: #71717a;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
}

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

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.container-center {
  justify-content: center;
}

/* Logo */
.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  margin-bottom: 8px;
}

.logo h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  margin-top: 4px;
  font-size: 0.95rem;
}

/* Welcome */
.welcome {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

/* Button icon */
.btn-icon {
  font-size: 1.2rem;
  margin-right: 4px;
}

/* How it works */
.how-it-works {
  margin-top: 32px;
}

.how-it-works h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
  color: var(--text-dim);
}

.steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.3;
}

/* Genres */
.genres-section {
  margin-top: 28px;
}

.genres-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
  color: var(--text-dim);
}

.genres-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.genre-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.genre-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gc);
}

.genre-card:hover {
  border-color: var(--gc);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Genre chips (room page) */
.genre-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.genre-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.genre-chip:hover {
  border-color: var(--primary);
  color: var(--text);
}

/* Footer */
.footer {
  margin-top: 32px;
  text-align: center;
  padding: 16px 0;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* Inputs */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

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

.input-code {
  text-transform: uppercase;
  letter-spacing: 3px;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  flex: 1;
  margin-bottom: 0;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  width: auto;
  min-width: 80px;
}

.btn-secondary:hover {
  border-color: var(--primary);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
  width: auto;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-skip {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

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

.btn-skip.voted {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

/* Divider */
.divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.divider span {
  background: var(--surface);
  padding: 0 12px;
  position: relative;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Join row */
.join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ========== Room page ========== */

/* Header */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.room-code {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--primary);
}

.room-users {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Search */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box .input {
  margin-bottom: 0;
  padding-right: 44px;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.search-results.open {
  display: block;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.search-item:hover {
  background: var(--surface2);
}

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

.search-item-info {
  flex: 1;
  min-width: 0;
}

.search-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-channel {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Now playing */
.now-playing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.now-playing-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 8px;
}

.now-playing-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.now-playing-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.now-playing-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.player-wrap {
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: #000;
}

.player-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
}

.empty-state p {
  font-size: 0.95rem;
}

/* Queue */
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.queue-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.queue-count {
  font-size: 0.8rem;
  color: var(--text-dim);
}

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

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.queue-item:last-child {
  border-bottom: none;
}

.queue-num {
  font-size: 0.8rem;
  color: var(--text-dim);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

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

.queue-item-info {
  flex: 1;
  min-width: 0;
}

.queue-item-title {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-added {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.queue-item .btn-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  transition: color 0.2s;
  flex-shrink: 0;
}

.queue-item .btn-remove:hover {
  color: var(--danger);
}

/* QR Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.modal h3 {
  margin-bottom: 16px;
}

.modal canvas {
  margin: 0 auto;
}

.share-link {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.share-link input {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  transition: transform 0.3s;
  z-index: 200;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 400px) {
  .logo h1 {
    font-size: 2rem;
  }
}
