:root {
  --bg: #12151c;
  --panel: rgba(24, 28, 38, 0.94);
  --panel-solid: #181c26;
  --line: var(--tint-3);
  --text: #eef0f4;
  --muted: #9aa3b5;
  --accent: #5b8def;
  --accent-ink: #0d1422;
  --on: #3fbf7f;
  --danger: #e2574c;
  --radius: 12px;
  --bar-height: 64px;
  --chat-width: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#game {
  position: fixed;
  inset: 0 0 var(--bar-height) 0;
  width: 100%;
  height: calc(100% - var(--bar-height));
  display: block;
  cursor: pointer;
}

/* ---------- Barra inferior ---------- */

#bar {
  position: fixed;
  inset: auto 0 0 0;
  height: var(--bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--panel-solid);
  border-top: 1px solid var(--line);
}

.bar-info { display: flex; flex-direction: column; min-width: 0; }
.bar-info span { color: var(--muted); font-size: 12px; }
.bar-actions { display: flex; gap: 8px; }

.bar-actions button {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--tint-1);
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}
/* Só com mouse: no toque o "hover" gruda no botão tocado e esconderia o verde de ligado. */
@media (hover: hover) {
  .bar-actions button:not([aria-pressed="true"]):hover { background: var(--tint-3); }
}
.bar-actions button[aria-pressed="true"] {
  background: var(--on);
  border-color: var(--on);
  color: #06210f;
  font-weight: 600;
}
.bar-actions button:disabled { opacity: 0.5; cursor: progress; }

/* ---------- Vídeos de quem está por perto ---------- */

#stage {
  position: fixed;
  top: 12px;
  left: 12px;
  right: calc(var(--chat-width) + 24px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}
body.chat-closed #stage { right: 12px; }

.tile {
  position: relative;
  width: 168px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--tile-bg);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  cursor: zoom-in;
}
.tile.screen { width: 300px; aspect-ratio: 16 / 9; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile.screen video { object-fit: contain; }
.tile.mirrored video { transform: scaleX(-1); }
.tile.no-video video { opacity: 0; }

.tile-avatar {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 40px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}
.tile.no-video .tile-avatar { display: grid; }

.tile-label {
  color: #ffffff;
  position: absolute;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.72);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-label .mic-off { color: var(--danger-ink); }
.tile-flip {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(10, 12, 18, 0.62);
  font-size: 18px;
  cursor: pointer;
}

.tile.expanded {
  position: fixed;
  inset: 24px 24px calc(var(--bar-height) + 24px) 24px;
  width: auto;
  aspect-ratio: auto;
  z-index: 20;
  cursor: zoom-out;
}
.tile.expanded video { object-fit: contain; }

/* ---------- Chat ---------- */

#chat {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: calc(var(--bar-height) + 12px);
  width: var(--chat-width);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
body.chat-closed #chat { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.scope { display: flex; padding: 2px; border-radius: 999px; background: var(--tint-2); }
.scope button {
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.scope button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }

#chat-log, #dm-log {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#chat-log li { overflow-wrap: anywhere; }
#chat-log .author { font-weight: 600; margin-right: 6px; }
#chat-log .tag {
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--tint-2);
  color: var(--muted);
  font-size: 11px;
}
#chat-log .system { color: var(--muted); font-size: 12px; }

#chat-form, #dm-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
#chat-form input, #dm-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
#chat-form button, #dm-form button {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- Abas, lista de pessoas e conversas individuais ---------- */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.chat-tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.chat-tabs button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-weight: 600;
}
.chat-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-view .chat-header { font-weight: 500; font-size: 12px; color: var(--muted); }

.badge {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.status-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }

