:root {
  --pine: #0f2420;
  --pine-2: #163530;
  --pine-3: #1f4640;
  --paper: #f1e6cc;
  --paper-2: #e6d6b2;
  --paper-edge: #cdb98d;
  --ink: #2a2318;
  --ink-soft: #5d5140;
  --red: #b3261e;
  --red-dark: #7e1812;
  --gold: #d4a63a;
  --gold-soft: #f0d58c;
  --green-ok: #2f7d4f;
  --snow: #fffdf7;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .25);
  --radius: 4px;
  --postit: #f3dd6d;
  --type: 'Special Elite', 'Courier New', monospace;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --hand: 'Caveat', 'Bradley Hand', cursive;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--snow);
  background:
    radial-gradient(1200px 600px at 50% -10%, #23524a 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #1a3b2f 0%, transparent 60%),
    var(--pine);
  background-attachment: fixed;
  overflow-x: hidden;
}
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 18px 16px 80px; }
img { max-width: 100%; display: block; }
button { font: inherit; }
a { color: var(--gold-soft); }

.type { font-family: var(--type); letter-spacing: .02em; }
.hand { font-family: var(--hand); font-weight: 500; }
.muted { color: rgba(255, 253, 247, .7); }
.small { font-size: .86rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Arranque ---------- */
.boot { min-height: 70dvh; display: grid; place-items: center; align-content: center; gap: 18px; }

/* ---------- Sellos ---------- */
.stamp {
  display: inline-block;
  font-family: var(--type);
  text-transform: uppercase;
  letter-spacing: .12em;
  border: 3px solid currentColor;
  border-radius: 6px;
  padding: 4px 12px;
  transform: rotate(-6deg);
  opacity: .9;
  mix-blend-mode: multiply;
}
.stamp-red { color: var(--red); }
.stamp-green { color: var(--green-ok); }
.stamp-light { color: var(--gold-soft); mix-blend-mode: normal; }
.stamp-in { animation: stampIn .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stampIn { from { transform: scale(2.4) rotate(-14deg); opacity: 0; } }

/* ---------- Cabecera ---------- */
.masthead { text-align: center; padding: 10px 0 6px; }
.masthead .kicker {
  font-family: var(--type); font-size: .78rem; letter-spacing: .25em; text-transform: uppercase;
  color: var(--gold-soft); opacity: .9;
}
.masthead h1 {
  font-family: var(--serif); font-weight: 900; line-height: .95; margin: 10px 0 6px;
  font-size: clamp(2.3rem, 11vw, 3.4rem); letter-spacing: -.01em;
}
.masthead h1 em { font-style: normal; color: var(--gold); display: block; }
.masthead .family { font-family: var(--type); color: rgba(255, 253, 247, .75); }

/* ---------- Foto de grupo ---------- */
.hero { position: relative; margin: 22px 6px 8px; }
.polaroid {
  background: var(--snow); padding: 10px 10px 40px; border-radius: 3px; box-shadow: var(--shadow);
  transform: rotate(-2deg); position: relative;
}
.polaroid .ph { aspect-ratio: 4 / 3; background: #2b3a36; overflow: hidden; position: relative; }
.polaroid .ph img { width: 100%; height: 100%; object-fit: cover; }
.polaroid .caption {
  position: absolute; left: 0; right: 0; bottom: 8px; text-align: center;
  font-family: var(--type); color: var(--ink); font-size: .95rem;
}
.hero .stamp { position: absolute; right: 8px; top: 18px; background: rgba(241, 230, 204, .0); z-index: 2; font-size: .9rem; }
.tape {
  position: absolute; width: 90px; height: 26px; background: rgba(240, 213, 140, .55); top: -12px; left: 50%;
  transform: translateX(-50%) rotate(3deg); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); z-index: 2;
}
.ph-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--paper);
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .04) 0 12px, transparent 12px 24px),
    linear-gradient(160deg, #24524a, #12302a);
  font-family: var(--type); padding: 16px;
}
.ph-fallback b { display: block; font-family: var(--serif); font-size: 2.2rem; color: var(--gold-soft); }

