* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-bottom: 80px;
  padding-top: 20px;
  padding-left: 40px;
  padding-right: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  color: #eee;
  background: no-repeat center center;
  background-size: cover;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: -1;
}

.player {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  margin: auto;
  flex: 1;
}

.album-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #333;
}

.album-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: #eee;
  line-height: 1.2;
}

.album-artist {
  font-size: 18px;
  margin: 0;
  color: #999;
  font-weight: 400;
  line-height: 1.2;
}

#now-playing {
  margin-bottom: 12px;
  font-size: 24px;
}

.now-playing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 8px;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  height: 1.2em;
}

.track-title-wrapper {
  flex: 1;
  min-width: 0;
  margin-right: 16px;
  overflow: hidden;
  position: relative;
  height: 100%;
}

#track-title {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

#track-title.long {
  animation: scroll-text var(--scroll-duration, 20s) linear infinite;
  text-overflow: unset;
  overflow: visible;
  max-width: none;
}

#track-title.long::after {
  content: attr(data-title);
  padding-left: 50px;
}

#track-time {
  flex-shrink: 0;
  white-space: nowrap;
}

@keyframes scroll-text {
  0%, 10% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(var(--scroll-distance, -200px));
  }
}

.controls,
.options {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 8px 0;
}

button {
  background: none;
  border: 1px solid #444;
  color: #eee;
  padding: 8px;
}

button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

input[type="range"] {
  width: 100%;
}

#download svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

#volume {
  width: 80px;
  margin-right: 8px;
  vertical-align: middle;
}

#playlist {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  max-height: 35vh;
  border-top: 1px solid #333;
  border-bottom: 1px solid #333;
}

#playlist li {
  padding: 8px 6px;
  cursor: pointer;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#playlist li.active {
  background: #333;
}

/* Firefox */
#playlist {
  scrollbar-width: thin;
  scrollbar-color: #444 #111;
}

/* WebKit */
#playlist::-webkit-scrollbar {
  width: 8px;
}

#playlist::-webkit-scrollbar-track {
  background: #111;
}

#playlist::-webkit-scrollbar-thumb {
  background-color: #444;
  border-radius: 4px;
}

.playlist-wrapper {
  margin-top: 12px;
}

.playlist-header {
  position: sticky;
  top: 0;
  width: 100%;
  background: #111;
  padding: 6px 8px;
  font-size: 12px;
  border-bottom: 1px solid #333;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

#playlist-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.playlist-wrapper.collapsed #playlist {
  max-height: 0;
  overflow: hidden;
}

.shortcuts summary {
  cursor: pointer;
  margin-top: 12px;
}

input,
button {
  background-color: #111;
  color: #eee;
  border-color: #444;
}

:root {
  color-scheme: dark;
}

html, body {
  color: #eee;
}

/* Range input – cross-browser dark styling */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

/* Track */
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #333;
  border-radius: 2px;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: #333;
  border-radius: 2px;
}

/* Thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #eee;
  border-radius: 50%;
  margin-top: -5px;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #eee;
  border-radius: 50%;
  border: none;
}

@media (hover: none), (max-width: 600px) {
  .options #volume {
    display: none;
  }
}

@media (hover: none), (max-width: 600px) {
  .shortcuts {
    display: none !important;
  }
}

@media (min-width: 801px) {
  body {
    background-attachment: fixed;
  }
}

/* Mobile optimization */
@media (max-height: 600px) {
  #playlist {
    max-height: 28vh;
  }
}

/* Desktop optimization */
@media (min-width: 800px) {
  #playlist {
    max-height: 300px;
  }
}

/* Footer navigation */
.footer {
  display: flex;
  justify-content: space-between;
  max-width: 420px;
  margin: 24px auto 0;
  padding: 16px;
  border-top: 1px solid #333;
}

.footer a {
  color: #eee;
  text-decoration: none;
  padding: 8px;
}

.footer a:hover {
  color: #fff;
  background: #333;
}
