:root {
  --paper: #f5f0e6;
  --paper-deep: #e9e0cf;
  --ink: #1f1d1a;
  --muted: #6c6257;
  --accent: #9f251f;
  --line: #c9bda9;
  --note: #fffaf0;
  --max: 1040px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: #d9d2c7;
  font-family: "Hiragino Sans", "Yu Gothic", "YuGothic", system-ui, sans-serif;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-underline-offset: 0.16em;
}

.page {
  width: min(100% - 24px, var(--max));
  margin: 24px auto 64px;
  background: var(--paper);
  box-shadow: 0 16px 50px rgb(0 0 0 / 0.12);
}

.masthead {
  padding: 56px clamp(24px, 6vw, 72px) 42px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, transparent 0 72%, rgb(159 37 31 / 0.06) 72% 100%),
    var(--paper);
}

.eyebrow,
.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  font-size: clamp(2.4rem, 8vw, 5.8rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 14px 0 0;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  letter-spacing: 0.12em;
}

.edition {
  margin-top: 28px;
  max-width: 56rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.toc {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow: auto;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  font-size: 0.82rem;
}

.toc h2 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding-left: 1.3em;
}

.toc li + li {
  margin-top: 0.45em;
}

.toc a {
  color: inherit;
  text-decoration: none;
}

.toc a:hover {
  color: var(--accent);
}

main {
  min-width: 0;
  padding: 40px clamp(24px, 5vw, 64px) 72px;
}

.rule-section {
  padding-top: 18px;
  margin-top: 42px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 18px;
}

.rule-section:first-child {
  margin-top: 0;
}

h2,
h3,
h4 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  line-height: 1.35;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

h3 {
  margin: 32px 0 12px;
  font-size: 1.35rem;
}

h4 {
  margin: 24px 0 8px;
  font-size: 1.06rem;
}

p {
  margin: 0.75em 0;
}

.lead {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  font-size: 1.12rem;
  line-height: 2;
}

.rule,
.example,
.translator-note,
.reconstruction-note,
.quickref,
.archetype {
  break-inside: avoid;
}

.rule,
.quickref {
  margin: 20px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: rgb(255 255 255 / 0.28);
}

.rule > :first-child,
.quickref > :first-child,
.example > :first-child,
.translator-note > :first-child,
.reconstruction-note > :first-child {
  margin-top: 0;
}

.rule > :last-child,
.quickref > :last-child,
.example > :last-child,
.translator-note > :last-child,
.reconstruction-note > :last-child {
  margin-bottom: 0;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.example {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 2px solid var(--line);
  color: #453f38;
  background: rgb(255 255 255 / 0.18);
}

.translator-note,
.reconstruction-note {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  background: var(--note);
  color: #494038;
  font-size: 0.9rem;
}

.reconstruction-note {
  border-style: solid;
  border-color: #a99070;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.archetype {
  padding: 16px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.2);
}

.archetype h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.stat {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffaf1;
  font-size: 0.86rem;
}

table {
  width: 100%;
  margin: 18px 0 26px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

caption {
  margin-bottom: 8px;
  text-align: left;
  color: var(--muted);
  font-size: 0.82rem;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

thead th {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

dl {
  margin: 18px 0;
}

dt {
  margin-top: 12px;
  font-weight: 700;
}

dd {
  margin: 2px 0 0 1.25em;
}

.steps {
  padding-left: 1.35em;
}

.steps li + li {
  margin-top: 0.4em;
}

.dice {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.two-col {
  columns: 2 18rem;
  column-gap: 28px;
}

.name-table {
  columns: 3 11rem;
  column-gap: 24px;
  padding-left: 1.4em;
}

.name-table li {
  break-inside: avoid;
  margin-bottom: 0.2em;
}

.source-footer {
  padding: 24px clamp(24px, 5vw, 64px) 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 760px) {
  .page {
    width: 100%;
    margin: 0;
    box-shadow: none;
  }

  .masthead {
    padding-top: 36px;
  }

  .layout {
    display: block;
  }

  .toc {
    position: static;
    max-height: none;
    padding: 20px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  main {
    padding-top: 28px;
  }

  .cards {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm 14mm 16mm;
  }

  body {
    background: white;
    font-size: 9.5pt;
    line-height: 1.62;
  }

  .page {
    width: auto;
    margin: 0;
    background: white;
    box-shadow: none;
  }

  .masthead {
    min-height: 250mm;
    padding: 34mm 8mm 18mm;
    border: 0;
    break-after: page;
  }

  .layout {
    display: block;
  }

  .toc {
    position: static;
    max-height: none;
    padding: 0 0 8mm;
    border: 0;
    break-after: page;
  }

  main {
    padding: 0;
  }

  .rule-section {
    break-before: page;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .rule-section[data-print-continue="true"] {
    break-before: auto;
  }

  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  table,
  .archetype,
  .rule,
  .quickref,
  .translator-note,
  .reconstruction-note {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  .source-footer {
    padding: 8mm 0 0;
  }
}
