:root {
  --bg-color: #222;
  --main-color: #4caf50;
  --btn-color: #4caf50;
  --btn-down-color: #f44336;
  --btn-text: #fff;
  --vote-ok: #00ff80;
  --vote-error: #ff6b6b;
  --circle-color: rgba(255,0,255,0.28);
  --vote-radius: 12px;
  --bg-blur: 10px;
  --card-radius: 15px;
  --card-border: 2px solid var(--main-color);
}

/* === Strona === */
body {
  font-family: sans-serif;
  text-align: center;
  margin: 2rem;
  background: var(--bg-color);
  color: #fff;
}
h1 { margin-bottom: 1rem; }
.section { margin-bottom: 2rem; }

/* === Teraz gramy === */
#nowplaying {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
}

/* === Karta utworu === */
.now-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1200px;
  max-width: 100%;
  height: 600px;              /* domyślnie dopasowana do zawartości */
  max-height: 620px;         /* nie przekracza 620px */
  padding: 1.5rem;
  border: var(--card-border);
  border-radius: var(--card-radius);
  background: #111;
  overflow: hidden;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
  will-change: transform;
  animation: pulseGlow 6s ease-in-out infinite;
}



/* 📱 iOS Safari fix — zapobiega ściskaniu treści */
@supports (-webkit-touch-callout: none) {
  .now-track:not(.fullscreen-active):not(.ios-fs) {
    height: min(55vh, 80vw); /* niech zajmuje 55% ekranu, ale nie więcej niż 80% szerokości */
    max-height: 500px;
  }
}


/* Efekt hover & bounce dla Teraz Gramy */
.now-track:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.35);
  border-color: var(--main-color);
}
.now-track:hover .main-artwork {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Pulsujący cień w rytmie muzyki */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.25); }
  50% { box-shadow: 0 0 35px rgba(76, 175, 80, 0.4); }
}

/* Rozmyte tło + canvas */
.now-track .bg-artwork {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(var(--bg-blur)) brightness(0.35);
  z-index: 0;
}
.now-track canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* Zawartość karty */
.now-track .content-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.main-artwork {
  width: 250px; height: 250px;
  border-radius: 15px;
  object-fit: cover;
  box-shadow: 0 0 30px 5px rgba(255,255,255,0.6);
  transition: all 0.6s ease-in-out;
}

.info-wrap {
  text-align: left;
  min-width: 260px;
  transition: all 0.5s ease;
}

/* Teksty */
.track-artist {
  font-size: 1.8rem;
  margin: 0 0 0.2rem 0;
}
.track-title {
  font-size: 1.4rem;
  margin: 0 0 0.8rem 0;
  color: #ddd;
}

/* Player controls */
.player-controls {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.player-controls .playBtn,
.player-controls .fsBtn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  background: var(--main-color);
  color: #fff;
  transition: all 0.3s ease;
}

/* Głośność */
.volume-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.volume-row .muteBtn,
.volume-row .unmuteBtn {
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: #333;
  color: #fff;
  cursor: pointer;
}
.volume-row .volumeControl {
  width: 100%;
}

/* Komunikaty */
.vote-msg {
  min-height: 1.2em;
  margin-top: 0.35rem;
  font-weight: bold;
  font-size: 0.95rem;
}

/* Głosowanie 👍 👎 */
.buttons {
  margin-top: 0.6rem;
  display: flex;
  justify-content: center;
  gap: 1.4rem;
}
.buttons .up,
.buttons .down {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--vote-radius);
  cursor: pointer;
  font-weight: bold;
  color: var(--btn-text);
  transition: transform 0.3s ease;
}
.buttons .up { background: var(--btn-color); }
.buttons .down { background: var(--btn-down-color); }
.buttons .up:hover,
.buttons .down:hover { transform: scale(1.1); }

/* === FULLSCREEN === */
.now-track.fullscreen-active {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  border: none;
  border-radius: 0;
  padding: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 9999;
  transition: all 0.6s ease-in-out;
}

/* Artwork fullscreen */
.now-track.fullscreen-active .main-artwork {
  width: min(30vw, 30vh);
  height: min(30vw, 30vh);
  border-radius: 20px;
  box-shadow: 0 0 35px rgba(255,255,255,0.5);
  margin-bottom: 1rem;
}

