:root {
  color-scheme: dark;
  --background: #252622;
  --header: #2e3029;
  --slate: #393b33;
  --lift: #484a3f;
  --recess: #1c1e1a;
  --canvas: #4d473a;
  --seam: #6f6e60;
  --ink: #f2ead7;
  --quiet: #ccc3af;
  --rule: #808273;
  --brass: #dcb373;
  --active: #c1cca9;
  --active-surface: #353e30;
  --danger: #efb7a0;
  font: calc(18px * var(--text-scale, 1))/1.34 "Segoe UI", Arial, sans-serif;
  background: var(--background);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; min-width: 280px; }
button, select, summary, input { min-height: 48px; min-width: 48px; font: inherit; color: inherit; }
button, select, input {
  border: 1px solid var(--rule);
  border-radius: 7px 4px 6px 3px;
  background: var(--slate);
  padding: 8px 12px;
}
button, summary { cursor: pointer; }
button:enabled:hover { background: var(--lift); }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }
button.primary { background: var(--brass); color: #241c12; border-color: #edc992; font-weight: 700; }
button.primary:enabled:hover { background: #e9c58d; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1, h2 { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: -.025em; line-height: 1.1; }
h1 { font-size: 1.9em; }
h2 { font-size: 1.45em; }
h3 { font-size: 1em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.actions button { max-width: 100%; overflow-wrap: anywhere; }
.item-icon, .with-icon img { width: 28px; height: 28px; object-fit: contain; flex: none; }

.frame { max-width: 1440px; margin-inline: auto; }
.page, .start-screen { margin-inline: 24px; }
.text-size { color: var(--quiet); }
.warning { margin: 8px 16px; color: var(--danger); }
.start-screen {
  min-height: 305px;
  margin-top: 16px;
  padding: clamp(20px, 6vw, 65px);
  background: #151612;
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.title-art { width: min(310px, 76vw); max-width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.start-copy { display: grid; gap: 12px; background: var(--background); border-left: 3px solid var(--brass); padding: clamp(16px, 4vw, 32px); width: fit-content; }

#play { min-height: 100dvh; display: flex; flex-direction: column; }
.watchbar {
  min-height: 48px;
  padding: 5px 24px;
  display: flex;
  gap: 4px 14px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--header);
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
#play .watchbar { justify-content: space-between; padding-block: 0; }
.watchbar strong { color: var(--danger); }
#play #depth { color: var(--quiet); }
#play #turn { order: -2; font-weight: 650; }
#play #depth { order: -3; }
#review-label { color: var(--brass); }
.dungeon-heading {
  min-height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 5px 24px;
}
.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.dungeon-tools, .menu-heading { display: flex; align-items: center; gap: 8px; }
.menu-heading { justify-content: space-between; }
.menu-button { min-width: 48px; padding-inline: 8px; }
.dungeon-grid {
  flex: 1;
  display: grid;
  grid-template: "board context" 1fr "board belt" auto / minmax(0, 1.8fr) minmax(284px, 1fr);
  gap: 12px 16px;
  padding: 14px 24px 24px;
  min-width: 0;
}
.board-space {
  position: relative;
  grid-area: board;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 180px;
  background: var(--recess);
  border: 1px solid var(--rule);
  overflow: hidden;
}
canvas { display: block; }
#board { touch-action: manipulation; user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
#board:focus-visible { outline-offset: -3px; }
#pickup { position: absolute; top: 8px; right: 8px; max-width: calc(100% - 16px); padding: 5px 9px; background: var(--recess); border: 1px solid var(--rule); color: var(--active); pointer-events: none; }
#pickup:empty { display: none; }
.situation {
  grid-area: context;
  align-self: start;
  min-width: 0;
  display: grid;
  gap: 10px;
}
#feedback {
  padding: 10px 12px;
  background: var(--slate);
  border-left: 3px solid var(--active);
}
#reaction { color: var(--brass); }
#context-title:empty, #detail:empty, #reaction:empty, #here:empty { display: none; }
.context-actions { justify-content: flex-end; }
.context-actions button { text-align: left; }
.control-menu { display: grid; gap: 12px; margin-top: 14px; }
.menu-disclosure { border-top: 1px solid var(--rule); }
.menu-disclosure summary, .item-details summary { align-content: center; font-weight: 600; }
.menu-disclosure[open] > :not(summary) { margin-bottom: 8px; }
#dungeon-menu .keys { margin: 0; }
.mobility button { flex: 1; }
.text-size { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.keys { color: var(--quiet); }
.log { margin: 0; padding-left: 1.35em; color: var(--quiet); }
.belt {
  grid-area: belt;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.belt button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 84px;
  padding: 4px 2px;
  font-weight: 600;
  line-height: 1.16;
  overflow-wrap: anywhere;
}
.belt .belt-item { border-color: var(--brass); }
.belt strong { font-weight: 650; }
.belt button[aria-pressed="true"] { box-shadow: inset 0 -3px var(--active); color: var(--active); }

dialog.inventory {
  --hide: #49392a; --hide-edge: #211b16; --stitch: #9c805b; --lining: #35392f; --buckle: #d9b981;
  position: fixed; inset: 0; margin: 0; width: 100%; max-width: none; height: 100dvh; max-height: none;
  padding: env(safe-area-inset-top) max(0px,env(safe-area-inset-right)) env(safe-area-inset-bottom) max(0px,env(safe-area-inset-left));
  background: var(--hide-edge); border: 0; border-radius: 0; color: var(--ink); overflow: hidden; overscroll-behavior: contain;
}
dialog.inventory[open] { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto minmax(0,1fr) auto auto; }
dialog.inventory::backdrop { background: #15171186; }
dialog.inventory p { margin-block: 0; }
.inventory-header { background: var(--hide); border-bottom: 3px double var(--stitch); }
.inventory-header h1 { font-size: 1.45em; }
#inventory-title:focus { outline: none; }
.inventory .watchbar { max-width: 1060px; margin: auto; background: transparent; padding: 6px 16px; gap: 12px; flex-wrap: nowrap; }
.inventory .watchbar h1 { flex: 1; color: #f5dfb6; font-size: 1.75em; }
.inventory .return, .pack-dismiss { border-radius: 50%; background: #302820; border: 1px solid var(--stitch); color: var(--buckle); font-size: 1.4rem; line-height: 1; padding: 0; min-width: 44px; min-height: 44px; }
#inventory-status { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.return { min-width: 48px; font-weight: 700; border-color: transparent; padding-inline: 3px; background: transparent; }
.inventory-tabs { display: flex; align-items: stretch; justify-content: center; gap: 6px; padding: 3px 12px 7px; }
.inventory-tabs button { flex: 1; max-width: 220px; display: flex; justify-content: center; align-items: center; gap: 7px; padding: 4px 8px;
  border: 1px solid #786347; border-bottom: 3px solid #38271c; border-radius: 4px 4px 10px 7px; background: #3d3025; color: #d9c8a8; font: bold 1rem Georgia,serif; }
.inventory-tabs button[aria-pressed="true"] { background: #665037; color: #fff0ce; border-color: var(--buckle); border-bottom-color: #977146; }
.inventory-tabs img { width: 30px; height: 30px; object-fit: contain; }
@media (min-width: 761px) { :root:not([data-enlarged-text]) #gear-tab { display: none; } }
#items { min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--lining); }
.inventory-detail { display: flex; flex-direction: column; width: 100%; max-width: 900px; min-width: 0; gap: 12px; padding: 18px 24px 24px; }
.inventory-body { display: grid; gap: 12px; align-content: start; }
.inventory-body[inert] { opacity: .55; }
.inventory-prompt { display: grid; gap: 8px; border: 1px solid var(--brass); padding: 12px; background: var(--slate); }
.equipped-gear { display: grid; gap: 10px; }
.inventory-gear-layout { display: grid; grid-template-columns: minmax(0, 1.17fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.equipment-doll { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.95fr) minmax(0, 1fr); gap: 5px; align-items: center; }
.equipment-rail { display: grid; gap: 5px; min-width: 0; }
.equipment-slot { display: grid; justify-items: center; align-content: center; gap: 1px; padding: 3px; min-width: 0; min-height: 48px; font-size: .78rem; line-height: 1.13; overflow-wrap: anywhere; }
.equipment-slot .item-icon { width: 28px; height: 28px; }
.equipment-slot.vacant { background: var(--recess); }
.equipment-slot.occupied { background: var(--canvas); border-color: #9e8b6d; }
.equipment-slot.equip-target { border-color: var(--active); background: var(--active-surface); }
.equipment-slot.gear-drop-target, .bag-grid.gear-drop-target { outline: 2px solid var(--active); outline-offset: -2px; }
.equipment-slot[aria-pressed="true"] { border-color: var(--active); box-shadow: inset 0 0 0 1px var(--active); }
.empty-slot { font-size: .85rem; color: var(--quiet); }
#loadout-portrait { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 45% 45% 6px 6px / 20% 20% 6px 6px; }
.wear-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wear-comparison .on-floor { border-color: var(--brass); grid-column: 1 / -1; }
.wear-comparison .on-floor h3 { color: var(--brass); }
.wear-limit { color: var(--quiet); }
.gear-fire { color: #ffc09a; }
.gear-spark { color: #f2d478; }
.gear-corrosion { color: #bfd68a; }
.gear-ice { color: #ace3f6; }
.gear-art { display: inline-grid; place-items: center; }
.bag-section { display: grid; gap: 8px; width: min(100%, 480px); }
.bag-grid {
  display: grid; width: 100%; aspect-ratio: var(--bag-columns) / var(--bag-rows);
  grid-template-columns: repeat(var(--bag-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--bag-rows), minmax(0, 1fr));
  background: var(--recess); border: 1px solid var(--rule); isolation: isolate;
}
.bag-grid > * { min-width: 0; min-height: 0; }
.bag-cell { border-right: 1px solid var(--seam); border-bottom: 1px solid var(--seam); }
.bag-tile {
  display: grid; place-content: center; justify-items: center; position: relative; z-index: 1;
  background: var(--canvas); border: 1px solid #9e8b6d; border-radius: 3px; padding: 0; margin: 1px;
}
.bag-tile .gear-art { position: absolute; display: block; inset: 2%; }
.bag-tile .item-icon { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.bag-tile .gear-pair .item-icon { width: 54%; }
.bag-tile .gear-pair .item-icon:first-child { transform: scaleX(-1); }
.bag-tile .gear-pair .item-icon:last-child { left: 46%; }
.bag-tile small { position: absolute; right: 3px; bottom: 0; font-size: .75rem; font-weight: 700; }
/* Item power level (1-15), top left; the options eye sits top right and the bonus bottom right. */
.bag-tile .power-badge { position: absolute; left: 2px; top: 2px; z-index: 1; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
  display: grid; place-items: center; font-size: .66rem; font-weight: 700; line-height: 1; color: var(--recess); background: var(--brass); box-shadow: 0 0 0 1px var(--recess); }
.bag-tile.selected { outline: 2px solid var(--active); outline-offset: -3px; }
.bag-target { z-index: 2; padding: 0; border: 0; border-radius: 0; opacity: 1; background: transparent; }
.bag-target.fits { box-shadow: inset 0 0 0 2px var(--active); background: #5662474d; }
.bag-target.fits:hover { background: #627454ab; }
.bag-tile:focus-visible, .bag-target:focus-visible { outline: 3px solid var(--active); outline-offset: -3px; }
.bag-detail { display: grid; gap: 6px; padding: 10px; background: var(--header); border-left: 2px solid var(--active); }
.item-details { color: var(--quiet); border-top: 1px solid var(--seam); }
.item-details[open] p { margin-bottom: 6px; }
.loadout-slot { display: grid; align-content: start; gap: 6px; padding: 10px; border: 1px solid var(--rule); border-top: 2px solid var(--active); background: var(--header); min-width: 0; }
.loadout-slot h3 { color: var(--active); font-weight: 650; }
.slot-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.slot-item .item-icon { width: 36px; height: 36px; }
.vacant { border-style: dashed; color: var(--quiet); }
.inventory-find { display: grid; gap: 6px; }
.gear-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gear-slot {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  text-align: left;
  background: var(--slate);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.gear-slot > span { margin-left: auto; color: var(--quiet); }
.inventory .find { color: var(--brass); }
.weapon-comparison { width: 100%; max-width: 750px; border-collapse: collapse; table-layout: fixed; }
.weapon-comparison th, .weapon-comparison td { text-align: left; font-weight: 400; padding: 6px 4px; overflow-wrap: anywhere; }
.weapon-comparison th:first-child, .weapon-comparison td:first-child { color: var(--quiet); width: 29%; padding-left: 0; }
.weapon-comparison thead th { vertical-align: bottom; }
.weapon-comparison tbody tr { border-top: 1px solid var(--rule); }
.item-plate { display: grid; gap: 5px; margin-top: 3px; color: var(--ink); }
.item-plate .item-icon { width: 100%; height: 75px; padding: 4px; background: var(--canvas); border-bottom: 1px solid var(--rule); }
.item-plate .gear-art { display: grid; }
.find .item-plate .item-icon { background: #523c34; border-bottom-color: #bd9271; }
.inventory-footer { margin-top: auto; display: grid; gap: 10px; }
.inventory-footer button { min-width: 72px; flex: 1; max-width: 220px; font-weight: 650; }

.page { max-width: 880px; padding-block: 16px; display: grid; justify-items: start; gap: 12px; }
.service-content { display: grid; align-content: start; gap: 12px; min-width: 0; }
.service-content article { display: grid; gap: 8px; background: var(--slate); padding: 14px; border: 1px solid var(--rule); }
#skills { width: min(100% - 48px, 620px); }
.character-heading { display: flex; align-items: center; gap: 10px; }
.character-heading button { font-size: 1.5em; line-height: 1; padding-block: 0; }
.character-tabs { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; border-bottom: 1px solid var(--rule); }
.character-tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; font-weight: 650; padding-inline: 9px; }
.character-tabs button[aria-pressed="true"] { color: var(--active); border-bottom-color: var(--active); }
#skills-content { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.character-hero {
  display: grid; grid-template-columns: minmax(100px, 26%) minmax(0, 1fr); align-items: center; gap: 16px;
  padding: 12px; background: var(--header); border: 1px solid var(--rule); border-left: 3px solid var(--active);
}
#character-portrait { width: 100%; height: auto; border-radius: 50% 50% 5px 5px / 21% 21% 5px 5px; }
.character-vitals, .character-meter { display: grid; gap: 6px; min-width: 0; }
.character-vitals h2 span { color: var(--brass); font: 700 .7em / 1.2 'Segoe UI', sans-serif; letter-spacing: 0; white-space: nowrap; }
.character-vitals p { color: var(--quiet); }
.character-meter > div { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 8px; }
.character-meter progress { --fill: var(--active); display: block; width: 100%; height: 9px; border: 0; border-radius: 2px; overflow: hidden; background: var(--background); }
.character-meter progress::-webkit-progress-bar { background: var(--background); }
.character-meter progress::-webkit-progress-value { background: var(--fill); }
.character-meter progress::-moz-progress-bar { background: var(--fill); }
.character-meter #character-hp { --fill: var(--danger); }
.character-meter #character-mana { --fill: #ace3f6; }
.character-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.character-panel { display: grid; gap: 8px; align-content: start; padding: 12px; border: 1px solid var(--rule); background: var(--header); }
.character-panel button { justify-self: start; max-width: 100%; }
.character-stats { display: grid; gap: 2px; margin: 0; }
.character-stats > div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--seam); padding: 4px 0; }
.character-stats dd { margin: 0; font-weight: 650; white-space: nowrap; }
.character-panel h3 { color: var(--quiet); }
.character-disclosure { display: block; padding-block: 0; }
.character-disclosure summary { align-content: center; font-weight: 650; }
.character-disclosure summary small { color: var(--quiet); font-weight: 500; }
.character-disclosure > div { display: grid; gap: 8px; padding-bottom: 12px; }
.attributes header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.attribute-balance { color: var(--active); }
.attribute-list { display: grid; grid-template-columns: minmax(0, 1fr); padding: 0; margin: 0; list-style: none; }
.attribute-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 6px; padding: 2px 0; border-bottom: 1px solid var(--seam); }
.attribute-row:last-child { border-bottom: 0; }
.attribute-name { padding-inline: 0 8px; background: transparent; border: 0; text-align: left; overflow-wrap: anywhere; }
.attribute-name::after { content: ''; display: inline-block; width: 5px; height: 5px; border: solid var(--quiet); border-width: 0 1px 1px 0; transform: rotate(-45deg); margin-left: 8px; vertical-align: .13em; }
.attribute-placeholder { visibility: hidden; }
.attribute-controls { display: flex; gap: 4px; align-items: center; }
.attribute-controls button { padding: 0 6px; }
.attribute-value { display: grid; width: 2.25ch; min-width: 28px; text-align: center; line-height: 1.13; font-variant-numeric: tabular-nums; }
.attribute-value span { color: var(--active); font-size: .75em; }
.attribute-summary {
  display: grid; gap: 8px; padding: 10px 12px;
  background: var(--header); border: 1px solid var(--rule); border-top: 2px solid var(--brass);
}
.attribute-outcomes { display: grid; grid-template-columns: 1fr 1.12fr; gap: 8px; margin: 0; }
.attribute-outcomes dt { color: var(--quiet); font-size: .88rem; }
.attribute-outcomes dd { margin: 0; font-variant-numeric: tabular-nums; }
.attribute-outcomes .gain { color: var(--active); }
.attribute-actions .primary { flex: 1; }
.character-points { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.advancement strong, .character-points strong, .mastered strong { color: var(--active); }
.character-status { border-left: 2px solid var(--active); padding-left: 10px; color: var(--active); }
.skill-lock { color: var(--quiet); }
.town-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 24px; background: var(--header); }
#bank { color: var(--brass); }
.town-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 16px; padding: 0 24px 24px; }
.town-map { position: relative; min-height: 310px; aspect-ratio: 11 / 10; align-self: start; background: #76554c url('./art/town.png') center / cover; }
.town-map button { position: absolute; transform: translate(-50%, -50%); padding: 6px 10px; background: #2e3029f2; border-color: var(--brass); color: var(--ink); }
.town-map [aria-pressed="true"] { color: #29211d; background: var(--brass); }
.town-map [data-value="academy"] { left: 20%; top: 37%; }
.town-map [data-value="roster"] { left: 49%; top: 48%; }
.town-map [data-value="chapel"] { left: 81%; top: 39%; }
.town-map [data-value="smithy"] { left: 19%; top: 55%; }
.town-map [data-value="shop"] { left: 90%; top: 66%; }
.town-map [data-value="journal"] { left: 81%; top: 86%; }
.journal-list { margin: 0; padding-left: 1.35em; }
#overview { max-width: 100%; height: auto; outline: 1px solid var(--rule); cursor: pointer; touch-action: manipulation; }
dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); background: var(--slate); color: var(--ink); border: 1px solid var(--rule); padding: 22px; }
dialog p { margin-block: 12px; }
dialog::backdrop { background: #151711bf; }

@media (max-width: 760px) {
  .town-layout { grid-template-columns: minmax(0, 1fr); padding: 0 0 16px; }
  #town-service { padding: 0 16px; }
  .town-heading { padding: 12px 16px; }
  .page, .start-screen { margin-inline: 16px; }
  .start-screen { min-height: 100dvh; margin: 0; border: 0; padding: 16px; flex-direction: column; justify-content: center; gap: 12px; }
  .start-copy { width: min(100%, 310px); padding: 0; border: 0; background: transparent; }
  .start-copy .actions { display: grid; }
  .dungeon-hud { display: flex; align-items: center; gap: 6px; padding: 3px 8px; background: var(--header); border-bottom: 1px solid var(--rule); }
  #play .watchbar { flex: 1; min-width: 0; padding: 0; border: 0; column-gap: 4px; }
  #play :is(#turn, #review-label, #region-title) { display: none; }
  .dungeon-heading { min-height: 0; padding: 0; }
  .dungeon-tools { gap: 4px; }
  .dungeon-tools .with-icon { justify-content: center; padding-inline: 8px; }
  .dungeon-tools .with-icon span { display: none; }
  #play { height: 100dvh; }
  .dungeon-grid { position: relative; grid-template: "board" minmax(168px, 1fr) "belt" auto / minmax(0, 1fr); gap: 0; padding: 0; min-height: 0; }
  .board-space { position: relative; min-height: 0; border: 0; }
  #board { position: absolute; top: 0; left: 50%; transform: translateX(-50%); }
  .situation { position: absolute; grid-area: board; inset: auto 8px 8px; gap: 6px; pointer-events: none; }
  .situation button { pointer-events: auto; }
  .situation h2 { font-size: 1.15em; }
  #feedback { max-width: 100%; max-height: 35dvh; overflow: auto; pointer-events: auto; }
  .belt {
    margin-top: 0;
    background: var(--header);
    border-top: 1px solid var(--rule);
    padding: 6px 7px max(6px, env(safe-area-inset-bottom));
  }
  .belt button { min-height: 54px; padding-block: 2px; }
  .belt .item-icon { width: 24px; height: 24px; }
  .inventory-tabs { padding-inline: 16px; }
  .inventory .watchbar { padding-inline: 16px; }
  #inventory-status > span { display: none; }
  .inventory-detail { padding: 12px 16px 16px; }
  .inventory-gear-layout { grid-template-columns: minmax(0, 1fr); }
  .inventory-gear-layout[data-tab="bag"] > .equipped-gear,
  .inventory-gear-layout[data-tab="gear"] > .bag-section,
  .equipped-gear > h2 { display: none; }
  .character-overview { grid-template-columns: minmax(0, 1fr); }
  #skills { width: min(100% - 32px, 620px); padding-block: 8px 16px; gap: 4px; }
  #skills-content { gap: 10px; }
  .attribute-summary { position: sticky; bottom: 0; z-index: 1; }
  .character-heading h1 { font-size: 1.55em; }
  .character-hero { gap: 10px; padding: 8px; }
}
@media (max-width: 760px) and (max-height: 400px) {
  #play { height: auto; }
  .dungeon-grid { grid-template-rows: minmax(280px, 1fr) auto; }
}
@media (max-width: 355px) {
  #play .watchbar { font-size: .89rem; }
  .belt .item-icon { width: 22px; height: 22px; }
}
@media (min-width: 365px) and (max-width: 760px) {
  :root:not([data-enlarged-text]) .belt .belt-item strong { letter-spacing: -.025em; white-space: nowrap; }
}
:root[data-enlarged-text] .belt { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
:root[data-enlarged-text] :is(.inventory-gear-layout, .wear-comparison) { grid-template-columns: minmax(0, 1fr); }
:root[data-enlarged-text] :is(.inventory-gear-layout[data-tab="bag"] > .equipped-gear, .inventory-gear-layout[data-tab="gear"] > .bag-section) { display: none; }
:root[data-enlarged-text] .equipment-doll { grid-template-columns: repeat(2, minmax(0, 1fr)); }
:root[data-enlarged-text] :is(.character-overview, .character-hero) { grid-template-columns: minmax(0, 1fr); }
:root[data-enlarged-text] .attribute-row { grid-template-columns: minmax(0, 1fr); }
:root[data-enlarged-text] .attribute-summary { position: static; }
:root[data-enlarged-text] .attribute-outcomes { grid-template-columns: minmax(0, 1fr); }
:root[data-enlarged-text] #character-portrait { max-width: 180px; }
:root[data-enlarged-text] #loadout-portrait { grid-area: 1 / 1 / 2 / -1; width: min(100%, 230px); justify-self: center; }
:root[data-enlarged-text] .town-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: center; padding: 12px; gap: 8px; }
:root[data-enlarged-text] .town-map button { position: static; transform: none; overflow-wrap: anywhere; }
:root[data-enlarged-text] .inventory-footer button { max-width: 100%; flex-basis: 100%; }
:root[data-enlarged-text] .weapon-comparison th:first-child,
:root[data-enlarged-text] .weapon-comparison td:first-child { width: 30%; }

#items p > .item-icon, #items h3 > .item-icon, #town p > .item-icon, #town h3 > .item-icon, #town h4 > .item-icon { width: 1.6em; height: 1.6em; object-fit: contain; vertical-align: middle; }

/* The pack opens flat: buckled header, equipment on the lining, stitched pockets below. */
.inventory-detail { max-width: 1040px; min-height: 100%; margin: 0 auto; justify-content: center; padding: 14px clamp(10px,3vw,28px); }
.inventory-gear-layout { align-items: center; gap: clamp(12px,3vw,32px); }
.equipped-gear > h2 { display: none; }
.equipment-doll { grid-template-columns: minmax(0,1fr) minmax(0,1.55fr) minmax(0,1fr); gap: 8px; }
.equipment-rail { gap: 4px; }
.equipment-slot { color: #e5d9c1; border: 1px dashed #857961; border-radius: 7px 4px 8px 5px; }
.equipment-slot.vacant { background: #303229; }
.equipment-slot.vacant .item-icon { opacity: .32; filter: grayscale(1); }
.equipment-slot.occupied { background: #514532; border: 1px solid var(--buckle); }
.equipment-slot.occupied, .bag-tile { touch-action: none; -webkit-touch-callout: none; user-select: none; cursor: grab; }
#loadout-portrait { border: none; border-radius: 43% 43% 15% 15%; }
.bag-section { justify-self: center; width: min(100%,520px); gap: 4px; }
.bag-grid { padding: 0; position: relative; background: #38362b; border: 1px solid #ac9069;
  outline: 3px solid #4b3827; box-shadow: 0 0 0 5px #221e18, 0 5px 0 5px #252019; border-radius: 2px; }
.bag-cell { border-color: #706750; border-style: dashed; border-width: 0 1px 1px 0; pointer-events: none; background: #3c3a30; }
.bag-cell:nth-child(4n+1) { background: #39372e; }
.bag-tile { background: #574936; border: 1px solid #87714f; box-shadow: inset 0 0 0 1px #443b2c; border-radius: 6px 3px 7px 4px; }
.bag-tile:enabled:hover { background: #61533d; }
.pocket-options { align-self: start; justify-self: end; z-index: 2; margin: 1px; width: min(25px,45%); height: min(25px,45%); min-width: 0; min-height: 0;
  padding: 0; color: #f0d49b; background: #443726; border: 0; border-radius: 0 2px 0 9px; font: bold 16px/1 Georgia,serif; }
.pack-feedback { min-height: 26px; position: relative; }
#inventory-receipt:not([hidden]) { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 3;
  width: max-content; max-width: min(100%,760px); padding: 4px 12px; border-radius: 5px; background: #29251e; color: #e6d8bd; font-size: .83rem; text-align: center; }
.pack-menu, .inventory-prompt { position: absolute; z-index: 5; left: 50%; bottom: calc(63px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(460px,calc(100% - 20px)); max-height: calc(100% - 145px); overflow: auto; padding: 14px 15px; gap: 9px;
  background: #302a22; border: 2px solid #a78c62; border-radius: 10px 7px 12px 8px; box-shadow: 0 4px 16px #15130fb3; }
.pack-menu h3, .inventory-prompt h2 { padding-right: 36px; color: #fae6bf; font: bold 1.1rem/1.15 Georgia,serif; }
.pack-menu .pack-dismiss { position: absolute; right: 5px; top: 3px; border: 0; background: transparent; }
.pack-menu p, .inventory-prompt p { font-size: .9rem; }
.pack-risk { color: #f2c494; }
.pack-menu .actions, .inventory-prompt .actions { gap: 6px; }
.pack-menu .actions button, .inventory-prompt button, .inventory-footer button { min-height: 44px; padding: 6px 11px; color: #eddbbc;
  background: #50412e; border: 1px solid #927954; border-bottom: 3px solid #241c15; border-radius: 7px 4px 8px 4px; font-weight: 650; }
.pack-menu .actions .primary, .inventory-prompt .primary, .inventory-footer .primary { color: #282116; background: #d7b477; border-color: #ecd09b; border-bottom-color: #886339; }
.pack-menu .item-details summary { min-height: 36px; padding-top: 6px; font-size: .88rem; }
.keyboard-move:not(:focus-visible) { position: absolute; width: 1px; height: 1px; min-width: 0 !important; min-height: 0 !important; padding: 0 !important; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.inventory-body[inert] .pack-menu { visibility: hidden; }
.pack-placement { position: absolute; bottom: env(safe-area-inset-bottom); inset-inline: 0; z-index: 5; justify-content: center; background: var(--hide-edge); padding: 4px; }
#inventory:has(.pack-placement) .inventory-tabs { visibility: hidden; }
.pack-ghost { position: fixed; z-index: 10; pointer-events: none; opacity: .94; margin: 0; box-shadow: 2px 5px 12px #14110ec0; }
.drag-source { opacity: .38; }
#inventory:has(.pack-ghost) .pack-menu { visibility: hidden; }
.drop-footprint { pointer-events: none; z-index: 3; border: 2px dashed #df9575; background: #65362466; }
.drop-footprint.fits { border: 2px solid #e6c081; background: #bfa36e44; }
.floor-pocket { display: inline-flex; align-items: center; gap: 3px; min-height: 44px; padding: 2px 6px; background: #393024; border: 1px dashed var(--stitch); color: #f0d7b0; font-size: .8rem; }
.floor-pocket .item-icon { width: 22px; height: 22px; }
.inventory-body > p .item-icon { vertical-align: middle; }
@media (max-width:760px) {
  .inventory-gear-layout { gap: 15px; }
  .inventory-detail { padding: 12px; }
  .inventory-tabs { padding-inline: 10px; }
  .equipment-doll { grid-template-columns: minmax(0,1fr) minmax(0,1.35fr) minmax(0,1fr); gap: 5px; }
  .equipment-slot { display: flex; align-items: center; justify-content: flex-start; gap: 3px; min-height: 44px; padding: 3px; font-size: .7rem; }
  .equipment-slot .item-icon { width: 25px; height: 25px; }
  .equipment-rail:last-child .equipment-slot { flex-direction: row-reverse; text-align: right; }
}
@media (max-width:355px) {
  .inventory-tabs { gap: 4px; }
  .inventory-tabs button { min-width: 0; font-size: .9rem; gap: 3px; padding-inline: 3px; }
  .inventory-tabs img { width: 24px; }
}
@media (max-width:760px) and (min-height:760px) {
  :root:not([data-enlarged-text]) .inventory-gear-layout { width: min(100%,520px); margin-inline: auto; }
  :root:not([data-enlarged-text]) .inventory-gear-layout .bag-section { width: min(100%,calc((100dvh - 510px)*1.2)); }
  :root:not([data-enlarged-text]) #loadout-portrait { max-height: 220px; object-fit: contain; }
  :root:not([data-enlarged-text]) .inventory-gear-layout[data-tab] > :is(.bag-section,.equipped-gear) { display: grid; }
  :root:not([data-enlarged-text]) #gear-tab { display: none; }
}
@media (max-height:450px) {
  .inventory-detail { justify-content: flex-start; padding-block: 6px; }
  .bag-section { max-width: max(156px,calc((100dvh - 169px)*1.2)); }
  .equipment-rail { gap: 2px; }
  .equipment-slot { display: flex; align-items: center; justify-content: center; min-height: 34px; }
  .equipment-slot .item-icon { width: 22px; height: 22px; }
  #loadout-portrait { max-height: 165px; object-fit: contain; }
}

/* One illustrated satchel fits any loadout. Stretch its leather wings and keep the clasp to scale. */
#inventory {
  --flap: clamp(62px,10dvh,94px); --paper: #ebd4a2; --pen: #382718;
  border: 0 solid transparent;
  border-image: url('./art/grudge-sack.webp') 340 58 190 fill / 0 clamp(9px,2.8vw,27px) 62px stretch;
}
#inventory .inventory-header { height: var(--flap); background: #58301c; border: 0 solid transparent;
  border-image: url('./art/grudge-clasp.webp') 0 335 fill / 0 max(0px,calc((100% - var(--flap)*1.04)/2)) stretch; }
#inventory .watchbar { height: 100%; max-width: 1160px; padding-inline: clamp(14px,4vw,42px); align-items: center; }
#inventory-title { color: #ffe3a0; font: bold clamp(1.45rem,3.3vw,2.25rem)/.92 Georgia,serif; text-shadow: 1px 2px 1px #38200e, 0 0 9px #372112; transform: rotate(-2deg); }
#inventory-status { font-size: .88rem; text-shadow: 0 1px 3px #1f1007; }
#inventory-status strong { color: #ffdfba; }
#inventory .return { background: #4e2b1b; color: #f8d58c; border: 2px solid #ac7e43; box-shadow: inset 0 0 0 2px #482713,0 2px 0 #28180d; }
#items, .pack-feedback, .inventory-tabs { background: transparent; }
#inventory .inventory-detail { padding-inline: clamp(16px,4.2vw,44px); }
#inventory .equipment-slot { background: #172b216e; border-color: #9b9b7473; border-radius: 24% 5% 10% 7% / 15% 12% 10% 18%; color:#ede1bd; }
#inventory .equipment-slot.occupied { background: #5c482ded; border-style: solid; border-color: #b39a6a; }
#inventory .equipment-slot.vacant .item-icon { opacity: .46; filter: sepia(.7) saturate(.6); }
#inventory .bag-grid { background: transparent; border: 1px solid #c69a5c; outline: 3px solid #57371e; box-shadow: 0 0 0 5px #35251a, 0 4px 2px 5px #16201899; }
#inventory .bag-cell { background: #292b2138; border-color: #d3bb81aa; }
#inventory .bag-tile { border-radius: 5% 10% 6% 9%; background: #655034bd; box-shadow: inset 0 0 0 1px #5e462a; }
#inventory .inventory-tabs button { flex: 0 1 150px; background: #432315db; border: 1px solid #b88f59; border-bottom: 3px solid #27170e; color: #ebcca0; border-radius: 6% 12% 22% 8%; }
#inventory .inventory-tabs button[aria-pressed="true"] { color: #ffebc7; background: #754323ed; border-color: #dfb36a; }
.stat-ribbon { width: min(650px,calc(100% - 28px)); align-self: center; justify-self: center; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)) auto;
  align-items: center; gap: 2px; min-height: 47px; padding: 2px 9px; margin: 4px 0 1px; position: relative; z-index: 1;
  color: #332616; border: 0; border-radius: 3px; background: linear-gradient(100deg,#d2af72,#eed7a4 28%,#e7c991 80%,#c39b60);
  box-shadow: 1px 3px 0 #2c2019a8; }
.stat-ribbon, .stat-ribbon:enabled:hover { background: #e6c691 url('./art/appraisal-ticket.webp') center 42% / 100% auto no-repeat; }
.ribbon-stat { display: grid; align-content: center; text-align: center; font: bold 1.12rem/1.06 Georgia,serif; font-variant-numeric: tabular-nums; }
.ribbon-stat small { font: 650 .65rem/1.2 "Segoe UI",sans-serif; }
.ribbon-stat + .ribbon-stat { border-left: 1px dotted #ae9264; }
.ledger-tab { color: #642e20; font: italic bold .8rem Georgia,serif; border-left: 1px dashed #80613e; padding: 7px 0 7px 6px; }
.stat-gain { color: #1e5336; } .stat-loss { color: #8f2c22; }
.old-stat { font-weight: 500; }
.pack-menu, #kit-ledger { --pen:#382718; color: var(--pen); background: #ebd4a2 url('./art/appraisal-ticket.webp') center / 100% 100% no-repeat;
  border: 1px solid #7e5c37; border-radius: 15px 5px 18px 5px / 5px 15px 6px 13px; box-shadow: 0 4px 0 #50391f,0 8px 14px #171511a6; }
.pack-menu { position: fixed; bottom: calc(62px + env(safe-area-inset-bottom)); padding: 13px 16px 7px; gap: 8px;
  max-height: calc(100dvh - 145px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow: auto; }
.ticket-heading { display: flex; align-items: center; gap: 9px; padding-right: 25px; }
.ticket-heading > .gear-art { flex: none; width: 44px; height: 46px; transform: rotate(-5deg); }
.ticket-heading .item-icon { width: 100%; height: 100%; object-fit: contain; }
.pack-menu .ticket-heading h3 { color: #392615; font: bold 1.18rem/1.05 Georgia,serif; padding: 0; }
.ticket-heading i { display: block; margin-top: 3px; color: #67482a; font: italic .82rem/1.17 Georgia,serif; }
.pack-menu .pack-dismiss { color: #664324; }
.pack-menu .pack-risk { color: #7b2d20; font-weight: 650; }
.fit-comparison { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; }
.fit-label { font: italic .84rem Georgia,serif; }
.fit-values, .receipt-changes { display: flex; flex-wrap: wrap; gap: 3px 12px; }
.fit-values, .kit-change { font-size: .83rem; }
.kit-change { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.kit-change b { font-variant-numeric: tabular-nums; }
.pack-menu .actions button { background: transparent; color: #593623; border: 0; border-bottom: 1px dashed #9e8154; border-radius: 0; padding: 5px 10px; }
.pack-menu .actions button:enabled:hover { background: #cdad76; }
.pack-menu .actions .primary { color: #ffefd1; background: #8a3724; border: 2px solid #59291b; border-radius: 16% 10% 20% 8%; padding-inline: 16px; box-shadow: inset 0 0 0 1px #cb8053,1px 2px 0 #70492e; }
.pack-menu .actions .primary:enabled:hover { background: #99432c; }
.pack-menu .item-details { color: #4d3925; border-top: 1px dashed #a48354; }
.pack-menu .item-details summary { min-height: 32px; color: #5b3824; }
.pack-menu :is(button,summary) { -webkit-tap-highlight-color: #a8793c33; }
#kit-ledger { width: min(480px,calc(100% - 24px)); max-height: calc(100dvh - 30px); padding: 16px; }
#kit-ledger::backdrop { background: #131710aa; }
.ledger-head { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.ledger-head button { background: none; border: 0; color: #442b18; font-size: 1.4rem; }
#ledger-entries h3 { margin: 10px 0 3px; color: #74412a; font: bold 1.08rem Georgia,serif; }
#ledger-entries dl { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 3px 16px; margin: 0; }
#ledger-entries dl div { display:flex; justify-content:space-between; align-items:baseline; gap:3px; border-bottom: 1px dotted #a88c5f; font-size:.85rem; }
#ledger-entries dd { margin:0; font-weight:bold; }
#ledger-entries p { margin: 7px 0; font: italic .85rem Georgia,serif; }
#inventory-receipt:not([hidden]) { color: #ffecd3; background: #31241a; }
.receipt-changes { justify-content: center; }
.receipt-changes .stat-gain { color: #b9df9e; } .receipt-changes .stat-loss { color: #ffb194; }
.inventory-body > .fit-comparison .stat-gain { color: #b9df9e; } .inventory-body > .fit-comparison .stat-loss { color: #ffb194; }
@media(max-width:540px) {
  #inventory-title { max-width: 38%; margin-right: auto; }
  #inventory-status > span { display:none; }
  #inventory .watchbar { gap:5px; }
  #inventory .floor-pocket { width:32px; min-width:32px; overflow:hidden; font-size:0; padding:2px; }
}
@media(max-height:450px) {
  #inventory { --flap: 46px; }
  .stat-ribbon { min-height:38px; margin-block:0; }
  .bag-section { max-width: max(130px,calc((100dvh - 206px)*1.2)); }
}
@media(prefers-reduced-motion:no-preference) {
  .stat-ribbon b:is(.stat-gain,.stat-loss) { display:inline-block; animation: tally-mark .22s ease-out; }
  @keyframes tally-mark { from {transform:scale(1.23) rotate(-4deg)} to {transform:scale(1)} }
}

/* The dungeon controls are the porter's belt. Its buckle opens the licence. */
#play { background: #201e18; }
.dungeon-hud, #actions { background: #23332b url('./art/porter-strap.webp') center / 100% 100%; }
#play .watchbar { background: transparent; color: #ffe4ac; border: 0; font-family: Georgia,serif; }
#play #depth { color: #f0d8a6; font-weight: bold; }
/* Board HUD: the delver's face (opens the licence) with a level badge, three bars, and a minimap (opens the map). */
.board-hud { position: absolute; top: 8px; left: 8px; z-index: 3; display: flex; align-items: center; gap: 6px; pointer-events: none; }
.hud-portrait { position: relative; pointer-events: auto; width: 58px; height: 58px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid #d9b46e; background: #3a2a1d; box-shadow: 0 0 0 2px #1b120c, 0 3px 6px #000a; }
.hud-portrait:hover, .hud-portrait:focus-visible { border-color: #ffe0a0; outline: none; box-shadow: 0 0 0 2px #1b120c, 0 0 0 4px #ffe0a0aa; }
.hud-portrait:active { transform: translateY(1px); }
.hud-face { position: absolute; inset: 0; overflow: hidden; border-radius: 50%; }
.hud-face img { position: absolute; left: 50%; top: 0; width: 190%; height: auto; transform: translate(-50%, var(--face-y, -3%)); max-width: none; }
.hud-level { position: absolute; right: -6px; top: -4px; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px;
  display: grid; place-items: center; font: bold .8rem/1 Georgia,serif; color: #2a1a0f; background: #f0c66e; border: 2px solid #1b120c; }
.hud-bars { display: grid; gap: 3px; width: min(132px, 34vw); }
.hud-bar { position: relative; height: 10px; border-radius: 5px; background: #1b120cd9; box-shadow: 0 0 0 1px #000a, inset 0 0 0 1px #f6e2b84d; overflow: hidden; }
.hud-bar.hp { height: 13px; border-radius: 6px; }
.hud-bar i { position: absolute; inset: 1px auto 1px 1px; max-width: calc(100% - 2px); border-radius: inherit; transition: width .25s ease-out; }
.hud-bar.hp i { background: linear-gradient(#e46a5c, #b8352a); }
.hud-bar.hp[data-low="true"] i { background: linear-gradient(#ff8a5c, #d9412a); animation: hud-low 1s ease-in-out infinite alternate; }
.hud-bar.mana { background: #0f1a33d9; box-shadow: 0 0 0 1px #000a, inset 0 0 0 1px #6fa8ff55; }
.hud-bar.mana i { background: linear-gradient(#6fa8ff, #3561c4); }
.hud-bar.hp { background: #2a0f0cd9; }
.hud-bar.xp { height: 7px; background: #2a210cd9; box-shadow: 0 0 0 1px #000a, inset 0 0 0 1px #f5d47e55; }
.hud-bar.xp i { background: linear-gradient(#f5d47e, #c69631); }
@keyframes hud-low { to { filter: brightness(1.35); } }
@media (prefers-reduced-motion: reduce) { .hud-bar i { transition: none; } .hud-bar.hp[data-low="true"] i { animation: none; } }
.hud-minimap { position: absolute; top: 8px; right: 8px; z-index: 3; width: 108px; height: 108px; padding: 3px; display: grid; place-items: center;
  background: #11191bd9; border: 2px solid #d9b46e; border-radius: 8px; box-shadow: 0 0 0 2px #1b120c, 0 3px 6px #000a; cursor: pointer; }
.hud-minimap canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.hud-minimap:focus-visible { outline: 3px solid #ffe0a0; outline-offset: 1px; }
#play #pickup { top: 128px; }
.dungeon-heading { color: #ffe4aa; }
.dungeon-tools button, #here button, #direction-pad button { color: #f7deaa; border: 1px solid #ad8350; border-bottom: 3px solid #332216; background: #543927; box-shadow: inset 0 0 0 1px #785536;
  border-radius: 18% 9% 14% 7% / 16% 14% 16% 12%; font-family: Georgia,serif; }
#here .primary { background: #7b4027; }
#actions { align-self: end; align-items: stretch; gap: 3px; padding: 7px 7px max(7px,env(safe-area-inset-bottom)); border: 1px solid #71532d; }
#actions button { position: relative; border: 1px solid #9b7145; border-bottom: 3px solid #2b1b11; border-radius: 8% 12% 24% 14% / 10% 12% 22% 24%;
  background: linear-gradient(100deg,#523220ed,#674430de 56%,#462d20f5); color: #f9dfaa; font: bold .9rem/1.05 Georgia,serif; padding: 3px 0 5px; }
#actions button[aria-pressed="true"] { color: #fff1ca; outline: 2px solid #e0bb72; outline-offset: -3px; }
#actions .item-icon { width: 35px; height: 33px; filter: drop-shadow(1px 2px 0 #281a13); }
.belt-count { position: absolute; right: 9%; top: 4px; font: bold .74rem Georgia,serif; color: #ffe7b2; }
#feedback, #pickup { color:#ffe4b4; background:#35291fec; border:1px solid #a88454; border-left:3px solid #b58c4a; border-radius:6px 12px 7px 4px; }
#feedback p { margin:0; }
#dungeon-menu, #attribute-help { background: #ebcd94 url('./art/appraisal-ticket.webp') center / 100% 100%; color: #3d291a; --quiet:#55402b; --rule:#a18459; border:1px solid #927244; border-radius: 8px 13px 5px 10px; }
#dungeon-menu button, #attribute-help button { background:#6a422a; color:#ffebc1; border:1px solid #9b7041; }
@media (max-width:760px) {
  .dungeon-hud { padding: 2px 7px; gap:4px; border-bottom: 2px solid #8d6940; }
  #play .watchbar { flex-wrap: nowrap; }
  #play .dungeon-tools button { padding: 1px; min-width: 44px; min-height:44px; }
  #actions button { min-height: 55px; }
}

/* A stitched cover, paper leaves and a live passport likeness. */
#skills { --ink:#352618; --quiet:#654b32; --rule:#ab8653; --seam:#b89969; --active:#285338; --brass:#754526;
  width:min(100%,680px); margin:0 auto; padding: 0 clamp(9px,2vw,18px) 16px; min-height:100dvh; align-content:start; gap:0;
  background: #253b30 url('./art/porter-strap.webp') center / auto 100%; color:var(--ink); }
.character-heading { width:100%; padding:5px 3px; min-height:56px; gap:11px; color:#ffe0a1; }
.character-heading h1 { font:bold clamp(1.45rem,4vw,2rem)/1 Georgia,serif; transform:rotate(-1.2deg); }
.character-heading button { border:1px solid #ab8855; border-radius:50% 45% 47% 43%; background:#523622; color:#f0d091; min-width:44px; min-height:44px; }
.character-tabs { border:0; padding:0 6px; gap:4px; align-items:end; }
.character-tabs button { color:#f7d091; background:#76472b; border:1px solid #a68251; border-radius:8px 9px 0 0; min-height:44px; padding:3px 13px; font:bold .96rem Georgia,serif; }
.character-tabs button[aria-pressed="true"] { color:#392616; background:#eccb90; border-color:#d4a86b; border-bottom:0; }
#skills-content { color:#39281a; gap:6px; padding:clamp(12px,3.5vw,22px); min-height:55dvh; align-content:start;
  background:#ecd099 url('./art/appraisal-ticket.webp') center / 100% 100%; border:1px solid #846638; box-shadow:2px 3px 0 #b18c57,4px 5px 0 #553d28; }
.character-hero { background: none; border:0; grid-template-columns:minmax(85px,29%) minmax(0,1fr); gap:11px; padding:2px 0 7px; border-bottom:2px solid #8b633b; }
.licence-portrait { position:relative; justify-self:center; width:min(100%,125px); transform:rotate(-3deg); background:#cbad70; box-shadow:inset 0 0 0 2px #997844,2px 2px 0 #a58554; }
#character-portrait { display:block; width:100%; }
.licence-stamp { position:absolute; bottom:0; right:-5%; transform:rotate(-7deg); color:#743324; background:#eed4a2eb;
  font:bold italic .65rem/1.05 Georgia,serif; padding:1px 4px; border:2px double #99583d; white-space:nowrap; }
.character-vitals h2 { font-size:1.4em; }
.character-vitals h2 span { display:inline-block; font:bold .72rem Georgia,serif; }
.character-vitals,.character-meter { gap:2px; }
.character-meter label,.character-meter strong { font: bold .83rem/1.2 Georgia,serif; }
.character-meter progress { --fill:#526348; height:6px; margin:2px 0 3px; border-radius:3px; background:#ac8959; }
.character-meter progress::-webkit-progress-bar { background:#bd9d6a; }
.character-meter #character-hp { --fill:#a74330; } .character-meter #character-mana { --fill:#326776; }
#skills .character-panel, #skills .service-content article { background:transparent; border:0; padding:3px 0; }
#skills .attributes { gap:2px; }
.attributes header h2 { font-size:1.22rem; }
.attribute-balance { font:bold italic .9rem Georgia,serif; }
.attribute-row { padding:0; border-bottom:1px dotted #aa8957; }
.attribute-controls button, #skills .attribute-actions button, #skills-content .primary { min-height:44px; min-width:44px; }
#skills .attribute-name { min-height:44px; color:#3c2a1b; font:bold 1.03rem Georgia,serif; }
#skills .attribute-name::after { display:none; }
.attribute-controls button { background:transparent; border:0; color:#673c24; font:bold 1.35rem Georgia,serif; }
.attribute-controls button:disabled { opacity:.55; }
.attribute-value strong { font:bold 1.2rem Georgia,serif; }
.attribute-summary { color:#372719; background:#edd09a; border:0; border-block:2px solid #a58050; padding:5px 0; gap:3px; }
.attribute-actions { gap:2px; }
#skills .attribute-actions button { color:#573822; background:transparent; border:0; font:bold .94rem Georgia,serif; }
#skills .attribute-actions .primary,#skills-content button.primary { background:#803d29; color:#ffebc6; border:2px solid #5e3121; border-radius:6px 9px 7px 4px; }
.attribute-outcomes dt { font:bold .79rem Georgia,serif; }
.character-disclosure summary { font:bold 1rem Georgia,serif; min-height:44px; }
#skills .character-overview { gap:3px 15px; }
#skills .character-panel summary { border-bottom:1px dotted #9b784b; }
#skills-content button:not(.attribute-name,.primary) { color:#583a23; }
#skills-content .character-disclosure button { background:#e4c38b; }
#skills-content .character-disclosure button.primary { background:#803d29; }
/* Keep the first lines clear of the ticket's corner pin. */
#skills-content > .character-points, #skills-content > .character-status, #skills-content > .character-points + p { padding-left:14px; }
#skills-content .character-status { font-size:.88rem; }
#skills-content .skill-heading { font:bold 1.12rem Georgia,serif; color:#3a2615; margin-top:8px; border-top:2px solid #8b633b; padding-top:6px; }
#skills-content .service-content { padding:8px 0; font-family:Georgia,serif; }
:root[data-enlarged-text] #skills .character-hero { grid-template-columns:minmax(0,1fr); }

#inventory .equipment-doll { width:min(100%,410px); margin:auto; grid-template-columns:clamp(45px,13vw,68px) minmax(0,1fr) clamp(45px,13vw,68px); }
#inventory .equipment-rail { align-items:center; gap:2px; }
#inventory .equipment-slot { position:relative; justify-content:center; padding:2px; width:100%; min-height:40px; height:clamp(40px,5.6dvh,56px); }
#inventory .equipment-slot > .gear-art { position:relative; display:block; width:100%; height:100%; }
#inventory .equipment-slot .item-icon { display:block; width:100%; height:100%; max-width:100%; object-fit:contain; }
#inventory .equipment-slot.vacant .item-icon { width:72%; height:78%; margin:auto; opacity:.48; }
#inventory .ticket-heading { display:flex; align-items:center; padding-right:33px; min-height:46px; gap:7px; }
#inventory .ticket-heading > .gear-art { display:block; position:relative; width:34px; height:44px; overflow:hidden; }
#inventory .ticket-heading > .gear-art .item-icon { display:block; position:static; max-width:100%; max-height:100%; width:100%; height:100%; object-fit:contain; }
.appraisal-eye { display:grid; place-items:center; min-width:44px; min-height:44px; margin-left:auto; border:0; background:transparent; }
.appraisal-eye .item-icon { width:25px; height:25px; }
#inventory .pack-dismiss { min-width:38px; min-height:44px; }
.appraisal-notes { border-top:1px dashed #ab8d61; padding-top:4px; }
.appraisal-notes p { margin:3px 0; }
#inventory .supply-tile { touch-action:none; }
#inventory .supply-tile small { background:#35291ee6; color:#ffedc5; min-width:1.25em; border-radius:6px; }
#inventory .pack-menu { bottom: max(12px,env(safe-area-inset-bottom)); }
@media (max-width:760px) and (max-height:759px) { #inventory .pack-menu { bottom:calc(55px + env(safe-area-inset-bottom)); } }
@media (min-width:761px), (min-height:760px) {
  :root:not([data-enlarged-text]) .inventory-tabs { display:none; }
  :root:not([data-enlarged-text]) #inventory { grid-template-rows:auto auto minmax(0,1fr) auto; }
  :root:not([data-enlarged-text]) .inventory-gear-layout .bag-section { width:min(100%,520px); }
}
@media (max-width:760px) and (min-height:760px) {
  :root:not([data-enlarged-text]) .inventory-gear-layout .bag-section { width:min(100%,calc((100dvh - 460px)*1.2)); }
}
:root[data-enlarged-text] #inventory .pack-menu { bottom:calc(62px + env(safe-area-inset-bottom)); }
#inventory .pack-feedback { min-height:30px; }
#inventory .pack-menu p { margin-block:2px; }
#inventory .pack-menu .pack-risk { font-size:.88rem; }


#skills .attribute-controls button:enabled:hover, #skills .attribute-name:enabled:hover { background:#d8b783; }
#skills .character-panel summary { list-style:none; cursor:pointer; }
#skills .character-panel summary::-webkit-details-marker { display:none; }
#skills .character-disclosure summary { display:flex; align-items:center; justify-content:space-between; gap:8px; }
#skills .character-disclosure summary::after { content:''; width:21px; height:21px; flex:none; background:url('./art/interface/eye.png') center / contain no-repeat; }
#skills .character-disclosure[open] summary { color:#723b26; }

#inventory .pocket-options { display:grid; place-items:center; width:24px; height:24px; background:#5b3e26; border-radius:0 4px 0 50%; }
#inventory .pocket-options .item-icon { width:16px; height:14px; object-fit:contain; pointer-events:none; }
@media (max-width:760px) and (min-height:560px) and (max-height:759px) {
  :root:not([data-enlarged-text]) #inventory { grid-template-rows:auto auto minmax(0,1fr) auto; }
  :root:not([data-enlarged-text]) #inventory .inventory-tabs { display:none; }
  :root:not([data-enlarged-text]) #inventory .inventory-gear-layout[data-tab] > :is(.bag-section,.equipped-gear) { display:grid; }
  :root:not([data-enlarged-text]) #inventory .equipment-doll { grid-template-columns:minmax(84px,1fr) minmax(76px,1.4fr) minmax(84px,1fr); }
  :root:not([data-enlarged-text]) #inventory .equipment-rail { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px; }
  :root:not([data-enlarged-text]) #inventory .equipment-slot { height:44px; min-height:44px; min-width:0; }
  :root:not([data-enlarged-text]) #inventory .equipment-rail:last-child .equipment-slot:last-child { grid-column:2; }
  :root:not([data-enlarged-text]) #inventory .bag-section { width:min(100%,calc((100dvh - 320px)*1.2)); }
  :root:not([data-enlarged-text]) #inventory .pack-menu { bottom:max(9px,env(safe-area-inset-bottom)); }
}

.delver-likeness { object-fit:contain; user-select:none; pointer-events:none; }
#inventory #loadout-portrait { border-radius:0; padding:4px; justify-self:center; max-width:240px; filter:drop-shadow(1px 3px 1px #15221da8); }
#skills #character-portrait { padding:4px 5px 8px; border-radius:0; }

#enrolment {
  --ink:#38271c; width:min(400px,calc(100% - 18px)); max-height:calc(100dvh - 16px); overflow-y:auto;
  padding:0; color:var(--ink); background:#efd4a0 url('./art/appraisal-ticket.webp') center / 136% 126%;
  border:2px solid #75502c; border-radius:15px 10px 12px 6px; box-shadow:0 7px 24px #0c0b09aa;
}
#enrolment::backdrop { background:#191e18ed; }
#enrolment button { color:#55341f; border:0; background:transparent; font:bold .98rem/1.1 Georgia,serif; min-height:44px; }
#enrolment .enrolment-head { display:flex; align-items:center; justify-content:space-between; padding:2px 8px 2px 16px;
  background:#442d20; color:#fff0cf; border-bottom:2px solid #bb8a4d; }
#enrolment-title { font:bold 1.45rem/1.15 Georgia,serif; margin:0; color:inherit; }
#enrolment-title:focus { outline:none; }
#enrolment .enrolment-head button { color:#f2d6a4; font-size:1.55rem; width:44px; }
#enrolment-sheet { display:grid; gap:9px; padding:13px 16px 16px; }
.enrol-actions,.enrol-balance,.enrol-signature { display:flex; align-items:center; gap:4px; }
.casting { display:grid; margin:-13px -16px 0; text-align:center; }
.casting-stage { display:grid; grid-template-columns:50px minmax(0,1fr) 50px; align-items:center; justify-items:center;
  padding:10px 8px 5px; height:clamp(130px,27dvh,236px); background:#203d32 url('./art/porter-strap.webp') center / cover;
  border-bottom:3px ridge #ad8150; }
.casting-figure { display:block; width:100%; height:100%; min-height:0; max-height:100%; object-fit:contain; filter:drop-shadow(0 3px 1px #17191080); }
#enrolment .race-arrow { width:45px; height:45px; border-radius:50%; color:#ffe6a5; background:#59412b;
  border:3px ridge #be904c; box-shadow:0 3px 2px #0d1712; font:bold 1.15rem Georgia,serif; }
.casting-caption { padding:8px 12px 0; }
.casting-count,.enrol-name,#enrolment .change-look span { font:bold .78rem/1.3 Georgia,serif; color:#694623; }
.casting-caption h3 { font:bold clamp(1.72rem,8vw,2.3rem)/1.12 Georgia,serif; margin:2px 0 0; color:#392318; }
.casting-gift { text-align:center; padding:0 6px 10px; border-bottom:1px solid #ac864f; }
.casting-gift strong { font:italic bold 1.04rem/1.3 Georgia,serif; color:#67371f; }
.casting-gift p { min-height:2.6em; margin:3px auto 0; max-width:30ch; color:#382b20; font:1rem/1.3 Georgia,serif; }
.casting-sign { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:end; gap:12px; }
.enrol-name { display:grid; gap:1px; }
.enrol-name input { width:100%; min-width:0; min-height:44px; background:#fff4d644; color:#38271b; padding:5px 4px;
  border:0; border-bottom:2px solid #8a6036; border-radius:0; font:bold 1.05rem Georgia,serif; }
#enrolment .change-look { text-align:left; padding:0 4px; min-height:61px; }
#enrolment .change-look span { display:block; padding-bottom:9px; }
#enrolment .seal-button { font:bold 1.13rem Georgia,serif; color:#fff0cb; background:#813d28; border:2px ridge #ad7645;
  border-radius:7px 12px 8px 5px; box-shadow:0 2px 0 #593421; }
.enrol-actions > .seal-button { flex:1; }
.enrol-balance { justify-content:space-between; border-bottom:1px dashed #977247; }
.enrol-signature img { width:53px; height:62px; }
.enrol-signature { padding-top:5px; gap:9px; }
.enrol-signature h3 { font:bold 1.23rem Georgia,serif; }
.birth-stats { margin:0; padding:0; }
.birth-stat { display:grid; grid-template-columns:minmax(0,1fr) 48px 38px 48px; align-items:center; border-bottom:1px dotted #9e8056; }
.birth-stat label,.birth-stat span { font:bold 1.03rem Georgia,serif; }
.birth-stat label { display:grid; align-content:center; padding-right:5px; }
.birth-stat input[type="range"] { width:100%; height:24px; min-height:24px; min-width:0; padding:0; margin:0; border:0; background:none;
  accent-color:#793c25; color-scheme:light; cursor:pointer; }
.enrol-balance > div { display:flex; }
#enrolment .enrol-balance button { padding-inline:6px; }
.birth-stat span { display:grid; text-align:center; font-variant-numeric:tabular-nums; }
.birth-stat small { min-height:.85em; font:.7rem/1 Georgia,serif; color:#275236; }
#enrolment button:enabled:hover { box-shadow:inset 0 0 0 1px #9b683c; }
#enrolment button:disabled { opacity:.4; }
@media (max-height:600px) { #enrolment-sheet { gap:3px; } .enrol-signature img { height:43px; } }
.character-vitals .licence-origin { font:italic .84rem Georgia,serif; color:#603c24; }

.enrol-signature img { object-fit:contain; }
#skills #character-portrait, #inventory #loadout-portrait { aspect-ratio:270/315; }
@media (max-width:760px) and (min-height:560px) and (max-height:759px) {
  :root:not([data-enlarged-text]) #inventory #loadout-portrait { max-height:138px; }
}

:root:not([data-enlarged-text]) #actions:has([data-act="gift-mode"]) { grid-template-columns:repeat(5,minmax(0,1fr)); }
.licence-gift { padding:7px 12px; color:#f4e1b7; background:#423226; font:1rem/1.35 Georgia,serif; }

.start-screen { margin:0 auto; min-height:100dvh; display:flex; flex-direction:column; justify-content:center; flex-wrap:nowrap;
  gap:clamp(4px,2vh,18px); padding:clamp(12px,3vh,26px) 18px; background:#1b211b radial-gradient(ellipse at 50% 35%,#4c4934 0%,#292c22 43%,#151a16 86%); }
.start-screen[hidden] { display:none; }
.start-screen .title-art { width:min(340px,77vw,39dvh); filter:drop-shadow(0 6px 6px #100e0c70); }
.start-copy { border:0; padding:0; background:none; width:min(322px,100%); }
.inn-actions { display:grid; gap:5px; }
.inn-actions button,.inn-dialog button { min-height:45px; font:bold 1.03rem Georgia,serif; color:#f6dfb4; background:#304237 url('./art/porter-strap.webp') center / cover;
  border:1px solid #94754a; border-bottom:3px solid #191912; border-radius:7px 12px 6px 10px; }
.inn-actions .inn-primary,.inn-dialog .inn-primary { color:#fff1cc; background:#803e27; border:2px ridge #c59a54; min-height:51px; font-size:1.22rem; }
.inn-actions #account-button { background:transparent; border:0; color:#e1c79c; }
.inn-dialog { width:min(355px,calc(100% - 24px)); padding:16px; color:#3b291b; background:#efd4a0 url('./art/appraisal-ticket.webp') center / 145% 135%;
  border:2px solid #8e6741; border-radius:10px 6px 8px 11px; }
.inn-dialog::backdrop { background:#151b16de; }
.inn-dialog header { display:flex; justify-content:space-between; align-items:center; }
.inn-dialog header button { min-width:44px; } .inn-dialog h2 { font:bold 1.55rem Georgia,serif; color:#452d1c; }
.inn-dialog form,.inn-dialog label { display:grid; gap:6px; } .inn-dialog form { gap:11px; }
.inn-dialog input { min-width:0; padding:9px; background:#ffedcb; color:#352819; font-size:1rem; }
.inn-dialog [hidden] { display:none; } .inn-dialog p { margin:7px 0; }
#provider-actions { display:grid; justify-items:center; gap:5px; margin-block:8px; }
#provider-actions .brand-signin { display:grid; place-items:center; width:min(220px,100%); min-height:46px; padding:0; border:0; background:none; }
#provider-actions .brand-signin img { display:block; max-width:100%; height:40px; object-fit:contain; }
#provider-actions .email-choice { width:min(220px,100%); }
#email-signin-form .email-options { display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px; }
#email-signin-form .email-options button { background:none; border:0; color:#57361d; text-decoration:underline; font-size:.86rem; padding-inline:2px; }
#events { max-width:650px; margin:auto; padding:12px; } #events article { margin:10px 0; padding:12px; background:#27382f; border-bottom:2px solid #8b6c43; }
#events h2,#events h1 { font-family:Georgia,serif; } #events select { max-width:100%; min-height:44px; }

#welcome-note { margin:0; color:#f4ded0; text-align:center; } #welcome-note:empty { display:none; }

.start-screen .title-art { mix-blend-mode:screen; }

#events .contest-bill,#events .honour-roll { color:#3d291c; border:2px solid #946b38; border-radius:7px 11px 6px 8px;
  background:#e9c894 url('./art/appraisal-ticket.webp') center / 142% 136%; }
#events .contest-bill { text-align:center; }
.event-spine { display:grid; grid-template-columns:44px 1fr 44px; align-items:center; gap:4px; }
.event-spine h2 { margin:0; color:#412719; font: bold 2rem/1.1 Georgia,serif; }
.event-spine h2 small { display:block; margin:0 0 3px; color:#6c4831; font:italic .88rem Georgia,serif; }
#events .event-spine button { min-height:44px; border-radius:50%; font:bold 1.3rem Georgia,serif; background:#533b28; border:2px ridge #b08b56; color:#fff0c4; }
.contest-bill p { margin:.5rem 0; } #events .actions { justify-content:center; }
#events .contest-bill .actions, .race-entry { gap:8px; }
.race-entry { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; margin:.6rem 0; }
.race-entry label { font:italic .88rem Georgia,serif; }
#events .contest-bill .actions button, #events .race-entry button, #events .race-entry select {
  min-width:48px; min-height:48px; color:#46291c; background:#ffedc6; border:1px solid #8d663b;
}
#events .contest-bill .actions .inn-primary { color:#fff1cc; background:#71371f; border-color:#71371f; }
#events .contest-bill .actions button:disabled { opacity:1; color:#644e3a; background:#dfc5a0; border-color:#a8865b; }
#events .contest-bill :focus-visible { outline-color:#71371f; }
#ranked-entry-hint { font-size:1rem; }
#events .honour-roll h2 { margin:0; color:#422b1f; } .honour-roll ol { margin:.6rem 0 0; padding-left:1.7rem; }
.honour-roll li { padding:.45rem 0; border-top:1px solid #a48660; } .honour-roll small { display:block; }
.board-link { display:flex; align-items:center; justify-content:center; min-height:48px; margin-top:.6rem; color:#71371f; font-weight:700; }
#events > .board-link { color:var(--brass); }

/* Town in the same leather, brass and ticket-paper as the licence (owner, 3 Dec 2026). */
#town { --ink:#352618; --quiet:#654b32; --rule:#ab8653; --active:#285338; --brass:#754526;
  width:min(100%,680px); margin:0 auto; min-height:100dvh; align-content:start;
  background:#253b30 url('./art/porter-strap.webp') center / auto 100%; color:var(--ink); }
#town .town-heading { background:transparent; color:#ffe0a1; padding:8px 12px 6px; }
#town .town-heading h1 { font:bold clamp(1.45rem,4vw,2rem)/1 Georgia,serif; transform:rotate(-1.2deg); }
#bank { color:#3b2716; background:#eccb90; border:2px double #8a5b33; border-radius:4px 8px 5px 7px; padding:3px 9px; font:bold .86rem Georgia,serif; transform:rotate(1.5deg); }
#town .town-layout { padding:0 10px 18px; gap:10px; }
#town .town-map { border:3px solid #6b4426; border-radius:9px 12px 8px 11px; box-shadow:0 0 0 1px #b48a52, 3px 4px 0 #2a1d14; }
#town .town-map button { min-height:40px; padding:4px 11px; color:#f7d091; background:#6b4028f2; border:1px solid #c19a5e;
  border-radius:7px 9px 6px 8px; font:bold .92rem Georgia,serif; box-shadow:1px 2px 0 #2a1b12; }
#town .town-map button:enabled:hover { background:#7d4c30; }
#town .town-map [aria-pressed="true"] { color:#392616; background:#eccb90; border-color:#8a5b33; }
#town-service { color:#39281a; padding:clamp(16px,4vw,24px) clamp(16px,4vw,22px) 22px 30px; gap:8px; font-family:Georgia,serif;
  background:#ecd099 url('./art/appraisal-ticket.webp') center / 100% 100%; border:1px solid #846638; box-shadow:2px 3px 0 #b18c57,4px 5px 0 #553d28; }
#town-service h2 { font:bold 1.4rem Georgia,serif; color:#3a2615; }
#town-service h3, #town-service h4 { font:bold 1.05rem Georgia,serif; color:#4a2f1b; }
#town-service p { color:#3e2b1b; }
#town-service article { background:transparent; border:0; border-bottom:1px dotted #9b784b; padding:6px 0 10px; gap:6px; }
#town-service button { color:#ffebc1; background:#6a422a; border:1px solid #9b7041; border-radius:6px 9px 7px 4px; font:bold .92rem Georgia,serif; }
#town-service button:enabled:hover { background:#7b4d31; }
#town-service button.primary { background:#803d29; color:#ffebc6; border:2px solid #5e3121; }
#town-service button[aria-pressed="true"] { background:#eccb90; color:#392616; border-color:#8a5b33; }
#town-service button:disabled { opacity:.5; }
#town-service [role="status"] { font-style:italic; color:#285338; }
#town-service .actions { display:flex; flex-wrap:wrap; gap:6px; }