/* ---------- Datos del evento ---------- */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0 6px; }
.fact {
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px;
  padding: 10px 8px; text-align: center; min-width: 0;
}
.fact .k { font-family: var(--type); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); }
.fact .v { font-weight: 600; font-size: .9rem; margin-top: 4px; overflow-wrap: anywhere; }

.countdown { display: flex; justify-content: center; gap: 8px; margin: 18px 0 4px; }
.countdown .u {
  position: relative; background: var(--paper); color: var(--ink); border-radius: 3px 3px 5px 5px; min-width: 62px; padding: 14px 6px 6px;
  text-align: center; box-shadow: 0 3px 6px rgba(0, 0, 0, .3); clip-path: polygon(50% 0, 100% 18%, 100% 100%, 0 100%, 0 18%);
}
.countdown .u::before { content: ''; position: absolute; top: 5px; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: var(--pine); transform: translateX(-50%); }
.countdown .u:nth-child(odd) { transform: rotate(-2deg); }
.countdown .u:nth-child(even) { transform: rotate(1.5deg); }
.countdown .n { font-family: var(--serif); font-weight: 900; font-size: 1.7rem; line-height: 1; }
.countdown .l { font-family: var(--type); font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.countdown-label { text-align: center; font-family: var(--type); font-size: .8rem; color: rgba(255, 253, 247, .7); }

/* ---------- Paneles de papel ---------- */
.paper {
  background:
    linear-gradient(transparent 0 31px, rgba(93, 81, 64, .06) 31px 32px) 0 0 / 100% 32px,
    var(--paper);
  color: var(--ink); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow); position: relative;
  margin: 22px 0;
}
.paper h2, .paper h3 { font-family: var(--serif); margin: 0 0 8px; line-height: 1.1; }
.paper h2 { font-size: 1.55rem; }
.paper h3 { font-size: 1.2rem; }
.paper p { line-height: 1.5; }
.paper .label { font-family: var(--type); text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: var(--red); }
.paper .muted { color: var(--ink-soft); }
.folder-tab {
  position: absolute; top: -16px; left: 18px; background: var(--paper); color: var(--ink-soft);
  font-family: var(--type); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; padding: 4px 14px 2px;
  border-radius: 8px 8px 0 0;
}

.section-title {
  font-family: var(--type); text-transform: uppercase; letter-spacing: .2em; font-size: .8rem; color: var(--gold-soft);
  display: flex; align-items: center; gap: 10px; margin: 30px 0 12px;
}
.section-title::after { content: ''; flex: 1; height: 0; border-top: 1px dashed rgba(212, 70, 58, .55); }

