body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #000;
  font-family: "Courier New", Courier, monospace;
  color: white;
}
#gameCanvas {
  background-color: #000; /* The background is now solid black */
  display: block;
  cursor: crosshair;
}
#ui-container {
  position: absolute;
  top: 20px;
  left: 20px;
  background-color: rgba(20, 20, 20, 0.7);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid #333;
  font-size: 1.2em;
  text-shadow: 0 0 5px #0f0;
}
#message-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.95);
  color: #111;
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  display: none; /* Hidden by default */
  font-size: 1.8em;
  box-shadow: 0 0 40px rgba(100, 255, 255, 0.5);
}
#message-box h2 {
  margin: 0;
  color: #008080;
}
#message-box button {
  margin-top: 20px;
  padding: 10px 25px;
  font-size: 0.8em;
  background-color: #008080;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

#message-box button:hover {
  background-color: #006666;
}

/* Welcome Popup – game theme (maze + paint) */
#welcome-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 12px;
}

.popup-content {
  background: #0f0f12;
  border: 1px solid #2c3e50;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    0 0 0 1px rgba(76, 175, 80, 0.15),
    0 0 30px rgba(0, 0, 0, 0.6),
    0 8px 32px rgba(0, 0, 0, 0.5);
  animation: popup-glow 3s ease-in-out infinite alternate;
}

@keyframes popup-glow {
  from {
    box-shadow:
      0 0 0 1px rgba(76, 175, 80, 0.15),
      0 0 30px rgba(0, 0, 0, 0.6),
      0 8px 32px rgba(0, 0, 0, 0.5);
  }
  to {
    box-shadow:
      0 0 0 1px rgba(76, 175, 80, 0.25),
      0 0 40px rgba(76, 175, 80, 0.08),
      0 8px 32px rgba(0, 0, 0, 0.5);
  }
}

.popup-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(44, 62, 80, 0.6);
}

.popup-content h1 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  color: #4caf50;
  letter-spacing: 0.02em;
  text-shadow: 0 0 12px rgba(76, 175, 80, 0.4);
}

.popup-tagline {
  margin: 8px 0 0;
  font-size: 1.05rem;
  color: rgba(76, 175, 80, 0.9);
  letter-spacing: 0.04em;
}

.instructions {
  margin-bottom: 20px;
}

.instructions h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(76, 175, 80, 0.9);
}

.instruction-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.instruction-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  font-size: 1.1rem;
  color: rgba(224, 224, 224, 0.95);
  line-height: 1.4;
  border-bottom: 1px solid rgba(44, 62, 80, 0.35);
}

.instruction-list li:last-child {
  border-bottom: none;
}

.instruction-list .key {
  flex-shrink: 0;
  min-width: 72px;
  padding: 5px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.35);
}

.tip {
  margin: 14px 0 0;
  padding: 12px 14px;
  font-size: 1.05rem;
  color: rgba(76, 175, 80, 0.9);
  background: rgba(76, 175, 80, 0.08);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 10px;
  line-height: 1.45;
}

#start-game-button {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 14px 24px;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #4caf50, #388e3c);
  border: 1px solid rgba(76, 175, 80, 0.5);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(76, 175, 80, 0.25);
}

#start-game-button:hover {
  background: linear-gradient(180deg, #5cb860, #4caf50);
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.35);
  transform: translateY(-1px);
}

#start-game-button:active {
  transform: translateY(0);
}

#test-victory-audio-welcome {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px 20px;
  font-size: 1.05rem;
  color: white;
  background: linear-gradient(45deg, #ff6b6b, #ee5a52);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#test-victory-audio-welcome:hover {
  transform: translateY(-1px);
}