#people-list { flex: 1; margin: 0; padding: 6px; list-style: none; overflow-y: auto; }
.empty-note { margin: 0; padding: 16px 14px; color: var(--muted); }
.person {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.person:hover { background: var(--tint-2); }
.person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-detail { color: var(--muted); font-size: 12px; }

.dm-header { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
.dm-header button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: var(--tint-2); }
#dm-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dm-note { margin: 0; padding: 6px 12px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
#dm-log li { max-width: 85%; padding: 6px 10px; border-radius: 12px; display: flex; flex-direction: column; overflow-wrap: anywhere; }
#dm-log .mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
#dm-log .theirs { align-self: flex-start; background: var(--tint-2); border-bottom-left-radius: 4px; }
.dm-time { align-self: flex-end; font-size: 10px; opacity: 0.7; }
#dm-input:disabled { opacity: 0.5; }

.status-field { display: flex; align-items: center; gap: 8px; margin-right: auto; color: var(--muted); font-size: 12px; }
.status-field select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  color: var(--text);
}


/* ---------- Entrada, avisos ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  padding: 16px;
  background: rgba(10, 12, 18, 0.82);
}

.card {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.card h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.card .lead { margin: 0 0 8px; color: var(--muted); }
.card label, .card .field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.card input[type="text"],
.card input[type="email"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
.card .primary {
  margin-top: 10px;
  padding: 11px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.card .hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.card .error { margin: 0; color: var(--danger-ink); }

#avatar-picker { display: flex; gap: 16px; align-items: center; }

.avatar-preview {
  flex: none;
  width: 128px;
  height: 128px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 88%, var(--tint-3), transparent 55%), #232938;
  image-rendering: pixelated;
  cursor: pointer;
}

.picker-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.picker-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.picker-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }

.swatches { display: flex; gap: 5px; }
.swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line);
}
.swatch[aria-checked="true"] { border-color: #fff; }

.stepper { display: flex; align-items: center; gap: 2px; }
.stepper-arrow {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--tint-2);
  font-size: 16px;
  line-height: 1;
}
.stepper-arrow:hover { background: var(--tint-3); }
.stepper-value { width: 104px; text-align: center; font-size: 13px; }

@media (max-width: 420px) {
  #avatar-picker { flex-direction: column; }
}

#game { image-rendering: pixelated; }

.card .link, .session .link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
}
.card a { color: var(--accent); }
.session { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--line); }
.card input[readonly] { opacity: 0.6; }

/* ---------- aviso de compartilhamento de tela ---------- */

#share-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(226, 87, 76, 0.45);
}
#share-banner button {
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #7a1f18;
  font-weight: 700;
}
.share-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: share-pulse 1.4s ease-in-out infinite; }
@keyframes share-pulse { 50% { opacity: 0.25; } }

/* Moldura vermelha em volta de tudo enquanto a tela está sendo compartilhada. */
body.sharing::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 17;
  border: 3px solid var(--danger);
  pointer-events: none;
}
body.sharing #stage { top: 60px; }
body.sharing #btn-screen[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- painel de conexão ---------- */

#netinfo {
  position: fixed;
  left: 12px;
  bottom: calc(var(--bar-height) + 12px);
  z-index: 12;
  max-width: min(440px, calc(100% - 24px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#netinfo:empty::before { content: "Medindo a conexão…"; color: var(--muted); }
.netinfo-row { display: flex; gap: 10px; }
.netinfo-label { flex: none; width: 92px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#reaction-menu {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bar-height) + 12px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.reaction-emoji {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  transition: transform 120ms ease, background-color 120ms ease;
}
.reaction-emoji:hover { background: var(--tint-3); transform: scale(1.2) translateY(-2px); }
.reaction-emoji:active { transform: scale(0.92); }
.reaction-sound {
  margin-left: 4px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--tint-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.reaction-sound[aria-pressed="true"] { color: var(--text); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-height) + 16px);
  transform: translateX(-50%);
  z-index: 25;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--toast-error-bg);
  border: 1px solid rgba(226, 87, 76, 0.55);
  text-align: center;
}

/* Com o chat aberto, o mapa ocupa só a área livre para nada ficar escondido atrás dele. */
@media (min-width: 761px) {
  body:not(.chat-closed) #game { width: calc(100% - var(--chat-width) - 24px); }
}

