:root {
  --soot: #241c17;
  --bark: #2e241e;
  --bark-2: #382c24;
  --twig: #4d3e32;
  --straw: #d8b26a;
  --straw-dim: #a88a52;
  --ember: #c4563c;
  --bone: #efe5d4;
  --ash: #ab9c8b;

  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  --c-fire: #e0703f;
  --c-cold: #86bde0;
  --c-lightning: #e8cb4f;
  --c-chaos: #ad85d8;
  --c-minion: #a3c27e;
  --c-life: #e06666;
  --c-mana: #7b98e6;
  --c-es: #8fd0d6;
  --c-defence: #cbb592;
  --c-resist: #bcc98c;
  --c-attack: #e3b56d;
  --c-physical: #cfa27c;
  --c-damage: #e59a5c;
  --c-speed: #9fd2b0;
  --c-movement: #9fd2b0;
  --c-projectile: #d9a6c9;
  --c-spell: #b8a0ea;
  --c-curse: #a283d6;
  --c-poison: #93c45c;
  --c-bleed: #d65a48;
  --c-crit: #f0d27a;
  --c-charges: #e9c47b;
  --c-attributes: #cbbba4;
  --c-totem: #bf9f6e;
  --c-stun: #c7ad82;
  --c-loot: #e8cb4f;
  --c-utility: #c4b7a7;
  --c-elemental: #e6b2d2;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 1rem; }

body {
  margin: 0;
  background: var(--soot);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--straw); color: var(--soot); padding: .5rem .8rem; border-radius: 4px;
}
.skip:focus { top: 1rem; }

:focus-visible { outline: 2px solid var(--straw); outline-offset: 2px; }

button, input, select { font: inherit; color: inherit; }

.icon {
  width: 1.1em; height: 1.1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--twig);
  background:
    repeating-linear-gradient(115deg, transparent 0 14px, rgba(216, 178, 106, .05) 14px 16px),
    repeating-linear-gradient(65deg, transparent 0 14px, rgba(216, 178, 106, .05) 14px 16px),
    var(--bark);
}
.masthead-inner {
  max-width: 1320px; margin: 0 auto; padding: 2.4rem 1.5rem 2rem;
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem 2rem;
}
.coffee {
  display: inline-flex; align-items: center; gap: .5rem; flex-shrink: 0;
  background: var(--straw); color: var(--soot); text-decoration: none; font-weight: 700;
  padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--straw);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); transition: background .15s, transform .15s;
}
.coffee:hover { background: var(--bone); transform: translateY(-1px); }
.coffee:focus-visible { outline: 2px solid var(--bone); outline-offset: 3px; }
.coffee .icon { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.foot a { color: var(--straw); }
.masthead h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -.01em;
  margin: 0 0 .7rem;
  color: var(--straw);
}
.lede { margin: 0; max-width: 60ch; color: var(--bone); font-size: 1.1rem; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1320px; margin: 0 auto; padding: 1.5rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 2rem;
  align-items: start;
}

/* ---------- Controls ---------- */
.controls { display: grid; gap: .9rem; margin-bottom: 1.2rem; }

.view-switch { display: inline-flex; border: 1px solid var(--twig); border-radius: 6px; overflow: hidden; width: max-content; }
.view-switch button {
  background: none; border: 0; padding: .55rem 1.2rem; cursor: pointer;
  font-family: var(--serif); font-weight: 700; font-size: 1.1rem; color: var(--ash);
}
.view-switch button + button { border-left: 1px solid var(--twig); }
.view-switch button[aria-selected="true"] { background: var(--straw); color: var(--soot); }

.search {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bark); border: 1px solid var(--twig); border-radius: 6px; padding: 0 .8rem;
}
.search .icon { color: var(--ash); }
.search input {
  flex: 1; background: none; border: 0; padding: .75rem 0; font-size: 1.05rem; min-width: 0;
}
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--straw); }

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  background: var(--bark); border: 1px solid var(--twig); border-radius: 999px;
  padding: .3rem .8rem; cursor: pointer; color: var(--bone); font-size: .95rem;
}
.chip:hover { border-color: var(--straw-dim); }
.chip[aria-pressed="true"] { background: var(--bone); color: var(--soot); border-color: var(--bone); }

.filter-line { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: center; }
.select-wrap { display: flex; align-items: center; gap: .5rem; color: var(--ash); font-size: .95rem; }
.select-wrap select {
  background: var(--bark); border: 1px solid var(--twig); border-radius: 6px; padding: .35rem .5rem; color: var(--bone);
}

.count { color: var(--ash); margin: 0 0 .6rem; font-size: .95rem; }

