:root {
  --bg: #0b1020;
  --ink: #eaf2ff;
  --muted: #9fb2d8;
  --accent: #5ad1ff;
  --panel: rgba(14, 22, 44, 0.92);
  --line: rgba(120, 160, 255, 0.18);
  --porto: #2a9d8f;
  --avenida: #f4a23a;
  --torre: #6c8cff;
  --praca: #e86a92;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#cena {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 30%, #16204a, #070a16);
  transition: opacity .6s ease;
}
#loader.hidden { opacity: 0; pointer-events: none; }
.loader-box { text-align: center; padding: 1rem; }
.loader-emoji { font-size: 64px; animation: float 2.4s ease-in-out infinite; }
.loader-box h1 { font-size: 28px; margin: 8px 0; letter-spacing: .5px; }
.loader-box p { color: var(--muted); margin-bottom: 18px; }
.loader-bar { width: min(240px, 80vw); height: 6px; border-radius: 6px; background: rgba(255,255,255,.1); margin: 0 auto; overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 40%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #a96bff);
  animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  pointer-events: none;
  max-width: 92vw;
}
.hud-title { font-size: 20px; font-weight: 700; text-shadow: 0 2px 18px #000; }
.hud-sub { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.hud-badges { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.hud-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 3px 8px; border-radius: 999px; text-transform: uppercase;
}
.hud-badge.usp { background: #003366; color: #ffcc00; border: 1px solid #ffcc00; }
.hud-badge.poli { background: rgba(90,209,255,.15); color: var(--accent); border: 1px solid rgba(90,209,255,.35); }
.hud-progress { margin-top: 8px; max-width: 220px; margin-left: auto; margin-right: auto; }
.hud-progress-bar {
  height: 5px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden;
}
.hud-progress-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #ffcc00, #5ad1ff);
  transition: width .4s ease;
}
.hud-progress-text { font-size: 10px; color: var(--muted); margin-top: 4px; display: block; }

#link-site {
  position: fixed; top: calc(12px + var(--safe-top)); left: 12px; z-index: 21;
  font-size: 12px; font-weight: 600; color: var(--ink); text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; backdrop-filter: blur(8px);
}
#link-site:hover { border-color: var(--accent); color: var(--accent); }

#minimapa {
  position: fixed; bottom: calc(16px + var(--safe-bottom)); left: 12px; z-index: 14;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px; backdrop-filter: blur(8px); cursor: pointer;
  transition: border-color .2s ease;
}
#minimapa:hover, #minimapa:focus { border-color: #ffcc00; outline: none; }
.minimapa-titulo { font-size: 10px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
#minimapa-canvas { display: block; border-radius: 8px; background: rgba(0,0,0,.25); }
#minimapa-legenda { font-size: 9px; color: var(--muted); margin-top: 4px; }

#btn-passaporte {
  position: fixed; bottom: calc(16px + var(--safe-bottom)); right: 12px; z-index: 14;
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); font-size: 22px; cursor: pointer;
  backdrop-filter: blur(8px); touch-action: manipulation;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
#btn-passaporte:hover { border-color: #ffcc00; transform: scale(1.05); }

