:root {
  --fondo: #04060c;
  --panel: rgba(12, 22, 48, .55);
  --borde: rgba(64, 140, 255, .28);
  --texto: #e8f1ff;
  --suave: #9db4d8;
  --neon: #2f8cff;
  --cian: #5ff3ff;
  --azul: #1f4dff;
  color-scheme: dark;
}

@font-face { font-family: "Unbounded"; font-weight: 800; font-display: swap; src: url("fuentes/unbounded-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 400; font-display: swap; src: url("fuentes/outfit-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 600; font-display: swap; src: url("fuentes/outfit-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 700; font-display: swap; src: url("fuentes/outfit-latin-700-normal.woff2") format("woff2"); }

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

body {
  min-height: 100vh;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.5 "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sprite { display: none; }

.tarjeta {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  padding: 0 20px calc(28px + env(safe-area-inset-bottom));
  isolation: isolate;
}

/* Lobo de fondo que se funde en negro */
.tarjeta::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 620px;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(4, 6, 12, .3) 0%, rgba(4, 6, 12, .6) 55%, var(--fondo) 100%),
    url("fondo.webp") center top / cover no-repeat;
}

.portada {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 26px;
}

/* Logotipo JR en 3D (renderizado en preparar_imagenes.py) */
[hidden] { display: none !important; }

.logo-caja { margin-bottom: 10px; perspective: 600px; touch-action: pan-y; }

.logo {
  display: block;
  width: 132px;
  height: auto;
  animation: flotar 6s ease-in-out infinite;
  transition: transform .25s ease-out, filter .25s ease-out;
  will-change: transform;
}

/* Mientras el dedo, el ratón o el giro del teléfono lo mueven (app.js) */
.logo.inclinado {
  animation: none;
  transform: rotateX(var(--giro-x, 0deg)) rotateY(var(--giro-y, 0deg)) scale(1.06);
  filter: drop-shadow(0 0 14px rgba(95, 243, 255, .55));
}

@keyframes flotar {
  0%, 100% { transform: rotateY(-8deg) translateY(0); }
  50% { transform: rotateY(8deg) translateY(-6px); }
}

.foto {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--cian);
  box-shadow:
    0 0 0 6px rgba(4, 6, 12, .85),
    0 0 0 8px rgba(47, 140, 255, .6),
    0 0 28px 8px rgba(47, 140, 255, .55);
  animation: entrar .7s cubic-bezier(.2, .7, .2, 1) .1s backwards, respirar 4s ease-in-out 1s infinite;
}

@keyframes respirar {
  0%, 100% { box-shadow: 0 0 0 6px rgba(4, 6, 12, .85), 0 0 0 8px rgba(47, 140, 255, .6), 0 0 24px 6px rgba(47, 140, 255, .45); }
  50% { box-shadow: 0 0 0 6px rgba(4, 6, 12, .85), 0 0 0 8px rgba(95, 243, 255, .8), 0 0 40px 12px rgba(47, 140, 255, .75); }
}

/* Entrada escalonada de los bloques */
@keyframes entrar {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.logo-caja, h1, .lema, .roles, .acciones > *, section, footer {
  animation: entrar .6s cubic-bezier(.2, .7, .2, 1) backwards;
}
.logo-caja { animation-delay: 0s; }
h1 { animation-delay: .2s; }
.lema { animation-delay: .28s; }
.roles { animation-delay: .36s; }
.acciones > :nth-child(1) { animation-delay: .44s; }
.acciones > :nth-child(2) { animation-delay: .5s; }
.acciones > :nth-child(3) { animation-delay: .56s; }
section:nth-of-type(1) { animation-delay: .64s; }
section:nth-of-type(2) { animation-delay: .72s; }
section:nth-of-type(3) { animation-delay: .8s; }
footer { animation-delay: .88s; }

h1 {
  margin-top: 20px;
  font-family: "Unbounded", "Outfit", system-ui, sans-serif;
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.1;
  color: #f4fbff;
  text-shadow: 0 0 8px rgba(95, 243, 255, .7), 0 0 24px rgba(47, 140, 255, .8);
}

.lema {
  margin-top: 10px;
  max-width: 330px;
  color: var(--texto);
  font-weight: 600;
  font-size: 1rem;
}

.roles {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.roles li {
  padding: 4px 12px;
  border: 1px solid var(--borde);
  border-radius: 999px;
  background: rgba(10, 24, 60, .6);
  color: var(--cian);
  font-size: .82rem;
  font-weight: 600;
}

svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }

a:focus-visible, button:focus-visible { outline: 2px solid var(--cian); outline-offset: 3px; }

button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.acciones { display: grid; gap: 12px; margin-top: 28px; }

.dos { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }

.boton.secundario {
  min-height: 48px;
  font-size: .95rem;
  border-color: var(--borde);
  box-shadow: none;
  background: var(--panel);
  color: var(--cian);
}

.boton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  border-radius: 14px;
  border: 1.5px solid var(--neon);
  background: rgba(8, 20, 52, .7);
  color: #f4fbff;
  font-weight: 700;
  font-size: 1.02rem;
  box-shadow: 0 0 14px rgba(47, 140, 255, .35), inset 0 0 12px rgba(47, 140, 255, .18);
  transition: transform .15s ease, box-shadow .15s ease;
}

.boton.principal {
  border-color: transparent;
  background: linear-gradient(135deg, var(--cian), var(--neon) 55%, var(--azul));
  color: #021024;
  box-shadow: 0 0 22px rgba(47, 140, 255, .65);
}

.boton:active, .red:active, .fila:active { transform: scale(.98); }

section { margin-top: 30px; }

h2 {
  margin-bottom: 12px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--suave);
}

