/* One dark theme in the game's own palette: near-black panels, bronze frames,
   unique-item orange for names. Cinzel (SIL OFL 1.1, fonts/Cinzel-OFL.txt) is
   served from this site so no visitor data goes to a font CDN. */
@font-face {
  font-family: 'Cinzel'; font-style: normal; font-weight: 600 700; font-display: swap;
  src: url(fonts/cinzel-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cinzel'; font-style: normal; font-weight: 600 700; font-display: swap;
  src: url(fonts/cinzel-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0a0705;
  --panel: #130e0a;
  --panel-2: #1b140e;
  --line: #33251a;
  --frame: #6e4a24;
  --frame-hi: #b07a3e;
  --ink: #e6dcc8;
  --ink-2: #a3967f;
  --gold: #d6b067;        /* gold fees and the headline number */
  --name: #f0a058;        /* unique-item orange, for names and headings */
  --up: #86cf8f;
  --down: #ec7a72;
  --focus: #ffd27a;
  --row-hover: #1f170f;
  --heading: 'Cinzel', Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --btn-bg: linear-gradient(180deg, #2c1c0f 0%, #160d06 55%, #0c0703 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); scrollbar-color: var(--frame) #0c0703; scrollbar-gutter: stable; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 400 15px/1.45 var(--body); font-variant-numeric: tabular-nums;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgb(175 96 37 / .14), transparent 70%),
    var(--bg);
}
a { color: var(--name); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 20; padding: 8px 14px; background: var(--panel-2); border: 1px solid var(--frame-hi); color: var(--ink); }
.skip:focus { top: 12px; }

/* ---------- header ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: end; gap: 12px 28px; padding: 14px 24px;
  background: radial-gradient(ellipse 55% 140% at 30% 50%, rgb(205 110 45 / .16), transparent 72%), linear-gradient(180deg, #0e0602 0%, #1d0f08 50%, #0e0602 100%);
  border-bottom: 1px solid var(--frame);
  box-shadow: 0 1px 0 #000, 0 6px 18px rgb(0 0 0 / .5);
}
.brand { font: 700 26px/1 var(--heading); margin: 0; color: var(--name); letter-spacing: .03em; text-shadow: 0 0 3px #000, 0 0 14px rgb(224 128 58 / .35); }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.controls label { display: grid; gap: 2px; font-size: 12px; color: var(--ink-2); }
.controls label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; padding-bottom: 6px; }
select, input[type="search"], input[type="number"] {
  font: inherit; font-size: 14px; color: var(--ink); background: #0c0805;
  border: 1px solid var(--frame); border-radius: 3px; padding: 5px 8px; max-width: 100%;
}
input[type="number"] { width: 6.5em; }
input[type="checkbox"] { accent-color: var(--frame-hi); }

main { padding: 0 24px 40px; max-width: 1400px; margin: 0 auto; }

/* ---------- hero: the market's anchor rate ---------- */
.hero { padding: 26px 0 18px; min-height: 140px; }
.rate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 0; }
.rate .side { display: inline-flex; align-items: center; gap: 10px; font: 700 clamp(28px, 5.5vw, 52px)/1 var(--heading); color: var(--ink); }
.rate .side img { width: 1.05em; height: 1.05em; object-fit: contain; }
.rate .eq { font: 600 clamp(24px, 4.5vw, 42px)/1 var(--heading); color: var(--ink-2); }
.rate .num { color: var(--gold); text-shadow: 0 0 16px rgb(214 176 103 / .25); }
.hero .sub { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; color: var(--ink-2); font-size: 14px; }
.hero .sub b { color: var(--ink); font-weight: 600; }
.status { color: var(--ink-2); font-size: 16px; }
.status.err { color: var(--down); max-width: 70ch; }

/* ---------- framed panels: live bar, drawer, toasts ---------- */
.live, dialog#drawer, .toast {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--frame);
  box-shadow: 0 0 0 1px #000, 0 0 22px rgb(175 96 37 / .12), 0 10px 28px rgb(0 0 0 / .55);
}
.live { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 14px; padding: 10px 12px; border-radius: 4px; font-size: 13px; color: var(--ink-2); max-width: 900px; }
.live .next { color: var(--ink); font-weight: 600; }
.live label.check, .live label.inline { display: flex; gap: 6px; align-items: center; }
.live input[type="number"] { width: 6em; padding: 3px 6px; font-size: 13px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--frame); overflow-x: auto; }
.tabs button {
  font: 600 14px/1 var(--heading); letter-spacing: .03em; color: var(--ink-2); background: none;
  border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; padding: 11px 14px 10px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--name); background: var(--btn-bg); border-color: var(--frame); text-shadow: 0 0 10px rgb(224 128 58 / .35); }

