/* =========================================================
   RatoLibre — Buscaminas: estilos propios del juego
   Depende de los tokens de ../../assets/css/base.css
   ========================================================= */

:root {
  --bm-fondo: #a99d88;
  --bm-tapada: #4c8a66;
  --bm-tapada-2: #559570;
  --bm-tapada-hover: #63a47e;
  --bm-abierta: #f7f0e3;
  --bm-abierta-2: #efe5d2;
  --bm-explotada: #e8796f;
}

/* ---------- Zona de juego ---------- */

.bm-area {
  padding: 6px;
}

@media (min-width: 600px) {
  .bm-area {
    padding: 14px;
  }

  .bm-panel .titulo {
    font-size: 1.6rem;
  }
}

/* ---------- Tablero ---------- */

.bm-marco {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.bm-tablero {
  display: grid;
  grid-template-columns: repeat(var(--bm-columnas, 9), var(--celda, 34px));
  grid-auto-rows: var(--celda, 34px);
  gap: 2px;
  width: max-content;
  margin: 0 auto;
  padding: 3px;
  border-radius: 10px;
  background: var(--bm-fondo);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: box-shadow 0.15s ease;
}

.bm-area.modo-bandera .bm-tablero {
  box-shadow: 0 0 0 4px var(--accent);
}

.bm-celda {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--celda, 34px);
  height: var(--celda, 34px);
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--bm-abierta);
  color: var(--text);
  font: inherit;
  font-size: calc(var(--celda, 34px) * 0.56);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.bm-celda svg {
  display: block;
  width: 72%;
  height: 72%;
  pointer-events: none;
}

.bm-celda:focus {
  outline: none;
}

.bm-celda:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--text);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px #ffffff;
}

/* Tapadas: verdes con relieve */
.bm-celda.tapada {
  background: var(--bm-tapada);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.bm-celda.tapada.par {
  background: var(--bm-tapada-2);
}

.bm-area:not(.terminada) .bm-celda.tapada:hover {
  background: var(--bm-tapada-hover);
}

.bm-celda.tapada:active {
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.18);
}

/* Abiertas: crema, sin relieve */
.bm-celda.abierta {
  background: var(--bm-abierta);
  cursor: default;
}

.bm-celda.abierta.par {
  background: var(--bm-abierta-2);
}

.bm-celda.abierta.numero {
  cursor: pointer;
}

.bm-celda.n1 { color: #1d4fbf; }
.bm-celda.n2 { color: #22693f; }
.bm-celda.n3 { color: #b4232a; }
.bm-celda.n4 { color: #23306e; }
.bm-celda.n5 { color: #7c2d12; }
.bm-celda.n6 { color: #0f6b63; }
.bm-celda.n7 { color: #1f2a37; }
.bm-celda.n8 { color: #4b5563; }

.bm-celda.mina,
.bm-celda.mina.par {
  background: #ece3d2;
}

.bm-celda.explotada,
.bm-celda.explotada.par {
  background: var(--bm-explotada);
  box-shadow: inset 0 0 0 3px #9c1f1f;
}

.bm-celda.error,
.bm-celda.error.par {
  background: #f2d3cf;
  box-shadow: none;
}

.bm-area.terminada .bm-celda {
  cursor: default;
}

/* ---------- Mensaje ---------- */

.bm-mensaje {
  min-height: 1.5rem;
  margin: 12px 4px 0;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.bm-mensaje.es-ok {
  color: var(--accent-2);
}

/* ---------- Barra de abajo: contadores y modo (se queda a la vista al bajar) ---------- */

.bm-barra {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 10px -6px -6px;
  padding: 8px 8px 10px;
  border-top: 2px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}

@media (min-width: 600px) {
  .bm-barra {
    margin: 14px -14px -14px;
    padding: 10px 14px 14px;
  }
}

/* Con el panel de fin de partida o de confirmación a la vista, la barra vuelve a su sitio */
.bm-area.con-panel .bm-barra {
  position: static;
}

.bm-contadores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 0 4px 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.bm-contador {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bm-contador strong {
  min-width: 2ch;
  font-size: 1.15rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bm-modos {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}

.bm-modo {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 6px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bm-modo svg {
  flex: 0 0 auto;
}

/* Celular: el dibujo arriba y el texto abajo, para que quepa en una línea */
@media (max-width: 479px) {
  .bm-modo {
    flex-direction: column;
    gap: 2px;
    min-height: 60px;
    padding: 4px 4px;
    font-size: 0.85rem;
  }
}

.bm-modo:hover {
  border-color: var(--accent-2);
}

.bm-modo:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

#modo-descubrir[aria-pressed="true"] {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: #ffffff;
}

#modo-bandera[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

#modo-bandera[aria-pressed="true"] svg path[fill] {
  fill: #ffffff;
}

@media (min-width: 600px) {
  .bm-modo {
    font-size: 1rem;
  }
}

/* En pantallas anchas, contadores y botones de modo en una sola fila */
@media (min-width: 760px) {
  .bm-barra {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 24px;
  }

  .bm-contadores {
    justify-content: flex-start;
    gap: 6px 28px;
    margin: 0 4px;
  }

  .bm-modos {
    flex: 0 1 460px;
    margin: 0;
  }
}

/* ---------- Paneles (fin de partida y confirmación) ---------- */

.bm-panel {
  margin: 0 0 14px;
  padding: 18px 14px;
  border: 2px solid var(--accent-2);
  border-radius: var(--radius);
  background: var(--accent-2-soft);
  text-align: center;
  animation: bm-aparecer 0.35s ease-out;
}

.bm-panel[hidden] {
  display: none;
}

.bm-panel:focus {
  outline: none;
}

.bm-panel .titulo {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--accent-2);
}

.bm-panel p {
  margin: 0 0 0.6rem;
}

.bm-panel .botones {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.bm-panel .botones .btn {
  flex: 1 1 220px;
  max-width: 340px;
}

.bm-panel .botones .btn[hidden] {
  display: none;
}

.bm-perdida,
.bm-confirmar {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.bm-perdida .titulo,
.bm-confirmar .titulo {
  color: var(--accent-dark);
}

@keyframes bm-aparecer {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Selector de nivel ---------- */

.bm-nivel {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.bm-nivel select {
  flex: 1 1 auto;
  min-width: 140px;
  min-height: 48px;
  padding: 0 40px 0 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%231f2a37' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M4 7l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.bm-nivel select:hover {
  border-color: var(--accent);
}

/* ---------- Récords ---------- */

.bm-records {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 16px 0;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.bm-records .dato {
  display: flex;
  flex-direction: column;
  min-width: 6ch;
}

.bm-records .etiqueta {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.bm-records strong {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Texto de ayuda ---------- */

.bm-ayuda ol li {
  margin-bottom: 0.6rem;
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  .bm-panel {
    animation: none;
  }

  .bm-tablero {
    transition: none;
  }
}
