/* ============================================================
   juego.css — barra de estatus, tablero, celdas y animaciones
   ============================================================ */

/* ---------- Barra de estatus ---------- */

.barra-estatus {
  background: #0C1424;
  border: 1px solid var(--borde);
  border-radius: var(--radio-m);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.estatus-fila { display: flex; align-items: center; gap: 9px; }

.estatus-punto {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--texto-tenue);
  flex: none;
  transition: background .2s ease, box-shadow .2s ease;
}

.estatus-texto { font-size: 13.5px; color: var(--texto-suave); }

.barra-estatus[data-estado="activo"] .estatus-punto {
  background: var(--gema);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .16);
  animation: pulso-punto 1.6s ease-in-out infinite;
}
.barra-estatus[data-estado="activo"] .estatus-texto { color: var(--texto); }

.barra-estatus[data-estado="perdido"] .estatus-punto { background: var(--rojo); box-shadow: 0 0 0 4px rgba(240, 80, 58, .16); }
.barra-estatus[data-estado="perdido"] .estatus-texto { color: #FCA5A5; }

.barra-estatus[data-estado="ganado"] .estatus-punto { background: var(--verde); box-shadow: 0 0 0 4px rgba(34, 197, 94, .16); }
.barra-estatus[data-estado="ganado"] .estatus-texto { color: #86EFAC; }

@keyframes pulso-punto {
  0%, 100% { box-shadow: 0 0 0 3px rgba(56, 189, 248, .14); }
  50%      { box-shadow: 0 0 0 7px rgba(56, 189, 248, .05); }
}

.estatus-progreso {
  height: 5px;
  background: #16233A;
  border-radius: 999px;
  overflow: hidden;
  margin: 11px 0 12px;
}

.estatus-progreso-relleno {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gema-honda), var(--gema));
  transition: width .35s cubic-bezier(.22, 1, .36, 1);
}

.barra-estatus[data-estado="perdido"] .estatus-progreso-relleno {
  background: linear-gradient(90deg, var(--rojo-honda), var(--rojo));
}

.estatus-datos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.estatus-datos dt {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--texto-tenue);
}

.estatus-datos dd {
  margin: 2px 0 0;
  font-family: var(--fuente-dato);
  font-size: 15px;
  font-weight: 700;
}

.estatus-datos div:nth-child(2) dd { color: var(--gema); }
.dato-verde { color: var(--verde); }

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

.tablero-marco {
  display: flex;
  justify-content: center;
}

.tablero {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(5px, 1.6vw, 11px);
  width: 100%;
  /* nunca más ancho que el panel ni más alto que la pantalla disponible */
  max-width: min(520px, max(260px, calc(100vh - 330px)));
}

.tablero.sacudir { animation: sacudida .45s cubic-bezier(.36, .07, .19, .97); }

