/* Moteur de jeu Démineur — styles partagés entre solo.php et demineur-expert.php.
   Extrait du bloc <style> historiquement inline dans solo.php. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #e0e0e0;
  padding: 16px;
}

#app {
  position: relative;
  z-index: 1;
  background: rgba(20, 20, 35, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 28px 24px 24px;
  max-width: 95vw;
  width: fit-content;
  min-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.back-link {
  font-size: 0.85rem;
  color: #818cf8;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}
.back-link:hover { color: #a78bfa; }

h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(90deg, #a78bfa, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  gap: 16px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.info-icon { font-size: 1.1rem; }
.mine-count { color: #f87171; }
.timer { color: #a78bfa; }
.score { color: #4ade80; }

/* Grille */
.grid-container {
  overflow: auto;
  max-width: 90vw;
  max-height: 70vh;
  margin: 0 auto 16px;
  border-radius: 8px;
}

.grid {
  display: inline-grid;
  gap: 1px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 1px;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  transition: all 0.15s ease;
  line-height: 1;
  box-shadow:
    inset 1px 1px 2px rgba(255, 255, 255, 0.15),
    inset -1px -1px 2px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.3);
  transform: translateY(0);
}

.cell:hover:not(.revealed):not(.exploded) {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.10));
  box-shadow:
    inset 1px 1px 2px rgba(255, 255, 255, 0.2),
    inset -1px -1px 2px rgba(0, 0, 0, 0.3),
    0 3px 6px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.cell:active:not(.revealed):not(.exploded) {
  transform: translateY(1px);
  box-shadow:
    inset -1px -1px 2px rgba(255, 255, 255, 0.08),
    inset 1px 1px 2px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.2);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.12));
}

.cell.revealed {
  background: rgba(255, 255, 255, 0.03);
  cursor: default;
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
  transform: none;
}

.cell.exploded {
  background: rgba(239, 68, 68, 0.4);
  cursor: default;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  transform: none;
}

.cell.mine-shown {
  background: rgba(239, 68, 68, 0.15);
  cursor: default;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
  transform: none;
  animation: mine-pop 0.3s ease-out;
}
@keyframes mine-pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.cell.flagged {
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.3), rgba(99, 102, 241, 0.12));
}

.cell.wrong-flag {
  background: rgba(239, 68, 68, 0.2);
  text-decoration: line-through;
}

/* Couleurs des chiffres */
.cell.n1 { color: #60a5fa; }
.cell.n2 { color: #4ade80; }
.cell.n3 { color: #f87171; }
.cell.n4 { color: #7c3aed; }
.cell.n5 { color: #a16207; }
.cell.n6 { color: #22d3ee; }
.cell.n7 { color: #e0e0e0; }
.cell.n8 { color: #94a3b8; }

/* Overlay fin de partie */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}
.overlay.visible { display: flex; }

.overlay-box {
  background: rgba(30, 27, 60, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.overlay-box h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.overlay-box .win { color: #4ade80; }
.overlay-box .lose { color: #f87171; }

.overlay-box p {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.overlay-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* CTA inscription */
#cta-inscription {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(167, 139, 250, 0.1));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
}
.cta-rang {
  font-size: 1.1rem;
  font-weight: 800;
  color: #a78bfa;
  margin-bottom: 6px;
}
.cta-rang .rang-nombre { color: #fbbf24; font-size: 1.3rem; }
.cta-score-msg {
  color: #c4b5fd !important;
  font-size: 0.85rem !important;
  margin-bottom: 12px !important;
}
.cta-auth-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.cta-auth-btns .btn { font-size: 0.85rem; padding: 8px 18px; }

/* Confettis */
.confetti {
  position: fixed;
  top: -10px;
  z-index: 200;
  pointer-events: none;
  font-size: 1.2rem;
  animation: confetti-fall 3s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}
.shake { animation: shake 0.5s; }

/* Footer */
footer {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 8px;
}
footer a {
  color: #818cf8;
  text-decoration: none;
}
footer a:hover { color: #a78bfa; }

.flag-toggle {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 4px 12px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.flag-toggle.active {
  background: rgba(99,102,241,0.3);
  border-color: rgba(99,102,241,0.6);
  box-shadow: 0 0 8px rgba(99,102,241,0.3);
}

.settings-toggle {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.settings-toggle:hover { background: rgba(255,255,255,0.15); }
.settings-panel {
  display: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  text-align: left;
}
.settings-panel.visible { display: block; }
.settings-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #cbd5e1;
  cursor: pointer;
  padding: 4px 0;
}
.settings-panel input[type="checkbox"] {
  accent-color: #6366f1;
  width: 16px;
  height: 16px;
}
.settings-info {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.4;
}
.settings-info a { color: #818cf8; text-decoration: none; }
.settings-info a:hover { color: #a78bfa; }

@media (max-width: 480px) {
  body { padding: 0; }
  #app {
    padding: 14px 2px 14px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-width: auto;
    width: 100%;
    max-width: 100vw; /* surcharge le max-width: 95vw de base qui laissait ~10px de marge */
  }
  /* Le banner partagé a margin: -28px -24px (débordement calé sur 24px de padding).
     Comme on réduit le padding de #app, on neutralise le débordement horizontal
     pour qu'il ne dépasse pas l'écran. Spécificité ID pour gagner sur banner.css. */
  #app .jeu-banner { margin-left: 0; margin-right: 0; }
  /* Grille pleine largeur : surcharge le max-width: 90vw de base de .grid-container. */
  #app .grid-container { max-width: 100%; }
  h1 { font-size: 1.3rem; }
  .cell { width: 28px; height: 28px; font-size: 0.75rem; }
  .info-bar { padding: 8px 10px; gap: 8px; }
  .info-item { font-size: 0.8rem; }
}
