/* ==================== MODAL OVERLAY ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.is-open {
  display: flex;
  opacity: 1;
}

.modal {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 20px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal__title {
  margin: 0;
  font-size: 28px;
  color: #fff;
  font-weight: 700;
}

.modal__close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.modal__body {
  padding: 30px;
}

/* ==================== MASTERMIND / MINESLOT GAME ==================== */
.mastermind {
  color: #fff;
}

.mastermind__start {
  text-align: center;
  padding: 20px;
}

.mastermind__start h3 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #ffd700;
}

.mastermind__rules {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  text-align: left;
}

.mastermind__btn {
  padding: 15px 40px;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mastermind__btn--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.mastermind__btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.mastermind__btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.mastermind__btn--secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.mastermind__btn--secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.mastermind__btn--secondary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.mastermind__btn--danger {
  background: rgba(220, 53, 69, 0.2);
  color: #ff6b6b;
  border: 2px solid rgba(220, 53, 69, 0.5);
}

.mastermind__btn--danger:hover {
  background: rgba(220, 53, 69, 0.3);
}

.mastermind__game {
  display: none;
}

.mastermind__secret {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
  text-align: center;
}

.mastermind__secret h4 {
  margin: 0 0 15px 0;
  color: #ffd700;
  font-size: 18px;
}

.mastermind__board {
  margin-bottom: 30px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.mastermind__controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.mastermind__controls .mastermind__btn {
  min-width: 140px;
}

/* ==================== MINESLOT GRID ==================== */

.mines__board {
  display: grid;
  grid-template-columns: repeat(var(--mines-cols, 5), 1fr);
  grid-template-rows: repeat(var(--mines-rows, 7), 1fr);
  gap: 8px;
}

.mines__cell {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  border-radius: 10px;
  border: 2px solid rgba(148, 163, 184, 0.5);
  background: radial-gradient(circle at 30% 20%, #1f2937 0%, #020617 55%, #000 100%);
  box-shadow:
    inset 0 2px 4px rgba(148, 163, 184, 0.3),
    0 8px 15px rgba(15, 23, 42, 0.7);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease,
    background 0.15s ease;
}

.mines__cell::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  background: radial-gradient(circle at 30% 20%, rgba(148, 163, 184, 0.4), transparent 60%);
  opacity: 0.4;
  pointer-events: none;
}

.mines__cell:hover {
  transform: translateY(-2px);
  box-shadow:
    0 10px 20px rgba(15, 23, 42, 0.9),
    0 0 20px rgba(56, 189, 248, 0.4);
  border-color: rgba(56, 189, 248, 0.8);
}

.mines__cell--safe {
  background: radial-gradient(circle at 30% 20%, #22c55e 0%, #166534 60%, #052e16 100%);
  border-color: rgba(74, 222, 128, 0.9);
  box-shadow:
    inset 0 2px 4px rgba(34, 197, 94, 0.4),
    0 10px 25px rgba(22, 163, 74, 0.9);
}

.mines__cell--bomb {
  background: radial-gradient(circle at 30% 20%, #ef4444 0%, #7f1d1d 55%, #020617 100%);
  border-color: rgba(248, 113, 113, 0.9);
  box-shadow:
    inset 0 2px 4px rgba(248, 113, 113, 0.5),
    0 10px 30px rgba(127, 29, 29, 1);
}

.mines__cell span,
.mines__cell svg,
.mines__cell::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mines__cell--safe::after {
  content: '✨';
  font-size: 1.8rem;
  filter: drop-shadow(0 0 6px rgba(250, 250, 250, 0.9));
}

.mines__cell--bomb::after {
  content: '💣';
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(248, 113, 113, 0.9));
}

.mines__cell[style*="pointer-events: none"] {
  cursor: default;
  opacity: 0.9;
}

/* ==================== MINESLOT STATS ==================== */

.mines__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.mines__stat-item {
  background: radial-gradient(circle at 0% 0%, rgba(148, 163, 184, 0.15), transparent 70%);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  text-align: left;
}

.mines__stat-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-bottom: 4px;
}

.mines__stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e5e7eb;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .modal {
    width: 95%;
    max-height: 95vh;
  }

  .modal__header {
    padding: 20px;
  }

  .modal__title {
    font-size: 22px;
  }

  .modal__body {
    padding: 20px;
  }

  .mastermind__peg {
    width: 35px;
    height: 35px;
  }

  .mastermind__color-btn {
    width: 45px;
    height: 45px;
  }

  .mastermind__controls .mastermind__btn {
    min-width: 120px;
    padding: 12px 20px;
    font-size: 16px;
  }
}