/* ─────────────────────────────────────────────────────────────────────────
   THE VAULT — EXPEDITION RECORD
   Front-end reference implementation. Data is generated client-side from a
   seeded RNG; every field name maps to a column in stats.db (see the API view
   and QuestLinesVault/md/vault-stats-schema.md).

   Visual system: a single dark world lit from within. The page takes on the
   colour of whichever vault you are looking at — every screen sets --tint from
   the opening's biome, and that tint drives the hero, the depth shaft and the
   accents. Neutral ore-light (--ore) is reserved for chrome so the biome
   colour never has to fight the UI. Deliberately no light theme: a luminous
   underground that turns white on a light OS setting stops being underground.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;

  /* Ground — warm-black with a blue undertone, layered rather than flat. */
  --void:     #07080B;
  --ground:   #0B0D12;
  --panel:    #12151D;
  --panel-2:  #191D27;
  --raised:   #1F2431;

  --edge:      rgba(255,255,255,.07);
  --edge-soft: rgba(255,255,255,.04);
  --edge-lit:  rgba(255,255,255,.13);

  --ink:   #EAE6DE;
  --ink-2: #9DA2B0;
  --ink-3: #666C7C;

  /* Ore-light: the lamp you carry. Chrome only. */
  --ore:      #E8A33D;
  --ore-dim:  #A9741F;
  --ore-glow: rgba(232,163,61,.30);

  --ember:      #E8593A;   /* death / critical */
  --ember-glow: rgba(232,89,58,.28);
  --good:       #4FC08A;

  /* Rarity ladder — authored in loottables.json, brightened for a dark ground. */
  --r-common:    #A8A8A8;
  --r-uncommon:  #46D92B;
  --r-rare:      #3E96F0;
  --r-epic:      #B478F5;
  --r-legendary: #FF9124;
  --r-unique:    #F0DA9E;
  --r-mythic:    #FF4F4F;

  /* Fallback tint until a view sets its biome colour. */
  --tint:     #E8A33D;
  --tint-dim: rgba(232,163,61,.22);

  /* Inter, matching the in-game UI. The hosted copy loads it from a CDN; the artifact
     build cannot (its CSP blocks font hosts) and falls back down this stack, so the
     fallbacks are chosen to be metrically close rather than arbitrary. */
  --display: "Inter","Inter Variable","Inter var",system-ui,"Segoe UI Variable Text","Segoe UI",Roboto,"Helvetica Neue",sans-serif;
  --body:    var(--display);
  --mono:    "Cascadia Mono","JetBrains Mono","IBM Plex Mono","SFMono-Regular",Menlo,Consolas,monospace;

  /* Hytale nine-patch chrome. Slice values come from the PatchStyle defs in the
     client's Common.ui, doubled because these are the @2x textures:
       ContainerFullPatch  Border 20            -> slice 40, width 20px
       ContainerPanelPatch Border 4             -> slice 8,  width 4px
       ContainerHeader     HorizontalBorder 50  -> slice 0 100, width 0 50px */
  --tex-frame:  url("ui/frame.png");
  --tex-panel:  url("ui/panel.png");
  --tex-panelt: url("ui/panelt.png");
  --tex-header: url("ui/header.png");
  --tex-decotop: url("ui/decotop.png");
  --tex-decobot: url("ui/decobot.png");
  --tex-tabbg:  url("ui/tabbg.png");
  --tex-tabsel: url("ui/tabsel.png");
  --tex-sep:    url("ui/sep.png");
}

/* The Histatu atmospheres (histatu-theme.js sets data-atm-frame) swap the navy chrome for the warm
   copies in ui/ember/, made by tools/recolor_vault_ui.py. Rarity-coloured slots keep Hytale's art. */
html[data-atm-frame="ember"] {
  --tex-frame:  url("ui/ember/frame.png");
  --tex-panel:  url("ui/ember/panel.png");
  --tex-panelt: url("ui/ember/panelt.png");
  --tex-header: url("ui/ember/header.png");
  --tex-decotop: url("ui/ember/decotop.png");
  --tex-decobot: url("ui/ember/decobot.png");
  --tex-tabbg:  url("ui/ember/tabbg.png");
  --tex-tabsel: url("ui/ember/tabsel.png");
  --tex-sep:    url("ui/ember/sep.png");
}

/* ── Hytale chrome ────────────────────────────────────────────────────── */
/* The client's own window frame. `fill` keeps the texture's dark centre, so the
   panel body is Hytale's colour rather than ours. */
.frame {
  border: 20px solid transparent;
  border-image: var(--tex-frame) 40 fill stretch;
  position: relative;
}
.panelbox {
  border: 4px solid transparent;
  border-image: var(--tex-panel) 8 fill stretch;
}
.panelbox.light { border-image: var(--tex-panelt) 8 fill stretch; }

