.rulebook-shell {
  display: grid;
  gap: 1.25rem;
}

.rulebook-nav {
  order: 2;
}

.rulebook-shell > article {
  order: 1;
}

@media (min-width: 992px) {
  .rulebook-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
  }

  .rulebook-nav {
    position: sticky;
    top: 1rem;
    order: 1;
  }

  .rulebook-shell > article {
    order: 2;
  }
}

@media (max-width: 991.98px) {
  .rulebook-nav-card .list-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .rulebook-nav-card .list-group-item {
    border: 1px solid rgba(27, 32, 64, 0.1);
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 575.98px) {
  .rulebook-nav-card .list-group {
    grid-template-columns: 1fr;
  }
}

.rulebook-card,
.rulebook-nav-card {
  background: #fff;
  border: 1px solid rgba(27, 32, 64, 0.12);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(27, 32, 64, 0.06);
}

.rulebook-nav-card {
  padding: 1rem;
}

.rulebook-content {
  padding: clamp(1.25rem, 3vw, 2.25rem);
  font-family: var(--theme-body-font);
  color: var(--ends-text);
  font-size: 1.08rem;
  line-height: 1.62;
}

.rulebook-content h1,
.rulebook-content h2,
.rulebook-content h3,
.rulebook-content h4,
.rulebook-content h5,
.rulebook-content h6 {
  font-family: var(--theme-header-font);
  color: var(--ends-navy);
  text-align: left;
}

.rulebook-content h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 1rem;
}

.rulebook-content h2 {
  margin-top: 2.2rem;
}

.rulebook-content h3 {
  margin-top: 2rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--ends-purple);
}

.rulebook-content h4,
.rulebook-content h5 {
  margin-top: 1.35rem;
  font-family: var(--theme-body-font);
  font-variant: small-caps;
  font-size: 1.08rem;
  letter-spacing: 0.02em;
}

.rulebook-content h2[id],
.rulebook-content h3[id],
.rulebook-content h4[id],
.rulebook-content h5[id] {
  scroll-margin-top: 1rem;
}

.rulebook-content h2[id]::after,
.rulebook-content h3[id]::after,
.rulebook-content h4[id]::after,
.rulebook-content h5[id]::after {
  content: " #";
  opacity: 0;
  color: var(--ends-blue);
  font-family: var(--tblr-font-sans-serif);
  font-size: 0.8em;
}

.rulebook-content h2[id]:hover::after,
.rulebook-content h3[id]:hover::after,
.rulebook-content h4[id]:hover::after,
.rulebook-content h5[id]:hover::after {
  opacity: 1;
}

.chapter-head {
  position: relative;
  min-height: 5.4rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.chapter-num {
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--theme-header-font);
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  font-weight: 700;
  color: var(--ends-navy);
  opacity: 0.12;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}

.chapter-sub {
  position: relative;
  display: inline-block;
  margin-top: 2.7rem;
  margin-left: 0.5rem;
  padding-bottom: 0.2rem;
  border-bottom: 3px solid var(--ends-purple);
  font-family: var(--theme-header-font);
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  font-weight: 600;
  color: var(--ends-navy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.05;
}

.rulebook-content table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--theme-table-bg);
  color: var(--theme-text-color);
  margin: 1.1rem 0;
  font-size: 0.96rem;
  display: block;
  overflow-x: auto;
}

.rulebook-content th {
  background-color: var(--ends-navy);
  color: #fff;
  text-align: left;
  padding: 0.5rem 0.65rem;
  font-family: var(--theme-header-font);
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.rulebook-content td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid rgba(27, 32, 64, 0.1);
  vertical-align: top;
}

.rulebook-content tr:nth-child(even) {
  background-color: var(--theme-table-alt);
}

.rulebook-content .note,
.rulebook-content .descriptive {
  margin: 1.1rem 0;
  padding: 0.85rem 1rem;
  border-radius: 0 6px 6px 0;
}

.rules-search {
  width: min(100%, 320px);
}

.rules-index {
  display: grid;
  gap: 0.65rem;
}

.rules-index-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(27, 32, 64, 0.12);
  border-radius: 8px;
  color: var(--ends-text);
  background: rgba(255, 255, 255, 0.72);
  text-decoration: none;
}

.rules-index-item:hover {
  border-color: rgba(85, 0, 170, 0.38);
  color: var(--ends-text);
  background: #fff;
}

.rules-index-item span {
  font-family: var(--theme-header-font);
  color: var(--ends-navy);
}

.rules-index-item small {
  color: var(--ends-text-muted);
  line-height: 1.35;
}

.rulebook-content .note {
  background: var(--ends-note-bg);
  border-left: 4px solid var(--ends-purple);
}

.rulebook-content .descriptive {
  background: var(--ends-desc-bg);
  color: var(--ends-desc-text);
  border-left: 4px solid var(--ends-purple);
}

.rulebook-content .descriptive h1,
.rulebook-content .descriptive h2,
.rulebook-content .descriptive h3,
.rulebook-content .descriptive h4,
.rulebook-content .descriptive h5,
.rulebook-content .descriptive h6 {
  color: var(--ends-purple-lt);
}

