/* Royal Boudoir Theme (Variant 1 — daipad.ru) — 100dvh zero-scroll, burgundy velvet & antique gold */
:root {
  color-scheme: dark;
  --bg: #0c070a;
  --s1: #150d11;
  --s2: rgba(255, 255, 255, 0.06);
  --hover: rgba(255, 255, 255, 0.11);
  --bd: rgba(255, 255, 255, 0.08);
  --bd-soft: rgba(255, 255, 255, 0.12);
  --text: #f3ede7;
  --dim: #9f8f97;
  --gold: #d4af37;
  --gold-bright: #ebd082;
  --acc: #d4a64a;
  --acc-hover: #e5ba62;
  --live: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --r-card: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse 75% 65% at 38% 48%, rgba(112, 24, 48, 0.26), transparent 70%),
    radial-gradient(ellipse 45% 55% at 88% 82%, rgba(176, 108, 36, 0.16), transparent 68%),
    var(--bg);
  color: var(--text);
  font: 13px/1.4 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--gold-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { outline-offset: 2px; }
:focus-visible { outline: 2px solid var(--gold); }

input, button, select {
  font: inherit;
  color: inherit;
  background: var(--s2);
  border: 1px solid var(--bd);
  border-radius: var(--r-sm);
  padding: 6px 11px;
}
button { cursor: pointer; white-space: nowrap; transition: background 120ms ease, border-color 120ms ease, color 120ms ease; }
button:hover:not(:disabled) { background: var(--hover); border-color: var(--bd-soft); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary, .btn-link.primary {
  background: #d6ab4c;
  border-color: transparent;
  color: #160c05;
  font-weight: 600;
}
button.primary:hover:not(:disabled), .btn-link.primary:hover {
  background: #e5bc61;
  border-color: transparent;
  text-decoration: none;
}
button.danger { color: #f87171; border-color: transparent; background: rgba(239, 68, 68, 0.11); }
button.danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); border-color: transparent; }
.ghost-btn { background: transparent; border-color: transparent; color: var(--dim); padding: 4px 8px; }
.ghost-btn:hover { background: var(--hover); color: var(--text); }
.btn-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--bd-soft);
  background: var(--s2);
  color: var(--text);
  font-size: 12px;
}
.error { color: #f87171; font-size: 12px; min-height: 1.2em; margin: 2px 0 0; }
.dim { color: var(--dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* /admin login */
#login { display: grid; place-items: center; height: 100dvh; padding: 20px; background: var(--bg); }
#login form {
  width: 100%;
  max-width: 340px;
  display: grid;
  gap: 12px;
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r-card);
  padding: 24px;
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand img { display: block; object-fit: contain; }
#login h1 { margin: 0; font: 700 18px/1.1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); letter-spacing: -0.02em; }
.login-back { font-size: 12px; color: var(--dim); text-align: center; }

/* App container: strict 100dvh flex column */
#app { display: none; flex-direction: column; height: 100dvh; overflow: hidden; }

/* Full-width 52px Minimal Top Header */
#bar {
  flex: none;
  height: 52px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  background: rgba(14, 8, 11, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 20;
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 700 17px/1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -0.025em;
  white-space: nowrap;
  color: #f5efe9;
}
.brand-tld {
  color: var(--dim);
  font-weight: 500;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand img { display: block; height: 23px; width: 23px; object-fit: contain; }

/* Variant 1 Studio / Viewer mode segmented switch */
.mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 10px;
}
.mode-switch-btn {
  padding: 5px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}
.mode-switch-btn.active,
.mode-switch-btn.active:hover:not(:disabled) {
  background: linear-gradient(180deg, #e7c46a 0%, #c18d30 100%);
  color: #1c0f06;
}
.mode-switch-btn.active:hover:not(:disabled) {
  background: linear-gradient(180deg, #f3d582 0%, #d49d3b 100%);
}
.bar-sep { width: 1px; height: 15px; background: rgba(255, 255, 255, 0.12); flex: none; }
.live-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); white-space: nowrap; }
.live-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; display: block; }
.bar-meta { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
#status { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 26vw; }
#playLoginBtn, #adminPlayBtn { border-radius: 999px; padding: 7px 18px; font-size: 13px; }
#playerLogoutBtn { border-radius: 999px; border-color: transparent; background: rgba(255, 255, 255, 0.07); padding: 6px 14px; font-size: 12.5px; color: var(--text); }
#playerLogoutBtn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); border-color: transparent; }
.timer-chip {
  font: 500 12.5px/1 ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  background: transparent;
  border: 0;
  padding: 4px 2px;
  white-space: nowrap;
}

/* Admin Settings Ribbon */
#adminPanel {
  flex: none;
  width: calc(100% - 32px);
  margin: 12px 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: 12px;
  flex-wrap: wrap;
  font-size: 12px;
}
#adminPanel select, #adminPanel input, #adminPanel button { padding: 5px 9px; font-size: 12px; }
.ribbon-label { color: var(--dim); font-weight: 600; }
.ribbon-check { display: inline-flex; align-items: center; gap: 5px; color: var(--text); white-space: nowrap; font-size: 12px; }
.ribbon-check input { padding: 0; accent-color: var(--acc); }
.ribbon-range { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); font-size: 12px; }
.ribbon-range input { width: 64px; padding: 0; border: 0; background: transparent; accent-color: var(--acc); }
.ribbon-spectator { display: inline-flex; align-items: center; gap: 6px; }
#spectatorChannel { width: 150px; }
.ribbon-spacer { flex: 1; }
#stats { font: 11px ui-monospace, monospace; color: var(--dim); white-space: nowrap; }

