:root {
  --marca: #005C45;
  --botao: #15765B;
  --botao-texto: #fff;
  --fundo: #F6F8F7;
  --cartao: #fff;
  --texto: #10201B;
  --suave: #3F524C;
  --borda: #B9C7C2;
  --sim: #157A3B;
  --nao: #B3261E;
  --aviso: #8A5A00;
  --aviso-fundo: #FFF3D6;
  --erro: #B3261E;
  --foco: #F2B400;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0E1513;
    --cartao: #17211E;
    --texto: #EEF4F1;
    --suave: #B8C8C2;
    --borda: #3B4D47;
    --aviso: #FFD27A;
    --aviso-fundo: #3A2E10;
    --erro: #FF8A80;
  }
}

* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--foco); outline-offset: 3px; }
.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topo {
  background: var(--marca); color: #fff; padding: 12px 16px; display: flex; justify-content: space-between;
  align-items: baseline; gap: 8px; flex-wrap: wrap; padding-top: max(12px, env(safe-area-inset-top));
}
.marca { font-weight: 700; }
.sub { opacity: .9; font-size: .9rem; }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; outline: none; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 8px 0 12px; outline: none; }
h2 { font-size: 1.2rem; margin: 20px 0 8px; }
.grande { font-size: 1.15rem; }
.pequeno { font-size: .9rem; color: var(--suave); }
a { color: inherit; font-weight: 700; }
.termo { background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 14px; }
.aviso { background: var(--aviso-fundo); color: var(--aviso); padding: 12px; border-radius: 10px; font-weight: 600; }
.erro { color: var(--erro); font-weight: 600; }

.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; margin: 12px 0;
  padding: 12px 18px; border: 2px solid var(--botao); border-radius: 14px; background: var(--botao);
  color: var(--botao-texto); font: inherit; font-weight: 700; font-size: 1.1rem; cursor: pointer; text-align: center;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-claro { background: transparent; color: var(--texto); border-color: var(--botao); }
.btn-sim { background: var(--sim); border-color: var(--sim); }
.btn-nao { background: var(--nao); border-color: var(--nao); }
.link {
  display: block; width: 100%; min-height: 48px; background: none; border: 0; color: var(--suave); font: inherit;
  text-decoration: underline; cursor: pointer;
}

.fotos { display: grid; gap: 12px; }
.foto {
  display: block; background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 12px;
}
.foto-titulo { font-weight: 700; display: block; }
.foto img { display: block; width: 100%; max-height: 260px; object-fit: contain; margin-top: 8px; border-radius: 8px; }
.foto:focus-within { outline: 3px solid var(--foco); outline-offset: 2px; }
label.btn:focus-within { outline: 3px solid var(--foco); outline-offset: 3px; }

.campo { display: block; border: 0; padding: 0; margin: 0 0 18px; font-weight: 600; min-width: 0; }
.campo legend { padding: 0; margin-bottom: 6px; }
.campo small { display: block; font-weight: 400; color: var(--suave); font-size: .85rem; }
input:not([type=file]), textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; font-weight: 400; color: var(--texto);
  background: var(--cartao); border: 2px solid var(--borda); border-radius: 10px;
}
.escala { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.escala button, .parte {
  min-height: 48px; font: inherit; font-weight: 700; border: 2px solid var(--borda); border-radius: 10px;
  background: var(--cartao); color: var(--texto); cursor: pointer; padding: 4px;
}
.escala button[aria-pressed=true], .parte[aria-pressed=true] { background: var(--botao); border-color: var(--botao); color: #fff; }

/* Figura do corpo simples: cabeça, pescoço, tronco entre os braços, pernas embaixo */
.corpo {
  display: grid; gap: 6px; grid-template-columns: 1fr .7fr .7fr 1fr;
  grid-template-areas: ". cab cab ." ". pes pes ." "bd ca ca be" "bd cb cb be" ". pd pe .";
}
.parte { font-size: .9rem; }
.p-cabeca { grid-area: cab; border-radius: 50%; min-height: 64px; }
.p-pescoco { grid-area: pes; }
.p-braco-d { grid-area: bd; }
.p-costas-a { grid-area: ca; min-height: 64px; }
.p-braco-e { grid-area: be; }
.p-costas-b { grid-area: cb; min-height: 64px; }
.p-perna-d { grid-area: pd; min-height: 80px; }
.p-perna-e { grid-area: pe; min-height: 80px; }
.lista { padding-left: 20px; margin: 4px 0; font-weight: 400; }

.teste { background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 12px; }
.teste video { width: 100%; border-radius: 8px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
.nivel { height: 14px; background: var(--borda); border-radius: 7px; overflow: hidden; margin-top: 10px; }
.nivel div { height: 100%; width: 0; background: var(--sim); transition: width .08s; }
.espelho { transform: scaleX(-1); }

.painel {
  background: var(--cartao); border: 2px solid var(--erro); border-radius: 12px; padding: 14px; margin-top: 16px;
}

main:has(.sala:not([hidden])) #negado {
  position: fixed; left: 12px; right: 12px; top: 64px; z-index: 5; max-height: 80dvh; overflow: auto; color: var(--texto);
}

.faixa { padding: 10px 16px; text-align: center; font-weight: 700; }
.faixa-erro { background: var(--erro); color: #fff; }
.faixa-aviso { background: var(--aviso-fundo); color: var(--aviso); }

/* Sala */
main:has(.sala:not([hidden])) { max-width: none; padding: 0; }
.sala { position: relative; background: #000; color: #fff; min-height: calc(100dvh - 52px); display: flex; flex-direction: column; }
.sala .faixa { position: absolute; top: 0; left: 0; right: 0; z-index: 3; }
.remotos { flex: 1; display: grid; gap: 4px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-content: center; }
.remotos.um { grid-template-columns: 1fr; }
.tile { position: relative; background: #111; min-height: 200px; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.remotos.um .tile { height: calc(100dvh - 160px); }
.remotos.um .tile video { object-fit: contain; }
.tile .nome { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 6px; }
.aguardando { text-align: center; padding: 40px 16px; font-size: 1.15rem; }
.minha {
  position: absolute; right: 12px; bottom: 96px; width: 30%; max-width: 160px; aspect-ratio: 3 / 4; object-fit: cover;
  border: 2px solid #fff; border-radius: 10px; background: #222; z-index: 2;
}
.gravando {
  position: absolute; top: 12px; left: 12px; z-index: 2; background: rgba(0,0,0,.65); color: #FF6B60;
  padding: 4px 10px; border-radius: 8px; font-weight: 700;
}
.controles {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom)); background: #0B0F0E;
}
.ctl {
  min-height: 60px; border-radius: 14px; border: 2px solid #fff; background: #1D2A26; color: #fff; font: inherit;
  font-weight: 700; cursor: pointer;
}
.ctl[aria-pressed=true] { background: #fff; color: #000; }
.ctl-sair { background: var(--nao); border-color: var(--nao); }
.sala #tocarSom { position: absolute; top: 50%; left: 16px; right: 16px; width: auto; z-index: 4; }

dialog {
  border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 480px); background: var(--cartao); color: var(--texto);
}
dialog::backdrop { background: rgba(0,0,0,.7); }
dialog h2 { margin-top: 0; font-size: 1.35rem; }
.aceite-botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.aceite-botoes .btn { margin: 0; min-height: 64px; font-size: 1.3rem; }
