@font-face { font-family: "Jost"; src: url(Jost.ttf) format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  --coral: #E75365; --magenta: #9D3166; --amarillo: #FFC60B; --naranja: #EE7402;
  --marfil: #FAF7F3; --gris: #555759; --tinta: #2B2B2B;
  --cruz: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%23ffffff' fill-opacity='0.08'%3E%3Crect x='51' y='22' width='18' height='76' rx='9'/%3E%3Crect x='22' y='51' width='76' height='18' rx='9'/%3E%3C/g%3E%3C/svg%3E");
  --suave: cubic-bezier(.22, .8, .25, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: "Jost", system-ui, sans-serif; color: var(--tinta); background: var(--magenta); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input { font: inherit; }
a { color: inherit; }
.oculto-visual { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ───────── Muro ───────── */
.muro { position: fixed; inset: 0; display: flex; gap: var(--hueco); justify-content: center; padding: 0 var(--hueco); overflow: hidden;
  --ancho: 168px; --hueco: 16px; background: var(--magenta) var(--cruz); background-size: 150px; }
@media (max-width: 700px) { .muro { --ancho: calc((100vw - 4 * 10px) / 3); --hueco: 10px; } }
.columna { flex: 0 0 var(--ancho); position: relative; }
.pista { display: flex; flex-direction: column; gap: var(--hueco); padding-top: var(--hueco); will-change: transform;
  animation: sube var(--dur, 90s) linear infinite; }
.columna:nth-child(even) .pista { animation-name: baja; }
.muro.quieto .pista { animation-play-state: paused; }
@keyframes sube { from { transform: translateY(0); } to { transform: translateY(-50%); } }
@keyframes baja { from { transform: translateY(-50%); } to { transform: translateY(0); } }

.mini { --c: var(--coral); width: var(--ancho); aspect-ratio: 9 / 16; border-radius: calc(var(--ancho) * .08);
  background: var(--c) var(--cruz); background-size: calc(var(--ancho) * .14); padding: 18% 7% 0; color: #fff;
  box-shadow: 0 6px 18px rgba(40, 0, 20, .18); position: relative; flex: 0 0 auto; }
.mini.coral { --c: var(--coral); } .mini.magenta { --c: var(--magenta); } .mini.naranja { --c: var(--naranja); }
.mini.amarillo { --c: var(--amarillo); color: #7A2550; }
.mini .blanco { background: #fff; border-radius: calc(var(--ancho) * .05); height: 62%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 6%; gap: 4%; }
.mini .g { color: var(--magenta); font-weight: 700; font-size: calc(var(--ancho) * .13); line-height: 1; }
.mini .n { color: var(--magenta); font-weight: 700; font-size: calc(var(--ancho) * var(--t, .15)); line-height: 1.05; overflow-wrap: break-word; hyphens: manual;
  background: linear-gradient(transparent 58%, var(--marca, rgba(231,83,101,.28)) 58%, var(--marca, rgba(231,83,101,.28)) 92%, transparent 92%); padding: 0 3%; }
.mini.magenta .n { --marca: rgba(157,49,102,.22); } .mini.amarillo .n { --marca: rgba(255,198,11,.55); } .mini.naranja .n { --marca: rgba(238,116,2,.28); }
.mini .p { color: var(--coral); font-weight: 600; font-size: calc(var(--ancho) * .075); line-height: 1.1; }
.mini .h { position: absolute; left: 0; right: 0; bottom: 7%; text-align: center; font-size: calc(var(--ancho) * .062); font-weight: 500; opacity: .9; }

/* Entrada en cascada */
.muro.entrando .mini { animation: entra .9s var(--suave) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes entra { from { opacity: 0; transform: translateY(60px) scale(.85) rotate(var(--giro, 0deg)); } }

/* La tarjeta nueva */
.mini.nueva { animation: brilla 2.4s ease-out 1; z-index: 2; }
@keyframes brilla { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.95), 0 6px 18px rgba(40,0,20,.18); }
  40% { box-shadow: 0 0 0 10px rgba(255,255,255,.55), 0 10px 30px rgba(40,0,20,.3); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0), 0 6px 18px rgba(40,0,20,.18); } }
.mini.abriendo { transition: height .6s var(--suave), margin .6s var(--suave), opacity .3s; }
.volando { position: fixed; z-index: 60; margin: 0; pointer-events: none; transform-origin: 0 0;
  transition: transform 1s cubic-bezier(.5, -0.1, .2, 1.25); box-shadow: 0 20px 50px rgba(40,0,20,.35); }

/* ───────── Velo y portada ───────── */
.velo { position: fixed; inset: 0; pointer-events: none; transition: background .6s;
  background: radial-gradient(ellipse at center, rgba(70, 12, 40, .78) 0%, rgba(70, 12, 40, .55) 45%, rgba(70, 12, 40, .25) 100%); }
body.editando .velo { background: rgba(50, 8, 28, .72); }
body.celebrando .velo { background: rgba(50, 8, 28, .12); }

.portada { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  color: #fff; padding: 24px; gap: 18px; transition: opacity .5s, transform .5s var(--suave); }
.portada > * { opacity: 0; transform: translateY(16px); animation: aparece .9s var(--suave) forwards; }
.portada > :nth-child(1) { animation-delay: 1.1s; } .portada > :nth-child(2) { animation-delay: 1.3s; }
.portada > :nth-child(3) { animation-delay: 1.5s; } .portada > :nth-child(4) { animation-delay: 1.7s; } .portada > :nth-child(5) { animation-delay: 1.9s; }
@keyframes aparece { to { opacity: 1; transform: none; } }
body.editando .portada, body.celebrando .portada { opacity: 0; transform: scale(.96); pointer-events: none; }
.portada .logo { width: 180px; filter: brightness(0) invert(1); }
.portada .fecha { font-size: 14px; letter-spacing: .28em; text-transform: uppercase; font-weight: 500; opacity: .9; }
.portada h1 { font-size: clamp(40px, 8vw, 86px); line-height: 1; font-weight: 700; text-transform: uppercase; letter-spacing: -.01em; max-width: 12ch; text-shadow: 0 4px 30px rgba(0,0,0,.25); }
.portada p.sub { font-size: clamp(18px, 2.4vw, 24px); font-style: italic; max-width: 32ch; }
.acciones { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.boton { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; cursor: pointer; border-radius: 999px;
  background: #fff; color: var(--magenta); font-weight: 600; font-size: 20px; padding: 16px 34px; text-decoration: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); transition: transform .2s, box-shadow .2s, opacity .2s; }
.boton:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0,0,0,.25); }
.boton:active { transform: translateY(1px); }
.boton.coral { background: var(--coral); color: #fff; }
.boton[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.enlace { color: #fff; font-size: 16px; text-underline-offset: 4px; opacity: .92; }
.enlace:hover { opacity: 1; }
:focus-visible { outline: 3px solid var(--amarillo); outline-offset: 3px; }

/* ───────── Editor ───────── */
.editor { position: fixed; z-index: 40; inset: auto 0 0 0; max-height: 100dvh; overflow: auto; background: var(--marfil); border-radius: 26px 26px 0 0;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .55s var(--suave);
  box-shadow: 0 -20px 60px rgba(0,0,0,.25); }
body.editando .editor { transform: none; }
.editor .tirador { width: 44px; height: 5px; border-radius: 3px; background: #d9ccd3; margin: -8px auto 14px; }
.editor .cerrar { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; color: var(--magenta);
  font-size: 24px; line-height: 1; cursor: pointer; }
.editor h2 { color: var(--magenta); font-size: 26px; line-height: 1.1; margin-bottom: 4px; padding-right: 44px; }
.editor .ayuda { color: var(--gris); font-size: 16px; margin-bottom: 16px; }
.rejilla-editor { display: grid; grid-template-columns: 1fr; gap: 18px; }
.vista { display: flex; justify-content: center; }
.vista canvas { width: auto; height: min(46vh, 420px); max-width: 100%; border-radius: 14px; box-shadow: 0 12px 30px rgba(60,10,35,.2); background: #eee; }
.vista.post canvas { height: min(36vh, 320px); }
.campo label { display: block; font-weight: 600; color: var(--magenta); margin-bottom: 6px; }
.campo input[type=text] { width: 100%; font-size: 22px; padding: 12px 16px; border-radius: 14px; border: 2px solid #e3d6dd; background: #fff; color: var(--magenta); font-weight: 600; }
.campo input[type=text]:focus { border-color: var(--coral); outline: none; }
.campo .mensaje { min-height: 22px; font-size: 15px; margin-top: 6px; color: var(--gris); }
.campo .mensaje.error { color: #b3261e; }
.colores { display: flex; gap: 12px; }
.colores button { width: 46px; height: 46px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #e3d6dd; cursor: pointer; }
.colores button[aria-pressed=true] { box-shadow: 0 0 0 3px var(--magenta); transform: scale(1.06); }
.formatos { display: inline-flex; background: #fff; border-radius: 999px; padding: 4px; border: 1px solid #e3d6dd; }
.formatos button { border: 0; background: none; padding: 8px 16px; border-radius: 999px; color: var(--magenta); cursor: pointer; font-weight: 500; }
.formatos button[aria-pressed=true] { background: var(--magenta); color: #fff; }
.fila { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.editor .botones { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.editor .boton { width: 100%; }
.editor .secundario { background: none; border: 0; color: var(--magenta); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; font-size: 16px; padding: 6px; }
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (min-width: 860px) {
  .editor { inset: 50% auto auto 50%; width: min(880px, 92vw); border-radius: 26px; transform: translate(-50%, -40%) scale(.96); opacity: 0; pointer-events: none;
    transition: transform .5s var(--suave), opacity .35s; }
  body.editando .editor { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
  .editor .tirador { display: none; }
  .rejilla-editor { grid-template-columns: auto 1fr; align-items: center; gap: 30px; }
  .vista canvas { height: min(62vh, 520px); }
  .vista.post canvas { height: min(40vh, 340px); }
}

/* ───────── Aviso y celebración ───────── */
.aviso { position: fixed; z-index: 70; left: 50%; top: calc(20px + env(safe-area-inset-top)); transform: translate(-50%, calc(-100% - 80px)); visibility: hidden; background: #fff; color: var(--magenta);
  border-radius: 18px; padding: 14px 20px; font-weight: 500; box-shadow: 0 14px 40px rgba(0,0,0,.25); max-width: min(92vw, 520px); text-align: center;
  transition: transform .45s var(--suave), visibility 0s .45s; }
.aviso.visible { transform: translate(-50%, 0); visibility: visible; transition: transform .45s var(--suave); }
.aviso a { color: var(--coral); font-weight: 600; }
.despues { position: fixed; z-index: 30; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 12px;
  opacity: 0; pointer-events: none; transition: opacity .5s .4s; }
body.celebrando .despues.activo { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  .pista { animation: none !important; }
  .muro.entrando .mini, .portada > * { animation-duration: .01s !important; animation-delay: 0s !important; }
  .volando { transition-duration: .01s !important; }
}

@media (max-width: 700px) {
  .velo { background: radial-gradient(ellipse at center, rgba(70, 12, 40, .86) 0%, rgba(70, 12, 40, .72) 55%, rgba(70, 12, 40, .45) 100%); }
  .portada .fecha { font-size: 12px; letter-spacing: .16em; }
  .portada .logo { width: 150px; }
  .editor h2 { font-size: 22px; }
  .editor .ayuda { font-size: 15px; margin-bottom: 12px; }
  .vista canvas { height: min(38vh, 340px); }
  .vista.post canvas { height: min(30vh, 260px); }
  .colores button { width: 40px; height: 40px; }
  .formatos button { padding: 7px 12px; }
}
@media (max-width: 859px) {
  .rejilla-editor .controles { display: contents !important; }
  .rejilla-editor .campo { order: 0; }
  .rejilla-editor .vista { order: 1; }
  .rejilla-editor .fila { order: 2; }
  .rejilla-editor .botones { order: 3; }
  .vista canvas { height: min(34vh, 300px); }
  .editor .ayuda { display: none; }
}