/* ---------- Agentes ---------- */
.agents { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 14px; }
@media (min-width: 440px) { .agents { grid-template-columns: repeat(3, 1fr); } }
.agent {
  background: var(--snow); color: var(--ink); border: 0; padding: 8px 8px 10px; border-radius: 3px; box-shadow: var(--shadow);
  cursor: pointer; text-align: center; position: relative; transition: transform .2s;
}
.agent:nth-child(odd) { transform: rotate(-1.6deg); }
.agent:nth-child(even) { transform: rotate(1.4deg); }
.agent:active { transform: scale(.97); }
.agent .face { aspect-ratio: 1; position: relative; overflow: hidden; background: #ccc; }
.agent .face img { width: 100%; height: 100%; object-fit: cover; }
.agent .apodo { font-family: var(--hand); font-weight: 700; font-size: 1.35rem; line-height: 1.05; color: var(--red-dark); margin-top: 8px; }
.agent .name { font-family: var(--type); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin-top: 4px; }
.agent .code { font-family: var(--type); font-size: .72rem; color: var(--ink-soft); min-height: 1em; margin-top: 4px; }
.agent.pending .face { filter: grayscale(1) contrast(.9) brightness(.85); }
.agent .badge {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: .66rem; padding: 2px 8px;
  background: rgba(255, 253, 247, .85); white-space: nowrap; border-width: 2px;
}
.agent.me { outline: 3px solid var(--gold); outline-offset: 3px; }

/* La foto va encima de las iniciales; si no carga, se quita sola y se ven las iniciales. */
.face img { position: relative; z-index: 1; }
.initials {
  position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-weight: 900;
  font-size: 2.6rem; color: var(--paper);
}

/* ---------- Botones y formularios ---------- */
.btn {
  appearance: none; border: 0; border-radius: 6px; padding: 14px 20px; font-family: var(--type); font-weight: 400;
  font-size: .98rem; letter-spacing: .06em; text-transform: uppercase; line-height: 1.2;
  background: var(--red); color: var(--snow); cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px rgba(255, 253, 247, .55), 0 4px 0 var(--red-dark);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px rgba(255, 253, 247, .55), 0 1px 0 var(--red-dark); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.gold {
  background: var(--gold); color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 0 3px rgba(42, 35, 24, .35), 0 4px 0 #9b7722;
}
.btn.gold:active { box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 0 3px rgba(42, 35, 24, .35), 0 1px 0 #9b7722; }
.btn.ghost { background: transparent; color: inherit; box-shadow: none; border: 2px dashed currentColor; }
.btn.link { background: none; box-shadow: none; color: inherit; text-decoration: underline; padding: 8px; width: auto; text-transform: none; letter-spacing: 0; font-family: var(--sans); font-weight: 500; }
.btn-row { display: grid; gap: 12px; margin-top: 16px; }

.field { display: grid; gap: 6px; margin: 14px 0; }
.field label { font-family: var(--type); font-size: .82rem; letter-spacing: .06em; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  font: inherit; font-size: 16px; width: 100%; padding: 12px 14px; border-radius: 3px; border: 1.5px solid var(--paper-edge);
  border-bottom-width: 2px; background: #fffaf0; color: var(--ink);
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--red); }
.hint { font-size: .82rem; color: var(--ink-soft); }
.error { color: var(--red); font-weight: 600; font-size: .9rem; min-height: 1.2em; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-size: .95rem; }
.check input { width: 22px; height: 22px; accent-color: var(--red); flex: none; margin-top: 1px; }

.back { background: none; border: 0; color: var(--gold-soft); font-family: var(--type); padding: 6px 0; cursor: pointer; font-size: .95rem; }

.code-box {
  font-family: var(--type); font-size: 1.6rem; letter-spacing: .12em; text-align: center; padding: 16px 10px;
  border: 3px dashed var(--red); border-radius: 12px; background: #fffaf0; color: var(--ink); margin: 12px 0; user-select: all;
}

.spinner {
  width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(179, 38, 30, .2); border-top-color: var(--red);
  animation: spin 1s linear infinite; margin: 18px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Avisos ---------- */
.alert {
  background: linear-gradient(135deg, #7e1812, #b3261e); color: var(--snow); border-radius: var(--radius); padding: 14px 16px;
  margin: 16px 0; box-shadow: var(--shadow); display: grid; gap: 4px;
}
.alert b { font-family: var(--serif); font-size: 1.1rem; }
.notice {
  position: relative; background: linear-gradient(175deg, #f7e784, var(--postit) 60%, #e9cf5a); color: var(--ink);
  padding: 22px 18px 16px; margin: 26px 8px 18px; line-height: 1.25; transform: rotate(-1.2deg);
  font-family: var(--hand); font-size: 1.45rem; font-weight: 500;
  box-shadow: 2px 6px 14px rgba(0, 0, 0, .35);
}
.notice::before {
  content: ''; position: absolute; top: -11px; left: 50%; width: 96px; height: 24px; transform: translateX(-50%) rotate(-2deg);
  background: rgba(255, 253, 247, .45); box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.notice .type { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--red-dark) !important; font-family: var(--type); }
.notice b { font-weight: 700; }

/* ---------- Sobre ---------- */
.envelope-stage { display: grid; place-items: center; padding: 40px 0 20px; perspective: 1200px; }
.envelope {
  width: min(330px, 86vw); aspect-ratio: 1.45; position: relative; background: #c9a978; border-radius: 6px;
  box-shadow: var(--shadow);
}
.envelope .letter {
  position: absolute; left: 6%; right: 6%; top: 8%; bottom: 8%; background: var(--paper); border-radius: 4px;
  transition: transform .9s cubic-bezier(.3, .7, .2, 1) .5s; z-index: 1; display: grid; place-items: start center; padding-top: 10%;
  font-family: var(--type); color: var(--red); letter-spacing: .14em;
}
.envelope .pocket {
  position: absolute; inset: 0; z-index: 2; border-radius: 6px;
  background:
    linear-gradient(to top right, #d9bb8a 50%, transparent 50.5%) left / 50.5% 100% no-repeat,
    linear-gradient(to top left, #d4b582 50%, transparent 50.5%) right / 50.5% 100% no-repeat,
    linear-gradient(to top, #cfae79 45%, transparent 45%);
}
.envelope .flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 3; transform-origin: top;
  background: #e0c493; clip-path: polygon(0 0, 100% 0, 50% 100%); transition: transform .6s ease-in-out;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .2));
}
.envelope .addr {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 12%; text-align: center; font-family: var(--type); color: var(--ink);
}
.seal {
  position: absolute; z-index: 5; left: 50%; top: 58%; width: 84px; height: 84px; transform: translate(-50%, -50%);
  border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #d8473d, #9e1b14 60%, #6d0f0a);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .45), inset 0 -4px 8px rgba(0, 0, 0, .35), inset 0 3px 6px rgba(255, 255, 255, .25);
  color: #f6c9c3; font-family: var(--serif); font-weight: 900; font-size: 1.5rem;
  animation: pulse 1.8s ease-in-out infinite;
}
.seal::before {
  content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 2px dashed rgba(246, 201, 195, .55);
}
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.07); } }
.envelope.open .flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .seal { animation: crack .5s forwards; }
.envelope.open .letter { transform: translateY(-62%); }
@keyframes crack {
  40% { transform: translate(-50%, -50%) scale(1.2) rotate(-10deg); }
  100% { transform: translate(-50%, 40%) scale(.6) rotate(40deg); opacity: 0; }
}
.tap-hint { margin-top: 26px; font-family: var(--type); color: var(--gold-soft); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Rasca y gana ---------- */
.scratch-wrap { position: relative; width: min(320px, 84vw); margin: 10px auto 0; }
.scratch-card { background: var(--snow); padding: 10px 10px 74px; border-radius: 3px; box-shadow: var(--shadow); transform: rotate(-1.5deg); }
.scratch-card .face { aspect-ratio: 1; position: relative; overflow: hidden; background: #ccc; }
.scratch-card .face img { width: 100%; height: 100%; object-fit: cover; }
.scratch-card .who {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-family: var(--serif); font-weight: 900;
  font-size: 1.7rem; color: var(--ink);
}
.scratch-card .who { font-family: var(--hand); font-size: 1.9rem; color: var(--red-dark); line-height: 1; }
.scratch-card .who small { display: block; font-family: var(--type); font-size: .8rem; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-soft); margin-top: 6px; }
.scratch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; border-radius: 3px; transition: opacity .7s; }
.scratch-canvas.done { opacity: 0; pointer-events: none; }

/* ---------- Expediente ---------- */
.dossier { margin-top: 34px; }
.dossier-head { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: center; }
.dossier-photo { background: var(--snow); padding: 6px 6px 18px; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); transform: rotate(-3deg); position: relative; }
.dossier-photo .face { aspect-ratio: 1; position: relative; overflow: hidden; background: #ccc; }
.dossier-photo .face img { width: 100%; height: 100%; object-fit: cover; }
.clip {
  position: absolute; top: -14px; right: 14px; width: 18px; height: 46px; border: 3px solid #8d8d8d; border-radius: 10px;
  border-bottom-color: transparent;
}
.dossier-name { font-family: var(--serif); font-weight: 900; font-size: 2rem; line-height: 1; }
.dossier-name.hand { font-family: var(--hand); font-weight: 700; font-size: 1.9rem; color: var(--red-dark); }
.dossier-real { font-family: var(--type); font-size: .82rem; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-soft); margin-top: 4px; }
.dossier dl { margin: 18px 0 0; display: grid; gap: 12px; }
.dossier dt { font-family: var(--type); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--red); }
.dossier dd { margin: 2px 0 0; line-height: 1.45; }
.dossier dd.empty { color: var(--ink-soft); font-style: italic; }
.redacted { background: var(--ink); color: transparent; border-radius: 2px; user-select: none; }

/* ---------- Buzón ---------- */
.chat { display: grid; gap: 10px; margin: 12px 0; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 3px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--type); font-size: .95rem; box-shadow: 0 2px 4px rgba(0, 0, 0, .15); }
.bubble.mine { justify-self: end; background: var(--red-dark); color: var(--snow); transform: rotate(.6deg); }
.bubble.theirs { justify-self: start; background: #fffaf0; border: 1px solid var(--paper-edge); transform: rotate(-.6deg); }
.bubble .meta { display: block; font-size: .7rem; opacity: .7; margin-top: 4px; font-family: var(--type); }
.chat-empty { font-family: var(--type); color: var(--ink-soft); text-align: center; padding: 10px; }
.compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.compose textarea { min-height: 48px; }
.compose .btn { width: auto; padding: 12px 16px; }

/* ---------- Selector de sospechoso ---------- */
.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.pick button {
  border: 2px solid transparent; background: #fffaf0; border-radius: 10px; padding: 6px; cursor: pointer; color: var(--ink);
  font-family: var(--serif); font-weight: 700; font-size: .85rem;
}
.pick button .face { aspect-ratio: 1; position: relative; overflow: hidden; border-radius: 6px; background: #ccc; margin-bottom: 4px; }
.pick button .face img { width: 100%; height: 100%; object-fit: cover; }
.pick button .initials { font-size: 1.4rem; }
.pick button.sel { border-color: var(--red); background: #ffe9e3; }

/* ---------- Tablero final ---------- */
.board {
  position: relative; aspect-ratio: 1; margin: 10px auto; width: min(100%, 520px); border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .08), transparent 40%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .05) 0 2px, transparent 2px 6px),
    #8a6a45;
  box-shadow: inset 0 0 0 10px #5a4129, var(--shadow);
}
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pin {
  position: absolute; width: 16%; transform: translate(-50%, -50%); background: var(--snow); padding: 4px 4px 14px; box-shadow: 0 3px 8px rgba(0, 0, 0, .4);
  text-align: center; color: var(--ink);
}
.pin .face { aspect-ratio: 1; position: relative; overflow: hidden; background: #ccc; }
.pin .face img { width: 100%; height: 100%; object-fit: cover; }
.pin .initials { font-size: 1.3rem; }
.pin span { position: absolute; left: 0; right: 0; bottom: 1px; font-family: var(--type); font-size: .6rem; }
.pin::before {
  content: ''; position: absolute; top: -5px; left: 50%; width: 11px; height: 11px; border-radius: 50%; transform: translateX(-50%);
  background: radial-gradient(circle at 35% 35%, #ff6b5f, #a3170f); z-index: 2; box-shadow: 0 2px 2px rgba(0, 0, 0, .4);
}
.results { display: grid; gap: 8px; margin-top: 12px; }
.result-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--paper-edge); font-size: .95rem; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 140%);
  background: var(--ink); color: var(--snow); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50;
  max-width: calc(100vw - 32px); transition: transform .3s, opacity .3s; font-size: .95rem; opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ---------- Confeti ---------- */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.burst i { position: absolute; top: -20px; font-style: normal; font-size: 22px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.footer { text-align: center; margin-top: 40px; font-family: var(--type); font-size: .78rem; color: rgba(255, 253, 247, .5); }


/* ---------- Presentación de apertura ---------- */
body.intro-open { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 30; color: var(--snow); cursor: pointer; user-select: none; -webkit-user-select: none;
  background:
    radial-gradient(900px 500px at 50% -10%, #2a5c52 0%, transparent 65%),
    radial-gradient(700px 500px at 100% 100%, #1a3b2f 0%, transparent 60%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .018) 0 2px, transparent 2px 7px),
    var(--pine);
  animation: introIn .6s ease both;
}
.intro.out { animation: introOut .7s ease forwards; }
@keyframes introIn { from { opacity: 0; } }
@keyframes introOut { to { opacity: 0; transform: scale(1.04); } }
.intro-skip {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 3; background: none; border: 0;
  color: rgba(255, 253, 247, .7); font-size: .95rem; padding: 8px 10px; cursor: pointer; letter-spacing: .08em;
}
.intro-stage { position: absolute; inset: 0; }
.intro-foot {
  position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 2; text-align: center;
  display: grid; gap: 8px; pointer-events: none;
}
.intro-dots { display: flex; justify-content: center; gap: 5px; }
.intro-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(240, 213, 140, .25); transition: background .3s; }
.intro-dots i.on { background: var(--gold); }
.intro-tap { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: rgba(255, 253, 247, .45); animation: blink 2s infinite; }

.sc { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; padding: 60px 22px 70px; gap: 14px; text-align: center; }
.w { display: inline-block; animation: wordIn .55s cubic-bezier(.2, 1.2, .3, 1) both; animation-delay: var(--d, 0s); }
@keyframes wordIn { from { opacity: 0; transform: translateY(18px) rotate(-2deg); filter: blur(4px); } }
.typing::after { content: '▍'; animation: blink .8s infinite; }

/* Portada: la carpeta del expediente */
.folder-cover {
  position: relative; width: min(360px, 92vw); padding: 56px 24px 44px; background: #d8b46f; color: var(--ink); border-radius: 4px 14px 4px 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), 0 24px 50px rgba(0, 0, 0, .5);
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .025) 0 1px, transparent 1px 3px),
    radial-gradient(260px 120px at 90% 100%, rgba(0, 0, 0, .08), transparent 70%);
  animation: folderIn .9s cubic-bezier(.2, 1.3, .3, 1) both;
}
@keyframes folderIn { from { opacity: 0; transform: translateY(60px) rotate(-7deg) scale(.92); } to { transform: rotate(-1.5deg); } }
.fc-tab {
  position: absolute; top: -22px; right: 18px; background: #e5c784; color: var(--ink-soft); font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; padding: 6px 14px 3px; border-radius: 8px 8px 0 0; box-shadow: 0 -2px 4px rgba(0, 0, 0, .06);
}
.fc-kicker { font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--red-dark); min-height: 1.2em; }
.fc-title { font-family: var(--serif); font-weight: 900; line-height: .98; font-size: clamp(2.1rem, 9.5vw, 2.9rem); margin: 14px 0 8px; letter-spacing: -.01em; }
.fc-title em { font-style: normal; color: var(--red); }
.fc-note { font-size: 1.5rem; color: var(--ink-soft); transform: rotate(-3deg); animation: wordIn .5s both; animation-delay: var(--d); }
.fc-stamp { position: absolute; right: -6px; bottom: 22px; font-size: 1.1rem; animation: stampIn .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: var(--d); }
.hole { position: absolute; left: 14px; width: 14px; height: 14px; border-radius: 50%; background: var(--pine); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6); }
.hole.h1 { top: 30%; } .hole.h2 { top: 65%; }

