:root {
  --bg: #0e1016; --panel: #161a24; --panel2: #1d2230; --line: #2a3144; --text: #dfe3ee; --mute: #8f98b0;
  --gold: #e8c26a; --gold2: #b8923a; --red: #d9625a; --blue: #5aa7e8; --green: #6fcf7a;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 Georgia, 'Times New Roman', serif; }
a { color: var(--gold); }
h1, h2, h3, h4 { font-family: Georgia, serif; color: var(--gold); line-height: 1.25; }
button, input, select, textarea { font: inherit; }

#top { position: sticky; top: 0; z-index: 20; display: flex; gap: 10px; align-items: center; padding: 10px 16px;
  background: #0b0d13ee; border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.brand { font-size: 1.25rem; font-weight: bold; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand span { color: var(--gold); }
#search { flex: 1; min-width: 80px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.btn { display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--gold2); background: var(--panel2);
  color: var(--gold); cursor: pointer; text-decoration: none; font-size: .9rem; white-space: nowrap; }
.btn:hover { background: #2a3045; }
.btn.small { padding: 3px 10px; font-size: .8rem; }
#menu-btn { display: none; background: none; border: 0; color: var(--text); font-size: 1.5rem; cursor: pointer; }

#layout { display: flex; max-width: 1400px; margin: 0 auto; }
#nav { width: 230px; flex: none; position: sticky; top: 58px; align-self: flex-start; max-height: calc(100vh - 58px); overflow: auto;
  padding: 18px 10px; border-right: 1px solid var(--line); }
#nav a { display: block; padding: 7px 12px; margin: 2px 0; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .95rem; }
#nav a:hover { background: var(--panel2); }
#nav a.active { background: var(--panel2); color: var(--gold); border-left: 3px solid var(--gold); }
#nav .group { margin: 14px 12px 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--mute); }
#main { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 80px; }
#main > h1 { margin-top: 0; font-size: 2rem; }

/* hero y relato */
.hero { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 26px; border: 1px solid var(--line); min-height: 240px; display: flex; align-items: flex-end; background: var(--panel); }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55) saturate(1.1); }
.hero .txt { position: relative; padding: 26px 30px; background: linear-gradient(transparent, #0008 40%, #000c); width: 100%; }
.hero h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.8rem); text-shadow: 0 2px 8px #000; }
.hero p { margin: 6px 0 0; font-style: italic; color: #f0e6c8; max-width: 60ch; }
.chapter { margin: 0 0 38px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.chapter .banner { position: relative; height: 200px; }
.chapter .banner img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.6); cursor: zoom-in; }
.chapter .banner h2 { position: absolute; left: 24px; bottom: 14px; margin: 0; font-size: 1.7rem; text-shadow: 0 2px 8px #000; }
.chapter h2.plain { margin: 20px 24px 0; font-size: 1.7rem; }
.chapter .body { padding: 18px 26px 22px; max-width: 72ch; }
.chapter .body p { margin: 0 0 1em; font-size: 1.08rem; }
.chapter .body p:first-child::first-letter { float: left; font-size: 3.2rem; line-height: .9; padding: 4px 8px 0 0; color: var(--gold); }
.chapter-num { color: var(--mute); font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; padding: 14px 26px 0; }
.chapter-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 22px; }
.chapter-nav a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: .85rem; text-decoration: none; color: var(--text); background: var(--panel); }
.chapter-nav a:hover { border-color: var(--gold); }
#progress { position: fixed; left: 0; top: 0; height: 3px; width: 0; background: var(--gold); z-index: 30; }

/* bloques genéricos */
.wiki-p { margin: .6em 0; max-width: 80ch; }
.wiki-h { margin: 1.6em 0 .4em; font-size: 1.2rem; }
.wiki-list { padding-left: 1.2em; max-width: 90ch; }
.wiki-list li { margin: .25em 0; }
.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel2); color: var(--gold); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.sprite-thumb { width: 160px; border-radius: 8px; border: 1px solid var(--line); margin: 6px 0; display: block; cursor: zoom-in; }

