:root {
  --fondo: #140b24;
  --fondo2: #241341;
  --morado: #7b4fd1;
  --morado-claro: #b79cff;
  --dorado: #f2c66d;
  --dorado-fuerte: #e0a93b;
  --texto: #f3ecff;
  --suave: #bfb0dc;
  --tarjeta: rgba(255, 255, 255, .06);
  --borde: rgba(242, 198, 109, .28);
}

* { box-sizing: border-box; }
.oculto { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--texto);
  background:
    radial-gradient(circle at 15% 0%, #3d1f73 0, transparent 45%),
    radial-gradient(circle at 100% 30%, #4a2370 0, transparent 40%),
    linear-gradient(180deg, var(--fondo2), var(--fondo) 60%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.estrellas {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 15%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 85% 60%, #f2c66d99 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 80%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 70%, #f2c66d88 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 45%, #fff6 50%, transparent 51%);
  animation: titilar 6s ease-in-out infinite alternate;
}
@keyframes titilar { from { opacity: .5; } to { opacity: 1; } }

h1, h2, .cuenta b { font-family: "Fraunces", Georgia, serif; }

main, .puerta { position: relative; z-index: 1; }
main { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }

/* ---------- Puerta ---------- */
.puerta {
  max-width: 380px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 24px;
}
.puerta-gnomo { width: 120px; height: 160px; animation: balanceo 3s ease-in-out infinite; transform-origin: 50% 100%; }
.puerta h1 { font-size: 2.2rem; margin: 12px 0 4px; color: var(--dorado); }
.puerta p { color: var(--suave); margin: 0 0 18px; }
.puerta form { display: flex; gap: 8px; width: 100%; }
.puerta input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--borde); background: rgba(255,255,255,.08); color: var(--texto); outline: none;
}
.puerta input:focus { border-color: var(--dorado); }
button {
  font: inherit; font-weight: 800; border: 0; border-radius: 14px; padding: 12px 18px; cursor: pointer;
  background: linear-gradient(135deg, var(--dorado), var(--dorado-fuerte)); color: #2a1647;
}
.puerta-error { color: #ffb4a8 !important; min-height: 1.4em; margin-top: 12px !important; }
.temblor { animation: temblor .4s; }

/* ---------- Cabecera ---------- */
.cabecera { text-align: center; }
.antetitulo { text-transform: uppercase; letter-spacing: .25em; font-size: .72rem; color: var(--morado-claro); margin: 8px 0 4px; }
.cabecera h1 { font-size: clamp(2rem, 8vw, 3.2rem); line-height: 1.05; margin: 0; font-weight: 800; }
.dorado {
  background: linear-gradient(90deg, var(--dorado), #fff1c9, var(--dorado-fuerte));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dibus { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 14px 0 6px; }
.dibu { flex: none; }
.capi-dibu { width: 112px; height: 84px; animation: flotar 4s ease-in-out infinite; }
.pibe-dibu { width: 76px; height: 66px; animation: botar 2.6s ease-in-out infinite; }
.gnomo-dibu { width: 62px; height: 84px; animation: balanceo 3s ease-in-out infinite; transform-origin: 50% 100%; }

.cuenta { display: flex; justify-content: center; gap: 8px; margin: 8px 0 6px; }
.cuenta div {
  min-width: 66px; padding: 10px 6px; border-radius: 16px;
  background: var(--tarjeta); border: 1px solid var(--borde);
}
.cuenta b { display: block; font-size: 1.7rem; color: var(--dorado); }
.cuenta span { font-size: .72rem; color: var(--suave); text-transform: uppercase; letter-spacing: .08em; }
.sub { color: var(--suave); font-size: .95rem; margin: 10px auto 0; max-width: 30em; }
.aviso-prueba {
  display: inline-block; margin-top: 12px; padding: 6px 12px; border-radius: 99px; font-size: .8rem;
  background: #ff7ab6; color: #2a0f20; font-weight: 800;
}

/* ---------- Tarjetas ---------- */
.tablero { display: grid; gap: 14px; margin-top: 28px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .tablero { grid-template-columns: 1fr 1fr; } .tarjeta.final { grid-column: 1 / -1; } }

.tarjeta {
  position: relative; border-radius: 22px; padding: 18px 18px 16px; overflow: hidden;
  background: linear-gradient(160deg, rgba(123,79,209,.22), rgba(255,255,255,.04));
  border: 1px solid var(--borde);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.tarjeta .fecha {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em; color: var(--dorado);
}
.tarjeta h2 { font-size: 1.25rem; margin: 6px 0 8px; }
.tarjeta p { margin: 0; line-height: 1.5; }
.tarjeta .texto { font-size: 1.05rem; }

.tarjeta.cerrada {
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 12px, rgba(255,255,255,.015) 12px 24px);
  border-style: dashed; border-color: rgba(183,156,255,.3); cursor: pointer;
  display: flex; align-items: center; gap: 14px; min-height: 92px;
}
.tarjeta.cerrada .candado { font-size: 1.8rem; filter: grayscale(.3); }
.tarjeta.cerrada .fecha { color: var(--morado-claro); }
.tarjeta.cerrada p { color: var(--suave); font-size: .95rem; }

.tarjeta.hoy { border-color: var(--dorado); box-shadow: 0 0 0 2px rgba(242,198,109,.25), 0 10px 30px rgba(0,0,0,.25); }
.etiqueta-hoy {
  position: absolute; top: 14px; right: 14px; font-size: .7rem; font-weight: 800; padding: 3px 9px; border-radius: 99px;
  background: var(--dorado); color: #2a1647; text-transform: uppercase; letter-spacing: .08em;
}

.reto {
  margin-top: 14px; border-top: 1px dashed var(--borde); padding-top: 10px;
}
.reto summary { cursor: pointer; font-weight: 800; color: var(--morado-claro); list-style: none; }
.reto summary::-webkit-details-marker { display: none; }
.reto summary::before { content: "🎯 "; }
.reto p { margin-top: 8px; color: var(--texto); font-size: .97rem; }

/* Pista falsa */
.boton-falsa {
  margin-top: 12px; padding: 8px 14px; font-size: .9rem;
  background: transparent; color: var(--dorado); border: 1px solid var(--dorado);
}
.sello {
  margin-top: 12px; padding: 10px 12px; border-radius: 14px; font-weight: 700;
  border: 2px solid #ff7a8a; color: #ffd0d6; background: rgba(255,122,138,.12);
  animation: sellar .45s cubic-bezier(.2,1.6,.4,1);
}

/* Final */
.tarjeta.final { text-align: center; padding: 24px 18px; background: linear-gradient(160deg, rgba(242,198,109,.22), rgba(123,79,209,.25)); }
.tarjeta.final.cerrada { justify-content: center; text-align: left; }
.tarjeta.final h2 { font-size: 1.8rem; }
.tarjeta.final .texto { font-size: 1.2rem; font-family: "Fraunces", Georgia, serif; }
.foto-gnomo { margin: 18px auto 4px; max-width: 420px; }
.foto-gnomo img { width: 100%; border-radius: 18px; border: 3px solid var(--dorado); display: block; }
.hueco-foto {
  aspect-ratio: 4 / 3; border-radius: 18px; border: 2px dashed var(--dorado);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--suave); padding: 16px;
}
.hueco-foto svg { width: 70px; height: 94px; }

/* Animación al desbloquear */
.desbloqueando { animation: desbloquear .9s cubic-bezier(.2,.9,.3,1.2) both; }
.desbloqueando::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(242,198,109,.45) 50%, transparent 70%);
  transform: translateX(-100%); animation: brillo 1.2s .35s ease-out forwards;
}
.chispa { position: absolute; font-size: 1.1rem; pointer-events: none; animation: chispa 1.1s ease-out forwards; }

.pie { text-align: center; color: var(--suave); font-size: .85rem; margin-top: 36px; opacity: .8; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 40px);
  background: #2a1647; border: 1px solid var(--borde); color: var(--texto);
  padding: 10px 16px; border-radius: 14px; opacity: 0; transition: .25s; z-index: 5; max-width: 90vw; text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes flotar { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-6px) rotate(1deg); } }
