:root {
  --bg: #0c0d10; --panel: #16181d; --panel2: #1e2128; --line: #2c3039;
  --text: #e4e2dc; --muted: #9a9ea8; --crimson: #b3263a; --crimson-d: #7a1626;
  --spectral: #62b3d6; --gold: #c4a15a; --danger: #d4495c; --ok: #6cc08b;
  --nav-h: 64px; --rail-w: 190px;
}
.high-contrast { --bg: #000; --panel: #0a0a0a; --panel2: #141414; --line: #8a8a8a; --text: #fff; --muted: #d0d0d0; }
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, "Segoe UI", Roboto, sans-serif; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: .03em; margin: 0 0 .5rem; }
h1 { color: var(--gold); font-size: 2.1rem; letter-spacing: .18em; text-align: center; }
h2 { color: var(--gold); } h3 { color: var(--spectral); font-size: 1.05rem; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--gold); color: #000; padding: .5rem; z-index: 99; }
.app { min-height: 100dvh; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .warn { color: var(--gold); }
.loading { padding-top: 40vh; }

.main { padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.main.solo { padding-bottom: 2rem; padding-top: calc(1rem + env(safe-area-inset-top)); }
.screen { display: grid; gap: .9rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.title-screen { display: grid; gap: 1rem; padding-top: 1rem; }
.title-head p { text-align: center; margin: 0; }
.slots { display: grid; gap: .9rem; }
.slot h2 { margin-bottom: .25rem; }

.row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; } .row.end { justify-content: flex-end; } .row.center { justify-content: center; }
.btn { min-height: 48px; padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--gold); } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--crimson-d); border-color: var(--crimson); }
.btn-danger { border-color: var(--danger); color: #ffb3bd; }
:focus-visible { outline: 3px solid var(--spectral); outline-offset: 2px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .5rem 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.facilities { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.facilities li { display: flex; gap: .7rem; align-items: center; justify-content: space-between; padding: .6rem; background: var(--panel2); border-radius: 8px; }
.tag { border: 1px solid var(--gold); color: var(--gold); border-radius: 6px; padding: .1rem .4rem; font-size: .75rem; white-space: nowrap; }

.field { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; align-items: center; margin: .6rem 0; }
.field input[type=range] { grid-column: 1 / -1; width: 100%; height: 36px; accent-color: var(--crimson); }
.field.check { grid-template-columns: auto 1fr; } .field.check input { width: 28px; height: 28px; accent-color: var(--crimson); }

/* navegação */
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; background: none; border: 0; color: var(--muted); font: inherit; font-size: .75rem; cursor: pointer; padding: .3rem; }
.nav-btn .ico { font-size: 1.3rem; line-height: 1; }
.nav-btn.active { color: var(--gold); box-shadow: inset 0 3px 0 var(--gold); }
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line); z-index: 20; }
.sheet { position: fixed; right: .6rem; bottom: calc(var(--nav-h) + .6rem + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, 120px); gap: .3rem; z-index: 21; }
.rail { display: none; }
@media (min-width: 900px) {
  .bottombar, .sheet { display: none; }
  .rail { display: flex; flex-direction: column; gap: .2rem; position: fixed; inset: 0 auto 0 0; width: var(--rail-w); padding: 1rem .5rem; background: var(--panel); border-right: 1px solid var(--line); }
  .rail .nav-btn { flex-direction: row; justify-content: flex-start; gap: .7rem; font-size: 1rem; padding: .5rem .8rem; border-radius: 8px; }
  .rail .nav-btn.active { box-shadow: inset 3px 0 0 var(--gold); background: var(--panel2); }
  .main { margin-left: calc(var(--rail-w) + max(0px, (100vw - var(--rail-w) - 760px) / 2)); margin-right: auto; padding-bottom: 2rem; }
  .main.solo { margin: 0 auto; }
}

