/* =========================================================================
   Town Hall — HUD / overlay styling (retro pixel arcade look)
   The Phaser canvas sits full-screen behind everything; all DOM UI here is
   an overlay layer (pointer-events selectively re-enabled per widget).
   ========================================================================= */

:root {
  --bg: #0f1410;
  --panel: #1a221b;
  --panel-2: #222d24;
  --ink: #e8ecf5;
  --muted: #f2f2f2;
  --accent: #ffd23f;
  --accent-2: #35d0a5;
  --danger: #ff5a5a;
  --warn: #ff9f40;
  --border: #324235;
  /* Chrome-only darks (video tiles, input fields, the pixel-shadow ring) —
     kept as separate tokens (not reused from --bg/--panel) so JS can retint
     just these on a theme change without touching the base palette shape. */
  --chrome-shadow: #0a0e0b;
  --chrome-input: #0d120e;
  --chrome-video: #060806;
  --pixel: 'Google Sans Code', Helvetica, Arial, sans-serif;
  --term: 'Google Sans Code', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over the `display:flex` on .overlay/.sidebar
   (the UA [hidden] rule is not !important, so author `display:` would defeat it). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--term);
  /* Root font-size in absolute px (not rem, which would be circular here) —
     every other font-size in this file is in rem relative to this value, so
     changing it rescales all text uniformly. 12.6px = 18px (old VT323-era
     base) x 0.7, correcting for Google Sans Code rendering visually larger
     than VT323 at the same declared size. */
  font-size: 12.6px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
/* ...but text you're actually meant to type into/select stays selectable. */
input, textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

button { font-family: var(--pixel); cursor: pointer; text-transform: uppercase; }
canvas { image-rendering: pixelated; }
p { padding: 4px 0 8px; margin: 0; line-height: 1.3; }

#game-root { position: fixed; inset: 0; z-index: 0; }
#game-root canvas { display: block; width: 100%; height: 100%; }

/* ---------- Overlays / panels ------------------------------------------- */
/* Plain black for now on the entry-flow modals (was a blocky yellow gradient)
   — the whole app is getting a redesign later. */
.overlay {
  background: #000;
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
/* Modals that sit on top of the map (running or the entry-screen preview)
   dim it rather than hiding it. */
#room-overlay, #avatar-overlay, #permission-modal,
#avatar-modal, #credits-modal, #object-modal, #agenda-modal, #agenda-view-modal,
#airhockey-modal, #pooltable-modal, #connect4-modal, #wheelfortune-modal, #wf-rules-modal,
#clubradio-modal {
  background: rgba(6, 8, 14, 0.78);
  backdrop-filter: blur(2px);
}
/* A help modal opened from on top of another one (Wheel of Fortune's rules,
   over the table itself) needs its own darker wash so it still reads as a
   distinct layer, not just more of the same dim. */
#wf-rules-modal { background: rgba(6, 8, 14, 0.9); }

.panel {
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow: 0 0 0 3px var(--chrome-shadow), 8px 8px 0 rgba(0,0,0,0.5);
  padding: 22px;
  max-width: 460px;
  width: 100%;
  max-height: 95vh;
  overflow: auto;
}

.entry-panel { max-width: 480px; }
/* Even vertical rhythm for the entry / lobby modals. */
.entry-panel { display: flex; flex-direction: column; gap: 12px; }
.entry-panel > * { margin: 0; }
.entry-panel form { display: flex; flex-direction: column; gap: 10px; }
.entry-panel form label { margin: 0; }
.entry-panel h4 { margin: 4px 0 0; color: #fff; }

#entry-room-id { color: #fff; }

.logo {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 1.6667rem;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--chrome-shadow);
  margin: 0 0 8px;
}

h1 { text-transform: uppercase; }
h1, h4, legend, .stage-dock-label { font-family: var(--pixel); }
h4 { font-size: 0.9444rem; color: #fff; padding: 16px 0 6px; letter-spacing: 1px; }
/* Manage Space tabs: a dashed rule between sections, matching the Objects
   list's own dashed dividers — skipped above the first section in a tab. */
.tab-pane h4 { border-top: 1px dashed var(--border); margin-top: 8px; }
.tab-pane h4:first-of-type { border-top: none; margin-top: 0; }
hr {
  border: none; border-bottom: 2px solid var(--border); padding: 12px 0;
}

.muted { color: var(--muted); line-height: 1.6; }
.tiny  { font-size: 0.8889rem; }
.hint  { color: var(--accent-2); min-height: 1.2em; font-size: 0.8333rem; }
.error { color: var(--danger); font-size: 0.8333rem; }

/* ---------- Forms ------------------------------------------------------- */
form label,
.avatar-controls label {
  display: block;
  margin: 10px 0;
  font-family: var(--term);
  font-size: 0.8889rem;
  color: var(--muted);
  letter-spacing: 0.5px;
}

/* Text inputs + selects share the button box model: same padding-y, border,
   font-size and line-height, so a field and a button line up pixel-for-pixel. */
input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=search], input[type=date], input[type=time],
textarea, select {
  width: 100%;
  margin-top: 6px;
  padding: 8px 14px;
  background: var(--chrome-input);
  color: var(--ink);
  border: 2px solid var(--border);
  font-family: var(--term);
  font-size: 0.9444rem;
  line-height: 1.2;
}
/* Drop the native select chrome so it's the exact same box (and height) as a
   text input; draw our own chevron. */
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%238a93a8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
input[type=color] {
  width: 100%; height: 42px; margin-top: 6px; padding: 2px;
  background: var(--chrome-input); border: 2px solid var(--border);
}
textarea { resize: vertical; }
/* Generic label + field pairing for plain form modals (agenda, etc.) — same
   label style as the avatar nickname field, just not avatar-specific. */
