:root {
  --bg: #eef4ff;
  --surface: #ffffff;
  --surface-soft: #f4f8ff;
  --text: #1f2d59;
  --muted: #6173a9;
  --border: #d7e2ff;
  --brandA: #6b63ff;
  --brandB: #35ccff;
  --brandC: #ff9c66;
  --brandD: #ffe06f;
  --danger: #ff4c88;
  --ok: #18c992;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--text);
  font-family: 'Poppins', Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at 6% 12%, #cbe9ff 0%, transparent 28%),
    radial-gradient(circle at 96% 18%, #ffe1cf 0%, transparent 25%),
    linear-gradient(180deg, #ebf3ff 0%, #f8f4ff 48%, #fff6ef 100%);
  overflow-x: hidden;
}

body[data-phase='playing'] {
  background:
    radial-gradient(circle at 10% 12%, #b8f4ff 0%, transparent 28%),
    radial-gradient(circle at 92% 18%, #d6cbff 0%, transparent 24%),
    linear-gradient(180deg, #e9fbff 0%, #f0f2ff 55%, #fffaf0 100%);
}

body[data-phase='voting'] {
  background:
    radial-gradient(circle at 8% 10%, #ffe6b8 0%, transparent 28%),
    radial-gradient(circle at 92% 16%, #ffd8ef 0%, transparent 24%),
    linear-gradient(180deg, #fff8e8 0%, #fff0fb 55%, #f5eeff 100%);
}

body[data-phase='results'] {
  background:
    radial-gradient(circle at 8% 10%, #d1ffd7 0%, transparent 28%),
    radial-gradient(circle at 92% 16%, #ffe3b3 0%, transparent 24%),
    linear-gradient(180deg, #ecfff2 0%, #effcff 55%, #fff7ea 100%);
}

#aurora {
  position: fixed;
  inset: -10%;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 20%, rgba(108, 99, 255, 0.2), transparent 35%),
    radial-gradient(circle at 82% 18%, rgba(46, 197, 255, 0.24), transparent 35%),
    radial-gradient(circle at 50% 88%, rgba(255, 138, 101, 0.2), transparent 35%);
  filter: blur(18px);
}

#bg-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.52;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 213, 79, 0.45) 0 3px, transparent 4px),
    radial-gradient(circle at 80% 60%, rgba(46, 197, 255, 0.4) 0 3px, transparent 4px),
    radial-gradient(circle at 65% 18%, rgba(255, 138, 101, 0.32) 0 2px, transparent 3px);
  background-size: 240px 240px, 280px 280px, 220px 220px;
}

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

@keyframes pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.45;
  }
  75% {
    transform: scale(1.5);
    opacity: 0;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@keyframes mascotBounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(-4deg);
  }
}

@keyframes burstFly {
  0% {
    transform: translateY(0) scale(0.7);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateY(-140px) scale(1.2) rotate(20deg);
    opacity: 0;
  }
}

.app-shell {
  position: relative;
  z-index: 2;
  max-width: 1020px;
  margin: 0 auto;
  padding: 14px 12px 72px;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #d6e3ff;
}

.app-brand {
  font-weight: 800;
  color: #2b3f8f;
}

.app-status {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #1f5f47;
  border: 1px solid #93e4bf;
  background: #e9fff5;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.hero {
  margin-bottom: 14px;
  background: linear-gradient(115deg, #ffffff 0%, #f8fbff 52%, #fff7ef 100%);
  border: 2px solid #d4e1ff;
}

.hero-sub {
  font-size: 1.02rem;
  margin-bottom: 10px;
}

.mascot-lane {
  display: flex;
  gap: 12px;
  padding-top: 4px;
}

.mascot {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #fff, #f0f6ff);
  border: 2px solid #d6e3ff;
  box-shadow: 0 8px 16px rgba(102, 124, 214, 0.16);
  font-size: 1.25rem;
  animation: mascotBounce 1.8s ease-in-out infinite;
}

.mascot:nth-child(2) {
  animation-delay: 0.25s;
}

.mascot:nth-child(3) {
  animation-delay: 0.4s;
}

.mascot:nth-child(4) {
  animation-delay: 0.6s;
}

.card {
  border-radius: 24px;
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 0 rgba(151, 168, 237, 0.22), 0 14px 28px rgba(72, 99, 188, 0.14);
  padding: 18px;
}

.glass {
  background: var(--surface);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: #1a2250;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
}

p {
  color: var(--muted);
}

.row {
  display: flex;
}

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

.row.between {
  justify-content: space-between;
}

.row.center {
  align-items: center;
}

.gap-sm {
  gap: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}

.home-join-card {
  margin-bottom: 14px;
  background: linear-gradient(145deg, #ffffff, #f3f8ff);
}

.join-sub {
  margin-bottom: 10px;
}

.join-wait-pill {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid #cce0ff;
  background: linear-gradient(135deg, #eaf6ff, #f2f0ff);
  color: #39508e;
  font-weight: 700;
  font-size: 0.85rem;
  animation: pulseSoft 1.4s ease-in-out infinite alternate;
}

.quick-guide {
  margin-top: 12px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.guide-bubble {
  background: linear-gradient(145deg, #fff8e8, #eef8ff);
  border: 2px solid #dbe6ff;
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  font-size: 0.84rem;
  color: #465990;
  font-weight: 700;
  animation: bob 2.2s ease-in-out infinite;
}

.guide-bubble:nth-child(2) {
  animation-delay: 0.2s;
}

.guide-bubble:nth-child(3) {
  animation-delay: 0.4s;
}

.create-room-details {
  margin-top: 12px;
}

.create-room-details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  text-align: center;
}

.create-room-details > summary::-webkit-details-marker {
  display: none;
}

.create-panel {
  margin-top: 10px;
  border: 2px dashed #d8e3ff;
  border-radius: 14px;
  padding: 12px;
  background: #f9fbff;
}

@keyframes pulseSoft {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.02);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.flow-guide {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.song-details {
  margin-top: 10px;
}

.song-details summary {
  cursor: pointer;
  font-weight: 600;
  color: #445792;
}

.system-feed-wrap {
  margin-top: 10px;
}

.system-feed-wrap summary {
  cursor: pointer;
  font-weight: 600;
  color: #445792;
}

.system-feed {
  margin-top: 8px;
  max-height: 130px;
  overflow: auto;
  border: 2px solid #d9e3ff;
  background: #f7faff;
  border-radius: 12px;
  padding: 8px;
}

.feed-item {
  font-size: 0.84rem;
  color: #56679f;
  padding: 5px 2px;
  border-bottom: 1px dashed #d8e2ff;
}

.feed-item:last-child {
  border-bottom: 0;
}

.flow-step {
  text-align: center;
  font-size: 0.82rem;
  padding: 9px;
  border-radius: 12px;
  border: 1px solid #e3e9ff;
  background: #f8faff;
  color: #6672a3;
  font-weight: 600;
  border-bottom-width: 3px;
  transition: transform 0.18s ease;
}

.flow-step.active {
  border-color: #b4c5ff;
  background: linear-gradient(135deg, #eef2ff, #e5f8ff);
  color: #30408d;
  box-shadow: 0 5px 18px rgba(107, 128, 255, 0.2);
  transform: translateY(-2px);
}

.phase-pill {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #c7d5ff;
  background: linear-gradient(135deg, #dff3ff, #e8e8ff);
  color: #314082;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-size: 0.9rem;
  color: #4d5a87;
}

input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 2px solid #d7e1ff;
  background: var(--surface-soft);
  color: var(--text);
}

input:focus {
  outline: 2px solid #9cb1ff;
  border-color: transparent;
}

.btn {
  margin-top: 12px;
  border: 0;
  border-radius: 16px;
  padding: 11px 15px;
  background: linear-gradient(135deg, #7a6fff, #4e9fff);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.btn:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.05);
  box-shadow: 0 10px 20px rgba(84, 117, 255, 0.24);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn.primary {
  background: linear-gradient(135deg, #6f66ff, #33c7ff);
}

.btn.ghost {
  background: linear-gradient(135deg, #f3f6ff, #ecf7ff);
  color: #314082;
  border-color: #cfdcff;
}

.btn.danger {
  background: linear-gradient(135deg, #ff6d8f, #ff4d7a);
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.88rem;
}

.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

.screen.active .card {
  animation: fadeIn 0.3s ease;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #cad6ff;
  background: #eef3ff;
  color: #33458b;
  padding: 4px 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.settings-grid {
  margin: 10px 0;
}

.players-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.player-tile {
  border: 2px solid #d8e2ff;
  border-radius: 18px;
  padding: 12px;
  text-align: left;
  font-weight: 650;
  color: #2f3d77;
  background: linear-gradient(160deg, #ffffff, #f4f8ff);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 -3px 0 rgba(175, 190, 240, 0.35);
}

.player-tile.host::after {
  content: '';
}

.player-tile.me {
  border-color: #8ee8cb;
  box-shadow: 0 0 0 1px rgba(18, 196, 139, 0.25);
}

.avatar-bubble {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.08rem;
  background: linear-gradient(135deg, #ffe37d, #ffad74);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 10px rgba(255, 158, 90, 0.3);
  flex-shrink: 0;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.host-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff3c7;
  border: 1px solid #ffe089;
  color: #6a4f00;
}

.player-tile.disconnected {
  opacity: 0.46;
  filter: grayscale(0.2);
}

.vote-grid .player-tile.vote-option {
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.vote-grid .player-tile.vote-option:hover {
  transform: translateY(-3px);
  border-color: #b2c4ff;
  box-shadow: 0 12px 18px rgba(108, 122, 204, 0.2);
}

.vote-grid .player-tile.selected {
  border-color: #83ddb9;
  background: linear-gradient(160deg, #f1fff9, #e9fff6);
  box-shadow: 0 0 0 2px rgba(18, 196, 139, 0.2);
}

.vote-grid .player-tile {
  min-height: 66px;
}

#voting-host-controls {
  display: none;
  margin: 8px 0;
}

.vote-grid .player-tile:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.countdown-wrap {
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.countdown {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(from 0deg, #61d9ff, #7e72ff, #ff9b75, #ffe07a, #61d9ff);
  color: #24305f;
  font-weight: 900;
  font-size: 2rem;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 20px rgba(100, 124, 235, 0.28);
}

.countdown.tick {
  animation: countdownPop 0.24s ease;
}

@keyframes countdownPop {
  0% {
    transform: scale(0.88);
  }
  100% {
    transform: scale(1);
  }
}

.play-card {
  text-align: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #ffffff, #f2f8ff);
  border-width: 3px;
}

.play-card h2 {
  font-size: 1.75rem;
}

.unlock-audio {
  margin: 8px auto 4px;
  display: inline-block;
  animation: pulseBtn 1.1s ease-in-out infinite alternate;
}

@keyframes pulseBtn {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.04);
  }
}

.pulse-ring {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(108, 99, 255, 0.45);
  position: relative;
}

.pulse-ring::before,
.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(46, 197, 255, 0.55);
  animation: pulse 2.5s linear infinite;
}

.pulse-ring::after {
  animation-delay: 1.1s;
}

.play-card audio {
  width: 100%;
  margin-top: 10px;
}

.hint {
  font-size: 0.82rem;
  opacity: 0.85;
}

.audio-no-signal {
  background: #fff8e1;
  color: #7a5200;
  border: 1.5px solid #ffca28;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 0.84rem;
  text-align: center;
  margin: 8px 0 4px;
  line-height: 1.45;
}

.song-list {
  margin-top: 10px;
  max-height: 170px;
  overflow: auto;
  border-radius: 12px;
  border: 2px solid #d9e3ff;
  background: #f7faff;
  padding: 8px;
  font-weight: 500;
}

.song-item {
  padding: 5px 4px;
  font-size: 0.92rem;
  color: #4e5b8b;
}

.song-item-title {
  font-weight: 700;
  color: #2e3c79;
  border-bottom: 1px solid #e0e8ff;
  margin-bottom: 4px;
}

.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.result-headline {
  font-size: 1.04rem;
  color: #273472;
  font-weight: 700;
  background: linear-gradient(135deg, #f0f4ff, #ecfbff);
  border: 2px solid #d4e2ff;
  border-radius: 14px;
  padding: 10px;
}

.winner-banner {
  margin-top: 10px;
  border-radius: 14px;
  padding: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
}

.winner-banner.crew {
  background: linear-gradient(135deg, #e7fff5, #e8f8ff);
  border: 2px solid #95e6c7;
  color: #1e6a52;
}

.winner-banner.imposter {
  background: linear-gradient(135deg, #fff0f6, #fff5ec);
  border: 2px solid #ffc2d7;
  color: #8a2f59;
}

body[data-phase='playing'] .app-topbar,
body[data-phase='playing'] .hero,
body[data-phase='playing'] .app-dock {
  opacity: 0.65;
}

.result-breakdown {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.vote-line {
  border-radius: 12px;
  padding: 10px;
  background: #f8fbff;
  border: 2px solid #dce5ff;
}

.songs-line {
  background: linear-gradient(135deg, #edf2ff, #e7f8ff);
  border-color: #cfe0ff;
  color: #3c4a83;
}

.result-player {
  display: grid;
  gap: 8px;
}

.result-player.imposter-reveal {
  border-color: #ffc6d4;
  background: linear-gradient(135deg, #fff4f7, #fff8fb);
  box-shadow: 0 8px 16px rgba(255, 134, 166, 0.2);
}

.result-player-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.result-sub {
  font-size: 0.86rem;
  color: #6572a0;
}

.votes-bar {
  height: 8px;
  border-radius: 999px;
  background: #e6ecff;
  overflow: hidden;
}

.votes-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5dcfff, #7d74ff);
}

.toast {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #d8e3ff;
  background: #ffffff;
  color: #2e3c79;
  box-shadow: 0 10px 20px rgba(99, 118, 193, 0.2);
}

.app-dock {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #d7e4ff;
  box-shadow: 0 8px 24px rgba(87, 102, 180, 0.22);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.dock-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f3f7ff, #edf9ff);
  border: 1px solid #d5e2ff;
}

.dock-pill.active {
  background: linear-gradient(135deg, #6f66ff, #31c9ff);
  color: #fff;
  border-color: transparent;
}

.party-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}

.burst-item {
  position: absolute;
  bottom: 18%;
  font-size: 1.25rem;
  animation: burstFly 1.2s ease-out forwards;
}

.toast.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .flow-guide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .players-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

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

@media (max-width: 720px) {
  .two-col {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 10px 8px 84px;
  }

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

  .app-dock {
    bottom: 8px;
  }
}