#passaporte {
  position: fixed; bottom: calc(72px + var(--safe-bottom)); right: 12px; z-index: 20;
  width: min(360px, 94vw); max-height: min(78vh, calc(100dvh - 100px));
  background: var(--panel); border: 1px solid #ffcc00;
  border-radius: 14px; padding: 16px; backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column; overflow: hidden;
}
#passaporte h3 { font-size: 15px; margin-bottom: 4px; flex-shrink: 0; }
.passaporte-resumo-linha { font-size: 11px; color: var(--muted); margin-bottom: 8px; line-height: 1.4; flex-shrink: 0; }
.passaporte-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-bottom: 10px; flex-shrink: 0;
}
.pass-stat {
  text-align: center; background: rgba(255,255,255,.04);
  border-radius: 8px; padding: 6px 4px; border: 1px solid var(--line);
}
.pass-stat-val { display: block; font-size: 14px; font-weight: 700; color: #ffcc00; }
.pass-stat-lbl { display: block; font-size: 9px; color: var(--muted); margin-top: 2px; }
.passaporte-abas {
  display: flex; gap: 4px; margin-bottom: 8px; flex-shrink: 0;
}
.passaporte-aba {
  flex: 1; padding: 7px 4px; font-size: 10px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 8px; background: transparent;
  color: var(--muted); cursor: pointer;
}
.passaporte-aba.ativa { background: rgba(255,204,0,.12); border-color: #ffcc00; color: var(--ink); }
.passaporte-conteudo { flex: 1; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.passaporte-painel.hidden { display: none; }
.chk-dica { font-size: 10px; color: var(--muted); margin-bottom: 8px; line-height: 1.4; }
.chk-secao { font-size: 11px; font-weight: 700; margin: 12px 0 6px; color: var(--accent); }
.chk-secao:first-child { margin-top: 0; }
.checklist { list-style: none; font-size: 12px; }
.chk-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.06);
}
.chk-status {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
  border: 2px solid var(--chk-cor, var(--line)); background: rgba(255,255,255,.04);
  font-size: 14px; cursor: pointer; display: grid; place-items: center;
  transition: transform .15s ease;
}
.chk-status:hover { transform: scale(1.08); }
.chk-status.marcado { border-color: #4ade80; background: rgba(74,222,128,.12); }
.chk-corpo { flex: 1; min-width: 0; }
.chk-titulo { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.chk-nome { font-size: 12px; line-height: 1.35; font-weight: 600; }
.chk-sub { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.chk-badge-cidade { font-size: 10px; }
.chk-badge-cidade.off { opacity: .5; }
.chk-ir {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--accent); background: rgba(90,209,255,.1);
  color: var(--accent); font-weight: 700; cursor: pointer; font-size: 14px;
}
.chk-link { font-size: 10px; color: var(--accent); display: inline-block; margin-top: 4px; }
.chk-orientador-box { font-size: 11px; line-height: 1.5; color: var(--muted); }
.chk-orientador { color: var(--ink); margin-bottom: 4px; }
.chk-orientador-sub { font-size: 10px; }
.passaporte-selos-wrap {
  margin-top: 10px; flex-shrink: 0; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 8px;
}
.passaporte-selos-wrap summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.passaporte-selos-wrap ul { margin-top: 6px; }
#passaporte p { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
#passaporte ul { list-style: none; font-size: 12px; }
#passaporte li { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
#passaporte-fechar {
  position: absolute; top: 8px; right: 8px; background: none; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer; width: 36px; height: 36px;
}

#boas-vindas {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(4, 8, 18, 0.82); backdrop-filter: blur(6px);
  padding: 20px;
}
.bv-card {
  max-width: 420px; background: var(--panel); border: 1px solid #ffcc00;
  border-radius: 18px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.bv-card h2 { font-size: 1.25rem; margin-bottom: 12px; }
.bv-card p { font-size: 14px; color: var(--muted); line-height: 1.55; margin-bottom: 14px; }
.bv-lista { font-size: 13px; color: var(--ink); margin-bottom: 18px; padding-left: 0; list-style: none; }
.bv-lista li { margin-bottom: 8px; }
.bv-btn {
  width: 100%; padding: 12px; border: none; border-radius: 12px; font-weight: 700;
  font-size: 14px; cursor: pointer; color: #07101f;
  background: linear-gradient(90deg, #ffcc00, #5ad1ff);
}

.painel-busca-wrap { margin-bottom: 12px; padding-right: 48px; }
#painel-busca {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.05);
  color: var(--ink); font-size: 14px;
}
#painel-busca::placeholder { color: var(--muted); }
#painel-busca:focus { outline: none; border-color: var(--accent); }

.card.lido { border-color: rgba(255, 204, 0, 0.35); }
.card.lido::after {
  content: '✓'; position: absolute; top: 10px; right: 12px;
  color: #ffcc00; font-weight: 700; font-size: 14px;
}
.card { position: relative; }

#dica {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0,0,0,.35);
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  max-width: 94vw;
  text-align: center;
}

#btn-voltar {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 12px;
  z-index: 22;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform .15s, background .15s;
  touch-action: manipulation;
}
#btn-voltar:hover { background: rgba(40,60,120,.95); transform: translateX(-2px); }

