:root {
  --ink: #0b0612;
  --ink-2: #140b1f;
  --plum: #2a1236;
  --velvet: #4a1a4f;
  --paper: #f3e6d0;
  --paper-dim: #c9b79c;
  --gold: #d9a74a;
  --gold-hi: #f6d58c;
  --pink: #ff3fae;
  --cyan: #35d6ff;
  --violet: #a65cff;
  --amber: #ffb54a;
  --red: #ff4a5a;
  --line: rgba(246, 213, 140, 0.22);
  --glass: rgba(18, 9, 28, 0.62);
  --f-title: 'Cinzel Decorative', 'Cinzel', serif;
  --f-caps: 'Cinzel', serif;
  --f-text: 'Cormorant Garamond', Georgia, serif;
  --f-neon: 'Tilt Neon', system-ui, sans-serif;
  --f-hand: 'Caveat', cursive;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); overflow: hidden; }
body { font-family: var(--f-text); font-size: 18px; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; border-radius: 6px; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .9s ease, visibility 0s linear .9s; }
.screen.is-on { opacity: 1; visibility: visible; transition: opacity .9s ease, visibility 0s; }

.brand { font-family: var(--f-title); font-weight: 700; letter-spacing: .06em; color: var(--gold-hi);
  text-shadow: 0 0 18px rgba(255, 181, 74, .35), 0 2px 0 #5a3410; }
.brand.sm { font-size: 22px; white-space: nowrap; }
@media (max-width: 600px) { .brand.sm { font-size: 17px; } .g-life { display: none; } }
.eyebrow { font-family: var(--f-caps); font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold); }