/* Popup responsive */
@media (max-width: 768px) {
  #welcome-popup {
    padding: 12px;
  }

  .popup-content {
    padding: 20px 22px;
    max-width: 100%;
  }

  .popup-content h1 {
    font-size: 1.75rem;
  }

  .popup-tagline {
    font-size: 0.95rem;
  }

  .instruction-list li {
    font-size: 1rem;
    padding: 8px 0;
  }

  .instruction-list .key {
    min-width: 64px;
    font-size: 0.85rem;
  }

  .tip {
    padding: 10px 12px;
    font-size: 0.95rem;
  }

  #start-game-button {
    padding: 12px 20px;
    font-size: 1.05rem;
  }
}

@media (max-width: 480px) {
  .popup-content {
    padding: 18px 20px;
  }

  .popup-content h1 {
    font-size: 1.6rem;
  }

  .instruction-list li {
    font-size: 0.95rem;
  }
}

/* Home Button Styles */
#home-button-container {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background-color: rgba(20, 20, 20, 0.8);
  padding: 5px;
  border-radius: 50%;
  border: 1px solid #333;
  backdrop-filter: blur(10px);
}

#home-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 50%;
  transition: all 0.3s ease;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4caf50;
}

#home-button svg {
  transition: all 0.3s ease;
}

#home-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
  color: #66bb6a;
}

/* Audio Controls Styles */
#audio-controls {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background-color: rgba(20, 20, 20, 0.8);
  padding: 5px;
  border-radius: 50%;
  border: 1px solid #333;
  backdrop-filter: blur(10px);
}

#mute-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 50%;
  transition: all 0.3s ease;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4caf50;
}

#mute-button svg {
  transition: all 0.3s ease;
}

#mute-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
  color: #66bb6a;
}

#mute-button.muted {
  opacity: 0.5;
  color: #666;
}

#mute-button.muted:hover {
  color: #888;
}

/* Mobile Joystick Controller Styles */
#joystick-container {
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 1000;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#joystick-container.joystick-hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

#joystick-container.joystick-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

#joystick-base {
  position: relative;
  width: 120px;
  height: 120px;
  background: radial-gradient(
    circle,
    rgba(233, 175, 81, 0.2) 0%,
    rgba(233, 175, 81, 0.1) 70%,
    transparent 100%
  );
  border: 3px solid rgba(233, 175, 81, 0.6);
  border-radius: 50%;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(233, 175, 81, 0.3),
    inset 0 0 20px rgba(233, 175, 81, 0.1);
  transition: all 0.2s ease;
  will-change: transform, box-shadow;
}

#joystick-base:active {
  transform: scale(0.95);
  box-shadow: 0 0 30px rgba(233, 175, 81, 0.5),
    inset 0 0 30px rgba(233, 175, 81, 0.2);
}

#joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  background: radial-gradient(circle, #e9af51 0%, #d19a3f 70%, #b8860b 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(233, 175, 81, 0.4),
    inset 0 2px 5px rgba(255, 255, 255, 0.2);
  transition: transform 0.05s ease-out;
  z-index: 2;
  will-change: transform;
}

#joystick-stick:active {
  transform: translate(-50%, -50%) scale(0.9);
  box-shadow: 0 2px 10px rgba(233, 175, 81, 0.6),
    inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

#joystick-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  z-index: 1;
}

/* Joystick movement animation */
@keyframes joystickGlow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(233, 175, 81, 0.3),
      inset 0 0 20px rgba(233, 175, 81, 0.1);
  }
  50% {
    box-shadow: 0 0 30px rgba(233, 175, 81, 0.5),
      inset 0 0 30px rgba(233, 175, 81, 0.2);
  }
}

#joystick-base.joystick-active {
  animation: joystickGlow 1s ease-in-out infinite;
}

/* Responsive joystick sizing */
@media (max-width: 768px) {
  #joystick-base {
    width: 100px;
    height: 100px;
  }

  #joystick-stick {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  #joystick-container {
    bottom: 20px;
    left: 20px;
  }

  #joystick-base {
    width: 90px;
    height: 90px;
  }

  #joystick-stick {
    width: 35px;
    height: 35px;
  }
}
