* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  text-align: center;
  user-select: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  color: #e2e8f0;
}

/* Estilo de tabla y columnas */
table {
  border-collapse: collapse;
  overflow: hidden;
  margin: 20px auto;
  border-radius: 5px;
  border: 1px solid #334155;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  background: #1e293b;
}

td {
  width: 40px;
  height: 40px;
  cursor: pointer;
  border: 1px solid #475569;
  background: #334155;
  text-align: center;
  color: #e2e8f0;
  font-size: 1.2rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

td:hover {
  background: #475569;
  transform: scale(1.02);
}

/* Estilo botón juego nuevo */
#juego-nuevo {
  display: inline-block;
  cursor: pointer;
  margin: 10px 0;
  padding: 5px 10px;
  border: 1px solid #38bdf8;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  background: transparent;
  color: #38bdf8;
  font-size: 1rem;
  font-weight: bold;
}

#juego-nuevo:hover {
  background: #38bdf8;
  color: #1e293b;
}

/* Estilo marcador de minas */
#timer,
#minas {
  display: inline-block;
  vertical-align: middle;
  margin: 0 10px;
  padding: 8px 18px;
  border: 1px solid #475569;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 2px;
}
 /* Estilo timer tiempo de juego */
#timer {
  background: #1e293b;
  color: #38bdf8;
}

#minas {
  background: #1e293b;
  color: #f87171;
}

#marcadores {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

#minas-label {
  margin-right: 2px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #f87171;
  letter-spacing: 1px;
}

#tiempo-label {
  margin-right: 2px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 1px;
}

/* Alerta centrada para derrota y victoria */
.alerta-centrada {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  background: rgba(44, 62, 80, 0.6);
}

.alerta-contenido {
  padding: 2em 2.5em;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  min-width: 260px;
  text-align: center;
  background: #263238;
  color: #fff;
}

.alerta-contenido h2 {
  margin: 0 0 1em 0;
  font-size: 1.6em;
  letter-spacing: 1px;
}

/* Dinámico dependiendo si pierde o gana */
.alerta-centrada.victoria .alerta-contenido h2 {
  color: rgba(67, 224, 72, 0.92);
}

.alerta-centrada.derrota .alerta-contenido h2 {
  color: #ff5a5a;
}

.alerta-contenido p {
  margin: 0.5em 0;
  color: #fff;
  font-size: 1.1em;
}

.alerta-contenido strong {
  color: #38bdf8;
}

.alerta-contenido button {
  cursor: pointer;
  margin-top: 1em;
  padding: 0.7em 1.5em;
  border: none;
  border-radius: 6px;
  background: #38bdf8;
  color: #1e293b;
  font-weight: bold;
  font-size: 1em;
  transition: 0.2s color 0.2s;
}

.alerta-contenido button:hover {
  background: #0ea5e9;
}