@keyframes botar { 0%,100% { transform: translateY(0) scaleY(1); } 45% { transform: translateY(-8px) scaleY(1.03); } 55% { transform: translateY(0) scaleY(.94); } }
@keyframes balanceo { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes temblor { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
@keyframes desbloquear {
  0% { transform: perspective(700px) rotateY(80deg) scale(.9); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes brillo { to { transform: translateX(100%); } }
@keyframes sellar { from { transform: scale(1.6) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes chispa { from { transform: translate(0,0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.nowrap { white-space: nowrap; }

.puerta-rey { position: relative; width: 170px; height: 170px; display: flex; align-items: center; justify-content: center; animation: balanceo 3s ease-in-out infinite; transform-origin: 50% 100%; }
.puerta-rey img { width: 170px; height: 170px; object-fit: cover; border-radius: 50%; border: 4px solid var(--dorado); box-shadow: 0 0 30px rgba(242,198,109,.35); }
.puerta-pibe { width: 150px; height: 130px; }
.corona { position: absolute; top: -26px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 2.6rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.puerta-rey { width: 200px; height: 200px; }
.puerta-rey img { width: 200px; height: 200px; border-radius: 28px; }
.puerta-rey img:not(.oculto) ~ .corona { display: none; }
.puerta-rey { width: 260px; height: auto; min-height: 150px; }
.puerta-rey img { width: 260px; height: auto; aspect-ratio: 480 / 352; }
.puerta-rey { width: 240px; }
.puerta-rey img { width: 240px; aspect-ratio: 1; }

.siguiente {
  display: inline-block; margin: 10px auto 0; padding: 7px 14px; border-radius: 99px;
  background: rgba(123,79,209,.28); border: 1px solid rgba(183,156,255,.45); color: var(--texto); font-size: .9rem;
}
.siguiente b { font-family: "Fraunces", Georgia, serif; color: var(--dorado); font-variant-numeric: tabular-nums; margin-left: 2px; }

.foto-falsa { display: block; width: 100%; max-width: 360px; margin: 14px auto 0; border-radius: 16px; border: 3px solid var(--dorado); }
.tablero { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 620px) { .tablero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.tarjeta { min-width: 0; }

.revelacion {
  text-align: center; margin: 12px 0 0 !important; font-family: "Fraunces", Georgia, serif; font-weight: 800;
  font-size: 2.2rem; letter-spacing: .04em; color: var(--dorado); text-shadow: 0 3px 0 #2a1647, 0 0 18px rgba(242,198,109,.45);
}

/* ---------- Apuestas ---------- */
.apuesta {
  margin-top: 14px; padding: 12px; border-radius: 16px;
  background: rgba(242,198,109,.08); border: 1px solid rgba(242,198,109,.35);
}
.apuesta-titulo { display: block; font-weight: 800; color: var(--dorado); font-size: .95rem; margin-bottom: 8px; }
.apuesta textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; resize: vertical; min-height: 60px;
  border: 1px solid var(--borde); background: rgba(0,0,0,.25); color: var(--texto); outline: none;
}
.apuesta textarea:focus { border-color: var(--dorado); }
.apuesta textarea:disabled { opacity: .6; }
.apuesta-pie { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--suave); margin-top: 6px; }
.apuesta-nota { font-size: .78rem !important; color: var(--suave); margin-top: 6px !important; }
.cerrada-apuesta { background: rgba(255,255,255,.04); border-style: dashed; }
.cerrada-apuesta .apuesta-titulo { color: var(--morado-claro); margin-bottom: 4px; }
.apuesta-texto { font-family: "Fraunces", Georgia, serif; font-size: 1.05rem; }
.apuesta-vacia { color: var(--suave); font-style: italic; font-size: .92rem; }
.historial { margin-top: 8px; font-size: .85rem; }
.historial summary { cursor: pointer; color: #ff9fca; font-weight: 700; }
.historial ul, .resumen-apuestas ul { list-style: none; padding: 0; margin: 8px 0 0; }
.historial li { padding: 3px 0; color: var(--suave); }
.historial li b { color: var(--texto); margin-right: 4px; font-variant-numeric: tabular-nums; }
.resumen-apuestas { margin: 20px auto 0; max-width: 460px; text-align: left; padding: 14px 16px; border-radius: 18px; background: rgba(0,0,0,.2); border: 1px solid var(--borde); }
.resumen-apuestas h3 { font-family: "Fraunces", Georgia, serif; color: var(--dorado); margin: 0 0 4px; font-size: 1.2rem; text-align: center; }
.resumen-apuestas li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(242,198,109,.2); }
.resumen-apuestas li:last-child { border-bottom: 0; }
.resumen-apuestas li b { flex: none; width: 7.5em; color: var(--morado-claro); font-size: .9rem; }
.resumen-apuestas li .vacia { color: var(--suave); }
.historial li, .apuesta-texto, .resumen-apuestas li span { overflow-wrap: anywhere; }
.resumen-apuestas li b { width: 4.2em; }

.frase-foto { font-family: "Fraunces", Georgia, serif; font-weight: 800; font-size: 1.5rem !important; color: var(--dorado); margin-top: 10px !important; }
