:root {
  --ms-primary: #2a0e61;
  --ms-secondary: #13073a;
  --ms-accent: #ff2a6d;
  --ms-accent-secondary: #05d9e8;
  --ms-text: #d1f7ff;
  --ms-grid-bg: #1a0b3b;
  --ms-cell-bg: #2d1674;
  --ms-cell-revealed: #3b1e8f;
  --ms-cell-hover: #4b29b8;
  --ms-border-glow: rgba(5, 217, 232, 0.6);
}

.minesweeper-container {
  font-family: "Segoe UI", "Arial", sans-serif;
  display: inline-block;
  background: linear-gradient(135deg, var(--ms-primary), var(--ms-secondary));
  border-radius: 12px;
  padding: 16px;
  user-select: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(5, 217, 232, 0.3);
  max-width: 100%;
  overflow: auto;
  color: var(--ms-text);
  border: 1px solid var(--ms-border-glow);
}

.minesweeper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(26, 11, 59, 0.7);
  border-radius: 8px;
  padding: 10px 15px;
  margin-bottom: 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(5, 217, 232, 0.2);
}

.minesweeper-counter {
  background-color: rgba(0, 0, 0, 0.6);
  color: var(--ms-accent-secondary);
  font-family: "Courier New", monospace;
  font-size: 20px;
  font-weight: bold;
  padding: 5px 10px;
  min-width: 60px;
  text-align: center;
  border-radius: 6px;
  border: 1px solid rgba(5, 217, 232, 0.4);
  box-shadow: 0 0 10px rgba(5, 217, 232, 0.3);
  text-shadow: 0 0 5px rgba(5, 217, 232, 0.7);
}

.minesweeper-reset-button {
  width: 40px;
  height: 40px;
  font-size: 24px;
  background: linear-gradient(135deg, #2d1674, #3b1e8f);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(5, 217, 232, 0.3);
  transition: all 0.2s ease;
  border: 1px solid rgba(5, 217, 232, 0.4);
}

.minesweeper-reset-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(5, 217, 232, 0.5);
}

.minesweeper-reset-button:active {
  transform: scale(0.95);
}

.minesweeper-difficulty-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.minesweeper-difficulty-btn {
  background: linear-gradient(135deg, #2d1674, #3b1e8f);
  border: 1px solid rgba(5, 217, 232, 0.4);
  border-radius: 6px;
  padding: 8px 15px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ms-text);
  transition: all 0.2s ease;
  box-shadow: 0 0 8px rgba(5, 217, 232, 0.2);
}

