/* ============================================================
   PUZZLE GAME - Game-Specific Styles
   Base styles loaded from hub.css
   ============================================================ */

/* ============================================================
   OVERRIDE HUB STYLES FOR THIS GAME (without !important)
   ============================================================ */
.system-controls {
  top: 10px;
  left: 10px;
  gap: 6px;
}

.speaker-btn, .music-toggle {
  width: 50px;
  height: 50px;
  border: 3px solid var(--primary-kids);
  font-size: 22px;
}

.btn-back-hub {
  top: 10px;
  right: 10px;
  padding: 7px 16px;
  font-size: 0.95rem;
}

/* ============================================================
   PUZZLE GAME CONTAINER
   ============================================================ */
.game-container {
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 40px;
  padding: 4vw;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), inset 0 0 0 6px rgba(255, 107, 107, 0.3);
  border: 6px solid #fff;
  max-width: 900px;
  width: 95%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 40px auto;
}

header h1 {
  font-size: 3.5rem;
  font-weight: 900;
  color: #ff4757;
  margin-bottom: 5px;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
  letter-spacing: -1px;
}

header p {
  font-size: 1.6rem;
  font-weight: 700;
  color: #57606f;
  margin-bottom: 25px;
  background: #fff;
  display: inline-block;
  padding: 8px 25px;
  border-radius: 30px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* ============================================================
   GAME AREA LAYOUT
   ============================================================ */
.game-area {
  display: flex;
  flex-direction: column;
  gap: 50px;
  width: 100%;
  align-items: center;
}

.holes-container, .shapes-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  width: 100%;
}

/* ============================================================
   SHAPES AND HOLES — Base Styling
   ============================================================ */
.hole {
  width: 108px;
  height: 108px;
  border: 4px dashed #bdc3c7;
  border-radius: 15px;
  background-color: rgba(241, 242, 246, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  position: relative;
}

.shape {
  width: 100px;
  height: 100px;
  cursor: grab;
  touch-action: none; /* Crucial for custom pointer events */
  filter: drop-shadow(0px 8px 0px rgba(0, 0, 0, 0.15)) drop-shadow(0px 15px 20px rgba(0, 0, 0, 0.15));
  transition: transform 0.1s, filter 0.1s;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}

.shape:active {
  cursor: grabbing;
  transform: scale(1.05) translateY(4px);
  filter: drop-shadow(0px 2px 0px rgba(0, 0, 0, 0.1)) drop-shadow(0px 5px 10px rgba(0, 0, 0, 0.1));
}

.shape.dragging {
  position: fixed;
  z-index: 9999;
  transition: none; /* Remove transition so it follows finger instantly */
  transform: scale(1.1);
  filter: drop-shadow(0px 15px 0px rgba(0, 0, 0, 0.1)) drop-shadow(0px 25px 30px rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

/* ============================================================
   SPECIFIC SHAPES
   ============================================================ */
.triangle {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  background-color: #ff6b6b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circle {
  border-radius: 50%;
  background-color: #4ecdc4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.square {
  border-radius: 15px; /* slight rounding to look friendly */
  background-color: #5f27cd;
  display: flex;
  align-items: center;
  justify-content: center;
}

.star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  background-color: #feca57;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   HOLES — Shape-Specific Styling
   ============================================================ */
.hole[data-shape="triangle"] {
  clip-path: none;
  border: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolygon points='50,5 95,95 5,95' fill='rgba(241, 242, 246, 0.5)' stroke='%23bdc3c7' stroke-width='4' stroke-dasharray='8,6' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.hole[data-shape="circle"] {
  border-radius: 50%;
}

.hole[data-shape="square"] {
  border-radius: 15px;
}

.hole[data-shape="star"] {
  clip-path: none;
  border: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolygon points='50,5 61,38 95,38 68,58 79,90 50,70 21,90 32,58 5,38 39,38' fill='rgba(241, 242, 246, 0.5)' stroke='%23bdc3c7' stroke-width='4' stroke-dasharray='8,6' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

/* ============================================================
   STATE CLASSES — Snapped/Matched Shapes
   ============================================================ */
.shape.snapped {
  cursor: default;
  filter: drop-shadow(0 0 0 2px #2ed573) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Preserve shape-specific geometry when snapped */
.circle.snapped {
  border-radius: 50%;
}

.square.snapped {
  border-radius: 15px;
}

.triangle.snapped {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.star.snapped {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  background-color: #2ed573;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 15px 30px;
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 0 #21a351, 0 15px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s, box-shadow 0.15s;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 20px;
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 0 #21a351, 0 18px 25px rgba(0, 0, 0, 0.15);
  }
}

.btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #21a351;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.shape.active-pulse {
  animation: pulse 1.5s infinite ease-in-out;
}

/* ============================================================
   RESPONSIVE — Mobile (≤600px)
   ============================================================ */
@media (max-width: 600px) {
  .game-container {
    margin: 70px auto 15px auto;
    padding: 15px;
  }

  header h1 {
    font-size: 2.4rem;
    margin-bottom: 3px;
  }

  header p {
    font-size: 1.2rem;
    margin-bottom: 12px;
    padding: 6px 18px;
  }

  .hole {
    width: 86px;
    height: 86px;
  }

  .shape {
    width: 80px;
    height: 80px;
  }

  .game-area {
    gap: 15px;
  }
}
