:root {
  --tinta: #2a1712;
  --crema: #fff6e3;
  --rojo: #a3172b;
  --amarillo: #ffd23f;
  /* Proporción del vídeo (ancho / alto) y sitio del cartel dentro de él. */
  --prop: 0.5643;
  --cartel-x: 14.5%;
  --cartel-y: 63.8%;
  --cartel-ancho: 69%;
  --cartel-alto: 23%;
  /* Hasta dónde tiene que verse la foto por encima del botón. */
  --cartel-fin: 0.865;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #140a07; }
body { font-family: Nunito, system-ui, sans-serif; color: var(--tinta); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.6; }
:focus-visible { outline: 3px solid var(--amarillo); outline-offset: 2px; }

/* ---------- Portada ---------- */
.escena {
  position: relative;
  overflow: hidden;
  container-type: size;
  width: min(100vw, max(100svh * 0.5643, 360px));
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  margin: 0 auto;
  background: var(--tinta);
}
.lienzo {
  --ancho: max(100cqw, 100cqh * var(--prop));
  --alto: calc(var(--ancho) / var(--prop));
  position: absolute;
  width: var(--ancho);
  height: var(--alto);
  left: calc(50cqw - var(--ancho) / 2);
  /* En pantallas bajas se sube la foto para que el botón no tape el cartel. */
  top: min(0px, calc(100cqh - 108px - var(--alto) * var(--cartel-fin)));
}
.foto { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; -webkit-mask-image: linear-gradient(#000 93%, transparent); mask-image: linear-gradient(#000 93%, transparent); }
.video { opacity: 0; pointer-events: none; }
.con-video .video { opacity: 1; }

.cartel {
  position: absolute;
  left: var(--cartel-x);
  top: var(--cartel-y);
  width: var(--cartel-ancho);
  height: var(--cartel-alto);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0 2px;
  transition: transform 0.35s ease-in, opacity 0.25s ease-in;
}
.cartel-titulo { margin: 0; font-family: Caveat, cursive; font-size: clamp(22px, 7cqw, 30px); line-height: 1; text-align: center; }
.cartel input {
  width: 100%;
  height: 46px;
  flex-shrink: 0;
  padding: 0 12px;
  border: 2px solid var(--tinta);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
}
.cerrado .cartel input { display: none; }
.cerrado .cartel-titulo { font-size: clamp(28px, 9cqw, 40px); padding: 0 12px; }
.lanzando .cartel { opacity: 0; transform: translateY(-45%) scale(0.5) rotate(-14deg); pointer-events: none; visibility: hidden; transition: transform 0.35s ease-in, opacity 0.25s ease-in, visibility 0s 0.35s; }

.titulo {
  position: absolute;
  inset: 0 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 16px 56px;
  text-align: center;
  color: #fffaf0;
  background: linear-gradient(180deg, rgba(24,10,8,0.88), rgba(24,10,8,0.55) 60%, rgba(24,10,8,0));
  transition: opacity 0.4s;
  pointer-events: none;
}
.titulo h1 { margin: 0; font-family: Caveat, cursive; font-size: clamp(44px, 15cqw, 62px); line-height: 0.95; }
.titulo p { margin: 6px 0 0; font-size: 17px; font-weight: 900; }

.abajo {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 24px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(0deg, rgba(24,10,8,0.92), rgba(24,10,8,0.6) 65%, rgba(24,10,8,0));
  transition: opacity 0.3s, transform 0.3s;
}
.mensaje { margin: 0; padding: 6px 14px; border-radius: 12px; background: var(--crema); color: var(--rojo); font-weight: 900; font-size: 15px; text-align: center; }
.mensaje:empty { display: none; }
.boton {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--amarillo);
  font-size: 19px;
  font-weight: 900;
  transition: transform 0.1s;
}
.boton:active:not(:disabled) { transform: scale(0.97); }
.cerrado .boton { display: none; }
.fecha { margin: 0; font-family: Caveat, cursive; font-size: 27px; line-height: 1; color: #fffaf0; }

.lanzando .titulo, .lanzando .abajo { opacity: 0; pointer-events: none; }
.lanzando .abajo { transform: translateY(30px); visibility: hidden; }

.ole {
  position: absolute;
  inset: calc(env(safe-area-inset-top) + 46px) 0 auto;
  margin: 0;
  font-family: Caveat, cursive;
  font-size: clamp(54px, 18cqw, 76px);
  text-align: center;
  color: #fffaf0;
  text-shadow: 0 3px 18px rgba(24,10,8,0.8);
  opacity: 0;
  transform: scale(0.4) rotate(-8deg);
  pointer-events: none;
}
.de-fiesta .ole { opacity: 1; transform: none; transition: opacity 0.3s, transform 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); animation: baile 0.8s 0.6s ease-in-out infinite alternate; }
@keyframes baile { from { rotate: -4deg; scale: 1; } to { rotate: 4deg; scale: 1.08; } }

/* ---------- Fiesta ---------- */
/* El gorro va en porcentajes de la foto; app.js lo mueve con su cabeza (--gorro-x). */
.gorro {
  position: absolute;
  left: calc(var(--gorro-x, 49.3%) - 23.5%);
  top: 15.8%;
  width: 47%;
  overflow: visible;
  filter: drop-shadow(0 5px 6px rgba(24,10,8,0.4));
  transform-origin: 50% 85%;
  opacity: 0;
  pointer-events: none;
}
.de-fiesta .gorro { opacity: 1; animation: calarse 0.75s cubic-bezier(0.3, 0.7, 0.4, 1) both; }
.pompon { transform-origin: 178px 76px; }
.de-fiesta .pompon { animation: pendulo 0.55s ease-in-out infinite alternate; }
@keyframes calarse {
  0% { opacity: 0; transform: translateY(-130%) rotate(-35deg) scale(1.15); }
  15% { opacity: 1; }
  62% { transform: translateY(5%) rotate(5deg) scale(1.04, 0.9); }
  80% { transform: translateY(-6%) rotate(-6deg) scale(0.98, 1.04); }
  100% { opacity: 1; transform: translateY(0) rotate(-3deg); }
}
@keyframes pendulo { from { transform: rotate(-9deg); } to { transform: rotate(12deg); } }
.confeti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.luces {
  position: absolute;
  inset: 0 -8px auto;
  display: flex;
  justify-content: space-between;
  height: 40px;
  pointer-events: none;
  transform: translateY(-60px);
  transition: transform 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.luces::before { content: ''; position: absolute; inset: -14px 0 auto; height: 24px; border-bottom: 2px solid #17401f; border-radius: 0 0 50% 50%; }
.luces i {
  position: relative;
  width: 13px;
  height: 18px;
  margin-top: 9px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: var(--luz, #ffd23f);
  box-shadow: 0 0 14px 4px var(--luz, #ffd23f);
  animation: parpadeo 0.9s ease-in-out infinite alternate;
}
.luces i:nth-child(odd) { margin-top: 3px; }
.luces i:nth-child(4n+2) { --luz: #ff4d5a; animation-delay: -0.3s; }
.luces i:nth-child(4n+3) { --luz: #3ddc84; animation-delay: -0.6s; }
.luces i:nth-child(4n) { --luz: #5ab9ff; animation-delay: -0.45s; }
.de-fiesta .luces { transform: translateY(env(safe-area-inset-top)); }
@keyframes parpadeo { from { opacity: 0.35; } to { opacity: 1; } }

.sonido {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 46px);
  right: 10px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(24,10,8,0.55);
  font-size: 19px;
  display: none;
}
.de-fiesta .sonido { display: block; }

/* Al salir el mensaje se sube la foto para que se vean los aplausos. */
.lienzo { transition: transform 0.6s ease; }
.fin .lienzo { transform: translateY(-4%); }

.final {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  padding: 14px 14px 4px;
  border-radius: 20px;
  background: var(--crema);
  text-align: center;
  transform: translateY(calc(100% + 40px));
  transition: transform 0.55s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.final[hidden] { display: none; }
.fin .final { transform: none; }
.final p { margin: 0 0 6px; font-size: 15px; line-height: 1.4; }
.final .final-titulo { font-size: 20px; font-weight: 900; }
.final .final-fecha { font-family: Caveat, cursive; font-size: 31px; line-height: 1; color: var(--rojo); }
.enlace { min-height: 44px; padding: 0 12px; border: 0; background: none; font-size: 14px; font-weight: 700; text-decoration: underline; }

/* Pantallas bajas: título más pequeño para no taparle la cara. */
@media (max-height: 660px) {
  .titulo { padding-top: 10px; padding-bottom: 28px; }
  .titulo h1 { font-size: 36px; }
  .titulo p { font-size: 14px; margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}

/* ---------- Organizador ---------- */
.panel-pagina { background: var(--crema); min-height: 100vh; min-height: 100dvh; }
.panel { max-width: 520px; margin: 0 auto; padding: 24px 18px 48px; display: flex; flex-direction: column; gap: 18px; }
.panel [hidden] { display: none !important; }
.panel h1 { margin: 0; font-family: Caveat, cursive; font-size: 46px; line-height: 1; }
.panel h2 { margin: 10px 0 0; font-size: 17px; font-weight: 900; }
.panel p { margin: 0; line-height: 1.45; }
.panel form, .bloque { display: flex; flex-direction: column; gap: 10px; }
.panel input[type=password], .panel input[type=email], .panel select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 2px solid var(--tinta);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
}
.panel button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--tinta); color: var(--crema); font-weight: 900; font-size: 16px; }
.panel button.suave { background: #f0dfbd; color: var(--tinta); }
.panel button.grande { min-height: 58px; border-radius: 999px; background: var(--rojo); color: #fff; font-size: 19px; }
.aviso { padding: 12px 14px; border-radius: 12px; background: var(--amarillo); font-weight: 700; }
.aviso:empty { display: none; }
.lista { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lista details { background: #fff; border-radius: 14px; }
.lista summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 16px; cursor: pointer; list-style: none; }
.lista summary::-webkit-details-marker { display: none; }
.lista .nombre { display: block; font-weight: 900; }
.lista .detalle { display: block; font-size: 14px; word-break: break-all; }
.lista .si { color: #1d6b3a; font-weight: 700; white-space: nowrap; }
.lista .no { color: var(--rojo); font-weight: 700; white-space: nowrap; }
.opciones { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 16px; }
.casilla { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; }
.casilla input { width: 22px; height: 22px; accent-color: var(--rojo); }
