:root {
  --bg: #0a1024;
  --bg-2: #111a36;
  --text: #eef2ff;
  --muted: #bac2e4;
  --card: rgba(17, 24, 54, 0.65);
  --card-border: rgba(130, 154, 255, 0.28);
  --primary: #4d6bff;
  --primary-2: #2d49d6;
  --accent: #1ec7a8;
  --danger: #b54f64;
  --react: 0;
  --pulse-bass: 0;
  --pulse-mid: 0;
  --pulse-high: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(
      circle at 15% 20%,
      rgba(
        calc(31 + var(--pulse-bass) * 45),
        calc(46 + var(--pulse-mid) * 24),
        calc(103 + var(--pulse-high) * 16),
        1
      )
      0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 85% 10%,
      rgba(
        calc(63 + var(--pulse-high) * 45),
        calc(31 + var(--pulse-mid) * 20),
        calc(103 + var(--pulse-bass) * 24),
        1
      )
      0%,
      transparent 42%
    ),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  transition: background 0.2s linear;
}

#visualizer-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: calc(0.15 + var(--react) * 0.34);
  filter: blur(calc(8px - var(--pulse-high) * 2px)) saturate(calc(1.1 + var(--pulse-mid) * 0.6));
  transition: opacity 0.16s linear, filter 0.16s linear;
}

