:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1d1c1a; --muted: #6b6862; --line: #e4e1da;
  --accent: #2f5bd3; --accent-ink: #ffffff; --chip: #eeece6;
  --weak: #c43d2f; --resist: #4a7a3a; --null: #6b6862; --absorb: #6a45b8; --immune: #3e6e8e;
  --captured: #1f7a4a; --rebuilt: #b8701a; --missing: #c43d2f; --held: #1f7a4a;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517; --panel: #1c1e21; --ink: #e8e6e1; --muted: #9a978f; --line: #2c2f33; --chip: #262a2e;
    --accent: #7ea0ff; --accent-ink: #0e1116;
  }
}
:root[data-theme="dark"] {
  --bg: #141517; --panel: #1c1e21; --ink: #e8e6e1; --muted: #9a978f; --line: #2c2f33; --chip: #262a2e;
  --accent: #7ea0ff; --accent-ink: #0e1116;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 10px 16px;
       background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; color: var(--ink); white-space: nowrap; }
#search { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
          background: var(--bg); color: var(--ink); font: inherit; }
#theme { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
h1 { font-size: 26px; margin: 4px 0 6px; } h2 { font-size: 19px; margin: 28px 0 10px; } h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-size: 22px; } .stat span { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card a.title { font-weight: 600; color: var(--ink); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
         padding: 2px 7px; border-radius: 99px; color: #fff; vertical-align: middle; }
.badge.captured { background: var(--captured); } .badge.rebuilt { background: var(--rebuilt); }
.badge.boss { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--chip); }
.chip.weak { color: #fff; background: var(--weak); } .chip.resist { color: #fff; background: var(--resist); }
.chip.null { color: #fff; background: var(--null); } .chip.absorb { color: #fff; background: var(--absorb); }
.chip.immune { color: #fff; background: var(--immune); }
.bar { height: 6px; border-radius: 99px; background: var(--chip); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--held); }
.dungeon { margin-bottom: 14px; }
.dungeon .battles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.bt { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); min-width: 200px; color: var(--ink); }
.bt small { color: var(--muted); display: block; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tabs button { border: 0; background: none; color: var(--muted); padding: 8px 12px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.enemy { margin-bottom: 18px; }
.enemy header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.mono { font-family: var(--mono); font-size: 12px; }
.writeup { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 18px 14px; }
.writeup h2 { display: none; } .writeup h3 { margin-top: 16px; }
.writeup ul { padding-left: 18px; } .writeup li p { margin: 3px 0; } .writeup em { color: var(--muted); }
.held { color: var(--held); } .missing { color: var(--missing); }
.prov { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.results a { display: block; padding: 6px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .stat { min-width: 45%; } h1 { font-size: 22px; } }

.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 10px 0; }
.phase { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 190px; max-width: 320px; }
.phase .cond { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.phase .sub { font-size: 13px; margin-top: 4px; }
.arrow { align-self: center; color: var(--muted); font-size: 20px; }
.ai-card { margin-bottom: 14px; overflow-x: auto; }
.graph { position: relative; margin: 12px 0; }
.graph svg { position: absolute; left: 0; top: 0; overflow: visible; }
.graph svg path { fill: none; stroke: var(--muted); stroke-width: 1.5; marker-end: url(#ah); }
.graph svg marker path { fill: var(--muted); stroke: none; }
.node { position: absolute; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
        color: var(--ink); padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px; overflow: hidden; }
.node span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node.start { border-color: var(--accent); }
.node.on { outline: 2px solid var(--accent); }
.logic { margin-top: 8px; } .logic pre, details pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; background: var(--bg);
        border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.badge.realm { background: #4a5a78; }

.fl { display: flex; flex-direction: column; align-items: flex-start; gap: 0; margin: 8px 0; }
.fl-step, .fl-end, .fl-diamond { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 10px; font-size: 13px; max-width: 640px; }
.fl-end { border-radius: 99px; border-color: var(--accent); }
.fl-diamond { border-color: var(--rebuilt); background: color-mix(in srgb, var(--rebuilt) 12%, var(--panel)); font-weight: 600; }
.fl-link { width: 2px; height: 12px; background: var(--line); margin-left: 18px; }
.fl-dec { display: flex; flex-direction: column; align-items: flex-start; }
.fl-branches { display: flex; gap: 14px; margin: 8px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line); flex-wrap: wrap; }
.fl-branch { display: flex; flex-direction: column; align-items: flex-start; min-width: 160px; }
.fl-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.fl-loop { border: 1px dashed var(--line); border-radius: 10px; padding: 6px 10px; display: flex; flex-direction: column; align-items: flex-start; }
.fl-call { cursor: pointer; font-size: 12px; white-space: nowrap; }
.fl-hook { margin: 10px 0 16px; padding: 8px 10px; border-radius: 10px; }
.fl-hook.flash { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* drill-down */
.typecard { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.typecard:hover { border-color: var(--accent); text-decoration: none; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.toggle button { border: 0; background: var(--panel); color: var(--muted); padding: 6px 16px; font: inherit; cursor: pointer; }
.toggle button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.loc { margin-bottom: 12px; } .loc.focus { border-color: var(--accent); }
.loc-head { margin-bottom: 4px; }
.encs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.enc { display: block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); min-width: 200px; flex: 1 1 220px; max-width: 360px; }
.enc:hover { border-color: var(--accent); text-decoration: none; }
.enc small { display: block; color: var(--muted); }
.round { margin: 18px 0; }
.round-head { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.monsters { display: flex; flex-wrap: wrap; gap: 10px; }
.monster { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-width: 200px; color: var(--ink); }
.monster.boss { border-color: var(--accent); }
.monster:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.monster small { display: block; color: var(--muted); margin-top: 2px; }
.graph { position: relative; margin: 12px 0; display: flex; flex-direction: column; gap: 34px; }
.g-row { display: flex; flex-wrap: wrap; gap: 14px; position: relative; z-index: 1; }
.graph .node { position: static; width: 190px; min-height: 54px; }
.graph svg { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
.ai-card { overflow: visible; }
.fl-branches { flex-wrap: wrap; }
.fl-step, .fl-end, .fl-diamond { max-width: 100%; overflow-wrap: anywhere; }

.forms { margin-bottom: 14px; } .forms table { margin-top: 6px; }

.anim { margin-bottom: 12px; } .anim .sub { margin-top: 8px; }
.phase-box { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 150px; }
.small { font-size: 12px; }
.kv td { padding: 3px 8px; } .complete { margin-top: 14px; } .complete details { margin: 6px 0 0 10px; }

.player { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 12px 0 18px; }
.stagebox canvas { width: 100%; height: 440px; display: block; background: var(--bg); border-radius: 8px; }
.stagebox.sheet canvas { height: 520px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 4px; }
.controls select, .controls button { font: inherit; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
#mscrub { width: 100%; }
.evbar { position: relative; height: 16px; background: var(--chip); border-radius: 4px; margin-top: 4px; }
.evbar i { position: absolute; top: 2px; width: 3px; height: 12px; margin-left: -1px; border-radius: 1px; cursor: pointer; }
.evhead, .dhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--weak); pointer-events: none; z-index: 2; }
.dope .dwrap { position: relative; margin-left: 180px; }
.drow { position: relative; height: 15px; border-bottom: 1px solid var(--line); }
.dname { position: absolute; left: -180px; width: 176px; font: 11px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.dbars { position: absolute; inset: 0; }
.dbars i { position: absolute; top: 3px; height: 9px; border-radius: 2px; opacity: .85; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: -1px; }
.fmt p { margin: 8px 0; line-height: 1.5; } .fmt code { font: 12px var(--mono); background: var(--chip); padding: 0 3px; border-radius: 3px; }
table.parts td { vertical-align: top; }
@media (max-width: 640px) { .stagebox canvas { height: 320px; } .dope .dwrap { margin-left: 110px; } .dname { left: -110px; width: 106px; } }
#mfilter { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }

.stagebtn { font: inherit; font-size: 12px; margin-left: 8px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; }
.stageview .stagebox canvas { height: 380px; }
.stagehold:empty { display: none; }
.maphold:empty { display: none; }
.maphold { margin: 10px 0; text-align: center; } .maphold .prov { text-align: left; }
.dmap { background: var(--bg); border-radius: 10px; max-width: 100%; }

.dmapwrap { position: relative; margin: 0 auto; max-width: 100%; }
.dmapwrap .dmap { display: block; }
.dstam { position: absolute; transform: translate(-50%, -50%); min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600;
  text-align: center; background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.dstam.dexit { font-weight: 500; color: var(--muted); }
.dlabel { position: absolute; font-size: 13px; line-height: 1.25; color: var(--ink); text-decoration: none; }
.dlabel:hover { color: var(--accent); text-decoration: underline; }
.dlabel.dboss { font-weight: 600; }
