:root {
  --fondo: #2b2d42;
  --papel: #fff8e7;
  --tinta: #3a2e22;
  --borde: #3a3a50;
  --oro: #ffd34d;
  --oro-osc: #b8860b;
  --verde: #4caf50;
  --rojo: #e05a47;
  --azul: #4a6fa5;
  --pixel: "Press Start 2P", monospace;
  --letra: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fondo); font-family: var(--letra); color: var(--tinta); }
[hidden] { display: none !important; }
#juego { position: fixed; inset: 0; }
#juego canvas { display: block; }

/* ---------- botones ---------- */
.boton {
  font: 900 15px var(--letra);
  background: var(--oro); color: var(--tinta);
  border: 3px solid var(--borde); border-radius: 10px;
  padding: 10px 18px; cursor: pointer;
  box-shadow: 0 4px 0 var(--borde);
  transition: transform .08s, box-shadow .08s;
}
.boton:hover { filter: brightness(1.06); }
.boton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--borde); }
.boton:disabled { opacity: .6; cursor: wait; }
.boton.secundario { background: var(--papel); }
.boton.chico { font-size: 13px; padding: 6px 12px; box-shadow: 0 3px 0 var(--borde); }
.boton.grande { font-size: 18px; padding: 14px 28px; }
.enlace { background: none; border: 0; color: #c9c9e0; text-decoration: underline; cursor: pointer; font: 13px var(--letra); margin-top: 10px; }

/* ---------- marcador ---------- */
#hud {
  position: fixed; top: 12px; left: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
#hud .dato {
  background: var(--papel); border: 3px solid var(--borde); border-radius: 10px;
  padding: 6px 12px; font: 12px var(--pixel);
}
#hud .dato b { font-weight: normal; }
#btn-musica { margin-left: auto; width: 38px; padding-left: 0; padding-right: 0; }
#btn-ayuda { width: 38px; }

#etiqueta {
  position: fixed; z-index: 30; pointer-events: none;
  background: var(--borde); color: #fff; font: 11px var(--pixel);
  padding: 6px 8px; border-radius: 6px; white-space: nowrap;
}

#aviso {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  font: 20px var(--pixel); color: var(--oro);
  text-shadow: 3px 3px 0 var(--borde); pointer-events: none; opacity: 0; z-index: 60;
}
#aviso.ver { animation: subir 1.6s ease-out; }
@keyframes subir {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -30px); }
}

#sin-guardar {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 65;
  width: min(520px, calc(100% - 24px));
  background: #fbd5cf; border: 3px solid var(--rojo); border-radius: 10px;
  padding: 8px 12px; font-weight: 700; font-size: 14px; text-align: center;
}

/* ---------- diálogo ---------- */
#dialogo {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(760px, calc(100% - 24px));
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--papel); border: 4px solid var(--borde); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 6px 0 rgba(0,0,0,.35);
  cursor: pointer; z-index: 40; user-select: none;
}
#dialogo .retrato {
  flex: none; width: 72px; height: 72px; border-radius: 10px;
  background-color: #dfe8f5; border: 3px solid var(--borde);
  background-repeat: no-repeat; background-size: 5376px auto; background-position: -1740px -266px;
  image-rendering: pixelated;
}
#dialogo .cuerpo { flex: 1; position: relative; min-height: 72px; }
#dialogo .nombre { margin: 0 0 6px; font: 10px/1.4 var(--pixel); color: var(--oro-osc); }
#dialogo .texto { margin: 0; font-size: 18px; line-height: 1.45; font-weight: 700; padding-right: 18px; }
#dialogo .seguir { position: absolute; right: 0; bottom: -4px; animation: rebote .8s infinite; color: var(--oro-osc); }
@keyframes rebote { 50% { transform: translateY(4px); } }