.field-label {
  display: block; margin: 0;
  font-family: var(--term); font-size: 0.8889rem; color: var(--muted); letter-spacing: 0.5px;
}
input:focus, select:focus, button:focus-visible, a.btn-primary:focus-visible,
a.btn-secondary:focus-visible, a.btn-tertiary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Buttons — one size, three emphasis tiers -------------------- */
/*   primary   → solid accent fill                                          */
/*   secondary → outlined (accent border, no fill)                          */
/*   tertiary  → bare text button (no fill, no outline)                     */
/*   + optional .danger / .warn colour modifiers on any tier.               */
.btn-primary, .btn-secondary, .btn-tertiary {
  display: inline-block;
  padding: 8px 22px;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.9444rem;
  line-height: 1.2;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  background: none;
  color: var(--accent);
  border: 2px solid transparent;
  border-radius: 4px;
}
.btn-primary   { background: var(--accent); border-color: var(--accent); color: #1a1400; }
.btn-secondary { border-color: var(--accent); }

.btn-primary:hover, .btn-secondary:hover { filter: brightness(1.08); }
.btn-tertiary:hover { background: var(--panel-2); }
.btn-primary:active, .btn-secondary:active { transform: translateY(2px); }
.btn-secondary.active { background: var(--warn); border-color: var(--warn); color: #2a1400; }
.btn-tertiary:active { transform: translateY(1px); }

/* Semantic colour — combine with any tier. */
.btn-primary.danger { background: var(--danger); border-color: var(--danger); color: #2a0000; }
.btn-primary.warn   { background: var(--warn);   border-color: var(--warn);   color: #2a1400; }
.btn-secondary.danger, .btn-tertiary.danger { border-color: var(--danger); color: var(--danger); }
.btn-secondary.warn,   .btn-tertiary.warn   { border-color: var(--warn);   color: var(--warn); }
.btn-primary.danger, .btn-primary.warn { box-shadow: none; }

.btn-primary:disabled, .btn-secondary:disabled, .btn-tertiary:disabled,
.btn-primary[disabled], .btn-secondary[disabled], .btn-tertiary[disabled] {
  opacity: 0.45; cursor: not-allowed; filter: none; transform: none;
}

/* ---------- Entry / lobby modals ------------------------------------- */
/* CTAs: bottom row, right-aligned — back sits alongside the primary button. */
.entry-cta { justify-content: flex-end; align-items: stretch; margin-top: 6px; flex-wrap: wrap; }
.entry-cta .btn-primary,
.entry-cta .btn-secondary,
.entry-cta .btn-tertiary,
.entry-cta a { flex: 0 0 auto; min-width: 132px; }

/* Three choices (Not now / Mic only / Cam & mic) need to share one row. */
#permission-modal .entry-cta { justify-content: flex-end; gap: 6px; }
#permission-modal .entry-cta button { min-width: 0; padding-left: 14px; padding-right: 14px; }

/* "Art & licences" sits apart from the action buttons. */
.credits-btn { margin-right: auto; min-width: 0 !important; }
.credits-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.credits-list li { padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 0.8889rem; }
.credits-list li:last-child { border-bottom: none; }
.rules-list { list-style: none; margin: 4px 0 0; padding: 0; }
.rules-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.8889rem; line-height: 1.4; }
.rules-list li:last-child { border-bottom: none; }

/* Readable text links inside panels (browser-default blue is invisible on dark). */
.panel p a, .credits-list a {
  color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px;
}
.panel p a:hover, .credits-list a:hover { color: var(--ink); }

/* ---------- Avatar editor --------------------------------------------- */
.avatar-editor { border: 2px solid var(--border); padding: 12px; margin-top: 10px; }
.avatar-editor legend { font-size: 0.8333rem; color: var(--accent); padding: 0 6px; }
.avatar-preview-wrap {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: var(--chrome-input); border: 2px solid var(--border);
  padding: 6px; margin-bottom: 10px;
}
.avatar-rand-link {
  background: none; border: none; margin-top: 2px; padding: 2px 4px;
  color: var(--accent); font-family: var(--term); font-size: 0.8333rem;
  text-transform: none; letter-spacing: 0.5px; cursor: pointer; text-decoration: underline;
}
.avatar-rand-link:hover { color: var(--ink); }

#avatar-preview, #avatar-preview-2 { image-rendering: pixelated; display: block; }
.avatar-controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
}

/* Preview on the left, customisation in 3 columns on the right. */
.avatar-wide { max-width: 820px; }
.avatar-layout { display: flex; gap: 16px; align-items: flex-start; margin-top: 4px; }
.avatar-layout .avatar-preview-wrap { flex: 0 0 auto; margin-bottom: 0; position: sticky; top: 0; }
.avatar-layout .avatar-controls {
  flex: 1 1 auto; grid-template-columns: repeat(3, 1fr); gap: 6px 12px;
}

/* Left column of the edit-avatar modal: preview + nickname + a vertical key
   list. Fixed narrow width so the customisation grid on the right gets most of
   the space; the preview height + gap are tuned so the nickname field lines up
   with the "Hat" dropdown row. */
.avatar-layout .avatar-preview-col {
  flex: 0 0 190px; position: sticky; top: 0;
  display: flex; flex-direction: column; gap: 16px;
}
.avatar-layout .avatar-preview-col .avatar-preview-wrap { position: static; }
/* Nickname field — same label + box style as the dropdowns on the right. */
.avatar-name-field {
  display: block; margin: 8px 0;
  font-family: var(--term); font-size: 0.8889rem; color: var(--muted); letter-spacing: 0.5px;
}
.controls-list { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.controls-list > div { display: flex; align-items: baseline; gap: 8px; }
.controls-list dt {
  font-family: var(--pixel); font-size: 0.7778rem; color: var(--ink);
  background: var(--panel-2); border: 2px solid var(--border); box-shadow: 0 2px 0 var(--chrome-shadow);
  padding: 2px 7px; min-width: 58px; text-align: center; white-space: nowrap;
}
.controls-list dd { margin: 0; color: var(--muted); font-size: 0.7778rem; }

.row-buttons { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; flex-wrap: wrap; }
/* Avatar modal actions — pinned bottom-right, not stretched. */
.avatar-actions { justify-content: flex-end; }
.avatar-actions .btn-primary,
.avatar-actions .btn-secondary,
.avatar-actions .btn-tertiary { flex: 0 0 auto; }

/* Raised-hand roster, top-right */
.hand-list {
  position: absolute; top: 10px; right: 10px; z-index: 22; pointer-events: none;
  background: var(--panel); border: 2px solid var(--accent-2);
  box-shadow: 0 0 0 3px var(--chrome-shadow);
  padding: 8px 12px; min-width: 150px; max-width: 240px;
}
.hand-list .hl-head { font-family: var(--pixel); font-size: 0.7778rem; color: var(--accent-2); margin-bottom: 5px; }
.hand-list .hl-name { font-family: var(--term); font-size: 0.8889rem; line-height: 1.3; color: var(--ink); }
/* nudge the right-hand sidebars down so the hand list has room */
body.has-hands #chat-sidebar,
body.has-hands #admin-sidebar { top: 120px; }

/* ---------- HUD ------------------------------------------------------- */
/* z-index 23, not 20 — #context-menu lives inside #hud, and its own
   z-index:40 only wins within #hud's stacking context; #hud itself still
   needs to clear .self-cam's z-index:22 (a body-level sibling, outside
   #hud) or the whole menu paints underneath it regardless. */
#hud { position: fixed; inset: 0; z-index: 23; pointer-events: none; }
#hud .host-only { display: none; }
#hud.is-host .host-only { display: flex; }

/* Bottom action bar */
.action-bar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 4px; align-items: stretch;
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: 0 0 0 3px var(--chrome-shadow);
  padding: 6px; pointer-events: auto;
  max-width: 96vw; overflow-x: auto;
  border-radius: 6px;
}
.ab-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 56px; height: 56px; padding: 6px 4px;
  background: var(--panel-2); border: 2px solid var(--border);
  color: var(--ink); font-size: 0.8889rem; line-height: 1;
  border-radius: 4px;
}
.ab-btn .ab-label { font-size: 0.8333rem; font-weight: 700; text-transform: uppercase; font-family: var(--term); color: var(--muted); letter-spacing: 0.5px; }
.ab-btn:hover { background: var(--border); }
a.ab-btn { text-decoration: none; }
/* Chunky low-res emoji so they sit with the pixel styling — the emoji is
   redrawn onto a small canvas by pixelateEmoji() and upscaled with hard pixels. */
.ab-emoji { display: inline-flex; line-height: 1; padding-bottom: 4px; }
.ab-emoji canvas { display: block; image-rendering: pixelated; }
.ab-btn.active { background: var(--accent-2); border-color: var(--accent-2); color: #06251d; }
.ab-btn.active .ab-label {color: #06251d; }
.ab-btn.danger { background: var(--danger); border-color: var(--danger); color: #2a0000; }
.ab-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ab-sep { display: block; width: 2px; background: var(--border); margin: 4px 3px; }

/* Interaction prompt */
.interact-prompt {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--accent); color: #1a1400;
  font-family: var(--pixel); font-size: 1rem;
  padding: 8px 12px; border: 2px solid #1a1400;
  pointer-events: none; white-space: nowrap;
}

/* Toast */
.toast {
  background: var(--panel); border: 2px solid var(--accent);
  color: var(--ink); font-family: var(--pixel); font-size: 1rem;
  padding: 10px 14px; pointer-events: none; max-width: 90vw; text-align: center;
}
/* The toast itself stays click-through (see pointer-events above) so it never
   blocks the map underneath — a link inside it opts back in. */
.toast a { pointer-events: auto; color: var(--accent-2); text-decoration: underline; cursor: pointer; }

/* FIFA-style goal celebration — full-screen flash + a huge bouncing banner. */
.goal-banner {
  position: absolute; inset: 0; z-index: 300; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0); transition: background 0.5s ease-out;
}
.goal-banner.show { background: rgba(10, 8, 4, 0.4); }
.goal-banner-text {
  font-family: var(--pixel); font-weight: bold; letter-spacing: 3px;
  font-size: clamp(2.6667rem, 10vw, 6.6667rem); color: #ffd23f;
  text-shadow: 0 8px 0 #7a1c10, 0 0 40px rgba(255, 140, 20, 0.85), 0 0 80px rgba(255, 210, 63, 0.5);
  transform: scale(0); opacity: 0;
  text-transform: uppercase;
}
.goal-banner.show .goal-banner-text { animation: goal-pop 2.2s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes goal-pop {
  0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
  45%  { transform: scale(1.2) rotate(3deg); opacity: 1; }
  62%  { transform: scale(0.92) rotate(-2deg); }
  78%  { transform: scale(1.06) rotate(1deg); }
  90%  { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 0; }
}

/* Stage video dock */
.stage-dock {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px var(--chrome-shadow);
  padding: 6px; pointer-events: auto; max-width: 92vw;
}
.stage-dock-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.stage-dock-label { font-size: 0.7222rem; color: var(--accent); letter-spacing: 1px; }
.grid-view-btn {
  background: transparent; border: 2px solid var(--accent); color: var(--accent);
  font-size: 0.6111rem; padding: 2px 8px; letter-spacing: 0.5px;
}
.grid-view-btn:hover { background: var(--accent); color: var(--chrome-video); }
/* Tiles never wrap — once they overflow the dock's max-width, scroll sideways
   instead (Grid view is the escape hatch for "see everyone at once"). */
.stage-tiles { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
.stage-tiles::-webkit-scrollbar { height: 6px; }
.stage-tiles::-webkit-scrollbar-thumb { background: var(--accent); }
.stage-tiles::-webkit-scrollbar-track { background: transparent; }
.stage-tiles .tile {
  position: relative; width: 160px; height: 90px; flex: 0 0 auto;
  background: var(--chrome-video); border: 2px solid var(--border); overflow: hidden;
}
.stage-tiles .tile.screen { width: 240px; }
.stage-tiles video, .dock-cam-portrait { width: 100%; height: 100%; object-fit: cover; background: var(--chrome-video); }
.stage-tiles video[hidden], .dock-cam-portrait[hidden] { display: none; }
.stage-tiles .cap {
  position: absolute; left: 0; bottom: 0; right: 0;
  display: flex; align-items: center; gap: 3px;
  font-family: var(--pixel); font-size: 0.6667rem; background: rgba(0,0,0,0.7);
  padding: 2px 4px; color: var(--ink);
}
.dock-mic-icon, .grid-cam-mic-icon { display: inline-flex; flex: 0 0 auto; color: var(--ink); }
.dock-mic-icon.muted, .grid-cam-mic-icon.muted { color: var(--danger); }
.stage-tiles .muted-dot { position: absolute; top: 3px; right: 3px; font-size: 0.6667rem; }
/* Grow the SPEAKERS dock while in a huddle. */
.stage-dock.huddle .stage-tiles .tile { width: 200px; height: 112px; }
.stage-dock.huddle .stage-tiles .tile.screen { width: 300px; }

/* Grid view: full-screen takeover of every camera in the huddle, Teams/Meet
   style — the escape hatch once a huddle outgrows the top dock. */
#cam-grid-overlay {
  position: fixed; inset: 0; z-index: 500; background: rgba(5, 7, 12, 0.97);
  display: flex; flex-direction: column; padding: 20px; pointer-events: auto;
}
#cam-grid-overlay[hidden] { display: none; }
.cam-grid-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex: 0 0 auto;
}
.cam-grid-head h3 { font-family: var(--pixel); font-weight: 700; color: var(--accent); font-size: 1.1111rem; letter-spacing: 1px; }
.cam-grid {
  flex: 1; display: grid; gap: 14px; overflow-y: auto;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: start;
}
.cam-grid .tile {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: var(--chrome-video); border: 2px solid var(--border); overflow: hidden;
}
.cam-grid .tile video { width: 100%; height: 100%; object-fit: cover; background: var(--chrome-video); }
.cam-grid .tile .cap {
  position: absolute; left: 0; bottom: 0; right: 0;
  font-family: var(--pixel); font-size: 0.7778rem; background: rgba(0,0,0,0.7);
  padding: 4px 6px; color: var(--ink);
}

/* Sidebars */
.sidebar {
  position: absolute; top: 10px; right: 10px; bottom: 92px; width: 390px; max-width: calc(100vw - 20px);
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: 0 0 0 3px var(--chrome-shadow);
  display: flex; flex-direction: column; pointer-events: auto;
  overflow: hidden;
}
.sidebar header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; row-gap: 4px;
  font-family: var(--pixel); font-weight: 700; font-size: 1.1111rem; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 12px;
}
/* Give the first control breathing room below the header. */
.sidebar .admin-block { padding: 16px 12px 12px; }
.sidebar .x, .object-header .x {
  background: transparent; border: none; color: var(--muted);
  font-size: 1rem; line-height: 1; font-family: var(--term);
}
.sidebar h4:first-of-type { margin-top: 6px; }
.sidebar > *:not(header) { padding: 0 10px; }
.sidebar ol, .sidebar ul { overflow-y: auto; }

/* ---- Manage Space: tabbed, single-scroll body --------------------------- */
.tab-bar { display: flex; gap: 4px; margin: 4px 0 10px; border-bottom: 2px solid var(--border); }
.tab-btn {
  flex: 1; padding: 9px 0px; cursor: pointer;
  margin-bottom: -2px;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  font-family: var(--pixel); font-weight: 700; font-size: 0.8333rem; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

#admin-sidebar .admin-scroll { flex: 1; overflow-y: auto; padding-top: 12px; padding-bottom: 16px; }
#admin-sidebar .admin-scroll ul { overflow: visible; }
/* Tight gap within a section; a bigger margin above each heading pushes the
   sections apart so a title reads as belonging to the content right below it. */
#admin-sidebar .tab-pane { display: flex; flex-direction: column; gap: 7px; }
#admin-sidebar .tab-pane[hidden] { display: none; }
#admin-sidebar .tab-pane h4 { padding: 16px 0 0 0; margin: 16px 0 0 0; }
#admin-sidebar .tab-pane > :first-child { margin-top: 0; }
#admin-sidebar .tab-pane .admin-block { padding: 0; }
#admin-sidebar .tab-pane .user-list,
#admin-sidebar .tab-pane .object-list { padding: 0; margin: 0; }

/* Any "field + button" row: the field must have no margin of its own, or
   align-items: stretch can't make it exactly match the button's height. */
.admin-linkrow { display: flex; gap: 6px; align-items: stretch; }
.admin-linkrow code {
  flex: 1; min-width: 0; font-family: var(--term); font-size: 0.8889rem;
  background: var(--chrome-input); border: 2px solid var(--border);
  padding: 9px 12px; overflow-x: auto; white-space: nowrap;
}
.admin-linkrow input { flex: 1; min-width: 0; margin: 0; }
.admin-linkrow .btn-secondary { flex: 0 0 auto; }

/* ---------- Map theme picker (Customise tab) ----------------------- */
.theme-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-swatch {
  display: flex; align-items: center; gap: 6px;
  background: var(--chrome-input); border: 2px solid var(--border); color: var(--muted);
  font-family: var(--term); font-size: 0.8333rem; text-transform: none; letter-spacing: 0.5px;
  padding: 6px 10px; cursor: pointer;
}
.theme-swatch:hover { color: var(--ink); border-color: var(--muted); }
.theme-swatch.active { color: var(--ink); border-color: var(--accent); }
.theme-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.35); }