/* Avisos: la nota mecanografiada */
.memo {
  position: relative; width: min(380px, 92vw); padding: 30px 22px 24px; color: var(--ink); text-align: left; border-radius: 2px;
  background:
    linear-gradient(transparent 0 27px, rgba(93, 81, 64, .09) 27px 28px) 0 10px / 100% 28px,
    var(--paper);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
  transform: rotate(1.2deg);
  animation: memoIn .7s cubic-bezier(.2, 1.2, .3, 1) both;
}
@keyframes memoIn { from { opacity: 0; transform: translateY(-40px) rotate(4deg); } to { transform: rotate(1.2deg); } }
.memo-clip { position: absolute; top: -16px; left: 26px; width: 20px; height: 52px; border: 3px solid #8d8d8d; border-radius: 10px; border-bottom-color: transparent; }
.memo-head { font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--red); border-bottom: 2px solid var(--red); padding-bottom: 6px; margin-bottom: 10px; }
.memo-list { margin: 0; padding-left: 22px; font-family: var(--type); font-size: .9rem; line-height: 1.45; }
.memo-list li { margin: 7px 0; animation: lineIn .5s ease both; animation-delay: var(--d); }
@keyframes lineIn { from { opacity: 0; transform: translateX(-10px); } }
.memo-nota { display: block; font-size: 1.25rem; line-height: 1.05; color: var(--red-dark); transform: rotate(-1.5deg); margin: 2px 0 0 6px; }
.memo-sign { text-align: right; font-size: 1.5rem; color: var(--ink-soft); margin-top: 10px; animation: wordIn .5s both; animation-delay: var(--d); }
.stain {
  position: absolute; right: 10px; bottom: 14px; width: 74px; height: 74px; border-radius: 50%; pointer-events: none;
  border: 7px solid rgba(120, 72, 20, .14); border-left-color: rgba(120, 72, 20, .05); transform: rotate(20deg); filter: blur(.4px);
}

