/* Encounter calculator. Plain utility style. */

:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --text: #1a1a1a;
  --muted: #555555;
  --border: #c8c8c8;
  --border-light: #e2e2e2;
  --accent: #8b1e2d;
  --accent-text: #ffffff;
  --party: #1a1a1a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e; --bg-alt: #2a2a2a; --text: #e8e8e8; --muted: #a8a8a8;
    --border: #4a4a4a; --border-light: #363636; --accent: #e8909b; --accent-text: #1e1e1e; --party: #e8e8e8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1e1e; --bg-alt: #2a2a2a; --text: #e8e8e8; --muted: #a8a8a8;
  --border: #4a4a4a; --border-light: #363636; --accent: #e8909b; --accent-text: #1e1e1e; --party: #e8e8e8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: underline; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; height: auto; }
.visually-hidden { 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(--bg); color: var(--text); padding: 8px 12px; border: 1px solid var(--border); z-index: 10; }
.skip:focus { left: 8px; }

h1 { font-size: 30px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 22px; line-height: 1.3; margin: 32px 0 10px; }
h3 { font-size: 18px; line-height: 1.35; margin: 22px 0 6px; }
p { margin: 0 0 14px; }
td, dd, .m-total { font-variant-numeric: tabular-nums; }

/* header and footer */
.site-head, .tool, .guide, .faq, .article, .site-foot { max-width: 1040px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.site-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.mark { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.mark-token { display: none; }
.mark-ed { font-weight: 400; color: var(--muted); }
.site-head nav { margin-left: auto; }
.site-head nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-head nav a { font-size: 16px; }
.site-head nav a[aria-current="page"] { color: var(--text); font-weight: 600; text-decoration: none; }
.theme-toggle { font: inherit; font-size: 14px; padding: 4px 10px; color: var(--text); background: var(--bg-alt); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }

.site-foot { margin-top: 40px; padding-top: 18px; padding-bottom: 28px; border-top: 1px solid var(--border); font-size: 15px; color: var(--muted); }
.foot-cols { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.foot-about { margin: 0; max-width: 560px; }
.foot-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.srd { font-size: 13px; margin-top: 14px; overflow-wrap: anywhere; }

/* calculator */
.tool { padding-top: 22px; }
.tool-head { margin-bottom: 18px; }
.lede { color: var(--muted); margin: 0; max-width: 700px; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: 28px; align-items: start; }

.rules-switch { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; margin-bottom: 16px; }
.switch-label { font-weight: 600; }
.rules-switch label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.block { border: 1px solid var(--border); border-radius: 4px; margin: 0 0 16px; padding: 12px 16px 16px; }
.block legend { font-weight: 700; font-size: 18px; padding: 0 6px; }

input, select, button { font: inherit; color: inherit; }
input[type="number"], input[type="text"], select {
  font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); min-height: 38px;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
button { cursor: pointer; }

.party-rows { list-style: none; margin: 0 0 8px; padding: 0; }
.party-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.party-row label { display: inline-flex; align-items: center; gap: 6px; }
.party-row input { width: 70px; }
.party-row .ring { display: none; }

.text-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); text-decoration: underline; font-size: 16px; }
.ink-btn { background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: 4px; padding: 6px 16px; min-height: 38px; }
.ink-btn:hover { filter: brightness(1.1); }
.x-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; width: 34px; height: 34px; color: var(--muted); font-size: 18px; line-height: 1; }
.x-btn:hover { color: var(--text); border-color: var(--muted); }

.finder label, .by-cr label { display: block; font-weight: 600; margin-bottom: 4px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 15px; }
.combo { position: relative; }
.combo input { width: 100%; scroll-margin-top: 12px; }
#find-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5; list-style: none; margin: 2px 0 0; padding: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; max-height: 320px; overflow-y: auto; box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
#find-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border-light); }
#find-list li[aria-selected="true"], #find-list li:hover { background: var(--bg-alt); }
#find-list li[aria-selected="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.opt-meta { color: var(--muted); font-size: 15px; white-space: nowrap; }
#find-list .none { cursor: default; color: var(--muted); }
@media (max-width: 640px) { #find-list { max-height: 50vh; } }

.by-cr { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; }
.by-cr label { width: 100%; font-weight: 400; margin: 0; }

.monster-rows { list-style: none; margin: 14px 0 6px; padding: 0; border-top: 1px solid var(--border-light); }
.monster-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 4px; }
.stepper button { width: 32px; height: 36px; border: 0; background: var(--bg-alt); font-size: 18px; line-height: 1; }
.stepper input { width: 44px; border: 0; border-radius: 0; text-align: center; padding: 0; min-height: 36px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.m-name { font-weight: 600; min-width: 0; }
.m-meta { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.m-lair { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; font-size: 14px; }
.m-total { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); margin: 8px 0; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; margin-top: 6px; }
.copied { font-size: 15px; color: var(--muted); }

/* result */
.result { border: 1px solid var(--border); border-radius: 4px; padding: 14px 16px 16px; background: var(--bg-alt); min-width: 0; }
.verdict { font-size: 26px; line-height: 1.3; margin: 0 0 6px; }
.verdict-kicker { font-weight: 400; }
.verdict-word { font-weight: 700; }
.verdict-line { margin: 0 0 12px; }

.xp-rule { position: relative; height: 70px; margin: 4px 0; }
.xp-track { position: absolute; left: 0; right: 0; top: 8px; height: 16px; border: 1px solid var(--muted); background: var(--bg); overflow: hidden; display: flex; }
.xp-seg { height: 100%; background: var(--accent); border-right: 1px solid var(--bg); flex: none; }
.xp-over { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, var(--bg) 0 2px, transparent 2px 6px); }
.xp-tick { position: absolute; top: 2px; height: 28px; width: 0; border-left: 1px solid var(--text); }
.xp-tick span { position: absolute; top: 30px; transform: translateX(-50%); font-size: 13px; white-space: nowrap; color: var(--muted); }
.xp-tick.first span { transform: translateX(-20%); }
.xp-tick.last span { transform: translateX(-80%); }
.xp-tick.row2 { height: 44px; }
.xp-tick.row2 span { top: 46px; }

