:root {
  --yellow: #FED449;
  --yellow-dark: #F2C230;
  --ink: #141110;
  --muted: #5f5c59;
  --red: #E8320A;
  --circle-desktop: 180px;
  --circle-mobile: 240px;
  --font: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: radial-gradient(circle at 50% 38%, #d4d4d4 0%, #c2c2c2 62%, #b4b4b4 100%);
  background-attachment: fixed;
  min-height: 100dvh;
}

.page {
  max-width: 90%;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(18px, 4vw, 48px) clamp(28px, 4vw, 48px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  margin-bottom: clamp(6px, 2vw, 22px);
}
.logo {
  position: absolute;
  left: clamp(4px, 1.5vw, 16px);
  top: 50%;
  transform: translateY(-50%);
  height: 66px;
  width: auto;
}
.stars { display: flex; gap: 14px; }
.stars svg { width: 48px; height: 48px; fill: var(--yellow); }

/* ---------- Hero ---------- */
.hero { text-align: center; }
.title {
  font-size: clamp(26px, 4.4vw, 44px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 6px 0 16px;
}
.lead {
  font-size: clamp(14px, 1.5vw, 17px);
  line-height: 1.55;
  color: #2c2a28;
  margin: 0 auto 10px;
  max-width: 60ch;
}
.lead strong { font-weight: 700; }
.lead-strong {
  font-weight: 700;
  font-size: clamp(15px, 1.6vw, 18px);
  margin: 0 0 clamp(18px, 3vw, 30px);
}

/* ---------- Flujo de 3 círculos (escritorio: fila) ---------- */
.flow {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(24px, 5vw, 70px);
  flex: 0 0 auto;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--circle-desktop);
}
.step-label {
  font-size: 13.5px;
  font-weight: 500;
  color: #2c2a28;
  text-align: center;
  min-height: 40px;
  margin: 0 0 14px;
  line-height: 1.3;
}
.step-label b { font-weight: 700; }
.step-label strong { font-weight: 700; }

.circle {
  position: relative;
  width: var(--circle-desktop);
  height: var(--circle-desktop);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 14px 22px -14px rgba(0, 0, 0, .40);
  background: transparent;
}
/* Círculo 1: subida, fondo blanco */
#circle1 { background: #ffffff; overflow: hidden; }
.upload-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--ink);
  text-align: center;
  padding: 12px;
}
.upload-inner .cloud { width: 40px; height: 40px; color: var(--ink); margin-bottom: 4px; }
.u-title { font-weight: 700; font-size: 14px; }
.u-sub { font-size: 12px; color: var(--muted); }

.placeholder,
.uploaded-thumb,
#resultCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.circle-insignia {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 6;
  border-radius: 50%;
}
#circle2 .croppie-container,
#cropArea { width: 100% !important; height: 100% !important; }

/* Barra de zoom bajo el círculo 2 */
.zoombar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
}
.z-ico { font-size: 20px; font-weight: 700; color: var(--muted); width: 14px; text-align: center; }
#zoomSlider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: rgba(0,0,0,.18);
  outline: none;
}
#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--yellow); border: 3px solid #fff; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
#zoomSlider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--yellow); border: 3px solid #fff; cursor: pointer;
}

/* ---------- Paso 4 + botón ---------- */
.step4 {
  text-align: center;
  font-weight: 700;
  font-size: clamp(16px, 2vw, 20px);
  margin: clamp(20px, 3vw, 32px) 0 clamp(14px, 2vw, 20px);
}
.step4 b { font-weight: 700; }

.actions { display: flex; justify-content: center; }
.btn-yellow {
  background: var(--yellow);
  color: var(--ink);
  border: none;
  border-radius: 0;
  font-family: var(--font);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 11px 24px;
  cursor: pointer;
  transition: background .15s, transform .06s;
}
.btn-yellow:hover { background: var(--yellow-dark); }
.btn-yellow:active { transform: translateY(1px); }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  text-decoration: underline;
}
.link-btn:hover { color: var(--ink); }