/* ---------- Room chat ----------------------------------------------- */
.chat-log { list-style: none; margin: 8px 0; padding: 0 10px; flex: 1; }
.chat-log li { position: relative; margin: 4px 0 12px; padding-right: 20px; font-size: 0.8889rem; line-height: 1.5; word-break: break-word; transition: background-color 0.4s ease; border-radius: 4px; }
.chat-log .c-del {
  position: absolute; top: 0; right: 0;
  background: none; border: none; color: var(--muted); font-family: var(--term);
  font-size: 0.7778rem; line-height: 1; padding: 2px; cursor: pointer; opacity: 0; transition: opacity 0.1s;
}
.chat-log li:hover .c-del { opacity: 1; }
.chat-log .c-del:hover { color: var(--danger); }
.chat-log .c-name { color: var(--accent-2); font-family: var(--pixel); font-weight: 700; font-size: 0.8889rem; margin-right: 6px; }
.chat-log li.me .c-name { color: var(--accent); }
.chat-log li.bot { padding: 4px 6px; margin: 8px -6px; }
.chat-log li.bot .c-name { color: #ffd23f; }
.chat-log li.bot strong { color: var(--accent-2); }
.chat-log .c-time { color: var(--muted); font-family: var(--term); font-size: 0.6667rem; margin-right: 6px; }
.chat-log a { color: var(--accent); word-break: break-all; }
/* New messages that arrived while chat was closed, until it's opened
   (markChatRead removes this the same moment it clears the ab-count badge). */
.chat-log li.unread { background: rgba(255, 255, 255, 0.08); padding: 4px 6px 4px 6px; margin: 4px -6px 12px; }
.chat-log a.matebot-agenda-link { font-weight: bold; word-break: normal; }
/* ---------- Icebreaker poll (top of chat) -------------------------- */
.sidebar .poll-box {
  list-style: none; margin: 4px 0 12px; padding: 12px 12px 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--border); border-radius: 4px;
}
.poll-top { display: flex; align-items: center; justify-content: space-between; }
.poll-tag {
  font-family: var(--pixel); font-weight: 700; font-size: 0.8333rem; letter-spacing: 1px;
  text-transform: uppercase; color: var(--accent-2);
}
.poll-tools { display: flex; gap: 4px; }
.poll-mini {
  background: transparent; border: 2px solid var(--border); color: var(--muted);
  font-family: var(--term); font-size: 0.7778rem; line-height: 1; padding: 3px 7px;
  border-radius: 3px; cursor: pointer;
}
.poll-mini:hover { color: var(--ink); border-color: var(--accent-2); }
.poll-q { margin: 6px 0 10px; padding: 0; color: var(--muted); font-size: 0.8889rem; }
.poll-opts { display: flex; flex-direction: column; gap: 8px; }
.poll-opt {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font-family: var(--term); font-size: 0.8889rem; color: var(--ink); text-transform: none;
  background: var(--chrome-input); border: 2px solid var(--border); border-left-width: 5px;
  padding: 10px 12px; border-radius: 3px; transition: transform .08s, border-color .12s, background .12s;
}
.poll-opts .poll-opt:nth-child(1) { border-left-color: var(--accent); }
.poll-opts .poll-opt:nth-child(2) { border-left-color: var(--accent-2); }
.poll-opt:hover { background: #151b16; transform: translateX(2px); }

.poll-results { margin-top: 10px; }
.poll-res { padding: 2px 0; }
.poll-res + .poll-res { margin-top: 10px; }
.poll-res-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.poll-res-label { flex: 1; min-width: 0; font-size: 0.8889rem; color: var(--ink); }
.poll-res-pct { flex: 0 0 auto; white-space: nowrap; font-family: var(--pixel); font-size: 0.8889rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.poll-bar {
  margin: 5px 0 3px; height: 14px; background: var(--chrome-input);
  border: 2px solid var(--border); border-radius: 3px; overflow: hidden;
}
.poll-bar-fill {
  display: block; height: 100%; min-width: 2px;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.14) 0 6px, transparent 6px 12px);
  background-color: var(--accent);
  transition: width .6s cubic-bezier(.22, 1, .36, 1);
}
.poll-bar-b { background-color: var(--accent-2); }
.poll-res-count { font-family: var(--term); font-size: 0.8889rem; color: var(--muted); }
.poll-mine-tag { color: var(--accent-2); white-space: nowrap; }
.poll-res.is-mine .poll-bar { border-color: var(--accent-2); }
.poll-res.is-lead .poll-res-pct { color: var(--ink); font-weight: 700; }
.poll-foot { margin: 10px 0 0; padding: 0; font-size: 0.8889rem; color: var(--muted); }

