/* =========================================================
   RESET BÁSICO
   ========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

button {
  font: inherit;
}


/* =========================================================
   PÁGINA
   ========================================================= */

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;

  padding: 24px;

  background: #f3f4f7;
  font-family: Arial, Helvetica, sans-serif;
}


/* =========================================================
   ESCENARIO PRINCIPAL
   ========================================================= */

.game {
  width: min(100%, 760px);

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 14px;

  padding: 28px 34px;

  background: #ffffff;
  border-radius: 24px;

  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   COLUMNA PRINCIPAL DE CONTENIDO
   ========================================================= */

.content-column {
  width: min(100%, 500px);

  display: grid;
  grid-template-columns: minmax(0, 390px) max-content;

  justify-content: center;
  align-items: center;

  column-gap: 12px;
  row-gap: 14px;
}


/* =========================================================
   ZONA DE AUDIO
   ========================================================= */

.top-row {
  grid-column: 1;
  grid-row: 1;

  width: 100%;

  display: grid;
  grid-template-columns: 76px 1fr;

  align-items: center;
  column-gap: 24px;
}

.audio-zone {
  display: flex;
  justify-content: center;
  align-items: center;

  margin-bottom: 2px;
}

.audio-button {
  width: 76px;
  height: 76px;

  font-size: 38px;
}

/* ========================================
   MARCADOR
======================================== */

#scoreboard {
  justify-self: end;

  display: flex;
  flex-direction: row;
  gap: 8px;

  padding: 10px;

  background: #fff4c7;
  border: 2px solid #d6b44a;
  border-radius: 14px;
}

#player-score,
#robot-score {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 10px;
  background: white;
  border-radius: 12px;
}

#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: 5px;
}

.star {
  color: #d9d9d9;
}

.star-green {
  color: #43a047;
}

.star-orange {
  color: #fb8c00;
}

.star-red {
  color: #e53935;
}

.score-character {
  width: 40px;
  height: 40px;
  object-fit: contain;
}


/* =========================================================
   ZONAS DE RESPUESTA
   ========================================================= */

.answer-zone {
  display: contents;
}


/* =========================================================
   TARJETAS DE CONTENIDO
   ========================================================= */

.content-card {
  position: relative;
  overflow: hidden;

  background: #ffffff;
}

/* =========================================================
   IMAGEN
   ========================================================= */

.image-card {
  width: 100%;
  aspect-ratio: 1 / 1;

  display: flex;
  justify-content: center;
  align-items: center;

  border: 4px solid #7d267c;
  border-radius: 42px;
}

.game-image {
  width: 100%;
  height: 100%;

  display: block;

  object-fit: contain;
}

.image-card {
  grid-column: 1;
  grid-row: 2;
}

.image-answer-controls {
  grid-column: 2;
  grid-row: 2;
}

.chunk-card {
  grid-column: 1;
  grid-row: 3;
  align-self: start;
}

.chunk-answer-controls {
  grid-column: 2;
  grid-row: 3;
  align-self: start;
}

/* =========================================================
   CHUNK
   ========================================================= */

.chunk-card {
  width: 100%;
  min-height: 86px;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 16px 24px;

  border: 4px solid #2dc951;
  border-radius: 18px;
}

.game-chunk {
  margin: 0;

  text-align: center;

  font-size: 25px;
  font-weight: 700;
  line-height: 1.25;
}


/* =========================================================
   CONTROLES DE RESPUESTA
   ========================================================= */

.answer-controls {
  display: flex;
  justify-content: center;
  align-items: center;

  gap: 8px;

  padding: 8px;

  border: 4px dashed;
  border-radius: 18px;

  background: #ffffff;
}

.image-answer-controls {
  flex-direction: column;

  border-color: #7d267c;
}

.chunk-answer-controls {
  flex-direction: column;

  position: relative;
  top: -40px;

  border-color: #2dc951;
}

.answer-type-icon {
  display: flex;
  justify-content: center;
  align-items: center;

  width: 54px;
  height: 54px;

  font-size: 34px;

  border-radius: 12px;
}


/* =========================================================
   BOTONES DE RESPUESTA
   ========================================================= */

