/* General Styling */
body {
  background-image: url('https://raw.githubusercontent.com/arpit456jain/Amazing-Js-Projects/master/Candy%20Crush/utils/bg.png');
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Montserrat', sans-serif;
  color: #85796b;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  height: 560px;
  width: 560px;
  background-color: rgba(109, 127, 151, 0.5);
  padding: 5px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) inset, 0 1px 0 #fff;
  margin-left: 80px;
  margin-top: 50px;
}

.grid div {
  height: 70px;
  width: 70px;
  background-size: cover;
  background-position: center;
  border-radius: 5px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: element;
  cursor: grab;
  touch-action: none;
  box-sizing: border-box;
}

/* Interactivity and Drag States */
.grid div:hover {
  transform: scale(1.05);
}

.grid div:active {
  cursor: grabbing;
}

.grid div.dragging {
  opacity: 0.45;
  transform: scale(0.92);
}

.grid div.drag-over {
  border: 2px dashed #ffeb3b;
  box-shadow: 0 0 12px rgba(255, 235, 59, 0.9);
}

.grid div.selected {
  outline: 3px solid #ffeb3b;
  outline-offset: -3px;
  box-shadow: 0 0 16px #ffeb3b;
  animation: candyPulse 0.9s infinite alternate;
}

@keyframes candyPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

/* Scoreboard Styling */
.scoreBoard {
  background-color: cyan;
  border-radius: 20px;
  margin-top: 200px;
  margin-left: 200px;
  width: auto;
  height: 120px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  color: #85796b;
}

h3, h1 {
  font-family: 'Montserrat', sans-serif;
  text-transform: uppercase;
  margin: 0;
}

h1 {
  margin-top: -10px;
}

/* Mode Selection Styling */
#modeSelection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: #f0f0f0;
  font-family: 'Montserrat', sans-serif;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
}

#modeSelection h2 {
  margin-bottom: 20px;
  color: #333;
}

#modeSelection button {
  margin: 10px;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background-color: #87ceeb;
  border: none;
  border-radius: 5px;
  color: white;
}

/* Timer and Change Mode Button */
#timer {
  font-size: 18px;
  margin-top: 10px;
}

#changeMode {
  margin-top: 10px;
  padding: 5px 10px;
  background-color: #ff6347;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

/* Initially Hide Game Elements */
.grid, .scoreBoard {
  display: none;
}

/* Responsive Layout */
@media (max-width: 850px) {
  body {
    flex-direction: column-reverse;
    justify-content: center;
    padding: 16px;
    min-height: 100vh;
  }

  .scoreBoard {
    margin: 15px auto 0 auto;
    width: 90%;
    max-width: 400px;
    height: auto;
    padding: 12px 20px;
  }

  .grid {
    margin: 10px auto;
    width: min(92vw, 480px);
    height: min(92vw, 480px);
  }

  .grid div {
    width: calc(min(92vw, 480px) / 8 - 2px);
    height: calc(min(92vw, 480px) / 8 - 2px);
  }
}