.sidebar .chat-form { display: flex; gap: 6px; align-items: stretch; padding: 8px 10px 12px; border-top: 2px solid var(--border); }
.sidebar .chat-form input { flex: 1; margin: 0; min-width: 0; }
.sidebar .chat-form .btn-primary { flex: 0 0 auto; padding: 9px 16px; }
.ab-dot {
  position: absolute; top: 2px; right: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); border: 1px solid #2a0000;
}
.ab-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #2a0000;
  font-family: var(--pixel); font-size: 0.6111rem;
  padding: 2px 3px; border: 1px solid #2a0000; border-radius: 2px;
}
.ab-btn { position: relative; }
/* A button carrying a notification dot/count gets a lighter red outline
   than the badge itself, so the darker badge still pops against it. */
.ab-btn:has(.ab-dot), .ab-btn:has(.ab-count) { border-color: #ff9d9d; }

/* ---------- Auditorium-only controls + status pills ---------------- */
#hud .aud-only { display: none; }
#hud.in-auditorium .aud-only { display: flex; }
#hud.in-auditorium .aud-hide { display: none; }
/* Status pills + toasts all stack vertically in one place instead of each
   claiming the same top-center spot — see #hud-top-stack. */
#hud-top-stack {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 26; pointer-events: none;
}
.mode-pill {
  background: var(--panel); border: 2px solid var(--accent-2); color: var(--ink);
  font-family: var(--pixel); font-size: 1rem; padding: 7px 12px; pointer-events: none;
  white-space: nowrap;
}
.mode-pill.live { border-color: var(--danger); color: var(--danger); }