/* Title bar — stretches horizontally, fixed height (76px @2x = 38 logical). */
.titlebar {
  height: 38px;
  border: 0 solid transparent;
  border-width: 0 50px;
  border-image: var(--tex-header) 0 100 fill stretch;
  display: flex; align-items: center; justify-content: center;
  margin: -4px -4px 14px;
}
.titlebar span {
  font-family: var(--mono); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; padding: 0 8px;
}
/* Ornaments that sit above / below a framed block. */
.deco { height: 11px; background-repeat: no-repeat; background-position: center; background-size: auto 11px; }
.deco.top { background-image: var(--tex-decotop); }
.deco.bot { background-image: var(--tex-decobot); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient depth: a cold glow overhead, darkness closing in at the edges. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(120,150,220,.10), transparent 60%),
    radial-gradient(90% 60% at 50% 115%, rgba(0,0,0,.85), transparent 55%);
}
/* Mineral grain. */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Scoped to the Vault's own column: the landclaim sidebar and topbar around it style their own links. */
:where(.vault-main) a { color: inherit; text-decoration: none; }

/* The page sits in the landclaim shell (style.css .main-wrapper), which centres a grid; the Vault
   lays itself out as a plain column. */
.vault-main { display: block; justify-items: normal; min-width: 0; }
:focus-visible { outline: 2px solid var(--ore); outline-offset: 3px; }

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.lbl {
  font-family: var(--mono); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ── Masthead ─────────────────────────────────────────────────────────── */
.masthead {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 30px;
  padding: 20px 40px 16px;
  border-bottom: 1px solid var(--edge);
  background: linear-gradient(180deg, var(--void), transparent);
}

.wordmark { display: flex; align-items: center; gap: 13px; line-height: 1; flex: none; text-decoration: none; }
.wordmark .wm-text { display: flex; flex-direction: column; }
.wm-logo { flex: none; width: 48px; height: 48px; filter: drop-shadow(0 0 8px rgba(255,120,40,.35)); }
.wordmark .a {
  font-family: var(--display); font-size: 26px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  background: linear-gradient(180deg, #FFF3DC 10%, var(--ore) 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.wordmark .b {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .38em;
  text-transform: uppercase; color: var(--ink-3); margin-top: 6px;
}

.mnav { display: flex; gap: 4px; margin-left: auto; }
.mnav a {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-2);
  padding: 9px 15px; border: 1px solid transparent; position: relative;
  transition: color .18s, border-color .18s;
}
.mnav a:hover { color: var(--ink); border-color: var(--edge); }
.mnav a[aria-current="page"] {
  color: var(--ore); border-color: rgba(232,163,61,.34);
  background: rgba(232,163,61,.06);
  box-shadow: inset 0 0 22px rgba(232,163,61,.10);
}

.search { position: relative; width: 230px; flex: none; }
.search input {
  width: 100%; font-family: var(--mono); font-size: 11.5px;
  background: rgba(0,0,0,.45); border: 1px solid var(--edge);
  color: var(--ink); padding: 10px 13px;
  transition: border-color .18s, box-shadow .18s;
}
.search input::placeholder {
  color: var(--ink-3); letter-spacing: .16em; text-transform: uppercase; font-size: 9.5px;
}
.search input:focus {
  outline: none; border-color: var(--ore-dim);
  box-shadow: 0 0 0 1px rgba(232,163,61,.18), 0 0 26px rgba(232,163,61,.10);
}
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--panel-2); border: 1px solid var(--edge-lit);
  box-shadow: 0 20px 50px rgba(0,0,0,.75);
  max-height: 320px; overflow-y: auto;
}
.results button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--edge-soft); padding: 10px 13px;
  cursor: pointer; color: var(--ink); font-family: var(--mono); font-size: 12px;
}
.results button:last-child { border-bottom: 0; }
.results button:hover { background: rgba(232,163,61,.10); color: var(--ore); }
.results .r-score { font-size: 10.5px; color: var(--ink-3); }