/* ---------- ventanas ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 20, 35, .55);
  display: grid; place-items: center; padding: 16px;
}
.caja {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--papel); border: 4px solid var(--borde); border-radius: 16px;
  padding: 22px; box-shadow: 0 8px 0 rgba(0,0,0,.35);
  animation: aparecer .2s ease-out;
}
.caja.ancha { width: min(760px, 100%); }
.caja.centrada { text-align: center; }
@keyframes aparecer { from { transform: scale(.9); opacity: 0; } }
.caja h2 { margin: 4px 0 16px; font-size: 22px; line-height: 1.25; }
.etiqueta-obra { margin: 0; font: 10px var(--pixel); color: var(--oro-osc); }
.pista { margin: 14px 0; font-size: 16px; line-height: 1.4; }
.grande { font: 22px var(--pixel); color: var(--oro-osc); }
.botones { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.opciones { display: grid; gap: 10px; }
.opcion {
  text-align: left; font: 700 17px var(--letra); color: var(--tinta);
  background: #fff; border: 3px solid var(--borde); border-radius: 10px;
  padding: 12px 14px; cursor: pointer;
}
.opcion:hover:not(:disabled) { background: #fff3c4; }
.opcion.mal { background: #fbd5cf; border-color: var(--rojo); opacity: .7; animation: sacudir .35s; }
.opcion.bien { background: #d4f2d0; border-color: var(--verde); }
.opcion:disabled { cursor: default; }

@keyframes sacudir { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.sacudir { animation: sacudir .35s; }

/* minijuego de los días */
.dias-fila { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.dia-hueco {
  min-height: 92px; border: 3px dashed #c9b88f; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 6px 4px; font-size: 12px; text-align: center; gap: 4px;
}
.dia-hueco span { font: 8px var(--pixel); color: var(--oro-osc); }
.dia-hueco b { font-size: 24px; }
.dia-hueco.lleno { border-style: solid; border-color: var(--verde); background: #eaf8e6; font-weight: 700; }
.dias-cartas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.carta-dia {
  width: 100px; min-height: 92px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: 700 13px var(--letra); color: var(--tinta); text-align: center;
  background: #fff; border: 3px solid var(--borde); border-radius: 10px; padding: 8px 6px; cursor: pointer;
}
.carta-dia b { font-size: 28px; }
.carta-dia:hover { background: #fff3c4; }

/* minijuego de parejas */
.parejas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.carta {
  aspect-ratio: 1; border: 3px solid var(--borde); border-radius: 12px; cursor: pointer;
  background: var(--azul) repeating-linear-gradient(45deg, transparent 0 8px, rgba(255,255,255,.12) 8px 16px);
  font-size: 40px; display: grid; place-items: center;
}
.carta span { visibility: hidden; }
.carta.vuelta { background: #fff; }
.carta.vuelta span { visibility: visible; }
.carta.par { background: #d4f2d0; border-color: var(--verde); cursor: default; }

/* rollos */
.rollo {
  margin: 16px auto 20px; padding: 26px 22px; max-width: 420px;
  background: #f3e2b3; border: 3px solid #8a6d3b; border-radius: 6px;
  box-shadow: inset 0 0 30px rgba(138, 109, 59, .35);
  position: relative;
}
.rollo::before, .rollo::after {
  content: ""; position: absolute; left: -10px; right: -10px; height: 14px;
  background: #b98f4f; border: 3px solid #6b4f24; border-radius: 8px;
}
.rollo::before { top: -10px; }
.rollo::after { bottom: -10px; }
.versiculo { font-size: 20px; font-style: italic; font-weight: 700; line-height: 1.4; margin: 0 0 10px; }
.cita { margin: 0; font: 10px var(--pixel); color: #6b4f24; }

/* capítulos de Génesis descubiertos */
.capitulos { margin: 0 0 16px; text-align: left; }
.capitulos p { margin: 0 0 6px; font-size: 14px; }
.barra-capitulos { display: grid; grid-template-columns: repeat(25, 1fr); gap: 2px; }
.barra-capitulos span { height: 10px; border-radius: 2px; background: #e2d6bd; }
.barra-capitulos span.visto { background: var(--oro-osc); }

.coleccion { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.coleccion li { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 10px; background: #eee6d4; opacity: .65; }
.coleccion li.hecha { background: #f3e2b3; opacity: 1; }
.coleccion .num { font: 12px var(--pixel); background: var(--borde); color: #fff; border-radius: 6px; padding: 6px 8px; }
.coleccion small { display: block; color: #7a6a55; }
.coleccion p { margin: 6px 0 0; font-style: italic; }
.coleccion i { font-style: normal; font-size: 12px; color: #6b4f24; }

/* ---------- inicio ---------- */
#inicio {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px 16px 40px;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 30%, #3d4270, #1b1c2e);
}
.inicio-caja { text-align: center; color: #fff; max-width: 620px; }
.inicio-caja h1 {
  font: 34px/1.3 var(--pixel); color: var(--oro); margin: 8px 0 24px;
  text-shadow: 4px 4px 0 #6b4a00;
}
/* 238 px de ancho real, ampliado al doble; en pantallas angostas se encoge */
.inicio-caja .logo {
  display: block; margin: 0 auto 20px;
  width: 476px; max-width: 100%; height: auto;
  image-rendering: pixelated;
}
.inicio-caja .sub { color: #c9c9e0; margin: 0; }
#aviso-inicio { font-size: 17px; line-height: 1.4; margin: 0 auto 22px; max-width: 420px; }
a.boton { display: inline-block; text-decoration: none; }
#elegir { display: flex; gap: 10px; justify-content: center; margin: 12px 0 24px; flex-wrap: wrap; }
#elegir button {
  width: 88px; height: 116px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 3px solid transparent;
  display: grid; place-items: center;
}
#elegir button:hover { background: rgba(255,255,255,.16); }
#elegir button.elegido { border-color: var(--oro); background: rgba(255, 211, 77, .18); }
#elegir .figura {
  width: 64px; height: 88px; image-rendering: pixelated;
  background-repeat: no-repeat; background-size: 3584px auto; background-position: -1152px -168px;
}
.creditos { position: absolute; left: 16px; bottom: 12px; margin: 0; text-align: left; font-size: 12px; color: #9a9ab8; }
.creditos a { color: #c9c9e0; }

@media (max-width: 560px) {
  .inicio-caja h1 { font-size: 24px; }
  .inicio-caja .logo { margin-bottom: 12px; }
  #dialogo .retrato { width: 52px; height: 52px; background-size: 3584px auto; background-position: -1158px -178px; }
  #dialogo .texto { font-size: 16px; }
  .dias-fila { grid-template-columns: repeat(4, 1fr); }
  .caja h2 { font-size: 19px; }
}
