* { box-sizing: border-box; }

/* Form controls don't inherit font-family from the page by default in most
   browsers' own UA stylesheets - force it so buttons/inputs stay terminal-styled too. */
button, input {
  font-family: inherit;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #fff;
  overflow-x: hidden;
  overflow-y: auto;
}

#wallpaper {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #111;
  z-index: -2;
  opacity: 0;
  filter: brightness(1.3) contrast(1.05);
  transition: opacity 1.5s ease;
}

#wallpaper.loaded {
  opacity: 1;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  z-index: -1;
}

.player {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  text-align: center;
  padding: 2rem;
}

h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

:root {
  /* Dark phosphor-terminal palette - matches the monochrome/CRT/hacker-noir
     wallpapers rather than a bright modern-app gradient. */
  --accent-1: #142a1e;
  --accent-2: #f5f5f5;
  --accent-gradient: radial-gradient(circle at 50% 38%, var(--accent-1) 0%, #05100a 75%);
  --noise-texture: 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.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- analog/CRT page overlay: subtle static grain + a sweeping interference band --- */
.crt-static {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background-image: var(--noise-texture);
  background-size: 140px 140px;
  opacity: 0.11;
  mix-blend-mode: overlay;
  animation: staticFlicker 0.15s steps(3) infinite;
}

@keyframes staticFlicker {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-3%, 2%); }
  66%  { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

.crt-scanband {
  position: fixed;
  left: 0;
  right: 0;
  height: 12vh;
  top: -15vh;
  z-index: 51;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.09) 45%,
    rgba(255, 255, 255, 0.16) 50%,
    rgba(255, 255, 255, 0.09) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  mix-blend-mode: overlay;
  animation: scanDown 9s linear infinite;
}

@keyframes scanDown {
  0%   { top: -15vh; }
  100% { top: 115vh; }
}

/* --- recent plays --- the first line (currently playing) reads as clearly
   as the STOPPED/PLAYING status text; the rest fade into background texture,
   like the code baked into the wallpaper images. Pinned to the far right on
   wide screens; on narrow screens (see media query) it drops into normal
   flow below the status line instead, since there's no room off to the side. */
.recent-songs {
  position: fixed;
  right: 4vw;
  top: 58%;
  max-width: min(40vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  font-family: "Courier New", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  text-align: left;
  pointer-events: none;
  z-index: 1;
}

.recent-songs div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* currently playing - as readable as .status */
.recent-now-playing {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

/* section label introducing the fading history list, with a typed-cursor feel */
.recent-label {
  margin-top: 0.4em;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.blink-cursor {
  display: inline-block;
  margin-left: 2px;
  animation: blinkCursor 1s step-end infinite;
}

@keyframes blinkCursor {
  0%, 50%  { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* per-item fade opacity is set inline (see player.js) since each item's
   position in the list determines it, not sibling order among mixed elements */
.recent-item {
  color: rgba(255, 255, 255, 0.4);
}

@media (max-width: 700px) {
  .recent-songs {
    position: static;
    right: auto;
    top: auto;
    max-width: 90vw;
    width: 100%;
    align-items: center;
    text-align: center;
    margin-top: 0.25rem;
  }
}

.play-btn {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 1px solid rgba(120, 255, 180, 0.3);
  background: var(--accent-gradient);
  color: var(--accent-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 26px -4px rgba(255, 255, 255, 0.45),
    inset 0 0 22px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

/* faint scanlines inside the button, echoing the CRT-screen texture used
   elsewhere on the page/TV */
.play-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.06) 0px,
    rgba(255, 255, 255, 0.06) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  pointer-events: none;
}

.play-btn:hover {
  transform: scale(1.05);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 34px -2px rgba(255, 255, 255, 0.65),
    inset 0 0 22px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.play-btn:active { transform: scale(0.94); }

/* "On-air" pulse rings, only animated while playing - reads like a signal
   sweep rather than a friendly UI bounce */
.play-btn-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  opacity: 0;
  pointer-events: none;
}

.play-btn.is-playing .play-btn-ring {
  animation: pulse-ring 2.2s cubic-bezier(0.2, 0.7, 0.4, 1) infinite;
}

.play-btn.is-playing .play-btn-ring--2 {
  animation-delay: 1.1s;
}

@keyframes pulse-ring {
  0%   { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.55); }
}

.btn-icon {
  position: absolute;
  width: 34px;
  height: 34px;
  fill: currentColor;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.85));
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-play { opacity: 1; transform: scale(1) rotate(0deg); }
.icon-pause { opacity: 0; transform: scale(0.6) rotate(-45deg); }

.play-btn.is-playing .icon-play { opacity: 0; transform: scale(0.6) rotate(45deg); }
.play-btn.is-playing .icon-pause { opacity: 1; transform: scale(1) rotate(0deg); }

.volume-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.mute-btn {
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: color 0.2s ease, background 0.2s ease;
}

.mute-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.vol-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.slider-track {
  position: relative;
  display: flex;
  align-items: center;
}

/* Styled like an analog VU-meter/mixing-console fader rather than a smooth
   modern slider: segmented LED-style ticks filling with phosphor white, and
   a thin fader-cap thumb instead of a round dot. */
.volume-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 10px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(
      to right,
      rgba(0, 0, 0, 0.55) 0px,
      rgba(0, 0, 0, 0.55) 1px,
      transparent 1px,
      transparent 7px
    ),
    linear-gradient(
      to right,
      var(--accent-2) 0%,
      var(--accent-2) calc(var(--volume, 0.8) * 100%),
      rgba(255, 255, 255, 0.1) calc(var(--volume, 0.8) * 100%),
      rgba(255, 255, 255, 0.1) 100%
    );
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  outline: none;
}

/* Some engines still render an opaque native track pseudo-element on top of
   the input's own background even with appearance:none - force it transparent
   so the gradient fill above shows through. */
.volume-row input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 10px;
  border-radius: 2px;
}

.volume-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 4px;
  height: 18px;
  border-radius: 1px;
  background: #ffffff;
  box-shadow: 0 0 6px 1px rgba(255, 255, 255, 0.85), 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.volume-row input[type="range"]:hover::-webkit-slider-thumb,
.volume-row input[type="range"]:active::-webkit-slider-thumb {
  transform: scaleY(1.15);
  box-shadow: 0 0 10px 2px rgba(255, 255, 255, 1), 0 1px 3px rgba(0, 0, 0, 0.6);
}

.volume-row input[type="range"]::-moz-range-track {
  height: 10px;
  border-radius: 2px;
  background: transparent;
}

.volume-row input[type="range"]::-moz-range-progress {
  height: 10px;
  border-radius: 2px;
  background: var(--accent-2);
}

.volume-row input[type="range"]::-moz-range-thumb {
  width: 4px;
  height: 18px;
  border: none;
  border-radius: 1px;
  background: #ffffff;
  box-shadow: 0 0 6px 1px rgba(255, 255, 255, 0.85), 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.volume-row input[type="range"]:hover::-moz-range-thumb,
.volume-row input[type="range"]:active::-moz-range-thumb {
  transform: scaleY(1.15);
}

.status {
  font-size: 0.75rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --- "history" link under the player --- */
.history-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.history-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* --- draggable "TV" play-history window: built entirely in CSS, no image --- */
.tv-popup {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: min(92vw, 480px);
  display: none;
  flex-direction: column;
  user-select: none;
}

.tv-popup.open {
  display: flex;
}

.tv-dragbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(20, 20, 22, 0.5);
  backdrop-filter: blur(6px);
  border-radius: 10px 10px 0 0;
  cursor: grab;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.tv-dragbar:active {
  cursor: grabbing;
}

.tv-dragbar-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 6px #ffffff;
  animation: dotPulse 1.6s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.tv-dragbar-label {
  flex: 1;
}

.tv-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.tv-close:hover {
  color: #fff;
}

.tv-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: transparent;
}

/* the popup itself: a glowing orange rounded rectangle, no TV chassis */
.tv-screen {
  position: relative;
  background: rgba(10, 10, 12, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  overflow: hidden;
  height: min(46vh, 320px);
  box-shadow:
    0 0 30px rgba(255, 255, 255, 0.35),
    0 0 60px rgba(255, 255, 255, 0.18),
    inset 0 0 30px rgba(255, 255, 255, 0.15);
}

.tv-screen-static {
  position: absolute;
  inset: 0;
  background-image: var(--noise-texture);
  background-size: 90px 90px;
  opacity: 0.28;
  mix-blend-mode: screen;
  animation: staticFlicker 0.15s steps(3) infinite;
  pointer-events: none;
}

.tv-screen-static::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--noise-texture);
  background-size: 230px 230px;
  opacity: 0.16;
  mix-blend-mode: overlay;
}

.tv-screen-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.4) 0px,
    rgba(0, 0, 0, 0.4) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
  pointer-events: none;
}