/* ── Status strip ─────────────────────────────────────────────────────── */
.statusbar {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 11px 40px;
  border-bottom: 1px solid var(--edge);
  background: rgba(0,0,0,.35);
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
}
.state { display: flex; align-items: center; gap: 9px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.open {
  background: var(--good);
  box-shadow: 0 0 12px var(--good), 0 0 26px rgba(79,192,138,.45);
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.state.live { color: var(--good); }
.state.shut { color: var(--ink-3); }
.status-clock { font-size: 15px; letter-spacing: .06em; color: var(--ink); font-variant-numeric: tabular-nums; }
.status-note { color: var(--ink-3); letter-spacing: .1em; }
.status-theme { color: var(--tint); letter-spacing: .3em; }

/* Live theme vote — shown while the vault is sealed, because the theme genuinely
   is not decided until the pre-open lead-in locks it in. */
.vote { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.vote-lbl { color: var(--ore); letter-spacing: .2em; }
.vote-opt { display: flex; align-items: center; gap: 6px; color: var(--ink-3); }
.vote-opt .n { letter-spacing: .12em; }
.vote-opt .vt { font-size: 8px; letter-spacing: .16em; color: var(--ink-3); opacity: .8; }
.vote-opt .bar { width: 34px; height: 4px; background: rgba(255,255,255,.09); position: relative; }
.vote-opt .bar i { position: absolute; inset: 0 auto 0 0; background: currentColor; opacity: .8; }
.vote-opt .c { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.vote-opt.lead { color: var(--tint); }
.vote-opt.lead .c { color: var(--tint); }

/* ── Crumbs + shell ───────────────────────────────────────────────────── */
.crumbs {
  position: relative; z-index: 5;
  padding: 14px 40px 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--ore); }
.crumbs .sep { opacity: .4; padding: 0 8px; }

.view { position: relative; z-index: 5; padding: 0 40px 90px; max-width: 1280px; }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  margin: 22px 0 34px;
  padding: 40px 34px 32px;
  /* Hytale's window frame, drawn WITHOUT `fill` so our tint gradients still show
     through the middle — the client chrome on top of the vault's own atmosphere. */
  border: 20px solid transparent;
  border-image: var(--tex-frame) 40 stretch;
  background:
    radial-gradient(130% 150% at 50% -30%, var(--tint-dim), transparent 62%),
    linear-gradient(180deg, rgba(255,255,255,.05), transparent 40%),
    var(--panel);
  overflow: hidden;
}
/* Light spilling from the top edge. */
.hero::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--tint), transparent);
  opacity: .85;
}
/* Strata scored into the floor of the hero. */
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
  pointer-events: none;
  background: repeating-linear-gradient(180deg,
    transparent 0 13px, rgba(255,255,255,.022) 13px 14px);
  mask-image: linear-gradient(180deg, transparent, #000);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000);
}
.hero > * { position: relative; z-index: 1; }

.hero-title {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(36px, 6vw, 70px); line-height: .98;
  letter-spacing: -.028em; margin: 12px 0 0; text-wrap: balance;
  color: var(--ink);
  text-shadow: 0 0 62px var(--tint-dim);
}
.hero-title.tinted {
  background: linear-gradient(176deg, #FFFFFF 4%, var(--tint) 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lede {
  font-size: 16.5px; color: var(--ink-2); max-width: 60ch; margin: 16px 0 0;
}
.hero-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 20px; }

.hero-split { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 34px; align-items: end; }
.hero-figure { text-align: right; flex: none; }
.hero-figure .v {
  font-family: var(--display); font-weight: 600; font-size: 62px; line-height: .9;
  color: var(--ore); text-shadow: 0 0 40px var(--ore-glow);
  font-variant-numeric: tabular-nums;
}
.hero-figure .k {
  font-family: var(--mono); font-size: 9px; letter-spacing: .24em;
  text-transform: uppercase; color: var(--ink-3); margin-top: 9px;
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.sec { margin-top: 44px; }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; padding-bottom: 10px;
  border-bottom: 1px solid var(--edge);
}
.sec-title {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .26em;
  text-transform: uppercase; color: var(--ink);
}
.sec-title::before { content: "◆ "; color: var(--tint); }
.sec-note { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3); }

/* ── Chips ────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .17em;
  text-transform: uppercase; padding: 5px 10px;
  border: 1px solid var(--edge); color: var(--ink-2);
  background: rgba(0,0,0,.28); white-space: nowrap;
}
a.chip { transition: border-color .18s, color .18s; }
a.chip:hover { color: var(--ore); border-color: var(--ore-dim); }
.chip.ok    { color: var(--good);  border-color: rgba(79,192,138,.42);  background: rgba(79,192,138,.09); }
.chip.bad   { color: var(--ember); border-color: rgba(232,89,58,.45);   background: rgba(232,89,58,.10);
              box-shadow: inset 0 0 18px var(--ember-glow); }
.chip.warn  { color: var(--ore);   border-color: rgba(232,163,61,.42);  background: rgba(232,163,61,.08); }
.chip.theme { color: var(--tint); border-color: currentColor; background: rgba(0,0,0,.35);
              box-shadow: inset 0 0 20px var(--tint-dim); }

/* Rarity emits light — the whole point of a loot record. */
.rar { font-family: var(--mono); font-size: 11px; letter-spacing: .09em; }
.rar-common    { color: var(--r-common); }
.rar-uncommon  { color: var(--r-uncommon);  text-shadow: 0 0 14px rgba(70,217,43,.5); }
.rar-rare      { color: var(--r-rare);      text-shadow: 0 0 14px rgba(62,150,240,.55); }
.rar-epic      { color: var(--r-epic);      text-shadow: 0 0 16px rgba(180,120,245,.6); }
.rar-legendary { color: var(--r-legendary); text-shadow: 0 0 18px rgba(255,145,36,.6); }
.rar-unique    { color: var(--r-unique);    text-shadow: 0 0 20px rgba(240,218,158,.6); }
.rar-mythic    { color: var(--r-mythic);    text-shadow: 0 0 20px rgba(255,79,79,.65); }

