:root {
  --bg: #08080b;
  --panel: #121218;
  --panel-2: #1a1a22;
  --line: #2a2a35;
  --text: #f2f2f5;
  --muted: #9a9aab;
  --accent: #e8ff3c;
  --accent-ink: #0b0b00;
  --a: #ff4d6d;
  --b: #4dd2ff;
  --danger: #ff5a4d;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 'Space Grotesk', system-ui, sans-serif; min-height: 100vh; }
a { color: var(--accent); }
h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 10px; }
.lede { color: var(--muted); font-size: 17px; margin: 0 0 20px; }
.hint { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: rgba(8, 8, 11, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
nav { display: flex; gap: 4px; overflow-x: auto; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 999px; font: inherit; cursor: pointer; white-space: nowrap; }
nav button.on { background: var(--panel-2); color: var(--text); }

main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
.view.narrow { max-width: 680px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1 1 220px; }

input, button { font: inherit; }
input[type=search], input:not([type]) {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; min-width: 0;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { cursor: pointer; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
button:disabled { opacity: .4; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.ghost:hover:not(:disabled) { border-color: var(--muted); }
.big { padding: 14px 22px; font-size: 17px; }
.small { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); padding: 4px; font-size: 13px; text-decoration: underline; }
.link:hover { color: var(--text); }
.danger { border-color: #4a2320; }
.danger-btn { background: transparent; color: var(--danger); border-color: var(--danger); }
.filebtn { display: inline-block; cursor: pointer; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line); background: var(--panel-2); }
kbd { font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border: 1px solid currentColor; border-radius: 4px; opacity: .6; margin-left: 4px; }

.steps ol { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 10px; }
.copyrow { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
code { background: var(--panel-2); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); word-break: break-all; }

.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#toast.err { border-color: var(--danger); }

/* Songs */
.songs-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.filters label { display: flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }
.filters .hint { width: 100%; margin: 0; }
.start { margin-top: 16px; }
.slider { display: block; margin: 8px 0 12px; }
.slider input { width: 100%; accent-color: var(--accent); }
#song-search, #rank-search { width: 100%; margin: 12px 0; }
.songlist, .ranklist { list-style: none; padding: 0; margin: 0; }
.songlist li, .ranklist li {
  display: grid; grid-template-columns: auto 44px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 6px; border-bottom: 1px solid var(--line);
}
.songlist li.off { opacity: .4; }
.songlist img, .ranklist img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--panel-2); }
.t-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-main { min-width: 0; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; font-weight: 500; }
.badge.warn { border-color: #6b5a1d; color: #e5c454; }
.songlist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.ranklist .pos { font-weight: 700; font-size: 18px; width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.ranklist .stat { text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranklist li.locked .pos { color: var(--accent); }
.ranklist .lock { font-size: 12px; }

/* Matchup */
.progress { margin-bottom: 20px; }
.progress-label { display: flex; gap: 14px; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; }
.progress-label span { color: var(--muted); font-size: 14px; }
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: start; }
.vs { align-self: center; font-weight: 700; font-size: 28px; color: var(--muted); letter-spacing: .05em; }
.side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0; transition: transform .15s, border-color .15s;
}
.side[data-side=a] { border-top: 3px solid var(--a); }
.side[data-side=b] { border-top: 3px solid var(--b); }
.side.chosen { transform: scale(1.02); border-color: var(--accent); }
.art { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--panel-2); max-height: 300px; }
.art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta .name { font-size: 22px; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.meta p { margin: 2px 0 0; color: var(--muted); }
.meta .record { font-size: 13px; }
.embed { min-height: 152px; border-radius: 12px; overflow: hidden; }
.embed iframe { display: block; width: 100%; border: 0; border-radius: 12px; }
.pick { width: 100%; }
.remove { align-self: center; }
.controls { display: flex; gap: 10px; justify-content: center; margin: 20px 0 8px; flex-wrap: wrap; }
.interstitial { max-width: 680px; margin: 0 auto; }
.interstitial ol { padding-left: 22px; }
.interstitial .row { margin-top: 14px; }
.interstitial input[type=number] { width: 90px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px; }

@media (max-width: 760px) {
  main { padding: 18px 16px 60px; }
  .top { padding: 10px 16px; }
  .brand span { display: none; }
  .matchup { grid-template-columns: 1fr; gap: 12px; }
  .vs { justify-self: center; font-size: 20px; }
  nav button { padding: 8px 10px; }
  .side { display: grid; grid-template-columns: 72px 1fr; gap: 10px 12px; padding: 12px; }
  .art { width: 72px; height: 72px; max-height: none; border-radius: 8px; }
  .embed, .pick, .remove { grid-column: 1 / -1; }
  .embed { min-height: 80px; }
  .embed iframe { height: 80px; }
  .remove { justify-self: center; }
  .meta .name { font-size: 17px; }
  .controls { margin-top: 12px; }
  kbd { display: none; }
  .songlist li, .ranklist li { grid-template-columns: auto 40px 1fr; }
  .songlist li > :last-child, .ranklist li > .stat { grid-column: 3; justify-self: start; text-align: left; }
}

/* Artists screen & setup */
#brand-artist { color: var(--accent); margin-left: 4px; }
#artist-search { width: 100%; margin: 4px 0 8px; font-size: 17px; padding: 14px 16px; }
#artist-results img, #saved-list img { border-radius: 50%; }
#artist-results li, #saved-list li { grid-template-columns: 44px 1fr auto; }
#artist-results li > span:first-child { display: none; }
.section-h { margin-top: 28px; }
.share-hint { margin-top: 28px; }
details.steps summary { cursor: pointer; list-style: none; }
details.steps summary::-webkit-details-marker { display: none; }
details.steps summary h2 { display: inline; }
details.steps summary::after { content: ' ▾'; color: var(--muted); }
details.steps[open] summary { margin-bottom: 12px; }
@media (max-width: 760px) {
  #brand-artist { display: none; }
  #artist-results li, #saved-list li { grid-template-columns: 40px 1fr; }
  #artist-results li > :last-child, #saved-list li > :last-child { grid-column: 2; }
}
