/* ============================================================
   ESTILOS GENERALES
   ============================================================ */
html,
body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #fff;
  font-family: "Arial", sans-serif;
  height: 100%;
  overflow: hidden;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: 8px;
}

/* ============================================================
   PANEL DE NOMBRE
   ============================================================ */
.name-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.name-box {
  background: linear-gradient(180deg, #3a2b1f, #24180f);
  border: 4px solid rgba(214, 170, 60, 1);
  color: #f4e5c0;
  padding: 22px;
  width: 360px;
  border-radius: 12px;
  text-align: center;
}

.name-box input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid #d4a02f;
  margin-top: 10px;
  margin-bottom: 12px;
  font-size: 16px;
}

/* ============================================================
   MENÚ PRINCIPAL
   ============================================================ */
#bg-image {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: url("sol1.png") center/cover no-repeat;
  filter: brightness(0.88);
  z-index: -1;
}

#mainMenu {
  position: fixed;
  inset: 0;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

#menuContent {
  position: relative;
  z-index: 3;
  text-align: center;
  width: 90%;
  max-width: 600px;
}

.menu-title {
  font-size: 42px;
  font-weight: bold;
  color: #ffd86b;
  text-shadow: 0 0 18px #c17800;
  margin-bottom: 8px;
}

.menu-subtitle {
  font-size: 20px;
  color: #ffe4b1;
  margin-bottom: 30px;
}

.menu-button {
  padding: 14px 24px;
  background: #d8a441;
  color: #000;
  font-size: 18px;
  font-weight: bold;
  width: 100%;
  border-radius: 14px;
  margin-bottom: 15px;
  transition: 0.2s;
}

.menu-button:hover {
  background: #ffcf63;
}

.menu-footer {
  margin-top: 25px;
  font-size: 14px;
  color: #f6e6bd;
  /* border: 1px solid red; */
}

.footer__author {
  display: inline-block;
  font-size: 1.5rem;
  color: #ffe39f;
  opacity: .9;
  font-weight: bold;

  border: 2px solid #d4a02f;
  border-radius: .75rem;
  padding: .75rem 1rem;
  background: rgba(0, 0, 0, .4);
  text-shadow: 2px 2px 2px #000;
  /* z-index: 10; */

}

#soundToggle {
  position: absolute;
  top: 12px;
  right: 15px;
  z-index: 4;
  font-size: 32px;
  cursor: pointer;
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
.hidden {
  display: none !important;
}

#gameRoot {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}

#background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
  filter: brightness(0.9);
}

#hud {
  z-index: 3;
  display: flex;
  justify-content: space-between;
  padding: 12px 22px;
  background: linear-gradient(90deg, #000000aa, #00000055);
  font-size: 20px;
}

.hud-box {
  padding: 8px 18px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #d4a02f;
  border-radius: 8px;
}

/* ============================================================
   STAGE
   ============================================================ */
#stage {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(100% - 80px);
  padding: 20px;
}

/* PANEL IZQ / DER */
.panel {
  width: 280px;
  text-align: center;
}

.portrait {
  width: 260px;
  height: 330px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: 4px solid #d4a02f;
  box-shadow: 0 0 14px #000;
  border-radius: 12px;
}

.portrait-name {
  margin-top: 8px;
  font-size: 20px;
  font-weight: bold;
  color: #ffdd9d;
  text-shadow: 0 0 6px #000;
}

/* PANEL CENTRAL */
#centerPanel {
  width: 50%;
  text-align: center;
}

.dialogue {
  background: rgba(0, 0, 0, 0.55);
  padding: 10px;
  border: 2px solid #d4a02f;
  margin-bottom: 14px;
  border-radius: 8px;
}

.problem-card {
  background: linear-gradient(180deg, #3e2f21, #1e150d);
  border: 5px solid #d4a02f;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 0 18px #000;
  max-height: 420px;
  /* evita cortes */
}

.problem-text {
  font-size: 20px;
  line-height: 1.4;
  min-height: 110px;
  color: #ffecc4;
}

/* TECLADO */
.keyboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.key {
  padding: 14px;
  font-size: 20px;
  background: #d4a02f;
  color: #000;
  border-radius: 12px;
}

.controls {
  margin-top: 18px;
}

.btn {
  padding: 14px 22px;
  font-size: 18px;
  border-radius: 12px;
}

.submit {
  background: #7cff7c;
  color: #003300;
}

.hint {
  background: #ffd277;
  color: #4b2c00;
}

/* ============================================================
   FINAL SCREEN — Cuadro centrado estilo “libro sagrado”
   ============================================================ */
.final-screen {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #000000cc, #000000ee);
}

.final-layout {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.inti-img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 75%;
  max-width: 650px;
  opacity: 0.15;
  transform: translate(-50%, -50%);
  z-index: 0;
  filter: drop-shadow(0 0 25px gold);
}

.summary-box {
  position: relative;
  margin: auto;
  width: 90%;
  max-width: 1000px;
  height: 85vh;
  background: linear-gradient(180deg, #3a2b1f, #24180f);
  border: 5px solid #d4a02f;
  border-radius: 18px;
  padding: 30px;
  z-index: 2;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 35px #d4a02f;
}

/* Contenedor de la tabla con scroll flexible */
#finalTableContainer {
  flex: 1;
  margin-top: 14px;
  max-height: 100%;
  overflow-y: auto;
  /* scroll solo si la tabla excede altura */
  background: rgba(60, 40, 20, 0.6);
  border: 2px solid #d4a02f;
  border-radius: 12px;
  padding: 12px;
  box-shadow: inset 0 0 12px #00000099;
}

#resultsTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  /* columna Pregunta se ajusta automáticamente */
}

