:root {
  --bg: #070a12;
  --card: rgba(255, 255, 255, 0.06);
  --stroke: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);

  --accent: #ff4d8d;
  --accent2: #7c3aed;
  --good: #22c55e;
  --danger: #ef4444;

  --radius: 18px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(124, 58, 237, 0.22), transparent 55%),
    radial-gradient(1000px 700px at 90% 20%, rgba(255, 77, 141, 0.18), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}
.s1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(255, 77, 141, 0.85), transparent 60%);
  top: -180px; left: -140px;
}
.s2 {
  width: 460px; height: 460px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.85), transparent 60%);
  bottom: -200px; right: -180px;
}
.s3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.5), transparent 60%);
  top: 30%; left: 70%;
}

.top {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 0 18px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; gap: 12px; align-items: center; }

.logo {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 77, 141, 0.2), rgba(124, 58, 237, 0.18));
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

h1 { margin: 0; font-size: 18px; }
#subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.container {
  max-width: 1100px;
  margin: 18px auto 70px;
  padding: 0 18px;
}

.card {
  background: linear-gradient(180deg, var(--card), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intro {
  padding: 18px;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.intro h2 { margin: 0 0 6px; font-size: 18px; }
.intro p { margin: 0; color: var(--muted); line-height: 1.45; }

.hint {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 77, 141, 0.15);
  border: 1px solid rgba(255, 77, 141, 0.25);
  border-radius: 999px;
  padding: 6px 10px;
  width: fit-content;
}

.progress { margin-top: 14px; display: grid; gap: 8px; }
.progress-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

.bar {
  width: 100%; height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 77, 141, 0.9), rgba(124, 58, 237, 0.9));
  transition: width 280ms ease;
}

.grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.day {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  min-height: 94px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}
.day:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.2); }

.day-inner { padding: 14px; display: grid; gap: 10px; }
.day-top { display: flex; align-items: center; justify-content: space-between; }
.day-num { font-weight: 800; font-size: 18px; }
.day-tag {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  padding: 6px 10px;
}
.day-emoji { font-size: 22px; opacity: 0.95; }

.day.locked { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.35); }
.day.locked:hover { transform: none; }

.day.opened {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.14), rgba(255, 255, 255, 0.03));
}
.day.opened .day-tag {
  color: rgba(34, 197, 94, 0.9);
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.08);
}

.sparkle {
  position: absolute;
  inset: -40px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 35%),
    radial-gradient(circle at 70% 60%, rgba(255, 77, 141, 0.18), transparent 40%),
    radial-gradient(circle at 40% 80%, rgba(124, 58, 237, 0.12), transparent 45%);
  transform: rotate(12deg);
  opacity: 0.8;
  pointer-events: none;
}

.btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
  transition: transform 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.12); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.12); }

.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(680px, calc(100% - 28px));
  border-radius: 22px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.04));
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-origin: center;
  animation: popIn 380ms cubic-bezier(0.2, 0.9, 0.15, 1);
}
.modal-glow {
  position: absolute;
  inset: -120px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 77, 141, 0.18), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(124, 58, 237, 0.16), transparent 55%),
    radial-gradient(circle at 50% 90%, rgba(34, 197, 94, 0.08), transparent 50%);
  filter: blur(40px);
  opacity: 0.9;
  pointer-events: none;
}
@keyframes popIn {
  0% { transform: scale(0.92) translateY(10px); opacity: 0; }
  65% { transform: scale(1.02) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.modal-title h3 { margin: 6px 0 0; font-size: 18px; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 750;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 77, 141, 0.28);
  background: rgba(255, 77, 141, 0.14);
}

.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.15);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
}

.modal-body { padding: 14px 16px 16px; }

/* ✅ MEDIA responsive (foto/video) */
.media-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  margin-bottom: 12px;

  /* El truco para adaptarse */
  width: 100%;
  aspect-ratio: 16 / 9; /* se ajusta a cualquier tamaño */
}

.media-wrap img,
.media-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover; /* recorta bonito sin deformar */
}

.media-wrap video { background: #000; }

.media-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.12), transparent 45%),
    linear-gradient(to top, rgba(0, 0, 0, 0.32), transparent 45%);
  pointer-events: none;
}

