/* Configurator Panel */
#configPanel {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(64px + env(safe-area-inset-bottom));

  width: 200px;
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #000;
  border-radius: 8px;
  padding: 16px;
  padding-bottom: 12px;

  opacity: 0;
  pointer-events: none;
  transform: scale(0.8) translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;

  z-index: 9999;
}

#configPanel.show {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
}

/* Config Squares Container */
.config-squares {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* Color squares */
.config-color {
  width: 100%;
  height: 100%;
  border: 2px solid #000;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;

  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.3);
}

.config-color:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.config-color:active {
  transform: scale(0.95);
}

.config-color.red {
  background: red;
}

.config-color.blue {
  background: blue;
}

.config-color.yellow {
  background: yellow;
}

.config-color.coming-soon {
  background: #ddd;
  color: #999;
  cursor: pointer;
  font-size: 10px;
  text-align: center;
  padding: 8px;
}

.config-color.coming-soon:hover {
  transform: none;
  box-shadow: none;
}

/* Music Player Bar */
.music-player-bar {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.music-player-bar.playing {
  animation: pulse 1.5s ease-in-out infinite;
}

.music-track-name {
  flex: 1;
  font-size: 11px;
  font-weight: bold;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-bar-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.music-bar-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: white;
  font-size: 12px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.music-bar-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

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

.music-bar-btn.play-btn-bar {
  width: 28px;
  height: 28px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.music-playlist-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #000;
  border-radius: 8px;
  color: #111;
  font-size: 24px;
  cursor: pointer;
  z-index: 10003;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Pixelate Disappear Animation */
@keyframes pixelateDisappear {
  0% {
    opacity: 1;
    transform: scale(1) translateX(0);
    filter: none;
  }

  20% {
    transform: scale(1.1) translateX(-2px);
    filter: contrast(120%) blur(1px);
  }

  50% {
    opacity: 0.8;
    transform: scale(0.8) translateX(-5px);
    filter: contrast(150%) blur(2px) grayscale(50%);
  }

  100% {
    opacity: 0;
    transform: scale(0.1) translateX(-10px);
    filter: contrast(200%) blur(8px) grayscale(100%);
    visibility: hidden;
  }
}

.music-playlist-btn.locked,
.music-playlist-btn.hidden {
  animation: pixelateDisappear 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
  cursor: default;
  image-rendering: pixelated;
}

.playlist-back-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: white;
  border: 2px solid #000;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  transition: all 0.2s ease;
  z-index: 10;
}

.playlist-back-btn:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.playlist-static-icon {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  background: white;
  border: 2px solid #000;
  border-radius: 8px;
  color: #111;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.music-playlist-btn:not(.locked):hover {
  background: white;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.music-playlist-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: #f9f9f9;
  border-right: 1px solid #e5e5e5;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);

  /* Mobile Width */
  @media (max-width: 768px) {
    width: 85vw;
    max-width: 320px;
  }

  display: flex;
  flex-direction: column;
  z-index: 10004;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.music-playlist-panel.show {
  transform: translateX(0);
}

.playlist-header {
  padding: 24px 20px;
  padding-top: 80px;
  font-size: 18px;
  font-weight: 700;
  color: #111;
  border-bottom: 1px solid #eee;
}

.playlist-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.playlist-item {
  padding: 12px 16px;
  margin: 4px 0;
  font-size: 14px;
  color: #444;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #111;
}

.playlist-item.active {
  background: #fff;
  color: #2b59ff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.config-color.music-player {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.config-color.music-player:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.config-color.music-player.playing {
  animation: pulse 1.5s ease-in-out infinite;
}

.music-track-title {
  font-size: 9px;
  font-weight: bold;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
  line-height: 1.2;
}

.music-mini-controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.music-mini-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: white;
  font-size: 12px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.music-mini-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

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

.music-mini-btn.play-btn {
  width: 26px;
  height: 26px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.music-mini-btn.play-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

/* Music Player Panel */
#musicPlayerPanel {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(220px + env(safe-area-inset-bottom));

  width: 200px;
  background: rgba(255, 255, 255, 0.98);
  border: 3px solid #667eea;
  border-radius: 12px;
  padding: 16px;

  opacity: 0;
  pointer-events: none;
  transform: scale(0.8) translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;

  z-index: 9998;
}

#musicPlayerPanel.show {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
}

.music-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #667eea;
  font-size: 24px;
  font-weight: bold;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  line-height: 1;
  padding: 0;
}

.music-close-btn:hover {
  background: rgba(102, 126, 234, 0.1);
  transform: scale(1.1);
}

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

.music-track-info {
  font-size: 13px;
  font-weight: bold;
  color: #333;
  text-align: center;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 6px;
  min-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
}

.music-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 18px;
  width: 50px;
  height: 40px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.music-btn:active {
  transform: scale(0.95);
}

#playPauseBtn {
  width: 60px;
  height: 45px;
  font-size: 20px;
}

@media (max-width: 768px) {
  #musicPlayerPanel {
    width: 180px;
    padding: 12px;
    bottom: calc(200px + env(safe-area-inset-bottom));
  }

  .music-track-info {
    font-size: 12px;
    padding: 6px;
  }

  .music-btn {
    width: 45px;
    height: 36px;
    font-size: 16px;
  }

  #playPauseBtn {
    width: 55px;
    height: 40px;
    font-size: 18px;
  }
}

@media (max-width: 768px) {
  #configPanel {
    width: 180px;
    height: 180px;
    gap: 10px;
    padding: 14px;
  }
}

/* Locked (all look same) */
.config-color.locked {
  background: #cfcfcf;
  /* neutral for pre-unlock */
  border: 2px solid #999;
  opacity: 0.35;
  filter: grayscale(100%);
  cursor: not-allowed;
}

/* Hide color when locked */
.config-color.locked::after {
  content: "";
}

/* -----------------------------
   CONFIGURATOR BUTTON & HELP
   (Moved from main.css)
----------------------------- */

/* Configurator icon */
#configBtn {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));

  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #111;
  font-size: 18px;
  cursor: pointer;
  z-index: 10000;

  opacity: 0.5;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@media (max-width: 768px) {
  #configBtn {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

#configBtn:hover {
  opacity: 1;
  transform: rotate(20deg);
}

/* Configurator help text */
.config-help {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(64px + env(safe-area-inset-bottom));

  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;

  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;

  z-index: 10001;
}

/* Visible state */
.config-help.show {
  opacity: 1;
  transform: translateY(0);
}