.panel { padding-top: 16px; }
.lede { max-width: 75ch; color: var(--ink-2); margin: 0 0 14px; }
.lede b { color: var(--ink); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin-bottom: 12px; }
.filters label { display: grid; gap: 2px; font-size: 12px; color: var(--ink-2); }
.filters label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; padding-bottom: 6px; }
.count { color: var(--ink-2); font-size: 13px; margin-left: auto; padding-bottom: 6px; }
details.morefilters { margin: -4px 0 12px; }
details.morefilters summary { cursor: pointer; color: var(--ink-2); font-size: 13px; width: max-content; }
details.morefilters .filters { margin: 10px 0 0; }

button.ghost {
  font: 600 13px/1 var(--heading); letter-spacing: .03em; color: #d9bd85; background: var(--btn-bg);
  border: 1px solid var(--frame); border-radius: 3px; padding: 10px 14px; cursor: pointer;
}
button.ghost:hover { border-color: var(--frame-hi); color: var(--ink); }
button.ghost:disabled { opacity: .6; cursor: progress; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; border-top: 1px solid var(--frame); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--panel); font-weight: 600; color: var(--ink-2); font-size: 13px; cursor: pointer; user-select: none; }
th[aria-sort] { color: var(--name); }
th[aria-sort="descending"]::after { content: " ▾"; }
th[aria-sort="ascending"]::after { content: " ▴"; }
th.l, td.l { text-align: left; }
th:first-child, td:first-child { padding-right: 0; }
tbody tr:hover { background: var(--row-hover); }
tr.click { cursor: pointer; }
tr.click:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.muted { color: var(--ink-2); }
.item { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.item img, .item .ph { width: 26px; height: 26px; object-fit: contain; flex: none; }
.ph { display: inline-grid; place-items: center; border: 1px solid var(--frame); border-radius: 3px; font-size: 12px; color: var(--ink-2); background: #0c0805; }
.item .name { overflow: hidden; text-overflow: ellipsis; max-width: 26ch; color: var(--ink); }
.item small { display: block; color: var(--ink-2); font-size: 12px; }
.gold { color: var(--gold); }
.up { color: var(--up); }
.down { color: var(--down); }
.dir { font-size: 13px; }
.dir img { width: 18px; height: 18px; vertical-align: -4px; }
svg.spark { width: 90px; height: 22px; display: block; margin-left: auto; }
svg.spark path { fill: none; stroke: var(--frame-hi); stroke-width: 1.5; }
.more { margin: 14px 0; }
.empty { color: var(--ink-2); padding: 18px 0; }
.badge { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 3px; font-size: 11px; line-height: 16px; vertical-align: 1px; border: 1px solid currentColor; }
.badge.new { color: var(--up); }
.badge.warn { color: var(--gold); }
button.star { font: inherit; font-size: 17px; line-height: 1; background: none; border: 0; padding: 2px 4px; cursor: pointer; color: var(--ink-2); }
button.star.on { color: var(--gold); }
.score { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; min-width: 70px; }
.score i { display: inline-block; width: 40px; height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--gold) var(--w), var(--line) var(--w)); }
.recipe { display: inline-flex; align-items: center; gap: 8px; }
.recipe .item .name { max-width: 20ch; }