/* ---------- Results ---------- */
.results:focus { outline: none; }
.group { margin-bottom: 2rem; }
.group-title {
  display: flex; align-items: baseline; gap: .8rem;
  font-family: var(--serif); font-weight: 700; font-size: 1.5rem; margin: 0 0 .4rem;
  color: var(--straw);
  border-bottom: 1px solid var(--twig); padding-bottom: .3rem;
}
.group-title small { font-family: var(--sans); font-weight: 400; font-size: .9rem; color: var(--ash); }

.entry {
  display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: .2rem 1rem;
  padding: 1rem 0; border-bottom: 1px solid rgba(77, 62, 50, .6);
}
.entry:last-child { border-bottom: 0; }

.badge {
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--cc) 16%, var(--bark));
  border: 1px solid color-mix(in srgb, var(--cc) 55%, transparent);
  color: var(--cc);
}
.badge .icon { width: 1.35rem; height: 1.35rem; }

.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .7rem; }
.entry-name { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; margin: 0; }
.slot-tag {
  font-size: .8rem; padding: .05rem .5rem; border-radius: 4px;
  border: 1px solid var(--twig); color: var(--ash);
}
.source { color: var(--ash); margin: .1rem 0 .5rem; font-size: .97rem; }
.source b { color: var(--bone); font-weight: 500; }
.unconfirmed { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.also { color: var(--ash); font-size: .9rem; margin: .5rem 0 0; }

.tiers { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.tier {
  display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) auto; gap: .8rem; align-items: start;
  padding: .3rem .4rem .3rem 0; border-radius: 4px;
}
.tier:hover { background: rgba(216, 178, 106, .06); }
.tier-label { color: var(--straw-dim); font-size: .9rem; padding-top: .05rem; display: flex; gap: .35rem; align-items: center; }
.tier-label .icon { width: .95em; height: .95em; color: var(--tc); }
.tier-text { white-space: pre-line; max-width: 70ch; }
.equip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: none; border: 1px solid var(--twig); border-radius: 4px;
  color: var(--ash); font-size: .85rem; padding: .15rem .55rem; cursor: pointer;
}
.equip:hover { color: var(--soot); background: var(--straw); border-color: var(--straw); }
.equip.on { color: var(--soot); background: var(--straw); border-color: var(--straw); }

mark { background: color-mix(in srgb, var(--straw) 35%, transparent); color: inherit; border-radius: 2px; }

.empty { padding: 2rem 0; color: var(--ash); }
.empty button {
  background: none; border: 0; color: var(--straw); text-decoration: underline; cursor: pointer; padding: 0;
}

/* ---------- Wickerman ---------- */
.wickerman {
  position: sticky; top: 1rem;
  background: var(--bark); border: 1px solid var(--twig); border-radius: 10px;
  padding: 1.2rem; max-height: calc(100vh - 2rem); overflow: auto;
}
.wm-head h2 { font-family: var(--serif); font-weight: 800; color: var(--straw); font-size: 1.6rem; margin: 0; }
.wm-sub { margin: .2rem 0 .4rem; color: var(--ash); font-size: .95rem; }

