/* ===========================================================================
   FFVI Pixel Remaster — Interactive 100% Guide
   Theme: deep crystal night + gold. Responsive, offline-friendly.
   =========================================================================== */
:root {
  --bg: #0a0e26;
  --bg-2: #0e1430;
  --panel: #141b42;
  --panel-2: #1a2356;
  --panel-3: #212c66;
  --border: #2c3a7e;
  --border-soft: #243069;
  --gold: #f0cf73;
  --gold-2: #e7b54b;
  --gold-dim: #b9974a;
  --text: #e9edff;
  --muted: #98a3d6;
  --muted-2: #6f7ab0;
  --wob: #5b9bd5;
  --wor: #e0746f;
  --boss: #b98ae6;
  --lore: #4fd2c2;
  --missable: #f3a64a;
  --revisit: #6ea8fe;
  --danger: #ff6f6f;
  --ok: #66d08c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .35);
  --maxw: 1180px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 150px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -5%, rgba(91, 155, 213, .16), transparent 60%),
    radial-gradient(1000px 500px at 10% 0%, rgba(185, 138, 230, .12), transparent 55%),
    radial-gradient(900px 700px at 50% 100%, rgba(240, 207, 115, .07), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, .35), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255, 255, 255, .25), transparent),
    radial-gradient(1px 1px at 85% 20%, rgba(255, 255, 255, .3), transparent),
    radial-gradient(1px 1px at 35% 80%, rgba(255, 255, 255, .2), transparent),
    radial-gradient(1.5px 1.5px at 75% 50%, rgba(255, 255, 255, .25), transparent);
  background-size: 600px 600px, 500px 500px, 700px 700px, 550px 550px, 650px 650px;
  opacity: .5;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, rgba(10, 14, 38, .96), rgba(10, 14, 38, .82));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .4);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 10px 18px; display: flex; flex-direction: column; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 40px; width: auto; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6)); }
.brand .titles { line-height: 1.1; }
.brand h1 { font-size: 1.02rem; margin: 0; letter-spacing: .5px; }
.brand .sub { font-size: .76rem; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }

/* dashboard */
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 8px 10px; position: relative; overflow: hidden;
}
.stat .lbl { font-size: .66rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.stat .num { font-size: 1.04rem; font-weight: 700; margin-top: 2px; }
.stat .num small { color: var(--muted-2); font-weight: 600; font-size: .72rem; }
.stat .bar { height: 5px; border-radius: 4px; background: #0c1130; margin-top: 6px; overflow: hidden; }
.stat .bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .35s ease; }
.stat.done { border-color: var(--ok); }
.stat.done .bar > span { background: linear-gradient(90deg, #4fae72, var(--ok)); }
.stat.overall { grid-column: span 1; }
.stat.overall .num { color: var(--gold); }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls .seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 999px; padding: 3px; }
.controls .seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: .8rem; font-weight: 600; }
.controls .seg button.active { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2a1e00; }
.search { flex: 1; min-width: 160px; }
.search input {
  width: 100%; background: var(--panel); border: 1px solid var(--border-soft); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: .85rem; outline: none;
}
.search input:focus { border-color: var(--gold-dim); }
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .8rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--gold-dim); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--muted); cursor: pointer; user-select: none; padding: 6px 10px; border: 1px solid var(--border-soft); border-radius: 999px; }
.toggle input { accent-color: var(--gold); }
.toggle.on { color: var(--text); border-color: var(--gold-dim); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 40px 18px 18px; }
.hero img.logo { height: 92px; width: auto; margin: 0 auto 8px; filter: drop-shadow(0 4px 18px rgba(0, 0, 0, .7)); }
.hero h2 { font-size: 1.7rem; margin: .2em 0 .1em; letter-spacing: 1px; }
.hero .tag { color: var(--gold); letter-spacing: 2px; text-transform: uppercase; font-size: .8rem; }
.hero p.lede { color: var(--muted); max-width: 720px; margin: 12px auto 0; }