/* "Broadcast to everyone" — persistent while a host is on the PA. */
.announce-pill {
  background: var(--panel); border: 2px solid var(--warn); color: var(--warn);
  font-family: var(--pixel); font-size: 1rem; padding: 7px 12px; pointer-events: none;
  white-space: nowrap;
}

/* ---------- Screen-share window (draggable + resizable) ------------ */
.screen-window {
  position: fixed; top: 60px; right: 16px; width: 480px; height: 300px;
  z-index: 40; background: var(--chrome-video);
  border: 3px solid var(--accent); box-shadow: 0 0 0 3px var(--chrome-shadow), 6px 6px 0 rgba(0,0,0,0.5);
  display: flex; flex-direction: column; pointer-events: auto;
}
.sw-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border-bottom: 2px solid var(--border);
  font-family: var(--pixel); font-size: 0.7778rem; color: var(--accent);
  padding: 6px 8px; cursor: move; touch-action: none; user-select: none;
}
.sw-close { background: transparent; border: none; color: var(--muted); font-size: 0.8889rem; font-family: var(--term); cursor: pointer; }
.screen-window video { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: var(--chrome-video); }
.sw-resize {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 45%, var(--accent) 45%, var(--accent) 60%, transparent 60%);
}

/* ---------- Screen-share takeover ---------------------------------- */
/* While someone shares, the window fills most of the viewport and the
   sharer's camera is pinned to the left. */
body.screen-sharing .screen-window {
  top: 14px; bottom: 96px; left: 250px; right: 14px;
  width: auto; height: auto;
}
/* Leave room for the open chat sidebar instead of running underneath it. */
body.screen-sharing.chat-open .screen-window { right: 416px; }
body.screen-sharing.im-presenting .self-cam { display: none; } /* your own is redundant */
/* The SPEAKERS dock now doubles as "who's watching this share with you" —
   push the status-pill stack below it so they don't overlap. */
#stage-dock:not([hidden]) ~ #hud-top-stack { top: 150px; }

.presenter-cam {
  position: fixed; left: 14px; top: 88px; z-index: 41;
  width: 224px; height: 168px;
  background: var(--chrome-video); border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px var(--chrome-shadow);
  pointer-events: none; overflow: hidden;
}
.presenter-cam video { width: 100%; height: 100%; object-fit: cover; }
.presenter-cam-label {
  position: absolute; left: 0; bottom: 0;
  font-family: var(--pixel); font-size: 0.7222rem;
  background: rgba(0,0,0,0.7); color: var(--ink); padding: 3px 6px;
}

/* ---------- Self camera (bottom-left) ------------------------------- */
.self-cam {
  position: fixed; left: 12px; bottom: 84px; z-index: 22;
  width: 168px; height: 126px;
  background: var(--chrome-video); border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px var(--chrome-shadow);
  pointer-events: auto; overflow: hidden; cursor: context-menu;
}
.self-cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self-cam-portrait { display: none; width: 100%; height: 100%; }
/* Camera off: show the avatar portrait canvas instead of the (stopped) video. */
.self-cam.cam-off video { display: none; }
.self-cam.cam-off .self-cam-portrait { display: block; }
.self-cam-label {
  position: absolute; left: 0; bottom: 2px;
  display: flex; align-items: center; gap: 3px;
  font-family: var(--pixel); font-size: 0.6667rem;
  background: rgba(0,0,0,0.7); color: var(--ink); padding: 2px 4px;
}
.self-cam-mic-icon { display: inline-flex; color: var(--ink); }
.self-cam-mic-icon.muted { color: var(--danger); }

.admin-block { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

/* Room-expiry countdown + extend link, sitting in the Manage Space header. */
.admin-head-right { display: flex; align-items: center; gap: 10px; }
.admin-head-right .expiry-countdown {
  font-family: var(--term); font-size: 0.8333rem; letter-spacing: 0.5px;
  color: var(--muted); text-transform: none;
}
.link-btn {
  background: none; border: none; padding: 0;
  font-family: var(--term); font-size: 0.8333rem; letter-spacing: 0.5px;
  color: var(--accent); text-transform: none; text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--ink); }
.switch-row { display: flex; gap: 8px; align-items: center; font-family: var(--term); font-size: 0.8333rem; color: var(--ink); }

.user-list, .object-list { list-style: none; margin: 0 0 10px; padding: 0 10px 10px; }
.user-list li {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  padding: 6px 0; font-size: 0.8889rem;
}
.user-list .u-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-list .u-name .badge { color: var(--accent); font-size: 0.7778rem; }
.u-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px;
  font-family: var(--term); font-size: 0.6667rem; letter-spacing: 0.3px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--panel-2);
  pointer-events: none; user-select: none;
}
.u-status.u-idle { color: var(--muted); }
.u-status.u-active { color: var(--accent-2); border-color: var(--accent-2); }
/* Admin participant rows: name on its own line, actions as a line of links below. */
#admin-user-list li { flex-wrap: wrap; gap: 4px; align-items: flex-start; }
#admin-user-list .u-name { flex: 1 0 100%; white-space: normal; }
#admin-user-list .u-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; flex: 1 0 100%; }
#admin-user-list .u-actions .link-btn.danger { color: var(--danger); }

.object-list li { padding: 24px 0; border-bottom: 1px dashed var(--border); }
.object-list li:first-child { padding-top: 0; }
.object-list .o-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.object-list .o-type { font-size: 0.7222rem; text-transform: uppercase; letter-spacing: 1px; }
.object-list .o-remove { color: var(--danger); text-transform: none; letter-spacing: 0.5px; }
.object-list li.o-disabled .o-remove { color: var(--accent); }
.object-list .o-name { width: 100%; margin-bottom: 6px; }
.object-list .o-row { display: flex; gap: 6px; margin-top: 6px; align-items: stretch; }
.object-list .o-row input { flex: 1; min-width: 0; margin: 0; }
.object-list .o-row .btn-secondary { flex: 0 0 auto; }
.object-list li.o-disabled .o-name,
.object-list li.o-disabled .o-row { opacity: 0.5; }