/* In-game style panel */
.wm-frame {
  position: relative; width: 100%; aspect-ratio: 300 / 250; margin: .6rem 0 .2rem;
  border-radius: 4px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, .55) 85%),
    repeating-linear-gradient(0deg, #2a1f18 0 13px, #1d1511 13px 15px),
    #2a1f18;
}
/* staggered brick joints */
.wm-frame::before {
  content: ""; position: absolute; inset: 12% 11% 6%;
  background:
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(0, 0, 0, .35) 26px 28px);
  -webkit-mask: repeating-linear-gradient(0deg, #000 0 15px, transparent 15px 30px);
          mask: repeating-linear-gradient(0deg, #000 0 15px, transparent 15px 30px);
  opacity: .8;
}
.wm-frame::after {
  content: ""; position: absolute; inset: 12% 11% 6%;
  background: repeating-linear-gradient(90deg, transparent 0 13px, rgba(0, 0, 0, .35) 13px 15px, transparent 15px 28px);
  -webkit-mask: repeating-linear-gradient(0deg, transparent 0 15px, #000 15px 30px);
          mask: repeating-linear-gradient(0deg, transparent 0 15px, #000 15px 30px);
  opacity: .8;
}
.wm-arch { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

.wm-plaque {
  position: absolute; z-index: 3; left: 50%; top: 2%; transform: translateX(-50%);
  padding: .2rem 1.6rem .25rem;
  font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: #e8dcc3;
  background: linear-gradient(#4a3a2c, #2f241b);
  border: 1px solid #7b6446; border-radius: 3px;
  box-shadow: 0 2px 0 #1a120d, inset 0 1px 0 rgba(255, 235, 200, .15);
  white-space: nowrap;
}

.wm-slot {
  position: absolute; z-index: 2; aspect-ratio: 1; transform: translate(-50%, -50%);
  display: grid; place-items: center; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 45%, #1a1310 0 45%, #0d0907 100%);
  border: 2px solid #5b4630;
  outline: 1px solid #1a120d; outline-offset: 2px;
  box-shadow: inset 0 0 0 1px #2b2018, inset 0 0 14px rgba(0, 0, 0, .9), 0 0 0 4px #2b2018;
  color: #4c3f33;
}
.wm-slot .icon { width: 46%; height: 46%; stroke-width: 1.6; }
.wm-slot:hover { border-color: var(--straw-dim); color: #6b5a48; }
.wm-slot:focus-visible { outline: 2px solid var(--straw); outline-offset: 3px; }
.wm-slot.filled {
  color: var(--cc); border-color: color-mix(in srgb, var(--cc) 60%, #5b4630);
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--cc) 22%, #1a1310) 0 40%, #0d0907 100%);
}
.wm-slot.filled .icon { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--cc) 70%, transparent)); }
.wm-tier {
  position: absolute; bottom: 4%; left: 0; right: 0; text-align: center;
  font-size: .68rem; color: var(--bone); opacity: .85; line-height: 1;
}
.wm-slot.just-filled { animation: kindle .4s ease-out; }

.slots { display: grid; gap: .7rem; margin-top: .6rem; }
.slot-row {
  display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: .5rem; align-items: center;
}
.slot-row .slot-name { font-family: var(--serif); font-weight: 700; color: var(--straw); }
.slot-row .pickers { display: grid; gap: .3rem; min-width: 0; }
.slot-row select {
  width: 100%; background: var(--soot); border: 1px solid var(--twig); border-radius: 5px;
  padding: .35rem .4rem; color: var(--bone); min-width: 0;
}
.slot-row select:disabled { opacity: .5; }
.clear-slot {
  background: none; border: 1px solid var(--twig); border-radius: 5px; color: var(--ash);
  width: 2rem; height: 2rem; display: grid; place-items: center; cursor: pointer;
}
.clear-slot:hover { color: var(--bone); border-color: var(--ember); }
.clear-slot:disabled { opacity: .35; cursor: default; }

.roll { margin-top: 1rem; display: grid; gap: .35rem; }
.roll-label { color: var(--ash); font-size: .9rem; }
.seg { display: flex; border: 1px solid var(--twig); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; background: none; border: 0; padding: .35rem 0; cursor: pointer; color: var(--ash); font-size: .9rem; }
.seg button + button { border-left: 1px solid var(--twig); }
.seg button[aria-checked="true"] { background: var(--bone); color: var(--soot); }

.grants { margin-top: 1.1rem; }
.grants h3 { font-family: var(--serif); font-size: 1.15rem; margin: 0 0 .5rem; }
.grants ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.grants li { display: grid; grid-template-columns: 1.3rem minmax(0, 1fr); gap: .55rem; align-items: start; }
.grants li .icon { color: var(--cc); margin-top: .2rem; }
.grants li .from { display: block; color: var(--ash); font-size: .85rem; }
.grants li .text { white-space: pre-line; }
.grants .none { color: var(--ash); display: block; }

.wm-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; }
.btn {
  background: var(--straw); color: var(--soot); border: 1px solid var(--straw);
  border-radius: 6px; padding: .45rem .8rem; cursor: pointer; font-weight: 500;
}
.btn.ghost { background: none; color: var(--bone); border-color: var(--twig); }
.btn.ghost:hover { border-color: var(--ember); }

.wm-jump { display: none; }

.foot { max-width: 1320px; margin: 0 auto; padding: 1rem 1.5rem 3rem; color: var(--ash); font-size: .88rem; }
.foot p { max-width: 80ch; }

@keyframes kindle {
  0% { box-shadow: inset 0 0 0 1px #2b2018, inset 0 0 14px rgba(0,0,0,.9), 0 0 0 4px #2b2018, 0 0 0 0 var(--cc); }
  50% { box-shadow: inset 0 0 0 1px #2b2018, inset 0 0 14px rgba(0,0,0,.9), 0 0 0 4px #2b2018, 0 0 22px 6px var(--cc); }
  100% { box-shadow: inset 0 0 0 1px #2b2018, inset 0 0 14px rgba(0,0,0,.9), 0 0 0 4px #2b2018, 0 0 0 0 var(--cc); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .wickerman { position: static; max-height: none; }
  .wm-jump {
    display: inline-flex; gap: .4rem; position: fixed; right: 1rem; bottom: 1rem; z-index: 5;
    background: var(--straw); color: var(--soot); text-decoration: none; font-weight: 700;
    padding: .6rem 1rem; border-radius: 999px; box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  }
}
@media (max-width: 600px) {
  .masthead-inner { padding: 1.6rem 1rem 1.4rem; }
  .layout { padding: 1rem; }
  .tier { grid-template-columns: 1fr auto; }
  .tier-label { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
