:root {
  --ink: #17162a;
  --night: #10162f;
  --night-soft: #1e2850;
  --paper: #f5efe3;
  --paper-deep: #e8dcc8;
  --gold: #d7a84a;
  --gold-light: #f1d78f;
  --rose: #b7707c;
  --lavender: #9288c5;
  --muted: #6a6473;
  --line: rgba(23, 22, 42, .16);
  --shadow: 0 24px 70px rgba(20, 18, 37, .18);
  --companion-preview-background: rgba(16,22,47,.97);
  --companion-preview-border: var(--gold-light);
  --companion-preview-radius: 18px;
  --companion-preview-font: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.narrow { width: min(970px, calc(100% - 40px)); }

.hero {
  min-height: 860px;
  position: relative;
  display: flex;
  flex-direction: column;
  color: white;
  background: var(--night) url("./hero.png") center 38% / cover no-repeat;
  isolation: isolate;
}
.hero__veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(10, 14, 34, .94) 0%, rgba(10, 14, 34, .68) 43%, rgba(10, 14, 34, .12) 72%),
    linear-gradient(0deg, rgba(10, 14, 34, .88), transparent 48%);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .84rem;
  letter-spacing: .04em;
}
.nav__brand { display: flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 760; }
.nav__mark { color: var(--gold-light); font-size: 1.25rem; }
.nav__links { display: flex; gap: 25px; }
.nav__links a { color: rgba(255,255,255,.8); text-decoration: none; }
.nav__links a:hover, .nav__links a:focus-visible { color: white; }
.hero__content { margin: auto; padding: 105px 0 135px; }
.eyebrow, .kicker {
  margin: 0 0 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow { color: var(--gold-light); }
.hero h1 {
  max-width: 770px;
  margin: 0;
  font-size: clamp(3.8rem, 8vw, 7.8rem);
  line-height: .88;
  letter-spacing: -.06em;
  text-wrap: balance;
}
.hero h1 em { color: var(--gold-light); font-weight: 400; }
.hero__lede { max-width: 650px; margin: 30px 0; color: rgba(255,255,255,.85); font-size: 1.18rem; }
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .03em;
}
.button--bright { color: var(--night); background: var(--gold-light); }
.button--ghost { color: white; background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.3); }
.button--ink { color: white; background: var(--ink); }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .card-tile:focus-visible, .mini-card:focus-visible, input:focus-visible, select:focus-visible, .dialog-close:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.hero__facts { display: flex; gap: 0; margin-top: 78px; max-width: 780px; border-top: 1px solid rgba(255,255,255,.28); }
.hero__facts div { flex: 1; padding: 20px 18px 0 0; }
.hero__facts strong { display: block; color: var(--gold-light); font: 700 1.9rem/1 ui-sans-serif, system-ui, sans-serif; }
.hero__facts span { color: rgba(255,255,255,.68); font: .76rem/1.2 ui-sans-serif, system-ui, sans-serif; }
.hero__credit { position: absolute; right: 20px; bottom: 16px; margin: 0; color: rgba(255,255,255,.48); font: .68rem ui-sans-serif, system-ui, sans-serif; }