/* ── Stat tiles ───────────────────────────────────────────────────────── */
/* Flex rather than grid so a partial last row CENTRES instead of hugging the left.
   --cols is computed per strip so rows are balanced (12 cells -> 6+6, not 8+4). */
.strip {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 1px; background: var(--edge-soft);
  border: 4px solid transparent;
  border-image: var(--tex-panel) 8 stretch;
}
.strip .cell {
  flex: 1 1 calc((100% - (var(--cols, 6) - 1) * 1px) / var(--cols, 6));
  min-width: 128px;          /* narrow screens re-wrap on their own */
  padding: 17px 18px; background: var(--panel);
  position: relative; transition: background .2s;
  text-align: center;
}
.strip .cell:hover { background: var(--panel-2); }
.strip .cell .v {
  font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1;
  letter-spacing: .005em; font-variant-numeric: tabular-nums; color: var(--ink);
}
.strip .cell .v small { font-size: 14px; color: var(--ink-3); font-family: var(--mono); }
.strip .cell .k {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-3); margin-top: 8px;
}

/* ── Openings list ────────────────────────────────────────────────────── */
.windows { display: flex; flex-direction: column; gap: 1px; }

.wcard {
  display: grid; grid-template-columns: 150px minmax(0,1fr) 290px 84px;
  gap: 26px; align-items: center;
  padding: 20px 24px;
  width: 100%; text-align: left; color: inherit; font: inherit;
  border: 1px solid var(--edge-soft); border-left: 3px solid var(--tint);
  background:
    linear-gradient(90deg, var(--tint-dim), transparent 32%),
    var(--panel);
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform .18s, border-color .18s, box-shadow .22s;
}
.wcard:hover {
  transform: translateX(4px);
  border-color: var(--edge-lit); border-left-color: var(--tint);
  box-shadow: -14px 0 40px -18px var(--tint), 0 14px 40px rgba(0,0,0,.55);
}

.wc-when { display: flex; flex-direction: column; gap: 3px; }
.wc-date { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); }
.wc-ago  { font-family: var(--mono); font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }

.wc-theme {
  font-family: var(--display); font-weight: 600; font-size: 25px;
  letter-spacing: -.015em; color: var(--tint); line-height: 1.1;
  text-shadow: 0 0 34px var(--tint-dim);
}
.wc-meta { font-size: 14px; color: var(--ink-2); margin-top: 5px; }

.wc-stats { display: flex; gap: 26px; }
.stat-mini { display: flex; flex-direction: column; gap: 3px; }
.stat-mini .v { font-family: var(--mono); font-size: 17px; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat-mini .k { font-family: var(--mono); font-size: 8px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }

.wc-go {
  text-align: right; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3);
  transition: color .18s, transform .18s;
}
.wcard:hover .wc-go { color: var(--tint); transform: translateX(4px); }

/* ── Depth shaft ──────────────────────────────────────────────────────── */
.gauge-wrap { display: flex; gap: 22px; align-items: flex-start; }

.shaft {
  position: relative; width: 86px; flex: none;
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, var(--panel-2), var(--void));
  overflow: hidden;
  box-shadow: inset 0 2px 24px rgba(0,0,0,.85);
}
/* Reached depth, lit from above. */
.shaft-fill {
  position: absolute; left: 0; right: 0; top: 0;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--tint) 62%, transparent),
    color-mix(in srgb, var(--tint) 12%, transparent));
}
.shaft-strata { position: absolute; inset: 0; }
.shaft-strata i { position: absolute; left: 0; right: 0; height: 1px; background: rgba(255,255,255,.055); }
/* The stopping point — a lit seam across the shaft. */
.shaft-cut {
  position: absolute; left: -1px; right: -1px; height: 0;
  border-top: 2px solid var(--tint);
  box-shadow: 0 0 20px var(--tint), 0 0 44px var(--tint-dim);
}
.shaft-cut span {
  position: absolute; right: 5px; top: 5px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .1em;
  color: var(--tint); text-shadow: 0 0 12px var(--tint);
}
/* Unreached floors, hatched into darkness. */
.shaft-below {
  position: absolute; left: 0; right: 0; bottom: 0;
  background:
    repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255,255,255,.05) 6px 7px),
    rgba(0,0,0,.55);
}
.gauge-ticks { width: 44px; flex: none; position: relative; font-family: var(--mono); font-size: 9px; color: var(--ink-3); }
.gauge-ticks b { position: absolute; left: 0; font-weight: 400; transform: translateY(-50%); font-variant-numeric: tabular-nums; }