@media (max-width: 760px) {
  :root { --chat-width: 0px; --bar-height: 108px; }
  #stage { right: 12px; }
  .tile { width: 112px; }
  .tile.screen { width: 200px; }
  #chat { left: 12px; width: auto; top: 30%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Marca: Meu Escritório Minha Vida ---------- */

.brand-banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
  padding: 18px 18px 0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
}
.brand-banner img { display: block; width: 100%; max-width: 340px; height: auto; margin-bottom: 14px; }
.brand-ribbon {
  position: relative;
  align-self: stretch;
  margin: 0 -18px;
  padding: 10px 10px 8px;
  border-radius: 0 0 14px 14px;
  background: #1d4fa8;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.brand-ribbon::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, #1d6fd8 0 25%, #2f9e44 25% 50%, #f2b705 50% 75%, #ef5a1c 75%);
}
.brand-seal {
  position: absolute;
  top: -16px;
  right: -16px;
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #ef5a1c;
  box-shadow: 0 0 0 3px #ffffff, 0 6px 14px rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(14deg);
  animation: seal-stamp 520ms cubic-bezier(0.2, 1.6, 0.4, 1) 250ms both;
}
.brand-seal::after { content: ""; position: absolute; inset: 5px; border: 2px dashed rgba(255, 255, 255, 0.7); border-radius: 50%; }
@keyframes seal-stamp {
  from { opacity: 0; transform: rotate(14deg) scale(2.2); }
  to { opacity: 1; transform: rotate(14deg) scale(1); }
}
.brand-banner--compact { padding: 12px 12px 0; }
.brand-banner--compact img { max-width: 240px; margin-bottom: 10px; }
.brand-banner--compact .brand-ribbon { margin: 0 -12px; font-size: 10px; }
.brand-banner--compact .brand-seal { width: 56px; height: 56px; font-size: 9px; }

