:root {
  --ball-size: 32px;
  --grid-cols: 10;
  --grid-rows: 16;
}

body {
  background-color: #fff;
  margin: 0;
  padding: 20px;
  font-family: Arial, sans-serif;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: calc(10 * var(--ball-size));
  margin: 20px auto 0;
  padding: 0 20px;
}

.score {
  position: static;
  font-size: 24px;
  font-weight: bold;
}

#resetBtn {
  position: static;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background-color: #4a90e2;
  color: white;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#resetBtn:hover {
  background-color: #357abd;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#resetBtn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), var(--ball-size));
  grid-template-rows: repeat(var(--grid-rows), var(--ball-size));
  width: fit-content;
  margin: 20px auto 0;
  gap: 0px;
}

.cell {
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball {
  width: var(--ball-size);
  height: var(--ball-size);
  object-fit: contain;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  transform-origin: center;
  display: block;
  will-change: transform;
  backface-visibility: hidden;
  border-radius: 50%;
  padding: 5px;
}

.ball.disabled {
  cursor: not-allowed;
}

.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup-content {
  background-color: white;
  padding: 30px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.popup h2 {
  margin: 0 0 20px 0;
  color: #333;
}

.popup p {
  margin: 0 0 20px 0;
  font-size: 18px;
}

.popup button {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
}

.popup button:hover {
  background-color: #45a049;
}

.hidden {
  display: none;
}

@keyframes flash {
  0% {
    filter: brightness(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0) inset;
  }
  50% {
    filter: brightness(2);
    box-shadow: 0 0 0 10px rgba(112, 127, 255, 0.7) inset;
  }
  100% {
    filter: brightness(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0) inset;
  }
}

.ball.flash {
  animation: flash 0.3s ease-out;
}
