:root {
  --ink: #17211f;
  --muted: #5c6662;
  --paper: #f8f5ee;
  --panel: #fffdf8;
  --line: #d9d1c4;
  --accent: #8f2f32;
  --accent-2: #2c6f69;
  --accent-3: #a87524;
  --deep: #132928;
  --soft: #e8efe9;
  --shadow: 0 18px 44px rgba(33, 28, 21, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  line-height: 1.5;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button,
.app-link,
.quick-nav a,
.filter-row button {
  border-radius: 6px;
}

.site-header {
  align-items: center;
  background: rgba(248, 245, 238, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 42px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-link,
.quick-nav a {
  color: var(--deep);
  font-weight: 700;
  text-decoration: none;
}

.app-link {
  border: 1px solid var(--accent-2);
  padding: 8px 11px;
}

.quick-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quick-nav a {
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 8px;
}

.quick-nav a:hover,
.quick-nav a:focus-visible,
.app-link:hover,
.app-link:focus-visible {
  border-color: var(--accent-2);
  color: var(--accent-2);
  outline: none;
}

.hero {
  display: grid;
  min-height: min(64vh, 620px);
  overflow: hidden;
  position: relative;
}

.hero img {
  filter: saturate(1.06) contrast(1.02);
  grid-area: 1 / 1;
  height: 100%;
  min-height: 430px;
  object-fit: cover;
  width: 100%;
}

.hero::after {
  background: linear-gradient(90deg, rgba(10, 18, 17, 0.82), rgba(10, 18, 17, 0.34) 56%, rgba(10, 18, 17, 0.1));
  content: "";
  grid-area: 1 / 1;
}

.hero-copy {
  align-self: center;
  color: #fffdf8;
  grid-area: 1 / 1;
  max-width: 760px;
  padding: clamp(28px, 8vw, 88px);
  position: relative;
  z-index: 1;
}

.hero-copy p:first-child,
.section-kicker {
  color: #f2c875;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(2.2rem, 8vw, 5.2rem);
  line-height: 0.96;
  margin: 0 0 18px;
  max-width: 760px;
}

.hero-copy p:last-child {
  font-size: clamp(1rem, 2vw, 1.25rem);
  margin: 0;
  max-width: 680px;
}

.primer-layout {
  align-items: start;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1480px;
  padding: 26px clamp(14px, 3vw, 38px) 68px;
}

.toc {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
  position: sticky;
  top: 74px;
}

.toc h2 {
  font-size: 0.92rem;
  margin: 0 0 8px;
}

.toc button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  display: block;
  font-weight: 700;
  padding: 8px 9px;
  text-align: left;
  width: 100%;
}

.toc button.active,
.toc button:hover,
.toc button:focus-visible {
  background: var(--soft);
  border-color: #b7ccc5;
  color: var(--deep);
  outline: none;
}

.content {
  display: grid;
  gap: 30px;
  min-width: 0;
}

.rules-section {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: clip;
}

.section-header {
  align-items: end;
  background: #132928;
  color: #fffdf8;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
  min-height: 260px;
  padding: clamp(18px, 3vw, 34px);
}

.section-header img {
  align-self: stretch;
  background: #0f1818;
  border: 1px solid rgba(255, 255, 255, 0.24);
  cursor: zoom-in;
  height: 220px;
  object-fit: cover;
  object-position: center;
  width: 100%;
}

.section-header h2 {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1;
  margin: 0 0 12px;
}

.section-header p {
  margin: 0;
  max-width: 820px;
}

.section-body {
  display: grid;
  gap: 18px;
  padding: clamp(16px, 3vw, 28px);
}

.beginner-note,
.rules-note {
  background: #f0f5f1;
  border-left: 5px solid var(--accent-2);
  padding: 14px 16px;
}

.rules-note {
  background: #fff8e6;
  border-left-color: var(--accent-3);
}

.beginner-note h3,
.rules-note h3 {
  font-size: 1rem;
  margin: 0 0 5px;
}

.beginner-note p,
.rules-note p {
  margin: 0;
}

.metric-grid,
.card-grid,
.compact-grid {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.reference-card {
  background: #fffefa;
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
}

.reference-card.with-image {
  grid-template-rows: auto 1fr;
  padding: 0;
}

.reference-card img {
  aspect-ratio: 16 / 9;
  background: #152120;
  cursor: zoom-in;
  object-fit: contain;
  width: 100%;
}

.reference-card .card-copy {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.reference-card h3,
.reference-card h4 {
  margin: 0;
}

.reference-card p {
  color: var(--muted);
  margin: 0;
}

.card-lore-link {
  align-self: start;
  color: var(--accent-2);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.card-lore-link:hover,
.card-lore-link:focus-visible {
  color: var(--accent);
}

.metric {
  background: #fffefa;
  border: 1px solid var(--line);
  padding: 14px;
}

.metric b {
  color: var(--accent);
  display: block;
  font-size: 1.9rem;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 0.92rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: #eef4f2;
  border: 1px solid #c8d9d4;
  color: var(--deep);
  display: inline-flex;
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 5px 7px;
}

.chip.gold {
  background: #fff5d8;
  border-color: #e7c36d;
}

.filter-panel {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(140px, 210px));
}

.filter-panel label {
  color: var(--muted);
  display: grid;
  font-size: 0.84rem;
  font-weight: 700;
  gap: 5px;
}

.filter-panel input,
.filter-panel select {
  background: #fffefa;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-row button {
  background: #fffefa;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 7px 10px;
}

.filter-row button.active {
  background: var(--deep);
  border-color: var(--deep);
  color: #fffdf8;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
}

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

.data-table th {
  background: #f1eadc;
  color: var(--deep);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.data-table td {
  background: #fffefa;
}

.table-wrap {
  overflow-x: auto;
}

details.reference-detail {
  border: 1px solid var(--line);
  background: #fffefa;
}

details.reference-detail summary {
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  padding: 12px 14px;
}

details.reference-detail summary::-webkit-details-marker {
  display: none;
}

details.reference-detail summary::after {
  color: var(--accent-2);
  content: "+";
  float: right;
  font-size: 1.2rem;
}

details.reference-detail[open] summary::after {
  content: "-";
}

.detail-body {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
}

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.55fr);
}

.spell-count {
  color: var(--muted);
  font-weight: 700;
}

.image-lightbox {
  align-items: center;
  background: rgba(8, 11, 10, 0.88);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 18px;
  position: fixed;
  z-index: 50;
}

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox button {
  background: #fffdf8;
  border: 0;
  color: var(--deep);
  cursor: pointer;
  font-weight: 800;
  justify-self: end;
  margin: 0 0 10px;
  padding: 9px 12px;
}

.image-lightbox img {
  max-height: 86vh;
  max-width: 96vw;
  object-fit: contain;
}

.loading,
.error {
  padding: 30px;
}

.error {
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 980px) {
  .primer-layout,
  .section-header,
  .split {
    grid-template-columns: 1fr;
  }

  .toc {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    position: sticky;
    top: 61px;
    z-index: 10;
  }

  .toc h2 {
    align-self: center;
    margin: 0 4px 0 0;
  }

  .toc button {
    white-space: nowrap;
    width: auto;
  }

  .section-header img {
    height: auto;
    max-height: 320px;
    object-fit: contain;
  }

  .metric-grid,
  .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-nav {
    justify-content: flex-start;
  }

  .hero img {
    min-height: 390px;
  }

  .hero::after {
    background: linear-gradient(180deg, rgba(10, 18, 17, 0.34), rgba(10, 18, 17, 0.88));
  }

  .hero-copy {
    align-self: end;
    padding: 24px;
  }

  .primer-layout {
    padding-inline: 10px;
  }

  .filter-panel,
  .metric-grid,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    font-size: 0.92rem;
  }
}