/* MAIN ROOM: Variant A — Maximum Full-Width 16:9 Cinema Stage + 3-Tier Observer Lounge Right Rail */
#roomLayout {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 10px 14px 10px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(12, 5, 9, 0.64) 0%, rgba(12, 5, 9, 0.36) 52%, rgba(10, 4, 7, 0.54) 100%),
    url("/assets/boudoir/lounge-bg.jpg") center center / cover no-repeat;
}
body.studio-mode #roomLayout {
  padding: 12px 16px;
  gap: 16px;
  background: var(--bg);
}

.stage-column {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  justify-content: flex-start;
}
body.studio-mode .stage-column {
  gap: 12px;
  align-items: flex-start;
  justify-content: flex-start;
}

/* Full-width Cinema Stage — always spans 100% of left column width, top-aligned on tall/narrow viewports */
.canopy-stage {
  position: relative;
  z-index: 6;
  flex: 0 1 auto;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0;
}
body.studio-mode .canopy-stage {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  max-height: 100%;
  margin-top: 0;
  overflow: hidden;
}

/* Large Aristocrat Observer Box anchored in the lower tier of the right rail (0% video overlap!) */
.rail-aristocrat-lounge {
  position: relative;
  flex: 1 1 0;
  min-height: 150px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  overflow: visible;
}
.aristocrat-fg-box {
  position: relative;
  width: min(104%, 340px);
  max-height: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: -12px;
  pointer-events: none;
}
.canopy-aristocrat-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.92));
}
.coffee-steam-canvas {
  position: absolute;
  left: 42.1%;
  top: 19.6%;
  width: 30%;
  height: 36%;
  transform: translate(-56%, -96%);
  pointer-events: none;
  background: transparent;
}

.canopy-observer-tag {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(14, 8, 11, 0.84);
  border: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  font: 500 11.5px/1.1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #dfd4cc;
  white-space: nowrap;
}
.canopy-tag-sep { opacity: 0.45; }
@media (max-height: 620px), (max-width: 860px) {
  .rail-aristocrat-lounge { display: none; }
}

/* Frameless cinema player container + seamless bottom controls bar */
#playerCard {
  position: relative;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  container-type: inline-size;
  container-name: player;
  display: flex;
  flex-direction: column;
  background: #080608;
  border: 0;
  border-radius: 10px;
  padding: 0;
  overflow: visible;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.72);
}
body.studio-mode #playerCard {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r-card);
  padding: 10px 10px 0;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* Studio Director Strip inside #playerCard */
.studio-director-strip {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
  border-top: 1px solid var(--bd);
  flex-wrap: wrap;
}
.studio-stream-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.studio-quick-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.studio-quick-actions button { padding: 6px 12px; font-size: 12px; }
.studio-quick-actions button.is-paused { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }

/* Studio Bottom Dock: Queue + Quick MemAlerts Test Pills */
.studio-bottom-dock {
  width: 100%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px;
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r-card);
  flex-wrap: wrap;
}
.studio-dock-queue { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.studio-dock-player-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.studio-dock-player-row strong { font-size: 13px; }
.compact-btn { padding: 3px 8px !important; font-size: 11px !important; }
.studio-dock-memes {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--bd);
  flex-wrap: wrap;
}
.studio-quick-memes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.studio-quick-pill {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--s2);
  border: 1px solid var(--bd-soft);
}
.studio-quick-pill:hover { border-color: var(--acc); background: var(--hover); }

