:root {
  --cream: #FBF6F0;
  --ink: #2A1F1D;
  --ink-soft: #6E5D58;
  --wine: #7B3256;
  --line: rgba(42, 31, 29, 0.12);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Hueco inferior para que el banner "Powered by Netlify" no tape nada:
     el banner ocupa ~7% del alto de la pantalla, se reserva un 8% */
  --banner-space: 8dvh;
}

/* Colores de cada bloque */
[data-block="1"] { --bg: #F7E8DB; --tint: #EFD2BB; --accent: #C0653F; }
[data-block="2"] { --bg: #F6E1E2; --tint: #EDC6C9; --accent: #AE4658; }
[data-block="3"] { --bg: #EEE1EA; --tint: #DCC3D3; --accent: #7B3256; }
[data-block="extra"] { --bg: #E8ECE2; --tint: #CFDBC7; --accent: #5C7757; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

.screen {
  position: fixed;
  inset: 0;
  height: 100dvh;
}
.screen[hidden] { display: none; }

/* ---------- Intro ---------- */
#intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--cream);
  padding: 32px;
  transition: opacity .5s ease, visibility .5s;
}
#intro.done { opacity: 0; visibility: hidden; }

.intro-text {
  font-family: var(--serif);
  font-weight: 350;
  font-size: clamp(30px, 9vw, 46px);
  line-height: 1.18;
  text-align: center;
  letter-spacing: -0.01em;
}
.intro-text .line {
  display: block;
  opacity: 0;
  transform: translateY(14px);
  filter: blur(4px);
  animation: lineIn .8s cubic-bezier(.2, .7, .2, 1) forwards;
}
.intro-text .line:nth-child(1) { animation-delay: .2s; }
.intro-text .line:nth-child(2) { animation-delay: .95s; font-style: italic; color: var(--wine); }
.intro-text .line:nth-child(3) { animation-delay: 1.7s; }

@keyframes lineIn {
  to { opacity: 1; transform: none; filter: none; }
}

/* ---------- Menú ---------- */
/* Arriba: ilustración y título centrados en el espacio libre.
   Abajo: botones e Instagram agrupados, justo por encima del banner. */
#menu {
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 28px) 28px calc(var(--safe-bottom) + 24px + var(--banner-space));
  background:
    radial-gradient(120% 60% at 50% 0%, #F6E1E2 0%, rgba(246, 225, 226, 0) 70%),
    var(--cream);
}
.menu-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* el espacio sobrante queda arriba, alrededor de la ilustración */
  align-items: center;
  text-align: center;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 24px;
}
.menu-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}
.menu-art {
  --tint: #F1D3D6;
  --accent: var(--wine);
  width: min(44vw, 170px);
  color: var(--accent);
  margin-bottom: 18px;
}
.menu-title {
  font-family: var(--serif);
  font-weight: 380;
  font-size: clamp(28px, 8.4vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.menu-title em {
  font-style: italic;
  color: var(--wine);
}
.menu-sub {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink-soft);
}
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 500;
  transition: transform .15s ease, background-color .2s ease;
}
.btn:active { transform: scale(.97); }
.btn svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn-primary { background: var(--wine); color: #fff; }
.btn-secondary { background: transparent; color: var(--wine); box-shadow: inset 0 0 0 1.5px var(--wine); }
.btn-tertiary {
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 8px;
  font-size: 15px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.btn-tertiary svg { width: 18px; height: 18px; }
.btn-center { justify-content: center; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #5C7757;
  background: #E1E9DB;
}
.badge[hidden] { display: none; }

.insta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: center;
  padding: 12px 18px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
  background: rgba(255, 255, 255, .6);
  box-shadow: inset 0 0 0 1px var(--line);
}
.insta strong { color: var(--ink); font-weight: 600; }
.insta span { white-space: nowrap; }
@media (max-width: 380px) {
  .insta { font-size: 13px; padding: 12px 14px; gap: 8px; }
}
.insta svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
}
.insta:active { transform: scale(.97); }

/* Entrada suave del menú tras la intro */
#menu .menu-inner > *, #menu .menu-bottom > * {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .6s ease, transform .6s ease;
}
#menu.ready .menu-inner > *, #menu.ready .menu-bottom > * { opacity: 1; transform: none; }
#menu.ready .menu-inner > :nth-child(2) { transition-delay: .06s; }
#menu.ready .menu-inner > :nth-child(3) { transition-delay: .12s; }
#menu.ready .menu-actions { transition-delay: .18s; }
#menu.ready .insta { transition-delay: .26s; }

/* ---------- Mazo ---------- */
#deck { background: var(--cream); }

