/* BLACKOUT — jogo no escuro, então o app é escuro por padrão e sem exceção.
   Nada de @media (prefers-color-scheme): uma tela clara na mão de alguém
   ilumina a sala inteira e estraga a rodada dos outros. */

:root {
  --preto: #000;
  --fundo: #07070a;
  --painel: #101017;
  --painel-alto: #1a1a24;
  --borda: #26263a;
  --texto: #e8e8f0;
  --fraco: #8a8aa0;
  --vermelho: #ff2b3d;
  --vermelho-fundo: #2a0509;
  --azul: #4d7cff;
  --verde: #22c96b;
  --ambar: #ffb020;
  --roxo: #a855f7;

  --r: 18px;
  --r-g: 26px;
  /* WCAG 2.2 AA pede 24px. Apple 44pt, Material 48dp. No escuro, com a mão
     tremendo, nada disso basta — o mínimo aqui é 72. */
  --toque: 72px;

  --seg-t: env(safe-area-inset-top, 0px);
  --seg-b: env(safe-area-inset-bottom, 0px);
  --seg-l: env(safe-area-inset-left, 0px);
  --seg-r: env(safe-area-inset-right, 0px);
}

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

/* O atributo hidden do HTML é só um display:none de baixíssima prioridade —
   qualquer regra com `display` explícito (e este arquivo tem várias, começando
   por `button { display: flex }`) o atropela em silêncio. Sem isto, o botão do
   flash aparecia mesmo com o host tendo desligado, e o painel do admin ficava
   visível o tempo todo. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--preto);
  color: var(--texto);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  /* Sem seleção de texto, sem menu de contexto, sem zoom por duplo toque,
     sem puxar-pra-atualizar. Tudo isso é acidente esperando acontecer
     quando o dedo está procurando um botão no escuro. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow: hidden;
}

#app {
  position: fixed; inset: 0;
  /* dvh acompanha a barra do navegador aparecendo e sumindo. vh não. */
  height: 100dvh;
  display: flex; flex-direction: column;
  padding: var(--seg-t) var(--seg-r) var(--seg-b) var(--seg-l);
  background: var(--fundo);
  transition: background .35s ease;
}
body[data-tela="rodada"] #app { background: var(--preto); }
body[data-tela="morto"]  #app { background: #120003; }
/* Depois do atraso o corpo vira FAROL: vermelho forte, pulsando devagar, pra
   ser achado do outro lado da sala escura. Vermelho de propósito — preserva a
   visão noturna de quem chega perto e não ilumina o cômodo como branco iluminaria. */