/* tarjetas interactivas */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 18px; }
.toolbar input, .toolbar select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; font-size: .85rem; }
.chip.on { border-color: var(--gold); color: var(--gold); background: var(--panel2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; text-align: left; color: inherit; padding: 0; }
.card:hover { transform: translateY(-3px); border-color: var(--gold2); }
.card .pic { height: 150px; background: #0a0c11; display: flex; align-items: center; justify-content: center; }
.card .pic img { max-width: 100%; max-height: 100%; object-fit: cover; width: 100%; height: 100%; }
.card .pic.contain img { object-fit: contain; }
.card .info { padding: 10px 12px; }
.card .info b { display: block; color: var(--text); }
.card .info small { color: var(--mute); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .72rem; background: var(--panel2); color: var(--mute); margin-right: 4px; }
.tag.boss, .tag.finalboss { background: #4a1f1f; color: #ffb4ae; }
.tag.elite { background: #46381a; color: #ffd98a; }
.rarity-common { color: #c9ced9; } .rarity-uncommon { color: #6fcf7a; } .rarity-rare { color: #5aa7e8; }
.rarity-epic { color: #c07aef; } .rarity-legendary { color: #f2a33a; }

.detail { border: 1px solid var(--gold2); background: var(--panel); border-radius: 14px; padding: 18px 22px; margin: 0 0 22px; display: grid; grid-template-columns: minmax(180px, 320px) 1fr; gap: 22px; }
.detail img { width: 100%; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.detail h3 { margin: 0 0 6px; font-size: 1.5rem; }
.detail .close { float: right; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.stats div { background: var(--panel2); border-radius: 8px; padding: 6px 10px; font-size: .85rem; color: var(--mute); }
.stats b { display: block; color: var(--text); font-size: 1.05rem; }
.spell { padding: 8px 12px; margin: 6px 0; border-left: 3px solid var(--gold2); background: var(--panel2); border-radius: 0 8px 8px 0; }
.spell small { color: var(--mute); }
details { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; background: var(--panel); }
summary { cursor: pointer; padding: 10px 14px; color: var(--gold); font-weight: bold; }
details > div { padding: 0 14px 12px; }
.empty { color: var(--mute); font-style: italic; padding: 20px 0; }

#search-results { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); width: min(720px, 94vw); max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--gold2); border-radius: 12px; z-index: 40; box-shadow: 0 12px 40px #000a; }
#search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
#search-results a:hover { background: var(--panel2); }
#search-results small { color: var(--mute); }
#lightbox { position: fixed; inset: 0; z-index: 60; background: #000d; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: zoom-out; padding: 20px; }
#lightbox[hidden], #search-results[hidden], .hidden { display: none !important; }
#lightbox img { max-width: 94vw; max-height: 84vh; border-radius: 10px; }
#lightbox p { color: #fff; margin: 10px 0 0; }

/* notas godmin */
.notes { margin-top: 44px; border: 1px dashed var(--gold2); border-radius: 12px; padding: 14px 18px; background: #1a1708; }
.notes h3 { margin: 0 0 8px; font-size: 1rem; }
.note { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: var(--panel); }
.note.hecho { opacity: .6; } .note.descartado { opacity: .4; text-decoration: line-through; }
.note p { margin: 0 0 6px; white-space: pre-wrap; }
.note .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.notes textarea { width: 100%; min-height: 70px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px; }
.login-box { display: flex; gap: 8px; flex-wrap: wrap; }
.login-box input { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--gold2); border-radius: 10px; padding: 10px 16px; z-index: 70; }

@media (max-width: 860px) {
  #menu-btn { display: block; }
  #nav { position: fixed; left: 0; top: 58px; bottom: 0; z-index: 25; background: var(--bg); transform: translateX(-100%); transition: transform .2s; max-height: none; }
  #nav.open { transform: none; }
  .detail { grid-template-columns: 1fr; }
}
.sprite-thumb-wrap { width: 160px; margin: 6px 0; } .sprite-thumb-wrap img { width: 100%; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