.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.viewport.dragging { cursor: grabbing; }
.track {
  display: flex;
  height: 100%;
  will-change: transform;
}
.track.animate { transition: transform .42s cubic-bezier(.22, .8, .24, 1); }

.card {
  flex: 0 0 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  padding: calc(var(--safe-top) + 76px) 28px calc(var(--safe-bottom) + 96px + var(--banner-space));
  display: flex;
}
.card-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}
.card-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.num small {
  display: block;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.num span {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(56px, 17vw, 76px);
  line-height: .9;
  color: var(--accent);
  letter-spacing: -0.03em;
}
.chip {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 7px 12px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.2px var(--accent);
  margin-bottom: 6px;
}
/* El icono ocupa el tercio superior y la pregunta queda hacia el centro;
   el espacio sobrante va debajo de la pregunta (margin-bottom: auto en .q) */
.art {
  flex: 0 1 30dvh;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0 18px;
  color: var(--accent);
}
.art svg {
  height: 100%;
  max-height: 230px;
  width: auto;
  max-width: 72%;
}
.blob { fill: var(--tint); stroke: none; }
.fill { fill: var(--tint); }
.card .fill { fill: var(--accent); fill-opacity: .22; }

.q {
  font-family: var(--serif);
  font-weight: 380;
  font-size: clamp(22px, 6.6vw, 28px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: pretty;
  margin-bottom: auto;
}
.q.mid  { font-size: clamp(20px, 5.8vw, 25px); }
.q.long { font-size: clamp(18px, 5.1vw, 22px); line-height: 1.34; }

.menu-art .fill { fill: var(--accent); fill-opacity: .2; }

.deck-header {
  position: absolute;
  z-index: 2;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 16px) 20px 0;
  pointer-events: none;
}
.deck-header > * { pointer-events: auto; }
.back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  background: rgba(255, 255, 255, .65);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--line);
}
.back:active { transform: scale(.97); }
.back svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.counter {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.deck-footer {
  position: absolute;
  z-index: 2;
  left: 0; right: 0; bottom: 0;
  padding: 0 28px calc(var(--safe-bottom) + 22px + var(--banner-space));
  pointer-events: none;
}
.progress {
  height: 3px;
  max-width: 460px;
  margin: 0 auto 16px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  opacity: .55;
  border-radius: 3px;
  transition: width .4s ease;
}
.hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--ink-soft);
}
.hint svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  animation: nudge 1.8s ease-in-out infinite;
}
.hint svg:first-child { animation-name: nudgeLeft; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateX(3px); } }
@keyframes nudgeLeft { 0%, 100% { transform: none; } 50% { transform: translateX(-3px); } }

/* ---------- Preguntas propias ---------- */
#custom {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--cream);
}
.custom-header {
  padding: calc(var(--safe-top) + 16px) 20px 0;
}
.custom-header .back { display: inline-flex; }
.custom-inner {
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 24px calc(var(--safe-bottom) + 32px + var(--banner-space));
  text-align: center;
}
.custom-art {
  width: 110px;
  margin: 4px auto 10px;
  color: var(--accent);
}
.custom-art .fill { fill: var(--accent); fill-opacity: .2; }
.custom-title {
  font-family: var(--serif);
  font-weight: 380;
  font-size: clamp(26px, 7.6vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.custom-sub {
  margin: 10px 0 24px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.fields {
  display: grid;
  gap: 12px;
  text-align: left;
}
.field {
  position: relative;
  padding: 14px 16px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .7);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .2s ease;
}
.field:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.field textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: 72px;
  overflow: hidden;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px; /* 16px o más evita el zoom automático de iOS */
  line-height: 1.35;
  -webkit-user-select: text;
  user-select: text;
}
.field textarea::placeholder { color: var(--ink-soft); opacity: .55; }
.field-clear {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
}
.field-clear svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}
.field:not(.has-text) .field-clear { display: none; }
.custom-note {
  margin: 16px 0 18px;
  font-size: 13px;
  color: var(--ink-soft);
}
.custom-actions { display: flex; gap: 10px; }
.custom-actions .btn { flex: 1; padding: 0 12px; }
#customBack { gap: 8px; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
#customBack svg { width: 20px; height: 20px; }
#customSave { background: var(--accent); }

/* Pantallas muy bajas (móviles pequeños en horizontal o iPhone SE) */
@media (max-height: 640px) {
  .card { padding-top: calc(var(--safe-top) + 68px); padding-bottom: calc(var(--safe-bottom) + 84px + var(--banner-space)); }
  .num span { font-size: 48px; }
  .art svg { max-height: 150px; }
  .menu-art { width: 120px; margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .intro-text .line { animation-duration: .01s; filter: none; }
  .track.animate { transition-duration: .01s; }
  .hint svg { animation: none; }
}
