:root {
  --emerald: #3ed88f;
  --mint: #a8f0cd;
  --deep: #0e2a1d;
  --bg: #0a1f16;
  --panel: #10281d;
  --text: #dff5ea;
  --muted: rgba(223, 245, 234, 0.6);
  --border: rgba(62, 216, 143, 0.22);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Slim pill scrollbars. The standard properties are gated to Firefox only —
   if Chromium sees them it switches to its native square thin scrollbar and
   ignores the rounded ::-webkit styling below. */
@supports (-moz-appearance: none) {
  html {
    scrollbar-width: thin;
    scrollbar-color: rgba(62, 216, 143, 0.35) transparent;
  }
  /* Firefox can't round scrollbar thumbs, so auto-hide the sidebar's instead:
     invisible while reading, thin while the cursor is over the rail. */
  #sidebar {
    scrollbar-width: none;
  }
  #sidebar:hover {
    scrollbar-width: thin;
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(62, 216, 143, 0.3);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(62, 216, 143, 0.5);
  background-clip: padding-box;
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
}

/* ---- Header ---- */
.wiki-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(10, 28, 20, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

#nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

#nav-toggle:hover {
  background: rgba(62, 216, 143, 0.12);
}

#nav-toggle .bar {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--emerald);
}

#nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

#nav-overlay[hidden] {
  display: none;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  width: 300px;
  max-width: 86vw;
  overflow-y: auto;
  padding: 14px 14px 34px;
  background: #0d2419;
  border-right: 1px solid var(--border);
  transform: translateX(-105%);
  transition: transform 0.22s ease;
}

#sidebar.open {
  transform: none;
  box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5);
}

#sidebar .sb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--emerald);
}

#nav-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}

#nav-close:hover {
  color: var(--emerald);
}

#sidebar .sb-index {
  display: block;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--mint);
  font-weight: 600;
  text-decoration: none;
}

#sidebar h3 {
  margin: 20px 0 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--emerald);
  background: linear-gradient(90deg, rgba(62, 216, 143, 0.14), rgba(62, 216, 143, 0.03));
  border-left: 3px solid var(--emerald);
  border-radius: 0 8px 8px 0;
}

#sidebar ul {
  list-style: none;
  padding-bottom: 4px;
}

#sidebar li a {
  display: block;
  padding: 6px 10px 6px 18px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
  text-decoration: none;
}

#sidebar .sb-index:hover,
#sidebar li a:hover {
  background: rgba(62, 216, 143, 0.1);
}

#sidebar li a.active {
  background: rgba(62, 216, 143, 0.16);
  color: var(--emerald);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  #sidebar {
    transition: none;
  }
}

/* Docked sidebar on wide screens — always visible, like a classic wiki. */
@media (min-width: 1100px) {
  #nav-toggle {
    display: none;
  }
  #nav-overlay {
    display: none !important;
  }
  #nav-close {
    display: none;
  }
  #sidebar {
    transform: none;
    transition: none;
    box-shadow: none;
  }
  body {
    padding-left: 300px;
  }
}

.wiki-header .home img {
  height: 44px;
  width: auto;
  display: block;
}

.wiki-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--emerald);
  text-decoration: none;
  letter-spacing: 0.04em;
}

.search {
  position: relative;
  margin-left: auto;
  width: min(340px, 55vw);
}

.search input {
  width: 100%;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.search input:focus {
  outline: none;
  border-color: var(--emerald);
}

#results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: #0d2419;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

#results a {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(62, 216, 143, 0.1);
}

#results a:last-child {
  border-bottom: none;
}

#results a:hover,
#results a.active {
  background: rgba(62, 216, 143, 0.12);
}

#results .hit-cat {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 8px;
}

#results .empty {
  display: block;
  padding: 10px 14px;
  color: var(--muted);
}

/* ---- Content ---- */
.wiki-content {
  flex: 1;
  width: min(94vw, 900px);
  margin: 0 auto;
  padding: 36px 0 56px;
}

.wiki-content h1 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--emerald);
  font-size: 2.1rem;
  margin-bottom: 18px;
}

.wiki-content h2,
.wiki-content h3,
.wiki-content h4 {
  color: var(--mint);
  margin: 28px 0 10px;
  scroll-margin-top: 80px;
}

.wiki-content h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.wiki-content p:empty {
  display: none;
}

.wiki-content p {
  margin: 10px 0;
}

.wiki-content a {
  color: var(--emerald);
  text-decoration: none;
}

.wiki-content a:hover {
  text-decoration: underline;
}

