:root {
  --bg: #0b0d12;
  --bg-elev: #12151d;
  --bg-elev-2: #1a1e28;
  --line: #262b38;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.15);
  --danger: #ff5a6a;
  --ok: #3ddc97;
  --radius: 14px;
  --radius-lg: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Regras de layout com display explícito venceriam o [hidden] do navegador. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: #232836; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #08101f; font-weight: 600; }
.btn-primary:hover { background: #6f9bff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #2a0409; font-weight: 600; }
.btn-ghost { background: transparent; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--accent); width: 18px; height: 18px; }

.error {
  display: none;
  margin: 0 0 14px;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: rgba(255, 90, 106, .12);
  border: 1px solid rgba(255, 90, 106, .35);
  color: #ffb3bb;
  font-size: 14px;
}
.error.show { display: block; }

.hint { color: var(--muted); font-size: 13px; }

/* ---------- Home ---------- */
.home {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.home-inner { width: 100%; max-width: 440px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px var(--accent); }
.tagline { color: var(--muted); margin: 0 0 26px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.row { display: flex; gap: 10px; }
.row .input { flex: 1; }

/* ---------- Pre-entrada ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, .82);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay .card { max-width: 420px; width: 100%; margin: 0; }

.preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  object-fit: cover;
  margin-bottom: 16px;
  transform: scaleX(-1);
}

/* ---------- Sala ---------- */
.room {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.topbar .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 10px;
  letter-spacing: .08em;
}
.spacer { flex: 1; }
.count { color: var(--muted); font-size: 14px; }

.stage { display: flex; min-height: 0; }

.grid {
  flex: 1;
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  align-content: center;
  justify-items: center;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.tile {
  position: relative;
  width: 100%;
  /* Impede que um tile sozinho estoure a altura da tela. */
  max-width: calc((100dvh - 190px) * 16 / 9);
  aspect-ratio: 16 / 9;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.tile.sharing { border-color: var(--ok); }
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.tile.self.mirror video { transform: scaleX(-1); }
.tile video.hidden { display: none; }

/* Tela compartilhada nunca é cortada: um monitor 21:9 aparece inteiro,
   com barras, em vez de perder as laterais dentro de um tile 16:9. */
.tile.screen video { object-fit: contain; }

/* Arrastar para reordenar */
.tile[draggable="true"] { cursor: grab; }
.tile.dragging { opacity: .45; cursor: grabbing; }
.tile.drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* Janela aberta com "Nova janela" */
body.popout { height: 100dvh; }
body.popout .grid {
  height: 100dvh;
  padding: 12px;
  align-content: center;
}
body.popout .tile { max-width: calc((100dvh - 30px) * 16 / 9); }

.avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--accent);
}

.tile-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 20px);
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(6, 8, 12, .72);
  font-size: 13px;
  z-index: 2;
}
.tile-label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; opacity: .9; }
.badge.off { color: var(--danger); }
.tag-share {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(61, 220, 151, .16);
  color: var(--ok);
  font-size: 12px;
  border: 1px solid rgba(61, 220, 151, .35);
}

/* ---------- Chat ---------- */
.chat {
  width: 320px;
  border-left: 1px solid var(--line);
  background: var(--bg-elev);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}