.minesweeper-difficulty-btn:hover {
  background: linear-gradient(135deg, #3b1e8f, #4b29b8);
  box-shadow: 0 0 12px rgba(5, 217, 232, 0.4);
}

.minesweeper-difficulty-btn:active,
.minesweeper-difficulty-btn.active {
  background: linear-gradient(135deg, #4b29b8, #5a35d8);
  box-shadow: 0 0 15px rgba(5, 217, 232, 0.6);
  transform: scale(0.95);
}

.minesweeper-grid {
  display: grid;
  grid-gap: 2px;
  border-radius: 8px;
  background-color: var(--ms-grid-bg);
  padding: 5px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
  overflow: auto;
  max-width: 100%;
  max-height: 70vh;
}

.minesweeper-cell {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #2d1674, #3b1e8f);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(5, 217, 232, 0.2);
  color: var(--ms-text);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.minesweeper-cell:hover {
  background: linear-gradient(135deg, #3b1e8f, #4b29b8);
  box-shadow: 0 0 8px rgba(5, 217, 232, 0.4);
  transform: translateY(-1px);
}

.minesweeper-cell.revealed {
  background: linear-gradient(135deg, #1a0b3b, #2d1674);
  border: 1px solid rgba(5, 217, 232, 0.1);
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
  transform: none;
}

.minesweeper-cell.flagged::before {
  content: "🚩";
  filter: drop-shadow(0 0 2px rgba(255, 42, 109, 0.8));
}

.minesweeper-cell.mine {
  background: linear-gradient(135deg, #6b0030, #ff2a6d);
  box-shadow: 0 0 15px rgba(255, 42, 109, 0.7);
}

.minesweeper-cell.mine::before {
  content: "💣";
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5));
}

.minesweeper-cell.wrong-flag {
  background: linear-gradient(135deg, #6b0030, #ff2a6d);
  box-shadow: 0 0 10px rgba(255, 42, 109, 0.5);
}

/* Numbers colors with glow effect */
.minesweeper-cell.adjacent-1 {
  color: #05d9e8;
  text-shadow: 0 0 5px rgba(5, 217, 232, 0.7);
}

.minesweeper-cell.adjacent-2 {
  color: #00ff9f;
  text-shadow: 0 0 5px rgba(0, 255, 159, 0.7);
}

.minesweeper-cell.adjacent-3 {
  color: #ff2a6d;
  text-shadow: 0 0 5px rgba(255, 42, 109, 0.7);
}

.minesweeper-cell.adjacent-4 {
  color: #d300c5;
  text-shadow: 0 0 5px rgba(211, 0, 197, 0.7);
}

.minesweeper-cell.adjacent-5 {
  color: #ff7c00;
  text-shadow: 0 0 5px rgba(255, 124, 0, 0.7);
}

.minesweeper-cell.adjacent-6 {
  color: #00b8ff;
  text-shadow: 0 0 5px rgba(0, 184, 255, 0.7);
}

.minesweeper-cell.adjacent-7 {
  color: #ffe600;
  text-shadow: 0 0 5px rgba(255, 230, 0, 0.7);
}

.minesweeper-cell.adjacent-8 {
  color: #ff00ea;
  text-shadow: 0 0 5px rgba(255, 0, 234, 0.7);
}

/* Game title */
.minesweeper-title {
  text-align: center;
  margin-bottom: 15px;
  font-size: 24px;
  font-weight: bold;
  color: var(--ms-accent-secondary);
  text-shadow: 0 0 10px rgba(5, 217, 232, 0.7);
  letter-spacing: 1px;
}

/* Stats display */
.minesweeper-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  background: rgba(26, 11, 59, 0.7);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid rgba(5, 217, 232, 0.2);
}

.minesweeper-stat {
  text-align: center;
}

.minesweeper-stat-label {
  font-size: 12px;
  color: var(--ms-text);
  opacity: 0.8;
}

.minesweeper-stat-value {
  font-size: 18px;
  font-weight: bold;
  color: var(--ms-accent-secondary);
  text-shadow: 0 0 5px rgba(5, 217, 232, 0.5);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .minesweeper-container {
    padding: 12px;
  }

  .minesweeper-grid {
    max-height: 60vh;
  }

  .minesweeper-cell {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .minesweeper-counter {
    font-size: 18px;
    min-width: 50px;
  }

  .minesweeper-reset-button {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}

@media (max-width: 576px) {
  .minesweeper-container {
    padding: 10px;
  }

  .minesweeper-grid {
    max-height: 50vh;
  }

  .minesweeper-cell {
    width: 24px;
    height: 24px;
    font-size: 12px;
    border-radius: 3px;
  }

  .minesweeper-counter {
    font-size: 16px;
    min-width: 45px;
    padding: 4px 8px;
  }

  .minesweeper-reset-button {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }

  .minesweeper-difficulty-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .minesweeper-title {
    font-size: 20px;
  }
}

/* For very small screens or expert mode */
@media (max-width: 480px) {
  .minesweeper-cell {
    width: 20px;
    height: 20px;
    font-size: 11px;
    border-radius: 2px;
  }

  .minesweeper-difficulty-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .minesweeper-header {
    padding: 8px 10px;
  }
}

/* Custom scrollbar for the grid */
.minesweeper-grid::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.minesweeper-grid::-webkit-scrollbar-track {
  background: var(--ms-secondary);
  border-radius: 4px;
}

.minesweeper-grid::-webkit-scrollbar-thumb {
  background: var(--ms-accent-secondary);
  border-radius: 4px;
}

.minesweeper-grid::-webkit-scrollbar-thumb:hover {
  background: var(--ms-accent);
}

/* Animation for revealing cells */
@keyframes reveal {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.minesweeper-cell.revealed {
  animation: reveal 0.2s ease-out;
}

/* Animation for game over */
@keyframes pulse {
  0% {
    box-shadow: 0 0 5px rgba(255, 42, 109, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 42, 109, 0.8);
  }
  100% {
    box-shadow: 0 0 5px rgba(255, 42, 109, 0.5);
  }
}

.game-over .minesweeper-container {
  animation: pulse 2s infinite;
}

