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

:root {
  --bg: #0a0a0a;
  --surface: #151515;
  --surface-hover: #1f1f1f;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #e63946;
  --accent-dim: rgba(230, 57, 70, 0.2);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* App layout - desktop: three columns */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Mobile tabs - hidden on desktop */
.mobile-tabs {
  display: none;
}

/* Panel header style */
.panel-header {
  padding: 1rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.1em;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* Queue panel (left sidebar) */
.queue-panel {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.queue-list::-webkit-scrollbar {
  width: 4px;
}

.queue-list::-webkit-scrollbar-track {
  background: transparent;
}

.queue-list::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

.queue-item {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #1a1a1a;
}

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

.queue-item .artist {
  font-weight: 500;
  font-size: 0.9rem;
}

.queue-item .name {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search-section {
  position: relative;
  padding: 1rem;
  border-top: 1px solid #222;
  background: rgba(0, 0, 0, 0.2);
  z-index: 20;
}

#search {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
}

#search:focus {
  outline: none;
  border-color: var(--accent);
}

#search::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  bottom: 100%;
  left: 1rem;
  right: 1rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
  display: none;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

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

.search-result {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #222;
}

.search-result:hover {
  background: var(--surface-hover);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result .artist {
  font-weight: 500;
  font-size: 0.9rem;
}

.search-result .name {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main panel (player) */
.main-panel {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #222;
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.listeners {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.player {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.artwork {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
  background: #222;
}

.artwork img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.info {
  margin-bottom: 1.25rem;
}

.now-playing {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.info h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.info p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.set-name {
  font-size: 0.8rem !important;
  margin-top: 0.5rem;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-container {
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
}

.progress {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.5s linear;
}

.time {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Next up (mobile only) */
.next-up {
  display: none;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.btn {
  background: var(--surface);
  border: none;
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--surface-hover);
}

.skip-btn {
  flex: 1;
  max-width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.skip-btn.voted {
  background: var(--accent-dim);
  color: var(--accent);
}

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

.secondary-controls {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat panel (right sidebar) */
.chat-panel {
  width: 300px;
  background: var(--surface);
  border-left: 1px solid #222;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

.chat-message {
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  padding-right: 1.5rem;
}

.chat-message:hover .reaction-btn {
  opacity: 1;
}

.chat-message-content {
  display: inline;
}

/* Reaction button */
.reaction-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0.25rem;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}

.reaction-btn:hover {
  color: var(--accent);
}

/* Reaction picker */
.reaction-picker {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface-hover);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.375rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  max-width: 200px;
}

.reaction-picker.hidden {
  display: none;
}

.emoji-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  padding: 0.3rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
}

.emoji-btn:hover {
  background: var(--surface);
  transform: scale(1.2);
}

/* Reactions display */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.chat-reactions:empty {
  display: none;
}

.reaction {
  background: var(--surface-hover);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.reaction:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.reaction.my-reaction {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* @mentions */
.mention {
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.mention-me {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.chat-name {
  color: var(--accent);
  font-weight: 600;
}

.chat-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0.25rem;
}

.chat-image {
  display: block;
  max-width: 100%;
  max-height: 200px;
  margin-top: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.chat-input-area {
  border-top: 1px solid #222;
  background: rgba(0, 0, 0, 0.2);
  position: relative;
}

/* @ mention autocomplete */
.mention-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid #333;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
}

.mention-autocomplete.hidden {
  display: none;
}

.mention-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #222;
  transition: background 0.15s;
}

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

.mention-item:hover,
.mention-item.selected {
  background: var(--surface-hover);
}

.mention-item.selected {
  border-left: 3px solid var(--accent);
}

.mention-item-name {
  color: var(--accent);
  font-weight: 500;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
}

.chat-input-row input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid #333;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input-row input::placeholder {
  color: var(--text-muted);
}

.chat-input-row .btn {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}

.chat-name-row {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 0.75rem;
}

.chat-name-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid #333;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
}

.chat-name-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-name-row input::placeholder {
  color: var(--text-muted);
}

.btn-small {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

/* Chat toast (mobile) */
.chat-toast {
  display: none;
}

/* Notification */
.notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 100;
}

.notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Play overlay */
.play-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.play-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.play-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--accent);
}

.play-overlay-content svg {
  filter: drop-shadow(0 0 20px var(--accent));
  animation: pulse-glow 2s ease-in-out infinite;
}

.play-overlay-content span {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.2em;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* Mobile styles */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    height: 100dvh;
    height: 100svh;
    overflow: hidden;
    position: fixed;
    inset: 0;
  }

  .mobile-tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid #222;
    flex-shrink: 0;
  }

  .mobile-tabs .tab {
    flex: 1;
    padding: 0.875rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
  }

  .mobile-tabs .tab.active {
    color: var(--accent);
  }

  .mobile-tabs .tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 1rem;
    height: 2px;
    background: var(--accent);
  }

  .mobile-tabs .tab.has-mention::before {
    content: '';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1s infinite;
  }

  .queue-panel,
  .main-panel,
  .chat-panel {
    display: none !important;
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
  }

  .queue-panel.active {
    display: flex !important;
    flex-direction: column;
  }

  .chat-panel.active {
    display: flex !important;
    flex-direction: column;
  }

  .main-panel.active {
    display: block !important;
    overflow-y: auto;
  }

  .main-panel .container {
    padding: 0.75rem;
    padding-bottom: 1rem;
  }

  .main-panel .player {
    padding: 1rem;
    margin-bottom: 0.75rem;
  }

  header {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
  }

  .info h2 {
    font-size: 1.2rem;
  }

  .controls {
    margin-bottom: 0.75rem;
  }

  /* Next up preview on mobile */
  .next-up {
    display: block;
    background: var(--surface);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
  }

  .next-up:empty {
    display: none;
  }

  .next-up-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
  }

  .next-up-artist {
    font-weight: 500;
  }

  /* Chat toast on mobile */
  .chat-toast {
    display: block;
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: var(--surface);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 50;
    border-left: 3px solid var(--accent);
  }

  .chat-toast.show {
    opacity: 1;
    transform: translateY(0);
  }

  .chat-toast .chat-name {
    color: var(--accent);
    font-weight: 600;
  }

  /* Always show reaction button on mobile */
  .chat-message .reaction-btn {
    opacity: 0.6;
  }

  /* Position picker better on mobile */
  .reaction-picker {
    right: auto;
    left: 0;
  }

  .search-section {
    padding: 0.75rem;
  }

  .search-results {
    position: fixed;
    bottom: 60px;
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    max-height: 50vh;
    margin: 0;
    border-radius: 8px;
  }
}

/* Large desktop */
@media (min-width: 1400px) {
  .queue-panel {
    width: 320px;
  }
  .chat-panel {
    width: 360px;
  }
}

/* Christmas Mode */
#christmas-mode {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* Twinkling lights */
.christmas-lights {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 1rem;
}

.christmas-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: twinkle 1.5s ease-in-out infinite;
}

.christmas-light.red {
  background: radial-gradient(circle at 30% 30%, #ff6666, #cc0000);
  box-shadow: 0 0 10px #ff4444, 0 0 20px #ff4444;
}

.christmas-light.green {
  background: radial-gradient(circle at 30% 30%, #66ff66, #00cc00);
  box-shadow: 0 0 10px #44ff44, 0 0 20px #44ff44;
}

.christmas-light.blue {
  background: radial-gradient(circle at 30% 30%, #6666ff, #0000cc);
  box-shadow: 0 0 10px #4444ff, 0 0 20px #4444ff;
}

.christmas-light.yellow {
  background: radial-gradient(circle at 30% 30%, #ffff66, #cccc00);
  box-shadow: 0 0 10px #ffff44, 0 0 20px #ffff44;
}

.christmas-light.magenta {
  background: radial-gradient(circle at 30% 30%, #ff66ff, #cc00cc);
  box-shadow: 0 0 10px #ff44ff, 0 0 20px #ff44ff;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.8);
    filter: blur(2px);
  }
}

/* Falling snowflakes */
.christmas-snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -20px;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
  animation: snowfall linear infinite;
}

@keyframes snowfall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

/* Reduce snowflakes on mobile */
@media (max-width: 640px) {
  .snowflake:nth-child(n+26) {
    display: none;
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .christmas-light {
    animation: none;
    opacity: 0.6;
  }
  .snowflake {
    animation-duration: 30s;
  }
}