/* Studio 4-Tab Right Inspector (Variant 1) */
.studio-inspector {
  flex: none;
  width: min(440px, 40vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r-card);
}
.inspector-tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--bd);
}
.inspector-tab {
  padding: 7px 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.inspector-tab:hover { color: var(--text); background: var(--s2); }
.inspector-tab.active,
.inspector-tab.active:hover:not(:disabled) {
  background: linear-gradient(180deg, #e7c46a 0%, #c18d30 100%);
  color: #1c0f06;
  border-color: #f3d789;
}
.inspector-tab.active:hover:not(:disabled) {
  background: linear-gradient(180deg, #f3d582 0%, #d49d3b 100%);
  border-color: #fbe4a4;
}
.inspector-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  overflow-y: auto;
}
.inspector-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 -14px;
}
.inspector-scroll table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; font-size: 12px; }
.inspector-scroll th, .inspector-scroll td { padding: 7px 14px; border-bottom: 1px solid rgba(38, 39, 46, 0.8); vertical-align: middle; }
.inspector-scroll th { position: sticky; top: 0; background: var(--s1); font-weight: 600; color: var(--dim); font-size: 11px; }
.inspector-scroll .num { text-align: right; }
.inspector-scroll .agent { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.logins-table th, .logins-table td { padding: 7px 8px; vertical-align: top; }
.log-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-cell-main { font-size: 11.5px; color: var(--text); white-space: nowrap; }
.log-cell-sub { font-size: 10.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 15ch; }
.log-ok { color: #6ee7b7; }
.log-err { color: #f87171; }
.ping-good { color: #6ee7b7; font-weight: 600; }
.ping-warn { color: #fbbf24; font-weight: 600; }
.ping-bad { color: #f87171; font-weight: 600; }

.studio-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 10px;
  font-size: 12px;
}
.studio-form .span-2 { grid-column: span 2; }
.studio-form label:not(.studio-toggle-row) { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 11px; }
.studio-form input, .studio-form select { width: 100%; font-size: 12px; }
.studio-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.studio-divider::after { content: ""; flex: 1; height: 1px; background: var(--bd); }
.studio-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  background: var(--s2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  cursor: pointer;
}
.studio-toggle-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.studio-toggle-row strong { font-size: 12px; color: var(--text); font-weight: 600; }
.studio-toggle-row small { font-size: 11px; }
.studio-toggle-row input[type="checkbox"] { width: 17px; height: 17px; flex: none; accent-color: var(--acc); padding: 0; }
.studio-stream-footer {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 8px;
  padding-top: 4px;
}
.studio-stream-footer button { padding: 9px 12px; font-size: 13px; font-weight: 600; }
.studio-issue-form { display: flex; gap: 6px; }
.studio-issue-form input[name="label"] { flex: 1; min-width: 0; }
.studio-issue-form input[name="minutes"] { width: 64px; font-family: ui-monospace, monospace; }
.subtab-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--bd); }
.studio-memes-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.studio-diag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.studio-diag-grid button { font-size: 12px; padding: 7px 10px; }
#stage {
  flex: 0 1 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 118px);
  min-height: 0;
  position: relative;
  z-index: 2;
  overflow: hidden;
  background: #060709;
  border-radius: 10px 10px 0 0;
}
body.studio-mode #stage {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  aspect-ratio: auto;
  max-height: none;
  border-radius: 8px;
}
#screen, #nativeVideo, #spectatorStage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#screen, #nativeVideo { display: block; object-fit: contain; background: #000; }
#stage.native #screen { opacity: 0; }
#stage.native #nativeVideo { pointer-events: none; }

#spectatorStage { z-index: 5; background: #0b0c10; }
.spectator-frame { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.spectator-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  gap: 8px;
}
.spectator-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 999px;
  padding: 3px 10px;
}
.spectator-placeholder strong { font-size: 17px; }
.spectator-placeholder p { margin: 0; max-width: 440px; color: var(--dim); font-size: 13px; }
.spectator-play-btn { margin-top: 8px; border-radius: 999px; padding: 8px 24px; font-size: 13.5px; }

#noSignal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  color: var(--dim);
  font-size: 13px;
  pointer-events: none;
}
#noSignal.blocked { background: #000; }

/* MemAlerts Overlay (bottom-left default; bottom-right for GTA VI Lucia quest) */
#memAlertOverlay {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}
#memAlertOverlay.lucia-pos {
  left: auto;
  right: 18px;
  bottom: 18px;
}

