/* City and Wilds Info — dark red on light grey, inspired by the Cities and Wilds v2 rulebook */
:root {
  --bg: #e7e5e1;
  --bg-deep: #dcd9d3;
  --paper: #f5f3ef;
  --paper-2: #fbfaf7;
  --ink: #2b2522;
  --ink-soft: #5a514c;
  --muted: #7b716b;
  --red: #7a1717;
  --red-bright: #a61f1f;
  --red-deep: #561010;
  --rose: #f7e3e1;
  --rose-2: #fdf3f2;
  --line: #cfc8bf;
  --line-soft: #e2ddd6;
  --gold: #a7844e;
  --ok: #2f6b3a;
  --focus: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 30, 20, .08), 0 6px 18px rgba(60, 30, 20, .07);
  --font-body: "Alegreya", Georgia, "Times New Roman", serif;
  --font-sc: "Alegreya SC", "Alegreya", Georgia, serif;
  --font-display: "Grenze", "Alegreya SC", Georgia, serif;
  --wrap: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font: 400 1.08rem/1.6 var(--font-body);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 15% 0%, rgba(255, 255, 255, .55), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(122, 23, 23, .05), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .27 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--red-bright); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--red); color: #fff; padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 1rem; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

h1, h2, h3, h4 { color: var(--red); line-height: 1.15; margin: 1.4em 0 .5em; }
h1 { font: 600 clamp(2rem, 5vw, 3rem)/1.05 var(--font-display); letter-spacing: .01em; margin-top: .3em; }
h2 { font: 600 clamp(1.5rem, 3.4vw, 2rem)/1.1 var(--font-display); }
h3 { font: 700 1.2rem/1.2 var(--font-sc); letter-spacing: .02em; }
h4 { font: 700 1.05rem var(--font-sc); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); font-size: .95rem; }
.m0 { margin: 0 !important; }
details > summary { cursor: pointer; font: 700 1rem var(--font-sc); color: var(--red); padding: .4rem 0; }
details[open] > summary { margin-bottom: .4rem; }