.bg-glow {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(90px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 {
  background: rgba(
    calc(95 + var(--pulse-bass) * 80),
    calc(124 + var(--pulse-mid) * 70),
    calc(255 - var(--pulse-high) * 30),
    1
  );
  top: -170px;
  left: -130px;
  transform: scale(calc(1 + var(--pulse-bass) * 0.18));
}

.bg-glow-2 {
  background: rgba(
    calc(22 + var(--pulse-high) * 120),
    calc(216 - var(--pulse-mid) * 20),
    calc(194 + var(--pulse-bass) * 38),
    1
  );
  bottom: -190px;
  right: -170px;
  transform: scale(calc(1 + var(--pulse-high) * 0.16));
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(2, 6, 22, 0.45);
  padding: 18px;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.5vw, 2.4rem);
  letter-spacing: 0.4px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

h2,
h3 {
  margin: 0 0 10px;
}

.muted {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  background: rgba(11, 17, 40, 0.62);
  border: 1px solid rgba(122, 145, 240, 0.2);
  border-radius: 14px;
  padding: 14px;
}

.room-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.room-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}

.queue-sidebar,
.main-panel {
  background: rgba(8, 14, 34, 0.56);
  border: 1px solid rgba(130, 154, 255, 0.2);
  border-radius: 14px;
  padding: 12px;
}

.area-box {
  border: 1px solid rgba(143, 167, 255, 0.28);
  background: rgba(10, 17, 40, 0.62);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}

.area-box h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  letter-spacing: 0.2px;
  color: #dbe5ff;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(79, 113, 255, 0.2);
  border: 1px solid rgba(143, 167, 255, 0.45);
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.soft {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.row {
  display: flex;
  gap: 10px;
}

.responsive-row {
  flex-wrap: wrap;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.section-head {
  margin-top: 16px;
}

input,
button {
  font-size: 15px;
}

input[type="text"],
input[type="url"] {
  width: 100%;
  background: rgba(6, 11, 32, 0.82);
  color: var(--text);
  border: 1px solid rgba(133, 152, 230, 0.4);
  border-radius: 12px;
  padding: 12px 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="range"]:focus {
  outline: none;
  border-color: #97abff;
  box-shadow: 0 0 0 3px rgba(90, 117, 255, 0.2);
}

.btn {
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 22px rgba(44, 75, 255, calc(0.26 + var(--pulse-mid) * 0.34));
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(0);
}

.btn.ghost {
  background: rgba(229, 234, 255, 0.1);
  box-shadow: none;
  border: 1px solid rgba(210, 221, 255, 0.2);
}

.btn.danger {
  background: linear-gradient(180deg, #c86a82, var(--danger));
  box-shadow: 0 8px 22px rgba(173, 56, 84, 0.35);
}

.btn.accent {
  background: linear-gradient(180deg, #27d4b4, var(--accent));
  box-shadow: 0 8px 22px rgba(26, 151, 134, calc(0.22 + var(--pulse-high) * 0.36));
}

.hidden {
  display: none !important;
}

.host-box,
.listener-box {
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(10, 16, 38, 0.7);
  border: 1px solid rgba(126, 149, 239, 0.28);
  border-radius: 14px;
  padding: 12px;
}

.host-box.area-box,
.listener-box.area-box,
.song-panel.area-box {
  margin-bottom: 0;
}

.host-box.area-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
}

.listener-box.area-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.host-box.area-box h4,
.listener-box.area-box h4,
.song-panel.area-box h4 {
  grid-column: 1 / -1;
}

.listener-box p {
  margin: 0;
  color: var(--muted);
}

.host-box p {
  margin: 0 0 8px;
}

.host-box img {
  width: 170px;
  height: 170px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: #fff;
}

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(7, 10, 24, 0.86);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.qr-overlay-card {
  width: min(92vw, 640px);
  background: rgba(16, 22, 52, 0.9);
  border: 1px solid rgba(143, 167, 255, 0.35);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 18px 48px rgba(3, 7, 27, 0.6);
  display: grid;
  justify-items: center;
  gap: 14px;
}

.qr-overlay-card h2 {
  margin: 0;
}

#join-qr-fullscreen {
  width: min(78vw, 520px);
  height: min(78vw, 520px);
  max-width: 100%;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #fff;
}

.queue-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.queue-list li {
  border: 1px solid rgba(132, 156, 255, 0.28);
  border-radius: 12px;
  padding: 11px 12px;
  background: rgba(8, 15, 36, 0.52);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.12s ease, background 0.2s ease;
}

.queue-list li:hover {
  transform: translateY(-1px);
  border-color: rgba(168, 186, 255, 0.66);
}

.queue-list li.active {
  border-color: #8ea8ff;
  background: linear-gradient(
    145deg,
    rgba(calc(45 + var(--pulse-mid) * 36), calc(67 + var(--pulse-bass) * 22), 160, 0.5),
    rgba(26, calc(44 + var(--pulse-high) * 24), 118, 0.58)
  );
}

#seek-slider {
  width: 100%;
  margin-top: 6px;
  margin-bottom: 10px;
}

input[type="range"] {
  accent-color: #95aafe;
}

.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.download-progress {
  margin-top: 10px;
  margin-bottom: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(132, 156, 255, 0.3);
  background: rgba(7, 14, 35, 0.62);
}

.download-progress-bar-wrap {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.download-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2ed8ba, #4c79ff);
  transition: width 0.22s ease;
}

#download-progress-text {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.song-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(137, 158, 252, 0.28);
  border-radius: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  background: rgba(8, 14, 32, 0.55);
}

.song-panel.area-box h4 {
  margin-bottom: 4px;
}

.cover {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

#song-title {
  margin: 0 0 4px;
  font-size: 1.8rem;
  font-weight: 700;
}

#song-artist,
#song-album {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 1.12rem;
}

a {
  color: #a9bcff;
  word-break: break-all;
}

@media (max-width: 900px) {
  .room-grid {
    grid-template-columns: 1fr;
  }

  .queue-sidebar {
    order: 2;
  }

  .main-panel {
    order: 1;
  }
}

@media (max-width: 760px) {
  .container {
    padding: 12px;
  }

  .card {
    border-radius: 14px;
    padding: 14px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .room-head {
    flex-direction: column;
  }

  .room-head .btn {
    width: 100%;
  }

  .head-actions {
    width: 100%;
    flex-direction: column;
  }

  .host-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .host-box img {
    width: 190px;
    height: 190px;
    align-self: center;
  }

  .controls-row .btn,
  .responsive-row .btn {
    width: 100%;
  }

  .song-panel {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .cover {
    width: min(100%, 280px);
    height: auto;
    aspect-ratio: 1 / 1;
  }
}
