/* ========================================
   1. AJUSTES GENERALES
======================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;

  display: flex;
  justify-content: center;
  align-items: center;

  background: #f3f4f8;
  font-family: Arial, sans-serif;
}

/* ========================================
   2. CONTENEDOR PRINCIPAL
======================================== */

#puzzle-game {
  width: min(1200px, 96vw);
  min-height: auto;

  display: grid;

  grid-template-columns: 360px 1fr 180px;
  grid-template-rows: auto auto auto;

  gap: 10px;
  padding: 16px;

  background: white;
  border: 3px solid #333;
  border-radius: 20px;
}

/* ========================================
   3. MARCADOR
======================================== */

#scoreboard {
  grid-column: 1;
  grid-row: 1;

  display: flex;
  flex-direction: row;
  gap: 8px;

  padding: 16px;

  background: #fff4c7;
  border: 2px solid #d6b44a;
  border-radius: 14px;

  justify-content: flex-start;
  align-items: center;
}

#player-score,
#robot-score {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 10px;
  background: white;
  border-radius: 12px;

  width: 145px;
  box-sizing: border-box;
}

#player-score {
  border: 3px solid #4f9df7;
}

#robot-score {
  border: 3px solid #f28b45;
}

.stars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;

  font-size: 16px;
  line-height: 1;
}

.star-row {
  display: flex;
  gap: 2px;
}

.star {
  color: #d9d9d9;
}

.star-green {
  color: #43a047;
}

.star-orange {
  color: #fb8c00;
}

.star-red {
  color: #e53935;
}

.score-character {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

/* ========================================
   4. ZONA SUPERIOR
======================================== */

#top-zone {
  grid-column: 2 / 4;
  grid-row: 1;

  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;

  min-height: 110px;
  padding: 14px;

  background: #eaf4ff;
  border: 2px dashed #6fa8dc;
  border-radius: 14px;
}

#play-button {
  width: 100px;
  height: 100px;

  border: none;
  border-radius: 50%;

  font-size: 50px;
  font-weight: bold;

  cursor: pointer;
  background: #31c950;
  box-shadow: 0 5px 0 #f4a8ff;
  transition: transform 0.2s ease;
}

#play-button:hover {
  transform: scale(1.08);
}

#selected-image-zone {
  position: relative;
  overflow: hidden;
  width: 230px;
  height: 140px;

  display: flex;
  justify-content: center;
  align-items: center;

  background: white;
  border: 2px dashed #999;
  border-radius: 12px;
}

#selected-image-zone img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Velo rojo para una imagen incorrecta */

#selected-image-zone.image-incorrect::after {
  content: "";

  position: absolute;
  inset: 0;

  background: rgba(220, 40, 40, 0.45);
  border-radius: 10px;

  pointer-events: none;
}

/* Velo verde para una imagen correcta */

#selected-image-zone.image-correct::after {
  content: "";

  position: absolute;
  inset: 0;

  background: rgba(70, 190, 90, 0.28);
  border-radius: 10px;

  pointer-events: none;
}

/* ========================================
   5. IMÁGENES DISPONIBLES
======================================== */

#image-options-zone {
  grid-column: 1;
  grid-row: 2 / 4;

  padding: 16px;

  background: #eef9ee;
  border: 2px dashed #69a96b;
  border-radius: 14px;
}

#image-options-zone h2 {
  margin-top: 0;
  text-align: center;
}

#image-options {
  min-height: 220px;
}

/* ========================================
   6. CONTROLES
======================================== */

#controls-zone {
  grid-column: 3;
  grid-row: 1;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  gap: 14px;
}

#next-button {
  min-width: 150px;
  padding: 14px 24px;

  border: none;
  border-radius: 12px;
  background: #fe9a37;
  font-size: 18px;
  font-weight: bold;
  transition: transform 0.2s ease;
  cursor: pointer;
}

#next-button:hover {
  transform: scale(1.08);
}

/* ========================================
   7. IMÁGENES DE LA RONDA
======================================== */

#image-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.image-option {
  padding: 6px;

  background: white;
  border: 2px solid transparent;
  border-radius: 12px;

  cursor: pointer;
  transition: transform 0.2s ease;

  /* Evita que el gesto táctil se interprete como scroll */

  touch-action: none;
}

.image-option:hover {
  transform: scale(1.06);
}

.image-option img {
  display: block;
  width: 100%;
  height: 180px;

  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* Copia visual de la imagen durante el arrastre táctil */

.touch-drag-image-clone {
  position: fixed;
  z-index: 2000;

  pointer-events: none;

  object-fit: contain;
}

/* ========================================
     ANIMACIÓN DE RETORNO DE IMÁGENES
======================================== */

/* ----------------------------------------
   Clon temporal de una imagen
---------------------------------------- */

.return-animation-clone {
  position: fixed;
  z-index: 1000;

  margin: 0;
  pointer-events: none;

  transition:
    left 0.65s ease-in-out,
    top 0.65s ease-in-out,
    width 0.65s ease-in-out,
    height 0.65s ease-in-out;
}

/* ========================================
   8. VENTANA FINAL DE LA PARTIDA
======================================== */

/* Mantener la ventana completamente oculta
   mientras conserve el atributo hidden */

#game-over-modal[hidden] {
  display: none;
}

/* ----------------------------------------
   Fondo que cubre toda la pantalla
---------------------------------------- */

#game-over-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 20px;

  background: rgba(30, 35, 50, 0.65);
}

/* ----------------------------------------
   Caja principal de la ventana
---------------------------------------- */

#game-over-window {
  width: min(680px, 94vw);

  padding: 28px;

  text-align: center;

  background: white;
  border: 4px solid #333;
  border-radius: 24px;

  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

/* ----------------------------------------
   Título y mensaje
---------------------------------------- */

#game-over-title {
  margin: 0 0 8px;

  font-family: "Fredoka", sans-serif;
  font-size: 48px;
  line-height: 1;

  color: #31a94b;
}

#game-over-message {
  margin: 0 0 24px;

  font-family: "Poppins", sans-serif;
  font-size: 22px;
  font-weight: 600;

  color: #333;
}

/* ----------------------------------------
   Marcador final
---------------------------------------- */

#final-scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;

  margin-bottom: 22px;
}

.final-score {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;

  padding: 18px;

  background: #fff4c7;
  border-radius: 16px;
}

.final-score:first-child {
  border: 3px solid #4f9df7;
}

.final-score:last-child {
  border: 3px solid #f28b45;
}

/* Las mismas imágenes del marcador,
   pero algo más grandes dentro de la modal */

.final-score .score-character {
  width: 120px;
  height: 120px;
}

/* Las estrellas conservan sus clases
   y colores originales */

.final-score .stars {
  font-size: 34px;
}

/* ----------------------------------------
   Resumen final
---------------------------------------- */

#game-over-summary {
  min-height: 28px;
  margin: 0 0 22px;

  font-family: "Poppins", sans-serif;
  font-size: 18px;
  font-weight: 600;

  color: #333;
}

/* ----------------------------------------
   Botón PLAY AGAIN
---------------------------------------- */

#play-again-button {
  min-width: 190px;
  padding: 14px 26px;

  border: none;
  border-radius: 12px;

  background: #31c950;

  font-family: "Poppins", sans-serif;
  font-size: 18px;
  font-weight: 600;

  cursor: pointer;

  box-shadow: 0 5px 0 #209c39;
  transition: transform 0.2s ease;
}

#play-again-button:hover {
  transform: scale(1.08);
}