@keyframes sacudida {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.nota-tablero {
  text-align: center;
  font-size: 12.5px;
  color: var(--texto-tenue);
  margin-top: 14px;
}

/* ---------- Celda ---------- */

.celda {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: var(--radio-m);
  perspective: 700px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.celda:disabled { cursor: default; }

.celda-interior {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform .42s cubic-bezier(.3, 1.4, .5, 1);
}

.celda.revelada .celda-interior { transform: rotateY(180deg); }

.cara {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radio-m);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* Cara oculta */
.cara-frente {
  background: linear-gradient(180deg, #1E3050 0%, #172742 100%);
  border: 1px solid #2A3D5E;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: transform .14s ease, background .14s ease, border-color .14s ease,
              visibility 0s linear .21s;
}

/* Respaldo: si el navegador aplana el 3D, la visibilidad hace el cambio igual */
.celda.revelada .cara-frente { visibility: hidden; }
.cara-reverso { visibility: hidden; transition: visibility 0s linear .21s; }
.celda.revelada .cara-reverso { visibility: visible; }

.celda:not(:disabled):hover .cara-frente {
  background: linear-gradient(180deg, #263D64 0%, #1D3053 100%);
  border-color: #3A5480;
  transform: translateY(-2px);
}

.celda:not(:disabled):active .cara-frente { transform: translateY(0) scale(.97); }

/* Cara revelada */
.cara-reverso {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #16243D 0%, #101B2E 100%);
  border: 1px solid #24344F;
}

.celda.gema .cara-reverso {
  background: linear-gradient(180deg, rgba(56, 189, 248, .16), rgba(14, 165, 233, .06));
  border-color: rgba(56, 189, 248, .45);
}

.celda.bomba .cara-reverso {
  background: linear-gradient(180deg, rgba(240, 80, 58, .18), rgba(185, 28, 28, .07));
  border-color: rgba(240, 80, 58, .5);
}

.celda.apagada { opacity: .42; }

/* ---------- Icono de gema ---------- */

.icono-gema {
  width: 56%;
  height: 56%;
  overflow: visible;
}

.gema-cuerpo {
  fill: url(#degradadoGema);
  stroke: #BAE6FD;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.gema-lineas {
  fill: none;
  stroke: rgba(224, 246, 255, .75);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-dasharray: 90;
  stroke-dashoffset: 90;
}

.celda.revelada.gema .icono-gema { animation: brote-gema .45s cubic-bezier(.2, 1.5, .4, 1) .18s backwards; }
.celda.revelada.gema .gema-lineas { animation: trazo-gema .5s ease-out .34s forwards; }

@keyframes brote-gema {
  0%   { transform: scale(.2) rotate(-14deg); opacity: 0; }
  60%  { transform: scale(1.14) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes trazo-gema {
  to { stroke-dashoffset: 0; }
}

/* destello que recorre la gema */
.destello {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 38%, rgba(186, 230, 253, .38) 50%, transparent 62%);
  transform: translateX(-110%);
}

.celda.revelada.gema .destello { animation: barrido .7s ease-out .42s; }

@keyframes barrido {
  to { transform: translateX(110%); }
}

/* ---------- Icono de bomba ---------- */

.icono-bomba { width: 56%; height: 56%; overflow: visible; }

.bomba-cuerpo { fill: url(#degradadoBomba); stroke: #FCA5A5; stroke-width: 1.4; }
.bomba-mecha { fill: none; stroke: #FCA5A5; stroke-width: 2.2; stroke-linecap: round; }
.bomba-brillo { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 1.8; stroke-linecap: round; }
.bomba-chispa { fill: var(--ambar); }

.celda.revelada.bomba .icono-bomba { animation: golpe-bomba .5s cubic-bezier(.2, 1.5, .4, 1) .16s backwards; }
.celda.revelada.bomba .bomba-chispa { animation: chispazo .6s ease-in-out .3s infinite; }

@keyframes golpe-bomba {
  0%   { transform: scale(.3); opacity: 0; }
  45%  { transform: scale(1.22); opacity: 1; }
  70%  { transform: scale(.94) rotate(-5deg); }
  85%  { transform: rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes chispazo {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(1.5); }
}

/* onda expansiva */
.onda {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2px solid var(--rojo);
  opacity: 0;
  pointer-events: none;
}

.celda.revelada.bomba .onda { animation: onda-expansiva .65s ease-out .2s; }
.celda.revelada.gema .onda { border-color: var(--gema); animation: onda-expansiva .6s ease-out .22s; }

@keyframes onda-expansiva {
  0%   { opacity: .9; transform: scale(.5); }
  100% { opacity: 0; transform: scale(4.6); }
}

/* fogonazo rojo al perder */
.panel-juego { position: relative; overflow: hidden; }

.panel-juego.fogonazo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(240, 80, 58, .22), transparent 65%);
  pointer-events: none;
  animation: fogonazo .6s ease-out forwards;
}

@keyframes fogonazo {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Responsivo ---------- */

/* Android y móviles pequeños */
@media (max-width: 480px) {
  .barra-estatus { padding: 10px 11px; }
  .estatus-datos dd { font-size: 13.5px; }
  .estatus-texto { font-size: 12.5px; }
  .nota-tablero { font-size: 11.5px; margin-top: 11px; }
  .icono-gema, .icono-bomba { width: 62%; height: 62%; }
}

/* Móvil en horizontal: el tablero manda sobre el alto */
@media (max-height: 560px) and (orientation: landscape) {
  .tablero { max-width: min(420px, max(200px, calc(100vh - 150px))); }
  .estatus-progreso { margin: 8px 0 9px; }
}

/* Laptops */
@media (min-width: 1024px) {
  .tablero { max-width: min(500px, max(300px, calc(100vh - 300px))); }
}

/* Monitores grandes */
@media (min-width: 1440px) {
  .tablero { max-width: min(580px, max(320px, calc(100vh - 300px))); }
  .estatus-datos dd { font-size: 17px; }
  .nota-tablero { font-size: 13.5px; }
}
