* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: #fff;
  color: #111;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  position: relative;
  overflow-x: hidden;
}

/* Ensure smooth scrolling and proper viewport handling */
html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
}

/* ASCII Background Layer */
#ascii-bg {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  white-space: pre;
  line-height: 6px;
  font-size: 6px;
  user-select: none;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: #111;
  opacity: 0.55;
  filter: contrast(1.25);
  z-index: 0;
  overflow: hidden;
}

/* Main Music Page */
.music-page {
  width: 100%;
  /* Use viewport units with fallback - scales better across resolutions */
  padding: max(80px, 6vh) 20px max(160px, 12vh) 20px;
  /* Remove min-height: 100vh to allow content to fit within viewport */
  min-height: calc(100vh - 150px); /* Account for footer + player */
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.0);
}

/* For very tall displays (like 2880x1920), add extra bottom padding */
@media (min-height: 1800px) {
  .music-page {
    padding-bottom: max(200px, 14vh);
  }
}

.music-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 24px 20px;
  margin-bottom: 0;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.music-title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.0);
}

.music-header .back-button {
  position: absolute;
  left: 1%;
  top: 45%;
  font-size: 16px;
}



/* Regenerate Background Button */
.regen-button {
  position: absolute;
  right: 1%;
  top: 35%;
  border: 1px solid rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: #fff;
}

.regen-button:hover {
  background: rgba(0, 0, 0, 1);
  border-color: rgba(0, 0, 0, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.regen-button:active {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Songs Grid - 3 columns */
.songs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 40px;
  padding-top: 2em;
}

.song-card {
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
}

.song-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.song-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.song-title {
  margin: 0;
  padding: 16px 16px 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

.song-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.play-btn, .info-btn {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.2s;
}

.play-btn {
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.8);
}

.play-btn:hover {
  background: rgba(0, 0, 0, 1);
}

.info-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Fixed Music Player - Above Footer */
.music-player {
  position: fixed;
  bottom: 70px; /* Above footer */
  left: 0;
  right: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px 20px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: transform 0.3s ease;
}

.music-player.hidden {
  transform: translateY(200px);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
}

.player-cover {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 2px;
}

.player-details {
  flex: 1;
  min-width: 0;
}

.player-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.player-artist {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.player-controls {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-pause-btn {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.play-pause-btn:hover {
  background: #fff;
  transform: scale(1.1);
}

.progress-bar {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
}

.progress-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.time-display {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  min-width: 40px;
}

.time-separator {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

/* Footer Styles */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  border-top: 1px solid rgba(0, 0, 0, 0.10);
  padding: 18px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.footer__inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  opacity: 0.85;
}

.footer__links a {
  color: inherit;
  text-decoration: none;
  margin-left: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.footer__links a:hover {
  border-bottom-color: rgba(0, 0, 0, 0.6);
}

.footer__description {
  text-align: center;
  font-size: 12px;
}

/* Info Modal */
.info-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 20px;
}

.info-modal.active {
  display: flex;
}

.info-modal-content {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 0px;
  padding: 40px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.info-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.5);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-modal-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.song-info {
  text-align: center;
}

.info-cover {
  width: 200px;
  height: 200px;
  object-fit: cover;
  margin: 0 auto 20px;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.song-info h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.info-artist {
  margin: 0 0 20px;
  font-size: 16px;
  opacity: 0.75;
}

.soundcloud-link { 
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 30px;
}

.lyrics-container {
  text-align: left;
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.lyrics-container h3 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}

.lyrics {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  margin: 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  max-height: 400px;
  overflow-y: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .music-page {
    padding-top: 17vh;
    padding-bottom: 12vh;
  }

  .music-header {
    padding: 16px;
  }

  .music-header .back-button {
    position: static;
    transform: none;
    display: block;
    margin-bottom: 12px;
  }

  .regen-button {
    position: static;
    transform: none;
    display: block;
    width: 100%;
    margin-bottom: 12px;
  }

  .music-title {
    font-size: 24px;
  }

  /* Stack songs on mobile */
  .songs-grid {
    grid-template-columns: 1fr;
    gap: 0px;
    padding-top: 1px;
    margin-top: 1px;
  }

  /* Mobile player */
  .music-player {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    bottom: 60px;
  }

  .player-info {
    width: 100%;
    min-width: auto;
  }

  .player-controls {
    width: 100%;
  }

  /* Mobile modal */
  .info-modal {
    padding: 20px 10px;
  }

  .info-modal-content {
    padding: 30px 20px;
    max-height: 95vh;
  }

  .info-cover {
    width: 150px;
    height: 150px;
  }

  .lyrics {
    font-size: 13px;
  }
}

/* Scale down for large/high-resolution displays (2K, 4K, Retina, etc.)
   This prevents footer cutoff and improves overall proportions on big screens */
@media (min-width: 2048px) {
  html {
    zoom: 0.9;
  }
}
