/* In-game meeting controls (toolbar, panels, screen viewer) */

.hud {
  --hud-bg: rgba(18, 20, 24, 0.82);
  --hud-bg-solid: #16181c;
  --hud-fg: #f4f5f7;
  --hud-muted: #a3a8b1;
  --hud-line: rgba(255, 255, 255, 0.1);
  --hud-btn: rgba(255, 255, 255, 0.08);
  --hud-btn-hover: rgba(255, 255, 255, 0.16);
  --hud-red: #e5484d;
  --hud-green: #3ddc84;
  --hud-blue: #3b82f6;

  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  color: var(--hud-fg);
  font-family: var(--font-family-primary);
}

.hud > * { pointer-events: auto; }
.hud [hidden] { display: none !important; }
body.menu-open .hud { display: none; }

/* Keep the controls hint above the toolbar */
.hint { bottom: 92px; }

/* ---------- Toolbar ---------- */

.hud-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px;
  max-width: calc(100% - 32px);
  overflow-x: auto;
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  scrollbar-width: none;
}

.hud-btn {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 62px;
  padding: 7px 8px 6px;
  font: inherit;
  font-size: 11px;
  color: var(--hud-fg);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease;
}

.hud-btn:hover { background: var(--hud-btn-hover); }
.hud-btn:focus-visible { outline: 2px solid var(--hud-blue); outline-offset: 1px; }
.hud-btn.is-active { background: rgba(59, 130, 246, 0.28); }
.hud-btn.is-off { color: var(--hud-red); }
.hud-btn.is-speaking svg { color: var(--hud-green); filter: drop-shadow(0 0 4px rgba(61, 220, 132, 0.7)); }

.hud-btn--leave { margin-left: 6px; color: #fff; background: var(--hud-red); }
.hud-btn--leave:hover { background: #cc3b40; }

.hud-badge {
  position: absolute;
  top: 3px;
  right: 10px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  color: #fff;
  background: var(--hud-red);
  border-radius: 999px;
}

.hud-badge--count { background: rgba(255, 255, 255, 0.22); }

/* ---------- Reactions picker ---------- */

.hud-reactions {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 6px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-reactions button {
  width: 44px;
  height: 44px;
  font-size: 24px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.hud-reactions button:hover { background: var(--hud-btn-hover); transform: scale(1.15); }

body:has(.hud-reactions:not([hidden])) .hint { opacity: 0; }

/* ---------- Side panels ---------- */

.hud-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 96px;
  display: flex;
  flex-direction: column;
  width: 320px;
  max-width: calc(100% - 32px);
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}

/* Both open: stack them */
.hud-panel:not([hidden]) ~ .hud-panel--chat:not([hidden]) { right: 348px; }

.hud-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 12px 16px;
  border-bottom: 1px solid var(--hud-line);
}

.hud-panel__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.hud-panel__head h2 span { color: var(--hud-muted); font-weight: 400; }

.hud-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--hud-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.hud-icon:hover { color: var(--hud-fg); background: var(--hud-btn-hover); }
.hud-icon svg { width: 18px; height: 18px; }

.hud-name {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--hud-muted);
  border-bottom: 1px solid var(--hud-line);
}

.hud input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--hud-fg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hud-line);
  border-radius: 8px;
}

.hud input[type="text"]:focus { outline: none; border-color: var(--hud-blue); }

.hud-people {
  flex: 1;
  margin: 0;
  padding: 6px 8px;
  list-style: none;
  overflow-y: auto;
}

.hud-person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  font-size: 14px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow 150ms ease;
}

.hud-person.is-speaking { box-shadow: inset 0 0 0 2px var(--hud-green); }
.hud-person__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-person__name em { color: var(--hud-muted); font-style: normal; }

.hud-person__icons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  color: var(--hud-muted);
}

.hud-person__icons svg { width: 16px; height: 16px; display: block; }
.hud-person__icons .is-off { color: var(--hud-red); }

/* Chat */

.hud-messages {
  flex: 1;
  margin: 0;
  padding: 10px 14px;
  list-style: none;
  overflow-y: auto;
}

.hud-message { margin-bottom: 12px; }
.hud-message__meta { font-size: 12px; color: var(--hud-muted); margin-bottom: 2px; }
.hud-message__meta b { color: var(--hud-fg); }
.hud-message__text { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.hud-message.is-self .hud-message__meta b { color: #8ab4ff; }

.hud-compose {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--hud-line);
}

.hud-compose button {
  flex: none;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--hud-blue);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- Screen share ---------- */

.hud-share {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 6px 6px 6px 14px;
  font-size: 13px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-share__dot {
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--hud-green);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(61, 220, 132, 0.2);
}

.hud-share__view {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #111;
  background: #fff;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.hud-share__view svg { width: 14px; height: 14px; }

.hud kbd {
  padding: 1px 5px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.hud-viewer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: rgba(8, 9, 11, 0.94);
  z-index: 2;
}

.hud-viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 18px;
  font-size: 14px;
  font-weight: 700;
}

.hud-viewer__stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px 16px;
}

.hud-viewer__video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  background: #000;
}

/* ---------- Contextual prompt (sit) ---------- */

