:root {
  --bg: #0e1015;
  --panel: #171a22;
  --panel-2: #1e222c;
  --line: #2a2f3c;
  --text: #dfe3ec;
  --dim: #868da0;
  --accent: #7d5fd3;
  --r0: #9aa0ad; --r1: #4bbf73; --r2: #4a90d8;
  --r3: #a86fe0; --r4: #d9a441; --r5: #e2622b;
}
* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #191d27, #14171f);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; }
.sub { margin: 1px 0 0; font-size: 11px; color: var(--dim); }
.mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: conic-gradient(from 210deg, var(--accent), #3fbf8f, #d9a441, var(--accent));
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid #1e4430; color: #4bbf73; background: #0f1f16;
}
.btn {
  font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); padding: 7px 12px; border-radius: 7px; cursor: pointer;
}
.btn:hover { border-color: #3c4356; background: #242936; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #8f72e0; }
.btn.sm { font-size: 12px; padding: 5px 10px; }

/* layout */
.layout {
  display: grid; gap: 12px; padding: 12px; align-items: start;
  grid-template-columns:
    minmax(250px, 300px) minmax(230px, 280px) minmax(300px, 1fr) minmax(240px, 300px);
}
@media (max-width: 1500px) { .layout { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px)  { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px;
}
.panel h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim);
}
.group-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 15px 0 8px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .7px; color: var(--dim);
}
.hint { text-transform: none; letter-spacing: 0; color: #545b6b; font-size: 10px; }

/* slots */
.slotgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.slot {
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  padding: 6px 4px; border-radius: 8px; cursor: pointer; min-height: 84px;
  background: var(--panel-2); border: 1px solid var(--line); text-align: center;
}
.slot:hover { border-color: var(--accent); }
.slot.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.slot .label { font-size: 9px; text-transform: uppercase; letter-spacing: .4px; color: var(--dim); }
.slot .name { font-size: 10px; line-height: 1.25; }
.slot.empty .name { color: #545b6b; }

.icon {
  width: 36px; height: 36px; border-radius: 7px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid #00000055; background: #20242f;
}
.icon img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
/* Browser rows: the icon is the primary way to recognise an item, so it gets
   real estate rather than being a thumbnail. */
.icon.sm { width: 56px; height: 56px; border-radius: 8px; }
.icon.ph { border-style: dashed; border-color: var(--line); }

/* showcase */
.showcase .stage {
  margin: 10px 0; display: grid; place-items: center; padding: 10px;
  background:
    repeating-conic-gradient(#181c25 0% 25%, #1c202b 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--line); border-radius: 10px; min-height: 300px;
}
#char { image-rendering: pixelated; display: block; }

.ctl-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ctl-label { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button, .rollmode button {
  font: inherit; font-size: 11px; background: #12151c; color: var(--dim);
  border: 0; padding: 4px 9px; cursor: pointer;
}
.seg button.on, .rollmode button.on { background: var(--accent); color: #fff; }
.seg button:hover:not(.on), .rollmode button:hover:not(.on) { background: #242936; }
.rollmode { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.rollmode button { font-size: 10px; text-transform: uppercase; padding: 3px 7px; }

.layers { margin-top: 10px; display: flex; flex-direction: column; gap: 3px; }
.lrow { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); }
.lrow b { color: #9fb0c9; font-weight: 500; }
.lrow.miss b { color: #6f7480; font-style: italic; }

/* browser */
.filters { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.filters input, .filters select {
  font: inherit; font-size: 12px; color: var(--text); background: #12151c;
  border: 1px solid var(--line); padding: 6px 9px; border-radius: 6px;
}
.filters input { flex: 1; min-width: 120px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }

.results { max-height: 64vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.row {
  display: flex; align-items: center; gap: 11px; padding: 8px 9px;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.row:hover { background: var(--panel-2); border-color: var(--line); }
.row .meta { flex: 1; min-width: 0; }
.row .rname { font-size: 13px; }
.row .rsub { font-size: 11px; color: var(--dim); margin-top: 1px; }
.row .rstats { font-size: 10px; color: #9fb0c9; text-align: right; white-space: pre-line; }
.count { margin-top: 8px; font-size: 10px; color: var(--dim); }

/* stats */
.note { font-size: 10px; color: var(--dim); margin: 8px 0 10px; }
.statrow {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 0; border-bottom: 1px dashed #232838;
}
.statrow:last-child { border-bottom: 0; }
.statrow .sname { font-size: 11px; display: flex; align-items: center; gap: 6px; }
.statrow.primary .sname { color: #fff; font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.statrow .sval { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.empty-note { font-size: 11px; color: #545b6b; padding: 5px 0; }

.relics { display: flex; flex-direction: column; gap: 5px; }
.relicrow { font-size: 11px; }
.relicrow .rl { color: var(--text); }
.relicrow .rv { color: #a86fe0; font-variant-numeric: tabular-nums; }
.relicrow .rr { color: var(--dim); font-size: 10px; }

.reqs { display: flex; flex-direction: column; gap: 3px; }
.req { font-size: 11px; color: var(--dim); display: flex; justify-content: space-between; }
.req b { color: var(--text); font-weight: 600; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #242936; border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .18s; z-index: 50;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #2c3242; border-radius: 4px; }

/* Roll ranges from the dungeon loot tables */
.row .rstats.rolled { color: #c3b0e8; }
.statrow .sval.ranged { color: #c3b0e8; font-size: 12px; }
/* ══════════════════════════════════════════════════════════════
   SOULBOUND BUILDS — design pass (append-only; later source order wins)
   0. TOKENS
   ══════════════════════════════════════════════════════════════ */
:root {
  /* surfaces: deeper, cooler, more separation page↔panel */
  --bg:      #0b0d12;
  --panel:   #14171f;
  --panel-2: #1b1f29;
  --line:    #262b38;
  --line-2:  #333a4b;          /* emphasised hairline / hover */
  --text:    #e4e8f1;
  --dim:     #8b93a7;
  --dimmer:  #5b6376;

  /* UI accent is deliberately NOT purple any more — purple means Epic */
  --accent:     #2fb6d6;
  --accent-2:   #57d3ef;
  --accent-ink: #04222b;       /* text on accent fills */

  /* rarity ramp — same names, nudged for contrast on the darker bg */
  --r0: #a4abb8;   /* common    */
  --r1: #57cc7f;   /* uncommon  */
  --r2: #5aa9ef;   /* rare      */
  --r3: #b478ec;   /* epic      */
  --r4: #e5ad3f;   /* legendary */
  --r5: #ff6a35;   /* unique    */

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  /* type scale — real steps, not a continuum */
  --fs-2xs: 9px;  --fs-xs: 10px; --fs-sm: 11px; --fs-md: 12px;
  --fs-base: 13px; --fs-lg: 15px; --fs-xl: 20px;

  /* spacing rhythm — everything is a multiple of 4 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  --top-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
}

/* rarity token cascade: one attribute drives every rarity-coloured
   property on the element and its children. Set by the JS hooks below. */
[data-r]      { --rar: var(--r0); }
[data-r="1"]  { --rar: var(--r1); }
[data-r="2"]  { --rar: var(--r2); }
[data-r="3"]  { --rar: var(--r3); }
[data-r="4"]  { --rar: var(--r4); }
[data-r="5"]  { --rar: var(--r5); }

body {
  font-size: var(--fs-base);
  background:
    radial-gradient(1100px 620px at 50% -12%, #1a2030 0%, transparent 68%),
    var(--bg);
  background-attachment: fixed;
}

/* 1px scanline wash — 1.4% alpha. Reads as CRT/pixel, not as texture. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(255,255,255,.014) 0 1px, transparent 1px 3px);
}

::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ══ 1. RARITY LANGUAGE ══════════════════════════════════════ */

/* icon frames pick up the rarity token */
.icon {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #232935, #171b23);
}
.icon[data-r] {
  border-color: color-mix(in srgb, var(--rar) 58%, #0b0d12);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--rar) 15%, #1b202a), #14171f);
  box-shadow: inset 0 0 14px -7px var(--rar);
}
.icon.ph { background: #0f1219; border-style: dashed; border-color: var(--line); }

/* names carry rarity; --rar is unset on empty slots so they fall back */
.row .rname,
.slot .name { color: var(--rar, var(--text)); }

/* left edge stripe on browser rows — the thing your eye tracks */
.row { position: relative; }
.row::before {
  content: ""; position: absolute; left: 0; top: 5px; bottom: 5px;
  width: 2px; border-radius: 0 2px 2px 0;
  background: var(--rar, transparent); opacity: .8;
}

/* ══ 2. TYPOGRAPHY ═══════════════════════════════════════════ */
.brand h1 {
  font-size: var(--fs-xl); letter-spacing: .3px; line-height: 1.1;
  background: linear-gradient(180deg, #ffffff, #b9c3d8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub {
  font-size: var(--fs-2xs); letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--dimmer); margin-top: 3px;
}

/* every number on the page is mono + tabular */
.sval, .rstats, .rv, .rr, .count, .badge, .req b, .lrow b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
}

/* micro-labels: one recipe, used everywhere */
.slot .label, .ctl-label, .group-label, .panel h2, .row .rsub {
  text-transform: uppercase;
  letter-spacing: .9px;
  font-weight: 600;
}

/* ══ 3. PANELS ═══════════════════════════════════════════════ */
.layout { gap: var(--s3); padding: var(--s3) var(--s4) var(--s6); }

.panel {
  padding: var(--s3) var(--s3) var(--s4);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #181c25 0%, #14171f 42%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.045),
    0 10px 26px -22px #000;
}

.panel h2 {
  display: flex; align-items: center; gap: var(--s2);
  margin: -1px calc(var(--s3) * -1) var(--s3);
  padding: 0 var(--s3) var(--s2);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm); letter-spacing: 1.3px; color: #b3bcd0;
}
.panel h2::before {
  content: ""; flex: none; width: 3px; height: 12px; border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px -1px var(--accent);
}

/* group labels get a rule instead of floating in space */
.group-label {
  align-items: flex-end;
  margin: var(--s4) 0 var(--s2);
  padding-bottom: 6px;
  border-bottom: 1px solid #20252f;
  font-size: var(--fs-2xs); color: var(--dim);
}
.group-label:first-of-type { margin-top: var(--s2); }
.hint { color: var(--dimmer); font-weight: 400; letter-spacing: 0; }

/* header */
.top {
  padding: var(--s3) var(--s4);
  min-height: var(--top-h);
  background: linear-gradient(180deg, #1a1f2b, #12151d);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -24px #000;
}
.top::after {   /* hairline of accent light under the bar */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg,
    transparent, color-mix(in srgb, var(--accent) 55%, transparent), transparent);
}
.top { position: sticky; }   /* re-assert; needed for ::after anchoring */

/* CSS-drawn pixel mark — 5×5 grid, no asset, scales crisply */
.mark {
  width: 30px; height: 30px; border-radius: 7px; position: relative;
  background: linear-gradient(160deg, #1d2331, #12151d);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 14px -6px var(--accent);
}
.mark::before {
  content: ""; position: absolute; left: 8px; top: 8px;
  width: 3px; height: 3px; background: var(--accent);
  box-shadow:
     4px  0    0 0 var(--accent),   8px  0   0 0 var(--r4),
     0    4px  0 0 var(--accent),   8px  4px 0 0 var(--accent),
     0    8px  0 0 var(--r3),       4px  8px 0 0 var(--accent),
     8px  8px  0 0 var(--accent);
}

/* the catalogue count is information, not a success state */
.badge {
  background: #10141c; border: 1px solid var(--line);
  color: var(--dim); font-size: var(--fs-xs); letter-spacing: .3px;
  border-radius: var(--radius-sm); padding: 5px 10px;
}

/* buttons */
.btn { border-radius: var(--radius-sm); font-size: var(--fs-md); padding: 7px 13px; }
.btn:hover { border-color: var(--line-2); background: #232937; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: color-mix(in srgb, var(--accent) 70%, #000);
  color: var(--accent-ink); font-weight: 700; letter-spacing: .2px;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 18px -10px var(--accent);
}
.btn.primary:hover { background: linear-gradient(180deg, #6cdcf5, var(--accent-2)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .filters input:focus-visible, .filters select:focus-visible,
.slot:focus-visible, .row:focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}

/* ══ 4. SLOTS ════════════════════════════════════════════════ */
.slotgrid {
  grid-template-columns: repeat(3, minmax(0, 116px));
  justify-content: start;
  gap: var(--s2);
}

.slot {
  position: relative;
  min-height: 98px;
  gap: 5px;
  padding: var(--s2) 5px 7px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #1a1f2a, #15191f);
  border: 1px solid var(--line);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.slot:hover { border-color: var(--accent-2); transform: translateY(-1px); }

/* filled: lit by its rarity */
.slot:not(.empty) {
  border-color: color-mix(in srgb, var(--rar) 45%, var(--line));
  box-shadow: inset 0 0 20px -11px var(--rar);
}
.slot:not(.empty):hover {
  box-shadow: inset 0 0 20px -8px var(--rar), 0 0 0 1px color-mix(in srgb, var(--rar) 30%, transparent);
}
/* clear affordance — a real button, so it can actually be clicked */
.slot-clear {
  position: absolute; top: 2px; right: 3px; z-index: 2;
  width: 18px; height: 18px; padding: 0; line-height: 1;
  display: grid; place-items: center;
  font: inherit; font-size: var(--fs-2xs);
  color: var(--dimmer); background: transparent;
  border: 1px solid transparent; border-radius: 4px;
  opacity: 0; cursor: pointer; transition: opacity .12s ease, color .12s ease;
}
.slot:hover .slot-clear, .slot-clear:focus-visible { opacity: 1; }
.slot-clear:hover { color: #ff8f8f; background: #2a1717; border-color: #5a2b2b; }
.slot-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* empty: recedes */
.slot.empty { background: #12151c; border-color: #1f2430; }
.slot.empty .name { color: #3d4351; font-size: var(--fs-2xs); letter-spacing: .5px; }
.slot.empty .icon.ph::after {
  content: "+"; font-size: 15px; color: #333a49; line-height: 1;
}

.slot .label { font-size: var(--fs-2xs); color: var(--dimmer); letter-spacing: .7px; }
.slot .name {
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.22;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.slot.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 22px -8px var(--accent);
  background: linear-gradient(180deg, #1c2733, #15191f);
}

/* min/avg/max roll switch */
.rollmode, .seg { border-radius: var(--radius-sm); background: #0e1119; border-color: var(--line); }
.rollmode button.on, .seg button.on {
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}

/* ══ 5. ITEM BROWSER ═════════════════════════════════════════ */
.filters { gap: var(--s2); margin: 0 0 var(--s3); }
.filters input, .filters select {
  height: 32px; font-size: var(--fs-md);
  background: #0d1017; border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
}
.filters input::placeholder { color: var(--dimmer); }
.filters select {
  appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b93a7' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.filters input:focus, .filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.results {
  max-height: calc(100vh - 268px);
  gap: 2px; padding-right: 2px;
  scrollbar-gutter: stable;
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s3);
  padding: 7px 10px 7px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background .1s ease, border-color .1s ease;
}
.row:nth-child(odd) { background: rgba(255,255,255,.022); }
.row:hover {
  background: color-mix(in srgb, var(--rar, #7f8cab) 10%, var(--panel-2));
  border-color: color-mix(in srgb, var(--rar, var(--line-2)) 38%, var(--line));
}
.row:active { transform: translateY(1px); }

.row .rname { font-size: var(--fs-base); font-weight: 600; line-height: 1.25; }
.row .rsub {
  margin-top: 2px;
  font-size: var(--fs-2xs); letter-spacing: .7px; color: var(--dimmer);
}
.row .rstats {
  min-width: 118px;
  font-size: var(--fs-xs); line-height: 1.55; color: #9fb0c9;
}

.count {
  margin-top: var(--s3); padding-top: var(--s2);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--dimmer);
}

/* when a slot is selected the browser is a modal-ish picker — say so */
#pickerTitle { color: var(--accent-2); }

/* ══ 6. SHOWCASE STAGE ═══════════════════════════════════════ */
.showcase .stage {
  position: relative;            /* pseudo-element anchor only */
  overflow: hidden;
  margin: 0 0 var(--s3);
  min-height: 330px;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(115% 78% at 50% 8%, #26304a 0%, #171c28 46%, #0e1118 100%);
  box-shadow: inset 0 0 70px -22px #000, inset 0 1px 0 rgba(255,255,255,.04);
}
/* 8px pixel grid, masked so it fades at the edges */
.showcase .stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg,  rgba(255,255,255,.045) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.045) 0 1px, transparent 1px 8px);
  -webkit-mask-image: radial-gradient(72% 62% at 50% 45%, #000 25%, transparent 100%);
          mask-image: radial-gradient(72% 62% at 50% 45%, #000 25%, transparent 100%);
}
/* corner framing ticks — cheap, and instantly reads "viewport" */
.showcase .stage::after {
  content: ""; position: absolute; inset: 7px; pointer-events: none;
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 3px;
  -webkit-mask-image:
    linear-gradient(#000 0 0) top left    / 14px 14px no-repeat,
    linear-gradient(#000 0 0) top right   / 14px 14px no-repeat,
    linear-gradient(#000 0 0) bottom left / 14px 14px no-repeat,
    linear-gradient(#000 0 0) bottom right/ 14px 14px no-repeat;
          mask-image:
    linear-gradient(#000 0 0) top left    / 14px 14px no-repeat,
    linear-gradient(#000 0 0) top right   / 14px 14px no-repeat,
    linear-gradient(#000 0 0) bottom left / 14px 14px no-repeat,
    linear-gradient(#000 0 0) bottom right/ 14px 14px no-repeat;
}
#char {
  position: relative; z-index: 1;
  image-rendering: pixelated;                /* re-assert: non-negotiable */
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.55));
}

/* controls line up into one column instead of three ragged rows */
.ctl-row { gap: var(--s2); margin-top: var(--s2); }
.ctl-label { flex: none; width: 66px; font-size: var(--fs-2xs); color: var(--dimmer); }
.seg button, .rollmode button { padding: 5px 11px; font-size: var(--fs-sm); }
.seg button + button { border-left: 1px solid rgba(255,255,255,.05); }

/* layer report: a mono readout, not body copy */
.layers {
  margin-top: var(--s3); padding-top: var(--s2);
  border-top: 1px solid var(--line); gap: 2px;
}
.lrow { font-size: var(--fs-xs); color: var(--dimmer); }
.lrow span:first-child { text-transform: uppercase; letter-spacing: .8px; }
.lrow b { color: #9fb0c9; font-weight: 500; }
.lrow.miss b { color: var(--r4); font-style: normal; opacity: .8; }

/* ══ 7. STATS ════════════════════════════════════════════════ */
.note {
  margin: 0 0 var(--s3); padding: var(--s2) 0 var(--s2) var(--s2);
  border-left: 2px solid var(--line-2);
  font-size: var(--fs-xs); line-height: 1.55; color: var(--dimmer);
}

.statrow { padding: 5px 0; border-bottom: 1px solid #1d2230; }
.statrow .sname { font-size: var(--fs-md); color: var(--dim); gap: var(--s2); }
.statrow .sval  { font-size: var(--fs-base); color: #cdd6e6; font-weight: 600; }

/* the six primaries are the headline */
.statrow.primary { padding: 7px 0; }
.statrow.primary .sname { font-size: var(--fs-base); color: #fff; }
.statrow.primary .sval  { font-size: var(--fs-lg); color: #fff; }
.statrow.primary .dot   { width: 7px; height: 7px; }

/* hairline between the primary block and the derived list */
.statrow.primary + .statrow:not(.primary) {
  margin-top: var(--s3); padding-top: var(--s3);
  border-top: 1px solid var(--line);
}

.dot { width: 5px; height: 5px; }

.relicrow { display: flex; align-items: baseline; gap: var(--s2); padding: 3px 0; }
.relicrow .rl { flex: 1; font-size: var(--fs-md); }
.relicrow .rv { color: var(--r3); font-weight: 600; }
.relicrow .rr { color: var(--dimmer); }

.req { padding: 3px 0; font-size: var(--fs-md); }
.req b { color: var(--text); }

.empty-note { color: #454c5d; font-size: var(--fs-sm); font-style: italic; }

/* ══ 8. LAYOUT & RESPONSIVE ══════════════════════════════════ */
.layout {
  grid-template-columns:
    minmax(258px, 300px) minmax(238px, 292px) minmax(360px, 1fr) minmax(248px, 300px);
}
.layout > .panel:nth-child(1) { grid-area: loadout; }
.layout > .panel:nth-child(2) { grid-area: showcase; }
.layout > .panel:nth-child(3) { grid-area: browser; }
.layout > .panel:nth-child(4) { grid-area: stats; }

@media (min-width: 1501px) {
  .layout { grid-template-areas: "loadout showcase browser stats"; }
  /* stats follow you down a long item list */
  .layout > .panel:nth-child(4) {
    position: sticky; top: calc(var(--top-h) + var(--s3));
  }
}

/* 2-column: loadout / showcase / stats stack at left, browser owns the right */
@media (max-width: 1500px) {
  .layout {
    grid-template-columns: minmax(280px, 348px) minmax(0, 1fr);
    grid-template-areas:
      "loadout  browser"
      "showcase browser"
      "stats    browser";
    align-content: start;
  }
  .layout > .panel:nth-child(3) { position: sticky; top: calc(var(--top-h) + var(--s3)); }
  .results { max-height: calc(100vh - 224px); }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "loadout" "showcase" "browser" "stats";
  }
  .layout > .panel { position: static !important; }
  .slotgrid { grid-template-columns: repeat(auto-fill, minmax(92px, 108px)); }
  .results { max-height: 62vh; }
}

@media (max-width: 560px) {
  .top { flex-direction: column; align-items: flex-start; gap: var(--s2); }
  .badge { display: none; }
  .ctl-label { width: 100%; }
  .ctl-row { align-items: baseline; }
}

/* ══ 9. CHROME ═══════════════════════════════════════════════ */
* { scrollbar-width: thin; scrollbar-color: #333a4b transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2b3242; border-radius: 6px;
  border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #3b445a; background-clip: padding-box; }

.toast {
  background: #1b2028;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  box-shadow: 0 18px 40px -20px #000;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .slot:hover, .row:active, .btn:active { transform: none; }
}

/* Hard-capped stats: a summed total above the cap is not the effective value */
.statrow .sval .capped {
  font-size: 10px; font-weight: 500; color: #e0894a;
  letter-spacing: .2px; white-space: nowrap;
}
.statrow .sval.over-cap { color: #e0894a; }

/* Cosmetic marker in the item browser */
.row .rname { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.tag-cos {
  font-size: 9px; text-transform: uppercase; letter-spacing: .6px;
  padding: 1px 5px; border-radius: 3px; font-weight: 600;
  color: #7fd8ef; background: #123039; border: 1px solid #1d4f5e;
}

/* Legendary effects applied by the loot table on drop */
.row .fx { display: flex; align-items: baseline; gap: 6px; margin-top: 3px; font-size: 10px; }
.fx-trigger {
  text-transform: uppercase; letter-spacing: .5px; font-size: 9px; font-weight: 600;
  color: #d9a441; background: #2a2113; border: 1px solid #4a3c1c;
  padding: 1px 5px; border-radius: 3px;
}
.fx-label { color: #e8d5a8; }
.fx-impact { color: var(--dim); }
.effects { display: flex; flex-direction: column; gap: 7px; }
.fxrow-head { display: flex; align-items: baseline; gap: 6px; font-size: 11px; }
.fxrow-sub { font-size: 10px; color: var(--dim); margin-top: 1px; }


/* follower toggle */
.chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs, 11px); color: var(--dim); cursor: pointer;
}
.chk input { accent-color: var(--accent); cursor: pointer; }

/* Legal / copyright footer — muted, unobtrusive, matches the panel chrome. */
.legal {
  max-width: 1200px;
  margin: 20px auto 28px;
  padding: 14px 18px 0;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px;
  line-height: 1.5;
}
.legal p { margin: 0; }
.legal a { color: var(--dim); text-decoration: underline; }
.legal a:hover { color: var(--text); }
