:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d2126;
  --muted: #5b6570;
  --line: #d9dcd6;
  --accent: #3f6b2a;
  --link: #2c5aa0;
  --plus: #2d7a3a;
  --minus: #a8402f;
  --icon-bg: #2a3138;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --panel: #1c2229;
    --ink: #e3e8ee;
    --muted: #97a3b0;
    --line: #2d3640;
    --accent: #9cc77a;
    --link: #8db8ff;
    --plus: #79c98a;
    --minus: #ef8a78;
    --icon-bg: #0d1115;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow-wrap: anywhere;
}

a { color: var(--link); }

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.play { margin-left: auto; font-weight: 600; color: var(--accent); }
.discord { font-weight: 600; color: #5865f2; }
.jump { display: none; }

.search { position: relative; flex: 1 1 100%; }
.search input {
  width: 100%;
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
#results {
  position: absolute;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  max-height: 60vh;
  overflow-y: auto;
}
#results a { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; text-decoration: none; color: var(--ink); }
#results a:hover, #results a:focus { background: var(--bg); }
#results small { color: var(--muted); }

.layout { padding: 0 16px; }
main { max-width: 760px; min-width: 0; padding: 8px 0 32px; }
main h1 { font-size: 1.9rem; line-height: 1.2; margin: 8px 0 12px; }
main h2 { margin-top: 2em; padding-bottom: 4px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
main h3 { margin-top: 1.5em; }
.crumb { margin: 12px 0 0; color: var(--muted); font-size: 0.9rem; }
.summary { color: var(--muted); font-size: 1.05rem; }
blockquote { margin: 1em 0; padding: 4px 16px; border-left: 4px solid var(--accent); color: var(--muted); }

.table { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.stats th { width: 45%; font-weight: 500; color: var(--muted); }
table.stats td { font-variant-numeric: tabular-nums; font-weight: 600; }
td a { display: inline-flex; align-items: center; gap: 8px; }

.icon { display: block; background: var(--icon-bg); border-radius: 8px; flex: none; }
.icon.big { width: 128px; height: 128px; float: right; margin: 0 0 12px 16px; }
.icon.mid { width: 72px; height: 72px; }
.icon.small { width: 36px; height: 36px; border-radius: 6px; }
main p > .icon.mid { float: left; margin: 4px 12px 4px 0; }
.icon.lead-art { float: right; margin: 0 0 12px 16px; }
.named .icon, td a .icon, .cards .icon, h2 .icon { flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.chips span:not(.rarity) { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.rarity { --tier: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 99px; border: 2px solid var(--tier); color: var(--ink); }

.effects { list-style: none; padding: 0; margin: 6px 0; clear: left; }
.effects li { padding-left: 1.3em; position: relative; }
.effects li::before { position: absolute; left: 0; font-weight: 700; }
.effects .plus::before { content: '+'; color: var(--plus); }
.effects .minus::before { content: '−'; color: var(--minus); }

tr.mod { scroll-margin-top: 120px; }
table.parts .effects { margin: 0; }
table.parts td { overflow-wrap: normal; }
.named { display: inline-flex; align-items: center; gap: 8px; }
tr:target { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.cards { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.cards a { display: flex; align-items: center; gap: 10px; height: 100%; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--accent); }
.cards span { display: flex; flex-direction: column; min-width: 0; }
.cards small { color: var(--muted); line-height: 1.35; }

.modlist { padding-left: 1.2em; }
.toc { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; margin: 12px 0; clear: right; }
.toc ul { margin: 4px 0 0; padding-left: 1.2em; }

.side { padding: 16px 0 24px; border-top: 1px solid var(--line); font-size: 0.95rem; }
.side h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 4px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: block; padding: 3px 0; text-decoration: none; color: var(--ink); }
.side a[aria-current='page'] { color: var(--accent); font-weight: 700; }

footer { padding: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

@media (max-width: 899px) {
  .jump { display: inline; }
  .icon.big { width: 96px; height: 96px; }
}

@media (min-width: 900px) {
  .search { flex: 0 1 320px; }
  .play { margin-left: 0; order: 3; }
  .discord { order: 3; }
  .layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; max-width: 1120px; margin: 0 auto; }
  .side { grid-column: 1; grid-row: 1; border-top: 0; position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; }
  main { grid-column: 2; grid-row: 1; }
}

.infobox { float: right; clear: right; width: 290px; margin: 0 0 16px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem; }
.ib-title, .nb-title { padding: 6px 12px; font-weight: 700; text-align: center; background: color-mix(in srgb, var(--accent) 18%, var(--panel)); border-bottom: 1px solid var(--line); }
.ib-title { font-size: 1.05rem; }
.infobox .icon.big { float: none; margin: 12px auto; }
.infobox .table, .infobox table, .navbox table { margin: 0; border: 0; background: none; }
.infobox th { width: 48%; font-weight: 500; color: var(--muted); }
.infobox td { font-weight: 600; font-variant-numeric: tabular-nums; }
.infobox tr:last-child > *, .navbox tr:last-child > * { border-bottom: 0; }

.navbox { clear: both; margin: 32px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem; }
.navbox th { width: 9em; color: var(--muted); font-weight: 600; }
.navbox ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.navbox li:not(:last-child)::after { content: '·'; margin: 0 8px; color: var(--muted); }

table.sortable thead th { padding: 0; }
.sort { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 6px 22px 6px 10px; cursor: pointer; position: relative; }
.sort::after { content: '⇅'; position: absolute; right: 6px; opacity: 0.45; }
th[aria-sort='ascending'] .sort::after { content: '▲'; opacity: 1; }
th[aria-sort='descending'] .sort::after { content: '▼'; opacity: 1; }
.sort:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
table.sortable td, .sort { font-variant-numeric: tabular-nums; white-space: nowrap; overflow-wrap: normal; }
table.unlocks td, table.unlocks .sort { white-space: normal; overflow-wrap: anywhere; }
table.unlocks td a { display: inline; }
table.unlocks td:last-child { width: 50%; }
table.unlocks .icon.small { width: 48px; height: 48px; }

@media (max-width: 599px) {
  .infobox { float: none; width: auto; margin: 0 0 16px; }
  .navbox tr, .navbox th, .navbox td { display: block; width: auto; }
  .navbox th { border-bottom: 0; padding-bottom: 0; }
  table.parts thead { display: none; }
  table.parts tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--line); }
  table.parts td { display: block; border: 0; padding: 2px 10px; }
  table.parts td.empty { display: none; }
  table.parts td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); }
  table.unlocks { min-width: 480px; }
  table.unlocks td, table.unlocks .sort { overflow-wrap: break-word; }
  table.unlocks .named { flex-direction: column; align-items: flex-start; gap: 4px; }
  .icon.lead-art { width: 56px; height: 56px; }
}
