:root {
  color-scheme: dark;
  --bg: #111a1a;
  --panel: #1c2727;
  --border: #3a4742;
  --ink: #f5e9d7;
  --muted: #a9b5ad;
  --flare: #e7a371;
  --gold: #e8c591;
  font-family: "Trebuchet MS", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; -webkit-user-select: none; user-select: none; background: radial-gradient(ellipse at 53% 0, #25322e, var(--bg) 580px); color: var(--ink); }
button, a { -webkit-tap-highlight-color: transparent; }
input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--border); background: #151e1cdd; }
.mast-inner { height: 68px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: inline-flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; font-size: .82rem; font-weight: 900; letter-spacing: .16em; }
.brand b { color: var(--flare); }
.brand-icon { display: grid; place-items: center; border: 1px solid #693e3c; border-radius: 9px; color: #ff9869; background: #34212a; width: 35px; height: 35px; font-size: 1.36rem; letter-spacing: normal; }
.mast-actions { display: flex; gap: 9px; }
.mast-actions[inert] { visibility: hidden; }
.icon-button { display: grid; place-items: center; background: #211d2b; border: 1px solid #373142; border-radius: 8px; width: 36px; height: 36px; color: #ded0d8; font-weight: bold; }
.icon-button:hover:not(:disabled), .inventory-button:hover { border-color: #9c6257; color: var(--gold); }
.icon-button svg { width: 18px; height: 18px; }
.help-button { font-family: system-ui, sans-serif; font-size: 1rem; }
main { padding-top: 30px; }
.cabinet { background: var(--panel); border: 1px solid var(--border); border-radius: 15px; overflow: hidden; box-shadow: 0 18px 65px #08070db0; }
.hud { min-height: 65px; padding: 9px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.location, .vitals, .counter { display: flex; align-items: center; }
.location { gap: 11px; }
.location-icon { display: grid; place-items: center; height: 34px; width: 34px; border-radius: 7px; color: #e6ad7c; background: #302333; font-size: 1.13rem; }
.location small { display: block; color: #bfb0c2; margin-bottom: 3px; letter-spacing: .13em; }
.location strong { font-size: .98rem; }
.vitals { gap: 17px; }
.counter { gap: 6px; min-width: 39px; font-variant-numeric: tabular-nums; }
.counter small, .location small { font-size: .66rem; font-weight: bold; }
.counter small { color: var(--muted); }
.coin { font-style: normal; color: #d3dddb; }
.key-status { gap: 4px; min-width: 0; padding: 3px 6px; border: 1px solid #6a5641; border-radius: 6px; background: #2a2527; color: var(--gold); }
.key-status svg { width: 18px; height: 18px; }
.level-status { min-width: 62px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.level { font-size: .73rem; }
.level small, #xp-count { color: #dec49c; }
#xp-progress { display: block; appearance: none; width: 100%; height: 4px; margin-top: 3px; border: 0; border-radius: 2px; overflow: hidden; background: #413631; }
#xp-progress::-webkit-progress-bar { background: #413631; }
#xp-progress::-webkit-progress-value { background: #d7a364; }
#xp-progress::-moz-progress-bar { background: #d7a364; }
.armor-status { display: grid; gap: 2px; min-width: 0; color: #daeee7; white-space: nowrap; font-size: .75rem; font-variant-numeric: tabular-nums; }
.armor-status progress { width: 100%; height: 5px; appearance: none; border: 0; border-radius: 2px; background: #39434a; color: #81b9b1; }
.armor-status progress::-webkit-progress-bar { background: #39434a; border-radius: 2px; }
.armor-status progress::-webkit-progress-value { background: currentColor; border-radius: 2px; }
.armor-status progress::-moz-progress-bar { background: currentColor; border-radius: 2px; }
.armor-status.low, .armor-status.low progress { color: #ffab7b; }
.health.low #health-fill { background: #c44c5a; }
.hud-controls { display: contents; }
.pause-button { height: 32px; width: 32px; }
.effects { display: flex; flex-wrap: wrap; gap: 5px 8px; padding: 5px clamp(8px,2vw,20px); border-bottom: 1px solid var(--border); background: #1b2425; }
.effect { padding: 2px 6px; border: 1px solid #625143; border-radius: 4px; color: #e4c097; font-size: .73rem; font-variant-numeric: tabular-nums; }
.effect b { color: #f7e5cd; }
.effect.ward { border-color: #476961; color: #aedbca; }
.effect.water { border-color: #486784; color: #acd0ed; }
.effect.poison { border-color: #748a4d; color: #d3e6a3; }
.stage { position: relative; isolation: isolate; aspect-ratio: 960 / 450; background: #20192e; overflow: hidden; }
canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.loading-screen {
  position: absolute; inset: 0; z-index: 4; display: grid; justify-items: center; align-content: center;
  gap: 12px; padding: 14px; text-align: center;
  background: radial-gradient(ellipse at 50% 88%, #34322a, #171c20 72%);
}
.loading-emblem {
  display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #865143; border-radius: 9px;
  color: #ff9a68; background: #36272a; font-size: 1.22rem;
}
.loading-screen strong { font: bold clamp(1.7rem, 5vw, 3.2rem)/1 Georgia, serif; }
.loading-screen p, .loading-screen noscript { margin: 0; color: #e2c9b0; font-size: .88rem; }
.loading-screen progress { width: min(216px, 85%); height: 6px; accent-color: #ef9c65; }
.loading-screen button { padding: 6px 12px; font-size: .79rem; }
.loading-screen[data-kind="door"] { background: radial-gradient(ellipse at 50% 62%, #3c332a, #172325 66%, #11181a); }
.loading-screen[data-kind="boss"] { background: radial-gradient(ellipse at 50% 65%, #481f24, #1d171a 63%, #0e1013); }
.loading-screen:is([data-kind="door"], [data-kind="boss"]) .loading-emblem {
  position: relative; overflow: hidden;
  width: 52px; height: 66px; border: 4px double #91694d; border-radius: 50% 50% 3px 3px / 36% 36% 3px 3px;
  background: repeating-linear-gradient(90deg, #1e1919 0 6px, #2d2320 6px 8px);
  box-shadow: inset 0 0 17px #e7723e6e, 0 0 32px #e7723e40; animation: door-light 1.6s ease-in-out infinite alternate;
}
.loading-screen:is([data-kind="door"], [data-kind="boss"]) .loading-emblem::before {
  content: ""; position: absolute; inset: 3px 45% 0; border-radius: 65% 65% 0 0; opacity: .7;
  background: linear-gradient(transparent, currentColor); box-shadow: 0 0 12px currentColor;
  animation: door-opening .8s ease-out both;
}
.loading-screen[data-kind="boss"] .loading-emblem { color: #ff826d; border-color: #9c4d48; box-shadow: inset 0 0 22px #d74248a0, 0 0 36px #b72d4570; }
.loading-screen[data-kind="boss"] strong { color: #ffd1bc; }
#loading-detail { max-width: 34ch; color: #d3b39f; }
@keyframes door-light { from { filter: brightness(.72); } to { filter: brightness(1.34); } }
@keyframes door-opening { from { transform: scaleX(.1); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .loading-screen[data-kind] .loading-emblem, .loading-screen[data-kind] .loading-emblem::before { animation: none; }
}
@media (max-width: 700px) {
  .loading-screen { gap: 7px; padding: 8px; }
  .loading-screen[data-kind] .loading-emblem { height: 45px; width: 36px; }
  .loading-screen strong { font-size: clamp(1.2rem, 5vw, 2rem); }
}
.intro { position: absolute; inset: 0; display: flex; align-items: center; background: linear-gradient(90deg, #131c1d 0%, #151e20e8 23%, #1922276b 52%, transparent 76%); }
.intro-content { padding-left: 6.7%; max-width: 54%; }
h1 { margin: 16px 0; font: bold clamp(2.1rem, 7.1vw, 6.15rem)/.95 Georgia, serif; letter-spacing: -.045em; text-shadow: 3px 4px #151e20; }
.intro p { margin: 19px 0 23px; max-width: 300px; color: #e1ccdb; font-size: clamp(.85rem, 1.5vw, 1rem); line-height: 1.55; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 16px; border-radius: 7px; font-weight: 900; }
.primary { background: #ff925f; border: 1px solid #ffac83; color: #241220; box-shadow: 0 4px #a0483d; }
.primary:hover { background: #ffaf81; }
.secondary { background: #2a2435; border: 1px solid #484054; }
.secondary:hover { border-color: var(--flare); }
.main-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.main-menu button { white-space: nowrap; }
.questline { display: flex; min-height: 53px; padding: 8px 18px; gap: 12px; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }
.quest { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: #e2d5df; }
.quest-dot { color: var(--gold); font-size: 1.23rem; }
.quest-copy { min-width: 0; }
.quest-status { display: block; max-width: 100%; margin-top: 3px; padding: 1px 0; border: 0; border-radius: 2px; background: transparent; color: var(--gold); text-align: left; font-size: .9em; font-weight: bold; }
.quest-status:hover { text-decoration: underline; text-underline-offset: 3px; }
.inventory-button { flex: none; display: flex; align-items: center; gap: 7px; background: transparent; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; padding: 4px 8px; }
kbd { display: inline-grid; place-items: center; border: 1px solid #50495d; border-bottom-width: 2px; border-radius: 5px; min-width: 24px; padding: 3px 5px; color: #e9d8e6; background: #282333; font-family: inherit; line-height: 1.1; font-size: .74rem; font-weight: 700; }
.inventory-button kbd { min-width: 20px; padding: 2px 3px; }
.log-list { margin: 0; padding-left: 19px; color: #e9d9e3; font-size: .88rem; line-height: 1.65; }
.log-list li::marker { color: var(--flare); }
footer { display: flex; justify-content: space-between; padding: 19px 0 25px; color: var(--muted); font-size: .75rem; }
.game-banner, .toast, .interact { position: absolute; pointer-events: none; text-align: center; }
.game-banner { top: 9%; width: 100%; text-shadow: 0 2px 4px #09060d; }
.game-banner small, .game-banner strong { display: block; }
.game-banner small { color: #fdbd8c; letter-spacing: .13em; font-weight: bold; font-size: .7rem; }
.game-banner strong { margin-top: 5px; font: bold clamp(1.05rem, 3vw, 2rem) Georgia, serif; }
.toast { top: 5%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92%; background: #1d1525f5; color: #ffeece; border: 1px solid #785348; border-radius: 6px; padding: 8px 12px; font-size: .84rem; }
.interact { bottom: 8%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92%; color: #ffebcc; background: #211927ef; border: 1px solid #785348; border-radius: 7px; padding: 6px 10px; font-size: .86rem; }
.interact kbd { margin-right: 6px; }
.modal-layer { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; background: #0c0814c5; z-index: 3; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 10px; }
.modal-card { flex: none; width: min(420px, 96%); margin-block: auto; padding: 17px 20px 21px; border: 1px solid #674952; border-radius: 11px; background: #211a2b; box-shadow: 0 10px 24px #100a17; }
.modal-card h2 { margin: 0 0 8px; font: bold clamp(1.1rem, 3vw, 1.65rem) Georgia, serif; color: #ffe5c7; }
#modal-art { display: block; width: 100%; height: auto; object-fit: cover; border: 1px solid #776251; border-radius: 5px; }
.portrait-card { display: grid; width: min(540px, 100%); grid-template-columns: clamp(72px, 23vw, 114px) minmax(0, 1fr); column-gap: 13px; }
.portrait-card #modal-art { grid-row: 1 / 3; aspect-ratio: 1; object-position: center 32%; margin-bottom: 12px; }
.portrait-card #modal-actions { grid-column: 1 / -1; }
.story-card { display: grid; width: min(960px, 100%); grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); grid-template-rows: 1fr auto auto 1fr; column-gap: 24px; padding: 16px; }
.story-card #modal-art { grid-row: 1 / span 4; align-self: center; aspect-ratio: 4 / 3; max-height: 360px; }
.story-card .modal-heading, .story-card #modal-text, .story-card #modal-speaker, .story-card #modal-actions { grid-column: 2; }
.story-card .modal-heading { grid-row: 1; align-self: end; }
.story-card #modal-text { grid-row: 2; }
.story-card #modal-speaker { grid-row: 3; }
.story-card #modal-actions { grid-row: 4; align-self: start; }
#modal-step { margin: 0 0 8px; color: #e4a77b; font-size: .75rem; font-weight: bold; }
#modal-speaker { display: flex; align-items: center; gap: 8px; margin: 0 0 13px; color: #ecd6bd; font-size: .83rem; }
#modal-speaker img { object-fit: cover; border: 1px solid #776251; border-radius: 5px; }
#modal-text { margin: 0 0 13px; font-size: .9rem; line-height: 1.45; color: #e2d0e0; white-space: pre-line; }
.goods-details { display: grid; gap: .65rem; margin: 0; white-space: normal; }
.goods-details dt { font-weight: bold; color: #ffe4c5; }
.goods-details dd { margin: 2px 0 0; }
.audio-card { padding: 9px 15px 12px; }
.audio-card #modal-text { margin-bottom: 8px; }
.audio-mixer { display: grid; gap: 7px; }
.audio-mixer fieldset { min-width: 0; margin: 0; padding: 5px 9px 7px; border: 1px solid #554753; border-radius: 6px; }
.audio-mixer legend { padding-inline: 5px; font-size: .83rem; font-weight: bold; color: #ffe4c5; }
.audio-level { display: grid; grid-template-columns: minmax(0, 1fr) 4ch; align-items: center; gap: 7px; }
.audio-level input[type="range"] {
  appearance: none; -webkit-appearance: none;
  width: 100%; min-width: 0; height: 22px; margin: 0; background: transparent; cursor: pointer;
  --track: #130e19;
  --thumb: #e8c591;
}
.audio-level input::-webkit-slider-runnable-track { height: 6px; border-radius: 4px; background: var(--track); }
.audio-level input::-moz-range-track { height: 6px; border-radius: 4px; background: var(--track); }
.audio-level input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -5px; border: 1px solid #392637; border-radius: 50%; background: var(--thumb);
}
.audio-level input::-moz-range-thumb {
  box-sizing: border-box;
  width: 16px; height: 16px; border: 1px solid #392637; border-radius: 50%; background: var(--thumb);
}
.audio-level output { text-align: right; font-variant-numeric: tabular-nums; }
.audio-mute { display: flex; align-items: center; gap: 5px; width: fit-content; cursor: pointer; }
.audio-mute input { margin-inline: 0; accent-color: var(--gold); }
.audio-mixer input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.admin-active .modal-card { width: min(520px, 100%); }
.admin-tools { display: grid; gap: 8px; white-space: normal; }
.admin-tools fieldset { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 5px 9px 9px; border: 1px solid #554753; border-radius: 6px; }
.admin-tools legend { color: #ffe4c5; padding-inline: 5px; font-weight: bold; }
.admin-tools select, .admin-tools input { color: inherit; background: #312538; border: 1px solid #8e758a; border-radius: 4px; padding: 4px; min-width: 0; width: 100%; font: inherit; }
.admin-tools select option { background: #312538; color: #ffe4c5; }
.admin-row { display: flex; flex-wrap: wrap; align-items: end; gap: 5px 8px; }
.admin-row > label { flex: 1 1 110px; }
.admin-tools button { padding: 5px 9px; font-size: .83rem; }
.admin-tools p { margin: 0; }
.admin-tools [role="status"] { min-height: 1.45em; color: #f0cda0; }
#admin[data-active] { border-color: var(--gold); color: var(--gold); }
#admin { padding-inline: 8px; }
#modal-actions { display: flex; flex-wrap: wrap; gap: 7px; }
#modal-actions button { padding: 7px 10px; font-size: .86rem; }
#modal-actions .keyboard-selected { outline: 2px solid var(--gold); outline-offset: 2px; }
.stage.help-active { width: 100%; min-height: min(510px, calc(100svh - 160px)); }
.help-card {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(748px, 100%); max-height: 100%; padding: 0; overflow: hidden;
}
.help-card .modal-heading, .help-card #modal-actions { padding: 11px 20px; background: #281e2e; }
.help-card .modal-heading { border-bottom: 1px solid #554052; }
.help-card h2 { margin: 0; font-size: clamp(1.3rem, 3vw, 1.8rem); }
.help-card #modal-text { min-height: 0; margin: 0; padding: 12px 20px; overflow-y: auto; overscroll-behavior: contain; white-space: normal; }
.help-card #modal-actions { justify-content: flex-end; border-top: 1px solid #554052; }
.help-guide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.help-guide section { min-width: 0; padding: 8px 12px; border: 1px solid #493a4e; border-radius: 7px; background: #251d2e; }
.help-guide h3 { margin: 0 0 6px; color: var(--gold); font-size: .96rem; }
.help-guide ul { display: grid; margin: 0; padding: 0; list-style: none; }
.help-guide li {
  display: grid; grid-template-columns: 102px minmax(0, 1fr);
  align-items: start; gap: 8px; padding: 4px 0; border-top: 1px solid #413345; line-height: 1.35;
}
.help-guide li > span:last-child { padding-top: 3px; overflow-wrap: anywhere; }
.help-guide small { display: block; color: #cbb5ca; font-size: .78rem; margin-top: 2px; }
.help-keys { display: flex; align-items: center; gap: 4px; white-space: nowrap; color: #cbb5ca; }
.help-keys kbd { min-height: 24px; border-color: #6b5264; background: #34293c; color: #fff0dc; }
.help-shield {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; column-gap: 10px;
  margin: 0; padding: 7px 10px; border-left: 2px solid #b98c65; border-radius: 3px;
  background: #32252f; font-size: .83rem;
}
.help-shield strong { color: var(--gold); }
.help-guide section:last-child { grid-column: 1 / -1; }
.help-guide section:last-child ul { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 12px; }
.help-guide section:last-child li { grid-template-columns: auto minmax(0, 1fr); font-size: .83rem; }
.inventory-card { width: min(610px, 100%); max-height: 100%; display: flex; flex-direction: column; }
.inventory-card #modal-actions { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 10px; min-height: 0; }
.inventory-groups { display: grid; gap: 13px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 3px; }
.inventory-description { min-height: 2lh; margin-top: 6px; padding: 6px 9px; border-left: 2px solid #ae8168; color: #ffe3c3; }
.inventory-card #modal-actions > button { flex: none; align-self: start; }
.inventory-group { min-width: 0; }
.inventory-group h3 { margin: 0 0 7px; padding-bottom: 5px; border-bottom: 1px solid #554753; color: #f0cda0; font-size: .86rem; }
.inventory-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 7px; }
.inventory-item { display: flex; align-items: center; min-width: 0; gap: 9px; text-align: left; }
.inventory-item > span { min-width: 0; overflow-wrap: anywhere; }
.inventory-item svg { flex: 0 0 28px; width: 28px; height: 28px; padding: 3px; border: 1px solid #514252; border-radius: 5px; background: #211a2b; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.inventory-item .gear-icon { flex: 0 0 28px; width: 28px; height: 28px; padding: 2px; border: 1px solid #655047; border-radius: 5px; background: #211a2b; }
.inventory-item small { display: block; margin-top: 2px; color: #caafc3; font-size: .74rem; font-weight: normal; font-variant-numeric: tabular-nums; }
.inventory-item .inventory-stat { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: center; gap: 6px; }
.inventory-stat progress { width: 100%; height: 5px; border: 0; border-radius: 2px; background: #443747; appearance: none; color: #b19dcd; }
.inventory-stat progress::-webkit-progress-bar { background: #443747; border-radius: 2px; }
.inventory-stat progress::-webkit-progress-value { background: currentColor; border-radius: 2px; }
.inventory-stat progress::-moz-progress-bar { background: currentColor; border-radius: 2px; }
#modal-actions .inventory-items button { min-width: 0; min-height: 44px; justify-content: flex-start; }
.inventory-items button[aria-disabled=true] { cursor: help; }
.inventory-empty { color: var(--muted); font-size: .82rem; }
.equipment-card { display: flex; flex-direction: column; width: min(640px, 100%); max-height: 100%; }
.equipment-card #modal-text { min-height: 0; overflow-y: auto; overscroll-behavior: contain; white-space: normal; }
.equipment-card h3 { margin: 4px 0 7px; color: #dbb78d; font: bold 1rem Georgia, serif; }
.equipment-card section + section { margin-top: 16px; }
.equipment-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 216px), 1fr)); gap: 8px; padding-right: 4px; }
.equipment-grid article { padding: 9px 12px; border: 1px solid #584553; border-radius: 6px; background: #2a2231; }
.equipment-grid h4 { display: flex; align-items: center; gap: 7px; margin: 0 0 5px; color: #ffe9ca; font-size: .94rem; }
.equipment-grid h4 > :first-child { flex: none; width: 27px; height: 27px; }
.equipment-grid svg { fill: none; stroke: currentColor; stroke-width: 1.5; }
.equipment-grid dl { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; row-gap: 3px; margin: 0; font-size: .82rem; }
.equipment-grid dd { margin: 0; color: #fff1dd; text-align: right; font-variant-numeric: tabular-nums; }
.equipment-card #modal-actions { flex: none; }
.bestiary-card { display: flex; flex-direction: column; width: min(660px, 100%); max-height: 100%; }
.bestiary-card #modal-text { min-height: 0; overflow-y: auto; overscroll-behavior: contain; white-space: normal; }
.bestiary-card #modal-actions { flex: none; }
.bestiary-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px; padding: 2px 6px 2px 2px; }
.bestiary-list .entry { display: grid; align-content: start; gap: 7px; padding: 8px; border: 1px solid #554753; border-radius: 6px; background: #28212e; font-size: .81rem; }
.bestiary-list .boss { border-color: #9c6257; }
.bestiary-list .identity { display: flex; gap: 9px; align-items: center; }
.bestiary-list .portrait { flex: none; width: 76px; height: auto; aspect-ratio: 124 / 98; border: 1px solid #625746; border-radius: 4px; background: #191b20; }
.bestiary-list h3 { margin: 0; color: #ffe4ba; font-size: 1rem; }
.bestiary-list p, .bestiary-list dl, .bestiary-list dd { margin: 0; }
.bestiary-list dl { display: flex; flex-wrap: wrap; gap: 4px 11px; padding-block: 4px; border-block: 1px solid #554753; }
.bestiary-list dt, .bestiary-list small { color: #d3beb0; font-size: .72rem; }
.bestiary-list dd { color: #ffe6bc; font-weight: bold; font-variant-numeric: tabular-nums; }
.sprite-link { display: block; padding: 2px 0; border: 0; background: none; color: #f0c797; font-size: .75rem; text-decoration: underline; text-underline-offset: 3px; }
.sprite-preview { width: min(590px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 17px; border: 1px solid #806552; border-radius: 8px; background: #232329; color: #ffecd2; }
.sprite-preview::backdrop { background: #121016db; }
.sprite-preview h2 { margin: 0 0 10px; font: 1.55rem/1.2 Georgia, serif; }
.sprite-preview select { width: 100%; padding: 8px; border: 1px solid #665846; border-radius: 4px; background: #1b1c21; color: inherit; font: inherit; }
.sprite-preview canvas { display: block; width: 100%; height: auto; margin-block: 10px; border: 1px solid #665846; border-radius: 4px; background: radial-gradient(ellipse at 50% 70%, #383a30, #171b20 88%); image-rendering: pixelated; }
.sprite-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sprite-controls input { flex: 1; min-width: 90px; accent-color: #e7a371; }
@media (max-width: 640px) {
  .stage.story-active { width: 100%; min-height: min(530px, calc(100svh - 110px)); }
  .stage.audio-active { width: 100%; min-height: 270px; }
  .stage.inventory-active { width: 100%; min-height: min(460px, calc(100svh - 150px)); }
  .stage.admin-active { width: 100%; min-height: min(470px, calc(100svh - 110px)); }
  .stage.equipment-active, .stage.bestiary-active { width: 100%; min-height: min(460px, calc(100svh - 125px)); }
  .stage.help-active { min-height: min(620px, calc(100svh - 155px)); }
  .help-guide { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .help-card .modal-heading, .help-card #modal-text, .help-card #modal-actions { padding: 11px 12px; }
  .help-guide section:last-child ul { grid-template-columns: repeat(auto-fit, minmax(min(126px, 100%), 1fr)); }
  .help-guide section:last-child li { align-content: start; gap: 5px; }
  .stage.story-active canvas, .stage.audio-active canvas, .stage.inventory-active canvas, .stage.admin-active canvas { object-fit: cover; }
  .inventory-card { padding: 12px; }
  .bestiary-card { padding: 12px; }
  .story-card { display: flex; flex-direction: column; padding: 12px; }
  .story-card #modal-art { order: 0; aspect-ratio: 1.8; max-height: 200px; margin-bottom: 10px; }
  .story-card .modal-heading, .story-card #modal-actions { align-self: stretch; }
}
@media (max-height: 470px) {
  .stage.help-active { min-height: min(250px, 65svh); }
}
@media (max-width: 700px) {
  .shell { width: calc(100% - 24px); }
  .mast-inner { height: 54px; }
  main { padding-top: 13px; }
  .hud { min-height: 54px; padding: 6px 9px; }
  .location { flex: 0 0 min(35%, 130px); min-width: 0; gap: 6px; }
  .location-icon { display: none; }
  .location strong { font-size: .79rem; overflow-wrap: anywhere; }
  .vitals { min-width: 0; flex-wrap: wrap; justify-content: flex-end; gap: 5px 7px; }
  .counter { min-width: auto; gap: 3px; font-size: .82rem; }
  .stage { aspect-ratio: 1.6; }
  canvas { object-fit: cover; }
  .intro-content { padding-left: 6%; max-width: 75%; }
  h1 { margin: 8px 0; }
  .intro p { margin: 8px 0 12px; line-height: 1.24; }
  .primary, .main-menu .secondary { padding: 8px 11px; font-size: .85rem; }
  .questline { padding: 5px 8px; min-height: 45px; }
  .quest { font-size: .75rem; gap: 4px; }
}
@media (max-width: 430px) { .menu-stage { width: 100%; min-height: 232px; } }
@media (max-width: 380px) {
  .brand { gap: 6px; font-size: .72rem; letter-spacing: .09em; }
  .brand-icon { width: 30px; height: 30px; }
  .mast-actions { gap: 5px; }
  .mast-actions .icon-button { width: 32px; height: 32px; }
  .location strong { font-size: .72rem; }
  h1 { font-size: 2.2rem; }
}
.map-card { width: min(920px, 100%); }
.map-scroll { height: clamp(150px, 28vw, 305px); overflow: auto; overscroll-behavior: contain; max-width: 100%;
  border: 1px solid #66554e; border-radius: 6px; background: #111a1b; scrollbar-color: #9c7660 #211a2b; cursor: grab; }
.map-scroll:active { cursor: grabbing; }
.room-map { display: block; max-width: none; user-select: none; }
#map-player path { fill: #fff0cc; stroke: #201926; stroke-width: 2; stroke-linejoin: round; }
#map-player circle { fill: #201926; }
#map-player text {
  fill: #fff0cc; font-size: 13px; font-weight: 700;
  stroke: #201926; stroke-width: 3; stroke-linejoin: round; paint-order: stroke;
}
.map-legend { margin: 8px 0 0; color: var(--muted); font-size: .82rem; }
@media (max-width: 700px) {
  .stage.map-active { width: 100%; min-height: min(350px, calc(100svh - 110px)); }
}
.health { position: relative; isolation: isolate; overflow: hidden; min-width: 90px; border: 1px solid #613d4d; border-radius: 5px; background: #281e2c; text-align: center; padding: 3px 6px; font-size: .73rem; font-variant-numeric: tabular-nums; }
.health span { position: absolute; z-index: -1; inset: 0 auto 0 0; width: 100%; background: #8d424e; }
.gem { font-style: normal; color: #a4d5ca; }
.quest { flex: 1; }
#modal-actions .option { flex-basis: 100%; justify-content: flex-start; }
#modal-actions .transfer { width: 100%; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.transfer input { min-width: 0; width: 90px; padding: 7px; font: inherit; border: 1px solid #675266; border-radius: 6px; }
@media (max-width: 700px) {
  .health { min-width: 58px; padding-inline: 3px; font-size: .65rem; }
  .questline { gap: 5px; }
  .inventory-button { gap: 4px; padding-inline: 4px; font-size: .76rem; }
}

.equipment-status { color: #e2c7d7; white-space: nowrap; font-size: .75rem; }
@media (max-width: 700px) { .equipment-status { display: none; } }
@media (max-width: 700px) {
  .level-status { min-width: 54px; }
  .armor-status { font-size: .68rem; }
}

#current-hero { display: block; color: #ceaf97; font-size: .73rem; font-weight: 650; }
#save-status { padding: 3px 8px; color: #ffc9b4; font-size: .75rem; }
.campaign-status { margin-top: 12px; color: #e6c6a9; font-size: .8rem; }
.campaign-status > button { display: block; margin-top: 7px; padding: 5px 10px; }
.campaign-label { display: grid; gap: 4px; text-align: left; }
.campaign-label small { color: #d3b9ab; font-size: .75rem; }
.primary .campaign-label small { color: #3e251e; }
.campaign-name { display: grid; gap: 8px; }
.campaign-name label { display: grid; gap: 7px; }
.campaign-name input { width: 100%; color: #fff1dc; background: #261e29; border: 1px solid #735b61; border-radius: 5px; padding: 8px 10px; font: inherit; }
.campaign-name small { color: #e5b68f; }

.touch-controls, .mobile-only { display: none; }

@media (pointer: coarse) {
  /* Use the visible viewport, including when mobile browser chrome expands or collapses. */
  html, body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
  button, a, .intro-content, .modal-layer, #modal-text, .inventory-groups, .map-scroll { touch-action: manipulation; }
  input:not([type="range"], [type="checkbox"], [type="radio"]), select, textarea { font-size: max(16px, 1em); }
  body { position: fixed; inset: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .shell { width: 100%; }
  .masthead { flex: none; }
  .mast-inner { height: auto; min-height: 50px; padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); }
  .mast-actions { gap: 5px; }
  .mast-actions .icon-button { width: 44px; height: 44px; }
  main.shell { flex: 1; min-height: 0; padding: 0; display: flex; }
  .cabinet { flex: 1; min-width: 0; display: flex; flex-direction: column; border: 0; border-radius: 0; box-shadow: none; }
  body.playing .masthead, .cabinet .questline, main > footer { display: none; }
  .hud { flex: none; min-height: 0; gap: 6px; padding: 2px max(8px, env(safe-area-inset-right)) 2px max(8px, env(safe-area-inset-left)); }
  .playing .hud { padding-top: max(2px, env(safe-area-inset-top)); }
  .hud .location { flex: 0 1 auto; min-width: 0; }
  .hud .location-icon, .hud .location small, .playing .hud #current-hero, .hud .equipment-status { display: none; }
  .hud .location strong { display: block; font-size: .83rem; line-height: 1.15; }
  .hud .vitals { flex-wrap: nowrap; gap: clamp(4px, 1.25vw, 14px); }
  .hud .counter { min-width: 0; }
  .hud .key-status, .hud .icon-button { min-width: 44px; height: 44px; }
  .hud .health { min-width: 58px; }
  .hud #pause[data-quest] { position: relative; }
  .hud #pause[data-quest]::after {
    content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px;
    background: #eab879; border-radius: 50%; box-shadow: 0 0 0 2px #221b29;
  }
  .playing .hud-controls { display: flex; flex: none; gap: 4px; }
  .hud #touch-sound { display: grid; }
  .hud #touch-inventory { display: grid; color: #f3cf96; }
  .effects { flex: none; gap: 3px 5px; padding: 2px max(8px, env(safe-area-inset-right)) 2px max(8px, env(safe-area-inset-left)); }

  .cabinet .stage { flex: 1; width: 100%; min-height: 0; aspect-ratio: auto; }
  #canvas { position: absolute; inset: 0; object-fit: contain; touch-action: none; -webkit-touch-callout: none; }
  .intro, .modal-layer, .loading-screen {
    padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .intro { overflow: hidden; background: linear-gradient(90deg, #121b1ef5, #171c24a6 54%, #171c2415 88%); }
  .intro-content { padding-left: clamp(4px, 4vw, 45px); max-width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
  .intro h1 { font-size: clamp(2.1rem, 13vh, 5rem); margin: 0 0 8px; }
  .intro p { margin: 8px 0 12px; }
  .main-menu button, #modal-actions button { min-height: 44px; }
  .modal-layer { overflow-x: hidden; }
  .modal-card { border-radius: 10px; padding: 12px; }
  .help-card { padding: 0; }
  .map-scroll { height: clamp(100px, 42dvh, 350px); }

  .touch-controls { display: block; position: absolute; inset: 0; z-index: 1; pointer-events: none; -webkit-touch-callout: none; }
  .stage > :is(#modal, #loading-screen):not([hidden]) ~ .touch-controls { display: none; }
  .touch-controls :is(.stick-zone, button) { pointer-events: auto; touch-action: none; }
  .stick-zone {
    --stick-size: clamp(84px, 28vh, 108px);
    position: absolute; left: max(6px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom));
    width: clamp(148px, 31vw, 270px); height: clamp(124px, 52%, 204px);
  }
  .stick-base {
    position: absolute; width: var(--stick-size); aspect-ratio: 1; border-radius: 50%;
    left: var(--stick-x, calc(var(--stick-size) / 2 + 16px)); top: var(--stick-y, calc(100% - var(--stick-size) / 2 - 8px));
    transform: translate(-50%, -50%); pointer-events: none;
    color: #ffe2af; border: 1px solid #dcb98780; box-shadow: inset 0 0 0 4px #190f1a66, 0 2px 6px #100e1599;
    background: #1c18288f; opacity: .8;
  }
  .stick-zone[data-active] .stick-base { opacity: 1; border-color: #e8ba81; }
  .stick-base span { position: absolute; font-size: 15px; line-height: 1; }
  .stick-up, .stick-down { left: 50%; translate: -50% 0; }
  .stick-up { top: 4px; }
  .stick-down { bottom: 4px; }
  .stick-left, .stick-right { top: 50%; translate: 0 -50%; }
  .stick-left { left: 6px; }
  .stick-right { right: 6px; }
  .stick-thumb {
    inset: 50% auto auto 50%; width: 40%; aspect-ratio: 1; border-radius: 50%; border: 1px solid #e8b8889c;
    background: radial-gradient(circle at 45% 30%, #846754, #403048 83%); box-shadow: 0 3px 8px #0e0e15c0;
    transform: translate(calc(-50% + var(--thumb-x, 0px)), calc(-50% + var(--thumb-y, 0px)));
  }

  .touch-actions {
    position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
    display: flex; align-items: flex-end; gap: 10px;
  }
  .touch-actions button {
    display: grid; place-items: center; padding: 0; aspect-ratio: 1; border-radius: 50%;
    border: 1px solid color-mix(in srgb, currentColor 63%, transparent);
    background: #211a2bba; box-shadow: inset 0 0 0 4px #2b202ab0, 0 3px 9px #0e0e16a8;
  }
  .touch-actions button svg { width: 48%; height: auto; }
  .touch-actions .touch-magic { position: relative; width: clamp(48px, 14vh, 61px); margin-bottom: 27px; color: #c4c0ff; }
  .touch-actions .touch-magic[data-empty] { color: #b8a8bc; }
  .touch-charges {
    position: absolute; bottom: -3px; right: -3px; min-width: 20px; padding: 2px 4px; border-radius: 9px;
    color: #e8ddff; border: 1px solid #9a7ea8; background: #241a30; font-size: .73rem; font-variant-numeric: tabular-nums;
  }
  .touch-actions .touch-attack { width: clamp(61px, 18vh, 78px); color: #ffd1a0; }
  .touch-actions button[data-active], .touch-actions button:active {
    background: #654357e6; box-shadow: inset 0 0 14px currentColor, 0 0 12px #fbcb994a;
  }
  .interact, .toast { z-index: 2; }
  .interact { bottom: max(12px, env(safe-area-inset-bottom)); max-width: min(48%, 360px); }
  .toast { top: 4%; }
}

@media (pointer: coarse) and (orientation: portrait) {
  .hud { align-items: start; }
  .hud .location { padding-top: 9px; }
  .hud .vitals { flex-wrap: wrap; }
  .hud .vitals .armor-status { order: 1; }
  .intro { align-items: end; }
  .intro-content { padding-bottom: max(22px, 6dvh); }
  .intro h1 { font-size: clamp(2rem, 11vw, 4rem); }
  .intro .rotate-hint { display: block; color: #d7b994; font-size: .8rem; }
  .interact { bottom: max(122px, calc(env(safe-area-inset-bottom) + 108px)); max-width: 92%; }
}

@media (pointer: coarse) and (max-height: 380px) and (orientation: landscape) {
  .intro h1 { font-size: clamp(2.1rem, 12vh, 3.2rem); }
  .intro p { margin-block: 4px 8px; }
  .story-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 5px 14px; }
  .story-card #modal-art { max-height: 185px; }
}


#install-game { min-height: 44px; margin-top: 9px; font-size: .82rem; padding: 6px 12px; }
.audio-enable { justify-self: start; min-height: 44px; padding: 7px 10px; }
