/* Base styles */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
}

h1 {
  margin-top: 0;
  color: white;
  text-align: center;
  font-size: 2.5rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  margin-bottom: 10px;
}

p {
  margin-bottom: 20px;
  color: white;
  text-align: center;
  font-size: 1.1rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Progress bar */
#progress-bar {
  width: 700px;
  height: 30px;
  background: rgba(255,255,255,0.2);
  border-radius: 15px;
  margin: 0 auto 20px auto;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.3);
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ecc71 0%, #27ae60 100%);
  border-radius: 13px;
  transition: width 0.3s ease;
  position: relative;
}

#progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

#progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Layout for game area */
#game-area {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  max-width: 1550px;
  margin: 0 auto;
}

/* Puzzle board: 10×10 grid */
#puzzle-container {
  width: 700px;
  height: 700px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  border: 4px solid #2c3e50;
  border-radius: 15px;
  position: relative;
  background-color: #fff;
  box-shadow: 0 15px 35px rgba(0,0,0,0.3), 0 5px 15px rgba(0,0,0,0.2);
  overflow: hidden;
}

/* Individual cells on the puzzle board */
.cell {
  border: 1px solid #ecf0f1;
  box-sizing: border-box;
  position: relative;
  transition: all 0.2s ease;
}

/* Highlight when dragging over a valid cell */
.cell.highlight {
  border-color: #3498db;
  background-color: #d5f4ff;
  transform: scale(1.02);
  box-shadow: inset 0 0 10px rgba(52, 152, 219, 0.3);
}

/* Pieces container for scrambled pieces */
#pieces-container {
  width: 700px;
  height: 700px;
  border: 3px dashed #34495e;
  border-radius: 15px;
  padding: 15px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 4px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  box-shadow: inset 0 5px 15px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}


/* Reference image container */
#reference-container {
  width: 400px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 3px solid #34495e;
  border-radius: 15px;
  padding: 15px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  position: relative;
  margin: 0 auto 20px auto;
}

#reference-container h3 {
  margin: 0 0 10px 0;
  color: #2c3e50;
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
}

#reference-image {
  width: 300px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  display: block;
  margin: 0 auto;
}


/* Puzzle piece */
.piece {
  width: 100%;
  height: 100%;
  border: 2px solid #2c3e50;
  border-radius: 6px;
  box-sizing: border-box;
  background-size: cover;
  background-repeat: no-repeat;
  cursor: grab;
  user-select: none;
  transition: all 0.2s ease;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  min-width: 0;
  min-height: 0;
}

.piece.placed {
  width: 100% !important;
  height: 100% !important;
}

.piece:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  border-color: #3498db;
}

/* Visual feedback while dragging */
.piece.dragging {
  opacity: 0.8;
  transform: rotate(5deg) scale(1.05);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

/* Message area */
#message {
  margin-top: 20px;
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  padding: 15px 30px;
  border-radius: 25px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  display: none;
  animation: celebration 0.8s ease-out;
}

#message:not(:empty) {
  display: block;
}

@keyframes celebration {
  0% {
    transform: scale(0.8) translateY(20px);
    opacity: 0;
  }
  50% {
    transform: scale(1.1) translateY(-5px);
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Responsive design */
@media (max-width: 1450px) {
  #game-area {
    flex-direction: column;
    align-items: center;
  }
  
  #puzzle-container {
    margin-bottom: 20px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  #reference-container {
    width: 300px;
  }
  
  #reference-image {
    width: 200px;
  }
  
  #puzzle-container {
    width: 500px;
    height: 500px;
  }
  
  #progress-bar {
    width: 500px;
  }
  
  #pieces-container {
    width: 500px;
    height: 500px;
  }
}