:root {
  --bg: #0c1511;
  --bg2: #111e18;
  --card: #15251d;
  --card2: #1b3026;
  --line: #2a4436;
  --text: #e8efe9;
  --muted: #9db3a6;
  --gold: #e3c15a;
  --gold2: #b8932f;
  --green: #4fbf7a;
  --child: #7fd49b;
  --adult: #7fb2ff;
  --extra: #e3a95a;
  --danger: #e2645a;
  --radius: 14px;
  --sidebar: 300px;
  --top: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background-image: radial-gradient(1200px 600px at 80% -10%, #1d3a2b 0%, transparent 60%);
  background-attachment: fixed;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
b { color: #fff; }
h1, h2, h3 { font-family: Cinzel, Georgia, serif; letter-spacing: .02em; line-height: 1.2; }
button { font: inherit; color: inherit; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: calc(var(--top) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; gap: 10px;
  background: rgba(10, 18, 14, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--gold); font-family: Cinzel, serif; font-weight: 800; white-space: nowrap; }
.brand small { color: var(--muted); font-weight: 600; font-size: .75em; }
.brand:hover { text-decoration: none; }
.iconbtn { width: 44px; height: 44px; border: 0; background: transparent; font-size: 22px; border-radius: 10px; cursor: pointer; flex: none; }
.iconbtn:hover { background: var(--card); }
.topprog { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.topprog .bar { width: 120px; }
.bar { height: 8px; background: #0a120e; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .3s; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - var(--top)); }
.sidebar {
  width: var(--sidebar); flex: none; border-right: 1px solid var(--line); background: var(--bg2);
  position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); height: calc(100vh - var(--top) - env(safe-area-inset-top));
  overflow-y: auto; padding: 10px 8px 40px; -webkit-overflow-scrolling: touch;
}
main { flex: 1; min-width: 0; padding: 20px clamp(16px, 3vw, 40px) 80px; max-width: 980px; outline: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; z-index: 40; transform: translateX(-105%); transition: transform .25s; box-shadow: 0 0 40px #000a; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  body.navopen .sidebar { transform: none; }
  body.navopen .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: #0008; }
  .topprog .bar { width: 70px; }
}
@media (min-width: 901px) { #menuBtn { display: none; } }
@media (max-width: 480px) { .brand small, .topprog .bar { display: none; } }

/* Sidebar nav */
.navsec { margin: 14px 8px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.navlink { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text); min-height: 44px; }
.navlink:hover { background: var(--card); text-decoration: none; }
.navlink.active { background: var(--card2); box-shadow: inset 3px 0 0 var(--gold); }
.navlink .lbl { flex: 1; font-size: 14.5px; line-height: 1.25; }
.navlink .mini { font-size: 11px; color: var(--muted); }
.navlink.done .lbl { color: var(--muted); text-decoration: line-through; text-decoration-color: #4fbf7a88; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid currentColor; }
.dot.child { color: var(--child); } .dot.adult { color: var(--adult); } .dot.extra { color: var(--extra); }
.navlink.done .dot { background: currentColor; }
.navlink .here { font-size: 13px; }

/* Cards & common */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border-radius: 12px; border: 1px solid var(--gold2); background: linear-gradient(180deg, #e3c15a, #b8932f); color: #1a1405;
  font-weight: 700; cursor: pointer; text-decoration: none !important;
}
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--card2); }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.muted { color: var(--muted); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; border: 1px solid currentColor; }
.tag.child { color: var(--child); } .tag.adult { color: var(--adult); } .tag.extra { color: var(--extra); }
.tag.dungeon { color: var(--gold); }

/* Home */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin-bottom: 18px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 38px); color: var(--gold); }
.ring { width: 120px; height: 120px; }
.ring text { font: 700 22px Inter, sans-serif; fill: var(--text); }
.continue { display: flex; gap: 14px; align-items: center; margin: 16px 0; border-color: var(--gold2); background: linear-gradient(135deg, #1f3a2b, #15251d); }
.continue img { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; background: #0a120e; }
.continue .info { flex: 1; min-width: 0; }
.continue h3 { margin: 2px 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0 24px; }
.stat { padding: 12px; display: block; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--gold2); }
.stat .n { font-size: 22px; font-weight: 700; color: var(--gold); }
.stat .l { font-size: 13px; color: var(--muted); }
.stat .bar { margin-top: 6px; height: 6px; }
.chgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.chcard { padding: 0; overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.chcard:hover { text-decoration: none; border-color: var(--gold2); }
.chcard .thumb { height: 110px; background: #0a120e center/cover no-repeat; position: relative; }
.chcard .thumb .tag { position: absolute; top: 8px; left: 8px; background: #000a; }
.chcard .body { padding: 10px 12px 12px; }
.chcard .body b { display: block; font-size: 15px; }
.chcard .bar { margin-top: 8px; height: 6px; }
.chcard.isdone { opacity: .7; }
.part-h { margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
.notice { font-size: 14px; color: var(--muted); border-left: 3px solid var(--gold2); padding: 6px 12px; margin: 14px 0; background: #ffffff06; border-radius: 0 8px 8px 0; }

/* Chapter page */
.chhead { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); min-height: 200px; display: flex; align-items: flex-end; background: #0a120e; }
.chhead img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.chhead.contain img { object-fit: contain; opacity: .8; background: radial-gradient(circle, #23412f, #0a120e); }
.chhead .over { position: relative; width: 100%; padding: 18px; background: linear-gradient(0deg, #0c1511f0, #0c151100); }
.chhead h1 { margin: 6px 0 4px; font-size: clamp(24px, 4vw, 34px); color: #fff; text-shadow: 0 2px 8px #000; }
.chhead .crumbs { font-size: 13px; color: var(--muted); }
.intro { font-size: 16.5px; margin: 16px 0; }
.actions { margin: 12px 0 18px; }
.videobox { margin: 14px 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #000; aspect-ratio: 16 / 9; }
.videobox iframe { width: 100%; height: 100%; border: 0; display: block; }
.sec { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.sec h2 { margin: 0; font-size: 21px; color: var(--gold); }
.sec .cnt { font-size: 13px; color: var(--muted); }
.sec .sp { flex: 1; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.check {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 12px 12px 10px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line); cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; position: relative;
}
.check:hover { border-color: #3d6150; }
.check .box {
  width: 28px; height: 28px; flex: none; border-radius: 8px; border: 2px solid #557a66; display: grid; place-items: center;
  font-size: 18px; color: transparent; margin-top: 1px; transition: .15s;
}
.check .num { font-size: 12px; color: var(--muted); font-weight: 700; min-width: 20px; padding-top: 5px; text-align: right; }
.check .txt { flex: 1; min-width: 0; }
.check .txt .sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.check.on { background: #13241b; border-color: #2c5a40; }
.check.on .box { background: var(--green); border-color: var(--green); color: #062010; }
.check.on .txt { color: var(--muted); }
.check.on .txt b { color: var(--muted); }
.check.bm { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.pin { border: 0; background: transparent; font-size: 18px; width: 40px; height: 40px; margin: -6px -6px -6px 0; border-radius: 10px; cursor: pointer; opacity: .35; flex: none; }
.pin:hover { background: var(--card2); opacity: .8; }
.check.bm .pin { opacity: 1; }
.agebadge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; border: 1px solid; margin-left: 6px; white-space: nowrap; }
.agebadge.C { color: var(--child); } .agebadge.A { color: var(--adult); } .agebadge.CA { color: var(--extra); }
.catlabel { font-size: 12px; color: var(--gold); font-weight: 700; margin-right: 6px; }

.fights { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.fight { display: flex; flex-direction: column; gap: 8px; }
.fight.boss { border-color: #6b4a1a; background: linear-gradient(160deg, #2b2312, var(--card)); }
.fight .top { display: flex; gap: 12px; align-items: center; }
.fight img { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; background: #0a120e; flex: none; }
.fight h3 { margin: 0; font-size: 17px; }
.fight .tip { font-size: 14.5px; }
.secrets { margin: 0; padding-left: 20px; }
.secrets li { margin: 8px 0; }
textarea.notes { width: 100%; min-height: 110px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: inherit; resize: vertical; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; }
.pager a { flex: 1; max-width: 48%; }
.pager .next { text-align: right; margin-left: auto; }
.pager small { display: block; color: var(--muted); }

/* Collectibles */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 10px 0 14px; -webkit-overflow-scrolling: touch; }
.tabs a { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); color: var(--text); font-size: 14px; white-space: nowrap; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.tabs a.active { background: var(--gold); color: #1a1405; border-color: var(--gold); font-weight: 700; }
.tabs a:hover { text-decoration: none; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters select, .filters input[type=search], .field input {
  min-height: 42px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font: inherit;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; min-height: 42px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--green); }
.grouph { margin: 18px 0 8px; font-size: 15px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.grouph a { font-weight: 600; }

/* Search */
dialog#searchDlg { width: min(720px, 94vw); max-height: 80vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg2); color: var(--text); padding: 12px; }
dialog::backdrop { background: #000b; }
.searchbox { display: flex; gap: 8px; }
.searchbox input { flex: 1; min-height: 46px; font: inherit; font-size: 17px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.searchresults { margin-top: 10px; overflow-y: auto; max-height: 62vh; display: grid; gap: 6px; }
.searchresults a { display: block; padding: 10px 12px; border-radius: 10px; background: var(--card); color: var(--text); }
.searchresults a:hover { text-decoration: none; border: 1px solid var(--gold2); }
.searchresults small { color: var(--gold); display: block; font-size: 12px; }
mark { background: #e3c15a55; color: #fff; border-radius: 3px; }

/* Settings */
.field { display: grid; gap: 6px; margin: 12px 0; }
.field input { width: 100%; }
.settings .card { margin-bottom: 14px; }
.settings h2 { font-size: 19px; margin: 0 0 8px; color: var(--gold); }
code { background: #0a120e; padding: 1px 6px; border-radius: 6px; font-size: .92em; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px); background: var(--card2); border: 1px solid var(--gold2); padding: 10px 18px; border-radius: 99px; z-index: 60; transition: transform .25s; font-size: 14px; max-width: 92vw; text-align: center; }
.toast.show { transform: translateX(-50%); }
img.broken { visibility: hidden; }

/* Fotos do walkthrough por passo, mapas e visualizador */
.photos {
  display: inline-flex; align-items: center; gap: 4px; margin: 8px 0 0; padding: 5px 10px; border-radius: 99px; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--gold); background: var(--card2); border: 1px solid var(--line); cursor: pointer;
}
.photos.open { border-color: var(--gold); }
.strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.shot { flex: none; width: 200px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0a120e; cursor: zoom-in; scroll-snap-align: start; text-align: left; color: var(--muted); font: inherit; }
.shot img { display: block; width: 100%; aspect-ratio: 5 / 3; object-fit: cover; }
.shot span { display: block; font-size: 12px; padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check.on .shot img { opacity: .75; }
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.mapthumb { padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #0a120e; cursor: zoom-in; }
.mapthumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; image-rendering: pixelated; }
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(4, 8, 6, .97); display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { width: min(100vw - 32px, 960px); height: auto; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 8px; }
.lightbox figcaption { color: var(--muted); font-size: 14px; text-align: center; }
.lbx, .lbnav { position: absolute; border: 0; background: rgba(255, 255, 255, .08); color: #fff; border-radius: 99px; cursor: pointer; font-size: 26px; width: 48px; height: 48px; }
.lbx { top: max(12px, env(safe-area-inset-top)); right: 12px; font-size: 20px; }
.lbnav { top: 50%; transform: translateY(-50%); }
.lbnav.prev { left: 10px; } .lbnav.next { right: 10px; }
