/* ============================================================
   VIDA E MINISTÉRIO — RPG 2D  ·  style.css
   ============================================================ */

:root {
  --fundo:        #10141b;
  --painel:       #1a212c;
  --painel-2:     #212a38;
  --borda:        #2e3a4c;
  --texto:        #e6ecf3;
  --texto-fraco:  #9aa8ba;
  --destaque:     #ffd166;
  --azul:         #5aa0e0;
  --verde:        #6fc48a;
  --roxo:         #a98ad6;
  --laranja:      #e8975a;
  --vermelho:     #e07a7a;
  --raio:         10px;
  --topo-h:       58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fundo);
  color: var(--texto);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  display: flex; flex-direction: column;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------------- TOPO ---------------- */
#topo {
  display: flex; align-items: center; gap: 18px;
  padding: 9px 14px;
  background: linear-gradient(180deg, #1d2634, #161d27);
  border-bottom: 1px solid var(--borda);
  flex: 0 0 auto;
}

.bloco-id { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(160deg, #3d6ea5, #2b4d76);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  border: 2px solid #4e7cb0; flex: 0 0 auto;
}
.nome { font-weight: 700; letter-spacing: .2px; }
.privilegio { font-size: 12px; color: var(--destaque); }

.bloco-tempo { min-width: 210px; }
.data { font-size: 13px; color: var(--texto-fraco); }
.nivel-linha { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-top: 3px; }
.nivel-linha span { white-space: nowrap; font-weight: 600; }

.bloco-energia { min-width: 155px; }
.bloco-energia .rotulo { font-size: 11px; color: var(--texto-fraco); text-transform: uppercase; letter-spacing: .5px; }
.bloco-energia .valor { font-size: 11px; color: var(--texto-fraco); margin-top: 2px; }

.bloco-botoes { margin-left: auto; display: flex; gap: 7px; align-items: center; }

.status-save {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 20px; border: 1px solid var(--borda);
  color: var(--texto-fraco); white-space: nowrap;
}
.status-save.ok { color: var(--verde); border-color: rgba(111,196,138,.4); }
.status-save.erro { color: var(--vermelho); border-color: rgba(224,122,122,.5); background: rgba(224,122,122,.10); }
.status-save.piscar { animation: pisca .9s ease; }
@keyframes pisca { 0% { background: rgba(111,196,138,.28); } 100% { background: transparent; } }

.barra {
  height: 9px; background: #0d1219; border-radius: 6px;
  overflow: hidden; border: 1px solid #26303e; flex: 1;
}
.barra.fina { height: 6px; }
.barra > div { height: 100%; width: 0%; transition: width .35s ease; border-radius: 6px; }

#hudNivelBarra { background: linear-gradient(90deg, #7a5cc4, #a98ad6); }
.energia { background: linear-gradient(90deg, #d8a33f, #ffd166); }
.c-conhecimento { background: linear-gradient(90deg, #3d78b8, #5aa0e0); }
.c-fe           { background: linear-gradient(90deg, #7a5cc4, #a98ad6); }
.c-ministerio   { background: linear-gradient(90deg, #3f9a63, #6fc48a); }
.c-ensino       { background: linear-gradient(90deg, #c1712f, #e8975a); }

/* ---------------- OBJETIVO ---------------- */
#objetivo {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 14px;
  background: #151d27;
  border-bottom: 1px solid var(--borda);
  flex: 0 0 auto;
}
#objetivo.guia { background: linear-gradient(90deg, rgba(255,209,102,.13), rgba(255,209,102,.03)); }
#objetivo .marca {
  flex: 0 0 auto; min-width: 38px; text-align: center;
  font-size: 11px; font-weight: 700;
  padding: 3px 7px; border-radius: 20px;
  background: #26303f; color: var(--texto-fraco);
}
#objetivo.guia .marca { background: var(--destaque); color: #20242c; }
.obj-texto { min-width: 0; flex: 1; }
.obj-titulo { font-weight: 600; font-size: 13px; }
#objetivo.guia .obj-titulo { color: var(--destaque); }
.obj-dica { font-size: 11.5px; color: var(--texto-fraco); }
.obj-local {
  flex: 0 0 auto; font-size: 11px; color: var(--texto-fraco);
  padding: 3px 9px; border: 1px solid var(--borda); border-radius: 20px;
}

/* ---------------- CORPO ---------------- */
#corpo { display: flex; flex: 1 1 auto; min-height: 0; }

#palco { position: relative; flex: 1 1 auto; min-width: 0; touch-action: none; }
#tela { display: block; width: 100%; height: 100%; touch-action: none; }

#dicaTeclas {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(12,16,22,.78);
  border: 1px solid var(--borda);
  padding: 5px 11px; border-radius: 20px;
  font-size: 11.5px; color: var(--texto-fraco);
  pointer-events: none;
}
#dicaTeclas b { color: var(--destaque); }
body.com-toque #dicaTeclas { display: none; }

/* ---------------- CONTROLES DE TOQUE ---------------- */
#toque {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
}
#toque[hidden] { display: none; }

.dpad {
  position: absolute; left: 16px; bottom: 16px;
  width: 152px; height: 152px;
  pointer-events: auto;
}
.dpad-centro {
  position: absolute; left: 51px; top: 51px;
  width: 50px; height: 50px; border-radius: 12px;
  background: rgba(20,26,34,.45); border: 1px solid rgba(255,255,255,.10);
}
.tq {
  position: absolute;
  background: rgba(26,33,44,.80);
  border: 1px solid rgba(255,255,255,.18);
  color: #dfe7f0;
  font-size: 19px; line-height: 1;
  display: grid; place-items: center;
  border-radius: 13px;
  padding: 0;
  touch-action: none;
  user-select: none;
  backdrop-filter: blur(4px);
  box-shadow: 0 3px 12px rgba(0,0,0,.4);
}
.tq.pressionado { background: rgba(70,120,175,.92); border-color: #7fc4ff; transform: scale(.94); }
.tq-cima  { left: 51px; top: 0;    width: 50px; height: 52px; }
.tq-baixo { left: 51px; bottom: 0; width: 50px; height: 52px; }
.tq-esq   { left: 0;    top: 51px; width: 52px; height: 50px; }
.tq-dir   { right: 0;   top: 51px; width: 52px; height: 50px; }

.acoes {
  position: absolute; right: 18px; bottom: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  pointer-events: auto;
}
.tq-acao {
  position: relative;
  width: 82px; height: 82px; border-radius: 50%;
  font-size: 26px;
  background: rgba(47,95,143,.88);
  border-color: #6ba7dd;
}
.tq-menu {
  position: relative;
  width: 50px; height: 50px; border-radius: 14px;
  font-size: 18px;
}

/* ---------------- LATERAL ---------------- */
#lateral {
  flex: 0 0 306px;
  background: var(--painel);
  border-left: 1px solid var(--borda);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cartao {
  background: var(--painel-2);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 11px 12px;
}
.cartao.cresce { flex: 1 1 auto; min-height: 150px; display: flex; flex-direction: column; }
.cartao h3 {
  margin: 0 0 9px;
  font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--texto-fraco); font-weight: 700;
}

.atributo { position: relative; margin-bottom: 9px; font-size: 12px; }
.atributo span { color: var(--texto-fraco); display: block; padding-right: 46px; }
.atributo .barra { margin-top: 3px; }
.atributo b {
  position: absolute; right: 0; top: 0;
  color: var(--texto); font-variant-numeric: tabular-nums;
}

.priv-nome { font-weight: 700; margin-bottom: 2px; }
.priv-desc { font-size: 11.5px; color: var(--texto-fraco); margin-bottom: 8px; }
.req { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; padding: 2px 0; }
.req span { min-width: 0; }
.req.ok { color: var(--verde); }
.req.falta { color: var(--texto-fraco); }
.req b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.vazio { font-size: 11.5px; color: var(--texto-fraco); margin: 0 0 6px; }
.nota { grid-column: 1/-1; font-size: 11px; color: var(--texto-fraco); margin-top: 6px; line-height: 1.35; }

/* trilhas paralelas de progresso */
.trilha-rotulo {
  font-size: 10px; letter-spacing: .7px; text-transform: uppercase;
  color: var(--azul); font-weight: 700; margin-bottom: 3px;
}
.separador { height: 1px; background: var(--borda); margin: 11px 0 9px; }

/* aviso de campanha especial */
.campanha {
  grid-column: 1/-1;
  background: rgba(255,209,102,.12);
  border: 1px solid rgba(255,209,102,.4);
  color: var(--destaque);
  border-radius: 8px; padding: 6px 9px;
  font-size: 11px; line-height: 1.35; margin-bottom: 2px;
}

.grade-num { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.num { background: #18202b; border: 1px solid var(--borda); border-radius: 8px; padding: 6px 8px; }
.num .k { font-size: 10.5px; color: var(--texto-fraco); text-transform: uppercase; letter-spacing: .4px; }
.num .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

#diario { overflow-y: auto; flex: 1; font-size: 12px; padding-right: 4px; }
.entrada { padding: 5px 0 5px 9px; border-left: 2px solid var(--borda); margin-bottom: 3px; }
.entrada .quando { font-size: 10px; color: #6f7d90; text-transform: uppercase; letter-spacing: .4px; }
.entrada.bom    { border-left-color: var(--verde); }
.entrada.otimo  { border-left-color: var(--destaque); background: rgba(255,209,102,.06); }
.entrada.ruim   { border-left-color: var(--vermelho); }
.entrada.info   { border-left-color: #3d5069; }

/* ---------------- BOTÕES ---------------- */
button {
  font: inherit; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--borda);
  background: #26303f; color: var(--texto);
  padding: 8px 14px;
  transition: background .15s, border-color .15s, transform .06s;
}
button:hover:not(:disabled) { background: #303d50; border-color: #46596f; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .42; cursor: not-allowed; }
button.mini { padding: 5px 11px; font-size: 12px; }
button.principal { background: linear-gradient(180deg, #3f7cb8, #2f5f8f); border-color: #4f8ec9; font-weight: 600; }
button.principal:hover:not(:disabled) { background: linear-gradient(180deg, #4a8bc9, #35699c); }

.campo {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--borda); background: #141b25; color: var(--texto);
  font: inherit;
}
.rotulo-campo { display: block; font-size: 12px; color: var(--texto-fraco); margin-bottom: 4px; }
.caixa-codigo {
  width: 100%; min-height: 90px; margin-top: 6px;
  border-radius: 8px; border: 1px solid var(--borda);
  background: #141b25; color: var(--texto-fraco);
  font: 11px/1.4 ui-monospace, Menlo, Consolas, monospace;
  padding: 8px; resize: vertical; word-break: break-all;
}

/* ---------------- MODAL ---------------- */
#modal {
  position: fixed; inset: 0;
  background: rgba(6,9,14,.74);
  display: grid; place-items: center;
  z-index: 50; padding: 20px;
  backdrop-filter: blur(3px);
}
#modal.oculto { display: none; }

#janela {
  width: min(720px, 100%);
  max-height: 88vh;
  background: var(--painel);
  border: 1px solid var(--borda);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: sobe .18s ease;
}
@keyframes sobe { from { opacity: 0; transform: translateY(10px); } }

#janela > header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 15px 18px;
  background: linear-gradient(180deg, #222d3d, #1b232f);
  border-bottom: 1px solid var(--borda);
  flex: 0 0 auto;
}
#mTitulo { margin: 0; font-size: 17px; }
#mSub { margin: 3px 0 0; font-size: 12.5px; color: var(--texto-fraco); }
#mFalar { margin-left: auto; background: transparent; border: none; font-size: 16px; color: var(--texto-fraco); padding: 2px 6px; line-height: 1; }
#mFalar:hover { background: transparent; transform: scale(1.15); }
#mFalar[hidden] { display: none; }
#mFechar { background: transparent; border: none; font-size: 17px; color: var(--texto-fraco); padding: 2px 6px; }
#mFechar:hover { color: #fff; background: transparent; }
/* quando o botão de voz está oculto, o X volta a empurrar para a direita */
#mFalar[hidden] + #mFechar { margin-left: auto; }

/* botão de narração no topo */
button.voz { font-size: 14px; padding: 4px 9px; line-height: 1; }
button.voz.ligado {
  background: rgba(111,196,138,.16);
  border-color: rgba(111,196,138,.55);
}

#mCorpo { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#mCorpo p { margin: 0 0 10px; }
#mCorpo code {
  background: #141b25; border: 1px solid var(--borda); border-radius: 4px;
  padding: 1px 5px; font-size: 12px;
}
#mCorpo .verso {
  background: #16202c; border-left: 3px solid var(--azul);
  padding: 9px 12px; border-radius: 0 8px 8px 0; margin: 10px 0;
  font-style: italic;
}
#mCorpo .verso .ref { display: block; font-style: normal; font-size: 11.5px; color: var(--azul); margin-top: 5px; font-weight: 600; }
#mCorpo .fala {
  background: #202a37; border-radius: 10px; padding: 10px 13px; margin: 10px 0;
  border: 1px solid var(--borda);
}
#mCorpo .fala .quem { font-size: 11px; color: var(--destaque); font-weight: 700; margin-bottom: 3px; }
#mCorpo .aviso { color: var(--laranja); font-size: 12.5px; }
#mCorpo .secao-reuniao {
  font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--destaque); font-weight: 700; margin: 14px 0 6px;
  border-bottom: 1px solid var(--borda); padding-bottom: 4px;
}
#mCorpo .parte { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; color: var(--texto-fraco); }
#mCorpo .parte.ativa { color: var(--texto); font-weight: 600; }
#mCorpo .parte .min { font-variant-numeric: tabular-nums; }

.medidores { display: flex; gap: 14px; margin: 4px 0 14px; }
.medidor { flex: 1; }
.medidor .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--texto-fraco); margin-bottom: 3px; }
.medidor .barra { height: 11px; }
#barInteresse { background: linear-gradient(90deg, #3f9a63, #6fc48a); }
#barPaciencia { background: linear-gradient(90deg, #b8863a, #e8b45a); }

#mOpcoes {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--borda);
  background: #161d27;
  display: flex; flex-direction: column; gap: 7px;
  flex: 0 0 auto;
  max-height: 46vh; overflow-y: auto;
}
.opcao { text-align: left; width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 10px 13px; }
.opcao .t { font-weight: 600; }
.opcao .d { font-size: 11.5px; color: var(--texto-fraco); }
.opcao .custo { font-size: 11px; color: var(--destaque); }
#mOpcoes.linha { flex-direction: row; flex-wrap: wrap; }
#mOpcoes.linha button { flex: 1 1 auto; text-align: center; min-width: 120px; }

/* ---------------- TOASTS ---------------- */
#toasts {
  position: fixed; top: 110px; right: 320px;
  display: flex; flex-direction: column; gap: 7px;
  z-index: 60; pointer-events: none; align-items: flex-end;
}
.toast {
  background: #232e3d; border: 1px solid var(--borda);
  border-left: 3px solid var(--azul);
  padding: 8px 14px; border-radius: 8px;
  font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.45);
  animation: entra .22s ease; max-width: 70vw;
}
.toast.bom   { border-left-color: var(--verde); }
.toast.otimo { border-left-color: var(--destaque); }
.toast.ruim  { border-left-color: var(--vermelho); }
@keyframes entra { from { opacity: 0; transform: translateX(16px); } }

/* ============================================================
   TELAS MÉDIAS — painel lateral vira faixa inferior
   ============================================================ */
@media (max-width: 1000px) {
  #corpo { flex-direction: column; }
  #palco { flex: 1 1 auto; min-height: 0; }
  #lateral {
    flex: 0 0 auto; max-height: 34vh;
    border-left: none; border-top: 1px solid var(--borda);
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
  }
  #lateral .cartao { flex: 0 0 260px; overflow-y: auto; }
  #lateral .cartao.cresce { flex: 0 0 300px; }
  #toasts { right: 14px; top: 100px; }
}

/* ============================================================
   CELULAR
   ============================================================ */
@media (max-width: 700px) {
  #topo { gap: 10px; padding: 7px 10px; }
  .bloco-id { min-width: 0; flex: 1 1 auto; }
  .id-texto { min-width: 0; }
  .nome, .privilegio { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
  .bloco-tempo { display: none; }
  .bloco-energia { min-width: 96px; flex: 0 0 auto; }
  .bloco-energia .rotulo { display: none; }
  .bloco-botoes { gap: 5px; }
  #btnSalvar { display: none; }        /* salva sozinho; ? explica */
  button.voz { padding: 4px 7px; }     /* narração continua visível no celular */
  .status-save { font-size: 9.5px; padding: 2px 6px; }

  #objetivo { padding: 5px 10px; gap: 8px; }
  .obj-local { display: none; }
  .obj-dica { display: none; }
  .obj-titulo { font-size: 12.5px; line-height: 1.3; }
  #objetivo .marca { min-width: 32px; font-size: 10px; padding: 2px 5px; }
  /* a dica aparece, mas no máximo em 2 linhas para não comer a tela */
  #objetivo.guia .obj-dica {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; font-size: 10.5px; line-height: 1.35;
  }

  /* controles um pouco menores e mais discretos no celular */
  .dpad { width: 138px; height: 138px; }
  .dpad-centro { left: 46px; top: 46px; width: 46px; height: 46px; }
  .tq-cima  { left: 46px; width: 46px; height: 47px; }
  .tq-baixo { left: 46px; width: 46px; height: 47px; }
  .tq-esq   { top: 46px; width: 47px; height: 46px; }
  .tq-dir   { top: 46px; width: 47px; height: 46px; }
  .tq { background: rgba(26,33,44,.66); }
  .tq-acao { width: 74px; height: 74px; background: rgba(47,95,143,.80); }

  /* painel some da tela; abre pelo botão ☰ */
  #lateral { display: none; }

  #janela { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; align-self: flex-end; }
  #modal { padding: 0; place-items: end center; }
  #mCorpo { padding: 14px; }
  #mOpcoes { padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); max-height: 52vh; }
  .opcao { padding: 12px 13px; }        /* alvo de toque maior */
  #mOpcoes.linha button { min-height: 46px; }
  #mTitulo { font-size: 16px; }

  #toasts { right: 10px; left: 10px; top: 92px; align-items: center; }
  .toast { max-width: 100%; }

  .dpad { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .acoes { right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 700px) and (orientation: landscape) {
  #objetivo .obj-dica { display: none; }
  .dpad { width: 128px; height: 128px; }
  .dpad-centro { left: 43px; top: 43px; width: 42px; height: 42px; }
  .tq-cima  { left: 43px; width: 42px; height: 44px; }
  .tq-baixo { left: 43px; width: 42px; height: 44px; }
  .tq-esq   { top: 43px; width: 44px; height: 42px; }
  .tq-dir   { top: 43px; width: 44px; height: 42px; }
  .tq-acao { width: 66px; height: 66px; font-size: 22px; }
}