.loading-card .lead { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card .button-link { display: block; text-align: center; text-decoration: none; }

.bar-brand { flex: none; }
.bar-brand img { display: block; height: 34px; width: auto; }

/* ---------- Cerimônia de entrega das chaves ---------- */

#ceremony { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; overflow: hidden; pointer-events: none; }
.ceremony-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 24px 20px;
  border-radius: 18px;
  background: #ffffff;
  color: #12151c;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: ceremony-pop 620ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.ceremony-card img { display: block; width: 100%; max-width: 300px; height: auto; margin: 6px auto 0; }
.ceremony-ribbon {
  position: absolute;
  top: -15px;
  left: 50%;
  padding: 6px 18px;
  border-radius: 6px;
  background: #ef5a1c;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-2deg);
  box-shadow: 0 6px 14px rgba(239, 90, 28, 0.4);
}
.ceremony-key { display: block; margin-top: 8px; font-size: 40px; line-height: 1; animation: key-turn 900ms ease-in-out 350ms both; }
.ceremony-title { margin: 8px 0 2px; font-size: 24px; font-weight: 900; letter-spacing: -0.01em; }
.ceremony-text { margin: 0; font-size: 15px; color: #2b303b; }
.ceremony-small { margin: 6px 0 0; font-size: 12px; color: #6b7180; }
#ceremony.leaving .ceremony-card { animation: ceremony-out 300ms ease-in forwards; }
.confetti {
  position: absolute;
  top: -16px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall var(--fall, 2.4s) linear var(--delay, 0s) forwards;
}
@keyframes ceremony-pop { from { opacity: 0; transform: scale(0.6) translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes ceremony-out { to { opacity: 0; transform: scale(0.9) translateY(-16px); } }
@keyframes key-turn {
  0% { opacity: 0; transform: rotate(0) scale(0.4); }
  50% { opacity: 1; transform: rotate(-30deg) scale(1.25); }
  100% { transform: rotate(0) scale(1); }
}
@keyframes confetti-fall { to { transform: translate(var(--drift, 0), calc(100vh + 40px)) rotate(var(--spin, 720deg)); } }

/* ---------- Menu de reações e efeitos sonoros ---------- */

#reaction-menu { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px; border-radius: 16px; width: min(372px, calc(100% - 32px)); }
.menu-caption { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.reaction-row { display: flex; justify-content: space-between; gap: 4px; }
.effect-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.effect-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 6px;
  border: 0;
  border-radius: 10px;
  background: var(--tint-1);
  font-size: 11px;
  transition: transform 120ms ease, background-color 120ms ease;
}
.effect-button:hover { background: var(--tint-3); transform: translateY(-2px); }
.effect-button:active { transform: scale(0.94); }
.effect-emoji { font-size: 22px; line-height: 1; }
#reaction-menu .reaction-sound { align-self: flex-end; margin: 2px 0 0; }

@media (max-width: 1100px) { .bar-brand img { height: 30px; } }
@media (max-width: 760px) { .bar-brand { display: none; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* ---------- Câmera e áudio ---------- */

.card .secondary {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tint-1);
  font-weight: 600;
}
.card .secondary:hover { background: var(--tint-3); }
.card .secondary + .primary { margin-top: 6px; }

#settings-dialog {
  width: min(720px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
#settings-dialog::backdrop { background: rgba(10, 12, 18, 0.72); }
.settings { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; }
.settings-header { display: flex; align-items: center; justify-content: space-between; }
.settings-header h2 { margin: 0; font-size: 18px; }
.settings-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--tint-2); }
.settings-status { margin: 0; padding: 8px 12px; border-radius: 8px; background: rgba(240, 198, 116, 0.12); color: var(--warning-ink); font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; }
.settings-preview { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 12px; background: #0b0e14; }
.settings-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#preview-empty { color: var(--muted); font-size: 13px; }
.settings-fields, #speaker-field { display: flex; flex-direction: column; gap: 6px; }
.settings-fields label { margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.settings-fields select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
}
.mic-meter { height: 8px; overflow: hidden; border-radius: 999px; background: var(--tint-2); }
#mic-level { display: block; width: 0%; height: 100%; background: var(--on); transition: width 60ms linear; }
.settings .hint { margin: 0; color: var(--muted); font-size: 12px; }
#speaker-test { align-self: flex-start; margin-top: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint-1); }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-footer .primary { padding: 9px 22px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
@media (max-width: 640px) { .settings-grid { grid-template-columns: 1fr; } }

/* ---------- Barra inferior em telas menores ---------- */

.bar-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-icon { font-size: 16px; line-height: 1; }
.warning-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(240, 198, 116, 0.12); color: var(--warning-ink); font-size: 13px; }

/* Sem espaço para os nomes: só os ícones (o nome continua disponível para leitores de tela). */
@media (max-width: 1400px) {
  .bar-actions .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .bar-actions button { min-width: 44px; min-height: 40px; padding: 8px 10px; }
  .btn-icon { font-size: 18px; }
}

/* Celular: informações em cima, todos os botões numa fileira que ocupa a largura toda. */
@media (max-width: 760px) {
  #bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 8px;
    padding: 6px 8px 8px;
  }
  .bar-info { flex-direction: row; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
  .status-field { margin: 0; }
  .status-field > span { display: none; }
  .bar-actions { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
  .bar-actions button { min-width: 0; min-height: 44px; padding: 0; border-radius: 12px; }
  .bar-actions button[hidden] { display: none; }
}

/* Aviso quando o navegador bloqueia o som automático (comum no Safari e no iPhone). */
#audio-unlock {
  position: fixed;
  top: 64px;
  left: 50%;
  z-index: 19;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  transform: translateX(-50%);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

.settings-volumes { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 10px 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.settings-volumes label { color: var(--muted); font-size: 12px; font-weight: 600; }
.settings-volumes output { display: inline-block; min-width: 40px; margin-left: 6px; color: var(--text); font-variant-numeric: tabular-nums; }
.settings-volumes input[type="range"] { width: 100%; accent-color: var(--accent); }
.settings-volumes select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); }
@media (max-width: 640px) { .settings-volumes { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- Microfone e câmera desligados: vermelho e ícone riscado ---------- */
.bar-actions .media-toggle[aria-pressed="false"] { background: rgba(226, 87, 76, 0.18); border-color: rgba(226, 87, 76, 0.65); color: var(--off-ink); }
.media-toggle .btn-icon { position: relative; }
.media-toggle[aria-pressed="false"] .btn-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -3px;
  right: -3px;
  height: 2px;
  border-radius: 2px;
  background: #ff5a4e;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transform: rotate(-45deg);
}

/* ---------- Mapa: zoom, menu do botão direito, dica ao passar o mouse ---------- */
/* none: o navegador não rola nem amplia o mapa; a pinça vira o zoom do próprio mapa (pinch.js). */
#game { touch-action: none; cursor: default; }
/* Sem o zoom de toque duplo do navegador no resto da tela (o iPhone ignora o user-scalable=no). */
html { touch-action: manipulation; }
#zoom-controls { position: fixed; top: 12px; left: 12px; z-index: 11; display: flex; flex-direction: column; gap: 4px; }
#zoom-controls button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 16px; }
#zoom-controls button:hover { background: var(--panel-solid); }
#map-tooltip, #map-menu { position: fixed; z-index: 26; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-solid); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45); }
#map-tooltip { padding: 6px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; }
#map-menu { display: flex; flex-direction: column; min-width: 200px; padding: 6px; }
#map-menu .menu-title { margin: 2px 8px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
#map-menu button { padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; }
#map-menu button:hover, #map-menu button:focus-visible { background: var(--tint-2); }
.room-action {
  align-self: flex-start;
  margin: 2px 0;
  padding: 3px 10px;
  border: 1px solid #f2c230;
  border-radius: 999px;
  background: rgba(242, 194, 48, 0.12);
  color: var(--stamp-ink);
  font-size: 12px;
  font-weight: 700;
}
#people-list li { display: flex; align-items: center; gap: 4px; }
#people-list .person { flex: 1; min-width: 0; }
.wave-button { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: var(--tint-1); font-size: 18px; }
.wave-button:hover { background: var(--tint-3); }
#toast.info { background: var(--toast-info-bg); border-color: rgba(91, 141, 239, 0.6); }

/* ---------- Não perturbe ---------- */
#quiet-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 18;
  max-width: calc(100% - 120px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--quiet-bg);
  border: 1px solid #f2c230;
  color: var(--quiet-ink);
  font-weight: 600;
  text-align: center;
  transform: translateX(-50%);
}
body.sharing #quiet-banner { top: 60px; }

/* Nome do lugar e botão da sala na mesma linha; a contagem de pessoas embaixo. */
@media (min-width: 761px) {
  .bar-info { display: grid; grid-template-columns: auto auto; align-items: center; justify-content: start; column-gap: 8px; }
  .bar-info #people-count { grid-column: 1 / -1; }
  .room-action { margin: 0; }
}

/* Campos nativos (e-mail, listas, preenchimento automático) no tema escuro, com texto legível. */
.card input:-webkit-autofill,
.card input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--field-solid) inset;
  transition: background-color 9999s ease-out;
}

/* ---------- Temas: escuro (padrão) e claro ---------- */
:root {
  color-scheme: dark;
  --tint-1: rgba(255, 255, 255, 0.05);
  --tint-2: rgba(255, 255, 255, 0.08);
  --tint-3: rgba(255, 255, 255, 0.13);
  --field: rgba(0, 0, 0, 0.28);
  --field-solid: #0f1219;
  --tooltip-bg: #0f1219;
  --tile-bg: #232938;
  --toast-error-bg: #2a1a1c;
  --toast-info-bg: #16263d;
  --danger-ink: #ffb4ad;
  --warning-ink: #f0c674;
  --success-ink: #7fd6a4;
  --quiet-bg: #3a2f12;
  --quiet-ink: #ffe08a;
  --off-ink: #ffc2bc;
  --stamp-ink: #f2c230;
  --series-1: #3987e5;
  --series-2: #d95926;
  --chart-grid: rgba(255, 255, 255, 0.09);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #e9edf3; --panel: rgba(255, 255, 255, 0.95); --panel-solid: #ffffff; --line: rgba(15, 23, 42, 0.13);
    --text: #1a1f2b; --muted: #5a6273; --accent: #2f6fe0; --accent-ink: #ffffff; --on: #1f9d5c; --danger: #d64036;
    --tint-1: rgba(15, 23, 42, 0.04); --tint-2: rgba(15, 23, 42, 0.07); --tint-3: rgba(15, 23, 42, 0.12);
    --field: #ffffff; --field-solid: #ffffff; --tooltip-bg: #ffffff; --tile-bg: #d9dfe8;
    --toast-error-bg: #fdecea; --toast-info-bg: #e7effd; --danger-ink: #b42318; --warning-ink: #8a5a00; --success-ink: #18794e;
    --quiet-bg: #fff4d6; --quiet-ink: #6b4b00; --off-ink: #b42318; --stamp-ink: #9a6700;
    --series-1: #2a78d6; --series-2: #eb6834; --chart-grid: rgba(15, 23, 42, 0.1);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9edf3; --panel: rgba(255, 255, 255, 0.95); --panel-solid: #ffffff; --line: rgba(15, 23, 42, 0.13);
  --text: #1a1f2b; --muted: #5a6273; --accent: #2f6fe0; --accent-ink: #ffffff; --on: #1f9d5c; --danger: #d64036;
  --tint-1: rgba(15, 23, 42, 0.04); --tint-2: rgba(15, 23, 42, 0.07); --tint-3: rgba(15, 23, 42, 0.12);
  --field: #ffffff; --field-solid: #ffffff; --tooltip-bg: #ffffff; --tile-bg: #d9dfe8;
  --toast-error-bg: #fdecea; --toast-info-bg: #e7effd; --danger-ink: #b42318; --warning-ink: #8a5a00; --success-ink: #18794e;
  --quiet-bg: #fff4d6; --quiet-ink: #6b4b00; --off-ink: #b42318; --stamp-ink: #9a6700;
  --series-1: #2a78d6; --series-2: #eb6834; --chart-grid: rgba(15, 23, 42, 0.1);
}

/* Sombras mais leves no tema claro. */
:root[data-theme="light"] #map-menu, :root[data-theme="light"] #map-tooltip, :root[data-theme="light"] #settings-dialog { box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) #map-menu, :root:not([data-theme="dark"]) #map-tooltip, :root:not([data-theme="dark"]) #settings-dialog { box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18); }
}

/* Logo com texto branco no tema escuro e com texto escuro no claro. */
.theme-light-only { display: none !important; }
:root[data-theme="light"] .theme-light-only { display: revert !important; }
:root[data-theme="light"] .theme-dark-only { display: none !important; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-light-only { display: revert !important; }
  :root:not([data-theme="dark"]) .theme-dark-only { display: none !important; }
}
@media (max-width: 760px) { #bar .bar-brand { display: none !important; } }

/* ---------- Direcional na tela (celular e tablet): segurar uma seta = segurar WASD ---------- */
#dpad, .hint-touch { display: none; }
@media (pointer: coarse) {
  .hint-desktop { display: none; }
  .hint-touch { display: inline; }
  #dpad {
    --dpad-cell: 50px;
    position: fixed;
    left: 16px;
    bottom: calc(var(--bar-height) + 16px);
    z-index: 11;
    display: grid;
    grid-template: repeat(3, var(--dpad-cell)) / repeat(3, var(--dpad-cell));
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--panel);
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  #dpad::after { content: ''; grid-area: 2 / 2; place-self: center; width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
  #dpad button { display: grid; place-items: center; min-width: 0; padding: 0; border: 0; border-radius: 14px; background: transparent; color: var(--text); }
  #dpad button.active { background: var(--accent); color: var(--accent-ink); }
  #dpad svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  .dpad-up { grid-area: 1 / 2; }
  .dpad-left { grid-area: 2 / 1; }
  .dpad-left svg { transform: rotate(-90deg); }
  .dpad-right { grid-area: 2 / 3; }
  .dpad-right svg { transform: rotate(90deg); }
  .dpad-down { grid-area: 3 / 2; }
  .dpad-down svg { transform: rotate(180deg); }
}
/* No celular o chat aberto cobre o mapa: o direcional sai junto. */
@media (pointer: coarse) and (max-width: 760px) {
  body:not(.chat-closed) #dpad { display: none; }
}
