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

:root {
  --bg:          #111111;
  --surface:     #1a1a1a;
  --surface-2:   #242424;
  --border:      #2e2e2e;
  --text:        #f0f0f0;
  --text-muted:  #666666;
  --green:       #1db954;
  --green-glow:  rgba(29, 185, 84, 0.35);
  --yellow:      #f0b429;
  --red:         #e63946;
  --gray:        #3a3a3a;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 64px;
}

#app {
  width: 100%;
  max-width: 480px;
}

/* ── Header ─────────────────────────────── */

header {
  text-align: center;
  margin-bottom: 28px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.header-spacer {
  width: 36px;
}

.title {
  font-size: 2.75rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  color: var(--text);
}

.stats-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.stats-btn:hover {
  border-color: #555;
}

.stats-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
}

/* ── Genre Tabs ──────────────────────────── */

.genre-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.tab {
  padding: 7px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tab:hover:not(.active) {
  border-color: #555;
  color: var(--text);
}

.tab.active {
  background: var(--text);
  border-color: var(--text);
  color: #111;
}

/* ── Guess Slots ─────────────────────────── */

.guess-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.slot {
  height: 46px;
  border-radius: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.slot.correct {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 600;
}

.slot.wrong {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 600;
}

.slot.close {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #111;
  font-weight: 600;
}

.slot.skipped {
  background: var(--gray);
  border-color: var(--gray);
  color: #888;
  font-style: italic;
}

/* ── Timeline ────────────────────────────── */

.timeline-wrapper {
  position: relative;
  margin-bottom: 28px;
  padding-top: 22px;
}

.timeline-label {
  position: absolute;
  top: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transform: translateX(-50%);
  transition: left 0.3s ease;
}

.timeline-label::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  margin: 2px auto 0;
}

.timeline {
  display: flex;
  gap: 3px;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
}

.timeline-seg {
  height: 100%;
  border-radius: 2px;
  background: var(--surface-2);
  transition: background 0.3s ease;
}

.timeline-seg.unlocked {
  background: var(--green);
}

/* ── Play Button ─────────────────────────── */

.play-area {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.play-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--green-glow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.play-btn:hover:not(:disabled) {
  transform: scale(1.07);
  box-shadow: 0 6px 30px var(--green-glow);
}

.play-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.play-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.play-btn svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}

.play-btn .icon-play {
  margin-left: 3px; /* optical center for triangle */
}

/* ── Volume ──────────────────────────────── */

.volume-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: -16px;
  margin-bottom: 24px;
}

.vol-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  flex-shrink: 0;
}

#volumeSlider {
  width: 120px;
  accent-color: var(--green);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}

#volumeSlider:hover {
  opacity: 1;
}

/* ── Search + Skip ───────────────────────── */

.search-area {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.autocomplete-wrapper {
  position: relative;
  flex: 1;
}

#searchInput {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s;
}

#searchInput:focus {
  border-color: #4a4a4a;
}

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

#searchInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  list-style: none;
  z-index: 100;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-list li {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: background 0.1s;
}

.autocomplete-list li:first-child {
  border-radius: 6px 6px 0 0;
}

.autocomplete-list li:last-child {
  border-radius: 0 0 6px 6px;
}

.autocomplete-list li:hover,
.autocomplete-list li.highlighted {
  background: #2e2e2e;
}

.autocomplete-list li .song-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.autocomplete-list li .song-artist {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.skip-btn {
  padding: 12px 20px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.skip-btn:hover:not(:disabled) {
  border-color: #555;
  color: var(--text);
}

.skip-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Result Banner ───────────────────────── */

.result-banner {
  margin-top: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  text-align: center;
}

.result-banner[hidden] {
  display: none;
}

.result-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

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

.result-song strong {
  color: var(--text);
}

/* ── Spotify Embed ───────────────────────── */

.spotify-embed {
  margin-top: 16px;
  border-radius: 12px;
  overflow: hidden;
}

.spotify-embed[hidden] {
  display: none;
}

.spotify-embed iframe {
  display: block;
  border-radius: 12px;
}

.next-song-btn {
  margin-top: 16px;
  padding: 10px 28px;
  background: var(--green);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}

.next-song-btn:hover {
  opacity: 0.85;
  transform: scale(1.03);
}

.next-song-btn[hidden] {
  display: none;
}

/* ── Loading / Error states ──────────────── */

.status-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 8px 0;
}

.status-msg.error {
  color: var(--red);
}

/* ── Stats Modal ─────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: opacity 0.15s;
}

.modal-close:hover {
  opacity: 0.7;
}

.modal-close svg {
  width: 20px;
  height: 20px;
  fill: var(--text-muted);
}

.stats-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 28px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.dist-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.distribution {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.dist-num {
  color: var(--text-muted);
  width: 12px;
  text-align: right;
  flex-shrink: 0;
}

.dist-bar-wrap {
  flex: 1;
}

.dist-bar {
  height: 22px;
  border-radius: 3px;
  background: var(--gray);
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.dist-bar.highlight {
  background: var(--green);
}

/* ── Mode Subtitle ───────────────────────── */

.mode-subtitle {
  font-size: 0.8rem;
  color: var(--yellow);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.mode-subtitle[hidden] { display: none; }

/* ── Artist Filter Bar ───────────────────── */

.artist-filter-bar {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.artist-filter-bar[hidden] { display: none; }

.artist-filter-btn {
  padding: 6px 16px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.artist-filter-btn:hover {
  border-color: #555;
  color: var(--text);
}

.artist-filter-btn.active {
  border-color: var(--yellow);
  color: var(--yellow);
}

/* ── Hint Button ─────────────────────────── */

.hint-btn {
  padding: 12px 14px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.hint-btn:hover:not(:disabled) {
  border-color: var(--yellow);
  color: var(--yellow);
}

.hint-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Hint Display ────────────────────────── */

.hint-display {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(240, 180, 41, 0.1);
  border: 1.5px solid rgba(240, 180, 41, 0.3);
  border-radius: 8px;
  color: var(--yellow);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

.hint-display[hidden] { display: none; }

/* ── Share Button ────────────────────────── */

.share-btn {
  display: block;
  margin: 12px auto 0;
  padding: 9px 24px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.share-btn:hover {
  border-color: #555;
  color: var(--text);
}

/* ── Artist Picker Modal ─────────────────── */

.artist-search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}

.artist-search-input:focus {
  border-color: #4a4a4a;
}

.artist-search-input::placeholder {
  color: var(--text-muted);
}

.artist-list {
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.artist-list li {
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.1s;
}

.artist-list li:hover {
  background: var(--surface-2);
}

.artist-list li.selected {
  color: var(--yellow);
}

.artist-list .artist-count {
  color: var(--text-muted);
  font-size: 0.78rem;
  flex-shrink: 0;
  margin-left: 8px;
}

.artist-list .all-artists-item {
  font-weight: 700;
  border-bottom: 1.5px solid var(--border);
  border-radius: 0;
  margin-bottom: 4px;
  padding-bottom: 12px;
}

/* ── Game Skeleton ───────────────────────── */

.game-skeleton {
  padding: 24px 16px;
  max-width: 400px;
  margin: 0 auto;
}

/* ── Responsive ──────────────────────────── */

@media (max-width: 360px) {
  .title { font-size: 2.25rem; }
  .play-btn { width: 58px; height: 58px; }
  .play-btn svg { width: 22px; height: 22px; }
  .stat-value { font-size: 1.6rem; }
}