.rejilla { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.red {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 4px 12px;
  border: 1px solid var(--borde);
  border-radius: 14px;
  background: var(--panel);
  font-size: .74rem;
  color: var(--suave);
  transition: transform .15s ease, border-color .15s ease;
}

.red svg { width: 26px; height: 26px; color: var(--cian); filter: drop-shadow(0 0 6px rgba(95, 243, 255, .6)); }

.lista { display: grid; gap: 10px; }

.fila {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--borde);
  border-radius: 14px;
  background: var(--panel);
  font-weight: 600;
}

.fila svg { color: var(--cian); filter: drop-shadow(0 0 6px rgba(95, 243, 255, .5)); }

.fila span { display: flex; flex-direction: column; flex: 1; }

.fila small { color: var(--suave); font-weight: 400; font-size: .8rem; }

.fila.apagada { opacity: .65; }

.fila em {
  font-style: normal;
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--borde);
  color: var(--cian);
}

@media (hover: hover) {
  .boton:hover { box-shadow: 0 0 26px rgba(47, 140, 255, .7); }
  .red:hover, a.fila:hover { border-color: var(--neon); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

footer {
  margin-top: 36px;
  text-align: center;
  font-size: .75rem;
  color: #5d7090;
}

/* Ventana del QR */
.ventana-qr {
  margin: auto;
  width: min(340px, calc(100vw - 32px));
  padding: 28px 24px 24px;
  border: 1.5px solid var(--neon);
  border-radius: 22px;
  background: #070d1d;
  color: var(--texto);
  text-align: center;
  box-shadow: 0 0 40px rgba(47, 140, 255, .55);
}

.ventana-qr[open] { animation: entrar .35s cubic-bezier(.2, .7, .2, 1); }

.ventana-qr::backdrop { background: rgba(2, 4, 10, .78); backdrop-filter: blur(6px); }

.ventana-qr h2 { color: #f4fbff; font-size: .9rem; margin-bottom: 16px; }

.ventana-qr img {
  display: block;
  width: 100%;
  height: auto;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
}

.ventana-qr p { margin-top: 14px; font-size: .85rem; color: var(--suave); }

.cerrar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--suave);
}

/* Aviso flotante (enlace copiado) */
.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border: 1px solid var(--neon);
  border-radius: 999px;
  background: #0a1430;
  color: #f4fbff;
  font-size: .9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.aviso.visible { opacity: 1; transform: translate(-50%, 0); }