/* Pixel-accurate GTA VI Lucia Objective Popup */
.lucia-quest-card {
  width: min(392px, calc(100vw - 32px));
  border-radius: 0;
  border: 1.5px solid #090d1b;
  background: linear-gradient(
    122deg,
    rgba(35, 34, 68, 0.96) 0%,
    rgba(35, 34, 68, 0.96) 62%,
    rgba(17, 36, 86, 0.96) 62.25%,
    rgba(17, 36, 86, 0.96) 100%
  );
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  overflow: hidden;
  animation: luciaSlideIn 340ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.lucia-quest-card.lucia-preview-card {
  width: 100%;
  animation: none;
}
.lucia-quest-card.leaving {
  animation: luciaSlideOut 300ms cubic-bezier(0.4, 0, 1, 1) forwards;
}
.lucia-top-bar {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, #ff1fa9 0%, #e41ec4 100%);
  box-shadow: 0 1px 10px rgba(255, 31, 169, 0.55);
}
.lucia-inner {
  padding: 13px 16px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}
.lucia-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.lucia-avatar {
  width: 42px;
  height: 42px;
  flex: none;
  object-fit: cover;
  display: block;
  background: #d426a7;
  border: 1.5px solid #f048c6;
  border-radius: 0;
}
.lucia-title {
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Impact, sans-serif;
  font-weight: 800;
  font-size: 26px;
  line-height: 1.04;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.lucia-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 16px;
  line-height: 1.25;
  color: #eef1f8;
  font-weight: 500;
}
.lucia-plus {
  color: #ec28a7;
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
}
.lucia-heart {
  width: 16px;
  height: 16px;
  fill: #ee2ba8;
  flex: none;
  margin-right: 3px;
}
.lucia-desc {
  margin: 0;
  font-size: 16px;
  line-height: 1.38;
  color: #f0f3fa;
  font-weight: 400;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.lucia-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 15px;
  line-height: 1.34;
  color: #f0f3fa;
  min-width: 0;
}
.lucia-list li {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.lucia-list li::marker {
  color: #ee2ba8;
}

@keyframes luciaSlideIn {
  0% { opacity: 0; transform: translateX(48px) scale(0.97); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes luciaSlideOut {
  0% { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(48px) scale(0.98); }
}

.meme-tile-lucia {
  grid-column: 1 / -1;
  flex-direction: row !important;
  justify-content: center;
  gap: 8px !important;
  min-height: 36px !important;
  padding: 6px 14px !important;
  border-radius: 999px !important;
  border: 0 !important;
  background: #b81d6c !important;
  box-shadow: none;
}
.meme-tile-lucia .meme-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
}
.meme-tile-lucia .meme-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.meme-tile-lucia:hover:not(:disabled) {
  background: #cc257a !important;
  box-shadow: none;
}
.lucia-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.lucia-form > * { min-width: 0; max-width: 100%; }
.lucia-form label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; font-size: 12px; color: var(--dim); }
.lucia-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lucia-counter { font: 11px ui-monospace, monospace; color: var(--dim); white-space: nowrap; }
.lucia-form input, .lucia-form textarea { width: 100%; min-width: 0; max-width: 100%; }
.lucia-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--s2);
  border: 1px solid var(--bd-soft);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  resize: vertical;
  min-height: 76px;
}
.lucia-preview-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; max-width: 100%; }
#luciaPreview { width: 100%; min-width: 0; max-width: 100%; overflow: hidden; }
.lucia-quest-card.lucia-preview-card { width: 100%; max-width: 100%; animation: none; }
.lucia-preview-label { font-size: 11px; color: var(--dim); }
.lucia-title.is-empty,
.lucia-desc.is-empty {
  opacity: 0.36;
}
.lucia-send-btn { background: #d91c99 !important; border-color: #ff1fa9 !important; color: #fff !important; }
.lucia-send-btn:hover:not(:disabled) { background: #ec28a7 !important; color: #fff !important; }
.mem-alert-card {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 350px;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(16, 17, 22, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  animation: memPop 180ms ease-out;
}
@keyframes memPop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.mem-alert-badge { font-size: 24px; line-height: 1; flex: none; }
.mem-alert-media { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; flex: none; background: #000; }
.mem-alert-body { min-width: 0; }
.mem-alert-body strong { display: block; font-size: 13px; color: #fff; }
.mem-alert-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 11px; color: var(--dim); }
.mem-alert-eq { display: inline-flex; align-items: end; gap: 2px; height: 10px; }
.mem-alert-eq i { display: block; width: 2px; height: 4px; background: var(--acc); animation: eqBounce 0.55s ease-in-out infinite; }
@keyframes eqBounce { 0%, 100% { height: 3px; } 50% { height: 10px; } }

/* Stats, Keys, and Gamepad overlays */
#statsPanel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 12;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow: auto;
  margin: 0;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 14px;
  background: rgba(16, 17, 22, 0.92);
  border: 1px solid var(--bd-soft);
  border-radius: 10px;
  font-size: 12px;
  pointer-events: none;
}
#statsPanel dt { color: var(--dim); }
#statsPanel dd { margin: 0; font: 11px ui-monospace, monospace; color: #fff; }

#keys, #gamepadPanel {
  position: absolute;
  right: 12px;
  left: auto;
  bottom: 10px;
  transform: none;
  z-index: 32;
  width: max-content;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 20px);
  overflow: auto;
  padding: 15px 18px;
  background: rgba(20, 12, 16, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  font-size: 12px;
}
#gamepadPanel { width: min(326px, calc(100% - 32px)); overflow-x: hidden; }
.help-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.help-heading h2 { font-size: 14px; margin: 0; }
#closeKeys, #closeGamepadPanel { padding: 3px; background: transparent; border: 0; }
#closeKeys img, #closeGamepadPanel img { width: 14px; height: 14px; filter: invert(1); display: block; }
#keys dl { display: grid; grid-template-columns: repeat(3, auto); gap: 7px 16px; margin: 0; }
.bindings > div { display: flex; align-items: center; gap: 6px; }
#keys dd { margin: 0; color: var(--dim); }
kbd { display: inline-block; padding: 2px 6px; background: var(--s2); border: 1px solid var(--bd-soft); border-radius: 4px; color: #fff; font: 600 11px/1.3 system-ui, sans-serif; }
#keys p { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.08); color: var(--dim); font-size: 11px; }

.gp-device {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}
.gp-device strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gp-mode {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  color: var(--dim);
}
.gp-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.gp-cap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  color: var(--dim);
}
.gp-cap[data-on="true"] {
  background: rgba(110, 231, 183, 0.11);
  color: #6ee7b7;
}
.gp-status { margin: 0 0 10px; color: var(--dim); line-height: 1.4; overflow-wrap: anywhere; }
.gp-status[data-tone="error"] { color: #f87171; }
.gp-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-bottom: 10px; min-width: 0; }
.gp-row label { font-size: 11px; color: var(--dim); }
.gp-row select { width: 100%; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.gp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.gp-actions button { font-size: 12px; padding: 6px 11px; }
.gp-haptics-box {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}
.gp-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}
.gp-toggle-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  min-width: 0;
}
.gp-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(214, 171, 76, 0.16);
  color: var(--gold-bright);
}
.gp-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  padding: 0;
  accent-color: var(--acc);
}
.gp-sink-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
.gp-sink-row select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 11.5px;
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gp-sink-row button {
  padding: 5px 8px;
  font-size: 12px;
}
.gp-haptics-status {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--dim);
}
.gp-haptics-status[data-tone="ok"] { color: #6ee7b7; }
.gp-haptics-status[data-tone="warn"] { color: #fbbf24; }
.gp-haptics-status[data-tone="error"] { color: #f87171; }
.gp-hint { margin: 0; font-size: 11px; color: var(--dim); line-height: 1.35; }
.gp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); display: block; flex: none; }

/* Integrated controls strip directly beneath the video (0px occlusion, responsive to container width) */
.player-tools {
  position: relative;
  z-index: 25;
  flex: none;
  min-height: 40px;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 4px;
  column-gap: 10px;
  padding: 4px 14px;
  border-radius: 0 0 10px 10px;
  background: #120a0e;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  opacity: 1;
  overflow: hidden;
}
body.studio-mode .player-tools {
  border-radius: 0;
  border-top: 1px solid var(--bd);
  background: transparent;
  padding: 4px 6px;
}
.tools-left, .tools-right { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0; }
.vol-group, .sens-group { display: flex; align-items: center; gap: 8px; flex: none; }
.sens-group { padding-left: 12px; border-left: 1px solid var(--bd); }
.vol-group input[type="range"], .sens-group input[type="range"] {
  width: 96px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  accent-color: var(--acc);
}
@container player (max-width: 780px) {
  .player-tools { padding: 4px 10px; column-gap: 8px; }
  .tools-left, .tools-right { gap: 6px; }
  .vol-group, .sens-group { gap: 5px; }
  .sens-group { padding-left: 8px; }
  .vol-group input[type="range"], .sens-group input[type="range"] { width: 68px; }
}
@container player (max-width: 640px) {
  #gamepadBtnLabel, #keysHelp span { display: none; }
  .vol-group input[type="range"], .sens-group input[type="range"] { width: 58px; }
  .tool-icon-btn { padding: 5px 7px; }
}
@container player (max-width: 500px) {
  .mode-label { display: none !important; }
  .vol-group input[type="range"], .sens-group input[type="range"] { width: 52px; }
}
.vol-group output {
  font: 12px ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  width: 4.4ch;
  text-align: right;
  flex: none;
}
.sens-group output {
  font: 12px ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  width: 5.4ch;
  text-align: right;
  flex: none;
}
.mini-icon { width: 16px; height: 16px; filter: invert(0.8); display: block; flex: none; }
.mode-label {
  flex: none;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  border: 0;
  color: #86efac;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mode-label[data-ping="warn"] { background: rgba(251, 191, 36, 0.14); color: #fbbf24; }
.mode-label[data-ping="bad"] { background: rgba(248, 113, 113, 0.16); color: #f87171; }
.tool-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-sm);
  flex: none;
}
.tool-icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.tool-icon-btn[aria-expanded="true"],
.tool-icon-btn[aria-expanded="true"]:hover:not(:disabled) {
  background: #d6ab4c;
  color: #160c05;
}
.tool-icon-btn[aria-expanded="true"]:hover:not(:disabled) {
  background: #e5bc61;
}
.tool-icon-btn[aria-expanded="true"] img,
.tool-icon-btn[aria-expanded="true"]:hover img { filter: brightness(0); }
.tool-icon-btn img { width: 16px; height: 16px; filter: invert(0.85); display: block; }

/* Fullscreen: true edge-to-edge 100% video + floating auto-hide bottom bar */
#playerCard:fullscreen,
#playerCard:-webkit-full-screen {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
}
#playerCard:fullscreen #stage,
#playerCard:-webkit-full-screen #stage {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  max-height: none;
  border-radius: 0;
}
#playerCard:fullscreen .player-tools,
#playerCard:-webkit-full-screen .player-tools {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: 100%;
  max-width: none;
  height: 44px;
  border-radius: 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  justify-content: space-between;
  z-index: 30;
  padding: 0 16px;
  background: rgba(12, 13, 18, 0.88);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
