:root {
  color-scheme: dark;
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel-2: #313338;
  --panel-3: #383a40;
  --line: #3f4147;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --faint: #80848e;
  --red: #e3350d;
  --red-hover: #c92c09;
  --green: #23a55a;
  --yellow: #f0b232;
  --danger: #f23f43;
  --focus: #00a8fc;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Topo ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #1a1b1e;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.brand-name { font-weight: 700; white-space: nowrap; }

.brand-sub {
  color: var(--muted);
  font-size: 13px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.room-chip {
  background: var(--panel-3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.room-chip strong { color: var(--text); letter-spacing: 0.12em; margin-left: 4px; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- Cartões de entrada ---------- */

.center-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 16px;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.35);
}

.card h1 { font-size: 22px; margin: 12px 0 4px; }

.hero-ball { display: block; margin: 0 auto; filter: drop-shadow(0 4px 10px rgb(227 53 13 / 0.35)); }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }

.form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; text-align: left; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field > span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid #1a1b1e;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
}

.field input:focus, .field select:focus { border-color: var(--focus); outline: none; }

.code-input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; text-align: center; }
.code-input::placeholder { letter-spacing: 0.3em; }

.form-error {
  margin: 0;
  color: #ff8a8d;
  background: rgb(242 63 67 / 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.host-link { color: var(--faint); font-size: 13px; }
.host-link:hover { color: var(--muted); }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-block { width: 100%; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-secondary { background: var(--panel-3); }
.btn-secondary:hover { background: #43454b; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d8373b; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--panel-3); color: var(--text); }
.danger-text { color: #ff8a8d; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover { background: rgb(255 255 255 / 0.12); }

/* ---------- Palco do vídeo ---------- */

.watch, .host {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-content: start;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
  align-self: start;
}

.watch .stage { max-height: calc(100vh - 90px); }

.stage video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }

.stage:fullscreen { border-radius: 0; max-height: none; aspect-ratio: auto; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, #2a2c31 0%, #111214 75%);
}

.overlay h2 { margin: 10px 0 0; font-size: 20px; }
.overlay p { margin: 0; color: var(--muted); max-width: 420px; }

.overlay-ball { animation: wobble 2.4s ease-in-out infinite; transform-origin: 50% 90%; }

@keyframes wobble {
  0%, 60%, 100% { transform: rotate(0); }
  70% { transform: rotate(-14deg); }
  80% { transform: rotate(12deg); }
  90% { transform: rotate(-6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-ball { animation: none; }
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 24px 12px 10px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.75));
  opacity: 0;
  transition: opacity 0.2s;
}

.stage:hover .controls, .stage:focus-within .controls, .controls.always { opacity: 1; }

@media (hover: none) { .controls { opacity: 1; } }

.controls-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.live-badge, .status-pill {
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
}

.status-pill[data-state="idle"] { background: var(--panel-3); color: var(--muted); }
.status-pill[data-state="connecting"] { background: var(--yellow); color: #1e1f22; }
.status-pill[data-state="error"] { background: #7a2224; }

.stats { color: #dfe1e5; font-size: 13px; font-variant-numeric: tabular-nums; margin-left: auto; text-shadow: 0 1px 2px #000; }

.volume { display: flex; align-items: center; gap: 4px; }
.volume input { width: 90px; accent-color: var(--text); }
.icon-muted { display: none; }
.is-muted .icon-muted { display: block; }
.is-muted .icon-sound { display: none; }

.unmute {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgb(0 0 0 / 0.75);
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

.unmute:hover { background: rgb(0 0 0 / 0.9); }

/* ---------- Painel lateral ---------- */

.side {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  align-self: start;
  max-height: calc(100vh - 90px);
}

.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.count {
  background: var(--panel-3);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 13px;
  font-weight: 700;
}

.people { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 40px; }

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
}

.person:hover { background: var(--panel-2); }

.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: hsl(var(--hue, 200) 55% 42%);
}

.person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { color: var(--faint); }

.tag { font-size: 11px; color: var(--faint); white-space: nowrap; }
.tag-watching { color: var(--green); }

.kick { width: 28px; height: 28px; color: var(--faint); }
.kick:hover { color: #ff8a8d; background: rgb(242 63 67 / 0.12); }

.net-warning {
  margin: 0;
  font-size: 13px;
  color: var(--yellow);
  background: rgb(240 178 50 / 0.1);
  border-radius: 8px;
  padding: 8px 10px;
}

/* ---------- Área do host ---------- */

.host-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

.status-text { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.4em; }
.status-text.is-error { color: #ff8a8d; }

.settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
}

.check { grid-column: 1 / -1; display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--red); width: 16px; height: 16px; }
.check small { display: block; color: var(--faint); font-size: 12px; }

.room-card {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.room-card-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.room-code {
  display: block;
  font-size: 34px;
  letter-spacing: 0.22em;
  margin: 4px 0 12px;
  padding-left: 0.22em;
  font-variant-numeric: tabular-nums;
}

.room-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.room-actions .btn { padding: 8px 6px; font-size: 13px; white-space: nowrap; }

/* ---------- Aviso rápido ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #111214;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
  z-index: 10;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Celular e telas estreitas ---------- */

@media (max-width: 860px) {
  .watch, .host { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
  .side { max-height: none; }
  .people { max-height: 260px; }
}

@media (max-width: 520px) {
  .brand-sub { display: none; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .volume input { width: 70px; }
}
