/* D&D reference pages (scripts/build-reference.js): long-form rules text in the site's D&D look, on top of
   assets/site.css (theme-dnd). Phone first; nothing here may make the page wider than the screen. */

.ref-main { padding: 0 var(--gutter) clamp(36px, 6vw, 64px); }
.ref { width: 100%; max-width: 860px; margin: 0 auto; padding-top: clamp(18px, 4vw, 36px); overflow-wrap: break-word; }
.ref section { margin-top: clamp(30px, 5vw, 46px); }
.ref h1 { margin: 6px 0 10px; font-family: var(--font-display); font-weight: 700; font-size: clamp(32px, 6.4vw, 54px); line-height: 1.08; color: var(--accent-2); text-shadow: 0 0 30px rgba(224, 177, 85, 0.3); }
.ref h2 { margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-family: var(--font-head); font-weight: 600; font-size: clamp(23px, 3.6vw, 30px); line-height: 1.2; color: var(--accent-2); }
.ref h2 .ed { display: inline-block; margin-left: 6px; padding: 2px 10px; vertical-align: middle; border: 1px solid var(--line-strong); border-radius: 999px; font-family: var(--font-ui); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.ref h3 { margin: 22px 0 8px; font-family: var(--font-head); font-weight: 600; font-size: 20px; color: var(--accent-2); }
.ref h4 { margin: 0 0 4px; font-family: var(--font-head); font-weight: 600; font-size: 17.5px; letter-spacing: 0.02em; color: var(--text); }
.ref p, .ref li { color: var(--text); opacity: 0.94; }
.ref p { margin: 0 0 14px; }
.ref a { color: var(--accent); text-underline-offset: 3px; }
.ref ul { padding-left: 1.2em; }
.ref li { margin-bottom: 8px; }
.ref li strong { color: var(--accent-2); }
html[lang^='zh'] .ref h2, html[lang^='zh'] .ref h3, html[lang^='zh'] .ref h4 { letter-spacing: 0.04em; }
html[lang^='zh'] .ref p, html[lang^='zh'] .ref li { line-height: 1.8; }

/* Title block */
.ref-head { display: grid; gap: 18px; align-items: center; margin-bottom: 18px; }
.ref-head .lead { margin: 0; font-size: clamp(17px, 2.4vw, 20px); font-style: italic; color: var(--muted); }
.ref-head .eyebrow { margin: 0; }
.ref-emblem { width: 112px; height: 112px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong), 0 12px 30px -10px rgba(0, 0, 0, 0.8); }
.ref-portraits { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 360px; }
.ref-portraits img, .ref-art { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line-strong); box-shadow: 0 16px 34px -14px rgba(0, 0, 0, 0.8); }
.ref-art { aspect-ratio: 16 / 9; object-fit: cover; }
@media (min-width: 700px) {
  .ref-head { grid-template-columns: auto 1fr; gap: 28px; }
  .ref-emblem { width: 150px; height: 150px; }
  .ref-head-species { grid-template-columns: 300px 1fr; }
  .ref-head-art { grid-template-columns: 360px 1fr; }
  .ref-head-index { grid-template-columns: 1fr; }
}

/* On this page */
.ref-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.ref-toc a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.03); font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.06em; color: var(--muted); text-decoration: none; }
.ref-toc a:hover { color: var(--accent-2); border-color: var(--line-strong); }

/* Definition lists: traits, quick facts */
.ref-traits { display: grid; gap: 1px; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--line); }
.ref-traits > div { display: grid; gap: 2px 16px; padding: 10px 16px; background: var(--panel); }
.ref-traits dt { font-family: var(--font-ui); font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--tag); }
.ref-traits dd { margin: 0; color: var(--text); }
@media (min-width: 640px) { .ref-traits > div { grid-template-columns: 210px 1fr; align-items: baseline; } }

