:root {
  --bg: #14161a; --panel: #1c1f26; --panel-2: #232730; --line: #2f3540;
  --text: #e6e8ec; --dim: #9aa2b1; --accent: #d9a441;
}
* { box-sizing: border-box; }
/* Several rules below target ids, which outrank the browser's built-in
   [hidden] { display: none }. Without this, the hidden attribute is ignored. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
}
header {
  position: sticky; top: 0; z-index: 10; background: var(--panel);
  border-bottom: 1px solid var(--line); padding: 12px 20px;
}
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 19px; letter-spacing: .3px; white-space: nowrap; }
h1 span { color: var(--accent); font-weight: 400; }
#q {
  flex: 1; min-width: 260px; padding: 9px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px;
}
#q:focus { outline: none; border-color: var(--accent); }
.count { color: var(--dim); font-size: 13px; white-space: nowrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
select, button {
  padding: 6px 9px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 13px;
}
select:hover, button:hover { border-color: var(--accent); cursor: pointer; }
select.on { border-color: var(--accent); color: var(--accent); }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.card {
  display: flex; gap: 11px; padding: 11px; border-radius: 9px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-left-width: 4px;
}
.card:hover { background: var(--panel-2); }
.art {
  width: 58px; height: 58px; flex: none; border-radius: 6px;
  background: #000 center/cover no-repeat; border: 1px solid var(--line);
}
.body { min-width: 0; }
.name { font-weight: 600; margin-bottom: 3px; }
.tags { color: var(--dim); font-size: 12px; margin-bottom: 5px; }
.desc { font-size: 13px; color: #c8ccd4; }
.desc b { color: var(--text); }
.kw { display: inline-block; margin: 4px 4px 0 0; padding: 1px 7px; border-radius: 10px;
      background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; color: var(--dim); }
.res { font-weight: 700; }
#more { display: block; margin: 22px auto; padding: 9px 22px; }
#empty { text-align: center; color: var(--dim); padding: 40px; }

#overlay { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; padding: 20px; z-index: 20; }
#detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  padding: 22px; max-width: 640px; width: 100%; max-height: 86vh; overflow: auto;
}
#detail h2 { margin: 0 0 4px; }
#detail .close { float: right; border: none; background: none; color: var(--dim);
                 font-size: 24px; line-height: 1; padding: 0 4px; }
#detail .close:hover { color: var(--accent); }
#detail .art { width: 96px; height: 96px; float: left; margin: 0 14px 10px 0; }
.meta { list-style: none; padding: 0; margin: 14px 0 0; clear: both; }
.meta li { padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px; }
.meta b { color: var(--dim); font-weight: 400; display: inline-block; min-width: 96px; }
.tm { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tm span { padding: 3px 8px; border-radius: 6px; background: var(--panel-2);
           border: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.tm span:hover { border-color: var(--accent); }

/* Game markup inside card text. */
.val { font-weight: 700; color: var(--text); }
.val.damage { color: #ff6b6b; }
.val.healing { color: #66bb6a; }
.var { color: var(--dim); font-size: 12px; }

/* Transmute chip lists. The nth-child threshold is CHIP_CAP + 1 in app.js --
   keep the two in step. */
.tm.collapsed span:nth-child(n+41) { display: none; }
.meta .n { color: var(--dim); font-size: 12px; }
.expand { margin-top: 6px; font-size: 12px; padding: 3px 9px; }

/* Cards / Events switch. */
.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tab { background: none; border: 1px solid transparent; color: var(--dim); padding: 5px 14px; }
.tab.on { color: var(--accent); border-color: var(--line); background: var(--panel-2); }
.tab .n { font-size: 11px; opacity: .7; }

/* Event rows: wider than cards, since they carry prose. */
.grid.events { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.event .art { width: 74px; height: 74px; }
.event .snippet { font-size: 13px; color: #c8ccd4; margin-top: 4px; }
.event .badges { color: var(--dim); font-size: 12px; }
.story {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.65; margin-top: 12px;
  max-height: 46vh; overflow: auto; padding: 12px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--line);
}

/* Event decision trees (data from dawn-dash, MIT).
   `overflow: auto` makes this a block formatting context, so without `clear` it
   sits beside the floated artwork for its whole height instead of flowing under
   it -- leaving a blank column down the left of a tall tree. */
.tree { clear: both; margin-top: 12px; max-height: 52vh; overflow: auto; padding: 12px;
        background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }
.tree li { position: relative; padding: 3px 0 3px 10px; border-left: 1px solid var(--line); }
.tree > ul > li { border-left: none; padding-left: 0; }
.tree summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.tree summary::marker { color: var(--dim); }
.node-text { font-size: 13px; color: #c8ccd4; line-height: 1.55; }
.tree .marks { margin-top: 2px; }
.tree span { display: inline-block; margin: 2px 4px 0 0; padding: 0 6px;
             border-radius: 4px; font-size: 11px; border: 1px solid var(--line); }
.tree .req { color: #ffd54f; }
.tree .eff { color: #66bb6a; }
.tree .kind { color: var(--dim); }
.tree .kind.combat { color: #ff6b6b; }
.tree .kind.loop, .tree .kind.alt { color: #8a93a5; font-style: italic; }
.credit { font-size: 11px; color: var(--dim); margin-top: 6px; }
.credit a { color: var(--accent); }
.hastree { color: var(--accent); }
/* Same reason as .tree: when an event has no decision tree this is the first
   block after the description, so it has to clear the artwork too. */
details.raw { clear: both; margin-top: 12px; }
details.raw > summary { cursor: pointer; color: var(--dim); font-size: 12px; }

/* Wider rows for the prose-carrying collections. */
.grid.events, .grid.shrines, .grid.monsters, .grid.areas { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.card.monster .art, .card.area .art, .card.event .art, .card.shrine .art { width: 74px; height: 74px; }
.card.area .art { display: none; }
.snippet { font-size: 13px; color: #c8ccd4; margin-top: 4px; }
.badges { color: var(--dim); font-size: 12px; }
.meta.glossary { margin-top: 14px; }
.meta.glossary li { font-size: 12.5px; color: #c8ccd4; }
.meta.glossary b { min-width: 0; margin-right: 6px; color: var(--accent); }
.tabs { flex-wrap: wrap; }