.rulebook-content blockquote {
  border-left: 4px solid var(--ends-blue);
  padding-left: 1rem;
  color: var(--ends-text-muted);
}

.dice.boon { color: #0055bb; }
.dice.bane { color: #c45000; }
.dice.ability { color: #007733; }
.dice.trial { color: #aa0011; }
.dice.mastery { color: #550099; }
.dice.crisis { color: #a07800; }

.dice {
  display: inline-block;
  position: relative;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.18em;
  margin: 0 0.03em;
  line-height: 1;
}

.dice.sm { width: 0.95em; height: 0.95em; }
.dice.lg { width: 1.35em; height: 1.35em; }

.dice::before,
.dice::after {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.dice::before { background-color: currentColor; }
.dice::after { background-color: #111; }

.dice.d6::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='14' y='14' width='72' height='72' rx='6' ry='6' fill='white'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='14' y='14' width='72' height='72' rx='6' ry='6' fill='white'/%3E%3C/svg%3E");
}

.dice.d6::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='14' y='14' width='72' height='72' rx='6' ry='6' fill='none' stroke='white' stroke-width='8' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='14' y='14' width='72' height='72' rx='6' ry='6' fill='none' stroke='white' stroke-width='8' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.dice.d8::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 88,50 50,90 12,50' fill='white'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 88,50 50,90 12,50' fill='white'/%3E%3C/svg%3E");
}

.dice.d8::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 88,50 50,90 12,50' fill='none' stroke='white' stroke-width='8' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 88,50 50,90 12,50' fill='none' stroke='white' stroke-width='8' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.dice.d12::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 84,30 84,70 50,90 16,70 16,30' fill='white'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 84,30 84,70 50,90 16,70 16,30' fill='white'/%3E%3C/svg%3E");
}

.dice.d12::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 84,30 84,70 50,90 16,70 16,30' fill='none' stroke='white' stroke-width='8' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 84,30 84,70 50,90 16,70 16,30' fill='none' stroke='white' stroke-width='8' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.diceicons {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-color: #111;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  vertical-align: -0.12em;
}

.diceicons.success {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.diceicons.failure {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

.diceicons.boon {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
}

.diceicons.bane {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
}

.diceicons.breakthrough {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.8 12A9.8 9.8 0 1 1 12 2.2 9.8 9.8 0 0 1 21.8 12Z'/%3E%3Cpath d='m8 12 2.7 2.7L16.5 9'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.8 12A9.8 9.8 0 1 1 12 2.2 9.8 9.8 0 0 1 21.8 12Z'/%3E%3Cpath d='m8 12 2.7 2.7L16.5 9'/%3E%3C/svg%3E");
}

.diceicons.calamity {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.8 12A9.8 9.8 0 1 1 12 2.2 9.8 9.8 0 0 1 21.8 12Z'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.8 12A9.8 9.8 0 1 1 12 2.2 9.8 9.8 0 0 1 21.8 12Z'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E");
}

.archetype,
.adversary,
.minion {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 0;
  font-family: var(--tblr-font-sans-serif);
}

.archetype .stat,
.adversary .stat,
.minion .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 36px;
  padding: 3px 4px;
  border-radius: 4px;
  background: var(--ends-navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.archetype .mig.stat::before { content: "MIG"; }
.archetype .agi.stat::before { content: "AGI"; }
.archetype .int.stat::before { content: "INT"; }
.archetype .sav.stat::before { content: "SAV"; }
.archetype .wil.stat::before { content: "WIL"; }
.archetype .cha.stat::before { content: "CHA"; }
.adversary .res.stat::before,
.minion .res.stat::before { content: "RES"; }
.adversary .wound.stat::before,
.minion .wound.stat::before { content: "WND"; }
.adversary .strain.stat::before { content: "STR"; }
.adversary .mdef.stat::before,
.minion .mdef.stat::before { content: "MDEF"; }
.adversary .rdef.stat::before,
.minion .rdef.stat::before { content: "RDEF"; }

.archetype .stat::before,
.adversary .stat::before,
.minion .stat::before {
  display: block;
  font-size: 7px;
  letter-spacing: 0.6px;
  opacity: 0.72;
  font-weight: 400;
}

.vehicle {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  font-family: var(--tblr-font-sans-serif);
}

.vehicle .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 3px 4px;
  border-radius: 4px;
  background: var(--ends-navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.vehicle .sil.stat::before { content: "SCALE"; }
.vehicle .speed.stat::before { content: "SPEED"; }
.vehicle .hand.stat::before { content: "HAND"; }
.vehicle .armor.stat::before { content: "ARMOR"; }
.vehicle .def.stat::before { content: "DEF"; }
.vehicle .ht.stat::before { content: "HULL"; }
.vehicle .ss.stat::before { content: "SYS"; }

.vehicle .stat::before {
  font-size: 7px;
  letter-spacing: 0.6px;
  opacity: 0.72;
  font-weight: 400;
}