/* Teksty fullscreen */
.now-track.fullscreen-active .track-artist {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  text-align: center;
}
.now-track.fullscreen-active .track-title {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: #ddd;
  text-align: center;
  margin-bottom: 1rem;
}

/* Przyciski fullscreen */
.now-track.fullscreen-active .player-controls,
.now-track.fullscreen-active .volume-row,
.now-track.fullscreen-active .buttons {
  justify-content: center;
  align-items: center;
}

/* === POPRAWKA: "Ostatnio grane" – efekt hover + bounce (3 karty w rzędzie) === */
#history {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.2rem;
  max-width: 1200px;
  margin: 0 auto;
}

#history .track {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 calc(33.33% - 1.2rem);
  max-width: 400px;
  background: #333;
  border-radius: 10px;
  border: 2px solid var(--main-color);
  padding: 1rem;
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.6s ease forwards;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease,
    background 0.3s ease;
  will-change: transform;
}

/* Hover + bounce */
#history .track:hover {
  transform: scale(1.03);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
  background: #3a3a3a;
}

#history .track img {
  width: 160px;
  height: 160px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 1rem;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
}

#history .track:hover img {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

#history .track-info {
  text-align: left;
  flex: 1;
}

#history .track-info h3 {
  margin: 0 0 0.3rem 0;
  font-size: 1.3rem;
}
#history .track-info p {
  margin: 0 0 0.4rem 0;
  font-size: 1.1rem;
  color: #ddd;
}

/* Efekt fade-in */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 🌟 Błysk tła */
@keyframes bgFlash {
  0% { filter: blur(var(--bg-blur)) brightness(0.35); }
  50% { filter: blur(var(--bg-blur)) brightness(0.55); }
  100% { filter: blur(var(--bg-blur)) brightness(0.35); }
}
.bg-flash {
  animation: bgFlash 1.2s ease-in-out;
}

/* 📱 Responsywność */
@media (max-width: 1200px) {
  #history .track { flex: 1 1 calc(50% - 1.2rem); }
}

@media (max-width: 800px) {
  #history .track { flex: 1 1 100%; }
  .content-wrap { flex-direction: column; }
  .main-artwork { width: 200px; height: 200px; }
  .info-wrap { text-align: center; }
}