/* avisos e diálogos */
.toasts { position: fixed; left: 0; right: 0; top: calc(.6rem + env(safe-area-inset-top)); display: grid; gap: .4rem; justify-items: center; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; max-width: 92vw; box-shadow: 0 4px 18px #000a; }
.toast-ok { border-color: var(--ok); } .toast-error { border-color: var(--danger); color: #ffd0d6; }
.overlay { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; padding: 1rem; z-index: 40; }
.dialog { max-width: 420px; width: 100%; }
.reduce-motion * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

/* Etapa 2: personagem e inventário */
.grow { flex: 1; min-width: 0; } .col { display: grid; gap: .4rem; }
.hero { display: flex; gap: 1rem; align-items: center; }
.portrait { width: 84px; height: 84px; border-radius: 12px; display: grid; place-items: center; font-size: 3rem; color: var(--gold); background: radial-gradient(circle at 50% 30%, #1d2a36, #0c0d10); border: 1px solid var(--gold); flex: none; }
.bar { height: 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: .35rem 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--crimson-d), var(--crimson)); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; }
.tab { min-height: 48px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 10px; font: inherit; cursor: pointer; }
.tab.active { color: var(--gold); border-color: var(--gold); background: var(--panel2); }
.nodes { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.nodes li { padding: .5rem; background: var(--panel2); border-radius: 8px; display: grid; gap: .1rem; }
.nodes li.done { border-left: 3px solid var(--ok); }
.nodes li .tag { justify-self: start; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.item { display: flex; gap: .8rem; align-items: center; } .item.equipped { border-color: var(--gold); }
.diff { margin-right: .6rem; white-space: nowrap; } .diff.up { color: var(--ok); } .diff.down { color: var(--danger); }
select, input[type=search] { min-height: 48px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 0 .7rem; font: inherit; flex: 1; min-width: 160px; }
.dev { border-style: dashed; }
.facilities li.stack { flex-direction: column; align-items: stretch; }
.btn { white-space: normal; text-align: center; }

/* Etapa 3: criaturas */
.art { position: relative; display: grid; place-items: center; border-radius: 12px; border: 2px solid var(--line); background: radial-gradient(circle at 50% 35%, #232833, #0c0d10); flex: none; }
.art-sm { width: 56px; height: 56px; font-size: 1.6rem; } .art-md { width: 84px; height: 84px; font-size: 2.4rem; } .art-lg { width: 96px; height: 96px; font-size: 2.8rem; }
.art-aff, .art-rar { position: absolute; font-size: .7rem; background: #000a; border-radius: 6px; padding: 0 .2rem; }
.art-aff { right: 2px; bottom: 2px; } .art-rar { left: 2px; top: 2px; color: var(--gold); }
.aff-fire { border-color: #d46a3a; } .aff-ice { border-color: #7fd0ea; } .aff-earth { border-color: #a08455; } .aff-poison { border-color: #7fbf5f; }
.aff-death { border-color: #8a8f99; } .aff-soul { border-color: var(--spectral); } .aff-dark { border-color: #7a56b3; } .aff-light { border-color: #f0dc8c; }
.team { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.team-slot { min-height: 92px; background: var(--panel2); border: 1px dashed var(--line); border-radius: 10px; color: var(--text); display: grid; place-items: center; gap: .2rem; padding: .4rem; font: inherit; cursor: pointer; }
.wallet { display: flex; flex-wrap: wrap; gap: .3rem .9rem; color: var(--gold); }
.evo { display: flex; gap: .7rem; align-items: center; justify-content: space-between; padding: .5rem 0; border-top: 1px solid var(--line); }
.facilities li.locked { opacity: .55; }

/* Etapa 4: combate */
.row.between { justify-content: space-between; align-items: center; }
.field-battle { display: grid; gap: .8rem; }
.side h3 { margin: 0 0 .3rem; } .brow { display: grid; gap: .4rem; margin: .3rem 0; } .blabel { text-transform: uppercase; letter-spacing: .08em; }
.ucard { display: flex; gap: .6rem; align-items: center; padding: .4rem; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
.ucard.dead { opacity: .4; } .ucard.acting { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.bar.thin { height: 10px; margin: .2rem 0; }
.logbox { max-height: 220px; overflow-y: auto; background: #0a0b0e; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; font-size: .85rem; display: grid; gap: .1rem; }
.l-hit { color: var(--text); } .l-crit { color: var(--gold); font-weight: 600; } .l-heal { color: var(--ok); } .l-miss { color: var(--muted); } .l-status { color: var(--spectral); }
.l-round { color: var(--gold); border-top: 1px solid var(--line); padding-top: .2rem; margin-top: .2rem; } .l-warn { color: #ffb36b; font-weight: 600; } .l-death { color: var(--danger); } .l-act { color: #cfd3da; }
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; } .acting-panel { border-color: var(--gold); }
.formrow { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .5rem; background: var(--panel2); border-radius: 8px; }
.formrow select { min-width: 110px; flex: none; }

/* ---- Etapa 6: mapa, expedição ---- */
.tabs.two { grid-template-columns: repeat(2, 1fr); margin: .5rem 0; }
.regions { display: grid; gap: .5rem; }
.region { display: grid; gap: .2rem; text-align: left; padding: .8rem; border-radius: 10px; border: 1px solid var(--line, #3a3042); background: linear-gradient(135deg, #1b2a22, #1a1620); color: inherit; font: inherit; }
.region.locked { opacity: .55; background: #17141c; }
.item.special { border-color: #7a4bb5; }
.graph { position: relative; margin: .6rem 0; border-radius: 12px; border: 1px solid #3a3042; background: radial-gradient(ellipse at 50% 100%, #1e2a22 0%, #121018 70%); }
.graph .edges { position: absolute; inset: 0; width: 100%; height: 100%; }
.edge { stroke: #4a4256; stroke-width: 2; } .edge.done { stroke: #8a7a5a; } .edge.live { stroke: #c9a24a; stroke-dasharray: 5 4; }
.gnode { position: absolute; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%; border: 2px solid #4a4256; background: #1b1722; color: #cfc6d8; font-size: 1.25rem; display: grid; place-items: center; padding: 0; }
.gnode.k-boss { border-color: #b23a48; color: #ff7a85; } .gnode.k-elite { border-color: #a05a2c; } .gnode.k-treasure { border-color: #c9a24a; color: #e7c872; } .gnode.k-rest { border-color: #d98a2b; color: #ffb35a; } .gnode.k-event { border-color: #6b5bb5; }
.gnode.visited { opacity: .45; } .gnode.here { box-shadow: 0 0 0 3px #c9a24a66; opacity: 1; }
.gnode.can { border-color: #e7c872; box-shadow: 0 0 10px #e7c87299; animation: pulse 1.6s infinite; cursor: pointer; }
.reduce-motion .gnode.can { animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 18px #e7c872; } }
.legend { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .5rem; }
.logbox.short { max-height: 8rem; } .btn.block { display: block; width: 100%; margin: .35rem 0; }
.warn { color: #ffb35a; }

/* ---- arte final (opcional) ---- */
.art-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.art .art-img { position: absolute; inset: 0; }
.fac-icon, .item-icon { width: 48px; height: 48px; flex: none; border-radius: 8px; object-fit: cover; }
.nav-img { width: 26px; height: 26px; object-fit: contain; }
.node-img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.boss-img { width: 100%; max-height: 220px; object-fit: cover; object-position: top; border-radius: 10px; margin-bottom: .5rem; }
.portrait .art-img { position: static; }

/* layout com arte: linhas com ícone não podem estourar a largura no celular */
.facilities li.fac { flex-wrap: wrap; }
.facilities li.fac .grow { flex: 1 1 10rem; min-width: 0; }
.facilities li.fac .col { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: flex-start; }
.item .grow { min-width: 0; }
.fort-banner { width: 100%; height: 150px; object-fit: cover; object-position: center 30%; border-radius: 10px; margin-bottom: .6rem; display: block; }
.title-logo { width: min(92%, 420px); margin: 0 auto .4rem; display: block; mix-blend-mode: screen; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.abil-img { width: 28px; height: 28px; border-radius: 50%; vertical-align: middle; margin-right: .4rem; }
.world-map-img { width: 100%; max-height: 260px; object-fit: cover; object-position: center; border-radius: 10px; margin-bottom: .5rem; display: block; }
.title-screen { min-height: 100dvh; background-attachment: fixed; }