.hidden { display: none !important; }

.modal-message {
  margin: 0;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
  animation: textSlide 420ms ease both;
}
@keyframes textSlide {
  0% { transform: translateY(6px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.modal-extra { margin-top: 14px; display: grid; gap: 8px; }
.extra-label { color: var(--muted); font-size: 12px; }
.extra-box {
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.16);
  color: rgba(255, 255, 255, 0.82);
}

.modal-foot {
  padding: 14px 16px 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* FX canvas */
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

@media (max-width: 860px) {
  .intro { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .modal-card { width: min(680px, calc(100% - 18px)); }
  .media-wrap { aspect-ratio: 4 / 5; } /* en celu queda más “story” */
}

/* =========================
   MEDIA (que se vea completo)
   ========================= */
#modalImg,
#modalVideo {
  width: 100%;
  max-height: min(62vh, 520px);
  border-radius: 14px;
  display: block;
  object-fit: contain; /* 🔥 clave: no recorta */
  background: rgba(0,0,0,0.25);
}

/* iOS: evita que el video “salte” */
#modalVideo {
  -webkit-transform: translateZ(0);
}

/* =========================
   FINAL MODAL + CARTA
   ========================= */
.final-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  z-index: 9999;
  padding: 18px;
}

.final-card {
  width: min(560px, 92vw);
  border-radius: 18px;
  background: rgba(12, 16, 32, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  overflow: hidden;
}

.final-head {
  padding: 16px 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.final-title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.final-body {
  padding: 18px;
}

.final-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.final-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.final-btn.primary {
  background: linear-gradient(135deg, rgba(255,77,141,0.9), rgba(124,58,237,0.9));
  color: white;
}

.final-btn.ghost {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

/* Carta animada */
.letter-wrap {
  perspective: 1200px;
  margin-top: 14px;
}

.envelope {
  position: relative;
  width: 100%;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
  transform-style: preserve-3d;
}

.envelope .flap {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
  clip-path: polygon(0 0, 100% 0, 50% 55%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 650ms cubic-bezier(.2,.9,.2,1);
}

.envelope .paper {
  position: relative;
  margin: 64px 16px 16px;
  padding: 16px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  color: #0b1020;
  transform: translateY(40px);
  opacity: 0;
  transition: transform 650ms cubic-bezier(.2,.9,.2,1), opacity 650ms ease;
}

.envelope.open .flap {
  transform: rotateX(160deg);
}

.envelope.open .paper {
  transform: translateY(0);
  opacity: 1;
}

.paper h3 {
  margin: 0 0 10px 0;
}

.paper p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap; /* respeta saltos de línea */
}
/* =========================
   UPGRADE: Carta más "real"
   (pegar al final del CSS)
   ========================= */

/* Animación de entrada del popup final */
.final-card {
  animation: finalPop 420ms cubic-bezier(.2,.9,.2,1) both;
}
@keyframes finalPop {
  0% { transform: translateY(12px) scale(.96); opacity: 0; }
  70% { transform: translateY(0) scale(1.02); opacity: 1; }
  100% { transform: translateY(0) scale(1); }
}

/* Envelope: mejor profundidad + borde glow sutil */
.envelope {
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  will-change: transform;
}

/* Solapa con sombra al abrir (se siente 3D) */
.envelope .flap {
  backface-visibility: hidden;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.25));
}

/* Papel: efecto papel real + sombra, y sin "saltos" */
.envelope .paper {
  box-shadow: 0 14px 34px rgba(0,0,0,0.25);
  will-change: transform, opacity;
}

/* Cuando abre: le damos un "overshoot" sutil */
.envelope.open .paper {
  animation: paperBounce 780ms cubic-bezier(.2,.9,.2,1) both;
}
@keyframes paperBounce {
  0% { transform: translateY(40px); opacity: 0; }
  70% { transform: translateY(-6px); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Accesibilidad: reduce motion */
@media (prefers-reduced-motion: reduce) {
  .final-card, .envelope .flap, .envelope .paper, .envelope.open .paper {
    animation: none !important;
    transition: none !important;
  }
}