/* The class table scrolls inside its own box on a phone, never the page. */
.ref-table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); -webkit-overflow-scrolling: touch; }
.ref-table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.35; }
.ref-table th, .ref-table td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.ref-table thead th { position: sticky; top: 0; font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tag); background: #1b1424; white-space: nowrap; }
.ref-table tbody th { font-family: var(--font-head); color: var(--accent); white-space: nowrap; }
.ref-table td:nth-child(3) { min-width: 200px; }
.ref-table td { white-space: nowrap; }
.ref-table td:nth-child(3) { white-space: normal; }
.ref-table tbody tr:last-child th, .ref-table tbody tr:last-child td { border-bottom: 0; }
.ref-note { font-size: 15px; color: var(--muted) !important; font-style: italic; }

/* Features by level */
.ref-levels { list-style: none; margin: 0; padding: 0; }
.ref-levels > li { position: relative; margin: 0; padding: 4px 0 14px 22px; border-left: 1px solid var(--line-strong); }
.ref-levels > li::before { content: ''; position: absolute; left: -6px; top: 12px; width: 11px; height: 11px; transform: rotate(45deg); background: var(--accent); box-shadow: 0 0 0 3px var(--bg); }
.ref-levels h3.lvl { margin: 4px 0 8px; font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.ref-levels p { margin-bottom: 12px; }
.ref-h3 { margin-top: 26px !important; }
.ref-subfeats { list-style: none; padding: 0 !important; }
.ref-subfeats > li { margin: 0 0 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ref-subfeats p { margin: 0; }
.lv { display: inline-block; margin-right: 6px; font-family: var(--font-ui); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.tok { font-variant: small-caps; letter-spacing: 0.03em; color: var(--accent-2); }
.tok.col { font-variant: all-small-caps; }
.ref-lead { font-style: italic; color: var(--muted) !important; }
.ref-spells { font-size: 16px; }

/* Options of a feature (invocations, metamagic...), lineages */
.ref-options { margin: 6px 0 16px; padding: 12px 16px; border: 1px dashed var(--line-strong); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.ref-options-head { margin: 0 0 8px !important; font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tag); }
.ref-options dl, dl.ref-options { margin: 0; }
.ref-options dl > div, dl.ref-options > div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.ref-options dl > div:last-child, dl.ref-options > div:last-child { border-bottom: 0; }
.ref-options dt { font-family: var(--font-head); font-weight: 600; color: var(--accent-2); }
.ref-options dd { margin: 2px 0 0; font-size: 16px; color: var(--text); opacity: 0.92; }

.ref-box { margin: 0 0 14px; padding: 14px 18px; border: 1px solid var(--line-strong); border-radius: 12px; background: linear-gradient(180deg, rgba(224, 177, 85, 0.08), rgba(224, 177, 85, 0.02)); }
.ref-box p { margin: 0; }

/* Feats */
.ref-feats { list-style: none; padding: 0 !important; }
.ref-feats > li { margin: 0 0 14px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); scroll-margin-top: 20px; }
.ref-feats h3 { margin: 0 0 4px; }
.ref-meta { margin: 0 0 8px !important; font-family: var(--font-ui); font-size: 12.5px; letter-spacing: 0.08em; color: var(--tag) !important; }
.ref-asi { margin: 0 0 6px !important; font-weight: 600; }
.ref-tip { margin: 8px 0 0 !important; padding-top: 8px; border-top: 1px solid var(--line); font-style: italic; color: var(--muted) !important; }
.ref-catnames > div { margin-bottom: 10px; }
.ref-catnames h4 { font-size: 15px; color: var(--tag); }
.ref-catnames p { color: var(--muted); }

/* Names-only lists */
.ref-cols { display: grid; gap: 4px 24px; }
@media (min-width: 640px) { .ref-cols { grid-template-columns: 1fr 1fr; } }
.ref-names { columns: 2; column-gap: 20px; margin: 0; padding-left: 1.1em !important; color: var(--muted); }
.ref-names li { margin-bottom: 4px; color: var(--muted); break-inside: avoid; }
.ref-names-dl dd { font-style: italic; }

/* Cards (index pages) */
.ref-grid { display: grid; gap: 14px; margin: 22px 0 28px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.ref-grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.ref-card { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: inherit; text-decoration: none !important; transition: border-color 0.25s, transform 0.25s; }
.ref-card:hover, .ref-card:focus-visible { border-color: var(--line-strong); transform: translateY(-2px); }
.ref-card img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line-strong); }
.ref-card-portrait img { border-radius: 10px; height: 90px; object-position: 50% 20%; }
.ref-card-art { grid-template-columns: 1fr; }
.ref-card-art img { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 10px; }
.ref-card-text { grid-template-columns: 1fr; }
.ref-card-body { display: grid; gap: 4px; min-width: 0; }
.ref-card-body strong { font-family: var(--font-head); font-size: 20px; letter-spacing: 0.04em; color: var(--accent-2); }
.ref-card-body > span:not(.tag) { font-size: 15.5px; line-height: 1.45; color: var(--muted); }
.ref-card-sub { font-style: italic; }

/* Calls to action and "more" links */
.ref-cta { margin: 22px 0 !important; }
.ref-cta .btn { min-height: 48px; }
.ref .btn-primary, .ref .btn-primary:hover { color: #141414; text-decoration: none; }
.ref-more { margin-top: 34px; }
.ref-more h2 { font-size: 20px; }
.ref-more div { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-more a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 16px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--font-ui); font-size: 14px; letter-spacing: 0.04em; color: var(--text); text-decoration: none; background: rgba(255, 255, 255, 0.03); }
.ref-more a:hover { border-color: var(--line-strong); color: var(--accent-2); }

/* SRD licence */
.ref-srd { max-width: 860px; margin: 38px auto 0; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.55; color: var(--faint); }
.ref-srd p { margin: 0 0 8px; color: var(--faint); }
.ref-srd a { color: var(--muted); overflow-wrap: anywhere; }

/* Language switch as links (these pages are static: each language has its own address) */
.ref .lang-switch, .lang-switch a { text-decoration: none; }
.lang-switch a { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 32px; padding: 4px 10px; white-space: nowrap; border-radius: 999px; color: var(--muted); font-family: var(--font-ui); font-size: 12.5px; letter-spacing: 0.06em; }
.lang-switch a[lang^='zh'] { font-family: system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif; letter-spacing: 0; }
.lang-switch a:hover { color: var(--text); }
.lang-switch a[aria-current] { background: linear-gradient(180deg, rgba(224, 177, 85, 0.32), rgba(156, 116, 40, 0.3)); color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ref-main ~ .foot, body.ref .foot { position: relative; z-index: 1; }
body.ref .crumbs { margin-top: 4px; align-items: center; }
body.ref .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }

/* Spell pages */
.ref-spells { display: grid; gap: 12px; }
.ref-spell { padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); scroll-margin-top: 20px; }
.ref-spell h3 { margin: 0 0 2px; }
.ref-spell > p:last-child { margin: 0; }
.ref-badge { display: inline-block; margin-left: 6px; padding: 1px 9px; vertical-align: middle; border: 1px solid var(--line-strong); border-radius: 999px; font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--accent); }
.ref-spell-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 6px 16px; margin: 6px 0 10px; }
.ref-spell-stats dt { font-family: var(--font-ui); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tag); }
.ref-spell-stats dd { margin: 0; font-size: 16px; color: var(--text); }
.ref-spell-stats a { color: var(--accent); }
.ref-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0 !important; list-style: none; }
.ref-chips li { margin: 0; }
.ref-chips a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.03); font-size: 15px; color: var(--text); text-decoration: none; }
.ref-chips a:hover { border-color: var(--line-strong); color: var(--accent-2); }
.ref-finder { margin: 0 0 20px; padding: 12px 16px 2px; border: 1px dashed var(--line-strong); border-radius: 14px; }
.ref-finder > div { scroll-margin-top: 20px; }
.ref-steps { display: flex; justify-content: space-between; gap: 12px; margin: 26px 0 0 !important; }
.ref-steps a, .ref-levels-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--font-ui); font-size: 14px; color: var(--text); text-decoration: none; }
.ref-steps a:last-child { margin-left: auto; }
.ref-levels-links { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-card-spells { grid-template-columns: 72px 1fr; }
.ref-card-title { font-family: var(--font-head); font-size: 20px; letter-spacing: 0.04em; color: var(--accent-2) !important; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.ref-card-levels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ref-card-levels a { display: inline-flex; align-items: center; min-height: 44px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; color: var(--text); text-decoration: none; }
.ref-table-spells td:nth-child(3) { min-width: 0; }
.ref-table-spells td:last-child { white-space: normal; min-width: 180px; }
.ref-table-spells th a { color: var(--accent); }

/* ---------- NPC stat blocks: the NPC Maker's block (src/shared/statblock/statblock.css, appended to this file by
   scripts/build-reference.js) on a sheet of parchment, with the Forge's ink colors ---------- */
.ref-npc { scroll-margin-top: 16px; }
.ref-npc > h2 .ed { white-space: nowrap; }
.ref-sb {
  --ink: #2f2417; --ink-2: #3d2c19; --muted: #5f5040; --faint: #75654f; --line-strong: #b4935a;
  --crimson: #8b1e1e; --crimson-2: #a8322b; --crimson-deep: #5e1010; --gold: #b8862f; --gold-ink: #85601e;
  --text: var(--ink); --accent: var(--crimson);
  margin: 0 0 18px; padding: 12px 16px 10px; border: 1px solid var(--line-strong); border-radius: 14px;
  background: linear-gradient(180deg, #fbf6ea, #f2e7cf); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35); color: var(--ink);
}
.ref .ref-sb p { margin: 0; color: var(--ink); opacity: 1; }
.ref .ref-sb .sb-entry { margin: 0 0 7px; }
.ref .ref-sb .sb-name { margin: 0; font-family: var(--font-head); font-size: 20px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.2; color: var(--crimson); }
.ref .ref-sb .sb-type { color: var(--muted); }
html[lang^='zh'] .ref .ref-sb p { line-height: 1.6; }
.ref-cr { margin-left: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ref-chips .ref-cr { margin-left: 6px; }

/* ---------- equipment tables and magic items ---------- */
.ref-table-items tbody th { min-width: 150px; white-space: normal; }
.ref-table-items td:nth-child(3) { min-width: 0; white-space: nowrap; }
.ref-table-items td.wrap { min-width: 170px; white-space: normal; }
.ref-tnote { display: block; margin-top: 2px; font-family: var(--font-body); font-size: 14px; font-weight: 400; letter-spacing: 0; line-height: 1.35; color: var(--muted); white-space: normal; }
.ref-magic .ref-spell-stats { margin: 6px 0 8px; }
.ref-magic { list-style: none; padding: 0 !important; }
.ref-magic .ref-spell-stats { grid-template-columns: repeat(auto-fill, minmax(min(46%, 170px), 1fr)); }
.ref h3 .ed { display: inline-block; margin-left: 6px; padding: 1px 9px; vertical-align: middle; border: 1px solid var(--line-strong); border-radius: 999px; font-family: var(--font-ui); font-size: 11.5px; letter-spacing: 0.08em; color: var(--muted); white-space: nowrap; }

/* ---------- guides (scripts/build-guides.js): long articles with figures, phone first ---------- */
.g-meta { margin: 12px 0 0 !important; font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.06em; color: var(--tag) !important; }
.guide h3 { margin-top: 24px; }
.guide section > h3:first-of-type { margin-top: 18px; }
.g-toc a { min-height: 44px; }
.g-steps { padding-left: 1.4em; }
.g-steps li { margin-bottom: 6px; }
/* Quick picker: a wish, then the classes that fit it */
.g-picker { display: grid; gap: 8px; margin: 0 0 22px; padding: 0 !important; list-style: none; }
.g-picker li { display: grid; gap: 6px; margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.g-want { font-style: italic; color: var(--text); }
.g-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.g-pick a { display: inline-flex; align-items: center; min-height: 44px; padding: 2px 14px; border: 1px solid var(--line-strong); border-radius: 999px; font-family: var(--font-ui); font-size: 14px; letter-spacing: 0.04em; color: var(--accent-2); text-decoration: none; background: rgba(224, 177, 85, 0.07); }
.g-pick a:hover { background: rgba(224, 177, 85, 0.16); }
@media (min-width: 700px) { .g-picker li { grid-template-columns: minmax(0, 1fr) auto; align-items: center; } .g-pick { justify-content: flex-end; } }
.g-table td { position: relative; white-space: normal; }
.g-table { font-size: 14.5px; }
.g-table thead th { white-space: normal; }
.g-table th, .g-table td { padding: 6px 8px; }
.g-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.g-table td:nth-child(3) { min-width: 0; }
.g-dots { display: inline-flex; gap: 3px; vertical-align: middle; white-space: nowrap; }
.g-dots i { display: inline-block; width: 9px; height: 9px; border: 1.5px solid var(--accent); border-radius: 50%; }
.g-dots i.on { background: var(--accent); }
.g-rate-n { font-size: 13px; color: var(--muted); }
/* One class */
.g-class { scroll-margin-top: 16px; padding-top: 6px; border-top: 1px solid var(--line); }
.g-class-head { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; margin-bottom: 6px; }
.g-class-head h2 { margin: 0 0 4px; padding: 0; border: 0; }
.g-emblem { width: 72px; height: 72px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong), 0 10px 24px -10px rgba(0, 0, 0, 0.8); }
.g-tags, .g-rate { margin: 0 0 2px !important; font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.04em; color: var(--tag) !important; }
.g-two { display: grid; gap: 0 24px; }
@media (min-width: 700px) { .g-two { grid-template-columns: 1fr 1fr; } .g-class-head { grid-template-columns: 96px 1fr; } .g-emblem { width: 96px; height: 96px; } }
.g-example { margin: 22px 0 12px; padding: 14px 16px 6px; border: 1px solid var(--line-strong); border-radius: 16px; background: linear-gradient(180deg, rgba(224, 177, 85, 0.07), rgba(224, 177, 85, 0.015)); }
.g-example h3 { margin: 0 0 10px; }
.g-example .ref-traits { margin-bottom: 12px; }
.g-make { font-size: 15.5px; font-style: italic; color: var(--muted) !important; }
.g-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0 !important; }
.g-links a, .g-links span { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--font-ui); font-size: 14px; letter-spacing: 0.03em; color: var(--text); text-decoration: none; background: rgba(255, 255, 255, 0.03); }
.g-links span { color: var(--muted); border-style: dashed; }
.g-links a:hover { border-color: var(--line-strong); color: var(--accent-2); }
/* Figures: phone screenshots stay narrow, desktop ones and printed pages take the width */
.g-figs { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 16px; margin: 18px 0 20px; }
.g-fig { margin: 0; flex: 0 1 auto; text-align: center; }
.g-fig img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 12px; border: 1px solid var(--line-strong); box-shadow: 0 16px 34px -14px rgba(0, 0, 0, 0.8); background: #f4ead2; }
.g-phone { width: min(100%, 300px); }
.g-desk { width: 100%; }
.g-page { width: min(100%, 360px); }
.g-page img { border-radius: 4px; }
.g-fig figcaption { margin-top: 8px; font-size: 14.5px; font-style: italic; line-height: 1.4; color: var(--muted); }
/* Checklists */
.g-check { list-style: none; padding-left: 0 !important; }
.g-check li { position: relative; padding-left: 30px; }
.g-check li::before { content: ''; position: absolute; left: 2px; top: 0.3em; width: 15px; height: 15px; border: 1.5px solid var(--accent); border-radius: 3px; }
.g-print { padding: 4px 16px 2px; border: 1px dashed var(--line-strong); border-radius: 14px; }
.g-ref-link a { font-style: normal; }
.g-card img { object-fit: cover; }
@media print {
  body.ref { background: #fff !important; color: #000 !important; }
  body.ref .top, body.ref .crumbs, body.ref .foot, body.ref .ad-slot, .g-toc, .g-figs, .ref-more, .g-links { display: none !important; }
  .ref, .ref p, .ref li, .ref h1, .ref h2, .ref h3, .g-meta { color: #000 !important; text-shadow: none !important; opacity: 1 !important; }
  .ref a { color: #000 !important; text-decoration: none; }
  .g-check li::before { border-color: #000; }
  .g-print, .ref-box, .g-example, .g-picker li { border-color: #888 !important; background: none !important; }
  .guide section { break-inside: auto; }
  .g-check li { break-inside: avoid; }
  /* The checklist stays in one piece: no "At the table" heading left alone at the foot of a page. */
  .g-print { break-inside: avoid; page-break-inside: avoid; }
  .g-print h3 { break-after: avoid; page-break-after: avoid; }
  .guide h2, .guide h3 { break-after: avoid; page-break-after: avoid; }
}

/* Stat blocks on the page (src/shared/statblock/html.js), in the Scholar's Parchment look: ink on paper, crimson
   headings and gold rules, the 2024 ability table (score, MOD, SAVE) or the 2014 row of six scores. Phone first. */

.sb { container-type: inline-size; margin: 4px 0 0; padding: 10px 2px 12px; border-top: 3px double var(--gold); border-bottom: 3px double var(--gold); font-size: 16px; line-height: 1.42; color: var(--ink); overflow-wrap: anywhere; }
.sb p { margin: 0; }
.sb-top { display: grid; gap: 1px; }
.sb-name { margin: 0; font-family: var(--font-head); font-size: 20px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.2; color: var(--crimson); }
.sb-edited { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 0 8px; border-radius: 999px; border: 1px solid #c49a45; background: rgba(214, 178, 90, 0.22); color: #6e4e14; font-family: var(--font-body); font-size: 13px; font-weight: 400; letter-spacing: 0; }
.sb-based { font-size: 14px; color: var(--gold-ink); }
.sb-type { font-style: italic; color: var(--muted); }
.sb-rule { height: 2px; margin: 8px 0; background: linear-gradient(90deg, var(--crimson), rgba(139, 30, 30, 0.15) 85%, transparent); }
.sb-line b, .sb-ab b { color: var(--crimson-deep); font-weight: 600; }
.sb-pair { display: flex; flex-wrap: wrap; gap: 0 22px; }
.sb-head { margin: 12px 0 6px; padding-bottom: 2px; border-bottom: 1px solid var(--crimson); font-family: var(--font-head); font-size: 15px; font-weight: 700; letter-spacing: 0.06em; color: var(--crimson); }
.sb-entry { margin: 0 0 7px !important; }
.sb-ename { font-weight: 600; font-style: italic; color: var(--ink-2); }
.sb-entry em { font-style: italic; color: var(--muted); }

/* 2024: three small tables (Str/Int, Dex/Wis, Con/Cha) with score, MOD and SAVE; two (Str-Con, Int-Cha) in a narrow block */
.sb-abil24 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: 620px; }
.sb-abil24.narrow { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@container (max-width: 470px) {
  .sb-abil24.wide { display: none; }
  .sb-abil24.narrow { display: grid; }
}
.sb-at { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 15px; background: rgba(214, 178, 90, 0.14); border-radius: 4px; }
.sb-at thead th:nth-child(1) { width: 30%; }
.sb-at thead th:nth-child(2) { width: 20%; }
.sb-at th, .sb-at td { padding: 1px 2px; text-align: center; white-space: nowrap; }
.sb-at thead th { font-family: var(--font-head); font-size: 10px; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.sb-at tbody th { text-align: left; font-family: var(--font-head); font-size: 12px; font-weight: 700; color: var(--crimson-deep); }
.sb-at td:nth-child(3), .sb-at td:nth-child(4) { color: var(--ink-2); }
/* 2014: one row of six scores (two rows of three on narrow phones) */
.sb-abil14 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; text-align: center; }
.sb-ab { display: grid; }
.sb-ab b { font-family: var(--font-head); font-size: 12px; letter-spacing: 0.04em; }
.sb-ab span { white-space: nowrap; font-size: 15px; }
@container (max-width: 330px) {
  .sb-abil14 { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 6px; }
}

/* The stat block of an NPC (or later a monster) inside its card: summary line, the block that opens, its tools */
.sb-panel { margin-top: 6px; }
.sb-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 6px 0 0; font-size: 15.5px; color: var(--ink); }
.sb-sum .chip { font-size: 13px; }
details.sb-details { margin-top: 8px; }
details.sb-details > summary { list-style: none; cursor: pointer; min-height: 44px; }
details.sb-details > summary::-webkit-details-marker { display: none; }
details.sb-details > summary .icon { transition: transform 0.2s; }
details.sb-details[open] > summary .icon { transform: rotate(90deg); }
.sb-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sb-tools .ghost-btn { min-height: 44px; }
.sb-tools .ghost-btn:disabled { opacity: 0.45; cursor: default; }
.sb-tools .ghost-btn[aria-pressed='true'] { background: linear-gradient(180deg, var(--crimson-2), var(--crimson) 60%, #761818); border-color: var(--gold); color: #fbf1dc; }
.sb-hint { margin: 8px 0 0; font-size: 14.5px; font-style: italic; color: var(--faint); }

/* The edit form */
.sb-edit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin-top: 10px; }
.sb-f { display: grid; gap: 2px; min-width: 0; }
.sb-f.wide { grid-column: 1 / -1; }
.sb-f label { font-family: var(--font-head); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.sb-f .edit-input { min-height: 44px; font-size: 16px; }
.sb-f.is-edited .edit-input { border-bottom-color: var(--gold); box-shadow: inset 0 -1px 0 var(--gold); }
/* a number that just followed a score change */
.sb-f.follows .edit-input { animation: moved 1.2s ease-out; }
.sb-abil-edit, .sb-sec-edit { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; margin: 6px 0 0; padding: 8px 10px 10px; border: 1px solid var(--line-strong); border-radius: 4px; }
.sb-sec-edit { grid-template-columns: minmax(0, 1fr); }
.sb-abil-edit legend, .sb-sec-edit legend { padding: 0 6px; font-family: var(--font-head); font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em; color: var(--crimson); }
.sb-entry-edit { display: grid; gap: 6px; padding-bottom: 8px; border-bottom: 1px dotted rgba(120, 90, 40, 0.3); }
.sb-entry-edit:last-child { border-bottom: 0; padding-bottom: 0; }
@media (min-width: 720px) { .sb-abil-edit { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* Chinese: bold labels and upright names (an italic Chinese face would only be a slanted copy) */
.sb:lang(zh) .sb-line b, .sb:lang(zh) .sb-ab b, .sb:lang(zh) .sb-ename { font-weight: 700; }
.sb:lang(zh) .sb-ename, .sb:lang(zh) em, .sb:lang(zh) .sb-type { font-style: normal; }