body[data-tela="morto"].farol #app { animation: farol 2.4s ease-in-out infinite; }
body[data-tela="morto"].farol .caveira { filter: none; opacity: .95; font-size: 96px; }
body[data-tela="morto"].farol .morto-txt { color: #ffb3bb; }
@keyframes farol {
  0%, 100% { background: #6b0010; }
  50%      { background: #c4001e; }
}
@media (prefers-reduced-motion: reduce) {
  body[data-tela="morto"].farol #app { animation: none; background: #a30019; }
}
body[data-tela="caindo"] #app { background: #0d0002; }

section[data-tela] { display: none; flex: 1; min-height: 0; flex-direction: column; }
section[data-tela].ativa { display: flex; }

/* ---------------------------------------------------------- tipografia */
h1 { font-size: clamp(28px, 8vw, 44px); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: clamp(20px, 5.5vw, 28px); font-weight: 700; letter-spacing: -.01em; }
.rotulo { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--fraco); }
.fraco { color: var(--fraco); }
.centro { text-align: center; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ------------------------------------------------------------- botões */
button {
  font: inherit; color: inherit; border: 0; background: none; cursor: pointer;
  min-height: var(--toque); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; padding: 14px 20px; position: relative; overflow: hidden;
  transition: transform .12s ease, opacity .2s ease;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .32; }
.btn-primario { background: var(--texto); color: #08080c; font-size: 19px; }
.btn-fantasma { background: var(--painel); border: 1px solid var(--borda); }
.btn-perigo { background: var(--vermelho); color: #fff; }
.btn-largo { width: 100%; }

/* Anel de progresso do toque longo. Segurar sem retorno visual é ansiedade pura. */
.longo::after {
  content: ""; position: absolute; inset: 0; background: currentColor;
  opacity: .22; transform-origin: left; transform: scaleX(var(--p, 0));
  transition: transform .05s linear; pointer-events: none;
}

/* -------------------------------------------------------------- campos */
input[type="text"] {
  width: 100%; min-height: var(--toque); padding: 16px 20px;
  background: var(--painel); border: 1px solid var(--borda); border-radius: var(--r);
  color: var(--texto); font: inherit; font-size: 20px; font-weight: 700;
  -webkit-user-select: text; user-select: text;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }

/* --------------------------------------------------------- estruturas */
.pilha { display: flex; flex-direction: column; gap: 14px; }
.rolo { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 20px; }
.rodape { padding: 16px 20px calc(16px + var(--seg-b)); }

.cartao { background: var(--painel); border: 1px solid var(--borda); border-radius: var(--r-g); padding: 20px; }

.lista-jog { display: flex; flex-direction: column; gap: 8px; }
.jog {
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 12px 16px; background: var(--painel); border: 1px solid var(--borda); border-radius: var(--r);
}
.jog.pronto { border-color: color-mix(in srgb, var(--verde) 55%, transparent); }
.jog.morto { opacity: .38; }
.ponto { width: 10px; height: 10px; border-radius: 50%; background: var(--fraco); flex: none; }
.jog.pronto .ponto { background: var(--verde); }
.jog.morto  .ponto { background: var(--vermelho); }
.jog .nome { flex: 1; font-weight: 700; }

/* ----------------------------------------------------------- cronômetro */
.timer { font-size: clamp(56px, 20vw, 120px); font-weight: 800; letter-spacing: -.04em; }
.barra { height: 6px; border-radius: 3px; background: var(--painel-alto); overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--texto); transform-origin: left; transition: transform .25s linear; }

/* ------------------------------------------------------ revelar papel */
.revelar {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; border-radius: var(--r-g); background: var(--painel); border: 1px solid var(--borda);
  margin: 20px; text-align: center; padding: 24px;
}
.revelar.aberto { border-color: transparent; }
.revelar.aberto.impostor { background: linear-gradient(160deg, #3d0410, #16020a); border: 1px solid var(--vermelho); }
.revelar.aberto.crew     { background: linear-gradient(160deg, #06213f, #04101f); border: 1px solid var(--azul); }
.revelar.aberto.detetive { background: linear-gradient(160deg, #3b2606, #1a1103); border: 1px solid var(--ambar); }
.revelar.aberto.medico   { background: linear-gradient(160deg, #063326, #021611); border: 1px solid var(--verde); }
.papel-nome { font-size: clamp(34px, 11vw, 56px); font-weight: 800; letter-spacing: -.03em; }

/* ============================ RODADA — a tela mais importante do jogo ===
   Preta de verdade. Num OLED preto puro é pixel apagado, ou seja, luz zero:
   o celular não denuncia sua posição no escuro. */

.rodada-topo {
  display: flex; gap: 10px; padding: 10px 12px;
}
.rodada-topo button { flex: 1; min-height: var(--toque); font-size: 15px; border-radius: var(--r); }
.btn-corpo { background: #1c0407; border: 1px solid #4a0d14; color: #ff6b78; }
.btn-emerg { background: #1a1405; border: 1px solid #4a3a0d; color: #ffc247; }

.zona-luz {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; position: relative;
}
.dica-luz { font-size: 13px; color: #33333f; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
/* Medidor de bateria da lanterna. No escuro tem que dar pra ler de relance:
   forma de pilha + os segundos que sobraram, em número. */
.pilha-bateria { display: flex; align-items: center; gap: 10px; }
.bateria {
  width: 62px; height: 24px; border: 2px solid #2a2a36; border-radius: 5px;
  padding: 3px; position: relative;
}
.bateria::after {
  content: ""; position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 9px; background: #2a2a36; border-radius: 0 2px 2px 0;
}
.bateria > i { display: block; height: 100%; border-radius: 2px; background: #4a4a5e; transform-origin: left; transition: transform .2s linear; }
.bateria.baixa > i { background: var(--ambar); }
.bateria.vazia > i { background: var(--vermelho); }
#bateriaSeg { font-size: 15px; font-weight: 700; color: #3a3a48; min-width: 34px; }
.bateria.baixa + #bateriaSeg { color: var(--ambar); }
.bateria.vazia + #bateriaSeg { color: var(--vermelho); }

/* Indicador do impostor: UM ponto. Tem ponto, pode matar. Não tem, espera.
   Confere de relance com o celular no peito, sem iluminar nada. */
.ponto-kill { width: 12px; height: 12px; border-radius: 50%; background: #2a0509; transition: background .3s; }
.ponto-kill.pronto { background: var(--vermelho); box-shadow: 0 0 14px rgba(255,43,61,.65); }

.rodada-imp { display: flex; gap: 10px; padding: 0 12px 10px; }
.rodada-imp button { flex: 1; font-size: 15px; }
.btn-matei { background: #2a0509; border: 1px solid #601018; color: #ff5566; }
.btn-sabot { background: #16061f; border: 1px solid #3d1155; color: #c98bff; }

.zona-morri {
  height: 30%; min-height: 130px; margin: 0 12px calc(12px + var(--seg-b));
  border-radius: var(--r-g); background: #0b0b10; border: 1px solid #1c1c26;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #3a3a48; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 15px;
  position: relative; overflow: hidden;
}
.zona-morri > i { position: absolute; inset: 0; background: var(--vermelho); opacity: .25; transform-origin: left; transform: scaleX(var(--p, 0)); }

/* A lanterna: a tela inteira em branco no talo. Ela ilumina o SEU rosto de
   baixo pra cima — denuncia mais do que revela, que é exatamente a graça. */
#lanterna {
  position: fixed; inset: 0; background: #fff; z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .07s linear;
}
#lanterna.on { opacity: 1; }

/* --------------------------------------------------------------- morto */
.morto-marca {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
}
.caveira { font-size: 72px; opacity: .5; filter: grayscale(1) brightness(.6); }
.morto-txt { color: #6b1420; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; font-size: 14px; }

/* ------------------------------------------------------------- votação */
.voto-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 74px; padding: 14px 18px; text-align: left; justify-content: flex-start;
  background: var(--painel); border: 1px solid var(--borda); border-radius: var(--r); font-size: 18px;
}
.voto-item.escolhido { border-color: var(--azul); background: color-mix(in srgb, var(--azul) 18%, var(--painel)); }
.voto-pular { border-style: dashed; color: var(--fraco); }
.contagem-votos { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 700; }

/* --------------------------------------------------------- revelação */
.reveal-passo { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; }
.reveal-votante { font-size: clamp(22px, 6vw, 30px); font-weight: 700; color: var(--fraco); }
.reveal-alvo { font-size: clamp(36px, 11vw, 58px); font-weight: 800; letter-spacing: -.03em; }
.reveal-alvo.animando { animation: bate .45s cubic-bezier(.2,.9,.3,1.4); }
@keyframes bate { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.placar { display: flex; flex-direction: column; gap: 8px; }
.placar-linha { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--painel); border-radius: var(--r); }
.placar-linha .n { margin-left: auto; font-weight: 800; font-size: 22px; }

/* ------------------------------------------------------- fim de jogo */
.fim { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px; }
.fim.tripulacao  { background: radial-gradient(circle at 50% 30%, #05301f, transparent 70%); }
.fim.impostores  { background: radial-gradient(circle at 50% 30%, #350409, transparent 70%); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--painel-alto); font-size: 13px; font-weight: 700; }
.chip.imp { background: var(--vermelho-fundo); color: #ff8892; }

/* ------------------------------------------------------------- avisos */
.aviso {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--seg-b)); z-index: 120;
  background: var(--painel-alto); border: 1px solid var(--borda); border-radius: var(--r);
  padding: 14px 18px; font-weight: 600; box-shadow: 0 12px 40px rgba(0,0,0,.7);
  transform: translateY(140%); transition: transform .3s cubic-bezier(.2,.9,.3,1.1);
}
.aviso.on { transform: none; }

.sino { position: fixed; inset: 0; z-index: 110; background: var(--vermelho); opacity: 0; pointer-events: none; }
.sino.bate { animation: sino .9s ease-out; }
@keyframes sino { 0%,100% { opacity: 0; } 12% { opacity: .55; } 40% { opacity: 0; } 55% { opacity: .4; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* revelação: os votos se acumulam pra dar pra entender o que aconteceu */
.rev-linha {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--painel); border-radius: 12px; font-size: 15px;
  animation: entra .3s ease-out;
}
.rev-linha .quem { color: var(--fraco); }
.rev-linha .seta { color: var(--borda); }
.rev-linha .alvo { font-weight: 700; margin-left: auto; }
.rev-linha.pular .alvo { color: var(--fraco); font-weight: 500; }
@keyframes entra { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.placar-barra { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--painel); border-radius: 12px; }
.placar-barra .topo { display: flex; align-items: baseline; gap: 8px; }
.placar-barra .topo .n { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.placar-barra .trilho { height: 6px; border-radius: 3px; background: var(--painel-alto); overflow: hidden; }
.placar-barra .trilho i { display: block; height: 100%; background: var(--azul); }
.placar-barra.saiu .trilho i { background: var(--vermelho); }
.placar-barra.saiu .topo .nome { color: var(--vermelho); }

.flash-ok { color: var(--verde) !important; }
.flash-nao { color: var(--ambar) !important; }
