@import url('https://fonts.googleapis.com/css2?family=Fredoka&display=swap');

html, body {
  font-family: 'Fredoka', sans-serif;
  background: transparent;
  margin: 0;
  padding: 0;
  text-align: center;
  position: relative;
  z-index: 0;
  touch-action: manipulation;
  height: 100%;
}

body::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: 
    linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.8)),
    url("https://cdn.shopify.com/s/files/1/0615/8522/7975/files/Pet_Pwr_Petsecor.png?v=1752680902") no-repeat center 75% / cover;
  z-index: -1;
}

/* === Logo e Titoli === */
#logo img {
  width: 90px;
  height: auto;
}

h1 {
  font-size: 2.2em;
  font-weight: bold;
  color: #6d3685;
  margin-top: 20px;
}

h2 {
  font-size: 1.2em;
  margin-top: 5px;
}

/* === Container === */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === Labirinto === */
.maze-wrapper {
  position: relative;
  display: inline-block;
  width: 90%;
  max-width: 600px;
  transform-origin: center center;
  touch-action: none;
}

#maze-image {
  width: 100%;
  display: block;
}

#draw-canvas, #mask-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  pointer-events: none;
}

#draw-canvas {
  z-index: 10;
  pointer-events: auto;
}

#x-marker {
  position: absolute;
  font-size: 40px;
  color: red;
  display: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* === Pulsante Reset === */
#restart {
  margin-top: 20px;
  background-color: #d1a7f3;
  padding: 10px 20px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 16px;
  cursor: pointer;
}

/* === Feedback Messaggi === */
#message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 12px 20px;
  font-size: 1.5rem;
  font-weight: bold;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 999;
}

.maze-wrapper.correct {
  background-color: #d8b4f8;
  animation: sparkle 1s ease infinite;
}

.maze-wrapper.wrong {
  background-color: #ff4d4d;
  animation: alarm 0.2s ease-in-out 6;
}

@keyframes sparkle {
  0%, 100% { box-shadow: 0 0 20px #c084fc; }
  50% { box-shadow: 0 0 40px #f3e8ff; }
}

@keyframes alarm {
  0%, 100% { background-color: #ff4d4d; }
  50% { background-color: #ff0000; }
}

/* === Popup === */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0; 
  left: 0;
  width: 100vw;
  height: 100vh;
  backdrop-filter: blur(5px);
  background-color: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.popup-overlay.show {
  display: flex !important;
}

.popup {
  background: white;
  padding: 30px 20px;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  max-width: 320px;
  width: 90%;
  text-align: center;
  position: relative;
  z-index: 10000;
  color: #8a4d96;
  font-family: 'Fredoka', sans-serif;
}

.popup .close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 22px;
  color: #8a4d96;
  cursor: pointer;
  font-weight: bold;
}

.popup-text {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 20px;
  color: #8a4d96;
}

.popup-text .code {
  font-size: 18px;
  font-weight: bold;
  color: #8a4d96;
}

#shopBtn {
  display: inline-block;
  margin-top: 10px;
  background-color: #d1a7f3;
  padding: 10px 20px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  font-size: 16px;
  text-transform: uppercase;
  text-decoration: none;
}

/* === Successo === */
#success {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 20px 30px;
  border-radius: 16px;
  font-size: 20px;
  font-weight: bold;
  color: #6d3685;
  box-shadow: 0 0 12px #fff, 0 0 24px #f0f;
  display: none;
  z-index: 10000;
}

#successMessage.sparkle {
  animation: sparkle 1s ease-in-out infinite;
}

/* === Responsive === */
@media (max-width: 768px) {
  #draw-canvas, #mask-canvas {
    touch-action: none;
  }

  .maze-wrapper {
    max-width: 100%;
  }
}