#playerCard:fullscreen .player-tools:hover,
#playerCard:fullscreen .player-tools:focus-within,
#playerCard:-webkit-full-screen .player-tools:hover,
#playerCard:-webkit-full-screen .player-tools:focus-within {
  opacity: 1;
}

/* Right Full-Height 3-Tier Sidebar: Compact Unified Queue + Compact MemAlerts + Large Aristocrat Observer */
#queueCard {
  position: relative;
  z-index: 7;
  flex: none;
  width: clamp(292px, 18.5vw, 336px);
  height: 100%;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  min-height: 0;
}

/* Compact Unified Queue Card (clean borderless dark frosted surface) */
.rail-queue {
  flex: 0 1 auto;
  min-height: 0;
  max-height: clamp(168px, 27vh, 240px);
  display: flex;
  flex-direction: column;
  background: rgba(18, 10, 14, 0.78);
  backdrop-filter: blur(14px);
  border: 0;
  border-radius: var(--r-card);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}
.rail-block { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.rail-unified-queue {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 0;
  padding: 11px 12px;
}
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rail-queue-head { padding: 0 2px; }
.rail-kicker {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.rail-title-icon {
  width: 17px;
  height: 17px;
  color: var(--dim);
  flex: none;
}
#liveDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  display: block;
  flex: none;
}
.rail-timer {
  font: 500 12px ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: #efe3d2;
  background: transparent;
  border: 0;
  padding: 0;
  white-space: nowrap;
  flex: none;
}

.queue-unified-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Active player pinned at the very top of the unified list */
.queue-active-row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  background: rgba(112, 22, 42, 0.62);
  border: 0;
  box-shadow: none;
  min-height: 42px;
}
.queue-active-row[data-active="false"] {
  background: rgba(255, 255, 255, 0.04);
  color: var(--dim);
}
.queue-active-row[data-active="false"] .queue-crown-slot,
.queue-active-row[data-active="false"] .queue-gamepad-slot {
  opacity: 0.25;
}
.queue-lead-slot {
  flex: none;
  width: 22px;
  display: grid;
  place-items: center;
}
.queue-chair-icon {
  display: block;
  height: 24px;
  width: auto;
  object-fit: contain;
}
.queue-active-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.queue-gamepad-slot {
  display: grid;
  place-items: center;
  color: #ebd082;
  flex: none;
}
.queue-gamepad-icon {
  width: 18px;
  height: 14px;
}