/* The guest-facing Agenda modal isn't a sidebar tab — its list should line
   up flush with the modal's own title, not carry the sidebar's side padding. */
#agenda-view-list { padding: 0; margin: 0; }

/* Agenda items reuse the object-list rhythm (dashed dividers, o-head layout). */
.agenda-time { font-size: 0.7222rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); white-space: nowrap; }
.agenda-title { font-family: var(--pixel); font-size: 0.8333rem; }
.agenda-desc { margin: 4px 0 0; color: var(--muted); font-size: 0.8333rem; }
.agenda-empty { color: var(--muted); padding: 12px 0; }
.agenda-now-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px; margin-left: 2px;
  font-family: var(--term); font-size: 0.6667rem; letter-spacing: 0.3px;
  color: var(--accent-2); border: 1px solid var(--accent-2); background: var(--panel-2);
  vertical-align: middle;
}

.banner-preview {
  border: 1px dashed var(--border); border-radius: 6px; padding: 6px;
  display: flex; justify-content: center;
  background:
    repeating-conic-gradient(#0003 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}
.banner-preview img {
  display: block; width: auto; max-width: 100%; max-height: 150px; height: auto;
  image-rendering: pixelated;
}
.banner-error { color: var(--danger); }

/* ---------- Landing page --------------------------------------------- */
/* Plain black for now — this page is getting a full SaaS-style redesign later. */
.landing-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100%; padding: 24px 16px;
  background: #000;
}
.landing-panel { max-width: 460px; display: flex; flex-direction: column; gap: 10px; }
.landing-panel > * { margin: 0; }
.landing-panel h4 { margin: 6px 0 0; }
.landing-panel h4:first-of-type { margin-top: 6px; }
.landing-panel .created .btn-primary { margin-top: 4px; }
.landing-panel .user-list { max-height: 42vh; overflow-y: auto; padding: 0; }
.landing-panel .user-list li .btn-secondary { flex: 0 0 auto; }

.created { border: 2px solid var(--accent-2); padding: 16px 12px; margin: 6px 0 4px; }
.created-row { display: flex; gap: 6px; align-items: stretch; margin: 6px 0 10px; }
.created-row code {
  flex: 1; min-width: 0; font-family: var(--term); font-size: 0.8333rem;
  background: var(--chrome-input); border: 2px solid var(--border);
  padding: 9px 12px; overflow-x: auto; white-space: nowrap;
}
.created-row .btn-secondary { flex: 0 0 auto; }

/* Context menu */
.context-menu {
  /* Higher than any overlay in the app (the huddle grid's is the highest,
     at 500) — now a body-level element (see index.html), so this always
     has to win outright, not just within some ancestor's own context. */
  position: absolute; z-index: 600; min-width: 150px;
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.6);
  pointer-events: auto;
}
.context-menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; font-size: 0.7778rem;
  text-transform: none;
  background: transparent; border: none; color: var(--ink);
}
.context-menu button:hover { background: var(--accent); color: #1a1400; }
.context-menu .cm-title {
  padding: 8px 12px; font-family: var(--pixel); font-size: 0.7778rem;
  color: var(--accent); border-bottom: 2px solid var(--border);
}

/* Object iframe modal */
.object-panel { max-width: 1400px; width: 95vw; height: 95vh; display: flex; flex-direction: column; padding: 0; }
.object-header {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--pixel); font-weight: 700; font-size: 1.1111rem; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 12px;
}

.object-header.no-padding { padding: 0; }
.object-header .open-tab-btn { font-size: 0.7222rem; padding: 5px 10px; margin-right: 6px; }
.object-header-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.object-title-status { display: flex; align-items: center; gap: 6px; min-width: 0; }
#object-title-status-text {
  font-family: var(--term); font-size: 0.7778rem; font-weight: 400; text-transform: none; letter-spacing: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px;
}
#object-title-status-text.is-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
#object-title-status-text.is-link:hover { color: var(--ink); }
.icon-btn {
  background: none; border: none; padding: 2px; margin: 0; line-height: 0; cursor: pointer;
  color: var(--muted); opacity: 0.7;
}
.icon-btn:hover { opacity: 1; color: var(--ink); }

/* Whoever has this same arcade cabinet / doc embed open shares a cam strip,
   same treatment as an air hockey pair or a Wheel of Fortune table. */
.object-cams {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 0 12px; background: var(--panel-2); border-bottom: 2px solid var(--border);
}
.object-cam-tile { position: relative; width: 150px; height: 120px; flex: 0 0 auto; background: var(--chrome-video); border: 2px solid var(--border); overflow: hidden; }
.object-cam-tile video, .object-cam-tile .oc-cam-portrait { width: 100%; height: 100%; object-fit: cover; }
.object-cam-tile video[hidden], .object-cam-tile .oc-cam-portrait[hidden] { display: none; }
.object-cam-tile .oc-cam-label {
  position: absolute; left: 0; bottom: 0px; right: 0;
  display: flex; align-items: center; gap: 3px;
  font-family: var(--pixel); font-size: 0.75rem; background: rgba(0,0,0,0.7);
  padding: 2px 2px; color: var(--ink);
}
.oc-cam-mic-icon { display: inline-flex; flex: 0 0 auto; color: var(--ink); }
.oc-cam-mic-icon.muted { color: var(--danger); }
.object-cams-names {
  display: flex; gap: 6px 16px; flex-wrap: wrap; justify-content: center;
  padding: 8px 12px; background: var(--panel-2); border-bottom: 2px solid var(--border);
  font-family: var(--pixel); font-size: 0.7778rem; color: var(--muted);
}

/* Dark, not white — a fallback in case some future embed's CSS zoom (see
   ui.js openObjectModal) doesn't fill the frame exactly on every browser;
   matching our own dark chrome there reads as intentional letterboxing
   instead of a broken white gap. */
.object-frame-wrap { flex: 1; background: var(--panel); overflow: hidden; }
#object-frame { display: block; width: 100%; height: 100%; border: 0; }