/* ── Bars ─────────────────────────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 150px minmax(0,1fr) 54px; gap: 14px; align-items: center; }
.bar-name { font-family: var(--mono); font-size: 11px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: rgba(0,0,0,.5); border: 1px solid var(--edge-soft); position: relative; overflow: hidden; }
.bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tint) 40%, transparent), var(--tint));
  box-shadow: 0 0 16px var(--tint-dim);
}
.bar-val { font-family: var(--mono); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.tablewrap {
  overflow-x: auto; background: var(--panel);
  border: 4px solid transparent;
  border-image: var(--tex-panel) 8 stretch;
}
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 400; text-align: right;
  padding: 13px 15px; border-bottom: 1px solid var(--edge);
  background: rgba(0,0,0,.34); white-space: nowrap;
}
th:first-child, td:first-child, th.l, td.l { text-align: left; }
td {
  font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums;
  padding: 12px 15px; border-bottom: 1px solid var(--edge-soft);
  text-align: right; white-space: nowrap; color: var(--ink-2);
}
tbody tr { cursor: pointer; transition: background .16s, box-shadow .16s; }
tbody tr:hover { background: rgba(255,255,255,.035); box-shadow: inset 3px 0 0 var(--tint); }
tbody tr:last-child td { border-bottom: 0; }
.rank { color: var(--ink-3); width: 52px; }
.rank.top { color: var(--ore); text-shadow: 0 0 14px var(--ore-glow); }
.pname { color: var(--ink); letter-spacing: .04em; }
tbody tr:hover .pname { color: var(--tint); }
.dim { color: var(--ink-3); }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--edge); margin-bottom: 22px; }
/* The client's own header-tab art, stretched to the label. */
.tabs button {
  font-family: var(--mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  border: 0; color: var(--ink-3); padding: 13px 20px 15px; cursor: pointer;
  margin: 0 1px -1px 0;
  background: var(--tex-tabbg) center/100% 100% no-repeat;
  transition: color .18s;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] {
  color: var(--ink);
  background-image: var(--tex-tabsel);
  text-shadow: 0 0 16px var(--tint-dim);
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px,1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(228px,1fr)); gap: 18px; }

.card {
  border: 4px solid transparent;
  border-image: var(--tex-panel) 8 stretch;
  background: var(--panel);
  padding: 18px; position: relative;
  box-shadow: inset 0 1px 0 var(--edge-soft);
}
.card h4 {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 12px; font-weight: 400;
}
.card .big {
  font-family: var(--display); font-weight: 600; font-size: 25px;
  letter-spacing: .01em; line-height: 1.1;
}
.card p { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }

/* ── Item slots ───────────────────────────────────────────────────────── */
/* The real client slot frames, one per item-quality tier. Hytale's ladder stops at
   legendary, so the MMO-only tiers (mythic / unique / divine) reuse the legendary
   frame and separate on the glow instead. */
/* An inventory grid: frame + icon only. Everything else lives in the hover card. */
.showcase { display: flex; flex-wrap: wrap; gap: 8px; }

.qslot {
  width: 64px; height: 64px; flex: none; position: relative;
  padding: 0; border: 0; cursor: pointer;
  background: var(--tex-slot, var(--tex-slotdefault)) center/100% 100% no-repeat;
  display: flex; align-items: center; justify-content: center;
  transition: transform .13s, filter .13s;
}
.qslot:hover, .qslot:focus-visible { transform: translateY(-2px); z-index: 2; }
.qslot img { width: 46px; height: 46px; image-rendering: auto; display: block; }
/* No client icon (custom Vault/MMO items aren't in the vanilla atlas). */
.qslot .noicon {
  font-family: var(--mono); font-size: 17px; color: var(--ink-3); opacity: .55;
}
.qslot .qty {
  position: absolute; right: 4px; bottom: 2px;
  font-family: var(--mono); font-size: 10.5px; color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 5px #000; font-variant-numeric: tabular-nums;
}

/* ── Item hover card ──────────────────────────────────────────────────── */
/* The client's own per-quality tooltip frame (107x107, Border 24 -> slice 48 @2x). */
#tip {
  position: fixed; z-index: 300; pointer-events: none;
  min-width: 232px; max-width: 340px;
  border: 24px solid transparent;
  border-image: var(--tip-tex, var(--tex-tipdefault)) 48 fill stretch;
  filter: drop-shadow(0 18px 34px rgba(0,0,0,.7));
  animation: tipIn .11s ease-out;
}
#tip[hidden] { display: none; }
@keyframes tipIn { from { opacity: 0; transform: translateY(3px); } }

#tip .tip-name { font-family: var(--display); font-weight: 600; font-size: 15px; line-height: 1.25; color: var(--ink); }
#tip .tip-sub {
  font-family: var(--mono); font-size: 9px; letter-spacing: .2em; text-transform: uppercase;
  margin-top: 5px; color: var(--mmo, var(--ink-3));
}
#tip .tip-id { font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); margin-top: 9px; word-break: break-all; }

/* Tooltip frame = the same quality's ItemTooltipTexture. QuestLinesMMO_Divine.json
   deliberately reuses the Legendary tooltip art, so divine does too. */