.hud-prompt {
  position: absolute;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  background: var(--hud-bg);
  border-radius: 999px;
  pointer-events: none !important;
}

.hud-prompt kbd {
  color: #111;
  background: #fff;
  border: 0;
  padding: 2px 7px;
}

/* ---------- Toast & floating reactions ---------- */

.hud-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translate(-50%, -6px);
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--hud-bg);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.hud-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.hud-floats {
  position: absolute;
  inset: 0;
  pointer-events: none !important;
  overflow: hidden;
}

.hud-float {
  position: absolute;
  bottom: 96px;
  font-size: 40px;
  animation: hud-float 2.2s ease-out forwards;
}

@keyframes hud-float {
  from { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { transform: translateY(-20px) scale(1.1); opacity: 1; }
  to { transform: translateY(-260px) scale(1); opacity: 0; }
}

@media (max-width: 720px) {
  .hud-btn { min-width: 52px; }
  .hud-btn span { display: none; }
  .hud-panel { left: 16px; width: auto; }
  .hud-panel:not([hidden]) ~ .hud-panel--chat:not([hidden]) { right: 16px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hud-float { animation-duration: 0.01s; }
}

/* ---------- Whiteboard drawing view ---------- */

.wb {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: rgba(8, 9, 11, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

body.drawing .hud-bar,
body.drawing .hud-prompt,
body.drawing .hint { display: none; }

.wb__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wb__group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  border-radius: 12px;
}

.wb__color {
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--c);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
}

.wb__color[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px var(--hud-blue); }

.wb__size,
.wb__tool,
.wb__done {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 34px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--hud-fg);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.wb__size { padding: 0; }
.wb__size i { display: block; width: var(--d); height: var(--d); min-width: 4px; min-height: 4px; background: currentColor; border-radius: 50%; }
.wb__size:hover, .wb__tool:hover { background: var(--hud-btn-hover); }
.wb__size[aria-pressed="true"], .wb__tool[aria-pressed="true"] { background: rgba(59, 130, 246, 0.35); }

.wb__done { display: flex; gap: 8px; color: #111; background: #fff; }
.wb__done kbd { border-color: rgba(0, 0, 0, 0.25); }

.wb button:focus-visible { outline: 2px solid var(--hud-blue); outline-offset: 2px; }

.wb__stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wb__canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto;
  background: #fbfbf9;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  cursor: crosshair;
  touch-action: none;
}

/* ---------- New chat message notifications ---------- */

.chat-notes {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 300px;
  max-width: calc(100% - 32px);
  pointer-events: none;
}

.chat-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  color: #f4f5f7;
  background: rgba(18, 20, 24, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid #3b82f6;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.chat-note.is-in { opacity: 1; transform: none; }
.chat-note:hover { background: rgba(30, 33, 39, 0.95); }
.chat-note:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.chat-note__icon { flex: none; font-size: 18px; line-height: 1.2; }
.chat-note__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; line-height: 1.35; }
.chat-note__body b { font-size: 13px; }
.chat-note__body span { color: #c9ccd2; overflow-wrap: anywhere; }

/* Don't cover the chat or people panels when they're open */
body:has(.hud-panel:not([hidden])) .chat-notes { right: 348px; }

@media (max-width: 720px) {
  .chat-notes { left: 16px; right: 16px; width: auto; }
  body:has(.hud-panel:not([hidden])) .chat-notes { right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-note { transition: none; transform: none; }
}

/* ---------- Faces (webcam gallery) ---------- */

.faces {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: rgba(8, 9, 11, 0.92);
}

.faces__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 18px;
  font-size: 14px;
  font-weight: 700;
}

.faces__bar em { color: var(--hud-muted); font-style: normal; font-weight: 400; }

.faces__grid {
  --cols: 2;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 0 16px 100px;
  align-content: center;
}

.face-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  overflow: hidden;
  background: hsl(var(--hue, 200) 35% 22%);
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px transparent;
  transition: box-shadow 150ms ease;
}

.face-tile.is-speaking { box-shadow: inset 0 0 0 3px var(--hud-green); }

.face-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.face-tile video.is-mirror { transform: scaleX(-1); }
.face-tile.is-cam-off video { display: none; }

.face-tile__initial {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: clamp(28px, 6vw, 64px);
  font-weight: 700;
  color: #fff;
}

.face-tile.is-cam-off .face-tile__initial { display: grid; }

.face-tile__name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 4px 10px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
}

.face-tile__name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face-tile__mic:empty { display: none; }
.face-tile__mic svg { width: 14px; height: 14px; display: block; color: var(--hud-red); }

.face-tile__hand {
  position: absolute;
  top: 8px;
  right: 10px;
  display: none;
  font-size: 22px;
}

.face-tile.is-hand .face-tile__hand { display: block; }

@media (max-width: 720px) {
  .faces__grid { --cols: 1 !important; grid-auto-rows: auto; overflow-y: auto; align-content: start; }
}

/* Keep the toolbar usable above the Faces gallery */
.hud-bar { z-index: 3; }
.hud:has(.faces:not([hidden])) ~ .hint,
.hud:has(.faces:not([hidden])) .hud-prompt { display: none; }
