@font-face {
    font-family: prism_ui;
    src: url('/css/fonts/OpenSans_SemiBold.woff2') format('woff2');
    font-display: swap;
    font-weight: 600;
    font-style: normal;
}

:root {
    color-scheme: dark;
    --background: #1b1713;
    --panel: #241e17;
    --raised: #2e251a;
    --line: #52412d;
    --soft-line: #3a3024;
    --text: #e6d8bf;
    --muted: #baa98c;
    --gold: #e4b978;
    --light: #ffe0a4;
    --prism: #a4d7ed;
    font: 600 16px/1.5 prism_ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    color: var(--text);
    background: linear-gradient(#211910e8, #211910e8), url('/img/bg/2.png'), var(--background);
}
a { color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--light); }
:focus-visible { outline: 2px solid var(--light); outline-offset: 3px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
h1, h2, h3 { margin: 0; color: #f7e7cc; }

.site-header {
    background: #1b1610;
    border-top: 3px solid #79603e;
    border-bottom: 1px solid var(--line);
}
.site-header-inner {
    max-width: 1268px;
    min-height: 86px;
    margin: auto;
    padding: 6px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.primary-navigation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 4px;
}
.primary-navigation a {
    padding: 9px 10px;
    border-radius: 4px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    font-size: .91rem;
}
.primary-navigation a:hover, .primary-navigation a[aria-current] {
    color: var(--light);
    background: var(--raised);
}
.brand { display: inline-flex; align-items: center; }
.brand img { height: 64px; width: 140px; object-fit: contain; object-position: left center; }
#catalogue { max-width: 1268px; margin: auto; padding: 22px 24px 72px; }
#sections { display: flex; flex-wrap: wrap; gap: 4px; max-width: 1268px; margin: auto; padding: 0 24px; }
#sections a {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    padding: 8px clamp(12px, 3vw, 24px);
    border: 1px solid transparent;
    border-radius: 6px 6px 0 0;
    color: var(--muted);
    text-decoration: none;
    font-weight: 650;
}
#sections a[aria-current] { color: var(--light); border-color: var(--line); background: var(--raised); }
#sections a:hover { color: var(--light); }
.equipment-restriction { color: var(--light); }
.catalogue-layout { display: grid; grid-template-columns: minmax(300px, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.results-panel, #detail { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-width: 0; }
.filter-actions {
    position: sticky; top: 0; z-index: 1; display: flex; justify-content: flex-end;
    padding: 8px 16px; background: var(--panel); border-radius: 8px 8px 0 0;
    border-bottom: 1px solid var(--soft-line);
}
#filters { display: grid; gap: 10px; padding: 10px 16px 0; }
#options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 12px; }
.bonus-filters { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; }
.bonus-filters summary { cursor: pointer; color: var(--gold); padding: 9px 0; min-height: 42px; }
.bonus-filters p { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
.bonus-filters label { margin-bottom: 10px; }
.bonus-selected { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 10px; }
.bonus-selected:empty { display: none; }
.bonus-selected button { font-size: .85rem; padding-inline: 8px; }
#filters label { display: grid; gap: 4px; color: var(--muted); font-size: .88rem; }
#filters label.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
input[type='checkbox'] { width: 17px; height: 17px; accent-color: var(--gold); }
input[type='search'], select {
    width: 100%; min-width: 0; min-height: 42px; color: var(--text); background: #1a1612;
    border: 1px solid var(--line); border-radius: 4px; padding: 6px 9px;
}
#status { margin: 12px 16px 8px; min-height: 1.5em; color: var(--muted); font-size: .86rem; }
#results { list-style: none; margin: 0; padding: 0; }
#results li { border-top: 1px solid var(--soft-line); }
.result {
    display: flex; gap: 10px; align-items: center; padding: 9px 14px; min-height: 49px;
    color: var(--text); text-decoration: none; overflow-wrap: anywhere;
}
.result:hover, .result[aria-current] { background: var(--raised); color: var(--light); }
.result[aria-current] { box-shadow: inset 3px 0 var(--gold); }
.result-image { width: 34px; height: 34px; object-fit: contain; flex: 0 0 34px; }
.result-image.ability-result-image { width: 48px; height: 48px; flex-basis: 48px; }
.ability-progression-rule {
    color: var(--gold);
    font-size: .875em;
    white-space: pre-line;
}
.result-item-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; }
.result-item-icon img { width: auto; height: auto; max-width: 34px; max-height: 34px; }
.result-text { display: grid; min-width: 0; gap: 1px; }
.result-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; color: var(--muted); font-size: .78rem; }
.quest-path-badge, .quest-series-badge {
    color: #d8c4a6; background: #332a20; border: 1px solid #665440; border-radius: 4px;
    padding: 0 5px; font-size: .72rem; line-height: 1.45; white-space: nowrap;
}
.quest-path-badge[data-path='Good Path'] { color: #b9dfbb; background: #263426; border-color: #526b50; }
.quest-path-badge[data-path='Evil Path'] { color: #ffb7ad; background: #422924; border-color: #87534b; }
.quest-series-badge { color: #ffc4d6; background: #462435; border-color: #94506d; }
.prism-badge { color: var(--prism); font-size: .78rem; margin-left: auto; white-space: nowrap; }
#pages { display: flex; gap: 8px; padding: 12px; align-items: center; justify-content: center; border-top: 1px solid var(--line); }
#pages span { color: var(--muted); font-size: .85rem; }
button, .back {
    min-height: 40px; padding: 6px 12px; color: var(--gold); background: #211a13;
    border: 1px solid var(--line); border-radius: 4px; text-decoration: none;
}
button:hover, .back:hover { color: var(--light); }

#detail { padding: clamp(16px, 3vw, 28px); overflow-wrap: anywhere; }
#detail h2 { font-size: clamp(1.35rem, 3vw, 1.85rem); line-height: 1.2; }
#detail h3 { font-size: 1rem; margin: 18px 0 6px; }
#detail .empty, .meta { color: var(--muted); }
#detail p { margin: 8px 0; }
.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back { flex: 0 0 auto; }
.portrait {
    display: grid; place-items: center; margin: 16px 0; min-height: 134px; padding: 12px;
    border: 1px solid var(--soft-line); border-radius: 6px;
    background: radial-gradient(ellipse, #3a2f23 0%, #211a14 72%);
}
.portrait img { max-width: 100%; max-height: 185px; object-fit: contain; }
.item-appearance {
    margin: 16px 0;
    border: 1px solid var(--soft-line);
    border-radius: 6px;
    background: radial-gradient(ellipse at 50% 40%, #3a2f23, #211a14 72%);
}
.appearance-stage { display: grid; place-items: center; min-height: 146px; padding: 4px 0; }
.appearance-stage .portrait { border: 0; background: none; margin: 0; min-height: 0; }
.appearance-stage canvas { display: block; image-rendering: pixelated; }
.appearance-stage [role='status']:empty { display: none; }
.appearance-controls {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
    padding: 0 8px 6px; font-size: .82rem;
}
.appearance-controls select { width: auto; min-height: 34px; padding: 2px 6px; }
.appearance-controls label { display: flex; align-items: center; gap: 5px; }
.appearance-toggle {
    display: grid; place-items: center; width: 34px; height: 34px; margin-inline-start: auto;
    padding: 0; border: 0; border-radius: 4px; color: var(--muted); background: transparent;
}
.appearance-toggle:hover { color: var(--light); background: var(--raised); }
.appearance-toggle::after { content: ''; width: 10px; height: 11px; border-inline: 3px solid currentColor; }
.appearance-toggle[data-paused='true']::after {
    width: 0; height: 0; border: 6px solid transparent; border-inline-start: 9px solid currentColor;
    margin-inline-start: 5px;
}
#detail.ability-detail { padding: clamp(12px, 2vw, 20px); }
#detail.ability-detail .detail-header { align-items: center; gap: 9px; }
.ability-detail .detail-header h2 { flex: 1; }
.ability-detail .detail-header .back { padding-block: 4px; }
.ability-icon { width: 54px; height: 54px; flex: 0 0 54px; object-fit: contain; }
#detail.ability-detail h3 { margin: 12px 0 4px; }
#detail.ability-detail p { margin: 6px 0; }
.ability-detail .fields {
    display: flex; flex-wrap: wrap; column-gap: 18px; row-gap: 4px;
    margin: 6px 0; padding: 5px 0;
    border-block: 1px solid var(--soft-line);
}
.ability-detail .fields > div:nth-child(n) {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 5px;
    border: 0; padding: 0;
}
.ability-detail .fields > .ability-exhaust { flex-basis: 100%; }
.ability-exhaust button { font: inherit; line-height: inherit; }
.ability-detail .fields dd { margin: 0; font-size: .9rem; }
.ability-detail .detail-list { margin: 3px 0 2px; }
.ability-detail .detail-list > li { padding-block: 0; }
.spell-effect {
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--raised);
}
.spell-effect > summary { color: var(--gold); cursor: pointer; }
.spell-effect-totals {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}
.spell-effect-total {
    display: grid;
    flex: 1 1 9rem;
    place-content: center;
    gap: 3px;
    min-width: 0;
    padding: 10px 8px;
    border: 1px solid color-mix(in srgb, var(--gold) 36%, var(--line));
    border-radius: 6px;
    background: var(--panel);
    text-align: center;
    overflow-wrap: anywhere;
}
.spell-effect-result {
    color: var(--light);
    font-size: clamp(1.125rem, 3.5vw, 1.5rem);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}
.spell-effect-total-primary { flex-basis: 100%; }
.spell-effect-total-primary ~ .spell-effect-total { border-color: var(--line); }
.spell-effect-total-primary ~ .spell-effect-total .spell-effect-result { font-size: 1rem; }
.spell-effect-result-label { color: var(--muted); font-size: .8rem; }
.spell-effect-steps { margin: 6px 0 0; }
.spell-effect-steps > div {
    display: grid;
    grid-template-columns: minmax(7rem, 1fr) minmax(0, 2fr);
    align-items: center;
    gap: 3px 12px;
    padding: 5px 0;
    border-top: 1px solid var(--line);
}
.spell-effect-steps dt { color: var(--muted); font-size: .83rem; }
.spell-effect-steps dd { margin: 0; font-size: .9rem; }
.spell-effect-operation { min-width: 0; }
.spell-effect-cases { display: grid; gap: 4px; }
.spell-effect-fraction { display: inline-grid; vertical-align: middle; text-align: center; line-height: 1.3; }
.spell-effect-fraction > span:first-child { border-bottom: 1px solid var(--muted); padding: 0 3px 1px; }
.spell-effect-fraction > span:last-child { padding: 1px 3px 0; }
.spell-effect-division { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.spell-effect-limit { margin-inline-start: 6px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.spell-effect-note { color: var(--muted); font-size: .79rem; }
.spell-effect-settings { margin-top: 8px; }
.spell-effect-settings > summary { color: var(--gold); font-size: .85rem; cursor: pointer; }
.spell-effect-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
    gap: 8px;
    margin-top: 7px;
}
.spell-effect-inputs label { display: grid; align-content: end; gap: 3px; color: var(--muted); font-size: .8rem; }
.spell-effect-inputs input { width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.spell-effect-inputs input:invalid { border-color: #e79779; }
@media (max-width: 480px) {
    .spell-effect-steps > div { grid-template-columns: minmax(0, 1fr); }
}
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 14px 0; }
.fields > div { padding: 8px 11px; border-bottom: 1px solid var(--soft-line); }
.fields > div:nth-child(even) { border-left: 1px solid var(--soft-line); }
.fields dt { font-size: .8rem; color: var(--muted); }
.fields dd { margin: 2px 0 0; }
.cadence-link {
    padding: 0; border: 0; background: transparent; color: var(--prism); text-align: start;
    text-decoration: underline; text-underline-offset: 3px;
}
.cadence-link:hover { color: var(--light); }
.cadence-dialog {
    width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px);
    padding: clamp(12px, 3vw, 20px); border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); background: var(--panel);
}
.cadence-dialog::backdrop { background: #0b0907cc; }
.cadence-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.cadence-header h2 { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.cadence-caption { margin: 6px 0; color: var(--gold); font-size: .86rem; }
.cadence-dialog svg { display: block; width: 100%; font-size: 12px; fill: var(--muted); }
.cadence-grid { stroke: var(--line); }
.cadence-threshold { stroke: var(--muted); stroke-dasharray: 3 4; }
.cadence-curve { stroke: var(--prism); stroke-width: 2.5; fill: none; }
.cadence-point { fill: var(--light); stroke: var(--panel); stroke-width: 2; }
.cadence-control { display: grid; gap: 4px; margin-top: 6px; font-size: .86rem; }
.cadence-control input { width: 100%; margin: 0; accent-color: var(--gold); }
.detail-list { margin: 6px 0 12px; padding-left: 21px; }
.detail-list > li { padding: 2px 0; }
.drop-list { list-style: none; padding: 0; }
.drop-list > li { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--soft-line); }
.drop-list > li span { flex-shrink: 0; color: var(--muted); }
details { border-top: 1px solid var(--soft-line); }
summary { cursor: pointer; padding: 7px 0; color: var(--gold); }
.stage { border-top: 1px solid var(--soft-line); }
.stage h4 { margin: 10px 0 3px; font-size: .9rem; color: var(--muted); }
.quest-components { list-style: none; margin: .4rem 0 .55rem; padding: 0 0 0 .75rem; border-left: 2px solid var(--soft-line); }
.quest-components > li + li { margin-top: .4rem; }
.quest-reward-steps li { white-space: pre-line; }
.weapon-commission { width: 100%; border-collapse: collapse; }
.weapon-commission :is(th, td) { padding: 6px; text-align: start; border-bottom: 1px solid var(--soft-line); }
.weapon-commission :is(th, td):not(:first-child) { text-align: end; }
.weapon-commission td:not(:first-child) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.weapon-commission th[scope="rowgroup"] { color: var(--muted); padding-top: 12px; }
.quest-choices { display: grid; gap: 5px; margin: 9px 0 12px; }
.quest-choice { border: 1px solid var(--line); border-radius: 5px; padding: 8px 12px; }
.quest-choice h5 { margin: 0; font-size: .93rem; color: var(--gold); }
.quest-choice-or { justify-self: center; color: var(--muted); font-size: .85rem; }
.inline-list {
    display: flex; flex-wrap: wrap; gap: 4px 18px; padding-left: 0;
    list-style: none; color: var(--muted);
}
.inline-list li { white-space: nowrap; }
.value-neutral { color: #8ed0ff; }
.value-bonus { color: #83df9d; }
.value-malus { color: #ff8d89; }
.quest-keyword { color: #ffd45c; }
.quest-reference { color: #83df9d; }
.quest-reference.monsters { color: #8ed0ff; }
button.quest-npc {
    display: inline; min-height: 0; padding: 0; border: 0; background: transparent;
    color: #dab4ff; text-decoration: underline; text-underline-offset: 3px;
}
.map-locations { list-style: none; padding-left: 0; }
.map-link {
    display: inline-block; min-height: 36px; padding: 5px 8px; margin: 3px 0;
    border: 1px solid var(--line); color: var(--gold); text-align: left;
    background: var(--raised); font-size: .86rem; max-width: 100%;
}

#catalogue-map {
    width: min(1080px, calc(100% - 32px)); max-width: none; max-height: calc(100% - 28px);
    padding: 16px; color: var(--text); background: var(--panel); border: 1px solid #87653c;
    border-radius: 8px; box-shadow: 0 20px 75px #000b;
}
#catalogue-map::backdrop { background: #0b0907cc; }
.map-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.map-header h2 { font-size: clamp(1.2rem, 3vw, 1.55rem); }
#map-subject, #map-status { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }
#map-status { min-height: 1.35em; margin-top: 6px; }
.map-controls { display: flex; gap: 6px; align-items: end; flex-wrap: wrap; margin: 10px 0 8px; }
.map-controls label { flex: 1 1 180px; color: var(--muted); font-size: .84rem; min-width: 0; }
.map-controls select { display: block; }
.map-controls button, .map-header button { min-height: 42px; white-space: nowrap; font-size: .9rem; }
#map-viewport {
    position: relative; height: min(63dvh, 650px); min-height: 190px; overflow: hidden;
    background: #090806; border: 1px solid var(--line); border-radius: 4px;
    touch-action: none; cursor: grab;
}
#map-viewport:active { cursor: grabbing; }
#map-terrain, #map-portals { position: absolute; inset: 0; width: 100%; height: 100%; }
#map-portals { pointer-events: none; }
.map-portal {
    display: grid; place-items: center; position: absolute; transform: translate(-50%, -50%);
    min-height: 0; width: 24px; height: 24px; padding: 0; border-radius: 50%;
    background: #e2ba6e; color: #1b1712; border: 2px solid #211b14; font-size: 17px; line-height: 1;
}
button.map-portal { pointer-events: auto; }
.map-portal[hidden] { display: none; }
.map-portal.numbered { background: #3a301b; color: #ffe5ae; border-color: #e2ba6e; font-size: 11px; }
.map-portal.destination { background: #ff7468; color: #211713; }
button.map-portal:hover, button.map-portal:focus-visible { background: #ffe1a5; color: #211713; z-index: 1; }
.map-zoom { position: absolute; bottom: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; }
.map-zoom button { min-width: 42px; padding: 0; min-height: 42px; font-size: 1.2rem; }

@media (max-width: 720px) {
    #catalogue { padding: 16px 12px 44px; }
    #sections { padding-inline: 12px; }
    #sections a { padding-inline: clamp(7px, 2vw, 14px); }
    .site-header-inner { flex-wrap: wrap; padding-inline: 14px; }
    .primary-navigation { order: 1; flex-basis: 100%; justify-content: flex-start; }
    .catalogue-layout { display: flex; flex-direction: column; }
    .results-panel, #detail { width: 100%; }
    #detail { order: -1; }
    #detail:has(.empty) { display: none; }
    .detail-header { align-items: start; }
    .back { font-size: .82rem; }
    #catalogue-map { width: calc(100% - 14px); max-height: calc(100% - 14px); padding: 9px; }
    .map-controls label { flex-basis: calc(100% - 75px); }
    .map-controls button, .map-header button { padding-inline: 8px; font-size: .8rem; }
    #map-viewport { height: 55dvh; }
}

.weapon-dps-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
    margin: 8px 0 0;
}
.weapon-dps-results .spell-effect-total { padding: 8px 6px; }
.weapon-dps-results .spell-effect-total:not(.weapon-dps-primary) { border-color: var(--line); }
.weapon-dps-results .spell-effect-result { margin: 0; font-size: clamp(1rem, 2.8vw, 1.3rem); }
.weapon-dps-results .weapon-dps-primary .spell-effect-result { color: var(--gold); }
.weapon-dps-profile { min-width: 0; border: 0; margin: 12px 0 0; padding: 0; }
.weapon-dps-profile legend { color: var(--text); padding: 0; font-size: .88rem; }
.weapon-dps .spell-effect-inputs input, .weapon-dps .spell-effect-inputs select { min-height: 38px; }
.weapon-dps .spell-effect-inputs select { border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.weapon-dps-target-mode { margin-top: 10px; }
.weapon-dps-message { color: #f0b599; }
.weapon-dps-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