.t-default   { --tip-tex: url("ui/tip-default.png"); }
.t-common    { --tip-tex: url("ui/tip-common.png"); }
.t-uncommon  { --tip-tex: url("ui/tip-uncommon.png"); }
.t-rare      { --tip-tex: url("ui/tip-rare.png"); }
.t-epic      { --tip-tex: url("ui/tip-epic.png"); }
.t-legendary { --tip-tex: url("ui/tip-legendary.png"); }
.t-junk      { --tip-tex: url("ui/tip-junk.png"); }
.t-tool      { --tip-tex: url("ui/tip-tool.png"); }
.t-divine    { --tip-tex: url("ui/tip-divine.png"); }
html[data-atm-frame="ember"] .t-default   { --tip-tex: url("ui/ember/tip-default.png"); }
html[data-atm-frame="ember"] .t-common    { --tip-tex: url("ui/ember/tip-common.png"); }
html[data-atm-frame="ember"] .t-uncommon  { --tip-tex: url("ui/ember/tip-uncommon.png"); }
html[data-atm-frame="ember"] .t-rare      { --tip-tex: url("ui/ember/tip-rare.png"); }
html[data-atm-frame="ember"] .t-epic      { --tip-tex: url("ui/ember/tip-epic.png"); }
html[data-atm-frame="ember"] .t-legendary { --tip-tex: url("ui/ember/tip-legendary.png"); }
html[data-atm-frame="ember"] .t-junk      { --tip-tex: url("ui/ember/tip-junk.png"); }
html[data-atm-frame="ember"] .t-tool      { --tip-tex: url("ui/ember/tip-tool.png"); }
html[data-atm-frame="ember"] .t-divine    { --tip-tex: url("ui/ember/tip-divine.png"); }

/* The MMO rolled tier — a separate system from the frame, so it reads as its own row. */
.tier {
  display: flex; align-items: baseline; gap: 8px; margin-top: 10px;
  padding-top: 9px; border-top: 1px solid var(--edge-soft);
  font-family: var(--mono); font-size: 9px; letter-spacing: .18em; text-transform: uppercase;
}
.tier-k { color: var(--ink-3); }
.tier-v { letter-spacing: .2em; }
.tier-x { color: var(--ink-3); margin-left: auto; letter-spacing: .1em; }

/* Divine set pieces carry their set's identity and cumulative tier bonuses. */
.setblock {
  margin-top: 10px; padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--set) 45%, transparent);
  background: color-mix(in srgb, var(--set) 9%, transparent);
}
.set-name {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--set);
}
.set-flavor { font-size: 12px; color: var(--ink-3); font-style: italic; margin-top: 2px; }
.set-tier {
  display: flex; align-items: baseline; gap: 7px; margin-top: 7px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase;
}
.set-pc { color: var(--set); border: 1px solid color-mix(in srgb, var(--set) 45%, transparent); padding: 0 4px; }
.set-lbl { color: var(--ink-2); }
.set-bonus { font-size: 12px; color: var(--ink-2); margin: 3px 0 0 12px; }

/* Frame = the item's own Hytale ItemQuality asset (SlotTexture). */
.q-default   { --tex-slot: url("ui/slot-default.png"); }
.q-common    { --tex-slot: url("ui/slot-common.png"); }
.q-uncommon  { --tex-slot: url("ui/slot-uncommon.png"); }
.q-rare      { --tex-slot: url("ui/slot-rare.png"); }
.q-epic      { --tex-slot: url("ui/slot-epic.png"); }
.q-legendary { --tex-slot: url("ui/slot-legendary.png"); }
.q-junk      { --tex-slot: url("ui/slot-junk.png"); }
.q-tool      { --tex-slot: url("ui/slot-tool.png"); }
/* Warm atmospheres: the plain and junk slots take the ember chrome; rarity slots keep their colour. */
html[data-atm-frame="ember"] .q-default { --tex-slot: url("ui/ember/slot-default.png"); }
html[data-atm-frame="ember"] .q-junk    { --tex-slot: url("ui/ember/slot-junk.png"); }
.q-divine    { --tex-slot: url("ui/slot-divine.png"); filter: drop-shadow(0 0 8px rgba(79,224,122,.8)); }

/* An uncollected relic: present in the set, but not yours yet. */
.qslot.locked { filter: grayscale(1) brightness(.42); opacity: .55; }
.qslot.locked:hover, .qslot.locked:focus-visible { filter: grayscale(.7) brightness(.6); opacity: .8; }

/* ── Reliquary progress ───────────────────────────────────────────────── */
.rrow { display: flex; align-items: center; gap: 12px; }
.rbar {
  flex: 1 1 auto; height: 12px; background: rgba(0,0,0,.5);
  border: 1px solid var(--edge-soft); position: relative; overflow: hidden;
}
.rbar i {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--ore) 45%, transparent), var(--ore));
  box-shadow: 0 0 14px var(--ore-glow);
}
.rpct {
  font-family: var(--mono); font-size: 13px; color: var(--ore);
  font-variant-numeric: tabular-nums; min-width: 42px; text-align: right;
}
.rcount {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; min-width: 56px; text-align: right;
}
.rset { margin-top: 18px; }
.rset-h {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em;
  text-transform: uppercase; margin-bottom: 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--edge-soft);
}

