#history-dialog {
  width: min(720px, calc(100% - 24px));
  max-height: 90dvh;
  padding: 18px;
  background: linear-gradient(150deg, #20252d, #141820 70%);
}
#history-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
#history-dialog > .modal-heading { margin-bottom: 12px; flex-shrink: 0; }
#history-dialog .memory-close { position: static; width: 44px; height: 44px; min-height: 44px; }
#history-dialog .messages {
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: 0 4px 16px 0;
  overscroll-behavior: contain;
}
.character-sheet { margin-bottom: 24px; }
.sheet-identity { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 20px; }
.sheet-portrait { width: 92px; height: 142px; object-fit: contain; object-position: center bottom; }
.sheet-level { margin: 0 0 6px; font: 600 11px/1.4 system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; }
.sheet-name { margin: 0; color: var(--ink); font: normal 36px/1.1 Georgia, serif; }
.sheet-title { margin: 4px 0 10px; color: var(--gold); font-style: italic; }
.sheet-note { margin: 6px 0 12px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.sheet-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0 24px; padding: 14px 0; border-block: 1px solid #a8997633; }
.sheet-facts dt { color: var(--muted); font: 500 10px/1.5 system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.05em; }
.sheet-facts dd { margin: 4px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.sheet-section { margin-top: 24px; }
.sheet-section h3 { margin: 0; color: var(--gold); font: normal 21px/1.3 Georgia, serif; }
.sheet-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sheet-count { color: var(--muted); white-space: nowrap; font: 12px system-ui, sans-serif; }
.sheet-deck { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.sheet-tarot { display: block; min-width: 0; padding: 0; border: 0; border-radius: 4px; background: transparent; }
.sheet-tarot img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: contain; border: 1px solid #b6a27766; border-radius: 4px; background: #10141b; box-sizing: border-box; }
.sheet-tarot[data-tarot-state="unknown"] { display: grid; place-items: center; aspect-ratio: 2 / 3; box-sizing: border-box; border: 1px dashed #a8997644; color: #b9b6bc88; font: 20px Georgia, serif; }
.sheet-tarot[data-tarot-state="active"] img { border-color: #b6a277; }
.sheet-tarot[data-tarot-state="reward"] img { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
button.sheet-tarot:hover { background: transparent; }
button.sheet-tarot:hover img { border-color: var(--gold); }
@media (max-width: 359px) {
  .sheet-deck { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.sheet-tarot:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.sheet-quest { margin-top: 10px; padding: 10px 12px; border-left: 2px solid #a8997666; background: #ffffff04; }
.sheet-quest h4 { margin: 0 0 3px; color: var(--gold); font: 600 11px/1.5 system-ui, sans-serif; }
.sheet-quest p { margin: 0; font-size: 13px; }
#history-dialog .inner-life { margin-top: 20px; padding-top: 16px; border-top: 1px solid #a8997633; }
#history-dialog .inner-life h3 {
  margin: 0 0 8px; color: var(--gold); font: normal 21px/1.3 Georgia, serif;
}
#history-dialog .character-sheet .inner-life { margin: 12px 0 0; padding: 0; border: 0; }
#history-dialog .inner-life .inner-life-persona { color: var(--ink); font-style: italic; }
.sheet-memories { margin: 0; }
.sheet-memories dt { margin-top: 10px; color: var(--ink); font: 600 14px/1.4 Georgia, serif; }
.sheet-memories dd { margin: 3px 0 12px; font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
#history-dialog .memory-place { margin-top: 18px; }
@media (min-width: 600px) {
  #history-dialog { padding: 24px; }
  .sheet-identity { grid-template-columns: 112px minmax(0, 1fr); }
  .sheet-portrait { width: 112px; height: 160px; }
  .sheet-name { font-size: 42px; }
  .sheet-deck { grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 7px; }
}
