:root {
  --bg: #f4f5f9;
  --painel: #ffffff;
  --texto: #1d2433;
  --suave: #6b7385;
  --borda: #e3e6ee;
  --primario: #5865f2;
  --primario-escuro: #4450d6;
  --perigo: #e5484d;
  --dock: #232536;
  --dock-2: #2e3146;
  --dock-texto: #e9eaf3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--texto); font-size: 14px; }
.oculto { display: none !important; }

/* ---------- Telas cheias ---------- */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(circle at 20% 20%, #3a3f6b 0%, #1b1d2b 70%); z-index: 50;
}
.overlay.escuro { background: rgba(15, 16, 25, .7); }
.card {
  background: var(--painel); border-radius: 18px; padding: 28px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 14px;
}
.card-login { max-width: 760px; flex-direction: row; gap: 28px; }
.col-avatar { flex: 0 0 260px; display: flex; flex-direction: column; justify-content: center; }
.col-form { flex: 1; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 720px) { .card-login { flex-direction: column; } .col-avatar { flex: none; } }
.card h1 { margin: 0; font-size: 22px; text-align: center; }
.card .logo { font-size: 36px; text-align: center; }
.sub { margin: -6px 0 6px; color: var(--suave); text-align: center; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
input, select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 10px; outline: none; background: #fff; color: var(--texto);
}
input:focus, select:focus { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(88, 101, 242, .18); }
.erro { color: var(--perigo); margin: 0; min-height: 1em; text-align: center; }
.nota { color: var(--suave); font-size: 12px; margin: 0; line-height: 1.5; }
.nota a { color: var(--primario); font-weight: 600; }
.linha-botoes { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Editor de avatar ---------- */
.editor-avatar { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.editor-avatar .preview {
  align-self: center; width: 120px; height: 150px; border-radius: 16px; display: grid; place-items: center;
  background: repeating-conic-gradient(#c68c56 0% 25%, #c08651 0% 50%) 0 0 / 24px 24px;
  box-shadow: inset 0 0 0 4px #a9723f;
}
.editor-avatar .preview canvas { width: 72px; height: 104px; image-rendering: pixelated; }
.editor-avatar .opcao { display: flex; align-items: center; gap: 8px; }
.editor-avatar .opcao span { flex: 1; font-size: 12px; font-weight: 600; color: var(--suave); }
.editor-avatar .opcao b { min-width: 80px; text-align: center; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.editor-avatar .opcao i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0, 0, 0, .15); }
.editor-avatar .seta { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--borda); background: #fff; cursor: pointer; font-size: 12px; }
.editor-avatar .seta:hover { background: #f0f2f8; }
.editor-avatar .aleatorio { margin-top: 4px; }

/* ---------- Botões ---------- */
.btn {
  font: inherit; border: 1px solid var(--borda); background: var(--painel); color: var(--texto);
  padding: 8px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f0f2f8; }
.btn.primario { background: var(--primario); color: #fff; border-color: var(--primario); }
.btn.primario:hover { background: var(--primario-escuro); }
.btn.perigo { color: var(--perigo); border-color: #f3c6c7; }
.btn.grande { padding: 12px; font-size: 15px; font-weight: 600; }
.btn.ativo { background: #e8ebff; border-color: var(--primario); }

/* ---------- App ---------- */
#app, #palco { position: fixed; inset: 0; }
#palco { background: #1b1d2b; overflow: hidden; }
#mapa { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; cursor: pointer; }

#topo-esq {
  position: absolute; top: 12px; left: 12px; background: rgba(35, 37, 54, .9); color: var(--dock-texto);
  padding: 8px 14px; border-radius: 12px; display: flex; flex-direction: column; gap: 2px; font-size: 12px;
}
#topo-esq b { font-size: 14px; }
#topo-esq span { color: #a9adc6; }

#dica {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 92px; max-width: 560px; width: calc(100% - 32px);
  background: rgba(35, 37, 54, .92); color: var(--dock-texto); padding: 9px 14px; border-radius: 12px; font-size: 12px;
  text-align: center; pointer-events: none;
}

/* Dock inferior */
#dock {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px;
  background: var(--dock); padding: 8px 10px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  max-width: calc(100% - 90px); overflow-x: auto; scrollbar-width: none;
}
#dock::-webkit-scrollbar { display: none; }
#dock .sep { width: 1px; height: 32px; background: #3b3f58; margin: 0 4px; flex-shrink: 0; }
.eu { display: flex; align-items: center; gap: 8px; padding: 2px 8px 2px 4px; border-radius: 10px; cursor: pointer; color: var(--dock-texto); flex-shrink: 0; }
.eu:hover { background: var(--dock-2); }
.eu canvas { width: 27px; height: 39px; image-rendering: pixelated; }
#dock-nome { font-weight: 700; font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: #b9bdd6; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cor, #9aa1b1); }
.btn-dock {
  font: inherit; font-size: 17px; border: 0; background: transparent; color: var(--dock-texto); cursor: pointer;
  min-width: 44px; height: 46px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  flex-shrink: 0; padding: 0 6px;
}
.btn-dock small { font-size: 10px; color: #a9adc6; }
.btn-dock:hover { background: var(--dock-2); }
.btn-dock.ativo { background: #3a4072; }
.btn-dock.desligado { background: #5a2a33; }
.btn-dock.perigo small { color: #ff9a9d; }

#zoom { position: absolute; right: 14px; bottom: 16px; display: flex; flex-direction: column; gap: 4px; background: var(--dock); padding: 4px; border-radius: 12px; }
#zoom .btn-dock { height: 36px; min-width: 36px; }

/* Vídeos */
#videos {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; max-width: calc(100% - 420px); pointer-events: none;
}
.tile {
  width: 168px; height: 112px; border-radius: 12px; overflow: hidden; position: relative;
  background: #2a2f45; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); pointer-events: auto; border: 2px solid transparent;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile video.espelho { transform: scaleX(-1); }
.tile .avatar-grande { position: absolute; inset: 0; display: grid; place-items: center; }
.tile .avatar-grande canvas { width: 45px; height: 65px; image-rendering: pixelated; }
.tile .rotulo {
  position: absolute; left: 6px; bottom: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 6px; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile.falando { border-color: #3ddc84; }

/* Lateral */
#lateral {
  position: absolute; top: 12px; right: 12px; bottom: 90px; width: 270px; background: rgba(35, 37, 54, .96); color: var(--dock-texto);
  border-radius: 14px; padding: 14px; overflow-y: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
#lateral h2 { font-size: 14px; margin: 0 0 10px; }
#lista-pessoas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#lista-pessoas li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; cursor: pointer; }
#lista-pessoas li:hover { background: var(--dock-2); }
#lista-pessoas li.off { opacity: .45; cursor: default; }
#lista-pessoas li.off:hover { background: none; }
#lista-pessoas canvas { width: 22px; height: 32px; image-rendering: pixelated; flex-shrink: 0; }
.pessoa-info { min-width: 0; flex: 1; }
.pessoa-nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pessoa-status { font-size: 11px; color: #a9adc6; }
.aviso { margin-top: 14px; font-size: 12px; background: #4a3d1c; border: 1px solid #6b5520; padding: 8px 10px; border-radius: 9px; color: #f4dc9c; }

/* Toasts */
#toasts { position: absolute; left: 12px; bottom: 96px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none; }
.toast { background: rgba(35, 37, 54, .95); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 13px; animation: entra .2s ease-out; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 900px) {
  .btn-dock small { display: none; }
  #videos { max-width: calc(100% - 24px); top: 70px; }
}