/* ── Rolled ("Reforged") attributes ───────────────────────────────────── */
.roll { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--edge-soft); }
.roll-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase;
}
.roll-rar { color: var(--mmo, var(--ink-2)); }
.roll-meta { color: var(--ink-3); }
.attr { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; margin-top: 5px; }
.attr .n { color: var(--ink-2); }
.attr .m { font-family: var(--mono); font-size: 11.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.attr .t {
  font-family: var(--mono); font-size: 8px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); border: 1px solid var(--edge); padding: 0 4px;
}
.attr.base .m  { color: var(--r-rare); }
.attr.perfect .m { color: var(--ore); text-shadow: 0 0 14px var(--ore-glow); }
.attr.curse .n, .attr.curse .m { color: var(--ember); }
.attr-cost {
  font-size: 11.5px; color: var(--ember); opacity: .85; margin: 2px 0 0 15px;
  font-family: var(--mono);
}
.sealed {
  font-family: var(--mono); font-size: 11px; color: var(--ore);
  border: 1px dashed var(--ore-dim); padding: 7px 10px; margin-top: 9px;
  background: rgba(232,163,61,.06);
}

.medals { display: flex; flex-wrap: wrap; gap: 10px; }
.medal {
  border: 1px solid var(--edge); padding: 13px 18px; background: var(--panel);
  display: flex; flex-direction: column; gap: 3px; min-width: 132px;
}
.medal .p {
  font-family: var(--display); font-weight: 600; font-size: 27px; line-height: 1;
  color: var(--ore); text-shadow: 0 0 22px var(--ore-glow); font-variant-numeric: tabular-nums;
}
.medal .m { font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }

/* ── Sparkline ────────────────────────────────────────────────────────── */
.spark { width: 100%; height: 74px; display: block; }
.spark .area { fill: var(--tint-dim); }
.spark .ln   { fill: none; stroke: var(--tint); stroke-width: 1.5; }
.spark .pt   { fill: var(--tint); }
.spark .grid { stroke: var(--edge-soft); stroke-width: 1; }

/* ── API view ─────────────────────────────────────────────────────────── */
.endpoint { border: 1px solid var(--edge); background: var(--panel); margin-bottom: 14px; }
.ep-head { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; padding: 14px 17px; border-bottom: 1px solid var(--edge-soft); }
.verb {
  font-family: var(--mono); font-size: 9px; letter-spacing: .18em;
  padding: 4px 9px; border: 1px solid var(--ore-dim); color: var(--ore);
  background: rgba(232,163,61,.07);
}
.ep-path { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.ep-desc { font-size: 13.5px; color: var(--ink-3); margin-left: auto; }
.ep-body { padding: 15px 17px; }
pre {
  margin: 0; overflow-x: auto; font-family: var(--mono); font-size: 11.5px;
  line-height: 1.7; color: var(--ink-2); background: rgba(0,0,0,.5);
  border: 1px solid var(--edge-soft); padding: 15px 16px;
}
pre .k { color: var(--ore); }
pre .c { color: var(--ink-3); font-style: italic; }

.note { border: 1px solid var(--edge); border-left: 3px solid var(--ore); background: var(--panel); padding: 18px 20px; margin-bottom: 14px; }
.note.good { border-left-color: var(--good); }
.note.good h4 { color: var(--good); }
.note h4 { font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ore); margin: 0 0 10px; }
.note p { margin: 0 0 10px; font-size: 14.5px; color: var(--ink-2); max-width: 74ch; }
.note p:last-child { margin-bottom: 0; }
.note code, .inline-code { font-family: var(--mono); font-size: 12.5px; color: var(--ink); background: rgba(0,0,0,.5); padding: 2px 6px; }

.empty { color: var(--ink-3); font-size: 14px; padding: 26px 0; }

/* Page-load reveal: one orchestrated moment, not scattered effects. */
.view > * { animation: rise .5s cubic-bezier(.2,.7,.3,1) backwards; }
.view > *:nth-child(1) { animation-delay: .02s }
.view > *:nth-child(2) { animation-delay: .08s }
.view > *:nth-child(3) { animation-delay: .14s }
.view > *:nth-child(4) { animation-delay: .2s }
.view > *:nth-child(n+5) { animation-delay: .26s }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ── Armory (divine sets, attributes, vault odds) ─────────────────────── */
.armctl {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px;
  margin: 0 0 22px; padding: 14px 16px; background: var(--panel);
  border: 4px solid transparent; border-image: var(--tex-panel) 8 stretch;
}
.armctl label {
  display: flex; flex-direction: column; gap: 7px; min-width: 150px;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3);
}
.armctl label.grow { flex: 1 1 220px; }
.armctl select, .armctl input[type="search"] {
  font: 13px var(--body); color: var(--ink); background: rgba(0,0,0,.45);
  border: 1px solid var(--edge-lit); padding: 8px 10px; letter-spacing: 0; text-transform: none;
}
.armctl select:focus, .armctl input:focus { outline: 1px solid var(--ore-dim); outline-offset: 1px; }
.armctl input[type="range"] { width: 100%; accent-color: var(--ore); margin: 6px 0; }
.armdepth {
  font-family: var(--mono); font-size: 13px; color: var(--ore); min-width: 118px;
  text-align: right; padding-bottom: 6px; font-variant-numeric: tabular-nums;
}
.armfoot { font-size: 13px; color: var(--ink-3); margin: 12px 0 0; max-width: 90ch; line-height: 1.55; }
.armtables { margin-bottom: 10px; }
.armthemes { margin-bottom: 8px; }
.armthemes button[aria-selected="true"] { color: var(--tint); }
.armkinds { margin: 0 0 14px; }
.armkind {
  font: inherit; color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 1px dotted var(--ink-3);
}
.armkind:hover { color: var(--ore); border-bottom-color: var(--ore-dim); }
.armsum { margin-bottom: 18px; }