#resultsTable th,
#resultsTable td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  padding: 12px 8px;
  color: #ffecc4;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  /* permite wrap */
  word-break: break-word;
  /* corta palabras largas */
}

/* Eliminar min-height rígido y altura automática */
#resultsTable tr {
  height: auto;
  min-height: unset;
}

/* Alternar color de filas */
#resultsTable tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

#resultsTable tr:nth-child(odd) {
  background: rgba(0, 0, 0, 0);
}

/* Scroll control */
#finalScroll {
  width: 100%;
  margin-top: 12px;
}

/* Puntajes y desbloqueo final */
#finalPoints,
#finalBonus,
#finalUnlock {
  font-size: 18px;
  margin-top: 6px;
  font-weight: bold;
  color: #ffd86b;
  text-shadow: 0 0 6px #000;
}

/* ============================================================
   FIX DEL EDITOR
   ============================================================ */
.editorCard {
  max-height: 500px;
  overflow-y: auto !important;
}

.tableContainer {
  max-height: 300px;
  /* scroll si hay muchos problemas */
  overflow-y: auto;
  border: 2px solid #d4a02f;
  border-radius: 8px;
  padding: 4px;
  background: rgba(60, 40, 20, 0.6);
}

.problemTable {
  width: 100%;
  border-collapse: collapse;
}

.problemTable th,
.problemTable td {
  padding: 8px 6px;
  color: #ffecc4;
  text-align: left;
  vertical-align: top;
  white-space: normal !important;
  /* permite wrap */
  word-break: break-word !important;
  /* rompe palabras largas */
}

.problemTable th:nth-child(1),
.problemTable td:nth-child(1) {
  width: 5%;
}

.problemTable th:nth-child(2),
.problemTable td:nth-child(2) {
  width: 80%;
}

/* más ancho para el enunciado */
.problemTable th:nth-child(3),
.problemTable td:nth-child(3) {
  width: 15%;
  text-align: center;
}

/* *********************************************************************************************************** */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Pantallas grandes */
/* --------------------- */
/* @media (min-width: 1500px) { */
/* .portrait { */
/* width: 320px; */
/* height: 400px; */
/* } */
/*  */
/* #centerPanel { */
/* width: 45%; */
/* } */
/*  */
/* .problem-text { */
/* font-size: 24px; */
/* } */
/*  */
/* .key { */
/* font-size: 24px; */
/* padding: 18px; */
/* } */
/* } */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Tablets horizontales (1200px ↓) */
/* --------------------- */
/* @media (max-width: 1200px) { */
/* #stage { */
/* padding: 10px; */
/* gap: 10px; */
/* } */
/*  */
/* .panel { */
/* width: 220px; */
/* } */
/*  */
/* .portrait { */
/* width: 200px; */
/* height: 260px; */
/* } */
/*  */
/* #centerPanel { */
/* width: 55%; */
/* } */
/*  */
/* .problem-card { */
/* max-height: 380px; */
/* } */
/* } */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Tablets verticales (980px ↓) */
/* --------------------- */
/* @media (max-width: 980px) { */
/* #hud { */
/* font-size: 16px; */
/* padding: 8px 12px; */
/* } */
/*  */
/* #stage { */
/* flex-direction: column; */
/* justify-content: start; */
/* height: auto; */
/* } */
/*  */
/* .panel { */
/* width: 100%; */
/* } */
/*  */
/* .portrait { */
/* margin: auto; */
/* width: 200px; */
/* height: 250px; */
/* } */
/*  */
/* #centerPanel { */
/* width: 100%; */
/* margin-top: 10px; */
/* } */
/* } */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Celulares grandes (780px ↓) */
/* --------------------- */
/* @media (max-width: 780px) { */
/* .menu-title { */
/* font-size: 32px; */
/* } */
/*  */
/* .menu-button.big { */
/* font-size: 16px; */
/* } */
/*  */
/* .portrait { */
/* width: 160px; */
/* height: 200px; */
/* } */
/*  */
/* .problem-card { */
/* padding: 16px; */
/* max-height: 360px; */
/* } */
/*  */
/* .problem-text { */
/* font-size: 18px; */
/* } */
/*  */
/* .key { */
/* font-size: 18px; */
/* padding: 12px; */
/* } */
/* } */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Celulares medianos (600px ↓) */
/* --------------------- */
/* @media (max-width: 600px) { */
/* #hud { */
/* flex-direction: column; */
/* gap: 6px; */
/* padding: 10px; */
/* font-size: 14px; */
/* } */
/*  */
/* .portrait { */
/* width: 140px; */
/* height: 180px; */
/* } */
/*  */
/* #problemText { */
/* font-size: 17px; */
/* } */
/*  */
/* #keyboard { */
/* grid-template-columns: repeat(3, 1fr); */
/* gap: 6px; */
/* } */
/*  */
/* .key { */
/* padding: 10px; */
/* } */
/*  */
/* .summary-box { */
/* padding: 16px; */
/* max-height: 80vh; */
/* } */
/*  */
/* #resultsTable th, */
/* #resultsTable td { */
/* font-size: 12px; */
/* padding: 4px; */
/* } */
/* } */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Celulares pequeños (480px ↓) */
/* --------------------- */
/* @media (max-width: 480px) { */
/* .menu-title { */
/* font-size: 26px; */
/* } */
/*  */
/* .menu-subtitle { */
/* font-size: 16px; */
/* } */
/*  */
/* #stage { */
/* padding: 6px; */
/* } */
/*  */
/* .portrait { */
/* width: 120px; */
/* height: 150px; */
/* } */
/*  */
/* .problem-card { */
/* padding: 10px; */
/* max-height: 300px; */
/* } */
/*  */
/* #problemText { */
/* font-size: 15px; */
/* } */
/*  */
/* .key { */
/* padding: 8px; */
/* font-size: 16px; */
/* } */
/*  */
/* #finalScroll { */
/* margin-top: 4px; */
/* } */
/* } */
/*  */
/*  */
/* /* --------------------- */
/* 🔹 Celulares muy pequeños (380px ↓) */
/* --------------------- */
/* @media (max-width: 380px) { */
/* .portrait { */
/* width: 100px; */
/* height: 130px; */
/* } */
/*  */
/* .problem-text { */
/* font-size: 14px; */
/* } */
/*  */
/* #keyboard { */
/* gap: 4px; */
/* } */
/*  */
/* .key { */
/* padding: 6px; */
/* font-size: 14px; */
/* } */
/*  */
/* #resultsTable th, */
/* #resultsTable td { */
/* font-size: 10px; */
/* } */
/* } */


