.tools #lore-open {
  width: auto;
  padding: 0 11px 0 9px;
  grid-auto-flow: column;
  gap: 5px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 13px;
}
#lore-open .icon { width: 16px; height: 16px; }
.sunmark .icon { width: 74%; height: 74%; }

#lore-dialog {
  width: min(620px, calc(100vw - 24px));
  max-width: none;
  max-height: min(760px, calc(100svh - 24px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: #352e23;
  border: 1px solid #e1c489;
  border-radius: 9px;
  background: #f2e7ca;
  box-shadow: 0 18px 72px #021619b3, inset 0 0 0 2px #645639;
}
#lore-dialog::backdrop { background: #071d24ad; }
body:has(#lore-dialog[open]) { overflow: hidden; }
.lore-folio {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(758px, calc(100svh - 26px));
}
.lore-cover {
  display: grid;
  justify-items: center;
  align-content: end;
  padding: 10px 44px 17px;
  min-width: 0;
  color: #f5e3b7;
  border-bottom: 3px double #c5a468;
  background:
    radial-gradient(ellipse at 48% 20%, #71917b60, transparent 58%),
    repeating-linear-gradient(117deg, #e6d59f08 0 1px, transparent 1px 15px),
    linear-gradient(110deg, #172f35, #365750 48%, #1b3739);
}
.tide-bell { display: block; width: 150px; height: 91px; }
.lore-cover h2 {
  margin: 0;
  color: #faeccb;
  font: 750 clamp(22px, 3vw, 32px)/1.35 "Songti SC", STSong, SimSun, serif;
  letter-spacing: .1em;
  text-indent: .1em;
  text-shadow: 0 2px #213932;
}
.lore-cover h2:focus { outline: none; }
#lore-close {
  position: absolute;
  z-index: 1;
  top: 9px; right: 9px;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: #22413f;
  border: 1px solid #c9b789;
  border-radius: 50%;
  color: #f8e7be;
  box-shadow: inset 0 0 0 2px #2d5149;
}
#lore-close:hover { background: #3e6154; }
#lore-close .icon { width: 18px; height: 18px; }
.lore-pages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #b9a579 #ede1c1;
  padding: 21px clamp(18px, 4vw, 33px) 25px;
  color: #393226;
  background:
    linear-gradient(90deg, #af865b12 0%, transparent 12%, transparent 91%, #ac8d5b16),
    repeating-linear-gradient(0deg, #a9946b08 0 1px, transparent 1px 4px);
}
.lore-pages h3, .lore-side h4 { margin: 0; }
.lore-pages h3 {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #34554c;
  font: 750 18px/1.5 "Songti SC", STSong, SimSun, serif;
  letter-spacing: .045em;
}
.lore-pages h3::after {
  flex: 1; height: 1px; margin-left: 7px; content: "";
  background: linear-gradient(to right, #96845187, #aa9b7310);
}
.lore-pages h3 span { color: #847458; font-size: .83em; }
.lore-pages p { font: 400 14px/1.8 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; margin: 6px 0 0; }
.lore-pages section + section { margin-top: 13px; }
.lore-armies {
  display: grid; grid-template-columns: 1fr 1fr; gap: 15px;
  margin-top: 15px;
  border-top: 1px solid #ae9d76;
  padding-top: 13px;
}
.lore-side { display: flex; align-items: flex-start; gap: 7px; }
.lore-side .icon {
  margin-top: 1px;
  width: 24px; height: 24px; padding: 3px;
  flex: none; border-radius: 50%;
  color: #eef0cd; background: #42665d;
  box-shadow: 0 0 0 1px #a4ad86, inset 0 0 0 1px #f9f1b67a;
}
.lore-kin .icon { background: #67503b; color: #f6da9b; box-shadow: 0 0 0 1px #ae9b72, inset 0 0 0 1px #f9f1b67a; }
.lore-side h4 { font-size: 13px; color: #344e43; line-height: 1.5; }
.lore-kin h4 { color: #684832; }
.lore-side p { margin: 2px 0 0; font-size: 12px; line-height: 1.65; color: #544a39; }

@media (prefers-reduced-motion: no-preference) {
  #lore-dialog[open] .lore-bell-body {
    transform-origin: 91px 24px;
    animation: tide-bell-settle 820ms ease-out;
  }
  @keyframes tide-bell-settle {
    0% { transform: rotate(-7deg); }
    32% { transform: rotate(4deg); }
    63% { transform: rotate(-1.5deg); }
    to { transform: rotate(0); }
  }
}
@media (max-width: 680px) {
  .tools #lore-open { min-height: 34px; padding: 0 8px 0 6px; gap: 3px; font-size: 12px; }
  .lore-cover { padding: 2px 38px 10px; }
  .tide-bell { width: 115px; height: 70px; }
  #lore-close { width: 38px; height: 38px; top: 6px; right: 6px; }
  .lore-pages { padding: 14px 16px 18px; }
  .lore-pages h3 { font-size: 16px; }
  .lore-pages p { font-size: 13px; line-height: 1.75; }
  .lore-armies { grid-template-columns: 1fr; gap: 8px; margin-top: 12px; padding-top: 12px; }
  .lore-side p { font-size: 12px; line-height: 1.6; }
}
@media (orientation: landscape) and (max-height: 510px) {
  #lore-dialog { width: min(680px, calc(100vw - 18px)); }
  .lore-folio { grid-template: minmax(0, 1fr) / 150px minmax(0,1fr); }
  .lore-cover {
    align-content: center;
    padding: 12px 6px;
    border: 0;
    border-right: 3px double #c5a468;
  }
  .lore-cover h2 { font-size: 19px; }
  .tide-bell { width: 124px; height: auto; }
  #lore-close { right: auto; left: 8px; top: 8px; width: 34px; height: 34px; }
  .lore-pages { padding: 14px 18px 16px; }
  .lore-pages h3 { font-size: 16px; }
  .lore-pages p { font-size: 13px; }
  .lore-armies { grid-template-columns: 1fr; gap: 8px; }
  .lore-side p { font-size: 12px; }
}
