@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #0e0e0e;
  --surface: #161616;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #666;
  --correct: #2d6a3f;
  --correct-text: #6fdc8c;
  --close: #7a5200;
  --close-text: #f1c21b;
  --wrong: #2a2a2a;
  --wrong-text: #888;
  --accent: #e8ff47;
  --cheat-color: #ff6b6b;
}

html, body {
  height: 100%;
}

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

header {
  width: 100%;
  max-width: 900px;
  padding: 32px 24px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
}

.logo span {
  color: var(--accent);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

#restart-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

#restart-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.guesses-counter {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.guesses-counter strong {
  color: var(--accent);
  font-weight: 500;
}

main {
  width: 100%;
  max-width: 900px;
  padding: 32px 24px;
  flex: 1;
}

.search-wrapper {
  position: relative;
  margin-bottom: 20px;
}

#search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s;
}

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

#search-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

#search-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 100;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.dropdown-item:hover {
  background: var(--border);
}

.dropdown-item img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.dropdown-item span {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item small {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Cheat / Dev Mode ─────────────────────────────────────── */

.cheat-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 10px 14px;
  background: rgba(255, 107, 107, 0.06);
  border: 1px solid rgba(255, 107, 107, 0.18);
  border-radius: 8px;
  width: fit-content;
  transition: border-color 0.2s, background 0.2s;
}

.cheat-wrapper:has(#cheat-toggle:checked) {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.35);
}

.cheat-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cheat-color);
  opacity: 0.7;
  transition: opacity 0.15s;
}

.cheat-toggle-label:hover {
  opacity: 1;
}

.cheat-toggle-label input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* Track */
.cheat-toggle-slider {
  position: relative;
  width: 38px;
  height: 20px;
  background: #2a2a2a;
  border-radius: 999px;
  border: 1px solid rgba(255, 107, 107, 0.3);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

/* Thumb */
.cheat-toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: #555;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.cheat-toggle-label input:checked + .cheat-toggle-slider {
  background: rgba(255, 107, 107, 0.25);
  border-color: var(--cheat-color);
}

.cheat-toggle-label input:checked + .cheat-toggle-slider::before {
  transform: translateX(18px);
  background: var(--cheat-color);
}

/* Dev badge */
.cheat-dev-badge {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--cheat-color);
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 4px;
  padding: 2px 6px;
  opacity: 0.8;
}

/* Answer reveal */
#cheat-box {
  display: none;
  align-items: center;
  gap: 8px;
}

#cheat-box::before {
  content: "→";
  color: var(--cheat-color);
  opacity: 0.5;
  font-size: 13px;
}

#cheat-answer {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--cheat-color);
  letter-spacing: 0.02em;
}

/* ── Legend ───────────────────────────────────────────────── */

.legend {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-dot.correct { background: var(--correct-text); }
.legend-dot.close { background: var(--close-text); }
.legend-dot.wrong { background: #555; }

/* ── Grid ─────────────────────────────────────────────────── */

#guesses-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-header {
  display: grid;
  grid-template-columns: 200px repeat(5, 1fr);
  gap: 6px;
  padding: 0 4px;
}

.header-artist,
.header-cell {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 8px;
}

.guess-row {
  display: grid;
  grid-template-columns: 200px repeat(5, 1fr);
  gap: 6px;
  animation: slideIn 0.3s ease both;
}

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

.guess-artist {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 0;
}

.guess-artist img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.guess-artist span {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
  text-align: center;
  min-height: 56px;
}

.guess-cell.correct {
  background: var(--correct);
  color: var(--correct-text);
}

.guess-cell.close {
  background: var(--close);
  color: var(--close-text);
}

.guess-cell.wrong {
  background: var(--wrong);
  color: var(--wrong-text);
}

.flag {
  width: 20px;
  height: auto;
  border-radius: 2px;
  margin-right: 5px;
  flex-shrink: 0;
}

.arrow {
  font-size: 16px;
  line-height: 1;
}

/* ── End overlay ──────────────────────────────────────────── */

#end-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

#end-overlay.visible {
  display: flex;
}

.end-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

#end-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 28px;
  letter-spacing: -0.5px;
}

#end-artist {
  margin-bottom: 28px;
}

#end-artist img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 14px;
  background: var(--border);
  border: 3px solid var(--border);
}

.end-artist-name {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.end-artist-meta {
  font-size: 13px;
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

#play-again-btn {
  background: var(--accent);
  color: #0e0e0e;
  border: none;
  border-radius: 8px;
  padding: 14px 32px;
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  letter-spacing: -0.3px;
}

#play-again-btn:hover {
  opacity: 0.85;
  transform: scale(0.98);
}

/* ── Toast ────────────────────────────────────────────────── */

#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
  pointer-events: none;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

@media (max-width: 900px) {
  header {
    padding: 24px 16px 20px;
  }

  main {
    padding: 24px 16px;
  }

  .logo {
    font-size: 24px;
  }

  #search-input {
    font-size: 15px;
    padding: 12px 16px;
  }

  .guess-cell {
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .grid-header,
  .guess-row {
    grid-template-columns: 120px repeat(5, 1fr);
  }

  .guess-artist {
    padding: 6px 8px;
  }

  .guess-artist span {
    font-size: 12px;
  }

  .guess-cell {
    font-size: 11px;
    padding: 6px 4px;
    min-height: 44px;
  }

  .dropdown-item {
    padding: 8px 10px;
  }

  .dropdown-item img {
    width: 30px;
    height: 30px;
  }

  .dropdown-item small {
    display: none;
  }

  .cheat-wrapper {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 20px;
  }

  #restart-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .guesses-counter {
    font-size: 11px;
  }

  .grid-header {
    display: none;
  }

  .guess-row {
    grid-template-columns: 1fr;
    gap: 8px;
    background: var(--surface);
    padding: 10px;
    border-radius: 8px;
  }

  .guess-artist {
    background: transparent;
    padding: 0;
  }

  .guess-cell {
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 12px;
    min-height: auto;
  }

  .guess-cell::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 400;
    font-family: 'Syne', sans-serif;
  }

  .legend {
    gap: 10px;
  }

  .end-card {
    padding: 28px 20px;
  }

  #end-title {
    font-size: 22px;
  }

  .end-artist-name {
    font-size: 18px;
  }

  #play-again-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .guess-cell {
    font-size: 10px;
  }

  .logo {
    font-size: 18px;
  }
}
.cheat-wrapper {
  display: none;
}