.armtable tbody tr { cursor: default; }
.armtable td.wrap { white-space: normal; min-width: 280px; max-width: 460px; }
.armtable td .chip { margin-left: 4px; vertical-align: 1px; }
.armtable tr.off td { opacity: .45; }
.armdesc { font-family: var(--body); font-size: 13.5px; color: var(--ink-2); margin-top: 5px; line-height: 1.45; }
.armcost { font-size: 12px; color: var(--ember); margin-top: 4px; }
.armname { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.armitem { display: flex; align-items: center; gap: 12px; }
.armitem .qslot { width: 44px; height: 44px; }
.armitem .qslot img { width: 32px; height: 32px; }

.armset { --set: var(--tint); }
.armset .set-pc, .armset .set-lbl { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; }
.armset-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.armset-flavor { margin: 0 0 14px !important; font-style: italic; }
.armset .showcase { margin-bottom: 16px; }
.armset-tiers { display: flex; flex-direction: column; gap: 10px; }
.armset-tier { padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--tint) 45%, transparent); }
.armset-req { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 3px; }
.armset-req .chip { padding: 3px 7px; }
.armset .set-pc { color: var(--tint); }
.armset .set-bonus { font-size: 13.5px; color: var(--ink-2); }
.armset-src {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--edge-soft);
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--ink-2);
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1120px) {
  .wcard { grid-template-columns: 132px minmax(0,1fr) 210px; }
  .wc-go { display: none; }
}
@media (max-width: 900px) {
  .masthead { padding: 16px 20px 14px; gap: 16px; flex-wrap: wrap; }
  .mnav { margin-left: 0; order: 3; width: 100%; }
  .search { width: 100%; order: 4; }
  .statusbar { padding: 10px 20px; }
  .status-theme { margin-left: 0; }
  .crumbs { padding: 12px 20px 0; }
  .view { padding: 0 20px 70px; }
  .hero { padding: 30px 22px 26px; }
  .hero-split { grid-template-columns: 1fr; align-items: start; }
  .hero-figure { text-align: left; }
  .wcard { grid-template-columns: 1fr; gap: 14px; }
  .wcard:hover { transform: none; }
  .gauge-wrap { flex-wrap: wrap; }
}

/* Phones: the section links as a 2x2 grid, and the Armory tables as stacked cards so the
   odds sit beside their labels instead of behind a sideways scroll. */
@media (max-width: 640px) {
  .mnav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .mnav a { text-align: center; padding: 10px 6px; letter-spacing: .14em; }
  .view { padding: 0 16px 60px; }
  .crumbs { padding: 12px 16px 0; }
  .masthead { padding: 14px 16px 12px; }
  .hero { padding: 24px 18px 22px; }
  .bar-row { grid-template-columns: minmax(64px, 108px) minmax(0,1fr) 50px; gap: 10px; }
  .sec-head { flex-wrap: wrap; gap: 4px 16px; }

  .armctl label { flex: 1 1 100%; min-width: 0; }
  .armdepth { min-width: 0; text-align: left; padding: 0; }
  .armtable { overflow: visible; }
  .armtable table, .armtable tbody, .armtable tr, .armtable td { display: block; min-width: 0; width: auto; }
  .armtable thead { display: none; }
  .armtable tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
    padding: 14px; border-bottom: 1px solid var(--edge-soft);
  }
  .armtable tr:last-child { border-bottom: 0; }
  .armtable td { padding: 0; border: 0; text-align: left; white-space: normal; }
  .armtable td:first-child, .armtable td.notes { grid-column: 1 / -1; }
  .armtable td.wrap { min-width: 0; max-width: none; }
  .armtable td.notes:empty { display: none; }
  .armtable td[data-l]::before {
    content: attr(data-l); display: block; margin-bottom: 3px;
    font-family: var(--mono); font-size: 8.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3);
  }
  .armtable td .chip:first-child { margin-left: 0; }
  .armset-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .view > * { animation: none; }
}
