:root {
  --amber: #ffb454;
  --teal: #8fffe0;
  --cream: #f4e9d8;
  --ink: #2a1c10;
  --panel: rgba(20, 12, 6, 0.55);
  --panel-border: rgba(255, 220, 170, 0.18);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Poppins', sans-serif;
  color: var(--cream);
  background: #1c110a;
}

/* ===== Background scene ===== */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #1c110a;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  transition: opacity 0.25s ease;
}
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, transparent 40%, rgba(0,0,0,0.55) 100%);
}

/* ===== Mobile title fallback ===== */
.mobile-title {
  display: none;
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  text-align: center;
  width: 90vw;
  pointer-events: none;
}
.mobile-title h1 {
  font-family: 'VT323', monospace;
  font-size: clamp(2.2rem, 11vw, 3rem);
  letter-spacing: 2px;
  margin: 0;
  color: var(--amber);
  text-shadow: 0 4px 16px rgba(0,0,0,0.7);
}
.mobile-title p {
  margin: 0.2rem 0 0;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 0.7rem;
  opacity: 0.85;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
}

/* ===== Top chrome ===== */
.chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 1rem 1.25rem;
  pointer-events: none;
}
.chrome-left, .chrome-right, .chrome-center {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  pointer-events: auto;
  min-width: 0;
}
.chrome-left { justify-self: start; }
.chrome-center { justify-self: center; }
.chrome-right { justify-self: end; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--cream);
  text-decoration: none;
  white-space: nowrap;
}
.clock, .listeners {
  background: none;
  border-color: transparent;
  backdrop-filter: none;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
}
.clock { font-family: 'VT323', monospace; font-size: 1.15rem; letter-spacing: 1px; }
.listeners .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5cf27a;
  box-shadow: 0 0 6px #5cf27a;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}
.coffee {
  background: linear-gradient(135deg, #ffdd8f, #ffb454);
  color: #2a1608;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.coffee:hover { filter: brightness(1.05); }

/* ===== Playlist tabs ===== */
.playlist-tabs {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90vw;
}
.tab-btn {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--cream);
  opacity: 0.75;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.15s ease;
}
.tab-btn:hover { opacity: 1; }
.tab-btn.active {
  opacity: 1;
  background: linear-gradient(135deg, var(--amber), #ff7b54);
  color: #2a1608;
  border-color: transparent;
  font-weight: 600;
}

/* ===== Player bar ===== */
.player-bar {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(92vw, 720px);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 1rem;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.player-art {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #000;
  box-shadow: 0 0 0 0 rgba(255, 180, 84, 0);
  transition: box-shadow 0.4s ease;
}
body.is-playing .player-art {
  box-shadow: 0 0 0 2px var(--amber), 0 0 16px rgba(255, 180, 84, 0.55);
}
.player-art img { width: 100%; height: 100%; object-fit: cover; }

.player-info { flex: 1; min-width: 0; }
.track-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-sub {
  font-size: 0.72rem;
  opacity: 0.65;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.time { font-size: 0.68rem; opacity: 0.6; font-variant-numeric: tabular-nums; }
.progress-track {
  position: relative;
  flex: 1;
  height: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.progress-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 999px;
}
.progress-fill {
  position: relative;
  height: 4px;
  width: 0%;
  background: var(--amber);
  border-radius: 999px;
  transition: width 0.5s linear;
  z-index: 1;
}
.progress-track.seeking .progress-fill { transition: none; }
.progress-fill::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  transition: transform 0.15s ease;
}
.progress-track:hover .progress-fill::after,
.progress-track.seeking .progress-fill::after {
  transform: translateY(-50%) scale(1);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--cream);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.16); }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.shuffle {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  opacity: 0.5;
}
.ctrl-btn.shuffle.active {
  opacity: 1;
  background: rgba(255, 180, 84, 0.18);
  color: var(--amber);
}
.ctrl-btn.play {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--amber), #ff7b54);
  color: #2a1608;
  font-size: 1rem;
}

.player-volume {
  display: none;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.player-volume input {
  width: 70px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.2);
  border-radius: 999px;
}
.player-volume input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cream);
  cursor: pointer;
}

@media (min-width: 720px) {
  .player-volume { display: flex; }
}

/* ===== Footer ===== */
.credit {
  position: fixed;
  bottom: 0.35rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-size: 0.65rem;
  opacity: 0.5;
  pointer-events: none;
}
.credit a {
  color: var(--amber);
  pointer-events: auto;
  text-decoration: underline;
  text-decoration-color: rgba(255, 180, 84, 0.5);
}
.credit a:hover {
  opacity: 1;
  text-decoration-color: var(--amber);
}

.yt-mount {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* ===== Vintage grain overlay ===== */
.grain {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .mobile-title { display: block; }
  .playlist-tabs { top: 24%; }
  /* The background image's own baked-in title gets cropped illegible on
     narrow screens (see .mobile-title above); darken that band heavily
     so the leftover fragments don't clutter behind the readable text title. */
  .scene::after {
    background:
      linear-gradient(to bottom, rgba(10,6,3,0.82) 0%, rgba(10,6,3,0.82) 27%, transparent 42%),
      radial-gradient(circle at 50% 45%, transparent 40%, rgba(0,0,0,0.55) 100%);
  }
  .chrome { padding: 0.75rem 0.75rem; }
  .pill { padding: 0.4rem 0.7rem; font-size: 0.75rem; }
  .playlist-tabs { gap: 0.4rem; max-width: 94vw; }
  .tab-btn { font-size: 0.72rem; padding: 0.35rem 0.7rem; }
  .coffee .coffee-label { display: none; }
  .coffee { padding: 0.5rem; }
  .player-bar { bottom: 0.75rem; padding: 0.6rem 0.75rem; gap: 0.6rem; }
  .track-sub { display: none; }
  .credit { display: none; }
}
