:root {
  --bg: #05030f;
  --ink: #f2eefc;
  --muted: #a99fc8;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}

/* Landing de escritorio: documento con scroll normal, no overlay fijo. */
html:has(body.scrollable), body.scrollable {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

body.scrollable {
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(139, 92, 246, 0.30), transparent 60%),
    radial-gradient(90% 40% at 50% 100%, rgba(34, 211, 238, 0.16), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}

canvas {
  display: block;
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
}

.hidden { display: none !important; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 32px 26px calc(32px + env(safe-area-inset-bottom));
  text-align: center;
  background:
    radial-gradient(120% 90% at 50% 12%, rgba(139, 92, 246, 0.30), transparent 60%),
    radial-gradient(90% 70% at 50% 100%, rgba(34, 211, 238, 0.16), transparent 62%),
    var(--bg);
}

.mark {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  position: relative;
  background:
    conic-gradient(from 0deg,
      #22d3ee, #8b5cf6, #ec4899, #8b5cf6, #22d3ee);
  filter: blur(0.2px);
  animation: spin 9s linear infinite;
  box-shadow: 0 0 70px rgba(139, 92, 246, 0.55);
}

.mark::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #0b0620 30%, #1a0f3d 70%, #2a1a5e 100%);
  box-shadow: inset 0 0 40px rgba(34, 211, 238, 0.35);
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .mark { animation: none; }
}

h1 {
  margin: 0;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

p, li {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  max-width: 34ch;
}

.overlay ul {
  margin: 0;
  padding-left: 20px;
  text-align: left;
  display: grid;
  gap: 10px;
}

.hint { font-size: 13.5px; color: #8d84ad; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  padding: 1px 5px;
  word-break: break-word;
}

/* ---------- botón / barra ---------- */

button {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  color: #0b0618;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: 0;
  border-radius: 999px;
  padding: 15px 34px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

button:active:not(:disabled) { transform: scale(0.97); }

button:disabled {
  opacity: 0.45;
  cursor: default;
  background: #2a2450;
  color: var(--muted);
}

.bar {
  width: min(260px, 70vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar > div {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.18s linear;
}

/* ---------- hint de escaneo ---------- */

#scan-hint {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 24px calc(38px + env(safe-area-inset-bottom));
  pointer-events: none;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.reticle {
  width: 62vw;
  max-width: 300px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed rgba(242, 238, 252, 0.5);
  position: fixed;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.85; transform: translate(-50%, -50%) scale(1.04); }
}

.pill {
  background: rgba(11, 6, 24, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14.5px;
  font-weight: 550;
  color: var(--ink);
}

/* ---------- landing de escritorio ---------- */

.landing {
  position: static;
  inset: auto;
  min-height: 100dvh;
  justify-content: flex-start;
  padding: 56px 24px 72px;
  gap: 26px;
  background: none;
}

.card {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 18px;
  justify-items: center;
  width: min(420px, 100%);
}

/* El QR se inyecta como <svg> dentro de este div, no como <img>: el selector
   debe ser de clase, no de elemento. */
.card .qr {
  width: 216px;
  height: 216px;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  box-sizing: border-box;
}

/* La librería emite <svg viewBox="0 0 29 29"> sin width/height. Sin esto el
   SVG colapsa a altura cero. */
.card .qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--accent-2);
  word-break: break-all;
  max-width: 100%;
}

.targets {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.targets figure {
  margin: 0;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.targets img {
  width: 128px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.targets figcaption {
  font-size: 11.5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.note {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  text-align: left;
  max-width: 46ch;
}

#error h1 { color: var(--danger); }

/* Degradación cuando el QR no se puede generar. */
.card .qr-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #0b0618;
  text-align: center;
  word-break: break-all;
}