/* ícones desenhados em CSS mask (SVG inline) */
.ico { display: inline-block; width: 20px; height: 20px; background: currentColor; flex: none;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ico-sound { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z' fill='black'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E"); }
.ico-mute, .ico-sound-off { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z' fill='black'/%3E%3Cpath d='M17 9l5 6M22 9l-5 6'/%3E%3C/svg%3E"); }
.ico-full { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5'/%3E%3C/svg%3E"); }
.ico-mural { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='M3 15l5-5 4 4 3-3 6 6'/%3E%3Ccircle cx='15.500' cy='8.500' r='1.300'/%3E%3C/svg%3E"); }
.ico-copia { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='8' y='8' width='12' height='13' rx='2'/%3E%3Cpath d='M16 8V5a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h2'/%3E%3C/svg%3E"); }
.ico-close { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
.ico-door { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M5 21V5a7 3 0 0 1 14 0v16z'/%3E%3Ccircle cx='15' cy='13' r='1.2' fill='black'/%3E%3C/svg%3E"); }
.ico-voice { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 12c3-1 4.8-4.6 7-4.6 1.1 0 1.7.7 2.5.7s1.4-.7 2.5-.7c2.2 0 4 3.6 7 4.6-3 3.6-6 5.4-9.5 5.4S5.500 15.600 2.500 12z'/%3E%3Cpath d='M2.5 12c5.500 1 13.500 1 19 0'/%3E%3C/svg%3E"); }
.ico-voice-off { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 12c3-1 4.8-4.6 7-4.6 1.1 0 1.7.7 2.5.7s1.4-.7 2.5-.7c2.2 0 4 3.6 7 4.6-3 3.6-6 5.4-9.5 5.4S5.500 15.600 2.500 12z'/%3E%3Cpath d='M2.5 12c5.500 1 13.500 1 19 0'/%3E%3Cpath d='M4 4l16 16'/%3E%3C/svg%3E"); }
.ico-back { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 26px;
  font-family: var(--f-caps); font-size: 15px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  border-radius: 999px; transition: transform .25s ease, box-shadow .25s ease, background .25s ease, color .25s; }
.btn-primary { color: #1b0c05; background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, #a8742a);
  box-shadow: 0 0 0 1px rgba(255, 230, 170, .5) inset, 0 10px 30px rgba(255, 170, 60, .25), 0 0 40px rgba(255, 63, 174, .18); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(255, 240, 200, .8) inset, 0 14px 36px rgba(255, 170, 60, .35), 0 0 60px rgba(255, 63, 174, .3); }
.btn-ghost { color: var(--paper); border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.btn-ghost:hover { border-color: rgba(246, 213, 140, .6); color: var(--gold-hi); }
.btn:active { transform: translateY(1px) scale(.98); }

.icon-btn { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(8px); color: var(--paper);
  transition: border-color .2s, color .2s, transform .2s; }
.icon-btn:hover { border-color: rgba(246, 213, 140, .6); color: var(--gold-hi); transform: translateY(-1px); }
.icon-btn[aria-pressed="false"] { color: var(--paper-dim); }

/* ---------- loader ---------- */
#loader { display: grid; place-content: center; justify-items: center; gap: 22px; padding: 24px;
  background: radial-gradient(60% 50% at 50% 45%, #241034 0%, var(--ink) 70%); }
.loader-orb { --d: clamp(170px, 26vmin, 250px); --p: 0; position: relative; width: calc(var(--d) * 1.1); height: calc(var(--d) * 1.4); display: grid; justify-items: center; animation: loFloat 6s ease-in-out infinite; }
@keyframes loFloat { 50% { transform: translateY(-6px); } }
/* luz da bola no escuro: cresce com o carregamento */
.lo-halo { position: absolute; left: 50%; top: calc(var(--d) * .5); width: calc(var(--d) * 2.2); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(176, 108, 255, calc(.22 + var(--p) * .3)), rgba(120, 60, 200, .08) 55%, transparent);
  animation: loHalo 3.2s ease-in-out infinite; transition: background .6s; }
@keyframes loHalo { 50% { transform: translate(-50%, -50%) scale(1.06); } }
.lo-ball { position: relative; width: var(--d); aspect-ratio: 1; border-radius: 50%; overflow: hidden; z-index: 1; background: #12051f;
  box-shadow: 0 0 calc(30px + var(--p) * 40px) rgba(166, 92, 255, calc(.35 + var(--p) * .35)), 0 18px 40px rgba(0, 0, 0, .6); }
.lo-ball canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.lo-mist { position: absolute; inset: -30%; pointer-events: none; mix-blend-mode: screen; opacity: .35;
  background: conic-gradient(from 0deg, transparent, rgba(255, 140, 230, .5), transparent 40%, rgba(120, 220, 255, .35), transparent 70%); filter: blur(14px); animation: spin 9s linear infinite; }
.lo-mist.b { animation-duration: 14s; animation-direction: reverse; opacity: .22; }
/* o vidro: brilho de janela no alto, borda escura e reflexo embaixo */
.lo-glass { position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(ellipse 34% 16% at 50% 9%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 70%),
    radial-gradient(ellipse 12% 22% at 18% 34%, rgba(255, 255, 255, .22), transparent 70%),
    radial-gradient(ellipse 50% 14% at 50% 92%, rgba(255, 210, 255, .18), transparent 70%),
    radial-gradient(circle at 50% 50%, transparent 62%, rgba(20, 4, 36, .35) 82%, rgba(8, 2, 16, .8) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 230, 255, .18), inset 0 -10px 30px rgba(0, 0, 0, .35); }
.lo-glass::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255, 245, 220, .9), rgba(255, 220, 160, 0) 60%); opacity: 0; }
.loader-orb.done .lo-glass::after { animation: loFlash .9s ease-out; }
@keyframes loFlash { 30% { opacity: .85; } 100% { opacity: 0; } }
/* medidas de tools/build_bolabase.py: a base encaixa na bola, com as garras por cima do vidro */
.lo-stand { position: absolute; z-index: 2; left: calc(50% - var(--d) * .4816); top: calc(var(--d) * .7805); width: calc(var(--d) * .967); filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .6)); }
@media (prefers-reduced-motion: reduce) { .loader-orb, .lo-halo, .lo-mist { animation: none; } }
.loader-line { font-family: var(--f-text); font-style: italic; font-size: 22px; color: var(--paper); min-height: 1.4em; max-width: min(88vw, 560px); text-align: center; text-wrap: balance; transition: opacity .24s ease; }
.loader-line.off { opacity: 0; }
@media (max-width: 600px) { .loader-line { min-height: 2.8em; font-size: 20px; } }
.loader-pct { font-family: var(--f-caps); font-size: 13px; letter-spacing: .3em; color: var(--paper-dim); }

/* ---------- portão ---------- */
/* a entrada é a própria rua, fora de foco, com o letreiro da casa aceso na frente */
#gate { display: grid; place-items: center; padding: 24px; background: var(--ink); overflow: hidden; z-index: 5; }
#gate::before { content: ""; position: absolute; inset: -30px; background: url("../assets/fundo01-key.webp") center / cover; filter: blur(4px) brightness(.8) saturate(1.2); }
#gate::after { content: ""; position: absolute; inset: 0; background: radial-gradient(70% 72% at 50% 46%, rgba(40, 10, 50, .5), rgba(11, 6, 18, .34) 58%, rgba(11, 6, 18, .78)); }
.gate-card { position: relative; z-index: 1; max-width: 640px; text-align: center; display: grid; gap: 18px; justify-items: center; }
.gate-card .eyebrow { color: var(--gold-hi); text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
.gate-sign { position: relative; display: grid; justify-items: center; width: min(560px, 100%); padding: 34px 44px 30px; font-family: var(--f-neon); font-weight: 400; line-height: 1; border-radius: 18px;
  background: radial-gradient(120% 90% at 50% 50%, rgba(40, 14, 48, .92), rgba(9, 4, 12, .98) 70%), repeating-linear-gradient(90deg, rgba(255, 255, 255, .015) 0 2px, transparent 2px 6px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), 0 0 90px rgba(255, 63, 174, .3); }
.gs-tube { position: absolute; border: 3px solid #ffe9f6; border-radius: 18px; inset: 8px; --tc: var(--pink); box-shadow: 0 0 2px #fff, 0 0 6px var(--tc), 0 0 14px var(--tc), inset 0 0 6px var(--tc), inset 0 0 12px var(--tc); }
.gs-tube.b { inset: 20px; border-radius: 11px; --tc: var(--cyan); }
.gs-eye { width: 92px; margin-bottom: 8px; overflow: visible; }
.gs-eye .t { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gs-eye .t-glow { stroke: var(--sc); stroke-width: 7; opacity: .45; }
.gs-eye .t-mid { stroke: var(--sc); stroke-width: 3.6; }
.gs-eye .t-core { stroke: #fff6fb; stroke-width: 1.4; }
.gs-row { display: flex; justify-content: center; white-space: nowrap; }
.gs-row.top { --lc: var(--cyan); font-size: clamp(30px, 6.2vw, 46px); letter-spacing: .24em; margin-right: -.24em; margin-bottom: 8px; }
.gs-row.main { --lc: var(--pink); font-size: clamp(66px, 15vw, 116px); letter-spacing: .05em; margin-right: -.05em; }
.gs-row .l { display: inline-block; color: #fff2fb; text-shadow: 0 0 1px #fff, 0 0 4px var(--lc), 0 0 10px var(--lc), 0 0 22px var(--lc); }
/* o letreiro acende letra por letra, como os da rua */
#gate.is-on .gs-tube, #gate.is-on .gs-eye { animation: gsLuz .9s steps(1) both; }
#gate.is-on .gs-tube.b { animation-delay: .18s; }
#gate.is-on .gs-eye { animation-delay: .34s; }
#gate.is-on .gs-row .l { animation: gsLetra .8s steps(1) both; animation-delay: calc(var(--i) * .09s + .1s); }
#gate.is-on .gs-row.main .l:nth-child(2) { animation: gsLetra .8s steps(1) both calc(var(--i) * .09s + .1s), gsZumbe 8s steps(1) 4s infinite; }
@keyframes gsLuz { 0%, 28%, 52% { opacity: .1; } 16%, 40%, 70%, 100% { opacity: 1; } }
@keyframes gsLetra { 0%, 26%, 54% { color: rgba(255, 215, 235, .13); text-shadow: none; } 14%, 40%, 72%, 100% { color: #fff2fb; } }
@keyframes gsZumbe { 0%, 90%, 92.5%, 95%, 100% { opacity: 1; } 91%, 94% { opacity: .25; } }
.gate-sub { font-size: 22px; line-height: 1.4; color: var(--paper); white-space: nowrap; text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
.gate-sub span { display: block; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 6px; }
.gate-actions .btn { --tc: var(--pink); color: #fff2fb; font-family: var(--f-neon); font-weight: 400; font-size: 17px; letter-spacing: .1em; background: rgba(9, 4, 12, .78); border: 2px solid #ffe9f6;
  text-shadow: 0 0 8px var(--tc); box-shadow: 0 0 2px #fff, 0 0 6px var(--tc), 0 0 16px var(--tc), inset 0 0 6px var(--tc); }
.gate-actions .btn-ghost { --tc: var(--cyan); }
.gate-actions .btn:hover { transform: translateY(-2px); color: #fff; box-shadow: 0 0 2px #fff, 0 0 10px var(--tc), 0 0 30px var(--tc), inset 0 0 10px var(--tc); }
.gate-tip { font-family: var(--f-hand); font-size: 23px; color: var(--paper); text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
@media (max-width: 900px) { #gate::before { background-image: url("../assets/fundo01-key-1600.webp"); } }
@media (max-width: 600px) { .gate-sign { padding: 28px 30px 24px; } .gs-eye { width: 74px; } .gate-sub { font-size: clamp(14px, 4.6vw, 20px); } .gate-actions .btn { width: 100%; } .gate-actions { width: 100%; } }
@media (prefers-reduced-motion: reduce) { #gate.is-on .gs-tube, #gate.is-on .gs-eye, #gate.is-on .gs-row .l, #gate.is-on .gs-row.main .l:nth-child(2) { animation: none; } }

/* ---------- transição pela porta ---------- */
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 30;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 50%), #fff 0%, #f2c8ff 18%, #8a3dff 45%, #1a0828 80%); }
#passage { display: grid; place-content: center; justify-items: center; gap: 40px; background: radial-gradient(60% 60% at 50% 45%, #2b0f3c, var(--ink) 75%); z-index: 4; }
.deck { position: relative; width: 120px; height: 206px; }
.tcard { position: absolute; inset: 0; border-radius: 10px; background: url("../assets/tarot/verso.webp") center / cover no-repeat; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
#passage.is-on .tcard { animation: shuffle 1.4s cubic-bezier(.6, 0, .3, 1) infinite; }
#passage.is-on .tcard:nth-child(2) { animation-delay: .12s; }
#passage.is-on .tcard:nth-child(3) { animation-delay: .24s; }
#passage.is-on .tcard:nth-child(4) { animation-delay: .36s; }
#passage.is-on .tcard:nth-child(5) { animation-delay: .48s; }
@keyframes shuffle {
  0%, 100% { transform: translateX(0) rotate(0); }
  30% { transform: translateX(-90px) rotate(-14deg); }
  55% { transform: translateX(90px) rotate(12deg) translateY(-6px); }
  80% { transform: translateX(0) rotate(0) translateY(-14px); }
}
.passage-line { font-style: italic; font-size: 24px; text-align: center; padding: 0 24px; }

/* ---------- modais e toast ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px;
  background: rgba(8, 3, 14, .72); backdrop-filter: blur(6px); animation: fadeIn .3s ease; }
.modal-card { position: relative; width: min(560px, 100%); max-height: min(80vh, 720px); overflow: auto; padding: 36px 32px 30px;
  border-radius: 18px; background: linear-gradient(180deg, #1d0e2a, #120819); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 0 6px rgba(20, 8, 30, .9), 0 0 0 7px rgba(246, 213, 140, .25);
  animation: rise .4s cubic-bezier(.2, .8, .2, 1); }
.modal-card h2 { font-family: var(--f-caps); font-size: 24px; letter-spacing: .08em; color: var(--gold-hi); margin-bottom: 14px; padding-right: 40px; }
.modal-card p { font-size: 19px; line-height: 1.5; margin-bottom: 12px; }
.modal-card ol, .modal-card ul { padding-left: 22px; margin: 0 0 14px; font-size: 19px; line-height: 1.5; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.life-row { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.life-row b { font-family: var(--f-caps); color: var(--gold-hi); font-size: 15px; letter-spacing: .06em; }
.life-row span { font-size: 17px; color: var(--paper-dim); }
.life-row .age { grid-row: span 2; font-family: var(--f-caps); font-size: 26px; color: var(--paper); min-width: 2.4em; text-align: center; }
.empty { font-style: italic; color: var(--paper-dim); }

#toast { position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 50; opacity: 0; pointer-events: none;
  padding: 14px 22px; border-radius: 999px; background: rgba(20, 8, 30, .92); border: 1px solid var(--line); font-size: 18px;
  transition: opacity .3s, transform .3s; width: max-content; max-width: min(calc(100vw - 32px), 620px); text-align: center; text-wrap: balance; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; }
}

/* convite para a tela cheia, junto do convite para o som */
.gate-cheia { display: inline-flex; align-items: center; gap: 9px; padding: 8px 14px; border-radius: 99px; font-family: var(--f-text); font-size: 18px; color: var(--paper); text-shadow: 0 1px 6px rgba(0, 0, 0, .9); cursor: pointer; }
.gate-cheia b { font-weight: 500; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(246, 213, 140, .5); }
.gate-cheia:hover, .gate-cheia:focus-visible { color: var(--gold-hi); }
.gate-cheia[hidden] { display: none; }