.tv-screen-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 60px 12px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.tv-log {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: #f5f5f5;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.55), 0 0 1px rgba(255, 255, 255, 0.8);
}

.tv-log::-webkit-scrollbar {
  width: 6px;
}

.tv-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 3px;
}

.tv-log::-webkit-scrollbar-track {
  background: transparent;
}

.tv-log-entry {
  white-space: pre-wrap;
}

.tv-log-time {
  opacity: 0.7;
  margin-right: 0.6em;
}

.tv-log-empty {
  opacity: 0.6;
}

.tv-plaque {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: linear-gradient(165deg, rgba(34, 34, 36, 0.5), rgba(12, 12, 13, 0.5));
  border-radius: 8px;
  padding: 7px 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 2px 5px rgba(0, 0, 0, 0.6);
}

.tv-plaque-brand {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.55);
}

.tv-tuning-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.tv-tuning-minmax {
  flex: none;
  font-size: 0.4rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.tv-led-bar {
  flex: 1;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.tv-led-bar span {
  flex: 1;
  height: 6px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.tv-led-bar span:nth-child(-n+5) {
  background: #ffffff;
  box-shadow: 0 0 5px #ffffff;
  animation: ledFlicker 2.4s ease-in-out infinite;
}

.tv-led-bar span:nth-child(1) { animation-delay: 0.1s; }
.tv-led-bar span:nth-child(2) { animation-delay: 0.4s; }
.tv-led-bar span:nth-child(3) { animation-delay: 0.7s; }
.tv-led-bar span:nth-child(4) { animation-delay: 1.0s; }
.tv-led-bar span:nth-child(5) { animation-delay: 1.3s; }

@keyframes ledFlicker {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}