/* Air hockey modal */
.airhockey-panel { max-width: 1300px; width: 95vw; padding: 0; display: flex; flex-direction: column; }
.airhockey-scoreboard {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 10px 12px; background: var(--panel-2); border-bottom: 2px solid var(--border);
}
.ah-name { font-family: var(--pixel); font-size: 1rem; color: var(--ink); min-width: 90px; text-align: center; }
.ah-score { font-family: var(--pixel); font-size: 1.4444rem; color: var(--accent); letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.airhockey-board-wrap { position: relative; background: var(--chrome-video); display: flex; justify-content: center; padding: 10px; }
#airhockey-canvas { width: 100%; max-width: 1240px; height: auto; border-radius: 12px; cursor: none; display: block; }
.airhockey-winner {
  position: absolute; inset: 10px; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: rgba(5, 7, 12, 0.72); border-radius: 12px;
}
.airhockey-winner-text {
  font-family: var(--pixel); font-weight: bold; font-size: 2.3333rem; letter-spacing: 2px; color: #ffd23f;
  text-shadow: 0 4px 0 #7a1c10, 0 0 30px rgba(255, 140, 20, 0.7);
}
.airhockey-hint { text-align: center; color: var(--muted); font-size: 0.7222rem; padding: 8px 12px 12px; }
.airhockey-cams { display: flex; gap: 10px; justify-content: center; padding: 0px 12px; background: var(--panel-2); border-bottom: 2px solid var(--border); }
.airhockey-cam-tile { position: relative; width: 170px; height: 96px; flex: 0 0 auto; background: var(--chrome-video); border: 2px solid var(--border); overflow: hidden; }
.airhockey-cam-tile video, .airhockey-cam-tile .ah-cam-portrait { width: 100%; height: 100%; object-fit: cover; }
.airhockey-cam-tile video[hidden], .airhockey-cam-tile .ah-cam-portrait[hidden] { display: none; }
.airhockey-cam-tile .ah-cam-label {
  position: absolute; left: 0; bottom: 0px; right: 0;
  display: flex; align-items: center; gap: 3px;
  font-family: var(--pixel); font-size: 0.75rem; background: rgba(0,0,0,0.7);
  padding: 2px 2px; color: var(--ink);
}
.ah-cam-mic-icon { display: inline-flex; flex: 0 0 auto; color: var(--ink); }
.ah-cam-mic-icon.muted { color: var(--danger); }
#airhockey-canvas { transition: width 0.15s ease, height 0.15s ease; }
.airhockey-announce {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 2px solid var(--accent);
  color: var(--ink); font-family: var(--pixel); font-size: 0.8889rem;
  padding: 8px 16px; white-space: nowrap; pointer-events: none;
}

/* Pool table modal — reuses most of the airhockey-* chrome above (cams,
   winner banner, hint), just its own scoreboard/status/canvas wrapper. */
/* Taller than the base .panel cap — the table needs real vertical room for
   the cue's full swing, not just the felt itself. */
#pooltable-modal .airhockey-panel { max-height: 97vh; }
.pooltable-scoreboard { gap: 14px; }
.pooltable-scoreboard .ah-name.pooltable-turn { color: var(--accent); }
.pooltable-side { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pooltable-type { font-family: var(--pixel); font-size: 0.6667rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.5px; min-height: 1em; }
.pooltable-vs { font-family: var(--pixel); font-size: 0.7778rem; color: var(--muted); }
.pooltable-status {
  text-align: center; margin: 0; padding: 8px 12px;
  font-family: var(--pixel); font-size: 0.8889rem; color: var(--accent);
  background: var(--panel-2); border-bottom: 2px solid var(--border);
}
.pooltable-board-wrap { justify-content: center; align-items: center; }
.pooltable-canvas-wrap canvas { display: block; border-radius: 12px; }
.pooltable-canvas-wrap { display: flex; justify-content: center; align-items: center; }

/* Connect 4 modal */
.connect4-panel { max-width: 820px; width: 94vw; padding: 0; display: flex; flex-direction: column; }
.connect4-scoreboard {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 10px 12px; background: var(--panel-2); border-bottom: 2px solid var(--border);
}
.c4-name { font-family: var(--pixel); font-size: 0.8889rem; min-width: 80px; text-align: center; opacity: 0.55; transition: opacity 0.15s ease; }
.c4-name.c4-turn { opacity: 1; }
.c4-name.c4-red { color: #e3342f; }
.c4-name.c4-yellow { color: #ffd23f; }
.c4-turn-label { font-family: var(--pixel); font-size: 0.6667rem; color: var(--muted); min-width: 90px; text-align: center; }
.connect4-board-wrap { position: relative; background: var(--chrome-video); display: flex; justify-content: center; padding: 10px; }
#connect4-canvas { width: 100%; max-width: 740px; height: auto; border-radius: 12px; display: block; cursor: pointer; transition: width 0.15s ease, height 0.15s ease; }
.connect4-winner-text { font-size: 1.8889rem; }

/* DJ booth / club radio modal */
.clubradio-panel { max-width: 760px; width: 92vw; max-height: 88vh; padding: 0; display: flex; flex-direction: column; }
.clubradio-now {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--panel-2); border-bottom: 2px solid var(--border);
}
.clubradio-live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); flex-shrink: 0;
  box-shadow: 0 0 8px var(--accent-2); animation: clubradio-pulse 1.6s ease-in-out infinite;
}
@keyframes clubradio-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.clubradio-now-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.clubradio-now-label { font-family: var(--term); font-size: 0.7222rem; letter-spacing: 1px; text-transform: uppercase; color: var(--accent-2); }
.clubradio-now-genre { font-family: var(--pixel); font-size: 1rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clubradio-now-station { font-size: 0.8333rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clubradio-grid { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.clubradio-category-title { font-family: var(--term); font-size: 0.7222rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.clubradio-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.clubradio-chip {
  background: var(--chrome-input); border: 2px solid var(--border); color: var(--muted);
  font-family: var(--term); font-size: 0.8333rem; letter-spacing: 0.5px;
  padding: 6px 10px; border-radius: 4px; cursor: pointer;
}
.clubradio-chip:hover { color: var(--ink); border-color: var(--muted); }
.clubradio-chip.active { color: var(--ink); border-color: var(--accent); background: rgba(255, 210, 63, 0.12); }

/* Wheel of Fortune modal */
.wf-panel { max-width: 900px; width: 94vw; padding: 0; display: flex; flex-direction: column; position: relative; }
.wf-players {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 0 12px; background: var(--panel-2); border-bottom: 2px solid var(--border);
}
.wf-player {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 110px; border-radius: 6px;
  border: 2px solid transparent; opacity: 0.55; transition: opacity 0.15s ease, border-color 0.15s ease;
}
.wf-player.wf-empty { opacity: 0.3; }
.wf-player.wf-turn { opacity: 1; border-color: var(--accent); }
.wf-player-cam {
  position: relative; width: 140px; height: 105px; border-radius: 4px; overflow: hidden;
  background: var(--chrome-video); border: 2px solid var(--border);
}
.wf-player-cam video, .wf-cam-portrait { width: 100%; height: 100%; object-fit: cover; }
.wf-player-cam video[hidden], .wf-cam-portrait[hidden] { display: none; }
/* Top-left score badge and bottom name/mic bar — same overlay-on-the-cam
   treatment as every other cam tile in the app (object-cams, air hockey,
   pool, Connect 4), for a consistent look across all the game modals. */
.wf-cam-score {
  position: absolute; top: 4px; left: 4px;
  font-family: var(--pixel); font-weight: 700; font-size: 0.8333rem;
  color: #1a1400; background: var(--accent); padding: 2px 6px; border-radius: 3px;
  font-variant-numeric: tabular-nums;
}
.wf-cam-label {
  position: absolute; left: 0; bottom: 0; right: 0;
  display: flex; align-items: center; gap: 4px;
  font-family: var(--pixel); font-size: 0.7222rem; background: rgba(0,0,0,0.7);
  padding: 3px 5px; color: var(--ink);
}
.wf-mic-icon { display: inline-flex; flex: 0 0 auto; color: var(--ink); }
.wf-mic-icon.muted { color: var(--danger); }
.wf-empty-label { font-family: var(--pixel); font-size: 0.7778rem; color: var(--muted); }

.wf-board {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: 10px 10px; padding: 16px 12px; background: var(--chrome-video);
}
.wf-word { display: inline-flex; gap: 3px; }
.wf-tile {
  width: 24px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-family: var(--pixel); font-size: 1rem; font-weight: bold; border-radius: 3px;
}
.wf-tile-blank { background: #1a221b; border: 2px solid var(--border); }
.wf-tile-filled { background: #f4f6fb; color: #14171c; border: 2px solid #c8cede; }
.wf-tile-punct { background: transparent; border: none; color: var(--muted); width: auto; min-width: 10px; }

.wf-main { display: flex; flex-direction: column; align-items: stretch; gap: 18px; padding: 14px 16px; }
.wf-wheel-col { flex: 0 0 auto; display: flex; justify-content: center; }
.wf-wheel-outer {
  --wheel-size: min(560px, 78vw);
  display: grid; grid-template-areas: "stack"; place-items: center;
  font-size: calc(var(--wheel-size) / 14); position: relative;
}
.wf-wheel-outer > * { grid-area: stack; position: relative; }
.wf-ticker {
  --tsize: 0.9em;
  place-self: center end;
  margin-inline-end: calc((var(--tsize) - 0.1em) * -1);
  background: #fff;
  width: var(--tsize); height: calc(var(--tsize) / 2);
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
  z-index: 2;
}
.wf-wheel {
  display: grid; place-items: center; overflow: hidden; grid-template-areas: "stack";
  inline-size: var(--wheel-size); block-size: var(--wheel-size); border-radius: 50%;
  transition: transform 4s cubic-bezier(0.33, 1, 0.68, 1);
  border: 3px solid var(--border); box-shadow: 0 0 0 3px var(--chrome-shadow);
}
.wf-slice {
  --count: 24; --radius: calc(var(--wheel-size) / 4); --deg: calc(var(--i) * (360deg / var(--count)));
  grid-area: stack; font-weight: 900;
  transform: translate3d(calc(cos(var(--deg)) * var(--radius)), calc(sin(var(--deg)) * var(--radius)), 0) rotate(var(--deg));
}
.wf-value {
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.12em; font-size: 0.68em;
  padding-bottom: 70px;
  font-family: "Zodiak", Georgia, serif; font-weight: 900;
  writing-mode: vertical-rl; text-orientation: upright; text-transform: uppercase;
  white-space: nowrap; rotate: 90deg; inline-size: calc(var(--wheel-size) / 2);
  block-size: calc(var(--wheel-size) / 24 * 3.3); background: var(--bg);
  clip-path: polygon(0 0, 100% 0, 50% 100%, 50% 100%);
  user-select: none; color: #14171c;
  text-shadow: var(--bg) 0.03em 0.03em, hsla(0, 0%, 0%, 0.2) 0.06em 0.06em;
}
.wf-value.wf-text { font-size: 0.4em; letter-spacing: -0.04em; }
.wf-slice:nth-child(odd) .wf-value { --bg: #ed7332; }
.wf-slice:nth-child(even) .wf-value { --bg: #62b67d; }
.wf-slice:nth-child(3n + 3) .wf-value { --bg: #fdf251; }
.wf-slice:nth-child(4n + 4) .wf-value { --bg: #62b7f9; }
.wf-slice .wf-value.wf-bankrupt { --bg: #14171c; color: #fff; text-shadow: none; }
.wf-hub {
  z-index: 3; width: calc(var(--wheel-size) / 4.5); height: calc(var(--wheel-size) / 4.5);
  display: flex; align-items: center; justify-content: center; text-align: center;
  border-radius: 50%; border: 3px solid var(--border); background: var(--panel);
  font-family: var(--pixel); font-size: 0.6111rem; letter-spacing: 0.5px; color: var(--muted);
  white-space: nowrap; pointer-events: none;
  /* Masks the wedge tips converging near dead-centre — without this, their
     antialiased points bleed through in a faint pinwheel around the hub. */
  box-shadow: 0 0 0 8px var(--panel);
}
#wf-wheel-outer { cursor: grab; touch-action: none; }
#wf-wheel-outer.wf-grabbing { cursor: grabbing; }
#wf-wheel-outer.wf-disabled { cursor: default; }

.wf-actions { display: flex; flex-direction: column; gap: 10px; }
/* Reserve room for the tallest of "pick a consonant" / "buy a vowel or
   solve" so switching between them never shifts the wheel below. */
.wf-action-area { min-height: 100px; }
.wf-status { font-family: var(--pixel); font-size: 0.8889rem; color: var(--accent); min-height: 1.4em; margin: 0; text-align: center; }
.wf-letter-grid { display: flex; flex-wrap: wrap; gap: 6px; }
#wf-consonants { justify-content: center; }
.wf-letter-btn {
  width: 32px; height: 32px; border-radius: 4px; border: 2px solid var(--border);
  background: var(--panel-2); color: var(--ink); font-family: var(--pixel); font-size: 0.8889rem; cursor: pointer;
}
.wf-letter-btn:hover:not(:disabled) { background: var(--panel); border-color: var(--accent); }
.wf-letter-btn:disabled { opacity: 0.3; cursor: default; }
.wf-idle-actions { display: flex; flex-direction: column; gap: 10px; }
.wf-idle-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.wf-idle-row .btn-secondary { flex: 0 0 auto; }
.wf-vowel-grid { margin-top: 2px; }
.wf-solve-form { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; }
.wf-solve-form input { flex: 1; width: auto; margin-top: 0; }

.wf-winner-text { font-size: 1.7778rem; }
.wf-winner-phrase { font-family: var(--pixel); font-size: 1.2222rem; color: var(--accent); text-align: center; margin: 4px 0; }
.wf-winner-next { color: var(--muted); font-size: 0.7222rem; margin: 0; }


@media (max-width: 640px) {
  .sidebar { width: 78vw; }
  .ab-btn .ab-label { display: none; }
  .stage-tiles .tile { width: 108px; height: 62px; }
  .stage-tiles .tile.screen { width: 150px; }
  .stage-dock.huddle .stage-tiles .tile { width: 140px; height: 79px; }
  .stage-dock.huddle .stage-tiles .tile.screen { width: 200px; }
  /* stack the presenter cam above the screen on narrow screens */
  .presenter-cam { top: 10px; left: 10px; width: 132px; height: 99px; }
  body.screen-sharing .screen-window { top: 118px; left: 8px; right: 8px; bottom: 88px; }
  body.screen-sharing.im-presenting .self-cam { display: none; }
}
@media (max-width: 760px) {
  .avatar-layout { flex-direction: column; }
  .avatar-layout .avatar-preview-wrap { align-self: center; position: static; }
  .avatar-layout .avatar-preview-col { align-self: center; position: static; align-items: center; }
  .avatar-layout .avatar-controls { grid-template-columns: repeat(2, 1fr); }
}