/* Barra de controles (Volver + Continuar/Descargar) */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: clamp(16px, 3dvh, 28px);
}
.nav-back {
  border: none;
  background: #fff;
  color: var(--ink);
  border-radius: 0;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s;
}
.nav-back svg { width: 24px; height: 24px; }
.nav-back:hover { background: #efefef; }

/* Croppie */
.croppie-container { padding: 0; }
.croppie-container .cr-boundary { border-radius: 50%; width: 100% !important; height: 100% !important; }
.croppie-container .cr-slider-wrap { display: none !important; }
.croppie-container .cr-viewport { box-shadow: 0 0 0 2px rgba(255,255,255,.65); }

/* ---------- Modal cámara ---------- */
.cam-open { margin-top: 14px; }
.cam-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 16, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.cam-inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.cam-stage {
  width: min(82vw, 56dvh);
  height: min(82vw, 56dvh);
  max-width: 380px;
  max-height: 380px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
}
#camVideo { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-btns { display: flex; align-items: center; gap: 24px; }
.cam-btns .link-btn { color: #fff; margin-top: 0; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 16, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px 26px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0,0,0,.3);
}
.modal-box p { margin: 0 0 20px; font-size: 16px; line-height: 1.5; }

/* ================= MÓVIL: vertical, paso a paso ================= */
@media (max-width: 820px) {
  .topbar { min-height: 70px; margin-bottom: 6px; }
  .logo { height: 52px; }
  .stars svg { width: 40px; height: 40px; }

  /* La página ocupa toda la altura y reparte el espacio */
  .page { min-height: 100dvh; }
  .hero { margin-bottom: clamp(8px, 2.5dvh, 26px); }
  .title { font-size: clamp(24px, 7.5vw, 36px); margin: 4px 0 clamp(10px, 2dvh, 18px); }
  .lead { font-size: clamp(14.5px, 4vw, 17px); line-height: 1.6; margin-bottom: clamp(8px, 1.6dvh, 14px); }
  .lead-strong { font-size: clamp(15px, 4.4vw, 19px); margin-bottom: 0; }

  .flow.is-mobile {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: clamp(10px, 3dvh, 34px) 0;
  }
  .flow.is-mobile .step { display: none; width: 100%; max-width: 360px; }
  .flow.is-mobile[data-step="1"] .step[data-step="1"],
  .flow.is-mobile[data-step="2"] .step[data-step="2"],
  .flow.is-mobile[data-step="3"] .step[data-step="3"] { display: flex; }

  .step { width: 100%; max-width: 360px; }
  .step-label { min-height: 0; font-size: clamp(15px, 4.4vw, 18px); margin-bottom: clamp(14px, 2.5dvh, 26px); }

  /* Círculo grande, relativo al ancho y a la altura disponibles */
  .circle {
    width: min(82vw, 42dvh);
    height: min(82vw, 42dvh);
  }

  .zoombar { margin-top: clamp(16px, 3dvh, 30px); }

  .controls-bar {
    width: 100%;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
    min-height: 30px;
  }
  body.m .controls-bar .btn-yellow { flex: 1 1 auto; }
  .nav-back { width: 56px; height: auto; }

  /* En móvil el "paso 4" solo aparece en el paso 3 */
  .flow.is-mobile:not([data-step="3"]) ~ .step4 { display: none; }

  /* Paso 1 lleva todo el copy: círculo más contenido para que quepa todo */
  body.m[data-step="1"] .circle { width: min(64vw, 31dvh); height: min(64vw, 31dvh); }

  /* Pasos 2 y 3: ocultar el copy largo (ya se vio en el paso 1) y dejar
     protagonismo a la etiqueta + el círculo grande */
  body.m[data-step="2"] .lead,
  body.m[data-step="2"] .lead-strong,
  body.m[data-step="3"] .lead,
  body.m[data-step="3"] .lead-strong { display: none; }
  body.m[data-step="2"] .title,
  body.m[data-step="3"] .title { font-size: clamp(19px, 5.6vw, 26px); margin-bottom: 0; }
}

/* Pantallas bajas: compactar aún más */
@media (max-width: 820px) and (max-height: 720px) {
  .topbar { min-height: 56px; }
  .logo { height: 44px; }
  .stars svg { width: 34px; height: 34px; }
  .circle { width: min(76vw, 38dvh); height: min(76vw, 38dvh); }
  body.m[data-step="1"] .circle { width: min(58vw, 27dvh); height: min(58vw, 27dvh); }
  .lead { line-height: 1.5; }
  .step-label { margin-bottom: clamp(10px, 2dvh, 18px); }
}

/* ---------- Transición entre pasos (móvil) ---------- */
@keyframes stepInRight {
  from { opacity: 0; transform: translateX(30px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes stepInLeft {
  from { opacity: 0; transform: translateX(-30px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 820px) {
  .flow.is-mobile[data-dir="fwd"]  .step { animation: stepInRight .36s cubic-bezier(.22,.61,.36,1) both; }
  .flow.is-mobile[data-dir="back"] .step { animation: stepInLeft  .36s cubic-bezier(.22,.61,.36,1) both; }
}
@media (prefers-reduced-motion: reduce) {
  .flow.is-mobile .step { animation: none !important; }
}
