/* ==========================================================================
   estilos.css
   Dos tipografias: una de pixeles para el juego, una manuscrita para la carta.
   Nada de bordes redondeados en el juego: todo es cuadrado, como debe ser.
   ========================================================================== */

:root {
  --tinta:      #150e2e;
  --tinta-alta: #241748;
  --tinta-baja: #0b0620;
  --marfil:     #fdf6e7;
  --verde:      #8fd14f;
  --verde-hondo:#4f8f2b;
  --rosa:       #ff5c8a;
  --rosa-hondo: #b62f57;
  --dorado:     #ffd166;
  --cielo:      #5ca8e8;

  --pixel: "Press Start 2P", "Courier New", ui-monospace, monospace;
  --mano:  "Caveat", "Bradley Hand", "Segoe Script", cursive;

  --borde: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tinta-baja);
  color: var(--marfil);
  font-family: var(--pixel);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 14px;
}

/* el cielo estrellado de fondo, hecho con degradados */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1px 1px at 12% 22%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 14%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 71%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 84% 62%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 41%, #fff4 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 88%, #fff5 50%, transparent 51%),
    radial-gradient(1200px 700px at 50% -10%, #2c1d5c 0%, var(--tinta-baja) 70%);
}

/* ==========================================================================
   La consola
   ========================================================================== */

#consola {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#marco {
  width: 100%;
  padding: var(--borde);
  background: var(--marfil);
  box-shadow: 0 8px 0 0 var(--rosa-hondo), 0 8px 0 4px var(--tinta);
}

#escenario {
  position: relative;
  width: 100%;
  aspect-ratio: 640 / 360;
  background: var(--cielo);
  overflow: hidden;
}

#lienzo {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* ==========================================================================
   Marcador
   ========================================================================== */

#hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: clamp(7px, 1.5vw, 11px);
  line-height: 1;
  text-shadow: 2px 2px 0 #0007;
  pointer-events: none;
}

#vidas { display: flex; gap: 4px; }

.corazon {
  width: 1.1em; height: 1.1em;
  background: var(--rosa);
  clip-path: polygon(50% 100%, 0 45%, 0 20%, 25% 0, 50% 20%, 75% 0, 100% 20%, 100% 45%);
}
.corazon.vacio { background: #ffffff55; }

#contador { display: flex; align-items: center; gap: 6px; }

#icono-repollo {
  width: 1.1em; height: 1.1em;
  background: var(--verde);
  border: 2px solid var(--verde-hondo);
}