.budgets { display: flex; flex-wrap: wrap; gap: 0; margin: 4px 0 14px; border: 1px solid var(--border); background: var(--bg); }
.budgets div { flex: 1 1 0; padding: 6px 10px; border-right: 1px solid var(--border-light); min-width: 70px; }
.budgets div:last-child { border-right: 0; }
.budgets dt { font-size: 14px; color: var(--muted); }
.budgets dd { margin: 0; font-weight: 600; }
.budgets div.hit { background: var(--bg-alt); }
.budgets div.hit dt { color: var(--text); font-weight: 600; }

.mat-fig { margin: 0 0 12px; }
.mat svg { display: block; width: 100%; height: auto; border: 1px solid var(--border); }
.mat svg .bg { fill: var(--bg); }
.mat svg .grid-l line { stroke: var(--border-light); stroke-width: 1; }
.mat svg .pc { fill: var(--bg); stroke: var(--party); stroke-width: 1.5; }
.mat svg .pc-t { font: 600 8.5px -apple-system, "Segoe UI", Arial, sans-serif; fill: var(--party); text-anchor: middle; }
.mat svg .mon { fill: var(--accent); }
.mat svg .mon-t { font: 600 6.5px -apple-system, "Segoe UI", Arial, sans-serif; fill: var(--accent-text); text-anchor: middle; }
.mat svg .mon-t.big { font-size: 10px; }
.mat svg .more { font: 400 8px -apple-system, "Segoe UI", Arial, sans-serif; fill: var(--muted); }
.mat-fig figcaption { font-size: 14px; color: var(--muted); margin-top: 4px; }

.warnings { margin: 0 0 12px; padding-left: 20px; }
.warnings li { font-size: 15px; margin-bottom: 6px; }
.award { margin: 0; font-size: 15px; }
.verdict-bar { display: none; }

/* guide and articles */
.guide { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 0 32px; margin-top: 16px; }
.prose ul { padding-left: 22px; }
.tiers { list-style: disc; }
.tiers li { margin-bottom: 6px; }
.side-note { align-self: start; margin-top: 32px; padding: 4px 16px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-alt); font-size: 16px; }
.side-note h2 { font-size: 18px; margin: 10px 0 8px; }

.faq .qa { max-width: 760px; }
.qa h3 { margin-top: 20px; }
figure { margin: 22px 0; }
figure img { display: block; border: 1px solid var(--border); }
figcaption { font-size: 15px; color: var(--muted); margin-top: 6px; }
.inline-fig { max-width: 760px; }
.prose, .article-head { max-width: 760px; }

.article { padding-top: 22px; }
.article-head { margin-bottom: 18px; }
.eyebrow { color: var(--muted); font-size: 15px; margin: 0 0 4px; }
.updated { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; border: 1px solid var(--border); font-size: 16px; margin-bottom: 8px; }
table.data caption { text-align: left; font-weight: 600; padding-bottom: 6px; }
table.data th, table.data td { border: 1px solid var(--border); padding: 5px 10px; text-align: right; }
table.data thead th { background: var(--bg-alt); text-align: center; }
table.data tbody th { text-align: left; font-weight: 600; }
table.data tbody tr:nth-child(even) { background: var(--bg-alt); }
table.compare th, table.compare td { text-align: left; vertical-align: top; }
.chart-fig { max-width: 900px; }

.split { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 8px 36px; align-items: start; margin-top: 20px; }
.split .prose h2:first-child { margin-top: 0; }
.side-table { max-width: 320px; }
.note { font-size: 15px; color: var(--muted); }

.monster-index { margin-top: 28px; }
.cr-columns { columns: 4 200px; column-gap: 28px; }
.cr-group { break-inside: avoid; margin-bottom: 16px; }
.cr-group h3 { font-size: 17px; margin: 0 0 4px; padding-bottom: 2px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.cr-group h3 span { font-weight: 400; color: var(--muted); }
.cr-group ul { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.lair { font-size: 13px; color: var(--muted); }

.lost { padding-top: 30px; padding-bottom: 40px; }

/* narrow screens */
@media (max-width: 900px) {
  .tool-grid, .guide, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  h1 { font-size: 26px; }
  .site-head, .tool, .guide, .faq, .article, .site-foot { padding-left: 14px; padding-right: 14px; }
  .site-head nav { order: 3; width: 100%; margin-left: 0; }
  .theme-toggle { margin-left: auto; }
  .block { padding: 10px 12px 14px; }
  .monster-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .monster-row .m-total { grid-column: 2; grid-row: 2; text-align: left; font-size: 14px; }
  .monster-row .stepper { grid-row: 1 / span 2; }
  .monster-row .x-btn { grid-row: 1 / span 2; grid-column: 3; }
  table.data th, table.data td { padding: 4px 7px; }
  .verdict-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: flex; justify-content: space-between; gap: 12px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); color: var(--text);
    border-top: 1px solid var(--border); box-shadow: 0 -2px 6px rgba(0, 0, 0, .12); text-decoration: none; font-size: 16px;
  }
  .verdict-bar #bar-word { font-weight: 700; }
  .verdict-bar.hide { display: none; }
  body.has-bar { padding-bottom: 50px; }
}
.theme-toggle[aria-pressed="true"] { background: var(--bg-alt); }
