@font-face { font-family: 'Rye'; src: url('fonts/Rye-Regular.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fjalla One'; src: url('fonts/FjallaOne-Regular.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/IBMPlexMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/IBMPlexMono-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
:root {
  --night: #120f24; --night2: #1b1733; --ink: #16121f; --paper: #f3e9d2; --paper2: #e9dcbd; --bone: #fbf5e6;
  --rosa: #CC006C; --orange: #F28C00; --yellow: #FFC20E; --teal: #00A6A6;
  /* text-on-cream variants (WCAG AA ≥4.5:1 on --paper); --rosa is darkened from #E4007C so bone-on-rosa is 5.1:1 */
  --teal-ink: #006E6E; --muted-ink: #5c4d33; --muted-night: #b9ad94;
  --display: 'Rye', 'Sancreek', Georgia, serif; --cond: 'Fjalla One', 'Oswald', Impact, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace; --body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body { background: var(--night); color: var(--paper); font-family: var(--body); line-height: 1.5; min-height: 100vh;
  background-image: radial-gradient(circle at 1px 1px, rgba(243,233,210,.07) 1px, transparent 0); background-size: 22px 22px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .9em; background: #e2d3ad; color: var(--ink); padding: 0 .3em; border: 1px solid #c9b88f; }

/* papel picado */
.picado-wrap { height: 78px; overflow: hidden; }
.picado { width: 100%; height: 78px; display: block; }
.flag { animation: sway 3.4s ease-in-out infinite alternate; animation-delay: var(--d); }
@keyframes sway { from { transform: rotate(-2.2deg); } to { transform: rotate(2.4deg) skewX(1deg); } }

/* petals */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.petal { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 60% 60% 60% 0; opacity: .8; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

main, .masthead, footer { position: relative; z-index: 1; max-width: 1140px; margin: 0 auto; padding: 0 20px; }

.masthead { text-align: center; padding-top: 18px; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow); }
h1 { font-family: var(--display); font-weight: 400; font-size: clamp(48px, 10vw, 112px); line-height: .95; margin: 10px 0 0; color: var(--paper); letter-spacing: .02em; text-shadow: 4px 4px 0 var(--rosa); }
.sub { font-family: var(--cond); font-size: clamp(20px, 3.4vw, 30px); letter-spacing: .12em; margin: 6px 0 12px; color: var(--orange); text-transform: uppercase; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip { font-family: var(--mono); font-size: 12px; padding: 4px 10px; border: 2px solid var(--ink); border-radius: 999px; font-weight: 600; }
.chip-model { background: var(--teal); color: var(--ink); }
.chip-chain { background: var(--yellow); color: var(--ink); }
.lede { max-width: 640px; margin: 14px auto 0; color: #d9cfb8; font-size: 16px; }

.section-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 34px 0 12px; font-family: var(--cond); font-weight: 400; text-transform: uppercase; letter-spacing: .06em; font-size: 26px; color: var(--yellow); }
.section-title small { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: #b9ad94; text-transform: none; }
.section-title span { border-bottom: 4px solid var(--rosa); }

/* summon bar */
.summon { margin-top: 28px; }
.summon-bar { display: flex; gap: 10px; background: var(--paper); padding: 10px; border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--orange); }
.summon-bar input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 15px; padding: 12px; border: 2px solid var(--ink); background: var(--bone); color: var(--ink); }
.btn { font-family: var(--cond); font-size: 17px; letter-spacing: .04em; text-transform: uppercase; border: 3px solid var(--ink); padding: 10px 16px; cursor: pointer; color: var(--bone); background: var(--ink); }
.btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: wait; transform: none; box-shadow: none; }
.btn-rosa { background: var(--rosa); }
.btn-teal { background: var(--teal); color: var(--ink); }
.btn-small { font-size: 15px; padding: 8px 14px; min-height: 44px; background: var(--orange); color: var(--ink); }
.samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.samples-label { font-family: var(--mono); font-size: 13px; color: var(--muted-night); }
.sample { font-family: var(--mono); font-size: 13px; background: transparent; color: var(--paper); border: 2px dashed var(--paper); padding: 5px 10px; cursor: pointer; min-height: 40px; }
.sample b { color: var(--yellow); font-weight: 600; }
.sample:hover { border-style: solid; border-color: var(--yellow); }

/* ritual */
.ritual { display: flex; gap: 24px; align-items: center; margin-top: 26px; padding: 18px; border: 2px dashed rgba(243,233,210,.35); }
.candles { display: flex; gap: 6px; }
.veladora { width: 44px; height: 88px; }
.flame, .flame-core { transform-origin: 30px 36px; animation: flicker .18s infinite alternate; animation-delay: calc(var(--i, 0) * .07s); }
.ofrenda-svg .flame { transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes flicker { from { transform: scale(1, 1) skewX(0); } to { transform: scale(.92, 1.08) skewX(3deg); } }
.steps { margin: 0; padding-left: 18px; font-family: var(--mono); font-size: 14px; }
.steps li { margin: 3px 0; }
.steps li.done { color: #9d927a; }
.steps li.now::after { content: ' …'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

.error { margin-top: 18px; background: var(--rosa); color: var(--bone); padding: 12px 16px; border: 3px solid var(--ink); font-family: var(--mono); font-size: 14px; }

/* grid */
.grid-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; align-items: start; }
.grid-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.grid-bottom .evidencia, .grid-bottom .familia { grid-column: 1 / -1; }
.grid-bottom:has(#familySec.hidden) .epitafio { grid-column: 1 / -1; }
.grid-bottom:has(#familySec.hidden) .ofrenda { max-width: 680px; }

/* loteria card */
.loteria { background: var(--paper); color: var(--ink); border: 4px solid var(--ink); padding: 10px; box-shadow: 8px 8px 0 var(--rosa); position: relative; }
.loteria .inner { border: 2px solid var(--ink); padding: 14px 14px 10px; position: relative; }
.lot-head { display: flex; justify-content: space-between; align-items: flex-start; font-family: var(--cond); }
.lot-num { font-family: var(--display); font-size: 34px; line-height: 1; }
.lot-kind { font-family: var(--mono); font-size: 12px; text-align: right; letter-spacing: .08em; }
.lot-art { display: flex; justify-content: center; margin: 4px 0 4px; }
.lot-name { text-align: center; background: var(--ink); color: var(--paper); font-family: var(--display); font-size: 26px; padding: 4px 8px; margin: 0 -14px 10px; overflow-wrap: anywhere; }
.fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.fields dt { font-family: var(--cond); text-transform: uppercase; letter-spacing: .04em; color: var(--muted-ink); font-size: 13px; padding-top: 2px; }
.fields dd { margin: 0; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.fields dd small { font-size: 12px; }
.cause { margin-top: 12px; border-top: 2px dashed var(--ink); padding-top: 10px; }
.cause h3 { margin: 0; font-family: var(--cond); font-weight: 400; font-size: 22px; color: var(--rosa); text-transform: uppercase; }
.cause p { margin: 4px 0 0; font-size: 14px; }
.factors { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.factors li { padding: 3px 0 3px 22px; position: relative; }
.factors li::before { content: ''; position: absolute; left: 4px; top: 9px; width: 10px; height: 10px; background: var(--orange); transform: rotate(45deg); }
.factors li.high::before { background: var(--rosa); }
.factors li.low::before { background: var(--teal); }
.confidence { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-family: var(--mono); font-size: 13px; }
.confidence { flex-wrap: wrap; }
.bar { flex: 1 1 120px; min-width: 100px; height: 10px; border: 2px solid var(--ink); background: var(--bone); }
.bar i { display: block; height: 100%; background: var(--rosa); }
.stamp small { display: block; font-family: var(--mono); font-size: 12px; text-align: center; }
.stamp { position: absolute; right: 14px; top: 120px; transform: rotate(-14deg); font-family: var(--display); color: var(--rosa); border: 4px double var(--rosa); padding: 6px 10px; font-size: 26px; background: rgba(243,233,210,.85); opacity: .92; pointer-events: none; }

/* seance */
.seance-box { background: var(--night2); border: 3px solid var(--paper); padding: 14px; box-shadow: 8px 8px 0 var(--teal); }
.ghost-head { display: flex; gap: 12px; align-items: center; border-bottom: 2px dashed rgba(243,233,210,.3); padding-bottom: 10px; }
.ghost-head h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; color: var(--yellow); }
.ghost-head p { margin: 0; font-family: var(--mono); font-size: 12px; color: #b9ad94; }
.calavera.ghost .pupil { animation: look 6s infinite; }
@keyframes look { 0%, 40% { transform: translate(0,0); } 50%, 70% { transform: translate(-5px, 3px); } 80%, 100% { transform: translate(0, 0); } }
.chat { min-height: 220px; max-height: 460px; overflow-y: auto; padding: 12px 2px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 12px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ghost { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); align-self: flex-start; border-radius: 2px 14px 14px 14px; }
.msg.user { background: var(--teal); color: var(--ink); align-self: flex-end; border: 2px solid var(--ink); border-radius: 14px 2px 14px 14px; }
.msg.notice { background: transparent; color: var(--yellow); border: 1px dashed var(--yellow); font-family: var(--mono); font-size: 12px; align-self: stretch; max-width: 100%; }
.msg .meta { display: block; margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted-ink); }
.msg.typing::after { content: '▍'; animation: blink 1s infinite; }
.cite { display: inline-block; font-family: var(--mono); font-size: 12px; line-height: 1; background: var(--rosa); color: var(--bone); padding: 2px 4px; margin: 0 1px; text-decoration: none; vertical-align: 2px; border-radius: 2px; }
.cite.bad { background: #6b5a3c; text-decoration: line-through; }
.cite.demo { vertical-align: 0; }
.uncited { text-decoration: underline dashed var(--orange); text-underline-offset: 3px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.preset { font-family: var(--mono); font-size: 13px; background: transparent; color: var(--paper); border: 2px solid var(--paper); padding: 6px 10px; cursor: pointer; min-height: 40px; }
.preset:hover { background: var(--paper); color: var(--ink); }
.preset:disabled { opacity: .4; cursor: wait; }
.chat-form { display: flex; gap: 8px; }
.chat-form input, .chat-form button { min-height: 44px; }
.summon-bar input, .summon-bar button { min-height: 44px; }
.chat-form input { flex: 1; min-width: 0; font-family: var(--body); font-size: 15px; padding: 10px; border: 2px solid var(--ink); background: var(--bone); color: var(--ink); }
.fine { font-family: var(--mono); font-size: 12.5px; color: var(--muted-night); margin: 10px 0 0; }
.paper-card .fine, .loteria .fine, .fine.on-paper { color: var(--muted-ink); }

/* paper cards */
.paper-card { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); padding: 16px; box-shadow: 6px 6px 0 var(--orange); }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; border-left: 3px dotted var(--ink); }
.timeline li { position: relative; padding: 6px 0 10px 30px; }
.timeline li::before { content: ''; position: absolute; left: 0; top: 11px; width: 14px; height: 14px; border-radius: 50%; background: var(--teal); border: 2px solid var(--ink); }
.timeline li.severe::before { background: var(--rosa); width: 18px; height: 18px; left: -2px; top: 9px; }
.timeline .when { font-family: var(--mono); font-size: 12px; color: var(--muted-ink); }
.timeline .what { font-family: var(--cond); font-size: 19px; text-transform: uppercase; letter-spacing: .03em; }
.timeline .det { font-size: 14px; }
.chart { width: 100%; height: auto; background: var(--ink); border: 2px solid var(--ink); }
.ch-label { font-family: var(--mono); font-size: 14px; } /* SVG user units: the chart scales, so labels are bumped on small screens below */

/* ofrenda */
.ofrenda { position: relative; background: var(--night2); border: 3px solid var(--paper); padding: 18px 16px 12px; text-align: center; box-shadow: 6px 6px 0 var(--yellow); }
.frame { background: var(--paper); color: var(--ink); border: 6px solid var(--orange); outline: 3px solid var(--ink); margin: 0 auto; max-width: 380px; padding: 14px; }
.frame p { margin: 0; font-family: var(--display); font-size: 19px; line-height: 1.35; white-space: pre-line; }
.ofrenda-svg { width: 100%; max-width: 420px; display: block; margin: -2px auto 10px; }

.family { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 13px; }
.family li { padding: 6px 0; border-bottom: 1px dashed #b9ad94; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.family .hp { color: var(--rosa); font-weight: 600; }

.evidence { margin: 0; padding-left: 0; list-style: none; font-size: 13px; }
.evidence li { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #c9bb98; }
.evidence li:target, .evidence li.flash { background: #ffe9a6; }
.evidence .eid { font-family: var(--mono); font-weight: 600; color: var(--rosa); }
.evidence .elabel { font-family: var(--cond); text-transform: uppercase; font-size: 15px; letter-spacing: .03em; }
.evidence .edet { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.evidence a, .family a, .fields a { color: var(--teal-ink); font-weight: 600; }

.alive .paper-card { box-shadow: 6px 6px 0 var(--teal); }
.alive h3 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 0 0 6px; color: var(--teal-ink); }

.why-card p { margin: 0 0 10px; }
.tombs { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.tomb-item { flex: 0 0 112px; text-align: center; background: none; border: 0; color: var(--paper); cursor: pointer; padding: 0; font: inherit; }
.tomb { width: 80px; height: 96px; display: block; margin: 0 auto; }
.tomb-item .sym { font-family: var(--cond); font-size: 16px; display: block; overflow-wrap: anywhere; }
.tomb-item .why { font-family: var(--mono); font-size: 12px; color: var(--muted-night); display: block; }
.tomb-item.alive .sym { color: var(--teal); }

footer { text-align: center; padding: 40px 20px 50px; border-top: 2px dashed rgba(243,233,210,.25); margin-top: 40px; font-family: var(--cond); letter-spacing: .04em; font-size: 16px; }

/* re-summoning the token already on screen still visibly reloads the card */
.loteria.reloaded { animation: resummon .9s ease-out; }
@keyframes resummon { 0% { box-shadow: 0 0 0 6px var(--yellow), 8px 8px 0 var(--rosa); transform: translateY(-4px); } 100% { box-shadow: 8px 8px 0 var(--rosa); transform: none; } }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* phones / touch: every tap target at least 44×44 px */
@media (max-width: 520px), (pointer: coarse) {
  .sample, .preset { min-height: 44px; }
  a.cite { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; font-size: 13px; margin: 2px; border-radius: 4px; }
  a.tap { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; margin: 0 -4px; }
  .evidence .edet a.tap { min-width: 44px; }
}

@media (max-width: 880px) {
  .grid-top, .grid-bottom { grid-template-columns: minmax(0, 1fr); }
  .ch-label { font-size: 20px; }
  .stamp { top: 96px; font-size: 22px; }
}
@media (max-width: 520px) {
  main, .masthead, footer { padding: 0 14px; }
  .summon-bar { flex-direction: column; }
  .ritual { flex-direction: column; align-items: flex-start; }
  .lot-name { font-size: 22px; }
  .fields { grid-template-columns: 1fr; gap: 0 0; }
  .fields dd { margin-bottom: 6px; }
  .section-title { font-size: 22px; }
  .ch-label { font-size: 26px; }
  .loteria, .paper-card, .seance-box { box-shadow: 4px 4px 0 var(--rosa); }
}
@media (prefers-reduced-motion: reduce) { .flag, .petal, .flame, .flame-core, .pupil { animation: none !important; } }
