:root {
  --bg: #0d0f12;
  --card: #161a20;
  --line: #262c35;
  --text: #eef1f5;
  --muted: #8b95a3;
  --accent: #7cf5b0;
  --accent-ink: #062414;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef0ec;
    --card: #ffffff;
    --line: #dde1e6;
    --text: #14171c;
    --muted: #5f6a78;
    --accent: #0b7a43;
    --accent-ink: #ffffff;
  }
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 16px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.player {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
}

/* Station header */

.station { margin-bottom: 28px; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Listener count, next to "Live"; stays muted even while playing. */
.listeners { color: var(--muted); }
.listeners::before { content: "·"; margin-right: 8px; }

/* Three bars, one per YM2149 channel; they dance while playing. */
.channels { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.channels i { width: 3px; height: 4px; border-radius: 1px; background: currentColor; }
.player[data-state="playing"] .live { color: var(--accent); }
.player[data-state="playing"] .channels i { animation: channel 0.9s ease-in-out infinite alternate; }
.player[data-state="playing"] .channels i:nth-child(2) { animation-duration: 0.63s; }
.player[data-state="playing"] .channels i:nth-child(3) { animation-duration: 0.77s; }
@keyframes channel { from { height: 3px; } to { height: 12px; } }

h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.tagline { margin: 4px 0 0; color: var(--muted); font: 13px var(--mono); }

/* Current track */

.track { min-height: 96px; }
.track p { margin: 0; overflow-wrap: anywhere; }
.title { font-size: 20px; font-weight: 650; line-height: 1.3; }
.artist { margin-top: 4px !important; font-size: 16px; color: var(--accent); }
.meta { margin-top: 8px !important; font: 12px/1.5 var(--mono); color: var(--muted); }

/* Progress */

.progress {
  height: 4px;
  margin-top: 22px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.bar { width: 0; height: 100%; background: var(--accent); transition: width 1s linear; }
.times {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font: 12px var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Controls */

.controls { display: flex; align-items: center; gap: 20px; margin-top: 22px; }

.play {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.play:hover { transform: scale(1.04); }
.play:active { transform: scale(0.97); }
.play:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.play svg { grid-area: 1 / 1; width: 28px; height: 28px; fill: currentColor; }
.play .icon-stop, .play .spinner { display: none; }
.player[data-state="playing"] .icon-play { display: none; }
.player[data-state="playing"] .icon-stop { display: block; }
.player[data-state="loading"] .icon-play { display: none; }
.player[data-state="loading"] .spinner { display: block; }

.spinner {
  grid-area: 1 / 1;
  width: 26px;
  height: 26px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.volume { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.volume svg { flex: none; width: 20px; height: 20px; fill: currentColor; }
.volume .wave { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.volume input { flex: 1; min-width: 0; accent-color: var(--accent); }

.notice {
  margin: 20px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

/* Recently played */

.history {
  width: 100%;
  max-width: 420px;
  padding: 22px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.history[hidden] { display: none; }
.history h2 {
  margin: 0 0 12px;
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.history ol { margin: 0; padding: 0; list-style: none; }
.history li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.history li:first-child { border-top: 0; padding-top: 0; }
.history li:last-child { padding-bottom: 0; }
.history time {
  grid-row: span 2;
  padding-top: 2px;
  font: 12px var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.history-title { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.history-artist { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

footer { max-width: 420px; text-align: center; font-size: 12px; line-height: 1.5; color: var(--muted); }
footer a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .channels i, .spinner { animation: none !important; }
  .bar { transition: none; }
}