/* *********************************************************************** */

/* ============================================================
   🔧 RESPONSIVE — PREVENIR QUE LAS IMÁGENES TAPEN BOTONES
   ============================================================ */

/* ================================================
     ⭐ HUD RESPONSIVE — Para celulares y tablets
  =================================================== */

@media (max-width: 900px) {

  /* El HUD se hace más compacto y ordenado */
  #hud {
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
  }

  #hud .hud-box {
    width: 95%;
    text-align: center;
    padding: 8px 5px;
    font-size: 18px;
  }
}

@media (max-width: 600px) {

  #hud {
    flex-direction: column;
    gap: 4px;
    padding: 6px 0;
  }

  #hud .hud-box {
    width: 90%;
    padding: 6px 5px;
    font-size: 16px;
    /* Más pequeño para evitar que tape elementos */
  }
}

/* Evitar que el HUD se superponga sobre los botones del problema */
@media (max-height: 600px) {
  #hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  #problemCard {
    margin-top: 10px !important;
  }
}

/* 📱 Celulares verticales pequeños */
@media (max-width: 600px) {

  /* Hace que el layout se apile en columna */
  #stage {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
  }

  /* Los paneles laterales (boss / jugador) se reducen */
  .panel {
    width: 100%;
    display: flex;
    justify-content: space-around;
    margin: 0;
    padding: 0;
  }

  /* Tamaño más pequeño para los retratos */
  .portrait {
    width: 80px !important;
    height: 80px !important;
    background-size: contain !important;
    background-position: center !important;
    margin: 5px;
  }

  /* Nombre debajo de cada retrato */
  .portrait-name {
    font-size: 14px;
    text-align: center;
  }

  /* 🔥 Caja del problema ocupa 100% del ancho */
  #problemCard {
    width: 95% !important;
    max-width: 500px;
  }

  /* Texto del problema más legible y sin salir del cuadro */
  #problemText {
    font-size: 16px;
    line-height: 1.25;
    word-break: break-word;
  }

  /* El teclado no se achica demasiado */
  .keyboard {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  /* Botones */
  .btn,
  .submit,
  .hint {
    font-size: 16px !important;
    padding: 10px !important;
  }

  /* Evita que las imágenes cubran los botones */
  #centerPanel {
    z-index: 10;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

/* 📱 Tablets pequeñas / grandes */
@media (min-width: 601px) and (max-width: 1024px) {

  .portrait {
    width: 110px !important;
    height: 110px !important;
  }

  #problemCard {
    width: 90% !important;
    max-width: 600px;
  }

  .keyboard {
    max-width: 500px;
  }

  #centerPanel {
    z-index: 10;
  }
}