/* ---------- Painel do distrito ---------- */
#painel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 18;
  width: min(420px, 100vw);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(12px);
  padding: calc(26px + var(--safe-top)) 22px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(0);
  transition: transform .4s cubic-bezier(.2,.8,.2,1);
  pointer-events: auto;
}
#painel.hidden {
  transform: translateX(105%);
  pointer-events: none;
}
#painel-fechar {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 18px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}
#painel-fechar:hover { color: var(--ink); background: rgba(255,80,80,.15); }
#painel-cabecalho { padding-right: 48px; }
#painel-cabecalho h2 { font-size: 22px; margin-bottom: 4px; line-height: 1.25; }
#painel-cabecalho .codigo { font-size: 12px; color: var(--accent); letter-spacing: 1px; }
#painel-cabecalho .desc { font-size: 13px; color: var(--muted); margin: 10px 0 18px; line-height: 1.5; }
#painel-cabecalho .barra { height: 4px; border-radius: 4px; margin-bottom: 20px; }
.lote-paragrafo {
  font-size: 14px; line-height: 1.55; color: var(--ink); margin: 0 0 14px;
  padding: 12px 14px; background: rgba(255,255,255,.04); border-radius: 10px;
  border-left: 3px solid var(--accent);
}
.lote-link {
  display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600;
  color: var(--accent); text-decoration: none;
}
.lote-link:hover { text-decoration: underline; }