/* ---------- Header ---------- */
.site-head { background: linear-gradient(#f2f0ec, #e9e6e1); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.head-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 14px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: inherit; min-width: 0; }
.brand-crest { width: 54px; height: 54px; color: var(--red); flex: none; filter: drop-shadow(0 2px 2px rgba(86, 16, 16, .25)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font: 700 clamp(1.6rem, 4.2vw, 2.35rem)/1 var(--font-display); color: var(--red); letter-spacing: .01em; }
.brand-sub { font: italic 500 clamp(.88rem, 2.2vw, 1.02rem)/1.3 var(--font-body); color: var(--ink-soft); margin-top: .25rem; }
.nav-toggle { display: none; background: var(--red); color: #fff; border: 0; border-radius: 8px; width: 46px; height: 46px; padding: 9px; cursor: pointer; flex: none; }
.nav-toggle svg { width: 28px; height: 28px; }

.site-nav { background: var(--red); background-image: linear-gradient(180deg, #8a1c1c, var(--red) 60%, #6c1414); border-top: 2px solid var(--red-deep); border-bottom: 3px solid var(--red-deep); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
.site-nav ul { list-style: none; display: flex; gap: 2px; margin: 0 auto; padding-top: 0; padding-bottom: 0; }
.site-nav li { flex: 1 1 0; }
.site-nav a { display: flex; align-items: center; gap: .55rem; height: 100%; padding: .7rem .65rem; color: #f8ece8; text-decoration: none; font: 700 .98rem/1.15 var(--font-sc); letter-spacing: .01em; border-bottom: 3px solid transparent; margin-bottom: -3px; transition: background .15s; }
.site-nav a svg { width: 26px; height: 26px; flex: none; color: #f2d7cf; }
.site-nav a b { color: #f3c9a8; font-weight: 800; }
.site-nav a:hover { background: rgba(0, 0, 0, .14); color: #fff; }
.site-nav a[aria-current="page"] { background: rgba(0, 0, 0, .22); border-bottom-color: #f3c9a8; color: #fff; }

/* ---------- Main ---------- */
main { flex: 1; padding-top: 22px; padding-bottom: 48px; outline: none; }
.loading { padding: 3rem 0; text-align: center; font: italic 1.2rem var(--font-body); color: var(--muted); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(16px, 3vw, 28px); margin-bottom: 20px; }
.panel > :first-child { margin-top: 0; }

.page-head { display: flex; align-items: center; gap: 1rem; margin: 6px 0 18px; }
.page-head h1 { margin: 0; }
.page-head .kicker { font: 700 .9rem var(--font-sc); color: var(--muted); letter-spacing: .06em; text-transform: lowercase; }

/* Medallion — the fantasy "digital icon" frame */
.medal { --s: 64px; width: var(--s); height: var(--s); flex: none; border-radius: 50%; display: grid; place-items: center; color: #fbeee8;
  background: radial-gradient(circle at 35% 30%, #b0302b, var(--red) 55%, var(--red-deep));
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--red-deep), 0 4px 10px rgba(86, 16, 16, .35), inset 0 2px 3px rgba(255, 255, 255, .25), inset 0 -3px 6px rgba(0, 0, 0, .3); }
.medal svg { width: 58%; height: 58%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.medal.sm { --s: 40px; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--red-deep), inset 0 1px 2px rgba(255, 255, 255, .25); }
.medal.xs { --s: 28px; box-shadow: 0 0 0 1.5px var(--red-deep); }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; padding: clamp(18px, 4vw, 40px); background:
  linear-gradient(135deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, .25)), var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(122, 23, 23, .18); border-radius: 10px; pointer-events: none; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); margin: 0 0 .2rem; }
.hero .lede { font: italic 500 1.2rem/1.5 var(--font-body); color: var(--ink-soft); margin-bottom: 1rem; }
.hero-art { display: grid; place-items: center; }
.hero-art svg { width: min(260px, 70%); height: auto; color: var(--red); opacity: .92; filter: drop-shadow(0 6px 10px rgba(86, 16, 16, .25)); }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.zones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0 0; }
.zone { display: flex; gap: .8rem; align-items: flex-start; background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px; }
.zone { text-decoration: none; color: inherit; transition: border-color .15s, background .15s; }
.zone:hover { border-color: var(--red); background: var(--rose-2); color: inherit; }
.zone h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.zone p { margin: 0; font-size: .97rem; color: var(--ink-soft); }

.sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin: 26px 0; }
.sec-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .55rem; padding: 26px 16px 18px; text-decoration: none; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.sec-card:hover { transform: translateY(-3px); border-color: var(--red); box-shadow: 0 10px 24px rgba(86, 16, 16, .15); color: var(--ink); }
.sec-card .num { position: absolute; top: 10px; left: 14px; font: 700 1.4rem var(--font-display); color: var(--gold); }
.sec-card h2 { font-size: 1.35rem; margin: .4rem 0 0; }
.sec-card p { margin: 0; color: var(--ink-soft); font-size: .97rem; line-height: 1.45; }
.sec-card .go { margin-top: auto; font: 700 .9rem var(--font-sc); color: var(--red); display: inline-flex; align-items: center; gap: .3rem; }
.sec-card .go svg { width: 16px; height: 16px; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid var(--red-deep);
  background: linear-gradient(#931f1f, var(--red)); color: #fff; font: 700 1rem var(--font-sc); letter-spacing: .02em; text-decoration: none; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 2px 4px rgba(86, 16, 16, .2); }
.btn:hover { background: linear-gradient(#a52626, #861a1a); color: #fff; }
.btn svg { width: 20px; height: 20px; }
.btn.ghost { background: var(--paper-2); color: var(--red); border-color: var(--red); box-shadow: none; }
.btn.ghost:hover { background: var(--rose-2); color: var(--red-deep); }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .92rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #bfb6ac; border-radius: 7px; padding: .55rem .7rem; width: 100%; min-height: 44px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: 3px solid rgba(166, 31, 31, .22); outline-offset: 0; }
input[type="number"] { text-align: right; }
::placeholder { color: #a39890; }

/* ---------- Wiki ---------- */
.wiki { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 22px; align-items: start; }
.wiki-side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.wiki-search { padding: 14px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--paper); z-index: 2; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 36px; }
.cat-list { list-style: none; margin: 0; padding: 6px 0 10px; }
.cat-list > li > button { all: unset; box-sizing: border-box; display: flex; width: 100%; align-items: center; gap: .6rem; padding: .5rem 14px; cursor: pointer; font: 700 1rem var(--font-sc); color: var(--red-deep); }
.cat-list > li > button:hover { background: var(--rose-2); }
.cat-list > li > button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.cat-list > li > button .count { margin-left: auto; font: 500 .8rem var(--font-body); color: var(--muted); }
.cat-list > li > button .chev { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.cat-list > li > button[aria-expanded="true"] .chev { transform: rotate(45deg); }
.cat-list ul { list-style: none; margin: 0 0 6px; padding: 0 0 0 56px; }
.cat-list ul a { display: block; padding: .22rem .6rem .22rem 0; text-decoration: none; color: var(--ink-soft); font-size: .97rem; line-height: 1.3; }
.cat-list ul a:hover { color: var(--red); }
.cat-list ul a[aria-current="page"] { color: var(--red); font-weight: 700; }
.cat-ico { width: 30px; height: 30px; flex: none; }
.wiki-main { min-width: 0; }
.crumbs { font: 600 .92rem var(--font-sc); color: var(--muted); margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--red); }
.article-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .6rem; }
.article-head h1 { margin: 0; font-size: clamp(1.9rem, 4.5vw, 2.6rem); }
.meta-row { display: flex; flex-wrap: wrap; gap: .45rem; margin: .2rem 0 1rem; }
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px; background: var(--rose); color: var(--red-deep); font: 700 .82rem var(--font-sc); border: 1px solid #ecc9c5; text-decoration: none; }
.tag.plain { background: var(--bg-deep); color: var(--ink-soft); border-color: var(--line); }
.summary { font: italic 500 1.15rem/1.5 var(--font-body); color: var(--ink-soft); border-left: 4px solid var(--red); padding: .2rem 0 .2rem 1rem; margin: 0 0 1.2rem; }
.article ul, .article ol { padding-left: 1.4rem; }
.article li { margin: .25rem 0; }
.article h3 { border-bottom: 1px solid var(--line-soft); padding-bottom: .25rem; }
.example, .callout-note { border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; font-size: 1rem; }
.example { background: #f2efe9; border: 1px dashed #b9ab98; }
.example > span { display: block; font: 700 .85rem var(--font-sc); color: var(--gold); letter-spacing: .06em; text-transform: lowercase; margin-bottom: .2rem; }
.callout-note { background: var(--rose-2); border: 1px solid #efcdc8; }
.statblock { display: grid; grid-template-columns: max-content 1fr; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper-2); }
.statblock dt, .statblock dd { margin: 0; padding: .5rem .8rem; border-bottom: 1px solid var(--line-soft); }
.statblock dt { font: 700 .95rem var(--font-sc); color: var(--red); background: var(--rose-2); }
.statblock dt:nth-last-of-type(1), .statblock dd:last-of-type { border-bottom: 0; }
.req { font-style: italic; color: var(--red-deep); }
.tbl-wrap { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); }
.tbl { width: 100%; border-collapse: collapse; font-size: .98rem; }
.article > .tbl { border: 1px solid var(--line); background: var(--paper-2); margin-bottom: 1rem; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: .5rem .7rem; border-bottom: 1px solid var(--line-soft); }
.tbl thead th { background: var(--red); color: #fff; font: 700 .92rem var(--font-sc); letter-spacing: .02em; }
.tbl tbody th { font: 700 .95rem var(--font-sc); color: var(--red); white-space: nowrap; background: var(--rose-2); }
.tbl tbody tr:nth-child(even) td { background: rgba(0, 0, 0, .018); }
.tbl .lvl { font: 700 1.05rem var(--font-display); color: var(--red); white-space: nowrap; }
.tbl .lvl small { display: block; font: 600 .78rem var(--font-sc); color: var(--muted); }
.tbl-filter { max-width: 360px; margin-bottom: .8rem; }
.chip-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.chip { border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-soft); border-radius: 999px; padding: .35rem .9rem; font: 700 .9rem var(--font-sc); cursor: pointer; min-height: 36px; }
.chip.on { background: var(--red); color: #fff; border-color: var(--red-deep); }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 1rem; }
.mini-card { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .85rem; border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 8px; background: var(--paper-2); text-decoration: none; color: var(--ink); }
.mini-card strong { color: var(--red); font-family: var(--font-sc); }
.mini-card span { font-size: .9rem; color: var(--ink-soft); line-height: 1.35; }
.mini-card:hover { background: var(--rose-2); color: var(--ink); }
.see-also { margin-top: 1.6rem; padding-top: 1rem; border-top: 2px solid var(--line-soft); }
.see-also h2 { font-size: 1.3rem; margin: 0 0 .6rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; }
.pager a { flex: 1; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); text-decoration: none; }
.pager a small { display: block; font: 600 .8rem var(--font-sc); color: var(--muted); }
.pager a.next { text-align: right; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cat-card { display: flex; gap: .8rem; align-items: center; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); text-decoration: none; color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.cat-card:hover { border-color: var(--red); background: var(--rose-2); color: var(--ink); }
.cat-card strong { display: block; font: 700 1.05rem var(--font-sc); color: var(--red); }
.cat-card span { font-size: .88rem; color: var(--muted); }
.results { list-style: none; padding: 0; margin: 0; }
.results li { border-bottom: 1px solid var(--line-soft); }
.results a { display: block; padding: .7rem .2rem; text-decoration: none; color: var(--ink); }
.results a:hover { background: var(--rose-2); }
.results strong { color: var(--red); font-family: var(--font-sc); font-size: 1.05rem; }
.results small { display: block; color: var(--muted); }
.results mark { background: #f6dcb8; color: inherit; padding: 0 1px; border-radius: 2px; }
.wiki-side-toggle { display: none; }

/* ---------- Forms ---------- */
.intro-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: start; }
.email-note { display: flex; gap: .9rem; align-items: center; padding: .9rem 1.1rem; background: var(--rose-2); border: 1px solid #efcdc8; border-left: 5px solid var(--red); border-radius: 10px; margin-bottom: 1rem; }
.email-note .medal { --s: 46px; }
.email-note p { margin: 0; }
.email-note a { font-weight: 700; }
.dl-card { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; padding: 1rem; border: 1px dashed var(--red); border-radius: 10px; background: var(--paper-2); max-width: 300px; }
.dl-card p { margin: 0; font-size: .95rem; color: var(--ink-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field .lbl { font: 700 1rem var(--font-sc); color: var(--red-deep); }
.field .req-star { color: var(--red-bright); margin-left: .15rem; }
.field .help { font-size: .92rem; color: var(--muted); line-height: 1.4; }
.field .help a { font-weight: 600; }
.field .err { display: none; color: #a11313; font-weight: 700; font-size: .93rem; }
.field.has-err input, .field.has-err select, .field.has-err textarea, .has-err .list-items input { border-color: #b51c1c; background: #fff7f6; }
.field.has-err .err { display: block; }
.field .count { align-self: flex-end; font-size: .8rem; color: var(--muted); margin-top: -.2rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.radio-row label { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font: 600 1rem var(--font-body); color: var(--ink); min-height: 44px; }
.radio-row input { width: auto; min-height: 0; accent-color: var(--red); }
.radio-row label:has(input:checked) { border-color: var(--red); background: var(--rose-2); color: var(--red-deep); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px clamp(12px, 2.5vw, 20px) 18px; margin: 0 0 18px; background: var(--paper-2); min-width: 0; }
legend { font: 700 1.15rem var(--font-sc); color: var(--red); padding: 0 .4rem; display: flex; align-items: center; gap: .5rem; }
legend .medal { --s: 30px; }
.form-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-top: 8px; padding-top: 16px; border-top: 2px solid var(--line-soft); }
.form-actions .status { font-weight: 700; color: var(--ink-soft); }
.form-actions .status.bad { color: #a11313; }
.form-actions .status.good { color: var(--ok); }
.form-alert { display: none; padding: .7rem 1rem; border-radius: 8px; background: #fff1ef; border: 1px solid #e8a9a1; color: #8f1111; font-weight: 700; margin-bottom: 1rem; }
.form-alert.show { display: block; }
.hp { position: absolute !important; left: -9999px !important; height: 0; overflow: hidden; }

.rolls { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.rolls .field label { text-align: center; font-size: .9rem; }
.rolls input { text-align: center; padding: .5rem .2rem; }
.res-tiers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tier { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.tier-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .55rem .8rem; background: var(--red); color: #fff; }
.tier-head strong { font: 700 1.05rem var(--font-sc); }
.tier-head span { font-size: .88rem; color: #f6d9d3; }
.res-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 78px; gap: .5rem; align-items: center; padding: .4rem .8rem; border-bottom: 1px solid var(--line-soft); }
.res-row:last-child { border-bottom: 0; }
.res-row label { font-weight: 600; }
.res-row input { min-height: 38px; padding: .35rem .5rem; }
.res-row .yield { text-align: right; font: 700 1rem var(--font-sc); color: var(--red-deep); }
.res-row .yield small { display: block; font: 500 .72rem var(--font-body); color: var(--muted); }
.res-row.has-err input { border-color: #b51c1c; background: #fff7f6; }
.budget { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; padding: .7rem 1rem; margin-bottom: 14px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.budget .bar { flex: 1 1 200px; height: 12px; background: var(--bg-deep); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.budget .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a52a2a, var(--red)); transition: width .2s; }
.budget.over .bar i { background: #d12f2f; }
.budget .nums { font: 700 1.05rem var(--font-sc); color: var(--red-deep); }
.budget.over .nums { color: #c01818; }
.budget .left { font-weight: 700; color: var(--ink-soft); }

.list-field .list-items { display: flex; flex-direction: column; gap: .45rem; }
.list-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 40px; gap: .5rem; align-items: center; }
.list-row::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); justify-self: center; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: #a11313; border-color: #a11313; }
.add-btn { align-self: flex-start; margin-top: .2rem; }
.actions-table { display: flex; flex-direction: column; gap: 10px; }
.action-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 190px; gap: 10px; align-items: start; }
.action-row .n { font: 700 1.5rem var(--font-display); color: var(--red); text-align: center; padding-top: .35rem; }
.action-row .field label { font-size: .85rem; }

/* ---------- Character sheet explainer ---------- */
.sheet-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
.sheet-index { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.sheet-index ol { margin: 0; padding: 0; list-style: none; counter-reset: hs; }
.sheet-index h3 { margin: .9rem 0 .35rem; font-size: 1rem; }
.sheet-index h3:first-of-type { margin-top: 0; }
.sheet-index li a { display: flex; gap: .55rem; align-items: baseline; padding: .28rem .4rem; border-radius: 6px; text-decoration: none; color: var(--ink-soft); line-height: 1.3; }
.sheet-index li a::before { counter-increment: hs; content: counter(hs); flex: none; width: 1.55rem; height: 1.55rem; border-radius: 50%; display: inline-grid; place-items: center; background: var(--red); color: #fff; font: 700 .78rem var(--font-sc); transform: translateY(2px); }
.sheet-index li a:hover, .sheet-index li a.on { background: var(--rose-2); color: var(--red-deep); }
.sheet-page { margin-bottom: 28px; }
.sheet-page h2 { display: flex; align-items: center; gap: .7rem; margin-top: 0; }
.sheet-figure { position: relative; margin: 0 0 12px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); line-height: 0; }
.sheet-figure img { width: 100%; height: auto; display: block; border-radius: 6px; }
.hs { position: absolute; display: block; padding: 0; border: 2px solid transparent; background: rgba(166, 31, 31, 0); border-radius: 4px; cursor: help; transition: background .15s, border-color .15s, box-shadow .15s; }
.hs .pin { position: absolute; top: -10px; left: -10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font: 700 .72rem/1 var(--font-sc); box-shadow: 0 0 0 2px #fff, 0 2px 4px rgba(0, 0, 0, .3); pointer-events: none; }
.hs:hover, .hs:focus-visible, .hs.on { background: rgba(166, 31, 31, .12); border-color: var(--red-bright); box-shadow: 0 0 0 3px rgba(166, 31, 31, .18); outline: none; }
.show-all .hs { border-color: rgba(166, 31, 31, .45); border-style: dashed; }
.sheet-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 12px; }
.sheet-tools label { display: inline-flex; gap: .45rem; align-items: center; font-weight: 600; cursor: pointer; }
.sheet-tools input { width: auto; min-height: 0; accent-color: var(--red); }
.callout { position: absolute; top: 0; left: 0; z-index: 50; width: min(360px, calc(100vw - 32px)); background: var(--paper-2); border: 1px solid var(--red); border-radius: 10px; box-shadow: 0 12px 30px rgba(40, 10, 10, .28); padding: .9rem 1rem .8rem; font-size: .98rem; line-height: 1.5; }
.callout[hidden] { display: none; }
.callout h4 { margin: 0 0 .35rem; color: var(--red); display: flex; gap: .5rem; align-items: center; }
.callout p { margin: 0 0 .5rem; }
.callout .ex { font-size: .9rem; background: #f2efe9; border-radius: 6px; padding: .45rem .6rem; margin-bottom: .5rem; }
.callout .links { display: flex; flex-wrap: wrap; gap: .35rem; }
.callout .arrow { position: absolute; width: 12px; height: 12px; background: var(--paper-2); transform: rotate(45deg); }
.callout .x { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; }
.breakdown { list-style: none; padding: 0; margin: 0; counter-reset: bd var(--start, 0); }
.breakdown li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: .7rem; padding: .8rem 0; border-bottom: 1px solid var(--line-soft); scroll-margin-top: 16px; }
.breakdown li::before { counter-increment: bd; content: counter(bd); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font: 700 .85rem var(--font-sc); }
.breakdown li.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { background: var(--rose); } 100% { background: transparent; } }
.breakdown h4 { margin: 0 0 .25rem; color: var(--red); }
.breakdown p { margin: 0 0 .4rem; }
.breakdown .links { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- Footer & toast ---------- */
.site-foot { background: #2d1513; background-image: linear-gradient(180deg, var(--red-deep), #2d1110); color: #ead7d2; border-top: 4px solid var(--red); }
.site-foot .wrap { display: flex; align-items: center; gap: 1rem; padding-top: 22px; padding-bottom: 26px; }
.site-foot p { margin: 0; font-size: 1rem; line-height: 1.55; }
.site-foot a { color: #fff; font-weight: 700; }
.foot-crest { width: 40px; height: 40px; color: #c9534a; flex: none; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); max-width: calc(100vw - 32px); font-weight: 600; }
.toast.bad { background: #8f1111; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .site-nav a { font-size: .9rem; padding: .6rem .45rem; }
  .site-nav a svg { width: 22px; height: 22px; }
  .wiki, .sheet-layout { grid-template-columns: 1fr; }
  .wiki-side, .sheet-index { position: static; max-height: none; }
  .wiki-side-toggle { display: flex; width: 100%; justify-content: space-between; align-items: center; background: none; border: 0; border-top: 1px solid var(--line-soft); padding: .7rem 14px; font: 700 1rem var(--font-sc); color: var(--red); cursor: pointer; }
  .wiki-side .cat-list { display: none; }
  .wiki-side.open .cat-list { display: block; }
  .sheet-index ol { columns: 2; column-gap: 1.2rem; }
  .sheet-index li { break-inside: avoid; }
}
@media (max-width: 820px) {
  .nav-toggle { display: grid; place-items: center; }
  .site-nav { display: none; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; padding: 6px 16px 10px; }
  .site-nav a { padding: .75rem .4rem; font-size: 1.02rem; border-bottom: 1px solid rgba(255, 255, 255, .12); margin: 0; }
  .site-nav a[aria-current="page"] { border-bottom-color: rgba(255, 255, 255, .12); border-left: 4px solid #f3c9a8; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .zones { grid-template-columns: 1fr; }
  .intro-grid { grid-template-columns: 1fr; }
  .dl-card { max-width: none; }
  .res-tiers { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 1.02rem; }
  .brand-crest { width: 44px; height: 44px; }
  .medal { --s: 52px; }
  .page-head { gap: .75rem; }
  .rolls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .action-row { grid-template-columns: 30px minmax(0, 1fr); }
  .action-row .mod { grid-column: 2; }
  .sheet-index ol { columns: 1; }
  .hs .pin { width: 18px; height: 18px; top: -8px; left: -8px; font-size: .62rem; }
  .statblock { grid-template-columns: 1fr; }
  .statblock dt { border-bottom: 0; padding-bottom: .1rem; }
  .pager { flex-direction: column; }
  .site-foot .wrap { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-head, .site-nav, .site-foot, .wiki-side, .sheet-index, .form-actions { display: none !important; }
  body { background: #fff; }
}
h1[tabindex="-1"]:focus, h1[tabindex="-1"]:focus-visible { outline: none; }
.hs .pin { opacity: .92; }
.callout-body { padding-right: 22px; }
