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

:root {
  --bg: #0e0e12;
  --text: #f0ece2;
  --muted: #8a8a9a;
  --accent: #c5a3ff;
  --card-bg: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 600px;
  padding: 2rem;
  position: relative;
}

/* ---------- Loading Screen ---------- */

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 300px;
}

.loading-screen.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: var(--muted);
  font-style: italic;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Input Screen ---------- */

.input-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeUp 0.6s ease;
}

.title {
  font-family: 'DM Serif Display', serif;
  font-size: 2.8rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 2.5rem;
  font-size: 1.05rem;
}

.input-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#moodInput {
  width: 100%;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

#moodInput::placeholder {
  color: var(--muted);
  font-style: italic;
}

#moodInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(197, 163, 255, 0.15);
}

#matchBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #0e0e12;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

#matchBtn:hover {
  transform: translateY(-2px);
  opacity: 0.92;
}

#matchBtn:active {
  transform: translateY(0);
}

.btn-arrow {
  font-size: 1.2rem;
  transition: transform 0.2s;
}

#matchBtn:hover .btn-arrow {
  transform: translateX(3px);
}

/* ---------- Result Screen ---------- */

.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-height: 100vh;
}

.result-screen.hidden {
  display: none;
}

.input-screen.hidden {
  display: none;
}

/* Palette */

.palette {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.5s ease;
}

.palette .swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: popIn 0.4s ease both;
}

.palette .swatch:nth-child(1) { animation-delay: 0.1s; }
.palette .swatch:nth-child(2) { animation-delay: 0.15s; }
.palette .swatch:nth-child(3) { animation-delay: 0.2s; }
.palette .swatch:nth-child(4) { animation-delay: 0.25s; }
.palette .swatch:nth-child(5) { animation-delay: 0.3s; }

/* Caption */

.caption {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  line-height: 1.4;
  max-width: 480px;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.6s ease 0.2s both;
}

/* Song List */

.song-list {
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: fadeUp 0.6s ease 0.3s both;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.song-list::-webkit-scrollbar {
  width: 6px;
}

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

.song-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  transition: background 0.15s;
}

.song-row:hover {
  background: var(--card-bg);
}

.song-num {
  color: var(--muted);
  font-size: 0.8rem;
  min-width: 1.5rem;
  text-align: right;
}

.song-details {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.song-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-yt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.song-yt:hover {
  color: #ff0000;
  background: rgba(255, 0, 0, 0.1);
}

.song-yt svg {
  width: 16px;
  height: 16px;
}

/* Result Actions */

.result-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.5rem;
  animation: fadeUp 0.6s ease 0.5s both;
}

.suggest-more {
  padding: 0.7rem 1.5rem;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #0e0e12;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.suggest-more:hover {
  transform: translateY(-2px);
  opacity: 0.92;
}

.suggest-more:active {
  transform: translateY(0);
}

.suggest-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.try-again {
  padding: 0.7rem 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.try-again:hover {
  color: var(--text);
  border-color: var(--text);
}

/* ---------- Animations ---------- */

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

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .title {
    font-size: 2rem;
  }

  .caption {
    font-size: 1.2rem;
  }

  .palette .swatch {
    width: 40px;
    height: 40px;
  }

  .song-list {
    max-height: 45vh;
  }
}