/* La pregunta y la ruleta */
.q-kicker { font-size: .78rem; letter-spacing: .25em; text-transform: uppercase; color: var(--gold-soft); animation: wordIn .5s both; }
.q-title { font-family: var(--serif); font-weight: 900; font-size: clamp(2rem, 9vw, 2.8rem); line-height: 1; margin: 0; animation: wordIn .6s .15s both; }
.q-title em { font-style: normal; color: var(--gold); }
.roulette { margin-top: 8px; perspective: 800px; }
.r-card {
  width: min(210px, 56vw); background: var(--snow); padding: 8px 8px 30px; color: var(--ink); position: relative; border-radius: 3px;
  box-shadow: var(--shadow); transform: rotate(2deg); animation: wordIn .6s .4s both;
}
.r-card.tick { animation: tick .12s ease-out; }
@keyframes tick { from { transform: rotate(2deg) scale(1.04) translateY(-3px); } to { transform: rotate(2deg); } }
.r-face { aspect-ratio: 1; position: relative; overflow: hidden; background: #ccc; }
.r-face .face { position: absolute; inset: 0; }
.r-face img { width: 100%; height: 100%; object-fit: cover; }
.r-name { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: .9rem; }
.r-q { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-weight: 900; font-size: 6rem; color: var(--paper); background: var(--pine-3); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.r-card.r-final { animation: shake .5s ease-out; }
@keyframes shake { 20% { transform: rotate(-3deg); } 50% { transform: rotate(5deg); } 80% { transform: rotate(0); } 100% { transform: rotate(2deg); } }
.r-stamp { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-14deg); font-size: .95rem; white-space: nowrap; background: rgba(255, 253, 247, .85); mix-blend-mode: normal; z-index: 3; }

/* Fichas de los agentes */
.f-counter { font-size: .72rem; letter-spacing: .25em; text-transform: uppercase; color: rgba(240, 213, 140, .8); }
.f-card {
  width: min(260px, 70vw); background: var(--snow); padding: 10px 10px 16px; color: var(--ink); position: relative; border-radius: 3px;
  box-shadow: var(--shadow); animation: cardIn .75s cubic-bezier(.2, 1.25, .35, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateX(calc(var(--from) * 110vw)) rotate(calc(var(--tilt) * 5)); }
  to { transform: rotate(var(--tilt)); }
}
.f-card .face { aspect-ratio: 1; position: relative; overflow: hidden; background: #ccc; }
.f-card .face img { width: 100%; height: 100%; object-fit: cover; }
.f-card .tape { width: 80px; top: -11px; }
.f-apodo { font-size: clamp(1.75rem, 7.5vw, 2.2rem); line-height: 1.1; margin-top: 12px; animation: wordIn .5s .45s both; }
.f-name { font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); margin-top: 6px; animation: wordIn .5s .9s both; }
.hl {
  padding: 0 .15em; font-weight: 700;
  background: linear-gradient(104deg, rgba(240, 213, 140, .95), rgba(212, 166, 58, .8)) no-repeat 0 55% / 0% 62%;
  animation: highlight .6s .75s cubic-bezier(.3, 0, .2, 1) forwards;
}
@keyframes highlight { to { background-size: 100% 62%; } }
.f-stamp { font-size: .9rem; margin-top: 4px; animation: stampIn .5s 1.25s cubic-bezier(.2, 1.6, .4, 1) both; mix-blend-mode: normal; background: rgba(15, 36, 32, .5); }

/* Cierre */
.end-title { font-family: var(--serif); font-weight: 900; font-size: clamp(2.3rem, 11vw, 3.4rem); line-height: 1; margin: 0; }
.end-note { font-size: 1.6rem; color: var(--gold-soft); transform: rotate(-2deg); margin: 0; animation: wordIn .5s both; animation-delay: var(--d); }
.end-btn { max-width: 280px; margin-top: 10px; animation: wordIn .5s both; animation-delay: var(--d); }

/* ---------- Grano de papel y pequeños desórdenes ---------- */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.paper { border-radius: 3px; }
.paper:nth-of-type(odd) { transform: rotate(-.4deg); }
.paper:nth-of-type(even) { transform: rotate(.35deg); }
.paper::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(220px 90px at 100% 100%, rgba(93, 81, 64, .08), transparent 70%);
}
.paper > * { position: relative; z-index: 1; }
.folder-tab { border-radius: 6px 6px 0 0; box-shadow: 0 -2px 3px rgba(0, 0, 0, .05); }
.agent::before {
  content: ''; position: absolute; top: -9px; left: 50%; width: 64px; height: 20px; z-index: 3;
  background: rgba(240, 213, 140, .55); transform: translateX(-50%) rotate(-3deg); box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.agent:nth-child(even)::before { transform: translateX(-50%) rotate(4deg); }
.masthead .kicker { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: .7rem; letter-spacing: .2em; }
.masthead .kicker::before, .masthead .kicker::after { content: ''; width: 14px; flex: none; border-top: 1px dashed rgba(212, 70, 58, .7); }

/* ---------- Ficha del evento (cartulina rayada) ---------- */
.ficha {
  position: relative; margin: 26px 10px 8px; padding: 18px 18px 44px 22px; color: var(--ink); transform: rotate(.8deg);
  background:
    linear-gradient(transparent 0 25px, rgba(48, 68, 107, .22) 25px 26px) 0 14px / 100% 26px,
    linear-gradient(#fbf4e0, #f3e8cc);
  border-top: 3px double var(--red); box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
}
.ficha::before { content: ''; position: absolute; left: 14px; top: 0; bottom: 0; border-left: 1px solid rgba(179, 38, 30, .35); }
.ficha .clip { top: -14px; right: 20px; }
.ficha-row { display: flex; align-items: baseline; gap: 10px; min-height: 26px; line-height: 26px; }
.ficha-row .k { font-family: var(--type); font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--red-dark); min-width: 92px; }
.ficha-row .v { font-family: var(--hand); font-size: 1.45rem; font-weight: 500; overflow-wrap: anywhere; }
.ficha .stamp { position: absolute; right: 16px; bottom: 9px; font-size: .68rem; opacity: .8; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