#hud-derecha {
  margin-left: auto;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.mini {
  font-family: var(--pixel);
  font-size: inherit;
  color: var(--marfil);
  background: #0006;
  border: 2px solid #ffffff44;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 1;
}
.mini:hover { background: #0009; }
.mini[aria-pressed="false"] { opacity: .45; }

/* ==========================================================================
   Capas (portada, tarjeta, pausa, etc.)
   ========================================================================== */

.capa {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 6% 8%;
  text-align: center;
  background: #150e2ee8;
  z-index: 5;
}
.capa[hidden] { display: none; }

.mini-titulo {
  margin: 0;
  font-size: clamp(7px, 1.4vw, 10px);
  color: var(--verde);
  letter-spacing: .08em;
}

.capa h1 {
  margin: 0;
  font-size: clamp(15px, 3.6vw, 30px);
  line-height: 1.5;
  color: var(--marfil);
  text-shadow: 3px 3px 0 var(--rosa-hondo);
}

.capa h2 {
  margin: 0;
  font-size: clamp(11px, 2.4vw, 19px);
  line-height: 1.6;
  color: var(--dorado);
}

.capa p {
  margin: 0;
  font-size: clamp(8px, 1.6vw, 12px);
  line-height: 1.9;
  color: #efe6ff;
  max-width: 44ch;
}

.ayuda-teclas { color: #bcaddd !important; }

/* ==========================================================================
   Botones
   ========================================================================== */

.boton {
  font-family: var(--pixel);
  font-size: clamp(9px, 1.8vw, 13px);
  color: var(--tinta);
  background: var(--verde);
  border: none;
  padding: 14px 22px;
  cursor: pointer;
  box-shadow: 0 5px 0 0 var(--verde-hondo);
  transition: transform .06s linear, box-shadow .06s linear;
}
.boton:hover { background: #9ee05c; }
.boton:active { transform: translateY(4px); box-shadow: 0 1px 0 0 var(--verde-hondo); }

.boton-suave {
  background: transparent;
  color: #cfc2ee;
  box-shadow: none;
  border: 2px solid #ffffff3a;
  padding: 11px 18px;
}
.boton-suave:hover { background: #ffffff14; color: var(--marfil); }
.boton-suave:active { transform: translateY(2px); box-shadow: none; }

:focus-visible {
  outline: 3px solid var(--dorado);
  outline-offset: 3px;
}

/* ==========================================================================
   Controles tactiles
   ========================================================================== */

#tactil {
  width: 100%;
  max-width: 860px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#tactil[hidden] { display: none; }

.grupo-izq { display: flex; gap: 12px; }

.pad {
  font-family: var(--pixel);
  font-size: 15px;
  color: var(--marfil);
  background: var(--tinta-alta);
  border: 3px solid #ffffff33;
  min-width: 74px;
  min-height: 68px;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 5px 0 0 #00000066;
}
.pad:active, .pad.presionado {
  background: var(--rosa-hondo);
  transform: translateY(4px);
  box-shadow: 0 1px 0 0 #00000066;
}

.pad-saltar {
  font-size: 11px;
  min-width: 132px;
  background: var(--rosa);
  color: var(--tinta);
  border-color: #ffffff55;
}
.pad-saltar:active, .pad-saltar.presionado { background: var(--dorado); }

/* solo teclado / solo tactil */
.solo-tactil  { display: none; }
body.es-tactil .solo-tactil  { display: inline; }
body.es-tactil .solo-teclado { display: none; }

/* ==========================================================================
   El final: la carta
   ========================================================================== */

#final {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  padding: 5vh 16px 8vh;
  background:
    radial-gradient(900px 600px at 50% 0%, #3a2166 0%, #150e2e 65%, #0b0620 100%);
}
#final[hidden] { display: none; }

#lluvia {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.gotita {
  position: absolute;
  top: -6vh;
  width: 12px;
  height: 12px;
  background: var(--rosa);
  clip-path: polygon(50% 100%, 0 45%, 0 20%, 25% 0, 50% 20%, 75% 0, 100% 20%, 100% 45%);
  opacity: .55;
  animation: caer linear infinite;
}
.gotita.verde { background: var(--verde); clip-path: none; border: 2px solid var(--verde-hondo); }

@keyframes caer {
  from { transform: translateY(-10vh) rotate(0deg); }
  to   { transform: translateY(112vh) rotate(220deg); }
}

#carta {
  position: relative;
  max-width: 660px;
  margin: 0 auto;
  padding: clamp(26px, 5vw, 48px);
  background: var(--marfil);
  color: #2b2118;
  box-shadow: 0 10px 0 0 var(--rosa-hondo), 0 10px 0 4px #00000055;
}

#dias-juntos {
  margin: 0 0 18px;
  font-family: var(--pixel);
  font-size: 9px;
  line-height: 1.8;
  color: var(--verde-hondo);
}

#carta-titulo {
  margin: 0 0 22px;
  font-family: var(--pixel);
  font-size: clamp(13px, 2.9vw, 18px);
  line-height: 1.75;
  color: var(--rosa-hondo);
}

/* fotos */
#fotos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 0 0 26px;
}

.polaroid {
  background: #fff;
  padding: 10px 10px 6px;
  box-shadow: 0 3px 10px #0000002e;
  max-width: 250px;
}
.polaroid:nth-child(odd)  { transform: rotate(-2deg); }
.polaroid:nth-child(even) { transform: rotate(2deg); }

.polaroid img,
.polaroid .sin-foto {
  display: block;
  width: 100%;
  max-width: 230px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #efe7d8;
}

.polaroid .sin-foto {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  color: var(--rosa);
}

.polaroid figcaption {
  font-family: var(--mano);
  font-size: 22px;
  text-align: center;
  color: #5b4a3a;
  padding-top: 6px;
}

/* texto de la carta */
#carta-texto p {
  font-family: var(--mano);
  font-size: clamp(21px, 2.9vw, 26px);
  line-height: 1.55;
  margin: 0 0 18px;
  color: #34281d;
  max-width: 42ch;
}

#carta-firma {
  font-family: var(--mano);
  font-size: clamp(23px, 3.2vw, 29px);
  color: var(--rosa-hondo);
  text-align: right;
  margin: 26px 0 0;
}

#carta-datos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 28px 0 22px;
  padding-top: 18px;
  border-top: 3px dashed #d8cbb4;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.9;
  color: #7a6a55;
}

#btn-otra-vez { display: block; margin: 0 auto; }

/* ==========================================================================
   Ajustes
   ========================================================================== */

@media (max-width: 560px) {
  body { padding: 10px; gap: 10px; }
  #marco { box-shadow: 0 5px 0 0 var(--rosa-hondo), 0 5px 0 3px var(--tinta); }
  .pad { min-width: 66px; min-height: 62px; }
  .pad-saltar { min-width: 108px; }
}

@media (prefers-reduced-motion: reduce) {
  .gotita { display: none; }
  .boton, .pad { transition: none; }
}
