:root {
  --bg: #120d17;
  --panel: #1d1524;
  --panel-2: #271d30;
  --text: #f3eaf7;
  --muted: #a898b3;
  --accent: #c062e8;
  --accent-2: #e86298;
  --danger: #ff6b7a;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }
button {
  background: var(--panel-2);
  border: 1px solid #3a2c46;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; font-weight: 600; }
button.active { background: var(--accent-2); border-color: var(--accent-2); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; }
input {
  background: var(--bg);
  border: 1px solid #3a2c46;
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.center-view { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h1 { margin: 0 0 4px; font-size: 26px; text-align: center; }
.card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; text-align: center; }

/* Sala */
#room-view { height: 100%; display: grid; grid-template-columns: 1fr 340px; }
#stage { position: relative; background: #000; min-height: 0; display: grid; place-items: center; }
#screen { width: 100%; height: 100%; object-fit: contain; background: #000; }
#stage:not(.live) #screen { display: none; }
#stage.live #placeholder { display: none; }
#placeholder { text-align: center; color: var(--muted); padding: 16px; }
#placeholder .hint { font-size: 13px; }
#stage-label {
  position: absolute; top: 12px; left: 12px;
  background: #000a; padding: 4px 10px; border-radius: 999px; font-size: 13px;
}

#sidebar { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#peers { padding: 12px; display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid #2f2339; }
.peer { background: var(--panel-2); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.peer.me { outline: 1px solid var(--accent); }
.peer .state { color: var(--muted); }

#controls { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid #2f2339; }
#controls .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid #3a2c46; border-radius: 8px; padding: 6px 8px;
}
#stats {
  position: absolute; top: 12px; right: 12px; margin: 0;
  max-width: min(420px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto;
  background: #000c; color: #e8ffe8; padding: 8px 10px; border-radius: 8px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap;
  pointer-events: none;
}
.slider { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.slider input { padding: 0; accent-color: var(--accent); }
#notice { margin: 0; font-size: 13px; color: var(--muted); min-height: 0; }
#notice:empty { display: none; }

#chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#messages { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
#messages li { max-width: 85%; background: var(--panel-2); padding: 6px 10px; border-radius: 10px; align-self: flex-start; overflow-wrap: anywhere; white-space: pre-wrap; }
#messages li.mine { align-self: flex-end; background: #4a2a5c; }
#messages .meta { display: block; font-size: 11px; color: var(--muted); }
#chat-form { display: flex; gap: 6px; padding: 12px; border-top: 1px solid #2f2339; }

@media (max-width: 800px) {
  #room-view { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; height: auto; min-height: 100%; }
  #sidebar { min-height: 55vh; }
}