.wiki-content ul,
.wiki-content ol {
  margin: 10px 0 10px 26px;
}

.wiki-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.wiki-content figure,
.wiki-content .thumb {
  margin: 14px 0;
}

.wiki-content figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.wiki-content table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 16px 0;
  max-width: 100%;
}

.wiki-content th,
.wiki-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.wiki-content th {
  background: rgba(62, 216, 143, 0.12);
  color: var(--mint);
}

.wiki-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}

.wiki-content aside,
.wiki-content .portable-infobox {
  float: right;
  width: min(300px, 100%);
  margin: 0 0 16px 22px;
  padding: 12px 14px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.9rem;
}

/* OSRS-style stat block: title, image, then tight label/value rows. */
.wiki-content aside h2 {
  font-size: 1.05rem;
  text-align: center;
  color: var(--emerald);
  border-bottom: none;
  margin: 0 0 8px;
  padding: 0;
}

.wiki-content aside figure,
.wiki-content aside p:has(> img:only-child) {
  margin: 0 0 4px;
}

.wiki-content aside img {
  display: block;
  width: 100%;
  height: auto;
}

.wiki-content aside h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(62, 216, 143, 0.12);
}

.wiki-content aside p {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

/* ---- Rarity / difficulty tinting (applied by wiki.js) ---- */
.tier-common { color: #cfd8d3; }
.tier-uncommon { color: #4ade80; }
.tier-rare { color: #38bdf8; }
.tier-epic { color: #c084fc; }
.tier-legendary { color: #f5a524; }
.tier-mythic { color: #f43f5e; }
.tier-bronze { color: #d0863c; }
.tier-silver { color: #c9ced1; }
.tier-gold { color: #ffd75e; }
.tier-diamond { color: #7dd3fc; }
.diff-easy { color: #4ade80; }
.diff-medium { color: #facc15; }
.diff-hard { color: #f87171; }
td[class^="tier-"], td[class^="diff-"] {
  font-weight: 600;
}

/* ---- Link hover previews ---- */
#link-preview {
  position: fixed;
  z-index: 60;
  max-width: 330px;
  padding: 12px 14px;
  background: #0d2419;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  font-size: 0.86rem;
  line-height: 1.5;
}

#link-preview .lp-title {
  color: var(--emerald);
  font-weight: 700;
}

#link-preview .lp-cat {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 8px;
}

#link-preview .lp-x {
  display: block;
  margin-top: 5px;
  color: var(--text);
}

.toc {
  display: inline-block;
  margin: 6px 0 14px;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.92rem;
}

.toc strong {
  color: var(--mint);
}

.toc ul {
  margin: 6px 0 0 18px;
}

/* ---- Breadcrumb + prev/next navigation ---- */
.crumbs {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.crumbs .updated {
  margin-left: auto;
  font-size: 0.78rem;
  opacity: 0.75;
}

.crumbs a {
  color: var(--mint);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--emerald);
}

.crumbs .sep {
  margin: 0 7px;
  opacity: 0.6;
}

.pagenav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 12px;
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  clear: both;
}

.pagenav .pn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.pagenav .pn:hover {
  background: rgba(62, 216, 143, 0.12);
}

.pagenav .pn.next {
  text-align: right;
}

.pagenav .pn.spacer {
  visibility: hidden;
}

.pagenav .pn-dir {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pagenav .pn-title {
  color: var(--emerald);
  font-weight: 600;
}

.pagenav .pn-all {
  align-self: center;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
}

.pagenav .pn-all:hover {
  color: var(--mint);
}

@media (max-width: 560px) {
  .pagenav {
    grid-template-columns: 1fr;
  }
  .pagenav .pn.next {
    text-align: left;
  }
  .pagenav .pn.spacer {
    display: none;
  }
  .pagenav .pn-all {
    order: 3;
  }
}

/* ---- Index page ---- */
.wiki-hero {
  text-align: center;
  margin-bottom: 10px;
}

.wiki-hero p {
  color: var(--muted);
}

.category-block {
  margin-top: 30px;
}

.category-block h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.page-grid {
  list-style: none;
  margin: 14px 0 0 !important;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.page-grid a {
  display: block;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.page-grid a:hover {
  background: rgba(62, 216, 143, 0.12);
  transform: translateY(-1px);
  text-decoration: none;
}

.page-grid .pg-title {
  color: var(--emerald);
  font-weight: 600;
}

.page-grid .pg-x {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Sortable tables ---- */
.wiki-content th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.wiki-content th.sortable::after {
  content: " ↕";
  opacity: 0.4;
  font-size: 0.8em;
}

.wiki-content th.sortable[aria-sort="ascending"]::after {
  content: " ↑";
  opacity: 1;
}

.wiki-content th.sortable[aria-sort="descending"]::after {
  content: " ↓";
  opacity: 1;
}

/* ---- Guide cards (Ever Wild style: quests, commands, weapons) ---- */
.wiki-content .eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--emerald);
  font-weight: 700;
  margin: 30px 0 -18px;
}

.wiki-content .eyebrow-violet {
  color: #b692e8;
}

.wiki-content .begin {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--emerald);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 18px 0;
}

.wiki-content .begin .mark {
  font-family: Georgia, serif;
  font-size: 2rem;
  color: var(--emerald);
  line-height: 1;
}

.wiki-content .begin h3 {
  margin: 0 0 4px;
  color: var(--emerald);
}

.wiki-content .begin p {
  margin: 0;
  color: var(--muted);
}

.wiki-content .begin strong {
  color: var(--text);
}

.wiki-content .quest-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  margin: 18px 0;
}

.wiki-content .quest {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.wiki-content .quest:hover {
  transform: translateY(-3px);
  border-color: rgba(62, 216, 143, 0.5);
}

.wiki-content .quest .qtop {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.wiki-content .quest h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--emerald);
  scroll-margin-top: 80px;
}

.wiki-content .quest .marker {
  color: var(--emerald);
  opacity: 0.7;
  font-size: 1.2rem;
}

.wiki-content .quest .desc {
  margin: 0;
  font-size: 0.93rem;
}

.wiki-content .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: auto;
  padding-top: 6px;
}

.wiki-content .meta .item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.wiki-content .meta .k {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.wiki-content .meta .v {
  font-size: 0.9rem;
}

.wiki-content .meta .v.reward {
  color: var(--mint);
  font-weight: 600;
}

.wiki-content .pill {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.wiki-content .pill.easy {
  color: #4ade80;
}

.wiki-content .pill.medium {
  color: #facc15;
}

.wiki-content .pill.hard {
  color: #f87171;
}

.wiki-content .chainflag {
  font-size: 0.76rem;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.wiki-content .chainflag b {
  color: var(--emerald);
}

.wiki-content .party {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 18px 0;
}

.wiki-content .cmd {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid #b692e8;
  border-radius: 12px;
  padding: 15px 17px;
}

.wiki-content .cmd code {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: #b692e8;
  margin-bottom: 5px;
}

.wiki-content .cmd p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.wiki-content .weapons-grid {
  display: grid;
  gap: 11px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 18px 0;
}

.wiki-content .weapon {
  display: flex;
  gap: 14px;
  align-items: baseline;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
}

.wiki-content .weapon .wname {
  font-family: Georgia, serif;
  font-size: 1.08rem;
  color: var(--emerald);
  min-width: 6.2rem;
  flex-shrink: 0;
}

.wiki-content .weapon .wtrait {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.wiki-content .weapon .wtrait b {
  color: var(--text);
}

.wiki-content .teaser {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 26px;
  margin: 34px 0 10px;
}

.wiki-content .teaser .eyebrow {
  margin: 0 0 10px;
}

.wiki-content .teaser h2 {
  border-bottom: none;
  margin: 0 0 8px;
  padding: 0;
}

.wiki-content .teaser p {
  max-width: 52ch;
  margin: 0 auto;
  color: var(--muted);
}

.wiki-content .teaser .soon {
  display: inline-block;
  margin-top: 18px;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--emerald);
  border: 1px solid var(--emerald);
  border-radius: 4px;
  padding: 5px 12px;
}

@media (max-width: 560px) {
  .wiki-content .begin {
    flex-direction: column;
    gap: 8px;
  }
  .wiki-content .weapon {
    flex-direction: column;
    gap: 4px;
  }
  .wiki-content .weapon .wname {
    min-width: 0;
  }
}

/* ---- Footer ---- */
.wiki-footer {
  padding: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.wiki-footer a {
  color: var(--mint);
}

.wiki-funnel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.wiki-funnel .wf-label {
  color: var(--muted);
}

.wiki-funnel code {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(62, 216, 143, 0.25);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

.wiki-funnel a {
  color: var(--emerald);
  font-weight: 600;
  text-decoration: none;
}

.wiki-funnel a:hover {
  text-decoration: underline;
}

@media (max-width: 560px) {
  .wiki-header {
    flex-wrap: wrap;
  }
  .search {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  .wiki-content aside,
  .wiki-content .portable-infobox {
    float: none;
    margin: 14px 0;
  }
}
