/* The Fae Oath-Weaver's Apothecary — v2 */
:root {
  --midnight: #0F101A;
  --plum: #1B192B;
  --plum-2: #26223B;
  --glass: rgba(27, 25, 43, 0.86);
  --gold: #D4AF37;
  --gold-soft: #F3E5AB;
  --cyan: #64DFDF;
  --amethyst: #B07BEA;
  --crimson: #E0335F;
  --ember: #E8A04B;
  --parchment: #F4EFE6;
  --muted: #CBC0D6;
  --line: rgba(212, 175, 55, 0.28);
  --radius: 16px;
  --font-display: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --font-head: 'Cinzel', Georgia, serif;
  --font-story: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Plus Jakarta Sans', system-ui, sans-serif;
  --story-size: 21px;
  --ui-size: 15px;
}
html[data-text='l'] { --story-size: 24px; --ui-size: 17px; }
html[data-text='xl'] { --story-size: 27px; --ui-size: 19px; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--midnight);
  color: var(--parchment);
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; border-radius: 8px; }
::selection { background: rgba(212, 175, 55, .35); }

/* ───────── scene ───────── */
#scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.scene-bg {
  position: absolute; inset: -4%;
  background: radial-gradient(ellipse at 50% 20%, #2b2347 0%, #15142a 55%, #0b0b14 100%);
  background-size: cover; background-position: center;
  transform: translate3d(var(--px, 0), var(--py, 0), 0) scale(1.04);
  transition: opacity .9s ease, transform .6s ease-out;
  filter: saturate(1.05) brightness(.62);
}
.scene-bg.has-img { filter: saturate(1.05) brightness(.5); }
.scene-candle {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 78%, rgba(255, 176, 80, .20), transparent 55%),
              radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(5, 5, 12, .85) 100%);
  animation: candle 4.5s ease-in-out infinite;
}
@keyframes candle { 0%, 100% { opacity: .92 } 23% { opacity: 1 } 41% { opacity: .84 } 63% { opacity: .97 } 81% { opacity: .88 } }
#motes { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ───────── HUD ───────── */
#hud {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  background: linear-gradient(to bottom, rgba(15, 16, 26, .96), rgba(15, 16, 26, .82));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.hud-left { display: flex; flex-direction: column; min-width: 0; }
.hud-night { font-family: var(--font-head); color: var(--gold); font-weight: 700; letter-spacing: .08em; font-size: 15px; }
.hud-name { color: var(--muted); font-size: 14px; font-style: italic; font-family: var(--font-story); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.hud-meters { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: center; flex-wrap: wrap; }
.meter { display: flex; flex-direction: column; gap: 3px; min-width: 64px; }
.meter-label { font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.meter-bar { display: block; height: 6px; width: 72px; background: rgba(255, 255, 255, .08); border-radius: 99px; overflow: hidden; }
.meter-bar i { display: block; height: 100%; width: 50%; border-radius: 99px; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.meter-veil i { background: linear-gradient(90deg, #2c9c9c, var(--cyan)); }
.meter-memory i { background: linear-gradient(90deg, #7442b8, var(--amethyst)); }
.meter-trust i { background: linear-gradient(90deg, #9a7a1c, var(--gold)); }
.meter.pulse .meter-bar { box-shadow: 0 0 12px currentColor; }
.threads { display: flex; flex-direction: column; gap: 2px; }
.thread { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.thread svg { width: 84px; height: 14px; overflow: visible; }
.thread path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 130; stroke-dashoffset: calc(130 - 130 * var(--a, .1)); transition: stroke-dashoffset 1.2s ease, filter 1.2s ease; }
.thread-caelum path { stroke: var(--cyan); filter: drop-shadow(0 0 calc(var(--a, .1) * 6px) var(--cyan)); }
.thread-malakor path { stroke: var(--ember); filter: drop-shadow(0 0 calc(var(--a, .1) * 6px) var(--ember)); }
.thread.flutter { animation: flutter 1.4s ease-in-out 2; }
@keyframes flutter { 30% { transform: scale(1.12) } 60% { transform: scale(1.04) } }
.hud-actions { display: flex; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--plum); border: 1px solid var(--line); border-radius: 12px; color: var(--gold-soft);
  transition: border-color .2s, transform .2s;
}
.icon-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.muted .snd-on, body:not(.muted) .snd-off { display: none; }

@media (max-width: 640px) {
  .hud-meters { order: 3; flex-basis: 100%; justify-content: space-between; gap: 8px; }
  .meter { min-width: 0; }
  .meter-bar { width: 52px; }
  .thread svg { width: 56px; }
}

/* ───────── layout ───────── */
#view { position: relative; z-index: 2; max-width: 980px; margin: 0 auto; padding: 24px 16px 96px; outline: none; }
.panel {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .04);
  backdrop-filter: blur(14px); padding: 24px;
}
@media (min-width: 720px) { .panel { padding: 32px; } }
.stack > * + * { margin-top: 16px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.grid-2 { display: grid; gap: 20px; }
@media (min-width: 820px) { .grid-2 { grid-template-columns: minmax(260px, 340px) 1fr; align-items: start; } }

.eyebrow { font-family: var(--font-head); font-size: 14px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
h1, h2, h3 { font-family: var(--font-head); color: var(--gold-soft); margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-family: var(--font-display); font-size: clamp(28px, 6vw, 46px); letter-spacing: .02em; text-shadow: 0 2px 24px rgba(212, 175, 55, .3); }
h2 { font-size: clamp(22px, 4.2vw, 30px); }
h3 { font-size: 19px; }
.story { font-family: var(--font-story); font-size: var(--story-size); font-weight: 500; line-height: 1.6; color: var(--parchment); }
.story p { margin: 0 0 .8em; }
.story p:last-child { margin-bottom: 0; }
.story em, .quote { font-style: italic; }
.quote { font-family: var(--font-story); font-size: var(--story-size); font-weight: 600; color: var(--gold-soft); border-left: 3px solid var(--gold); padding: 6px 0 6px 16px; margin: 0; }
.small { font-size: 14px; color: var(--muted); }
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); border: 0; margin: 20px auto; max-width: 240px; opacity: .7; }

/* ink reveal */
.ink .w { opacity: 0; filter: blur(4px); display: inline-block; animation: ink .7s ease forwards; }
@keyframes ink { to { opacity: 1; filter: blur(0); } }

/* ───────── buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px; border-radius: 12px;
  font-weight: 700; font-size: var(--ui-size); letter-spacing: .02em;
  border: 1px solid var(--gold); background: linear-gradient(180deg, #e2c25a, #b8932a); color: #1a1426;
  box-shadow: 0 6px 24px rgba(212, 175, 55, .25); transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(212, 175, 55, .38); }
.btn:active { transform: translateY(1px); }
.btn:disabled { filter: grayscale(.8) brightness(.6); cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--gold-soft); box-shadow: none; border-color: var(--line); }
.btn.ghost:hover { border-color: var(--gold); }
.btn.danger { background: transparent; color: #ff9fb6; border-color: rgba(224, 51, 95, .5); box-shadow: none; }
.btn.wide { width: 100%; }

/* tone choices */
.choices { display: grid; gap: 12px; }
.choice {
  text-align: left; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(15, 16, 26, .66); transition: border-color .2s, background .2s, transform .15s;
  display: grid; gap: 6px;
}
.choice:hover { transform: translateY(-1px); background: rgba(38, 34, 59, .85); }
.choice .tone { font-size: 14px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.choice .txt { font-family: var(--font-story); font-size: calc(var(--story-size) - 1px); font-weight: 600; line-height: 1.45; }
.choice[data-tone='Defiant'] .tone { color: #ff8aa6; }
.choice[data-tone='Merciful'] .tone { color: var(--cyan); }
.choice[data-tone='Cunning'] .tone { color: #cfa7ff; }
.choice[data-tone='Defiant']:hover { border-color: var(--crimson); }
.choice[data-tone='Merciful']:hover { border-color: var(--cyan); }
.choice[data-tone='Cunning']:hover { border-color: var(--amethyst); }
.choice.secret { border-color: var(--gold); background: linear-gradient(135deg, rgba(212, 175, 55, .18), rgba(15, 16, 26, .7)); box-shadow: 0 0 30px rgba(212, 175, 55, .25); }
.choice .favored { font-size: 14px; color: var(--gold-soft); font-weight: 600; letter-spacing: 0; text-transform: none; }
.tag-risk { font-size: 14px; color: var(--ember); font-weight: 600; letter-spacing: 0; text-transform: none; }

.reply { border-radius: 14px; padding: 16px 18px; background: rgba(212, 175, 55, .08); border: 1px solid var(--line); }
.whispers { display: grid; gap: 6px; }
.whisper-line { font-family: var(--font-story); font-style: italic; font-weight: 600; font-size: 19px; color: var(--gold-soft); opacity: 0; animation: rise .8s ease forwards; }
.whisper-line::before { content: '✦ '; color: var(--gold); font-style: normal; }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* ───────── portraits ───────── */
.portrait {
  position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 4 / 5; width: 100%;
  border: 1px solid var(--line); background: #1b1830; box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.portrait > img, .portrait > video, .portrait > .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.portrait > video { opacity: 0; transition: opacity 1s ease; }
.portrait > video.live { opacity: 1; }
.portrait .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 16px 14px; background: linear-gradient(to top, rgba(10, 9, 18, .95), transparent); }
.portrait .cap b { display: block; font-family: var(--font-head); font-size: 20px; color: var(--gold-soft); }
.portrait .cap span { font-size: 14px; color: var(--muted); font-style: italic; }
.ph { display: grid; place-items: center; }
.ph svg { width: 100%; height: 100%; }
@media (max-width: 819px) { .grid-2 .portrait { max-width: 300px; margin: 0 auto; aspect-ratio: 4 / 4.4; } }

/* ───────── tarot ───────── */
.tarot-wrap { perspective: 1200px; width: min(280px, 72vw); margin: 0 auto; }
.tarot { position: relative; aspect-ratio: 2 / 3; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.3, 1.4, .4, 1); cursor: pointer; }
.tarot.flipped { transform: rotateY(180deg); }
/* Reversed cards stay readable: a crimson ribbon and aura mark them instead of turning the art upside down. */
.tarot.reversed .front { box-shadow: 0 0 0 2px var(--crimson), 0 0 40px rgba(224, 51, 95, .55); border-color: var(--crimson); }
.tarot.reversed .front::after { content: 'Reversed ☾'; position: absolute; top: 7%; left: -2px; right: -2px; padding: 4px 0; text-align: center; background: linear-gradient(90deg, transparent, rgba(157, 18, 56, .92) 15%, rgba(157, 18, 56, .92) 85%, transparent); color: #ffe3ea; font-family: var(--font-head); font-weight: 700; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; }
.tarot-mini .tarot.reversed .front::after { content: '☾'; top: 4px; left: auto; right: 4px; width: 26px; padding: 2px 0; border-radius: 50%; background: rgba(157, 18, 56, .92); }
.tarot .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; overflow: hidden; border: 2px solid var(--gold); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.tarot .back { background: radial-gradient(circle, #3a2a5e, #15122a 70%); display: grid; place-items: center; }
.tarot .back svg { width: 70%; }
.tarot .front { transform: rotateY(180deg); background: #1b1830; }
.tarot .front img, .tarot .front .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tarot .plaque { position: absolute; left: 10%; right: 10%; bottom: 5%; padding: 6px 8px; text-align: center; background: rgba(10, 9, 18, .82); border: 1px solid var(--gold); border-radius: 8px; font-family: var(--font-head); font-weight: 700; color: var(--gold-soft); font-size: 14px; line-height: 1.2; }
.tarot-glow { position: absolute; inset: -20%; background: radial-gradient(circle, rgba(212, 175, 55, .55), transparent 60%); opacity: 0; pointer-events: none; }
.tarot.flipped .tarot-glow { animation: glow 1.6s ease .5s; }
@keyframes glow { 0% { opacity: 0 } 30% { opacity: 1 } 100% { opacity: 0 } }
.tarot-mini { width: 92px; flex: none; }
.tarot-mini .tarot { cursor: default; }

/* ───────── dice ───────── */
.dice-zone { display: grid; place-items: center; gap: 10px; padding: 12px 0; }
.die { width: 84px; height: 84px; position: relative; transform-style: preserve-3d; transition: transform 1.4s cubic-bezier(.2, .9, .3, 1.1); }
.die .f { position: absolute; inset: 0; border-radius: 14px; background: linear-gradient(145deg, #f7ecc6, #d9b85a); border: 2px solid #8a6a16; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 12px; box-shadow: inset 0 0 12px rgba(0, 0, 0, .25); }
.die .f i { width: 14px; height: 14px; border-radius: 50%; background: #3b1630; place-self: center; }
.die .f1 { transform: rotateY(0) translateZ(42px); } .die .f6 { transform: rotateY(180deg) translateZ(42px); }
.die .f2 { transform: rotateY(90deg) translateZ(42px); } .die .f5 { transform: rotateY(-90deg) translateZ(42px); }
.die .f3 { transform: rotateX(90deg) translateZ(42px); } .die .f4 { transform: rotateX(-90deg) translateZ(42px); }
.die.bounce { animation: bounce 1.4s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bounce { 0% { translate: 0 -70px } 40% { translate: 0 0 } 55% { translate: 0 -18px } 70% { translate: 0 0 } 82% { translate: 0 -5px } 100% { translate: 0 0 } }
.roll-math { font-size: 16px; color: var(--muted); }
.roll-math b { color: var(--gold-soft); }
.outcome { font-family: var(--font-head); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 16px; }
.outcome.success { color: #8ef0c4; } .outcome.mixed { color: var(--gold-soft); } .outcome.fail { color: #ff9fb6; }

/* ───────── distillation ───────── */
.codex { display: grid; gap: 14px; }
.picker { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .picker { grid-template-columns: repeat(3, 1fr); } }
.ing {
  padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(15, 16, 26, .66); text-align: left;
  display: grid; gap: 4px; transition: border-color .2s, box-shadow .2s, transform .15s;
}
.ing b { font-family: var(--font-head); color: var(--gold-soft); font-size: 16px; }
.ing span { font-size: 14px; color: var(--muted); line-height: 1.4; }
.ing .dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 14px currentColor; }
.ing[aria-pressed='true'] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212, 175, 55, .35), 0 0 24px rgba(212, 175, 55, .2); transform: translateY(-2px); }
.alembic { display: grid; gap: 12px; place-items: center; }
.alembic canvas { width: min(260px, 70vw); height: auto; aspect-ratio: 26 / 30; }
.heat { width: min(340px, 86vw); height: 18px; border-radius: 99px; background: rgba(255, 255, 255, .08); position: relative; overflow: hidden; border: 1px solid var(--line); }
.heat .band { position: absolute; top: 0; bottom: 0; left: 55%; width: 22%; background: rgba(212, 175, 55, .35); border-left: 1px solid var(--gold); border-right: 1px solid var(--gold); }
.heat .needle { position: absolute; top: -2px; bottom: -2px; width: 4px; border-radius: 4px; background: #fff; box-shadow: 0 0 10px #fff; left: 0; }
.progress { width: min(340px, 86vw); height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }
.hold-btn { user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; }
.hold-btn.holding { filter: brightness(1.15); box-shadow: 0 0 36px rgba(212, 175, 55, .6); }
.vial-result { display: grid; place-items: center; gap: 10px; }
.vial-result svg { width: 110px; filter: drop-shadow(0 0 24px var(--vc, #fff)); animation: rise 1s ease; }

/* ───────── loom ───────── */
.clauses { display: grid; gap: 12px; }
.clause { text-align: left; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: rgba(15, 16, 26, .66); display: grid; gap: 4px; transition: border-color .2s, transform .15s; }
.clause:hover { transform: translateY(-1px); border-color: var(--gold); }
.clause b { font-family: var(--font-head); color: var(--gold-soft); font-size: 17px; }
.clause span { font-family: var(--font-story); font-size: 19px; font-weight: 500; }
.clause.risky { border-color: rgba(232, 160, 75, .5); }
.seal-zone { display: grid; place-items: center; gap: 12px; }
.seal { width: 132px; height: 132px; border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, #ff5c7f, #9d1238 60%, #5e0a22); box-shadow: 0 10px 30px rgba(157, 18, 56, .5), inset 0 -6px 14px rgba(0, 0, 0, .35); color: #ffd9e2; font-family: var(--font-head); font-weight: 700; font-size: 15px; position: relative; }
.seal svg.ring { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); transform: rotate(-90deg); }
.seal svg.ring circle { fill: none; stroke: var(--gold); stroke-width: 4; stroke-dasharray: 440; stroke-dashoffset: 440; }
.seal.done { animation: stamp .5s ease; }
@keyframes stamp { 40% { transform: scale(.86) } 100% { transform: scale(1) } }

/* ───────── mirror ───────── */
.mirror-head { display: flex; gap: 16px; align-items: flex-start; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: rgba(15, 16, 26, .6); font-size: 15px; }
.pill:hover { border-color: var(--gold); }
.moons { display: flex; gap: 8px; }
.moon { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: rgba(15, 16, 26, .6); font-size: 22px; display: grid; place-items: center; }
.moon[aria-pressed='true'] { border-color: var(--gold); box-shadow: 0 0 18px rgba(212, 175, 55, .45); background: rgba(212, 175, 55, .15); }
textarea.journal {
  width: 100%; min-height: 200px; padding: 18px; border-radius: 14px; resize: vertical;
  background: rgba(244, 239, 230, .06); border: 1px solid var(--line);
  font-family: var(--font-story); font-size: var(--story-size); font-weight: 500; line-height: 1.6; color: var(--parchment);
  background-image: repeating-linear-gradient(transparent 0 calc(1.6em - 1px), rgba(212, 175, 55, .1) calc(1.6em - 1px) 1.6em);
  background-attachment: local;
}
textarea.journal:focus { outline: none; border-color: var(--gold); }
.oracle-box { border: 1px dashed var(--line); border-radius: 14px; padding: 14px 16px; }
input.field { width: 100%; min-height: 50px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(15, 16, 26, .7); font-size: 18px; }
input.field:focus { outline: none; border-color: var(--gold); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 96px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: rgba(15, 16, 26, .6); font-weight: 600; }
.seg button[aria-pressed='true'] { border-color: var(--gold); background: rgba(212, 175, 55, .16); color: var(--gold-soft); }

/* ───────── title & night card ───────── */
.title-screen { min-height: calc(100vh - 140px); display: grid; place-items: center; }
.title-menu { display: grid; gap: 12px; max-width: 360px; margin: 0 auto; }
.stage-steps { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.stage-steps span { font-size: 14px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.stage-steps span.on { color: var(--midnight); background: var(--gold); border-color: var(--gold); font-weight: 700; }
.stage-steps span.done { color: var(--gold-soft); border-color: var(--gold); }
.night-card { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.night-card .num { font-family: var(--font-display); font-size: clamp(64px, 18vw, 140px); color: var(--gold); line-height: 1; text-shadow: 0 0 40px rgba(212, 175, 55, .45); animation: rise 1.4s ease; }
.howto { display: grid; gap: 10px; }
@media (min-width: 640px) { .howto { grid-template-columns: repeat(5, 1fr); } }
.howto div { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(15, 16, 26, .55); }
.howto b { display: block; font-family: var(--font-head); color: var(--gold-soft); font-size: 15px; }
.howto span { font-size: 14px; color: var(--muted); }

/* ───────── video overlay ───────── */
.cinema { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; }
.cinema video, .cinema img { width: 100%; height: 100%; object-fit: cover; }
.cinema .skip { position: absolute; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
.cinema .cine-title { position: absolute; left: 0; right: 0; bottom: 18%; text-align: center; padding: 0 16px; animation: rise 2s ease; }

/* ───────── ending ───────── */
.ending-hero { position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--gold); }
.ending-hero img, .ending-hero video, .ending-hero .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ending-hero video { opacity: 0; transition: opacity 1.2s; } .ending-hero video.live { opacity: 1; }

/* ───────── modal ───────── */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 5, 12, .78); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(6px); }
.modal-card { width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--plum); border: 1px solid var(--gold); border-radius: 18px; padding: 22px; position: relative; }
.modal-close { position: sticky; top: 0; float: right; margin: -6px -6px 0 0; z-index: 2; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 16px; }
.tabs button { min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-weight: 600; }
.tabs button[aria-selected='true'] { background: rgba(212, 175, 55, .16); border-color: var(--gold); color: var(--gold-soft); }
.entry { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: rgba(15, 16, 26, .5); }
.entry + .entry { margin-top: 12px; }
.entry .meta { font-size: 14px; color: var(--gold); font-weight: 600; }
.entry .txt { font-family: var(--font-story); font-size: 19px; white-space: pre-wrap; margin-top: 6px; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.vial-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; background: rgba(15, 16, 26, .5); }
.vial-card svg { width: 46px; }
.vial-card b { display: block; font-size: 14px; color: var(--gold-soft); }
.vial-card span { font-size: 14px; color: var(--muted); }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.codex-card { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 2 / 3; position: relative; background: #15122a; }
.codex-card img, .codex-card .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.codex-card.locked { display: grid; place-items: center; color: var(--muted); font-family: var(--font-head); font-size: 26px; }
.codex-card .plaque { font-size: 14px; }
.ending-slot { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: rgba(15, 16, 26, .5); display: grid; gap: 4px; }
.ending-slot.got { border-color: var(--gold); }
.ending-slot b { font-family: var(--font-head); color: var(--gold-soft); }

/* ───────── overlays ───────── */
#veil { position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(40, 28, 70, .96), rgba(10, 8, 20, .99)); transition: opacity .45s ease; }
#veil.on { opacity: 1; }
#burst { position: fixed; inset: 0; z-index: 45; pointer-events: none; width: 100%; height: 100%; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 70; background: var(--plum-2); border: 1px solid var(--gold); color: var(--gold-soft); padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .35s; pointer-events: none; max-width: calc(100vw - 32px); font-weight: 600; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ───────── reduced motion ───────── */
html.calm *, html.calm *::before, html.calm *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
html.calm .ink .w { opacity: 1; filter: none; }

/* ───────── print: the grimoire ───────── */
#print { display: none; }
@media print {
  @page { margin: 16mm; }
  body { background: #fff !important; color: #1b192b !important; }
  body > *:not(#print) { display: none !important; }
  #print { display: block !important; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 13pt; color: #1b192b; }
  #print h1, #print h2, #print h3 { color: #4a2c0f; text-shadow: none; }
  #print .pcover { text-align: center; page-break-after: always; padding-top: 30mm; }
  #print .pcover img { width: 70%; border-radius: 8px; margin: 10mm auto; display: block; }
  #print .pentry { page-break-inside: avoid; border-top: 1px solid #c9b48a; padding: 6mm 0; }
  #print .pentry .meta { font-family: 'Cinzel', serif; font-size: 10pt; color: #8a6a16; }
  #print .pentry .q { font-style: italic; color: #4a3b5a; }
  #print .pentry .t { white-space: pre-wrap; margin-top: 3mm; }
  #print .pend { page-break-before: always; }
  #print .pend img { width: 100%; border-radius: 8px; }
}
