:root {
  --fondo: #0b0816;
  --fondo-2: #17102e;
  --panel: rgba(255, 255, 255, 0.045);
  --borde: rgba(230, 196, 120, 0.28);
  --oro: #e6c478;
  --texto: #f3ecff;
  --tenue: #a79bc2;
  --papel: #f7efdc;
  --tinta: #2a1a4a;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, var(--fondo-2), var(--fondo) 70%) fixed var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

main {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

h1, h2, .marca { font-family: Georgia, 'Times New Roman', serif; font-weight: normal; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 12px 0 8px; text-align: center; }
h2 { font-size: 1.1rem; margin: 0 0 12px; color: var(--oro); }

.cabecera { text-align: center; padding: 8px 0 4px; }
.marca { color: var(--oro); text-decoration: none; font-size: 1.2rem; letter-spacing: 0.15em; }
.aviso-demo { margin: 8px 0 0; font-size: 0.8rem; color: #1a1030; background: var(--oro); border-radius: 99px; padding: 2px 12px; display: inline-block; }

.bajada { text-align: center; color: var(--tenue); margin: 0 0 20px; }

/* Modalidades */
.modalidades { display: grid; gap: 10px; }
.modalidad {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  text-align: left;
  color: inherit;
  font: inherit;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.modalidad:active { background: rgba(255, 255, 255, 0.12); }
.modalidad .icono { display: grid; place-items: center; color: var(--oro); }
.modalidad .icono svg { width: 30px; height: 30px; }
h1 .icono-linea { width: 0.82em; height: 0.82em; vertical-align: -0.08em; color: var(--oro); }
.modalidad strong { display: block; font-size: 1.05rem; }
.modalidad small { color: var(--tenue); display: block; line-height: 1.3; }
.modalidad .precio { color: var(--oro); font-weight: 600; white-space: nowrap; }

.retomar {
  display: block;
  text-align: center;
  margin: 0 0 14px;
  padding: 10px;
  color: var(--oro);
  border: 1px dashed var(--borde);
  border-radius: 12px;
  text-decoration: none;
}

/* Carta del día */
.del-dia { margin: 24px 0 16px; padding: 16px; background: var(--panel); border-radius: 14px; }
.del-dia-cuerpo { display: flex; gap: 14px; align-items: center; }
.del-dia-cuerpo p { margin: 0; font-size: 0.95rem; }
.carta-chica { width: 106px; flex: none; }

/* Formulario */
label { display: block; margin: 8px 0 6px; color: var(--tenue); }
textarea {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* evita el zoom automático de iOS */
  color: var(--texto);
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 12px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--oro); outline-offset: 1px; }

.boton {
  display: block;
  width: 100%;
  margin: 14px 0 0;
  padding: 15px;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: #1a1030;
  background: linear-gradient(180deg, #f1d590, var(--oro));
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
.boton:disabled { opacity: 0.6; }
.boton.secundario { background: transparent; color: var(--oro); border: 1px solid var(--borde); }

.volver { background: none; border: 0; color: var(--tenue); font: inherit; padding: 8px 0; cursor: pointer; }
.nota { text-align: center; color: var(--tenue); font-size: 0.85rem; margin-top: 12px; }
.error { color: #ffb4b4; text-align: center; }

/* Espera */
#vista-espera { text-align: center; padding-top: 32px; }
.bola { color: var(--oro); animation: latir 1.6s ease-in-out infinite; }
.bola svg { width: 84px; height: 84px; }
@keyframes latir { 50% { transform: scale(1.12); opacity: 0.75; } }

/* Mesa y cartas */
/* Mesa de cartas */
.mesa { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px 12px; margin: 20px 0; }
.mesa .ranura { width: calc((100% - 24px) / 3); max-width: 165px; text-align: center; }
.mesa .ranura:only-child { width: 64%; max-width: 260px; }
.mesa .ranura span { display: block; margin-top: 24px; font-size: 0.78rem; color: var(--tenue); line-height: 1.2; }
.mesa .ranura span b { display: block; color: var(--oro); font-weight: 600; }
/* Cada carta flota a su propio ritmo */
.ranura:nth-child(2) { --desfase: -1.7s; }
.ranura:nth-child(3) { --desfase: -3.4s; }
.ranura:nth-child(4) { --desfase: -0.9s; }
.ranura:nth-child(5) { --desfase: -2.6s; }

.carta {
  position: relative;
  aspect-ratio: 4 / 7;
  perspective: 900px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* Sombra en el piso: se achica y aclara cuando la carta sube */
.carta::after {
  content: '';
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -11%;
  height: 8%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.75), transparent 70%);
  filter: blur(5px);
  pointer-events: none;
  animation: sombra 6s ease-in-out infinite;
  animation-delay: var(--desfase, 0s);
}
.carta-flota {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: flotar 6s ease-in-out infinite;
  animation-delay: var(--desfase, 0s);
}
@keyframes flotar {
  0%, 100% { transform: translateY(0) rotateX(4deg) rotateY(-7deg) rotateZ(-0.8deg); }
  50% { transform: translateY(-10px) rotateX(-3deg) rotateY(7deg) rotateZ(0.8deg); }
}
@keyframes sombra {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(0.8); opacity: 0.45; }
}

.carta-giro { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
/* Al darla vuelta la carta se levanta hacia quien mira y gira */
.carta.volteada .carta-giro { transform: rotateY(180deg); animation: voltear 0.9s cubic-bezier(0.3, 0.1, 0.2, 1); }
@keyframes voltear {
  0% { transform: rotateY(0); }
  50% { transform: translateZ(80px) rotateY(90deg); }
  100% { transform: rotateY(180deg); }
}
.carta:not(.volteada):active .carta-giro { transform: translateZ(25px); transition: transform 0.15s; }

.cara {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6% / 3.5%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* canto de cartulina + sombra propia */
  box-shadow: 0 0 0 1px rgba(40, 25, 5, 0.55), 0 1px 0 2px rgba(255, 250, 235, 0.25), 0 16px 26px -10px rgba(0, 0, 0, 0.7);
}
/* Brillo del barniz que recorre la carta mientras se mueve */
.cara::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(112deg, transparent 35%, rgba(255, 255, 255, 0.3) 48%, transparent 60%) 120% 0 / 300% 100% no-repeat,
    radial-gradient(ellipse at center, transparent 55%, rgba(50, 30, 5, 0.22));
  animation: brillo 6s ease-in-out infinite;
  animation-delay: var(--desfase, 0s);
}
@keyframes brillo {
  0%, 100% { background-position: 120% 0, 0 0; }
  50% { background-position: -20% 0, 0 0; }
}

/* Reverso propio: azul noche con dorado, ojo dentro de un sol y fases de la luna */
.dorso { background: #0b0820 url(/cartas/dorso.jpg?v=2) center / cover no-repeat; }
.frente {
  transform: rotateY(180deg);
  background: var(--papel);
  color: var(--tinta);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6% 4%;
  font-family: Georgia, serif;
}
.frente .numero { font-size: 0.8rem; letter-spacing: 0.1em; }
.frente .simbolo { font-size: 2.2rem; line-height: 1; }
.frente .nombre { font-size: 0.72rem; text-align: center; line-height: 1.15; }
.frente img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.carta.invertida .frente .simbolo, .carta.invertida .frente img { transform: rotate(180deg); }
.carta-chica .frente .simbolo { font-size: 1.8rem; }
.carta-chica { cursor: default; margin-bottom: 12px; }

/* Cartas destacadas: aura dorada (muy buena señal) o roja (advertencia) al quedar boca arriba */
.carta::before {
  content: '';
  position: absolute;
  inset: -16%;
  border-radius: 50%;
  filter: blur(16px);
  opacity: 0;
  pointer-events: none;
}
.carta.volteada.tono-luz::before {
  opacity: 0.95;
  background: radial-gradient(ellipse at center, rgba(255, 222, 130, 0.95), rgba(255, 185, 50, 0.45) 55%, transparent 72%);
  animation: aura-entra 0.9s 0.6s both, aura 3.2s 1.5s ease-in-out infinite;
}
.carta.volteada.tono-sombra::before {
  opacity: 0.95;
  background: radial-gradient(ellipse at center, rgba(225, 35, 50, 0.9), rgba(120, 0, 25, 0.5) 55%, transparent 72%);
  animation: aura-entra 0.9s 0.6s both, aura 2.2s 1.5s ease-in-out infinite;
}
@keyframes aura-entra { from { opacity: 0; transform: scale(0.7); } }
@keyframes aura { 50% { opacity: 0.55; transform: scale(1.1); } }
.carta.tono-luz .frente { box-shadow: 0 0 0 2px #ffd978, 0 0 14px 2px rgba(255, 210, 110, 0.7), 0 16px 26px -10px rgba(0, 0, 0, 0.7); }
.carta.tono-sombra .frente { box-shadow: 0 0 0 2px #c2202f, 0 0 14px 2px rgba(200, 30, 45, 0.7), 0 16px 26px -10px rgba(0, 0, 0, 0.7); }
/* La carta de advertencia tiembla al apoyarse */
.carta.volteada.tono-sombra { animation: temblor 0.5s 0.85s; }
@keyframes temblor {
  20%, 60% { transform: translateX(-4px) rotate(-1deg); }
  40%, 80% { transform: translateX(4px) rotate(1deg); }
}
.senal { display: block; margin-top: 3px; font-style: normal; font-weight: 600; font-size: 0.72rem; }
.senal.luz, .bloque.tono-luz h3 { color: #ffd978; }
.senal.sombra, .bloque.tono-sombra h3 { color: #ff7d86; }
.bloque.tono-luz { border-left-color: #ffd978; background: rgba(255, 215, 120, 0.1); }
.bloque.tono-sombra { border-left-color: #c2202f; background: rgba(200, 30, 45, 0.12); }

.cabecera { position: relative; }
.sonido { position: absolute; right: 0; top: 2px; background: none; border: 0; color: var(--oro); padding: 6px; cursor: pointer; opacity: 0.8; }

/* Textos de la lectura */
.pregunta { text-align: center; font-style: italic; color: var(--oro); margin: 0 0 12px; overflow-wrap: anywhere; }
.respuesta {
  text-align: center;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  color: var(--oro);
  margin: 0 0 16px;
}
.bloque {
  background: var(--panel);
  border-left: 3px solid var(--oro);
  border-radius: 0 12px 12px 0;
  padding: 12px 14px;
  margin-bottom: 10px;
  animation: aparecer 0.6s ease both;
}
.bloque h3 { margin: 0 0 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tenue); font-weight: 600; }
.bloque h4 { margin: 0 0 6px; font-family: Georgia, serif; font-weight: normal; font-size: 1.15rem; color: var(--oro); }
.bloque p { margin: 0; }
.cierre { text-align: center; padding: 14px; border: 1px solid var(--borde); border-radius: 12px; animation: aparecer 0.6s ease both; }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } }

footer { margin-top: 32px; text-align: center; color: var(--tenue); font-size: 0.75rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--papel);
  color: var(--tinta);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 0.9rem;
  max-width: 90vw;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .carta, .carta::before, .carta-flota, .carta-giro, .carta::after, .cara::after, .bola, .bloque, .cierre { animation: none !important; }
}

/* Paneles de ingreso con mail y de cobro */
.destacado { color: var(--oro); font-weight: 600; }
.panel {
  margin: 4px 0 16px;
  padding: 18px 16px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  animation: aparecer 0.6s ease both;
}
.panel h2 { font-size: 1.3rem; margin-bottom: 6px; }
.panel p { margin: 0 0 12px; color: var(--tenue); }
.panel p b { color: var(--texto); overflow-wrap: anywhere; }
.panel input {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 16px; /* evita el zoom automático de iOS */
  text-align: center;
  color: var(--texto);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--borde);
  border-radius: 12px;
}
.panel input:focus { outline: 2px solid var(--oro); outline-offset: 1px; }
#codigo { font-size: 1.6rem; letter-spacing: 0.4em; padding-left: 0.4em; }
.panel .aviso-demo { color: #1a1030; }
.enlace { background: none; border: 0; padding: 10px 0 0; color: var(--oro); font: inherit; font-size: 0.9rem; text-decoration: underline; cursor: pointer; }
.nota .enlace { padding: 0; }

/* Carta en grande al tocarla */
.carta.volteada { cursor: zoom-in; }
.zoom {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: rgba(10, 6, 22, 0.92);
  cursor: zoom-out;
  animation: aparecer 0.25s ease both;
}
.zoom img { max-width: 92vw; max-height: 80vh; max-height: 80dvh; border-radius: 14px; box-shadow: 0 0 0 1px rgba(40, 25, 5, 0.55), 0 24px 60px rgba(0, 0, 0, 0.8); }
.zoom img.invertida { transform: rotate(180deg); }
.zoom p { margin: 0; font-family: Georgia, serif; font-size: 1.2rem; color: var(--oro); text-align: center; }

/* El cartel de modo demo va en su propia línea para no chocar con el botón de sonido */
.cabecera .aviso-demo { display: table; margin: 8px auto 0; }

.sonido svg { display: block; width: 22px; height: 22px; }