/* ✅ MOBILE LANDSCAPE FIX — artwork po lewej, reszta po prawej */
@media (max-width: 768px) and (orientation: landscape) {
  .now-track.fullscreen-active .content-wrap {
    flex-direction: row !important;
    align-items: center;
    justify-content: center;
    gap: 3vw;
  }

  .now-track.fullscreen-active .main-artwork {
    width: 55vh;
    height: 55vh;
    margin-left: -3%;
  }

  .now-track.fullscreen-active .info-wrap {
    max-width: 45%;
  }

  .now-track.fullscreen-active .buttons {
    gap: 1.8rem;
  }
}
/* === FINAL OVERRIDE: fullscreen landscape na wszystkich urządzeniach === */
@media (orientation: landscape) {
  /* Ułóż poziomo w fullscreen (zarówno natywny, jak i iOS fallback) */
  .now-track.fullscreen-active .content-wrap,
  .now-track.ios-fs .content-wrap {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3vw !important;
    text-align: left !important;
  }

  /* Artwork po lewej, sensowne ograniczenie rozmiaru w landscape */
  .now-track.fullscreen-active .main-artwork,
  .now-track.ios-fs .main-artwork {
    width: min(40vh, 40vw) !important;
    height: min(40vh, 40vw) !important;
    margin: 0 3vw 0 0 !important;
  }

  /* Treści po prawej */
  .now-track.fullscreen-active .info-wrap,
  .now-track.ios-fs .info-wrap {
    max-width: 45% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    text-align: left !important;
    gap: 0.8rem !important;
  }

  /* Przyciski i suwak po prawej, wyrównanie do lewej */
  .now-track.fullscreen-active .player-controls,
  .now-track.fullscreen-active .volume-row,
  .now-track.fullscreen-active .buttons,
  .now-track.ios-fs .player-controls,
  .now-track.ios-fs .volume-row,
  .now-track.ios-fs .buttons {
    justify-content: flex-start !important;
    align-items: center !important;
  }
}
/* === 📱 TRYB NORMALNY NA TELEFONACH (nie fullscreen, wykrywanie przez ekran dotykowy) === */
@media (hover: none) and (pointer: coarse) {
  /* Sekcja TERAZ GRAMY */
  #nowplaying {
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .now-track {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
	margin-top : 15px;
    width: 100%;
    height: 100vh; /* lekko więcej miejsca, ~45% ekranu */
    max-height: 655px;
    padding: 1rem;
  }

  .now-track .content-wrap {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
  }

  .now-track .main-artwork {
    width: 50vw;
    height: 50vw;
    max-width: 250px;
    max-height: 250px;
    border-radius: 15px;
  }

  .now-track .info-wrap {
    text-align: center;
    margin-top: 0.6rem;
  }

  .now-track .player-controls,
  .now-track .volume-row,
  .now-track .buttons {
    justify-content: center;
    margin-top: 0.5rem;
  }

  /* Sekcja WCZEŚNIEJ GRANE pod spodem */
  #history {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
  }

  #history .track {
    width: 95%;
    max-width: 420px;
    flex-direction: row;
    margin-bottom: 0.8rem;
  }

  #history .track img {
    width: 150px;
    height: 150px;
  }
}
/* === 📱 UNIWERSALNY UKŁAD DLA TELEFONÓW (portrait & landscape, nie fullscreen) === */
@media screen and (max-width: 1024px), (hover: none) and (pointer: coarse) {
  /* --- TERAZ GRAMY --- */
  #nowplaying {
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .now-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 🟢 centrowanie w pionie */
  width: 100%;
  max-width: 100%;
  height: 80vw; /* proporcjonalna wysokość sekcji */
  padding: 1rem;
  margin-bottom: 1rem;
  box-sizing: border-box;
  text-align: center; /* 🟢 wyrównanie tekstu */
}


  .now-track .content-wrap {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
  }

  .now-track .main-artwork {
    width: 50vw;
    height: 50vw;
    max-width: 250px;
    max-height: 250px;
    border-radius: 15px;
  }

  .now-track .info-wrap {
    text-align: center;
    margin-top: 0.6rem;
  }

  .now-track .player-controls,
  .now-track .volume-row,
  .now-track .buttons {
    justify-content: center;
    margin-top: 0.5rem;
  }

  /* --- WCZEŚNIEJ GRANE --- */
  #history {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0 1rem;
    margin-top: 1rem;
  }

  #history .track {
    width: 95%;
    max-width: 99%;
    flex-direction: row;
    align-items: center;
    margin: 0 auto;
  }

  #history .track img {
    width: 200px;
    height: 200px;
    border-radius: 10px;
  }
}
/* Button link */
a.button-link {
  display: inline-block;
  margin-top: 2rem;
  padding: 10px 20px;
  background: #4caf50;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: background 0.3s;
}
a.button-link:hover { background: #45a049; }
/* Sticky player */
#stickyPlayer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #111;
  border-top: 2px solid var(--main-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.3);
  z-index: 9999;
}
#stickyPlayer.hidden { display: none; }

#stickyPlayer img {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  margin-right: 0.8rem;
}
.sticky-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}
.sticky-info p { margin: 0; }

/* Overlay dla top.php */
#topOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  z-index: 9998;
}
#topOverlay.hidden { display: none; }
#topOverlay iframe {
  flex: 1;
  border: none;
  width: 100%;
}
#closeTop {
  background: var(--main-color);
  color: white;
  border: none;
  padding: 0.8rem;
  font-size: 1rem;
  cursor: pointer;
}
/* 📱 Naprawa uciekającego artworku – mobilne czcionki */
@media (max-width: 768px) {

  .track-artist {
    font-size: 1.2rem !important;
    max-width: 85vw;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .track-title {
    font-size: 1rem !important;
    max-width: 85vw;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* Zmniejszamy minimalną szerokość info-wrap */
  .info-wrap {
      min-width: auto !important;
      max-width: 90vw !important;
  }
}