.card {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
  touch-action: manipulation;
}
.card:hover, .card:active { transform: translateY(-2px); border-color: var(--accent); background: rgba(90,209,255,.08); }
.card .tag { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.card h3 { font-size: 15px; margin: 4px 0 6px; line-height: 1.3; }
.card .npc-mini { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---------- Diálogo NPC ---------- */
#dialogo {
  position: fixed;
  top: 50%;
  left: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  z-index: 25;
  width: min(680px, calc(100vw - 32px));
  max-height: min(82vh, 600px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 20px 22px 16px;
  box-shadow: 0 18px 60px rgba(0,0,0,.5);
  backdrop-filter: blur(12px);
  animation: pop .25s ease;
  pointer-events: auto;
}
body.painel-aberto #dialogo {
  left: calc((100% - min(420px, 100vw)) / 2);
  width: min(680px, calc(100% - min(420px, 100vw) - 32px));
}
#dialogo.hidden { display: none; }
@keyframes pop {
  from { transform: translate(-50%, calc(-50% + 18px)); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}
.dialogo-fechar {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,.06);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 16px;
  cursor: pointer;
  transition: background .15s, color .15s;
  touch-action: manipulation;
  z-index: 2;
}
.dialogo-fechar:hover { background: rgba(255,80,80,.18); color: #ff8a8a; }
.dialogo-npc { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding-right: 40px; }
.dialogo-avatar { font-size: 26px; flex-shrink: 0; }
.dialogo-nome { font-weight: 700; color: var(--accent); }
.dialogo-titulo { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.dialogo-texto { font-size: 17px; line-height: 1.55; min-height: 48px; }
.dialogo-ganchos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dialogo-ganchos span {
  font-size: 11px;
  background: rgba(90,209,255,.12);
  color: var(--accent);
  border: 1px solid rgba(90,209,255,.3);
  padding: 3px 9px;
  border-radius: 999px;
}
.dialogo-rodape {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.dialogo-progresso { font-size: 12px; color: var(--muted); margin-right: auto; }
.dialogo-prox {
  background: linear-gradient(90deg, var(--accent), #a96bff);
  color: #07101f;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .12s;
  touch-action: manipulation;
  flex-shrink: 0;
}
.dialogo-prox:hover { transform: scale(1.04); }
.dialogo-voltar {
  background: rgba(255,255,255,.05);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  touch-action: manipulation;
  flex-shrink: 0;
}
.dialogo-voltar:hover { background: rgba(120,160,255,.16); color: var(--ink); }
.dialogo-voltar.invisivel { visibility: hidden; pointer-events: none; }

.dialogo-pdf {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  color: #07101f;
  background: linear-gradient(90deg, #5ad1ff, #1DB954);
  padding: 12px 16px;
  min-height: 44px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(90, 209, 255, .25);
  transition: transform .12s, box-shadow .2s;
  touch-action: manipulation;
}
.dialogo-pdf:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(29, 185, 84, .35); }
.dialogo-pdf.hidden { display: none; }
.dialogo-pdf.indisponivel {
  background: rgba(255,255,255,.08);
  color: var(--muted);
  box-shadow: none;
  pointer-events: none;
  cursor: default;
}

/* ---------- Alternador de modo ---------- */
#modos {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  z-index: 22;
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  backdrop-filter: blur(8px);
}
.modo-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
  touch-action: manipulation;
}
.modo-btn:hover { color: var(--ink); }
.modo-btn.ativo { background: rgba(90,209,255,.16); color: var(--accent); }

/* ---------- Modo caminhar ---------- */
#mira {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  color: rgba(255,255,255,.7);
  font-size: 26px;
  font-weight: 300;
  pointer-events: none;
  text-shadow: 0 0 6px #000;
}
#walk-dica {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  font-size: 12px;
  color: var(--ink);
  background: rgba(0,0,0,.5);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  backdrop-filter: blur(6px);
  max-width: 94vw;
  text-align: center;
}
#walk-dica b { color: var(--accent); }

/* ---------- Controles touch (mobile) ---------- */
#touch-controls {
  position: fixed;
  bottom: calc(88px + var(--safe-bottom));
  left: 16px;
  z-index: 15;
  display: none;
  grid-template-columns: 44px 44px 44px;
  grid-template-rows: 44px 44px 44px;
  gap: 6px;
  pointer-events: none;
}
#touch-controls.visivel { display: grid; }
.touch-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 22, 44, .82);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.touch-btn:active { background: rgba(90,209,255,.25); border-color: var(--accent); }
.touch-btn[data-dir="up"] { grid-column: 2; grid-row: 1; }
.touch-btn[data-dir="left"] { grid-column: 1; grid-row: 2; }
.touch-btn[data-dir="down"] { grid-column: 2; grid-row: 3; }
.touch-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }

