#handbook-panel {
  --paper: #fcf7eb;
  --folio: #f0e7d5;
  --ink: #2c2b27;
  --muted-ink: #605845;
  --rule: #dcd0b9;
  --vermilion: #8b392b;
  --wash: #ead9c0;
  --book-serif: "Songti SC", "Noto Serif SC", Georgia, serif;
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  width: min(1160px, calc(100vw - 52px));
  height: min(820px, calc(100dvh - 48px));
  max-width: none;
  max-height: none;
  overflow: hidden;
  color: var(--ink);
  color-scheme: light;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 15px;
  box-shadow: 0 18px 78px #0d17166e;
  font: 15px/1.65 system-ui, sans-serif;
  text-align: left;
  letter-spacing: normal;
}
#handbook-panel[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
#handbook-panel::backdrop { background: #172420a8; }
#handbook-panel [hidden] { display: none !important; }
#handbook-panel button {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 7px 13px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  font: inherit;
  text-shadow: none;
  cursor: pointer;
}
#handbook-panel button:not(:disabled):hover { background: var(--wash); }
#handbook-panel button:disabled { cursor: default; opacity: .46; }
#handbook-panel :focus-visible { outline: 2px solid var(--vermilion); outline-offset: 2px; }
#handbook-panel :is(h2,h3,h4,h5,p,ol,ul,figure) { margin: 0; }
#handbook-panel a { color: var(--vermilion); }
.handbook-header {
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 24px;
  border-bottom: 1px solid var(--rule);
  background: #f5eddd;
}
#handbook-panel header { text-shadow: none; }
#handbook-panel header p { max-width: none; white-space: normal; overflow: visible; }
.handbook-emblem {
  display: grid;
  flex: none;
  place-items: center;
  width: 37px;
  height: 43px;
  border-radius: 3px 6px 6px 3px;
  color: #fff5e7;
  background: var(--vermilion);
  box-shadow: inset 4px 0 #57251f5e;
  font: 660 20px/1 var(--book-serif);
}
.handbook-header p { color: var(--muted-ink); font-size: 12px; letter-spacing: .07em; }
#handbook-panel h2 { color: var(--ink); font: 700 25px/1.25 var(--book-serif); }
.handbook-header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#handbook-contents { display: none; }
#handbook-panel #handbook-close { width: 40px; padding: 0; font: 27px/1 system-ui; }
.handbook-body { position: relative; display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 0; }
#handbook-sidebar {
  min-height: 0;
  overflow: auto;
  padding: 19px 14px;
  border-right: 1px solid var(--rule);
  background: var(--folio);
  overscroll-behavior: contain;
  scrollbar-color: #ac9c83 transparent;
}
#handbook-sidebar label { display: block; margin: 0 4px 6px; font-size: 13px; font-weight: 670; color: var(--muted-ink); }
#handbook-search {
  box-sizing: border-box;
  width: 100%;
  min-height: 41px;
  padding: 7px 10px;
  border: 1px solid #c7b89e;
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
}
#handbook-search::placeholder { color: var(--muted-ink); font-size: 12px; }
#handbook-panel #handbook-status { margin: 6px 5px 0; color: var(--muted-ink); font-size: 12px; }
#handbook-panel #handbook-status:empty { display: none; }
#handbook-sidebar nav { position: static; display: block; width: auto; transform: none; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
#handbook-sidebar nav span { color: inherit; font-size: inherit; }
#handbook-panel #handbook-index { list-style: none; margin-top: 11px; padding: 0; }
#handbook-panel .handbook-index-link {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 35px;
  padding: 4px 7px;
  border: 1px solid transparent;
  text-align: left;
  font-size: 14px;
  line-height: 1.36;
}
#handbook-panel .handbook-index-link[aria-current] { border-color: #d7c5aa; background: #e9d9c0; color: #743427; font-weight: 700; }
#handbook-sidebar .handbook-index-number { color: var(--muted-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.handbook-index-link small { grid-column: 2; color: var(--muted-ink); font-size: 12px; }
#handbook-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-color: #ac9c83 transparent;
  background: radial-gradient(ellipse at 10% 0%, #e5d8ba45, transparent 56%),
    repeating-linear-gradient(0deg, #57442604, #57442604 1px, transparent 1px, transparent 4px), var(--paper);
}
#handbook-article { max-width: 870px; margin: 0 auto; padding: 30px clamp(19px, 4vw, 47px) 46px; }
.handbook-chapter { display: block; padding: 0 0 20px; border-bottom: 1px solid var(--rule); }
#handbook-panel .handbook-shelf { margin-bottom: 3px; color: var(--vermilion); font-size: 13px; font-weight: 650; }
#handbook-panel .handbook-chapter h3 { color: var(--ink); font: 750 clamp(25px, 4vw, 40px)/1.25 var(--book-serif); }
#handbook-panel .handbook-intro { max-width: 44em; margin-top: 8px; color: var(--muted-ink); font-size: inherit; letter-spacing: normal; }
#handbook-panel .handbook-section { margin-top: 22px; scroll-margin-top: 14px; }
#handbook-panel .handbook-section h4 { margin-bottom: 9px; color: var(--ink); font: 700 20px/1.35 var(--book-serif); }
#handbook-panel .handbook-section-text { margin-bottom: 10px; max-width: 52em; }
.handbook-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 10px; }
.handbook-section:first-of-type .handbook-cards { align-items: stretch; }
.handbook-card {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fffaf0a8;
}
#handbook-panel .handbook-card h5 { margin-bottom: 4px; color: var(--ink); font-size: 16px; line-height: 1.4; }
.handbook-card-role { display: block; margin-bottom: 4px; color: var(--vermilion); font-size: 12px; }
#handbook-panel .handbook-card ol { padding-left: 1.24em; }
.handbook-card li+li { margin-top: 4px; }
#handbook-panel .handbook-card .handbook-note { margin-top: 7px; color: var(--muted-ink); font-size: 13px; }
.handbook-keys,.handbook-key-group,.handbook-gesture { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.handbook-keys,.handbook-gesture { margin: 7px 0 9px; gap: 10px; color: var(--muted-ink); }
.handbook-key-group { gap: 3px; }
.handbook-key-group kbd {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid #bbac91;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #f4eddf;
  color: var(--ink);
  font: 700 13px/1 system-ui, sans-serif;
}
.handbook-symbol { position: relative; display: inline-block; width: 24px; height: 24px; color: var(--vermilion); }
.handbook-symbol::before,.handbook-symbol::after { content: ''; position: absolute; }
.handbook-symbol[data-icon=mouse]::before { inset: 0 4px; border: 2px solid currentColor; border-radius: 10px; }
.handbook-symbol[data-icon=mouse]::after { width: 2px; height: 5px; top: 4px; left: 11px; background: currentColor; }
.handbook-symbol:is([data-icon=joystick],[data-icon=tap])::before { inset: 2px; border: 2px solid currentColor; border-radius: 50%; }
.handbook-symbol:is([data-icon=joystick],[data-icon=tap])::after { inset: 8px; border-radius: 50%; background: currentColor; }
.handbook-symbol[data-icon=touch]::before { inset: 4px 13px 4px 3px; border-radius: 6px; background: currentColor; transform: rotate(-25deg); }
.handbook-symbol[data-icon=touch]::after { inset: 1px 3px 5px 13px; border-radius: 6px; background: currentColor; transform: rotate(20deg); }
.handbook-symbol[data-icon=book]::before { inset: 2px 4px; border: 2px solid currentColor; border-left-width: 4px; border-radius: 2px 5px 5px 2px; }
.handbook-card-actions { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 6px; }
#handbook-panel .handbook-link {
  min-height: 33px;
  padding: 1px 0;
  border: 0;
  color: var(--vermilion);
  background: transparent;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: inherit;
}
#handbook-panel .handbook-link:hover { text-decoration-thickness: 2px; background: transparent; }
.handbook-table { margin: 9px 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: #fffaf0a8; }
.handbook-table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.handbook-table :is(th,td) { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.handbook-table th { font-weight: 690; color: var(--muted-ink); background: var(--folio); }
.handbook-table tr:last-child td { border-bottom: 0; }
#handbook-panel .handbook-search-hit { background: #ead9c066; scroll-margin-top: 14px; }
#handbook-panel .handbook-chapter h3:focus { outline: none; }
#handbook-panel .handbook-table .handbook-link { min-height: 30px; padding-block: 0; }
#handbook-panel .handbook-figure { margin-top: 16px; border-radius: 8px; overflow: hidden; background: var(--folio); }
.handbook-figure img { display: block; width: 100%; aspect-ratio: 3.6; object-fit: cover; }
.handbook-figure figcaption { padding: 6px 10px; color: var(--muted-ink); font-size: 12px; }
#handbook-panel .handbook-sources { margin-top: 10px; padding-left: 1.2em; font-size: 13px; }
.handbook-turn {
  display: grid;
  grid-template-columns: 1fr auto 124px auto;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  border-top: 1px solid var(--rule);
  background: var(--folio);
}
#handbook-back { grid-column: 1; justify-self: start; }
#handbook-prev { grid-column: 2; }
#handbook-next { grid-column: 4; }
.handbook-page-position { grid-column: 3; grid-row: 1; text-align: center; color: var(--muted-ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.handbook-page-position progress { display: block; width: 84px; height: 5px; margin: 3px auto; accent-color: var(--vermilion); }
@media (max-width: 720px) {
  #handbook-panel { width: calc(100vw - 14px); height: calc(100dvh - 16px); border-radius: 11px; }
  .handbook-header { padding: 10px 12px; gap: 9px; }
  .handbook-emblem { width: 30px; height: 36px; font-size: 17px; }
  #handbook-panel h2 { font-size: 20px; }
  #handbook-panel .handbook-header p { font-size: 11px; }
  #handbook-contents { display: inline-block; }
  #handbook-panel #handbook-contents { min-height: 44px; padding: 5px 8px; font-size: 13px; }
  #handbook-panel #handbook-close { width: 44px; min-height: 44px; }
  .handbook-body { grid-template-columns: minmax(0, 1fr); }
  #handbook-sidebar { display: none; }
  #handbook-sidebar[data-expanded] {
    position: absolute;
    z-index: 1;
    inset: 0 0 auto 0;
    display: block;
    max-height: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 12px 24px #33271435;
  }
  #handbook-panel .handbook-index-link { min-height: 44px; }
  #handbook-search { min-height: 44px; font-size: 16px; }
  #handbook-article { padding: 20px 15px 29px; }
  .handbook-cards { grid-template-columns: minmax(0, 1fr); }
  #handbook-panel .handbook-table .handbook-link,#handbook-panel .handbook-link { min-height: 44px; }
  .handbook-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .handbook-table tr { display: block; padding: 6px 8px; border-bottom: 1px solid var(--rule); }
  .handbook-table tr:last-child { border-bottom: 0; }
  .handbook-table td { display: grid; grid-template-columns: minmax(4.5em, 27%) minmax(0, 1fr); align-items: baseline; gap: 6px; padding: 4px 6px; border: 0; }
  .handbook-table td::before { content: attr(data-label); color: var(--muted-ink); font-size: 12px; }
  .handbook-figure img { aspect-ratio: 2.3; }
  .handbook-turn { grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; padding: 7px 10px; }
  #handbook-panel .handbook-turn button { min-height: 44px; padding: 5px 8px; font-size: 13px; }
  #handbook-back { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  #handbook-prev { grid-column: 1; }
  #handbook-next { grid-column: 3; }
  .handbook-page-position { grid-column: 2; }
}
