/* ============================================
   Démineur — Game-specific styles
   ============================================ */

.ms-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

/* ---- DIFFICULTY BUTTONS ---- */
.ms-difficulty {
  display: flex;
  gap: var(--space-sm);
}

.diff-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.diff-btn span {
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.diff-btn:hover {
  border-color: var(--accent-secondary);
  color: var(--text-primary);
}

.diff-btn.active {
  background: rgba(0, 180, 216, 0.15);
  border-color: #00b4d8;
  color: #00b4d8;
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.2);
}

.diff-btn.active span {
  color: rgba(0, 180, 216, 0.7);
}

/* ---- STATUS BAR ---- */
.ms-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
}

.ms-stat {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: 'Space Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: #00b4d8;
  min-width: 70px;
}

.ms-stat:last-child {
  justify-content: flex-end;
}

.ms-stat-icon {
  font-size: 1rem;
}

.ms-face {
  font-size: 1.6rem;
  background: var(--bg-card);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  line-height: 1;
}

.ms-face:hover {
  border-color: #00b4d8;
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.25);
  transform: scale(1.1);
}

/* ---- BOARD WRAPPER ---- */
.ms-board-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 180, 216, 0.2),
    0 0 30px rgba(0, 180, 216, 0.08),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ---- BOARD GRID ---- */
.ms-board {
  display: grid;
  background: var(--bg-secondary);
  padding: 3px;
  gap: 2px;
  user-select: none;
}

/* ---- CELLS ---- */
.ms-cell {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: background 100ms ease, box-shadow 100ms ease;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--surface-light);
}

.ms-cell:hover:not(.revealed):not(.exploded) {
  background: var(--surface-light);
  box-shadow: 0 0 8px rgba(0, 180, 216, 0.15);
}

/* Revealed empty cell */
.ms-cell.revealed {
  background: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.04);
  cursor: default;
}

/* Numbers */
.ms-cell.n1 { color: #00b4d8; }
.ms-cell.n2 { color: #00e5a0; }
.ms-cell.n3 { color: #ff6b6b; }
.ms-cell.n4 { color: #7b61ff; }
.ms-cell.n5 { color: #ff9f43; }
.ms-cell.n6 { color: #26de81; }
.ms-cell.n7 { color: #fd79a8; }
.ms-cell.n8 { color: var(--text-secondary); }

/* Flag */
.ms-cell.flagged {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
}

/* Mine revealed on game over */
.ms-cell.mine-show {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.3);
  cursor: default;
}

/* The clicked mine */
.ms-cell.exploded {
  background: rgba(255, 60, 60, 0.5);
  border-color: #ff3c3c;
  box-shadow: 0 0 16px rgba(255, 60, 60, 0.6);
  cursor: default;
  animation: explode 0.3s ease-out;
}

/* Wrong flag on game over */
.ms-cell.wrong-flag {
  background: rgba(255, 107, 107, 0.2);
  border-color: rgba(255, 107, 107, 0.5);
}

/* Win flash */
.ms-cell.win-flash {
  animation: winFlash 0.5s ease-out both;
}

@keyframes explode {
  0%   { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes winFlash {
  0%   { background: var(--bg-secondary); }
  50%  { background: rgba(0, 229, 160, 0.25); box-shadow: 0 0 10px rgba(0, 229, 160, 0.4); }
  100% { background: var(--bg-secondary); }
}

/* ---- OVERLAY ---- */
.ms-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  transition: var(--transition-normal);
  z-index: 10;
}

.ms-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.ms-overlay h2 {
  font-family: 'Space Mono', monospace;
  font-size: 1.8rem;
  letter-spacing: 0.1em;
}

.ms-overlay.win h2 {
  color: #00e5a0;
  text-shadow: 0 0 20px rgba(0, 229, 160, 0.6);
}

.ms-overlay.lose h2 {
  color: #ff6b6b;
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
}

.ms-overlay p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.8;
  font-family: 'Space Mono', monospace;
}

/* ---- HINT ---- */
.ms-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: 'Space Mono', monospace;
  text-align: center;
  line-height: 2;
}

.ms-hint kbd {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--text-secondary);
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .ms-difficulty {
    flex-direction: column;
    width: 100%;
    max-width: 320px;
  }

  .diff-btn {
    flex-direction: row;
    justify-content: space-between;
  }

  .ms-cell {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .ms-status {
    max-width: 100%;
  }
}