/* ---------- Sections ---------- */
section { padding: 26px 0; }
.section-title { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.section-title h3 { font-size: 1.25rem; margin: 0; letter-spacing: .5px; }
.section-title .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.section-title .pill { font-size: .72rem; color: var(--muted); background: var(--panel); border: 1px solid var(--border-soft); padding: 3px 10px; border-radius: 999px; }

.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* golden rules */
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.rule-card { padding: 14px 16px; }
.rule-card .n { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2a1e00; font-weight: 800; font-size: .85rem; margin-bottom: 6px; }
.rule-card h4 { margin: 4px 0 6px; font-size: .98rem; }
.rule-card p { margin: 0; color: var(--muted); font-size: .88rem; }

/* world divider */
.world-divider { position: relative; border-radius: var(--radius); overflow: hidden; margin: 8px 0 18px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.world-divider img { width: 100%; height: 150px; object-fit: cover; filter: saturate(1.05); }
.world-divider .ov { position: absolute; inset: 0; display: flex; align-items: center; gap: 14px; padding: 0 22px; background: linear-gradient(90deg, rgba(8, 11, 30, .9), rgba(8, 11, 30, .45) 60%, rgba(8, 11, 30, .2)); }
.world-divider .ov h3 { font-size: 1.5rem; margin: 0; letter-spacing: 1px; }
.world-divider .ov .d { color: var(--muted); font-size: .86rem; max-width: 560px; }
.badge-world { font-size: .68rem; font-weight: 800; letter-spacing: .8px; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; }
.badge-world.WoB { background: rgba(91, 155, 213, .18); color: var(--wob); border: 1px solid rgba(91, 155, 213, .5); }
.badge-world.WoR { background: rgba(224, 116, 111, .16); color: var(--wor); border: 1px solid rgba(224, 116, 111, .5); }

/* ---------- Zone card ---------- */
.zone { margin-bottom: 16px; overflow: hidden; scroll-margin-top: 160px; }
.zone.complete { border-color: rgba(102, 208, 140, .6); }
.zone-head { position: relative; cursor: pointer; }
.zone-head .banner { width: 100%; height: 132px; object-fit: cover; opacity: .92; }
.zone-head .banner.placeholder { background: linear-gradient(135deg, var(--panel-3), var(--panel)); height: 96px; }
.zone-head .head-ov { position: absolute; inset: 0; padding: 12px 16px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(180deg, rgba(8, 11, 30, .35), rgba(8, 11, 30, .9)); }
.zone-head .top-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.zone-head .bottom-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.zone-head h3 { margin: 0; font-size: 1.12rem; text-shadow: 0 2px 8px rgba(0, 0, 0, .8); letter-spacing: .3px; }
.zone-head .znum { font-size: .72rem; color: var(--gold); font-weight: 700; }
.zone-mini { display: flex; gap: 8px; align-items: center; }
.zone-mini .mini-bar { width: 90px; height: 6px; background: #0c1130; border-radius: 4px; overflow: hidden; border: 1px solid var(--border-soft); }
.zone-mini .mini-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.zone-mini .mini-pct { font-size: .74rem; color: var(--muted); min-width: 34px; text-align: right; }
.chevron { transition: transform .25s ease; color: var(--gold); font-size: 1.1rem; }
.zone.open .chevron { transform: rotate(90deg); }

.badge { font-size: .66rem; font-weight: 800; letter-spacing: .5px; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.badge.ponr { background: rgba(255, 111, 111, .2); color: var(--danger); border: 1px solid rgba(255, 111, 111, .55); }
.badge.onetime { background: rgba(243, 166, 74, .18); color: var(--missable); border: 1px solid rgba(243, 166, 74, .5); }
.badge.veldt { background: rgba(79, 210, 194, .15); color: var(--lore); border: 1px solid rgba(79, 210, 194, .45); }

.zone-body { display: none; padding: 16px; border-top: 1px solid var(--border-soft); }
.zone.open .zone-body { display: block; }
.zone-story { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }
.zone-story .credit { display: block; font-size: .72rem; color: var(--muted-2); margin-top: 8px; }

.subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 720px) { .subgrid { grid-template-columns: 1fr; } }
.subbox { background: rgba(10, 14, 38, .5); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.subbox h5 { margin: 0 0 8px; font-size: .76rem; text-transform: uppercase; letter-spacing: .7px; color: var(--gold); display: flex; align-items: center; gap: 6px; }
.subbox .note { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.subbox .note.warn { color: var(--missable); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .76rem; padding: 3px 9px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--border-soft); color: var(--text); }
.chip.lore { background: rgba(79, 210, 194, .12); border-color: rgba(79, 210, 194, .4); color: var(--lore); }
.chip.esper { background: rgba(185, 138, 230, .12); border-color: rgba(185, 138, 230, .4); color: var(--boss); }

/* check rows */
.checkrow { display: flex; align-items: flex-start; gap: 9px; padding: 5px 0; }
label.chk { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: .86rem; }
label.chk input { display: none; }
.box { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 5px; border: 1.5px solid var(--border); background: #0c1130; position: relative; transition: all .15s ease; }
label.chk input:checked + .box { background: linear-gradient(180deg, var(--gold), var(--gold-2)); border-color: var(--gold); }
label.chk input:checked + .box::after { content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #241900; font-size: 12px; font-weight: 900; }
label.chk .ctext { flex: 1; }
label.chk input:checked ~ .ctext { color: var(--muted-2); text-decoration: line-through; text-decoration-color: var(--gold-dim); }
.checkrow .t { font-size: .58rem; font-weight: 800; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; margin-left: 4px; vertical-align: 1px; }
.lore-where { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
label.chk input:checked ~ .ctext .lore-where { color: var(--muted-2); }

/* esper info rows */
.esper-row { padding: 6px 0; border-top: 1px solid var(--border-soft); }
.esper-row:first-child { border-top: 0; padding-top: 2px; }
.esper-row strong { font-size: .85rem; color: var(--boss); }
.esper-where { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.esper-warn { display: block; color: var(--missable); font-size: .78rem; font-weight: 600; margin-top: 3px; }

/* bestiary grid */
.best-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 10px; }
.best-head h5 { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .7px; color: var(--gold); }
.best-head .mini-actions { display: flex; gap: 6px; }
.best-head .mini-actions button { font-size: .72rem; padding: 3px 9px; }
.enemies { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 14px; }
.enemy { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; border: 1px solid transparent; }
.enemy-spr { width: 30px; height: 30px; flex: none; object-fit: contain; image-rendering: pixelated; background: radial-gradient(circle at 50% 40%, #1a2356, #0c1130); border: 1px solid var(--border-soft); border-radius: 5px; padding: 1px; }
.enemy-spr.ph { opacity: .3; }

/* treasures list */
.treasures { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 3px 16px; margin-bottom: 8px; }
.treasure { display: flex; align-items: baseline; gap: 8px; padding: 4px 6px; border-radius: 8px; border: 1px solid transparent; }
.treasure:hover { background: rgba(10, 14, 38, .55); border-color: var(--border-soft); }
.treasure label.chk { flex: none; }
.treasure .tcontent { font-weight: 600; font-size: .85rem; white-space: nowrap; }
.treasure .tcontent a { color: var(--gold); }
.treasure input:checked ~ .tcontent { color: var(--muted-2); text-decoration: line-through; }
.treasure .tfind { font-size: .73rem; color: var(--muted); flex: 1; }
.treasure .tfind .troom { display: inline-block; color: var(--text); background: rgba(10, 14, 38, .8); border: 1px solid var(--border-soft); border-radius: 4px; padding: 0 6px; margin-right: 6px; font-size: .68rem; font-weight: 600; white-space: nowrap; }
.tre-notes { margin-top: 6px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: rgba(10, 14, 38, .5); }
.tre-notes summary { cursor: pointer; padding: 8px 12px; font-size: .78rem; color: var(--gold); }
.tre-notes-body { padding: 0 14px 12px; font-size: .82rem; color: var(--muted); line-height: 1.6; }
.enemy:hover { background: rgba(10, 14, 38, .55); border-color: var(--border-soft); }
.enemy.boss { background: rgba(185, 138, 230, .07); }
.enemy.miss { box-shadow: inset 3px 0 0 var(--missable); }
.enemy .pr { font-size: .68rem; color: var(--muted-2); font-variant-numeric: tabular-nums; min-width: 30px; }
.enemy .ename { flex: 1; font-size: .85rem; }
.enemy .ename a { color: inherit; }
.enemy .ename a:hover { color: var(--gold); }
.enemy label.chk input:checked ~ .ename { color: var(--muted-2); text-decoration: line-through; }
.enemy .ename .troom { display: inline-block; color: var(--text); background: rgba(10, 14, 38, .8); border: 1px solid var(--border-soft); border-radius: 4px; padding: 0 6px; margin: 0 4px; font-size: .66rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.tags { display: inline-flex; gap: 4px; margin-left: 4px; }
.tag { font-size: .58rem; font-weight: 800; padding: 1px 5px; border-radius: 4px; letter-spacing: .4px; }
.tag.boss { background: rgba(185, 138, 230, .2); color: var(--boss); }
.tag.miss { background: rgba(243, 166, 74, .2); color: var(--missable); }
.tag.lore { background: rgba(79, 210, 194, .2); color: var(--lore); }
.tag.revisit { background: rgba(110, 168, 254, .2); color: var(--revisit); }

/* ---------- Characters ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.char { padding: 0; overflow: hidden; text-align: center; }
.char .portrait { width: 100%; height: 150px; object-fit: cover; object-position: top center; background: var(--panel-3); }
.char .pad { padding: 10px; }
.char h4 { margin: 0 0 4px; font-size: .92rem; }
.char .where { font-size: .74rem; color: var(--muted); margin: 0 0 8px; min-height: 30px; }
.char.recruited { border-color: var(--ok); }
.char.recruited .portrait { filter: none; }
.char:not(.recruited) .portrait { filter: grayscale(.65) brightness(.8); }

/* ---------- Lores ---------- */
.lore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.lore-item { display: flex; gap: 9px; padding: 9px 11px; }
.lore-item .meta { flex: 1; }
.lore-item h4 { margin: 0; font-size: .9rem; }
.lore-item .where { font-size: .78rem; color: var(--muted); }
.lore-item .t { font-size: .6rem; font-weight: 800; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; align-self: flex-start; }
.t.easy { background: rgba(102, 208, 140, .18); color: var(--ok); }
.t.mid { background: rgba(240, 207, 115, .16); color: var(--gold); }
.t.hard { background: rgba(255, 111, 111, .16); color: var(--danger); }

/* ---------- Missables quick ref ---------- */
.miss-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.miss-zone { padding: 12px 14px; }
.miss-zone .mz-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.miss-zone h4 { margin: 0; font-size: .92rem; }
.miss-zone ul { margin: 6px 0 0; padding-left: 18px; }
.miss-zone li { font-size: .8rem; color: var(--muted); margin: 2px 0; }
.miss-zone li.boss { color: var(--boss); }

/* ---------- Credits & sources ---------- */
.cred-note { background: rgba(10, 14, 38, .5); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px 14px; color: var(--muted); font-size: .84rem; margin-bottom: 14px; }
.cred-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.cred { padding: 8px; text-align: center; font-size: .72rem; }
.cred img { width: 100%; height: 84px; object-fit: contain; background: #0c1130; border-radius: 6px; margin-bottom: 6px; }
.cred a { color: var(--muted); }
.cred .t { color: var(--text); display: block; margin-bottom: 2px; font-weight: 600; font-size: .74rem; }
.src-list { columns: 2; column-gap: 24px; }
@media (max-width: 640px) { .src-list { columns: 1; } }
.src-list li { margin: 0 0 8px; break-inside: avoid; font-size: .85rem; }

footer { padding: 30px 18px 60px; text-align: center; color: var(--muted-2); font-size: .78rem; border-top: 1px solid var(--border); margin-top: 20px; }

/* back to top */
#toTop { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel-2); color: var(--gold); font-size: 1.2rem; cursor: pointer; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s; }
#toTop.show { opacity: 1; pointer-events: auto; }

/* pixel sprites crisp */
.enemy-spr, img.pixel { image-rendering: pixelated; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--panel-3); border: 1px solid var(--gold-dim); color: var(--text); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s; z-index: 80; font-size: .85rem; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* hud toggle button */
.hud-toggle {
  margin-left: auto;
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, transform .25s ease;
}
.hud-toggle:hover { border-color: var(--gold-dim); }
.topbar.hud-collapsed .hud-toggle { transform: rotate(180deg); }
.topbar.hud-collapsed .dash,
.topbar.hud-collapsed .controls { display: none; }
.topbar.hud-collapsed { --scroll-pad: 60px; }

/* responsive dashboard */
@media (max-width: 900px) { .dash { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .dash { grid-template-columns: repeat(2, 1fr); } .hero img.logo { height: 64px; } .brand .sub { display: none; } }

/* hidden filter state */
.zone.hide, .enemy.hide, .char.hide, .lore-item.hide { display: none !important; }
.empty-msg { color: var(--muted); text-align: center; padding: 30px; font-style: italic; }
