*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-card: #1c1c1c;
  --bg-hover: #282828;
  --text-primary: #ffffff;
  --text-secondary: #b8b8b8;
  --text-muted: #707070;
  --accent: #00d4aa;
  --accent-hover: #00ecc0;
  --accent-glow: rgba(0, 212, 170, 0.15);
  --border-radius: 12px;
  --border-radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  --transition: 0.2s ease;
  --max-width: 520px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  background-image: linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)), url('img/Fondo.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
}

/* ========== HEADER ========== */
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0 4px;
}

.header-logo {
  max-height: 80px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

/* ========== PLAYER ========== */
.player {
  background: rgba(28, 28, 28, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--border-radius-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- Cover --- */
.cover-art {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease;
}

.cover-art.playing {
  transform: scale(1.02);
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- VU Meter --- */
.vu-meter {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 40px;
  width: 100%;
  max-width: 220px;
  padding: 4px 0;
}

.vu-bar {
  width: 14px;
  height: 4%;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(to top, var(--accent), #00f5d4);
  transition: height 0.08s ease, opacity 0.15s ease;
  opacity: 0.15;
  min-height: 3px;
}

/* --- Track Info --- */
.track-info {
  text-align: center;
  width: 100%;
}

.track-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  word-break: break-word;
}

.track-artist {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --- Progress --- */
.progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.progress-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 5px;
  background: var(--bg-hover);
  border-radius: 3px;
  pointer-events: none;
}

.progress-buffer {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  pointer-events: none;
  width: 0%;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 5px;
  background: linear-gradient(90deg, var(--accent), #00f5d4);
  border-radius: 3px;
  pointer-events: none;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 8px var(--accent-glow);
  pointer-events: none;
  left: 0%;
  transition: left 0.1s linear, transform 0.15s ease;
}

.progress-track:hover .progress-thumb,
.progress-track:active .progress-thumb {
  transform: translate(-50%, -50%) scale(1.25);
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* --- Controls --- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
}

.control-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
  color: var(--accent);
}

.control-btn:active {
  transform: scale(0.92);
}

.play-btn {
  background: var(--accent);
  width: 60px;
  height: 60px;
  box-shadow: 0 0 20px var(--accent-glow);
  color: #0a0a0a;
}

.play-btn:hover {
  background: var(--accent-hover);
  color: #0a0a0a;
  box-shadow: 0 0 30px var(--accent-glow);
}

.play-btn:active {
  transform: scale(0.9);
}

/* --- Volume --- */
.volume-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 180px;
}

.volume-btn {
  flex-shrink: 0;
  color: var(--text-muted);
}

.volume-btn:hover {
  color: var(--text-primary);
}

.volume-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-hover);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  border: none;
  transition: var(--transition);
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  border: none;
  cursor: pointer;
}

.volume-slider::-moz-range-track {
  background: var(--bg-hover);
  border-radius: 2px;
  height: 4px;
}

/* ========== INFO BAR (Reloj + Clima) ========== */
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(28, 28, 28, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--border-radius);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  gap: 12px;
}

.info-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  flex-shrink: 0;
}

.info-clock-digits {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-glow);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.info-clock-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0.6;
}

.info-weather {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}

.weather-loading {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.weather-error {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.wi-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.wi-temp {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.wi-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.wi-detail {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ========== FOOTER ========== */
.footer {
  margin-top: auto;
  padding: 12px 0 4px;
  text-align: center;
}

.footer p {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 360px) {
  .app { padding: 12px 10px; gap: 12px; }
  .player { padding: 16px 14px; gap: 12px; }
  .track-title { font-size: 1.05rem; }
  .play-btn { width: 52px; height: 52px; }
  .controls { gap: 16px; }
  .cover-art { max-width: 200px; }
  .vu-meter { height: 32px; max-width: 180px; }
  .vu-bar { width: 12px; }
  .info-clock-digits { font-size: 1.2rem; }
  .wi-temp { font-size: 1rem; }
  .header-logo { max-height: 60px; }
}

@media (min-width: 768px) {
  .app { padding: 32px 24px; gap: 24px; }
  .player { padding: 32px 28px; gap: 18px; }
  .track-title { font-size: 1.35rem; }
  .play-btn { width: 68px; height: 68px; }
  .control-btn svg { width: 30px; height: 30px; }
  .play-btn svg { width: 42px; height: 42px; }
  .cover-art { max-width: 320px; }
  .vu-meter { height: 48px; max-width: 260px; }
  .vu-bar { width: 16px; }
  .info-clock-digits { font-size: 1.8rem; }
  .wi-icon { font-size: 1.5rem; }
  .wi-temp { font-size: 1.4rem; }
  .header-logo { max-height: 100px; }
}

@media (min-width: 1200px) {
  :root { --max-width: 600px; }
  .app { padding: 40px 32px; gap: 28px; justify-content: center; }
  .player { padding: 36px 32px; gap: 20px; border-radius: 28px; }
  .track-title { font-size: 1.5rem; }
  .play-btn { width: 76px; height: 76px; }
  .play-btn svg { width: 46px; height: 46px; }
  .cover-art { max-width: 360px; }
  .vu-meter { height: 52px; max-width: 300px; }
  .vu-bar { width: 18px; }
  .info-clock-digits { font-size: 2rem; }
  .header-logo { max-height: 120px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .app {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    max-width: 100%;
    justify-content: center;
  }
  .player { max-width: 400px; padding: 14px; }
  .cover-art { max-width: 100px; }
  .vu-meter { height: 28px; max-width: 140px; }
  .vu-bar { width: 10px; }
  .header { display: none; }
  .info-clock-digits { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cover-art.playing { transform: none; }
}

/* ========== TV ========== */
.tv-container {
  background: rgba(28, 28, 28, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.tv-header {
  padding: 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tv-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0.7;
}

.tv-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.tv-player .clappr-player {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 360px) {
  .tv-player { aspect-ratio: 4 / 3; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .tv-container { max-width: 400px; }
}
