: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; /* referencja dla absolutnego FS */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1200px;
  max-width: 100%;
  height: 600px;
  max-height: 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);
    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: static; /* ważne: żeby FS łapał .now-track, nie content */
  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;
}

/* 🎛 Głosowanie + PLAY w jednej linii */
.buttons {
  margin-top: 0.6rem;
  display: flex;
  justify-content: center;
  gap: 1.4rem;
}
.buttons .up,
.buttons .down {
  cursor: pointer;
}

/* 🔹 Specjalnie dla sekcji TERAZ GRAMY */
.player-vote-row {
  justify-content: center;
  gap: 1rem;
}

/* Fullscreen row (sam kontener; sam przycisk i tak absolutny) */
.fs-row {
  margin-top: 0.4rem;
  display: flex;
  justify-content: flex-start;
}

/* Głośność */
.volume-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.volume-row .volumeControl {
  width: 100%;
}

/* Komunikaty */
.vote-msg {
  min-height: 1.2em;
  margin-top: 0.35rem;
  font-weight: bold;
  font-size: 0.95rem;
}

/* === 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(20vw, 20vh);
  height: min(20vw, 20vh);
  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 .volume-row,
.now-track.fullscreen-active .buttons,
.now-track.fullscreen-active .fs-row {
  justify-content: center;
  align-items: center;
}

/* === "Ostatnio grane" – 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: 380px;
  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 kart historii */
@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ść historii */
@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; }
}

/* === FULLSCREEN landscape — artwork po lewej, treść po prawej === */
@media (orientation: landscape) {
  .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;
  }

  .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;
  }

  .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;
  }

  .now-track.fullscreen-active .volume-row,
  .now-track.fullscreen-active .buttons,
  .now-track.fullscreen-active .fs-row,
  .now-track.ios-fs .volume-row,
  .now-track.ios-fs .buttons,
  .now-track.ios-fs .fs-row {
    justify-content: flex-start !important;
    align-items: center !important;
  }
}

/* === 📱 UNIWERSALNY UKŁAD DLA TELEFONÓW (portrait & landscape, nie fullscreen) === */
@media screen and (max-width: 1024px), (hover: none) and (pointer: coarse) {
  #nowplaying {
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .now-track {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    height: 80vw;
    padding: 1rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
    text-align: center;
  }

  .now-track .content-wrap {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
  }

  .now-track .main-artwork {
    width: 40vw;
    height: 40vw;
    max-width: 250px;
    max-height: 250px;
    border-radius: 15px;
  }

  .now-track .info-wrap {
    text-align: center;
    margin-top: 0.6rem;
  }

  .now-track .volume-row,
  .now-track .buttons,
  .now-track .fs-row {
    justify-content: center;
    margin-top: 0.5rem;
  }

  #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 – używa wyglądu z .btn-glass */
a.button-link {
  display: inline-block;
  margin-top: 2rem;
  font-size: 1.3rem;
  font-weight: bold;
  text-decoration: none;
  color: #fff;
}

/* Sticky player (na przyszłość, jeśli dodasz HTML) */
#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 (też „na zaś”) */
#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;
}

/* === Fullscreen button in bottom-right corner (glass-neon) === */
.now-track .fsBtn {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 5;
}

/* === GLASS / NEON STYLE DLA WSZYSTKICH PRZYCISKÓW (w tym <a>) === */
.btn-glass,
a.btn-glass {
  padding: 10px 18px;
  border-radius: 12px;
  border: 2px solid var(--main-color);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: white;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.btn-glass:hover,
a.btn-glass:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.75);
  box-shadow: 0 0 15px var(--main-color);
}

.btn-round {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 👍 Zielony neon */
.btn-up {
  border-color: #00ff80;
  box-shadow: 0 0 10px #00ff80;
}
.btn-up:hover {
  box-shadow: 0 0 18px #00ff80;
}

/* 👎 Czerwony neon */
.btn-down {
  border-color: #ff4f4f;
  box-shadow: 0 0 10px #ff4f4f;
}
.btn-down:hover {
  box-shadow: 0 0 18px #ff4f4f;
}

/* ▶️ Play neon */
.btn-play {
  border-color: #4caf50;
  box-shadow: 0 0 10px #4caf50;
}
.btn-play:hover {
  box-shadow: 0 0 20px #4caf50;
}

/* 🔇/🔊 Volume buttons */
.btn-volume {
  border-color: #bbbbbb;
  box-shadow: 0 0 10px #bbbbbb;
}
.btn-volume:hover {
  box-shadow: 0 0 20px #ffffff;
}