.current-player {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  font-size: 13px;
}
.queue-person {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}
.avatar-active {
  background: rgba(235, 208, 130, 0.18);
  border: 0;
  color: #f4df9e;
  box-shadow: none;
}
.queue-person > div {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.queue-person strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-active-row[data-active="true"] .queue-person strong {
  color: #f5e6cf;
  font-weight: 600;
}
.playing-suffix {
  font-size: 12px;
  font-weight: 400;
  color: rgba(245, 230, 207, 0.72);
  flex: none;
}
.queue-person small {
  color: var(--dim);
  font-size: 11px;
  flex: none;
}

#waitingPlayers {
  list-style: none;
  padding: 2px 0 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#waitingPlayers:empty { flex: 0; padding: 0; }
#waitingPlayers li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 8px;
  transition: background 140ms ease;
}
#waitingPlayers li:hover { background: rgba(255, 255, 255, 0.05); }
#waitingPlayers li[aria-current="true"] {
  background: rgba(235, 208, 130, 0.12);
}
#waitingPlayers [aria-current="true"] strong { color: var(--gold-bright); }
.queue-clock-slot {
  margin-left: auto;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.34);
  flex: none;
}
.queue-clock-icon {
  width: 16px;
  height: 16px;
  display: block;
}
#emptyQueue {
  margin: 4px 0 0;
  padding-left: 40px;
  font-size: 12px;
  color: var(--dim);
}
.leave-btn { margin-top: 8px; align-self: flex-start; font-size: 12px; padding: 5px 10px; }

/* Compact MemAlerts Card (clean borderless dark frosted surface) */
.rail-memes {
  flex: none;
  padding: 11px 12px;
  background: rgba(18, 10, 14, 0.78);
  backdrop-filter: blur(14px);
  border: 0;
  border-radius: var(--r-card);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}
