:root {
  --bg: #f4f0e6;
  --fg: #1c1915;
  --card: #fffcf7;
  --border: #e3d9c8;
  --accent: #8f3d32;
  --muted: #6d655c;
  --secondary: #efe8da;
  --max: 72rem;
  --reading: 46rem;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  line-height: 1.6;
}

a { color: inherit; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 5;
  background: var(--card);
  padding: 0.4rem 0.7rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 88%, transparent);
}

.site-header .inner,
.site-footer .inner {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0.4rem;
}

.brand { text-decoration: none; }

.kicker {
  display: block;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand-name,
h1, h2, .child-title {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 560;
}

.brand-name {
  font-size: 2rem;
  line-height: 1;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.6rem 0 1rem;
}

.nav a {
  text-decoration: none;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--secondary);
}

main {
  flex: 1;
  width: min(var(--reading), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}

.crumbs {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.4rem;
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  line-height: 1.1;
  margin: 0.35rem 0 0;
}

.lede {
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.7;
}

.prose { font-size: 1.05rem; }

.prose p,
.prose ul,
.prose ol { line-height: 1.75; }

.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.2;
  margin: 1.6rem 0 0.45rem;
  scroll-margin-top: 1rem;
}

.prose h2 { font-size: 1.7rem; }
.prose h3 { font-size: 1.35rem; }
.prose h4 { font-size: 1.12rem; }

.prose ul,
.prose ol { padding-left: 1.3rem; }

.prose li { margin: 0.2rem 0; }

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

.prose blockquote {
  margin: 1rem 0;
  padding-left: 0.9rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

.prose th { background: var(--secondary); }

.prose .rang-scroll {
  overflow-x: auto;
  margin: 1rem 0 0.4rem;
}

.prose .rang-table {
  width: max-content;
  min-width: 100%;
  font-size: 0.78rem;
  line-height: 1.35;
}

.prose .rang-table th,
.prose .rang-table td {
  text-align: center;
  vertical-align: middle;
  padding: 0.28rem 0.4rem;
}

.prose .rang-table th { white-space: nowrap; }

.prose img,
.figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card);
}

.map-board { max-width: 36rem; margin: 0.5rem 0 1.6rem; }

.prose .map-grid {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
}

.prose .map-grid th,
.prose .map-grid td {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: center;
  vertical-align: middle;
}

.prose .map-grid th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem;
}

.prose .map-grid th.map-a { background: #ebc79e; color: #1c1915; }
.prose .map-grid th.map-b { background: #32cd99; color: #1c1915; }

.prose .map-grid td a { display: block; line-height: 0; }

.prose .map-grid img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.map-popup {
  max-width: min(96vw, 80rem);
  max-height: 94vh;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--card);
}

.map-popup img {
  display: block;
  max-width: 92vw;
  max-height: 86vh;
  width: auto;
  height: auto;
}

.map-popup-close {
  display: block;
  margin: 0 0 0.4rem auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.map-popup::backdrop { background: rgba(28, 25, 21, 0.72); }

.sheet,
.child-list,
.downloads {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--card);
}

.sheet div,
.child-list a,
.downloads li {
  display: grid;
  gap: 0.2rem 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sheet div:last-child,
.child-list a:last-child,
.downloads li:last-child { border-bottom: 0; }

.sheet dt { color: var(--muted); }

@media (min-width: 640px) {
  .sheet div { grid-template-columns: 11rem 1fr; }
}

.scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .scores { grid-template-columns: repeat(6, 1fr); }
}

.scores span {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  text-align: center;
  padding: 0.45rem 0.2rem 0.35rem;
}

.scores small {
  display: block;
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.scores b {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.6rem;
  font-weight: 560;
}

.child-list a {
  text-decoration: none;
  align-items: baseline;
}

.child-list a:hover { background: color-mix(in srgb, var(--secondary) 65%, white); }

.child-title { font-size: 1.45rem; }

.hero-sort {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1.2rem;
}

.hero-sort button {
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
}

.hero-sort button[aria-pressed="true"] {
  background: var(--secondary);
  border-color: transparent;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }

.tags span,
.downloads a {
  color: var(--accent);
}

.tags span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
}

.downloads { list-style: none; padding: 0; }

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer .inner { padding: 2rem 0; }