.chat[hidden] { display: none; }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; }
.chat-log { overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { font-size: 14px; }
.msg .who { color: var(--accent); font-weight: 600; font-size: 13px; }
.msg .time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.system { color: var(--muted); font-size: 13px; font-style: italic; }
.chat-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form .input { flex: 1; min-width: 0; }
.msg .body a { color: var(--accent); text-decoration: underline; }
.msg .body:empty { display: none; }

/* Foto do chat: miniatura clicável, abre o tamanho original em outra aba. */
.chat-img { display: block; margin-top: 6px; }
.chat-img img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

/* Cartão de prévia de link (Open Graph). */
.chat-card {
  display: block;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}
.chat-card:hover { background: rgba(255, 255, 255, .04); }
.chat-card img { display: block; width: 100%; max-height: 160px; object-fit: cover; }
.chat-card-txt { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.chat-card-site { color: var(--muted); font-size: 11px; }
.chat-card-tit { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.chat-card-desc {
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

/* Imagem colada esperando o Enter. */
.chat-anexo { position: relative; flex-basis: 100%; }
.chat-anexo[hidden] { display: none; }
.chat-anexo img { display: block; max-width: 100%; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); }
.chat-anexo-x {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

/* ---------- Participantes (mesmo painel do chat, do lado esquerdo) ---------- */
.participantes { width: 240px; border-left: none; border-right: 1px solid var(--line); grid-template-rows: auto 1fr auto; }
.participantes-total { color: var(--muted); font-weight: 400; margin-left: 6px; }
.participantes-lista { list-style: none; margin: 0; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.participante { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 14px; }
.participante:hover { background: var(--accent-soft); }
.participante-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participante-voce { color: var(--muted); font-size: 12px; margin-left: 4px; }
.participante-mudo { margin-left: auto; display: grid; place-items: center; color: var(--danger); }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #08101f;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.avatar { transition: box-shadow .12s; }
.participante.falando .avatar { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ok); }
.prejoin-presentes { margin: -6px 0 14px; overflow-wrap: anywhere; }

/* ---------- Barra de controles ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
}
.ctrl {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ctrl:hover { background: #232836; }
.ctrl.off { background: rgba(255, 90, 106, .16); border-color: rgba(255, 90, 106, .45); color: #ffb3bb; }
.ctrl.active { background: var(--accent-soft); border-color: var(--accent); color: #cfdcff; }
.ctrl.leave { background: var(--danger); border-color: var(--danger); color: #2a0409; }
.select {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  cursor: pointer;
}

.toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 760px) {
  .stage { flex-direction: column; }
  .chat { width: auto; border-left: none; border-top: 1px solid var(--line); max-height: 45dvh; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); padding: 10px; gap: 8px; }
  .ctrl { width: 46px; height: 46px; font-size: 18px; }
  .topbar { padding: 10px 12px; }
}

/* ---------- Modal de configuração ---------- */
.overlay .card.card-wide { max-width: 520px; }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 9px 14px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel[hidden] { display: none !important; }

.input.range { padding: 8px 0; background: none; border: none; accent-color: var(--accent); }

.cfg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------- Painel de rede ---------- */
.netpanel {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 30;
  width: 250px;
  max-height: 60dvh;
  overflow-y: auto;
  background: rgba(18, 21, 29, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  font-size: 12px;
}
.netpanel[hidden] { display: none !important; }
.netpanel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  cursor: grab;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--bg-elev-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.netpanel header:active { cursor: grabbing; }
.netpanel header button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
#netbody { padding: 10px 12px; }
.net-peer { margin-bottom: 14px; }
.net-peer:last-child { margin-bottom: 0; }
.net-nome {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.net-linha {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  white-space: pre;
  line-height: 1.7;
}
.net-linha b { color: var(--text); font-weight: 600; }
.net-linha.alerta b { color: var(--danger); }

/* ---------- Grade vazia ---------- */
.grid-wrap { flex: 1; position: relative; display: flex; min-width: 0; }
.grid-wrap .grid { width: 100%; }
.grid-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  pointer-events: none;
}
.grid-empty[hidden] { display: none !important; }

/* ---------- Ações e volume no tile ---------- */
.tile-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-actions,
.tile:focus-within .tile-actions { opacity: 1; }

.tile-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(6, 8, 12, .72);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.tile-btn:hover { background: var(--accent); color: #08101f; }
.tile-btn.off { color: var(--danger); }

.tile-audio {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(6, 8, 12, .72);
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-audio,
.tile:focus-within .tile-audio,
.tile-audio:has(.mudo.off) { opacity: 1; }
.tile-audio[hidden] { display: none !important; }
.tile-audio .tile-btn { border: none; background: none; width: 26px; height: 26px; }
.tile-audio .tile-btn:hover { background: none; color: var(--accent); }
.tile-audio .vol { width: 78px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Botão com seta (esconder minha transmissão) ---------- */
.ctrl-split { position: relative; display: flex; align-items: center; gap: 2px; }
.ctrl.seta {
  width: 26px;
  height: 52px;
  border-radius: 0 26px 26px 0;
  font-size: 12px;
  margin-left: -14px;
  padding-left: 8px;
}
.menu {
  position: absolute;
  bottom: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  white-space: nowrap;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
}
.menu[hidden] { display: none !important; }

@media (max-width: 760px) {
  .netpanel { width: min(250px, calc(100vw - 24px)); }
  .ctrl.seta { height: 46px; }
}

/* Bloco "Você" no painel de rede */
.net-peer.eu .net-nome { color: var(--ok); }

/* Fonte que ainda não trouxe áudio: controle aparece, mas apagado. */
.tile:hover .tile-audio.sem-audio,
.tile:focus-within .tile-audio.sem-audio { opacity: .55; }

/* ---------- Medidor de voz (configuração de áudio) ---------- */

/* A barra é o fundo; o range fica por cima, transparente, e só o polegar
   aparece — é ele o marcador arrastável do limiar. */
.meter {
  position: relative;
  height: 26px;
  border-radius: 8px;
  background: #151922;
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #2a3550, #4a6bb5);
  transition: width 60ms linear;
}
.meter.ativo .meter-fill { background: linear-gradient(90deg, #1f5f45, var(--ok)); }
.meter-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #ffffff;
  opacity: .75;
  pointer-events: none;
}
.meter-range {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--accent);
  cursor: ew-resize;
}
.meter-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 24px;
  border-radius: 5px;
  background: var(--accent);
  border: 1px solid #0b0d12;
}
.meter-range::-moz-range-thumb {
  width: 14px;
  height: 24px;
  border-radius: 5px;
  background: var(--accent);
  border: 1px solid #0b0d12;
}
.meter-range::-moz-range-track { background: none; }

.ptt-row { display: flex; align-items: center; gap: 12px; }
.ptt-row b { color: var(--text); font-size: 14px; }
#cfgPttSet.capturando { border-color: var(--accent); color: #cfdcff; }

/* ---------- Espectadores e microfone falando ---------- */

.viewers {
  color: var(--ok);
  font-size: 14px;
  margin-right: 12px;
  white-space: nowrap;
}
.viewers[hidden] { display: none !important; }

#idleCount { color: var(--muted); font-style: normal; }

.ctrl.falando { box-shadow: 0 0 0 2px var(--ok) inset; }

/* ---------- Assistir transmissão (clique para abrir) ---------- */
.tile-watch {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(10, 14, 22, .92), rgba(6, 8, 12, .96));
}
.tile-watch[hidden] { display: none !important; }
.btn-watch {
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #08101f;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}
.btn-watch:hover { filter: brightness(1.12); }

/* Parar de assistir: contorno vermelho, ao lado do tela cheia. */
.tile-btn.parar {
  width: auto;
  padding: 0 10px;
  gap: 4px;
  font-size: 12px;
  border-color: var(--danger);
  color: var(--danger);
}
.tile-btn.parar:hover { background: var(--danger); color: #08101f; }
.tile-btn.parar[hidden] { display: none !important; }
/* Com o botão de parar presente, as ações não ficam totalmente escondidas:
   quem está assistindo precisa enxergar a saída sem caçar com o mouse. */
.tile-actions:has(.parar:not([hidden])) { opacity: .6; }
.tile:hover .tile-actions:has(.parar:not([hidden])) { opacity: 1; }

/* ---------------- Painel de sons (MyInstants) ---------------- */

/* A barrinha de volume nasce fechada e abre para o lado no hover. Fica ao lado
   do botão de propósito: o volume do soundboard não é o volume da sala. */
.sfx-vol { display: flex; align-items: center; }
.sfx-range {
  width: 0;
  opacity: 0;
  margin-left: 0;
  accent-color: var(--accent);
  transition: width .18s ease, opacity .18s ease, margin-left .18s ease;
}
.sfx-vol:hover .sfx-range,
.sfx-vol:focus-within .sfx-range,
.sfx-split:hover .sfx-range {
  width: 110px;
  opacity: 1;
  margin-left: 8px;
}

.sfx-card { width: min(760px, 94vw); }
.sfx-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sfx-head h2 { margin: 0; }
.sfx-head .input { flex: 1; }
.sfx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: min(56vh, 420px);
  overflow-y: auto;
  padding-right: 4px;
}
.sfx-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: inherit;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.sfx-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.sfx-item:active { transform: translateY(1px); }
.sfx-rodape { margin: 12px 0 0; }

@media (max-width: 640px) {
  /* Sem hover no toque: a barra fica sempre visível. */
  .sfx-range { width: 90px; opacity: 1; margin-left: 8px; }
  .sfx-head { flex-wrap: wrap; }
}

/* Parar de ouvir: aparece só enquanto um som está tocando. */
.ctrl.sfx-stop { width: 44px; height: 44px; font-size: 16px; }
.ctrl.sfx-stop[hidden] { display: none !important; }

/* Cabeçalho "Favoritos ▾": o texto no meio de uma linha, como uma divisória
   que também é botão. */
.sfx-fav-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 4px 0 10px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.sfx-fav-head::before,
.sfx-fav-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.sfx-fav-head:hover { color: inherit; }
.sfx-grid-fav { margin-bottom: 12px; }

/* Cada som: o corpo toca, a estrela guarda. */
.sfx-cell { position: relative; }
.sfx-cell .sfx-item { width: 100%; padding-right: 28px; }
.sfx-star {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.sfx-star:hover { color: #ffd166; background: rgba(255, 209, 102, .12); }
.sfx-star.on { color: #ffd166; }

/* ---------- Chat: aviso de mensagem nova ---------- */
/* O contador fica preso ao canto do botão. */
.ctrl { position: relative; }
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #2a0409;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-elev);
}
.badge[hidden] { display: none !important; }

/* Divisória "novas mensagens": marca onde a leitura parou. */
.chat-novas {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.chat-novas::before,
.chat-novas::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--danger);
  opacity: .55;
}

/* ---------- Quem está assistindo ---------- */
/* Caixinha de ~60px à esquerda do olho: até três linhas de nomes. */
.viewer-names {
  max-width: 64px;
  margin-right: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  text-align: right;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  /* Reticências na terceira linha: deixa claro que há mais gente assistindo
     do que coube — a lista inteira fica no title, ao passar o mouse. */
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}
.viewer-names[hidden] { display: none !important; }

/* ---------- Salas abertas (tela inicial) ---------- */
.home {
  display: flex;
  flex-direction: column;
  place-items: initial;
  align-items: center;
}
.home-top {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.vista {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-elev);
}
.vista-btn {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.vista-btn svg { fill: currentColor; }
.vista-btn:hover { color: var(--text); }
.vista-btn.ativo { background: var(--accent-soft); color: var(--accent); }

.salas { width: 100%; max-width: 1100px; margin-top: 18px; }
.salas-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.salas-head h2 { margin: 0; font-size: 16px; font-weight: 600; }

.salas-grade { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .salas-grade { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .salas-grade { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 500px)  { .salas-grade { grid-template-columns: minmax(0, 1fr); } }
.salas-grade.salas-modo-lista { grid-template-columns: minmax(0, 1fr); gap: 8px; }

.sala-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  cursor: pointer;
  min-width: 0;
  transition: border-color .15s, background .15s;
}
.sala-card:hover { border-color: var(--accent); background: var(--bg-elev-2); }
.sala-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sala-card .code,
.overlay .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
}
.sala-pessoas { font-weight: 600; }
.sala-nomes { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.sala-tempo { color: var(--muted); font-size: 12px; }

.salas-modo-lista .sala-card { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 12px 16px; }
.salas-modo-lista .sala-nomes { flex: 1; min-width: 120px; }
.salas-modo-lista .sala-tempo { margin-left: auto; }

.pedido-espera { margin: 0 0 6px; font-weight: 600; text-align: center; }
.pedido-contagem { margin: 0 0 6px; font-size: 40px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; color: var(--accent); }
#pedidoRegra { text-align: center; margin: 0 0 14px; }

/* ---------- Votação de entrada (dentro da sala) ---------- */
.votacao { z-index: 60; }
.votacao .card { text-align: center; }
.votacao-nome { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.votacao .row { margin-top: 14px; }
.votacao .row .btn { flex: 1; }

/* "Aberta há ..." no canto inferior direito da sala. */
.controls { position: relative; }
.sala-aberta {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .sala-aberta { position: static; transform: none; width: 100%; text-align: right; }
}

/* Ko-fi: botão "Doe-um café" + modal com iframe. */
.kofi-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.kofi-btn:hover { background: var(--bg-elev-2); border-color: var(--accent); }
.home-top { gap: 10px; align-items: center; }
.kofi-sala {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}
@media (max-width: 900px) {
  .kofi-sala { position: static; transform: none; }
}
.kofi-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .6);
}
.kofi-box {
  position: relative;
  width: min(420px, 100%);
  height: min(680px, 90vh);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  overflow: hidden;
}
.kofi-box iframe { width: 100%; height: 100%; border: 0; background: #f9f9f9; }
.kofi-fechar {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  cursor: pointer;
}

/* ---------- Cinema ---------- */
.grid-wrap { flex-direction: column; }
.grid-wrap .grid { flex: 1; min-height: 0; }

.tile.cinema {
  grid-column: span 2;
  grid-row: span 2;
  max-width: none;
  background: #000;
  border-color: rgba(91, 140, 255, .55);
  box-shadow: 0 0 30px rgba(255, 184, 107, .12);
  color: var(--text);
}
@media (max-width: 700px) { .tile.cinema { grid-column: auto; grid-row: auto; } }
.tile.cinema.so { grid-column: 1 / -1; }
.cine-video, .cine-cena, .cine-escudo { position: absolute; inset: 0; }
.cine-video iframe, .cine-video > div { width: 100%; height: 100%; border: 0; }
.cine-cena svg, .cine-convite-cena svg { width: 100%; height: 100%; display: block; }
.cine-escudo { z-index: 1; }
.tile.cinema.clique-livre .cine-escudo { pointer-events: none; }
.cine-topo, .cine-base, .cine-voto, .cine-aviso, .cine-som { position: absolute; z-index: 2; }
.cine-topo {
  left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(rgba(0,0,0,.75), transparent);
}
.cine-chip {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
.cine-acoes { display: flex; gap: 6px; flex-shrink: 0; }
.tile.cinema .tile-btn { width: auto; min-width: 32px; padding: 0 8px; }
.tile-btn.on { background: var(--accent); color: #08101f; }
.tile-btn:disabled { opacity: .45; cursor: not-allowed; }
.cine-base {
  left: 0; right: 0; bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
}
.cine-prog { height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; margin-bottom: 7px; overflow: hidden; }
.cine-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
.cine-ctl { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cine-ctl .vol { width: 80px; accent-color: var(--accent); }
.cine-tempo { color: var(--muted); font-variant-numeric: tabular-nums; }
.cine-avs { display: flex; margin-left: auto; }
.cine-avs b {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); color: #0b0d12; font-size: 9px;
  display: grid; place-items: center; margin-left: -5px; border: 2px solid #000;
}
.cine-avs b.eu { background: var(--ok); }
.cine-voto {
  left: 50%; top: 48px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(18, 21, 29, .92); border: 1px solid var(--accent);
  border-radius: 12px; padding: 6px 10px; font-size: 13px; white-space: nowrap;
}
.cine-voto[hidden] { display: none; }
.cine-voto-conta { color: var(--muted); }
.cine-aviso {
  left: 50%; bottom: 60px; transform: translateX(-50%);
  background: rgba(255, 90, 106, .9); color: #2a0409; font-weight: 600;
  border-radius: 10px; padding: 6px 12px; font-size: 13px; max-width: 90%; text-align: center;
}
.cine-aviso[hidden], .cine-som[hidden] { display: none; }
.cine-som {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 10px 16px; font-weight: 700; cursor: pointer;
}

/* Convite: quem não sentou não vê o player */
.cine-convite { display: none; }
.tile.cinema.convidado > :not(.cine-convite) { display: none !important; }
.tile.cinema.convidado .cine-convite {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 14px;
  background: radial-gradient(ellipse at 50% 0%, #3a2a6b, #0b0d12 70%);
  border: 1px dashed rgba(91,140,255,.5); border-radius: inherit;
}
.cine-convite-cena { width: 60%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; filter: blur(4px) brightness(.65); }
.cine-convite-txt { font-weight: 700; }
.cine-convite-sub { color: var(--muted); font-size: 13px; }

/* Fila embaixo da grade */
.cine-fila {
  margin: 0 14px 12px; padding: 10px 12px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  max-height: 34dvh; overflow: auto; flex-shrink: 0;
}
.cine-fila[hidden] { display: none; }
.cine-mu { color: var(--muted); font-size: 12px; }
.cine-fila-lista { margin: 6px 0; }
.cine-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cine-item.atual .cine-item-tit { color: #cfdcff; }
.cine-item .tile-btn { margin-left: auto; flex-shrink: 0; }
.cine-th {
  width: 56px; height: 32px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, #3a2a6b, #1a1e28) center / cover;
  display: grid; place-items: center; font-size: 14px;
}
.cine-th-twitch { background: linear-gradient(135deg, #6441a5, #1a1e28); }
.cine-item-txt { min-width: 0; }
.cine-item-tit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cine-fila-vazia { padding: 8px 0; }
.cine-fila-form { display: flex; gap: 8px; }
.cine-fila-form .input { flex: 1; min-width: 0; }

/* Modal da salinha */
.cine-modal {
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: #07080c; color: var(--text); width: min(820px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
}
.cine-modal::backdrop { background: rgba(0,0,0,.7); }
.cine-modal-topo { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 13px; flex-wrap: wrap; }
.cine-legenda { color: var(--muted); font-size: 12px; }
.cine-legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 8px; vertical-align: -1px; }
.cine-legenda .l-livre { background: #b8333f; }
.cine-legenda .l-ocup { background: #4a6ad8; }
.cine-legenda .l-sua { background: var(--ok); }
.cine-sala-wrap { position: relative; }
.cine-svg { display: block; width: 100%; height: auto; }
.cine-sala { transition: filter 1.2s; }
.cine-sala.escuro { filter: brightness(.45) saturate(.85); }
.cine-brilho { opacity: .55; }
.cine-poltrona { cursor: pointer; transition: transform .18s; outline: none; }
.cine-poltrona.ocupada { cursor: default; }
.cine-poltrona:not(.ocupada):hover, .cine-poltrona:not(.ocupada):focus-visible { transform: translateY(-5px); }
.cine-realce { opacity: 0; transition: opacity .18s; }
.cine-poltrona:not(.ocupada):hover .cine-realce,
.cine-poltrona:focus-visible .cine-realce,
.cine-poltrona.sel .cine-realce { opacity: 1; }
.cine-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -130%);
  background: rgba(18,21,29,.94); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 9px; font-size: 12px; white-space: nowrap;
}
.cine-tip[hidden] { display: none; }
.cine-modal-pe {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--bg-elev); border-top: 1px solid var(--line);
}
.cine-modal-acoes { display: flex; gap: 8px; }

/* Tela compartilhada no cinema */
.cine-tela { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cine-tela[hidden] { display: none; }
.tile.cinema.com-tela .cine-video { visibility: hidden; }
.tile.cinema.com-tela .cine-cena { display: none; }
.cine-tela-msg, .cine-tela-pedir {
  position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(18,21,29,.92); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; text-align: center; font-size: 14px;
}
.cine-tela-pedir { display: flex; flex-direction: column; gap: 8px; align-items: center; border-color: var(--accent); }
.cine-tela-msg[hidden], .cine-tela-pedir[hidden] { display: none; }
.cine-fila-form .btn-ghost { white-space: nowrap; }

/* Tomatada */
.cine-tomate-btn { margin-left: 6px; }
.cine-splash-camada { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.cine-tomate {
  position: absolute; font-size: 34px; transform: translate(-50%, -50%) rotate(0deg) scale(.6);
  transition: top .42s cubic-bezier(.2,.7,.3,1), transform .42s ease-out;
}
.cine-tomate.voando { transform: translate(-50%, -50%) rotate(540deg) scale(1.25); }
.cine-splash {
  position: absolute; width: 150px; transform: translate(-50%, -38%);
  animation: cine-splash-some var(--dura, 1.9s) ease-in forwards;
}
.cine-splash-svg { width: 100%; overflow: visible; animation: cine-splat .18s ease-out; }
.cine-splash-svg .esc { transform-box: fill-box; transform-origin: top; animation: cine-escorre var(--dura, 1.9s) ease-in forwards; }
.cine-splash-svg .e2 { animation-duration: calc(var(--dura, 1.9s) * .9); }
.cine-splash-svg .e3 { animation-duration: calc(var(--dura, 1.9s) * .75); }
.cine-splash-quem {
  position: absolute; left: 50%; top: -18px; transform: translateX(-50%);
  font-size: 11px; background: rgba(0,0,0,.6); border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
@keyframes cine-splat { from { transform: scale(.2); } to { transform: scale(1); } }
@keyframes cine-escorre { from { transform: scaleY(.3); } to { transform: scaleY(2.6); } }
@keyframes cine-splash-some { 0%, 70% { opacity: 1; translate: 0 0; } 100% { opacity: 0; translate: 0 28px; } }

/* Cineminha na aba Participantes */
.cine-mini { border-top: 1px solid var(--line); padding: 8px 6px 10px; position: relative; }
.cine-mini[hidden] { display: none; }
.cine-mini-tit { font-size: 12px; color: var(--muted); margin: 0 4px 4px; }
.cine-mini-sala { position: relative; }
.cine-aviso.info { background: rgba(18,21,29,.92); color: var(--text); border: 1px solid var(--accent); font-weight: 500; }
.cine-cc { font-size: 11px; font-weight: 800; letter-spacing: .5px; }
.cine-cc[hidden] { display: none; }
/* Legenda do YouTube fica embaixo: com CC ligado, a barra só aparece no hover */
.tile.cinema.legenda-on .cine-base { opacity: 0; transition: opacity .2s; }
.tile.cinema.legenda-on:hover .cine-base,
.tile.cinema.legenda-on:focus-within .cine-base { opacity: 1; }

/* Menu do botão direito na aba Participantes */
.menu-participante { position: fixed; z-index: 1000; min-width: 200px; padding: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 4px; }
.menu-part-item { all: unset; cursor: pointer; padding: 8px 10px; border-radius: 6px; color: var(--text); font-size: 14px; }
.menu-part-item:hover, .menu-part-item:focus-visible { background: var(--accent-soft); }
.menu-part-rotulo { padding: 6px 10px 0; color: var(--muted); font-size: 13px; }
.menu-part-vol { margin: 4px 10px 8px; accent-color: var(--accent); }