.rail-memes-title { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.rail-memes-meta { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.cd-tag {
  font: 500 11px ui-monospace, monospace;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--s2);
  color: var(--dim);
  flex: none;
}
.cd-tag[data-state="ready"] { background: rgba(34, 197, 94, 0.14); color: #6ee7b7; }
.cd-tag[data-state="cooldown"] { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }
.cd-tag[data-state="off"] { background: rgba(239, 68, 68, 0.14); color: #f87171; }

.sender-field { display: grid; gap: 4px; margin-bottom: 8px; }
.sender-field input { width: 100%; padding: 6px 10px; font-size: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: var(--r-sm); }

.mem-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.meme-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 0;
  border-radius: 9px;
  min-height: 48px;
}
.meme-tile:hover:not(:disabled) { background: rgba(255, 255, 255, 0.11); }
.meme-emoji { font-size: 17px; line-height: 1; }
.meme-thumb { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.meme-title { font-size: 10.5px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meme-cd { display: none; }
.mem-status {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mem-status[data-tone="ok"] { color: #6ee7b7; }
.mem-status[data-tone="error"] { color: #f87171; }
.mem-status:empty { display: none; }
.alerts-empty { margin: 0; font-size: 12px; color: var(--dim); grid-column: 1 / -1; }

/* Modals (Password + Add Alert) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 370px;
  background: var(--s1);
  border: 1px solid var(--bd-soft);
  border-radius: var(--r-card);
  padding: 18px 20px;
}
.modal-wide { max-width: 490px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-desc { margin: 0 0 12px; font-size: 12px; color: var(--dim); line-height: 1.45; }
#spectatorLoginForm { display: grid; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-form-grid label { display: grid; gap: 4px; font-size: 11px; color: var(--dim); }
.modal-form-grid .span-2 { grid-column: 1 / -1; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.upload-row input[type="file"] { font-size: 11px; padding: 4px; max-width: 170px; }

/* ADMIN 100dvh AIRY ROUNDED WORKSPACE */
#managementTitle, #playerLink { display: none; }
.management #managementTitle { display: block; margin: 0; font-size: 16px; font-weight: 700; }
.management #playerLink { display: inline-flex; border-radius: 999px; padding: 6px 14px; }
.management #adminHeaderMeta { display: inline !important; }
.management #roomLayout, .management .brand span, .management #liveBadge, .management #viewerCount,
.management #playLoginBtn, .management #playerLogoutBtn, .management #adminToggle, .management #passTimerPill,
.management #connect, .management #statsToggle, .management #latencyTest, .management #hidConnect,
.management #gamepadSelect, .management #stats, .management #manageLink, .management #status { display: none !important; }
.management .brand { gap: 0; }
.management .ribbon-spectator { display: inline-flex; }
body:not(.management) .ribbon-spectator, body:not(.management) .admin-only-sep { display: none; }

#accessPanel {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 12px 16px 16px;
  display: grid;
  grid-template-columns: 58% 42%;
  gap: 16px;
  overflow: hidden;
}
.admin-col { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.admin-left {
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r-card);
}
.admin-right { display: grid; grid-template-rows: 44% 56%; gap: 14px; }
.admin-split-top, .admin-split-bottom {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--s1);
  border: 1px solid var(--bd);
  border-radius: var(--r-card);
}

.pane-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bd);
  flex-wrap: wrap;
}
.pane-head h2 { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.pane-title-row { display: flex; align-items: center; gap: 8px; }
.mini-tag { font: 11px ui-monospace, monospace; padding: 2px 7px; border-radius: 999px; background: var(--s2); color: var(--dim); border: 1px solid var(--bd-soft); }
.tab-group { display: flex; gap: 4px; }
.tab-btn { background: transparent; border-color: transparent; color: var(--dim); font-weight: 600; padding: 5px 10px; border-radius: var(--r-sm); }
.tab-btn.active { color: var(--text); background: var(--s2); }
.compact-issue { display: flex; align-items: center; gap: 6px; }
.compact-issue input[name="label"] { width: 140px; }
.compact-issue input[name="minutes"] { width: 64px; font-family: ui-monospace, monospace; }

.issued-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(139, 92, 246, 0.14);
  border-bottom: 1px solid var(--acc);
  font-size: 12px;
}
.issued-banner input { flex: 1; font: 12px ui-monospace, monospace; background: var(--bg); }
.pane-notice { flex: none; padding: 0 14px; font-size: 12px; color: var(--dim); }
.pane-notice:not(:empty) { padding: 6px 14px; border-bottom: 1px solid var(--bd); }
.pane-subhead { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px; font-size: 11px; }
.pane-subline { flex: none; padding: 7px 14px; font-size: 12px; color: var(--dim); border-bottom: 1px solid var(--bd); }

.pane-scroll { flex: 1; min-height: 0; overflow: auto; }
#accessPanel table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; font-size: 12px; }
#accessPanel th, #accessPanel td { padding: 7px 14px; border-bottom: 1px solid rgba(38, 39, 46, 0.8); vertical-align: middle; }
#accessPanel th { position: sticky; top: 0; background: var(--s1); font-weight: 600; color: var(--dim); font-size: 11px; }
#accessPanel .num { text-align: right; }
#accessPanel .agent { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
#accessPanel .more { margin: 8px 14px; }
.row-actions { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.row-actions button { padding: 4px 8px; font-size: 11px; }

.admin-queue-list { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.admin-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--s2);
  border: 1px solid var(--bd);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.alerts-limits-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--bd);
  font-size: 11px;
  color: var(--dim);
  flex-wrap: wrap;
}
.alerts-limits-bar label { display: inline-flex; align-items: center; gap: 4px; }
.alerts-limits-bar input { width: 46px; padding: 3px 6px; font: 11px ui-monospace, monospace; }
.alerts-limits-bar button { padding: 4px 9px; font-size: 11px; }

.restream-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 5px;
  background: #22c55e;
  vertical-align: middle;
}
.restream-dot[data-mode="slate"] { background: #f59e0b; }
.restream-dot[data-mode="error"] { background: var(--danger); }
.restream-pane { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.restream-status-card {
  padding: 12px 14px;
  background: var(--s2);
  border: 1px solid var(--bd);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.restream-status-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.restream-status-top strong { font-size: 14px; display: block; margin-bottom: 2px; }
.restream-error {
  font: 12px ui-monospace, monospace;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  word-break: break-word;
}
.restream-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; font-size: 12px; }
.restream-form .span-2 { grid-column: span 2; }
.restream-form label:not(.ribbon-check) { display: flex; flex-direction: column; gap: 4px; color: var(--dim); }
.restream-presets { grid-column: span 2; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.restream-presets button { padding: 3px 8px; font-size: 11px; }
.restream-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }

@media (pointer: coarse) and (not (any-pointer: fine)) {
  .fine-pointer { display: none !important; }
  .sens-group { display: none !important; }
}
@media (max-width: 860px) {
  html, body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  #app {
    height: auto;
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: visible;
  }
  #bar {
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .bar-left, .bar-right { gap: 8px; flex-wrap: wrap; }
  .brand { font-size: 15px; gap: 7px; }
  .brand img { height: 22px; width: auto; }
  .bar-sep, #liveBadge { display: none; }
  .bar-meta { font-size: 12px; }
  #playLoginBtn { padding: 6px 12px; font-size: 12px; }
  #status { display: none; }

  #adminPanel {
    width: auto;
    margin: 8px 12px 0;
    padding: 8px 10px;
    gap: 6px;
  }
  #spectatorChannel { width: 130px; max-width: 100%; }

  #roomLayout {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 10px 22px;
    gap: 14px;
    overflow: visible;
  }
  .canopy-stage, body.studio-mode .canopy-stage { flex: none; width: 100%; aspect-ratio: auto; max-height: none; overflow: visible; margin-left: 0; margin-top: 0; }
  .canopy-frame-overlay { display: none; }
  .canopy-foreground-floor { display: none; }
  #playerCard, body.studio-mode #playerCard {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 10px;
    padding: 0;
  }
  .stage-column { width: 100%; align-items: stretch; justify-content: flex-start; }
  .studio-bottom-dock { padding: 10px 12px; }
  .studio-dock-memes { padding-left: 0; border-left: 0; padding-top: 8px; border-top: 1px solid var(--bd); width: 100%; }
  .studio-inspector { width: 100%; height: auto; overflow: visible; }
  .inspector-body { overflow: visible; }
  .inspector-scroll { margin: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .studio-form { grid-template-columns: 1fr; }
  .studio-form .span-2, .restream-presets { grid-column: span 1; }
  .studio-stream-footer { grid-template-columns: 1fr; }
  .studio-diag-grid { grid-template-columns: 1fr; }
  #stage, body.studio-mode #stage {
    width: 100%;
    aspect-ratio: 16 / 9;
    flex: none;
  }
  .player-tools {
    position: static;
    transform: none;
    opacity: 1;
    width: 100%;
    max-width: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    height: auto;
    min-height: 40px;
    padding: 6px 2px;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .tools-left, .tools-right { gap: 6px; flex-wrap: wrap; }
  .vol-group input[type="range"] { width: 68px; }
  .sens-group, .mode-label { display: none !important; }
  .tool-icon-btn { padding: 5px 7px; font-size: 11px; }

  #memAlertOverlay { left: 8px; right: 8px; bottom: 8px; }
  #memAlertOverlay.lucia-pos { left: auto; right: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  #memAlertOverlay.lucia-pos .lucia-quest-card { width: min(290px, calc(100vw - 32px)); }
  #memAlertOverlay.lucia-pos .lucia-inner { padding: 9px 11px 10px; gap: 6px; }
  #memAlertOverlay.lucia-pos .lucia-avatar { width: 32px; height: 32px; }
  #memAlertOverlay.lucia-pos .lucia-title { font-size: 18px; }
  #memAlertOverlay.lucia-pos .lucia-sub, #memAlertOverlay.lucia-pos .lucia-desc, #memAlertOverlay.lucia-pos .lucia-list { font-size: 12px; }
  .mem-alert-card { max-width: 100%; padding: 7px 10px; }
  #keys, #gamepadPanel { left: 50%; right: auto; transform: translateX(-50%); }
  #keys dl { grid-template-columns: repeat(2, auto); gap: 5px 10px; }

  #queueCard {
    width: 100%;
    height: auto;
    align-self: stretch;
    gap: 12px;
  }
  .rail-queue, .rail-unified-queue, .rail-memes { flex: none; overflow: visible; max-height: none; }
  .rail-aristocrat-lounge { display: none; }
  .rail-block { padding: 12px 14px; }
  #memAlertsCard { padding: 12px 14px; }
  .mem-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .meme-tile { min-height: 60px; padding: 8px 4px; }

  #accessPanel {
    grid-template-columns: 1fr;
    padding: 8px 12px 24px;
    gap: 12px;
    overflow: visible;
  }
  .admin-col, .admin-right, .admin-split-top, .admin-split-bottom {
    display: flex;
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  .pane-head { padding: 10px 12px; }
  .tab-group { flex-wrap: wrap; width: 100%; }
  .compact-issue { width: 100%; flex-wrap: wrap; }
  .compact-issue input[name="label"] { flex: 1 1 120px; width: auto; min-width: 0; }
  .pane-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .restream-form { grid-template-columns: 1fr; }
  .restream-form .span-2, .restream-presets { grid-column: span 1; }
  .modal-form-grid { grid-template-columns: 1fr; }
  .modal-form-grid .span-2 { grid-column: span 1; }

  /* Full-viewport Lucia modal on mobile */
  #luciaModal {
    padding: 0;
    align-items: stretch;
    justify-items: stretch;
  }
  #luciaModal .modal-card {
    max-width: none;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  #luciaModal .lucia-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  #luciaModal .modal-actions {
    margin-top: auto;
    padding-top: 12px;
  }
  #luciaModal .modal-actions button {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
  }
}
@media (max-width: 440px) {
  #gamepadBtnLabel, #keysHelp span { display: none; }
  .vol-group output { display: none; }
  .vol-group input[type="range"] { width: 64px; }
}

input.masked-secret {
  -webkit-text-security: disc;
  text-security: disc;
}

/* Chromeless embedded stream stage for Dashboard Overview */
body.embed-mode {
  background: #070709 !important;
  overflow: hidden !important;
}
body.embed-mode #bar,
body.embed-mode #queueCard,
body.embed-mode #studioInspector,
body.embed-mode #studioBottomDock,
body.embed-mode #studioDirectorStrip,
body.embed-mode .player-tools {
  display: none !important;
}
body.embed-mode #app,
body.embed-mode #roomLayout,
body.embed-mode .stage-column,
body.embed-mode .canopy-stage,
body.embed-mode #playerCard {
  display: block !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: #070709 !important;
  box-shadow: none !important;
}
body.embed-mode #stage {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  border: 0 !important;
  background: #070709 !important;
}
