:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --line: #2b303a;
  --fg: #e6e8ec;
  --dim: #9aa3b2;
  --accent: #5b8cff;
  --danger: #ff5b6e;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}
button {
  font: inherit; color: var(--fg); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { border-color: var(--danger); color: var(--danger); }

.landing {
  height: 100%; display: grid; place-content: center; justify-items: center;
  gap: 18px; text-align: center; padding: 20px;
}
.landing h1 { margin: 0; font-size: 34px; letter-spacing: -0.5px; }
.landing p { margin: 0; color: var(--dim); max-width: 36ch; }
.landing button { padding: 12px 22px; background: var(--accent); border-color: var(--accent); color: #fff; }

.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
}
header .room { font-weight: 600; margin-right: auto; }
header .room span { color: var(--dim); font-weight: 400; }
#stage {
  display: grid; gap: 10px; padding: 12px; align-content: start; overflow: auto;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.tile {
  position: relative; background: #0e1014; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center;
}
.tile video { width: 100%; height: 100%; object-fit: contain; display: none; }
.tile.live video { display: block; }
.tile .idle { color: var(--dim); font-size: 13px; }
.tile.live .idle { display: none; }
.tile .label {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 6px;
  background: rgba(0,0,0,.6); font-size: 12px;
}
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
#toast.show { opacity: 1; }

/* --- maximizar --- */
.tile { cursor: zoom-in; }
.tile .expand {
  position: absolute; right: 8px; top: 8px; padding: 4px 8px; line-height: 1;
  background: rgba(0,0,0,.6); border-color: transparent; opacity: 0; transition: opacity .15s;
}
.tile:hover .expand, .tile:focus-within .expand { opacity: 1; }

/* Um tile em foco ocupa a area inteira; os outros saem do fluxo. */
#stage.focused { grid-template-columns: 1fr; align-content: stretch; overflow: hidden; }
#stage.focused .tile { display: none; }
#stage.focused .tile.focus { display: grid; aspect-ratio: auto; height: 100%; cursor: zoom-out; }

.tile:fullscreen { aspect-ratio: auto; border-radius: 0; border: none; width: 100%; height: 100%; }

/* --- nome, portaria e expulsao --- */
.hidden { display: none !important; }
.badge {
  padding: 2px 8px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); color: var(--dim);
}
.badge.owner { border-color: var(--accent); color: var(--accent); }

#gate {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(10, 11, 14, .94); display: grid; place-items: center; padding: 20px;
}
#gate .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; width: min(380px, 100%); text-align: center;
}
#gate h2 { margin: 0 0 6px; font-size: 20px; }
#gate p { margin: 0 0 16px; color: var(--dim); }
#gate form { display: flex; gap: 8px; }
#gate input { flex: 1; min-width: 0; }
input {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; outline: none;
}
input:focus { border-color: var(--accent); }
#gate.waiting form { display: none; }

/* Pedidos de entrada: so o dono ve. */
#requests {
  position: fixed; right: 16px; bottom: 16px; z-index: 15;
  display: flex; flex-direction: column; gap: 8px; width: min(320px, calc(100vw - 32px));
}
.request {
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; gap: 8px;
}
.request .who { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.request button { padding: 5px 10px; }

.tile .kick {
  position: absolute; right: 8px; bottom: 8px; padding: 4px 10px; line-height: 1;
  background: rgba(0,0,0,.6); border-color: transparent; color: var(--danger);
  opacity: 0; transition: opacity .15s;
}
body.owner .tile:hover .kick { opacity: 1; }

.tile .state {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 12px; color: var(--dim); pointer-events: none; text-align: center;
}
.tile.live .state { top: auto; bottom: 8px; left: auto; right: 8px; transform: none; }
.tile .state:empty { display: none; }

/* --- pergunta do audio --- */
#ask {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(10, 11, 14, .94); display: grid; place-items: center; padding: 20px;
}
#ask .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; width: min(420px, 100%); text-align: center;
}
#ask h2 { margin: 0 0 6px; font-size: 20px; }
#ask p { margin: 0 0 16px; color: var(--dim); }
#ask .row { display: flex; gap: 8px; justify-content: center; }
#ask #askYes { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- volume por tile --- */
.tile .audioctl {
  position: absolute; left: 8px; top: 8px; display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.6); border-radius: 8px; padding: 4px 8px;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .audioctl, .tile .audioctl:focus-within { opacity: 1; }
.tile .audioctl button { padding: 2px 6px; line-height: 1; background: transparent; border: none; }
.tile .audioctl input[type="range"] { width: 80px; accent-color: var(--accent); }