/* ---------- Toast de chegada ---------- */
#toast {
  position: fixed;
  top: calc(64px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--accent);
  padding: 10px 16px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: toastIn .35s ease;
  max-width: 92vw;
  text-align: center;
  line-height: 1.4;
}
#toast b { color: var(--accent); }
@keyframes toastIn {
  from { transform: translate(-50%, -10px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.hidden { display: none !important; }

/* Esconder chrome 3D quando painel ou chat estão ativos */
body.painel-aberto #modos,
body.painel-aberto #hud,
body.painel-aberto #toast,
body.painel-aberto #minimapa,
body.painel-aberto #btn-passaporte,
body.painel-aberto #link-site,
body.painel-aberto #passaporte:not(.hidden),
body.dialogo-aberto #modos,
body.dialogo-aberto #hud,
body.dialogo-aberto #toast,
body.dialogo-aberto #minimapa,
body.dialogo-aberto #btn-passaporte,
body.dialogo-aberto #link-site,
body.dialogo-aberto #passaporte:not(.hidden) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.dialogo-aberto #painel {
  visibility: hidden;
  pointer-events: none;
}

body.dialogo-aberto #btn-voltar {
  display: none !important;
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .hud-title { font-size: 16px; }
  .hud-sub { font-size: 11px; display: none; }
  .hud-badges { margin-bottom: 2px; }
  .hud-progress { max-width: 160px; margin-top: 4px; }
  #hud { top: calc(56px + var(--safe-top)); }
  #modos { top: calc(8px + var(--safe-top)); right: 8px; }
  #link-site { top: calc(8px + var(--safe-top)); left: 8px; font-size: 11px; padding: 6px 10px; }
  #minimapa { bottom: calc(78px + var(--safe-bottom)); left: 8px; padding: 6px 8px; }
  #minimapa-canvas { width: 88px; height: 88px; }
  #btn-passaporte { bottom: calc(78px + var(--safe-bottom)); right: 8px; width: 42px; height: 42px; font-size: 18px; }
  #passaporte { bottom: calc(130px + var(--safe-bottom)); right: 8px; left: 8px; width: auto; max-height: min(70vh, calc(100dvh - 140px)); }

  /* Painel em tela cheia acima de qualquer controle */
  body.painel-aberto #painel {
    z-index: 26;
    width: 100vw;
    border-left: none;
    padding-top: calc(54px + var(--safe-top));
  }

  body.painel-aberto #btn-voltar {
    display: block !important;
    top: calc(10px + var(--safe-top));
    bottom: auto;
    left: 10px;
    z-index: 30;
    font-size: 12px;
    padding: 8px 12px;
    min-height: 40px;
  }

  body.painel-aberto #painel-fechar {
    z-index: 2;
  }

  body.painel-aberto #modos,
  body.painel-aberto #hud,
  body.dialogo-aberto #modos,
  body.dialogo-aberto #hud,
  body.painel-aberto #minimapa,
  body.dialogo-aberto #minimapa,
  body.painel-aberto #link-site,
  body.dialogo-aberto #link-site,
  body.painel-aberto #btn-passaporte,
  body.dialogo-aberto #btn-passaporte {
    display: none !important;
  }

  body.painel-aberto #touch-controls,
  body.dialogo-aberto #touch-controls {
    display: none !important;
  }

  #btn-voltar {
    top: auto;
    bottom: calc(12px + var(--safe-bottom));
    left: 8px;
    font-size: 12px;
    padding: 10px 12px;
  }

  #dica { font-size: 11px; padding: 6px 10px; bottom: calc(12px + var(--safe-bottom)); }

  /* Chat em folha inferior — não compete com painel atrás */
  body.dialogo-aberto #painel {
    transform: translateX(105%);
  }

  body.dialogo-aberto::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 18, 0.78);
    z-index: 27;
    pointer-events: auto;
  }

  #dialogo {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: min(88dvh, calc(100dvh - 24px));
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(16px + var(--safe-bottom));
    z-index: 28;
    animation: slideUpDialogo .3s ease;
  }

  body.dialogo-aberto #dialogo {
    top: auto;
    left: 0;
    transform: none;
    width: 100%;
  }

  @keyframes slideUpDialogo {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  @keyframes pop {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .dialogo-texto { font-size: 15px; }
  .dialogo-rodape { justify-content: center; }
  .dialogo-progresso { width: 100%; text-align: center; margin: 0; order: -1; }
  #painel { width: 100vw; border-left: none; }
  #walk-dica { bottom: calc(100px + var(--safe-bottom)); font-size: 11px; }
  body.dialogo-aberto #walk-dica,
  body.dialogo-aberto #dica { display: none; }
  body.painel-aberto #dica { display: none; }
}

@media (max-height: 500px) and (orientation: landscape) {
  #hud { display: none; }
  #dialogo { max-height: min(90vh, calc(100dvh - 24px)); }
  #touch-controls { bottom: calc(12px + var(--safe-bottom)); }
}