/* Modal de ajustes */
.modal-ajustes {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.modal-contenido {
  margin: 5% auto;
  width: 90%;
  max-width: 500px;
  padding: 0;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  animation: modalSlideIn 0.3s ease-out;
}

/* Animación para mostrar el contenido */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid #475569;
  border-radius: 15px 15px 0 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.modal-header h2 {
  margin: 0;
  color: #e2e8f0;
  font-size: 1.5rem;
  font-weight: 600;
}

.cerrar-modal {
  cursor: pointer;
  font-size: 28px;
  font-weight: bold;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.cerrar-modal:hover {
  color: #f87171;
}

/* Estilo niveles */
.niveles-container {
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.nivel-opcion {
  display: flex;
  cursor: pointer;
  padding: 15px;
  margin: 10px 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #334155;
  align-items: center;
  transition: all 0.3s ease;
}

.nivel-opcion:hover {
  transform: translateX(5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.nivel-opcion:nth-child(1):hover {
  border-color: #10b981;
  background: linear-gradient(150deg, #334155 20%, #065f46 100%);
}

.nivel-opcion:nth-child(2):hover {
  border-color: rgb(229, 245, 11);
  background: linear-gradient(150deg, #334155 20%, rgb(167, 164, 12) 100%);
}

.nivel-opcion:nth-child(3):hover {
  border-color: #f59e0b;
  background: linear-gradient(150deg, #334155 20%, #92400e 100%);
}

.nivel-opcion:nth-child(4):hover {
  border-color: #8b5cf6;
  background: linear-gradient(150deg, #334155 20%, #5b21b6 100%);
}

.nivel-opcion:nth-child(5):hover {
  border-color: #dc2626;
  background: linear-gradient(150deg, #334155 20%, #7f1d1d 100%);
}

.nivel-icono {
  font-size: 2rem;
  min-width: 50px;
  margin-right: 15px;
  text-align: center;
}

.nivel-info h3 {
  margin: 0 0 5px 0;
  color: #e2e8f0;
  font-size: 1.1rem;
  font-weight: 600;
}

.nivel-info p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

/* Scrollbar personalizado para el modal */
.niveles-container::-webkit-scrollbar {
  width: 8px;
}

.niveles-container::-webkit-scrollbar-track {
  background: #1e293b;
  border-radius: 4px;
}

.niveles-container::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}

.niveles-container::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Estilo modal nombre jugador */
.modal-nombre {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1002;
  background: rgba(44, 62, 80, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-nombre-contenido {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 16px;
  box-shadow: 0 4px 24px #0005;
  padding: 28px;
  min-width: 240px;
  color: #eceff1;
}

.modal-nombre-contenido h2 {
  margin-bottom: 10px;
  font-size: 1.3em;
}

.modal-nombre-contenido input {
  background: #37474f;
  color: #eceff1;
  border: 1px solid #90a4ae;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 1em;
  width: 170px;
  text-align: center;
  margin-bottom: 7px;
  outline: none;
  transition: border 0.2s;
}

.modal-nombre-contenido input:focus {
  border: 1.5px solid #38bdf8;
  background: #455a64;
}

.modal-nombre-contenido button {
  margin-top: 7px;
  padding: 7px 18px;
  border-radius: 8px;
  background: #38bdf8;
  border: none;
  font-size: 1em;
  color: #1e293b;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 6px #0002;
  transition: 0.2s;
}

.modal-nombre-contenido button:hover { 
  background: #0ea5e9; 
}

.modal-nombre-inicial { 
  display: flex; 
}

.modal-nombre-titulo { 
  margin-bottom: 10px; 
  font-size: 1.3em; 
}

.modal-nombre-entrada { 
  padding: 7px 12px; 
  border-radius: 8px; 
  border: 1px solid #b0bec5; 
  font-size: 1em; 
  width: 170px; 
  text-align: center; 
  margin-bottom: 7px; 
  outline: none; 
}

.modal-nombre-error { 
  color: #ff8a80; 
  font-size: 0.95em; 
  margin-bottom: 5px; 
  display: none; 
}

.modal-nombre-boton { 
  margin-top: 7px; 
  padding: 7px 18px; 
  border-radius: 8px; 
  background: #263238; 
  color: #fff; 
  border: none; 
  font-size: 1em; 
  cursor: pointer; 
  box-shadow: 0 2px 6px #0002; 
}

/* Alertas de victoria y derrota con fondo oscuro y borde de color */
.alerta-centrada.victoria .alerta-contenido {
  background: #232e3c;
  color: #fff;
  border: 2.5px solid rgba(67, 224, 72, 0.92);
  box-shadow: 0 4px 24px #0007;
}

.alerta-centrada.derrota .alerta-contenido {
  background: #232e3c;
  color: #fff;
  border: 2.5px solid #ff5a5a;
  box-shadow: 0 4px 24px #0007;
}

.alerta-oculta { 
  display: none; 
}

.modal-nombre:not(.modal-nombre-inicial) {
  display: none;
}

/* Modal de Ranking */
.modal-ranking-oculto {
  display: none;
}

.modal-ranking-visible {
  display: flex;
}

#modal-ranking {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(30, 41, 59, 0.85); 
  align-items: center;
  justify-content: center;
}

.modal-ranking-contenido {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 18px;
  box-shadow: 0 8px 32px #0007;
  padding: 32px 32px 24px 32px;
  min-width: 340px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.modal-ranking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 18px;
  position: relative;
}

.modal-ranking-header h2 {
  font-size: 2em;
  color: #fff;
  margin: 0;
  flex: 1;
  text-align: center;
}

.cerrar-modal-ranking {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 28px;
  cursor: pointer;
  position: absolute;
  top: 18px;
  right: 24px;
  font-weight: bold;
  transition: color 0.2s ease;
}

.cerrar-modal-ranking:hover {
  color: #f87171;
}

/* Estilo de tabla de ranking */
#tabla-ranking {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  background: #263238;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px #0003;
}

#tabla-ranking th, #tabla-ranking td {
  padding: 8px 12px;
  text-align: center;
}

#tabla-ranking th {
  background: #374151;
  color: #38bdf8;
  font-weight: 700;
  font-size: 1.1em;
}

#tabla-ranking td {
  color: #e2e8f0;
  font-size: 1em;
  background: #263238;
}

#tabla-ranking tr:nth-child(even) td {
  background: #2e3a43;
}

.ranking-vacio {
  color: #ff8a80;
  font-size: 1.1em;
  margin-top: 10px;
  display: none;
}

.filtros-ranking {
  width: 100%;
  padding: 12px 20px;
  background: #263238;
  border-radius: 10px;
  box-shadow: 0 2px 12px #0003;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.filtros-ranking label {
  color: #38bdf8;
  font-size: 1.1em;
  font-weight: 600;
  white-space: nowrap;
}

.filtros-ranking select {
  padding: 8px 12px;
  font-size: 1em;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #334155;
  color: #e2e8f0;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.filtros-ranking select:hover {
  border-color: #38bdf8;
  background: #2e3a43;
}

.filtros-ranking select:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 5px rgba(56, 189, 248, 0.5);
}
/* Responsive para modal de ranking */
@media (max-width: 600px) {
  .modal-ranking-contenido {
    padding: 24px 18px;
    min-width: 90vw;
    max-height: 90vh;
    border-radius: 14px;
  }

  .modal-ranking-header h2 {
    font-size: 1.5em;
  }

  .cerrar-modal-ranking {
    font-size: 24px;
    top: 12px;
    right: 16px;
  }

  .filtros-ranking {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px;
  }

  .filtros-ranking label {
    font-size: 1em;
    margin-bottom: 4px;
  }

  .filtros-ranking select {
    width: 100%;
  }

  #tabla-ranking {
    font-size: 0.9em;
  }

  #tabla-ranking th,
  #tabla-ranking td {
    padding: 6px 8px;
  }

  .ranking-vacio {
    font-size: 1em;
  }
}
.tabla-ranking-wrapper {
  width: 100%;
  overflow-x: auto;
}

#tabla-ranking {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px; 
}

#tabla-ranking th,
#tabla-ranking td {
  text-align: center;
  padding: 10px;
  white-space: nowrap; 
}

@media (max-width: 600px) {
  #tabla-ranking {
    font-size: 0.9em;
  }
}