/* ---------- top picks ---------- */
.picks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 12px 36px; }
.picks-grid h2, .about h2 { font: 700 19px/1.2 var(--heading); color: var(--name); letter-spacing: .02em; margin: 6px 0 6px; }
ol.picks { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--frame); }
ol.picks li { border-bottom: 1px solid var(--line); }
button.pick { display: grid; grid-template-columns: 32px 1fr auto auto 92px; align-items: center; gap: 12px; width: 100%; padding: 9px 4px; font: inherit; color: inherit; text-align: left; background: none; border: 0; cursor: pointer; }
button.pick:hover { background: var(--row-hover); }
button.pick img, button.pick .ph { width: 32px; height: 32px; object-fit: contain; }
.pick-main { min-width: 0; }
.pick-main b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-main small, .pick-num small { display: block; color: var(--ink-2); font-size: 12px; }
.pick-num { text-align: right; white-space: nowrap; }
.pick-tag { font-size: 12px; text-align: right; }
.pick-tag.ok { color: var(--up); }
.pick-tag.warn { color: var(--gold); }

/* ---------- charts ---------- */
figure.chart { margin: 8px 0 14px; }
figure.chart svg { display: block; width: 100%; height: auto; max-height: 220px; }
figure.chart .grid { stroke: var(--line); stroke-width: 1; }
figure.chart .axis { fill: var(--ink-2); font-size: 11px; font-family: var(--body); }
figure.chart .line { fill: none; stroke-width: 2; }
figure.chart .line.a { stroke: var(--ink); }
figure.chart .line.b { stroke: var(--name); }
figure.chart .band { fill: var(--frame); opacity: .35; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.legend .key { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: 3px; background: var(--ink); }
.legend .key.b { background: var(--name); }
figure.chart.hero-chart { max-width: 560px; margin-top: 12px; }
figure.chart.hero-chart svg { max-height: 120px; width: auto; max-width: 100%; }

/* ---------- detail drawer ---------- */
dialog#drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(560px, 100vw); max-width: 100vw;
  border-width: 0 0 0 1px; padding: 22px 22px 40px; color: var(--ink); overflow-y: auto;
}
dialog#drawer::backdrop { background: rgb(0 0 0 / .65); }
dialog#drawer h2 { font: 700 21px/1.2 var(--heading); color: var(--name); margin: 0 36px 10px 0; text-shadow: 0 0 3px #000, 0 0 12px rgb(224 128 58 / .3); }
dialog#drawer h3 { font: 700 15px/1.2 var(--heading); letter-spacing: .03em; margin: 20px 0 6px; color: var(--ink); }
.close { position: absolute; top: 10px; right: 10px; font-size: 24px; line-height: 1; background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 4px 8px; }
.close:hover { color: var(--ink); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 6px 0 0; font-size: 14px; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; }
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 8px 0 12px; }
.calc label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-2); }
.calc .unit { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.calc input { width: 100%; min-width: 0; }
.steps { padding-left: 20px; margin: 8px 0; }
.steps li { margin: 4px 0; }
.result { font-size: 15px; }
.links { margin-top: 18px; display: flex; align-items: center; gap: 10px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 10; max-width: min(380px, calc(100vw - 32px)); }
.toast { position: relative; border-radius: 4px; border-color: var(--frame-hi); animation: toast-in .25s ease-out; }
.toast .toast-body { display: grid; gap: 2px; width: 100%; padding: 12px 36px 12px 14px; font: inherit; font-size: 14px; color: var(--ink); text-align: left; background: none; border: 0; cursor: pointer; }
.toast .toast-body b { color: var(--name); font-weight: 600; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- guide and footer ---------- */
.about { max-width: 72ch; }
.about h2 { margin-top: 26px; }
.about code { font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); padding: 1px 4px; border-radius: 3px; }
.foot { padding: 18px 24px 28px; color: var(--ink-2); font-size: 13px; border-top: 1px solid var(--frame); background: var(--panel); }
.foot p { margin: 4px 0; max-width: 100ch; }

@media (max-width: 640px) {
  .bar, main, .foot { padding-left: 16px; padding-right: 16px; }
  .item .name { max-width: 16ch; }
  .calc { grid-template-columns: 1fr; }
  dialog#drawer { padding: 18px 16px 32px; }
  button.pick { grid-template-columns: 28px 1fr auto; }
  button.pick .pick-num:nth-of-type(3), button.pick .pick-tag { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } .toast { animation: none; } }
.chain { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; white-space: normal; }

ol.demand { padding-left: 20px; margin: 6px 0 10px; }
ol.demand li { margin: 6px 0; }
ol.demand li .desc { display: block; color: var(--ink-2); font-size: 14px; }
ol.demand li.limit b { color: var(--gold); }

/* ---------- formulas: info buttons, popovers, panel, worked examples ---------- */
button.info {
  display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 5px; padding: 0; vertical-align: 1px;
  font: 700 11px/1 var(--body); color: var(--ink-2); background: #0c0805; border: 1px solid var(--frame); border-radius: 50%; cursor: help;
}
button.info:hover, button.info:focus-visible { color: var(--name); border-color: var(--frame-hi); }
.pop {
  max-width: min(520px, calc(100vw - 32px)); padding: 16px 18px; color: var(--ink);
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--frame-hi); border-radius: 4px;
  box-shadow: 0 0 0 1px #000, 0 12px 40px rgb(0 0 0 / .7);
}
.pop::backdrop { background: rgb(0 0 0 / .35); }
.formula b { display: block; font: 700 15px/1.2 var(--heading); color: var(--name); letter-spacing: .02em; margin-bottom: 6px; }
.formula pre {
  margin: 0 0 8px; padding: 8px 10px; white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--gold); background: #0c0805; border: 1px solid var(--line); border-radius: 3px;
}
.formula p { margin: 0 0 8px; color: var(--ink-2); font-size: 14px; }
.fgroup { padding: 14px 0; border-top: 1px solid var(--line); }
.param { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px 10px; margin: 8px 0; font-size: 14px; }
.param .unit { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.param input[type="number"] { width: 6.5em; }
.param small { grid-column: 1 / -1; color: var(--ink-2); font-size: 12px; }
button.linklike { font: inherit; font-size: 13px; color: var(--name); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
details.worked { margin: 14px 0; padding: 8px 12px; background: #0c0805; border: 1px solid var(--line); border-radius: 3px; }
details.worked summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
details.worked dl, dl.lab-out { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 10px 0 2px; font-size: 13px; }
details.worked dt, dl.lab-out dt { color: var(--ink-2); }
details.worked dd, dl.lab-out dd { margin: 0; overflow-wrap: anywhere; }
details.worked code, dl.lab-out code { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--gold); }
.controls .ghost { align-self: end; margin-bottom: 1px; }

/* ---------- lab ---------- */
.labs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: 18px 28px; }
.lab { padding: 14px 16px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--frame); border-radius: 4px; }
.lab h2 { font: 700 18px/1.2 var(--heading); color: var(--name); margin: 0 0 10px; }
.lab-in { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
.lab-in label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-2); }
.lab-in input { width: 100%; }
dl.lab-out { padding-top: 10px; border-top: 1px solid var(--line); }
@media (max-width: 640px) { details.worked dl, dl.lab-out, .param { grid-template-columns: 1fr; } }
table.mini { width: 100%; margin: 4px 0 10px; font-size: 13px; }
table.mini th, table.mini td { text-align: left; white-space: normal; padding: 5px 8px; position: static; cursor: default; }
.formula .note { font-size: 13px; }
