:root {
  --bg: #111418;
  --panel: #1a1f25;
  --panel-2: #222932;
  --line: #2e3742;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --accent: #f2c14e;
  --link: #7cc4ff;
  --tier-low: #9aa4b1;
  --tier-mid: #59b36b;
  --tier-high: #b07cf2;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 52px; flex-shrink: 0; }
header nav { display: flex; flex-shrink: 0; }
header h1 { flex-shrink: 0; }
header h1 { font-size: 18px; margin: 0; color: var(--accent); letter-spacing: .5px; }
nav button { background: none; border: 0; color: var(--muted); font: inherit; padding: 6px 10px; cursor: pointer; border-radius: 6px; }
nav button.active, nav button:hover { color: var(--text); background: var(--panel-2); }
#meta { margin-left: auto; color: var(--muted); font-size: 12px; }
main { flex: 1; min-height: 0; }
.view { display: none; height: 100%; }
.view.active { display: grid; grid-template-columns: 260px minmax(0, 1fr) 320px; }
#view-tables.view.active { grid-template-columns: 260px minmax(0, 1fr); }
#view-research.view.active { grid-template-columns: 280px minmax(0, 1fr); }
.panel { background: var(--panel); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.panel:last-child { border-right: 0; border-left: 1px solid var(--line); }
.panel, .content, .grid { min-width: 0; min-height: 0; overflow-wrap: anywhere; }
.panel label { display: block; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.panel select, .panel input:not([type=checkbox]) { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: inherit; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 10px; padding: 6px 10px; }
.panel fieldset label, fieldset label { display: flex; gap: 6px; align-items: center; margin: 4px 0; color: var(--text); font-size: 13px; }
legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
h2 { font-size: 17px; margin: 0 0 8px; }
.hint { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.list li:hover, .list li.sel { background: var(--panel-2); }
.list li small { margin-left: auto; color: var(--muted); }
#type-list small, .list li small, td.count { white-space: nowrap; flex-shrink: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
#map { height: 100%; background: #0b0d10; }
#map-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#map-summary { position: absolute; top: 12px; right: 12px; z-index: 500; max-width: calc(100% - 70px); padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #1a1f25ed; font-size: 12px; box-shadow: 0 2px 12px #0005; }
#map-status { position: absolute; inset: 0; z-index: 600; display: grid; place-content: center; text-align: center; gap: 10px; padding: 24px; background: #111418e8; }
#map-status[hidden], #map-summary[hidden] { display: none; }
#map-status .btn { justify-self: center; }
#upcoming { height: 100%; }
.leaflet-container { background: #0b0d10; }
.loc-label { color: #ffe27a; font-size: 11px; font-weight: 600; text-shadow: 0 0 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; }
.tag { display: inline-block; padding: 1px 6px; margin: 2px 2px 0 0; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11.5px; color: var(--text); }
.tag.muted { color: var(--muted); }
.conf { font-size: 11px; color: var(--muted); }
a, .link { color: var(--link); cursor: pointer; text-decoration: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; padding: 12px; overflow-y: auto; align-content: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; cursor: pointer; font-size: 12px; }
.card:hover, .card.sel { border-color: var(--accent); }
.card { color: var(--text); font-family: inherit; }
.card.sel { background: #302b1d; box-shadow: inset 0 0 0 1px var(--accent); }
.card img, .icon-lg { width: 72px; height: 72px; object-fit: contain; display: block; margin: 0 auto 6px; }
.icon-lg { width: 128px; height: 128px; }
.card .noicon { width: 72px; height: 72px; margin: 0 auto 6px; border-radius: 6px; background: var(--panel-2); }
.tier-Low { border-bottom: 3px solid var(--tier-low); }
.tier-Mid { border-bottom: 3px solid var(--tier-mid); }
.tier-High { border-bottom: 3px solid var(--tier-high); }
.itemrow { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.itemrow img { width: 28px; height: 28px; object-fit: contain; }
.itemrow .ph { width: 28px; height: 28px; background: var(--panel-2); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.content { padding: 16px 20px; overflow-y: auto; }
button.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
button.btn:hover { border-color: var(--accent); }
#item-filter-chip { background: #3a2f10; border: 1px solid var(--accent); border-radius: 6px; padding: 6px 8px; margin-bottom: 10px; font-size: 12px; }
#map-scope { border: 1px solid var(--accent); border-radius: 6px; padding: 8px; margin-bottom: 10px; font-size: 12px; }
#map-scope .btn { display: block; margin-top: 6px; }
#cal-warning { background: #3b1c1c; border: 1px solid #a54848; border-radius: 6px; padding: 6px 8px; margin-bottom: 10px; font-size: 12px; }
#calibrator { position: fixed; right: 360px; bottom: 16px; width: 340px; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 12px; z-index: 1000; }
#calibrator input[type=range] { width: 100%; }
#calibrator textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font: 11px monospace; }

#upcoming { grid-column: 2; }
#map[hidden], #upcoming[hidden] { display: none; }
select:disabled { opacity: .5; }
#cal-warning.subtle { background: none; border: 0; padding: 0; color: var(--muted); }
#calibrator label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
#calibrator select { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.loc-label.exit { color: #8ce99a; font-weight: 500; }
.loc-label.district { color: #d0ebff; font-size: 15px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; opacity: .9;
  text-shadow: 0 0 4px #000, 0 0 8px #000; }
.loc-label.district span { display: inline-block; transform: translate(-50%, -50%); }
#type-filter label { font-size: 12.5px; }
#type-filter legend a { font-size: 11px; }
.tier-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tier-dot.tier-Low { background: var(--tier-low); border: 0; }
.tier-dot.tier-Mid { background: var(--tier-mid); border: 0; }
.tier-dot.tier-High { background: var(--tier-high); border: 0; }
details summary { cursor: pointer; margin: 10px 0 4px; }
.loc-label.clickable { pointer-events: auto; cursor: pointer; }
.loc-label.clickable:hover, .loc-label.sel { text-decoration: underline; color: #fff; }
.loc-label.district.clickable:hover span, .loc-label.district.sel span { color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.filters .mini { flex: 1 1 45%; min-width: 0; padding: 4px 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12px; }
.filters input.mini { flex-basis: 100%; }
.itemrow.sel { background: var(--panel-2); border-radius: 6px; }
.focus { border: 1px solid var(--accent); border-radius: 8px; padding: 8px; margin: 6px 0 10px; background: #1f1c12; }

/* rarity (decoded QualityLevel) */
:root { --r-common: #b0b8c1; --r-uncommon: #51cf66; --r-rare: #4dabf7; --r-epic: #cc5de8; --r-legendary: #ff922b; }
.rarity { font-size: 10.5px; padding: 0 5px; border-radius: 4px; border: 1px solid currentColor; flex: none; }
.r-Common { color: var(--r-common); } .r-Uncommon { color: var(--r-uncommon); } .r-Rare { color: var(--r-rare); }
.r-Epic { color: var(--r-epic); } .r-Legendary { color: var(--r-legendary); }
.card.r-border-Common { border-bottom: 3px solid var(--r-common); } .card.r-border-Uncommon { border-bottom: 3px solid var(--r-uncommon); }
.card.r-border-Rare { border-bottom: 3px solid var(--r-rare); } .card.r-border-Epic { border-bottom: 3px solid var(--r-epic); }
.card.r-border-Legendary { border-bottom: 3px solid var(--r-legendary); }
.filters input[type=number].mini { flex-basis: 45%; }

/* area weight multipliers (decoded value pools) */
.wt { font-size: 10.5px; padding: 0 4px; border-radius: 4px; background: #2a2f36; color: #aab; flex: none; margin-left: 4px; }
.wt.up { background: #1f3b26; color: #7ee08f; } .wt.down { background: #3b2a1f; color: #f0a870; } .wt.off { background: #3b1f1f; color: #f08080; }
.pool { border-left: 2px solid #3a4250; padding: 4px 0 6px 8px; margin: 6px 0; }
.pool .off { opacity: .4; }
.pool .rules { margin-top: 4px; font-size: 12px; color: #aab; }

/* Navigation and feedback */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, input, select { accent-color: var(--accent); }
.reset { width: 100%; margin-bottom: 10px; }
.search-results { margin: -4px 0 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.search-results button { display: block; width: 100%; text-align: left; padding: 9px; color: var(--text); background: var(--panel-2); border: 0; border-bottom: 1px solid var(--line); font: inherit; cursor: pointer; }
.search-results button:hover { background: #303b49; }
.search-results button small { display: block; color: var(--muted); }
.search-results p { padding: 0 10px; }
.empty-state { grid-column: 1 / -1; align-self: start; padding: 30px 20px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); }
#app-status { position: fixed; inset: 52px 0 0; z-index: 1500; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
#notice { position: fixed; z-index: 2000; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 10px 16px; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); max-width: calc(100% - 32px); }
#notice input { display: block; width: 100%; margin-top: 8px; }
.mobile-tools { display: none; }
#copy-link { white-space: nowrap; margin-left: auto; }
#meta { white-space: nowrap; }
#table-detail > table { min-width: 620px; }
@media (max-width: 1200px) { #meta { font-size: 11px; } }
@media (max-width: 1050px) { #meta { display: none; } }
@media (max-width: 900px) {
  header { gap: 8px; padding: 8px 10px; }
  header h1 { font-size: 16px; }
  nav button { font-size: 12px; padding: 7px; }
  #copy-link { font-size: 12px; padding: 6px 8px; }
  .mobile-tools { display: flex; gap: 6px; padding: 7px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-shrink: 0; }
  .mobile-tools button { flex: 1; }
  .mobile-tools button.active { border-color: var(--accent); color: var(--accent); }
  .view.active, #view-tables.view.active, #view-research.view.active { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .view.active > .panel, body[data-mobile-panel="filters"] .view.active > :not(:first-child), body[data-mobile-panel="detail"] .view.active > :not(:last-child) { display: none; }
  body[data-mobile-panel="filters"] .view.active > .panel:first-child, body[data-mobile-panel="detail"] .view.active > .panel:last-child { display: block; }
  .panel { border: 0; padding: 16px; }
  .panel:last-child { border: 0; }
  .panel select, .panel input:not([type=checkbox]) { padding: 10px; font-size: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); }
  #calibrator { right: 16px; left: 16px; width: auto; max-height: 80dvh; overflow: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

.evidence-badges, .button-row, .spot-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.evidence-badge { display: inline-block; padding: 3px 8px; border: 1px solid #427764; border-radius: 5px; color: #9cdbc0; font-size: 12px; margin: 3px 5px 3px 0; }
.evidence-badge.unknown { color: #edd099; border-color: #786137; }
.evidence-section, .rule-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 12px 0; background: var(--panel); }
.rule-card { background: var(--panel-2); }
.rule-card b { display: block; }
#rare-main { max-width: 1200px; }
#rare-main code, #detail code { font-size: 11px; overflow-wrap: anywhere; }
.primary { border-color: var(--accent) !important; }
#rare-message { color: var(--accent); }
@media (max-width: 600px) {
  header { flex-wrap: wrap; }
  header nav { order: 3; width: 100%; justify-content: space-between; }
  header nav button { flex: 1; }
}

/* Container category filter (grouped, with icons and expandable sub-types) */
#type-filter { margin: 0 0 12px; }
.tf-head { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 2px; font-size: 12px; }
.tf-head h3 { margin: 0; flex: 1; }
.tf-group { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.link-btn { background: none; border: 0; padding: 2px; color: var(--link); font: inherit; font-size: 12px; text-transform: none; letter-spacing: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.tf-row { display: flex; align-items: stretch; gap: 2px; }
.tf-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 6px; background: none; border: 0; border-radius: 6px; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.tf-toggle:hover, .tf-more:hover { background: var(--panel-2); }
.tf-toggle span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-toggle small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.type-icon { flex: none; vertical-align: middle; }
.tf-row.off .tf-toggle { color: var(--muted); }
.tf-row.off .type-icon { opacity: .35; filter: grayscale(1); }
.tf-more { width: 26px; flex: none; background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 12px; }
.tf-subs { margin: 0 0 6px 21px; padding-left: 10px; border-left: 1px solid var(--line); }
.panel .tf-subs label { display: flex; align-items: center; gap: 6px; margin: 3px 0; color: var(--text); font-size: 12px; }
.tf-subs label span { flex: 1; min-width: 0; }
.tf-subs small { color: var(--muted); font-variant-numeric: tabular-nums; }
.tf-subs input:disabled + span { color: var(--muted); }

/* Loot areas corner panel (replaces area pins on the map) */
#area-panel { position: absolute; right: 12px; bottom: 12px; z-index: 500; width: 260px; max-width: calc(100% - 24px); max-height: min(440px, 48%);
  display: flex; flex-direction: column; background: #1a1f25f2; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 12px #0006; }
#area-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
#area-toggle small { color: var(--muted); font-weight: 400; margin-left: auto; }
#area-toggle .caret::after { content: '▾'; color: var(--muted); }
#area-toggle[aria-expanded="false"] .caret::after { content: '▴'; }
#area-body { min-height: 0; overflow-y: auto; padding: 0 6px 6px; border-top: 1px solid var(--line); }
#area-body .conf { margin: 6px 4px 0; }
#area-list .area-group { cursor: default; margin-top: 6px; padding: 4px 4px 2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
#area-list .area-group:hover { background: none; }
#area-list .area-row { padding: 0; gap: 0; font-size: 12.5px; cursor: default; }
#area-list .area-row:hover { background: none; }
#area-list .area-row.off { opacity: .45; }
#area-list .area-row.sel { background: #302b1d; box-shadow: inset 0 0 0 1px var(--accent); }
#area-list .area-row.member { margin-left: 16px; border-left: 1px solid var(--line); border-radius: 0 6px 6px 0; }
.area-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 6px; background: none; border: 0; border-radius: 6px; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.area-main:hover, .area-caret:hover { background: var(--panel-2); }
.area-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-main small { color: var(--muted); font-variant-numeric: tabular-nums; }
.area-mult { flex: none; padding: 0 5px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 10.5px; }
.area-caret { width: 24px; flex: none; background: none; border: 0; border-radius: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.area-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c); box-shadow: 0 0 0 1.5px #111, 0 0 0 2.5px var(--c); }
.area-group .area-dot { width: 8px; height: 8px; box-shadow: none; }

/* Spot hover tooltips and selected-spot title */
.leaflet-container.spot-hover { cursor: pointer; }
.leaflet-tooltip { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: 0 2px 10px #0008; }
.leaflet-tooltip-top::before { border-top-color: var(--line); }
.leaflet-tooltip.spot-tip { font: 12px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; padding: 5px 8px; }
.tip-title { display: flex; align-items: center; gap: 6px; }
.tip-hit { color: var(--accent); margin-top: 2px; }
.spot-title { display: flex; align-items: center; gap: 8px; }

/* Item search summary ("where to find") */
#item-summary .summary-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
#item-summary .summary-head img, #item-summary .summary-head .ph { width: 48px; height: 48px; object-fit: contain; flex: none; border-radius: 6px; }
#item-summary .summary-head .ph { background: var(--panel-2); }
#item-summary .summary-head h2 { margin: 0 0 2px; }
.found-row, .place-row { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; margin: 0 0 4px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.found-row:hover, .place-row:hover, .place-row:focus-visible { border-color: var(--accent); }
.found-name, .place-name { flex: 1; min-width: 0; }
.found-name small, .place-name small { display: block; color: var(--muted); font-size: 11px; }
.found-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.found-row .bar { position: absolute; left: 0; bottom: 0; height: 2px; width: var(--w); background: var(--c); }
.found-row.off { opacity: .55; }
.found-row.off .type-icon { filter: grayscale(1); }
.place-types { display: flex; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.place-types span { display: inline-flex; align-items: center; gap: 2px; }
@media (max-width: 900px) {
  #area-panel { width: auto; left: 12px; max-height: 45%; }
}
/* Item search: condition comparisons keep evidence counts distinct from odds. */
.condition-comparison { margin: 20px 0 12px; border-top: 1px solid #39404b; padding-top: 14px; }
.condition-comparison summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.condition-rows { display: grid; gap: 5px; }
.condition-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 10px; text-align: left; color: inherit; background: transparent; border: 1px solid #39404b; border-radius: 6px; cursor: pointer; font: inherit; }
.condition-row:hover, .condition-row[aria-pressed="true"] { background: #2e3032; border-color: #f2c14e; }
.condition-row:focus-visible { outline: 2px solid #f2c14e; outline-offset: 2px; }
.condition-row small { display: block; margin-top: 4px; color: #aeb5bf; font-size: 11px; }
.condition-row strong { flex-shrink: 0; max-width: 105px; font-size: 12px; text-align: right; }
