:root {
  color-scheme: dark;
  --ink: #f7f7f7;
  --paper: #000;
  --line: #303030;
  --muted: #a0a0a0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, a { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
main { min-height: 100vh; }
main.player-open { padding-bottom: 112px; }

.topbar {
  height: 82px;
  padding: 0 42px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 10px 18px;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.login-button:hover { background: var(--ink); color: var(--paper); }
.login-button.is-user { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.leaderboard { width: min(820px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 46px; }
.period-tabs {
  display: flex;
  align-items: center;
  gap: 26px;
  margin: 0 0 38px;
  overflow-x: auto;
  scrollbar-width: none;
}
.period-tabs::-webkit-scrollbar { display: none; }
.period-tab {
  position: relative;
  flex: 0 0 auto;
  border: 0;
  padding: 0 0 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.period-tab:hover, .period-tab.active { color: var(--ink); }
.period-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ink);
}
.list-heading {
  display: grid;
  grid-template-columns: 34px 38px minmax(200px, 1fr) 42px 58px 78px;
  gap: 10px;
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.heading-place { grid-column: 1 / 3; }
.heading-track { grid-column: 3; }
.heading-rating { grid-column: 5; text-align: right; }
.heading-vote { grid-column: 6; text-align: right; }
.track-list { border-top: 1px solid var(--ink); }
.track {
  min-height: 82px;
  display: grid;
  grid-template-columns: 34px 38px minmax(200px, 1fr) 42px 58px 78px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.place { color: var(--muted); font-size: 13px; font-weight: 700; }
.track:first-child .place { color: var(--ink); }
.play {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.play > span { display: block; transform: translateX(1px); }
.play.is-playing > span { transform: none; }
.play:hover, .play.is-playing { background: var(--ink); color: var(--paper); }
.track-copy { min-width: 0; }
.track-copy h2 { margin: 0 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.track-copy p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 1.3; font-weight: 500; }
.track-copy p span { opacity: .7; }
.duration { color: var(--muted); font-size: 12px; font-weight: 600; }
.score { text-align: right; font-size: 14px; font-weight: 800; }
.votes { display: flex; justify-content: flex-end; gap: 6px; }
.votes button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  font-family: "Segoe UI Symbol", Arial, sans-serif;
  font-size: 16px;
  line-height: 1;
}
.votes button:hover { border-color: var(--ink); transform: translateY(-1px); }
.votes button.active { color: var(--paper); border-color: var(--ink); background: var(--ink); }
.loading, .empty-state { min-height: 150px; display: grid; place-items: center; border-bottom: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 13px; line-height: 1.5; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 16px; }
.player-bar {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: 18px;
  width: min(820px, calc(100% - 40px));
  min-height: 76px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: minmax(150px, 190px) 42px minmax(260px, 1fr) 34px;
  gap: 14px;
  align-items: center;
  padding: 13px 16px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: #0a0a0a;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .5);
  animation: player-in .2s ease-out;
}
.player-bar[hidden] { display: none; }
@keyframes player-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.player-track { min-width: 0; }
.player-track strong, .player-track span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-track strong { font-size: 14px; }
.player-track span { margin-top: 4px; color: #bdbdbd; font-size: 11px; }
.player-toggle, .player-close { display: grid; place-items: center; color: var(--ink); background: transparent; cursor: pointer; }
.player-toggle { width: 38px; height: 38px; padding: 0; border: 1px solid #777; border-radius: 50%; font-size: 12px; line-height: 1; }
.player-toggle span { display: grid; place-items: center; width: 100%; height: 100%; }
.player-close { width: 30px; height: 30px; border: 0; border-radius: 6px; font-size: 24px; }
.player-toggle:hover, .player-close:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.player-timeline { display: grid; grid-template-columns: 38px minmax(100px, 1fr) 38px; gap: 9px; align-items: center; }
.player-timeline time { color: #d0d0d0; font-size: 10px; text-align: center; }
.player-timeline input { width: 100%; height: 20px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; opacity: 0; transform: translate(-50%, 14px); border-radius: 999px; padding: 10px 16px; background: var(--ink); color: var(--paper); pointer-events: none; font-size: 12px; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
main.player-open .toast { bottom: 112px; }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #888; outline-offset: 3px; }

@media (max-width: 800px) {
  .topbar { height: 68px; padding: 0 20px; }
  .login-button { min-height: 38px; padding: 8px 13px; font-size: 11px; }
  .leaderboard { width: min(100% - 32px, 620px); padding-top: 48px; }
  .period-tabs { gap: 20px; margin-bottom: 32px; }
  .period-tab { font-size: 11px; }
  .list-heading { grid-template-columns: 28px 36px minmax(0, 1fr) 48px 74px; }
  .heading-place { grid-column: 1 / 3; }
  .heading-track { grid-column: 3; }
  .heading-rating { grid-column: 4; }
  .heading-vote { grid-column: 5; }
  .track { grid-template-columns: 28px 36px minmax(0, 1fr) 48px 74px; gap: 8px; min-height: 78px; }
  .track .duration { display: none; }
  .score { grid-column: 4; }
  .votes { grid-column: 5; }
  .player-bar { width: min(100% - 24px, 620px); grid-template-columns: minmax(0, 1fr) 40px 32px; gap: 10px; bottom: 12px; }
  .player-timeline { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 520px) {
  .login-button { border: 0; padding: 8px 0; text-decoration: underline; text-underline-offset: 4px; }
  .leaderboard { padding-top: 42px; }
  .track { grid-template-columns: 25px 34px minmax(0, 1fr) 70px; }
  .score { display: none; }
  .votes { grid-column: 4; }
  .track-copy h2 { font-size: 15px; }
  .track-copy p span { display: none; }
  .list-heading { grid-template-columns: 59px minmax(0, 1fr) 70px; }
  .heading-place { grid-column: 1; }
  .heading-track { grid-column: 2; }
  .heading-rating { display: none; }
  .heading-vote { grid-column: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