.answer-button {
  width: 58px;
  height: 58px;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 0;

  border: 0;
  border-radius: 14px;

  background: transparent;

  font-size: 40px;
  line-height: 1;

  cursor: pointer;

  transition:
    transform 0.15s ease,
    background-color 0.15s ease,
    opacity 0.15s ease;
}

.answer-button:hover {
  transform: scale(1.08);
}

.answer-button:active {
  transform: scale(0.96);
}

.answer-button.selected {
  background: #dcefff;
  transform: scale(1.08);
}

.answer-button:disabled {
  cursor: default;
  opacity: 0.65;
}

.answer-button:focus-visible {
  outline: 4px solid #2f7ee6;
  outline-offset: 3px;
}


/* =========================================================
   VELOS DE FEEDBACK
   ========================================================= */

.feedback-overlay {
  position: absolute;
  inset: 0;

  z-index: 2;

  pointer-events: none;

  opacity: 0;

  transition: opacity 0.25s ease;
}

.feedback-overlay.is-visible {
  opacity: 0.5;
}

.feedback-overlay.is-correct {
  background: #21c45a;
}

.feedback-overlay.is-wrong {
  background: #f39a24;
}

/* =========================================================
   CONTROLES GENERALES
   ========================================================= */

.game-controls {
  width: 390px;

  display: flex;
  justify-content: center;
  align-items: center;

  gap: 14px;

  /*margin-top: -75px;*/
  margin-top: -150px;
  margin-left: 100px;

  align-self: flex-start;

  border: 4px solid #4a90e2;
  border-radius: 18px;

  padding: 10px;
}

.icon-button {
  width: 66px;
  height: 66px;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 0;

  border: 0;
  border-radius: 16px;

  background: linear-gradient(
    180deg,
    #6cb6ff 0%,
    #3e8be6 100%
  );

  color: #ffffff;

  font-size: 34px;
  line-height: 1;

  cursor: pointer;

  box-shadow:
    0 5px 0 #246ab9,
    0 7px 12px rgba(0, 0, 0, 0.18);

  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    opacity 0.15s ease;
}

.icon-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.icon-button:active:not(:disabled) {
  transform: translateY(3px);

  box-shadow:
    0 2px 0 #246ab9,
    0 4px 7px rgba(0, 0, 0, 0.14);
}

.icon-button:focus-visible {
  outline: 4px solid #222222;
  outline-offset: 4px;
}

.icon-button:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}

.check-button {
  background: linear-gradient(
    180deg,
    #58d889 0%,
    #27aa62 100%
  );

  box-shadow:
    0 5px 0 #168248,
    0 7px 12px rgba(0, 0, 0, 0.18);
}

/* =========================================================
   BOTÓN ACTIVO
   ========================================================= */

.active-button {
  animation: buttonPulse 1.1s ease-in-out infinite;
}

@keyframes buttonPulse {

  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }

}




/* ========================================
   13. 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);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 640px) {

  body {
    padding: 12px;
    align-items: flex-start;
  }

  .game {
    padding: 20px 14px;
    border-radius: 18px;
  }

  .content-column {
    column-gap: 8px;
    row-gap: 12px;
  }

  .image-card {
    border-radius: 28px;
  }

  .answer-controls {
    padding: 5px;
    gap: 4px;
  }

  .answer-type-icon {
    width: 44px;
    height: 44px;

    font-size: 28px;
  }

  .answer-button {
    width: 48px;
    height: 48px;

    font-size: 33px;
  }

  .chunk-card {
    min-height: 74px;
    padding: 12px 16px;
  }

  .icon-button {
    width: 58px;
    height: 58px;

    font-size: 30px;
  }
}

@media (max-width: 440px) {

  .game {
    gap: 10px;
  }

  .image-card {
    border-width: 3px;
  }

  .chunk-card {
    border-width: 3px;
  }

  .answer-controls {
    border-width: 3px;
  }

  .answer-type-icon {
    display: none;
  }

  .answer-button {
    width: 42px;
    height: 42px;

    font-size: 29px;
  }

  .game-controls {
    gap: 10px;
  }
}