section { padding: 110px 0; }
.paper-section { background: var(--paper); }
.night-section, .ink-section { color: white; background: var(--night); }
.rose-section { background: #dbc1c2; }
.kicker { color: #8f6540; }
.kicker--moon { color: var(--gold-light); }
h2 { margin: 0 0 25px; font-size: clamp(2.45rem, 5vw, 4.8rem); line-height: .98; letter-spacing: -.045em; }
h3 { margin: 0 0 10px; font-size: 1.45rem; line-height: 1.1; }
.section-lede { max-width: 650px; color: rgba(255,255,255,.7); font-size: 1.05rem; }
.chapter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-top: 55px; border-top: 1px solid var(--line); }
.chapter { position: relative; padding: 35px 35px 15px 0; border-right: 1px solid var(--line); }
.chapter + .chapter { padding-left: 35px; }
.chapter:last-child { border-right: 0; }
.chapter__number { display: block; margin-bottom: 45px; color: var(--rose); font-size: 2.3rem; font-style: italic; }
.chapter p { color: var(--muted); }
.chapter__cards { font-size: .83rem; font-style: italic; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 80px; align-items: center; }
.lab { max-width: 660px; margin-top: 36px; padding: 28px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); }
.lab > label, .lab legend { display: block; margin-bottom: 8px; color: var(--gold-light); font: 700 .75rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.lab select, .controls input, .controls select {
  width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid rgba(255,255,255,.22); border-radius: 4px; color: inherit; background: rgba(255,255,255,.08);
}
.lab select option { color: var(--ink); background: white; }
.lab fieldset { display: grid; gap: 10px; margin: 22px 0; padding: 0; border: 0; }
.lab fieldset label { color: rgba(255,255,255,.8); font-family: ui-sans-serif, system-ui, sans-serif; }
.lab input { accent-color: var(--gold); }
.lab__result { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.18); }
.lab__result strong { color: var(--gold-light); font-size: 4rem; line-height: 1; }
.lab__result span { max-width: 330px; color: rgba(255,255,255,.68); }
.rule-card { padding: 45px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); transform: rotate(1deg); }
.rule-card__sigil { color: var(--gold); font-size: 2rem; }
.rule-card ol { padding-left: 20px; color: var(--muted); }
.rule-card li + li { margin-top: 14px; }
.section-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 42px; }
.section-heading h2 { margin-bottom: 0; }
.section-note { max-width: 260px; color: var(--muted); font-style: italic; }
.keep-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.keep-grid article { padding: 28px; border: 1px solid var(--line); background: rgba(255,255,255,.35); }
.keep-grid strong { font-size: 1.25rem; }
.keep-grid p { margin-bottom: 0; color: var(--muted); }
.hand-panel { margin: 0 0 35px; padding: 25px; background: #eee4d2; border: 1px solid var(--line); }
.mini-cards { display: grid; grid-template-columns: repeat(7, minmax(90px, 1fr)); gap: 8px; }
.mini-card { min-width: 0; min-height: 105px; padding: 12px; display: flex; align-items: end; border: 0; border-radius: 7px; color: white; text-align: left; background: var(--night-soft) center / cover; box-shadow: inset 0 -70px 50px -35px rgba(8,10,25,.94); cursor: pointer; font: 700 .72rem/1.15 ui-sans-serif, system-ui, sans-serif; transition: transform .2s ease, box-shadow .2s ease; }
.mini-card:hover { transform: translateY(-3px); box-shadow: inset 0 -70px 50px -35px rgba(8,10,25,.94), 0 9px 18px rgba(26,20,38,.22); }
.finisher-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-top: 45px; }
.finisher { position: relative; min-height: 320px; padding: 18px; display: flex; align-items: end; overflow: hidden; color: white; background: var(--night) center / cover; }
.finisher::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(12,13,30,.92), transparent 68%); }
.finisher strong { position: relative; z-index: 1; font-size: .86rem; line-height: 1.1; }
.footnote { margin: 28px 0 0; color: #5f4750; font-style: italic; }
.controls { display: grid; grid-template-columns: 1fr 280px; gap: 14px; margin-bottom: 24px; }
.controls label { color: var(--muted); font: 700 .72rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.controls input, .controls select { display: block; margin-top: 8px; color: var(--ink); border-color: var(--line); background: white; }
.section-note a { color: #8f6540; font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.card-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px 16px; }
.card-tile { min-width: 0; padding: 0; overflow: hidden; border: 1px solid rgba(15,21,50,.18); border-radius: 14px; text-align: left; color: white; background: var(--night); cursor: pointer; box-shadow: 0 12px 30px rgba(26,20,38,.14); transition: transform .2s ease, box-shadow .2s ease; }
.card-tile:hover { transform: translateY(-5px); box-shadow: 0 20px 45px rgba(26,20,38,.22); }
.card-tile__frame { position: relative; display: block; aspect-ratio: 488 / 680; padding: 9px; overflow: hidden; background: linear-gradient(rgba(13,18,42,.7), rgba(13,18,42,.92)), var(--card-art) center / cover; }
.card-tile__image { position: relative; z-index: 1; display: block; width: 100%; height: 100%; border-radius: 4.7% / 3.4%; object-fit: contain; filter: saturate(.96); box-shadow: 0 8px 22px rgba(0,0,0,.42); transition: transform .2s ease, filter .2s ease; }
.card-tile:hover .card-tile__image { transform: scale(1.018); filter: saturate(1.08); }
.card-tile__badge { position: absolute; z-index: 2; top: 16px; right: 15px; padding: 5px 7px; border-radius: 999px; color: var(--night); background: var(--gold-light); box-shadow: 0 3px 12px rgba(0,0,0,.28); font: 800 .55rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.card-tile__body { display: block; min-height: 100px; padding: 14px 15px 16px; border-top: 1px solid rgba(255,255,255,.08); background: linear-gradient(145deg, #151a37, #0d1229); }
.card-tile__role { display: block; color: var(--gold-light); font: 700 .62rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.card-tile__name { display: block; margin-top: 5px; font-weight: 700; line-height: 1.15; }
.card-tile__tags { display: block; margin-top: 8px; color: rgba(255,255,255,.54); font: .65rem ui-sans-serif, system-ui, sans-serif; }
.empty-state { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.split--deck { display: block; }
.split--deck p { color: rgba(255,255,255,.72); }
.deck-intro { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: clamp(40px, 7vw, 100px); align-items: end; padding-bottom: 58px; border-bottom: 1px solid rgba(255,255,255,.18); }
.deck-intro h2 { max-width: 820px; }
.deck-intro__details { max-width: 460px; padding-bottom: 6px; }
.deck-intro__details > p { margin-top: 0; font-size: 1.08rem; }
.deck-columns { columns: 4; column-gap: clamp(30px, 4vw, 64px); margin-top: 58px; }
.deck-role { break-inside: avoid; margin: 0 0 38px; }
.deck-role h3 { margin-bottom: 13px; color: var(--gold-light); font: 700 .82rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.deck-role p { margin: 7px 0; font-size: 1rem; line-height: 1.42; }
footer { padding: 50px 0; color: rgba(255,255,255,.65); background: #090d1d; font: .78rem ui-sans-serif, system-ui, sans-serif; }
.footer__inner { display: flex; justify-content: space-between; gap: 30px; }
.footer__inner p:last-child { text-align: right; }
.footer__inner a { color: var(--gold-light); }
.card-dialog { width: min(900px, calc(100% - 30px)); max-height: calc(100dvh - 30px); padding: 0; overflow: hidden; border: 0; color: var(--ink); background: var(--paper); box-shadow: 0 40px 100px rgba(0,0,0,.45); }
.card-dialog::backdrop { background: rgba(8,10,24,.82); backdrop-filter: blur(8px); }
.dialog-close { position: absolute; z-index: 2; top: 12px; right: 12px; width: 42px; height: 42px; border: 0; border-radius: 50%; color: white; background: rgba(10,12,30,.78); cursor: pointer; font-size: 1.6rem; }
.dialog-card { display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); max-height: calc(100dvh - 30px); }
.dialog-card__image { min-width: 0; min-height: 0; display: grid; place-items: center; padding: 14px; overflow: hidden; background: var(--night); }
.dialog-card img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.dialog-card__copy { max-height: calc(100dvh - 30px); padding: 45px; overflow-y: auto; }
.dialog-card__copy .tag { color: #8f6540; font: 800 .7rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .09em; text-transform: uppercase; }
.oracle { white-space: pre-line; color: var(--muted); }

@media (max-width: 980px) {
  .nav__links a:nth-child(-n+2) { display: none; }
  .chapter-grid, .keep-grid { grid-template-columns: 1fr; }
  .chapter { padding: 28px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .chapter + .chapter { padding-left: 0; }
  .chapter__number { margin-bottom: 14px; }
  .split { grid-template-columns: 1fr; gap: 45px; }
  .deck-intro { grid-template-columns: 1fr; gap: 24px; align-items: start; }
  .deck-intro__details { max-width: 680px; }
  .deck-columns { columns: 2; }
  .rule-card { transform: none; }
  .finisher-strip { grid-template-columns: repeat(4, 1fr); }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .mini-cards { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  .shell, .narrow { width: min(100% - 28px, 1180px); }
  .hero { min-height: 780px; background-position: 60% center; }
  .hero__veil { background: linear-gradient(0deg, rgba(10,14,34,.96) 12%, rgba(10,14,34,.5) 100%); }
  .nav { padding-top: 18px; }
  .nav__links a { display: none; }
  .nav__links a:last-child { display: block; }
  .hero__content { padding-top: 170px; padding-bottom: 80px; }
  .hero h1 { font-size: clamp(3.2rem, 17vw, 5.2rem); }
  .hero__facts { display: grid; grid-template-columns: 1fr 1fr; margin-top: 45px; }
  section { padding: 75px 0; }
  .section-heading { display: block; }
  .section-heading .button { margin-top: 18px; }
  .controls { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .card-tile__frame { padding: 6px; }
  .card-tile__body { min-height: 94px; padding: 12px; }
  .card-tile__badge { top: 11px; right: 10px; font-size: .48rem; }
  .finisher-strip { grid-template-columns: repeat(2, 1fr); }
  .finisher { min-height: 250px; }
  .mini-cards { grid-template-columns: repeat(2, 1fr); }
  .deck-columns { columns: 1; }
  .deck-role p { font-size: 1.02rem; }
  .footer__inner { display: block; }
  .footer__inner p:last-child { text-align: left; }
  .card-dialog { overflow-y: auto; }
  .dialog-card { grid-template-columns: 1fr; max-height: none; }
  .dialog-card__image { height: min(62dvh, 560px); padding: 10px; }
  .dialog-card__copy { max-height: none; padding: 28px; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
