@ywkrlerche/richardwho 1.0.34 β†’ 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/app.js +467 -72
  2. package/index.html +92 -7
  3. package/package.json +1 -1
  4. package/style.css +70 -2
package/app.js CHANGED
@@ -406,11 +406,11 @@
406
406
  }
407
407
 
408
408
  // ---------- Routing: "" home, #games, #recent, #play/<id> ----------
409
- const VIEW_ORDER = ["home", "games", "chat", "stats", "settings", "changelog"];
409
+ const VIEW_ORDER = ["home", "games", "chat", "stats", "live", "settings", "changelog"];
410
410
  let lastView = null;
411
411
  function viewFor(hash) {
412
412
  return hash === "#games" || hash === "#recent" ? "games" : hash === "#settings" ? "settings" : hash === "#chat" ? "chat"
413
- : hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : "home";
413
+ : hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : hash === "#live" ? "live" : "home";
414
414
  }
415
415
  // Switching pages: the old page slides out while the new one slides in (down the side bar = upward,
416
416
  // up the side bar = downward). Uses the browser's view transitions; older browsers just switch.
@@ -420,12 +420,14 @@
420
420
  !matchMedia("(prefers-reduced-motion: reduce)").matches;
421
421
  if (!animate) { routeNow(); after?.(); return; }
422
422
  document.documentElement.dataset.navDir = VIEW_ORDER.indexOf(next) < VIEW_ORDER.indexOf(lastView) ? "up" : "down";
423
- document.startViewTransition(() => { routeNow(); after?.(); });
423
+ const t = document.startViewTransition(() => { routeNow(); after?.(); });
424
+ t.ready.catch(() => {}); // a quick second click skips the first slide: harmless, so don't report it as an error
424
425
  }
425
426
  function routeNow() {
426
427
  const m = location.hash.match(/^#play\/(.+)$/);
427
428
  const game = m && byId.get(decodeURIComponent(m[1]));
428
429
  if (game) {
430
+ if (live.viewer) stopWatching(); // a game covers the Live page: stop the stream's sound too
429
431
  els.player.hidden = false;
430
432
  document.body.classList.add("playing");
431
433
  addRecent(game.id);
@@ -449,6 +451,9 @@
449
451
  lastView = view;
450
452
  $("view-stats").hidden = view !== "stats";
451
453
  $("view-changelog").hidden = view !== "changelog";
454
+ $("view-live").hidden = view !== "live";
455
+ if (view === "live") { openChat(); renderLive(); }
456
+ else if (live.viewer) stopWatching(); // leaving the Live page stops the stream (and its sound); Watch live rejoins
452
457
  if (view === "changelog") renderChangelog();
453
458
  placeChatBox();
454
459
  if (view === "settings") { renderSettings(); renderAdmin(); }
@@ -461,10 +466,13 @@
461
466
  if (location.hash === "#recent") requestAnimationFrame(() => els.recentBlock.scrollIntoView({ block: "start" }));
462
467
  }
463
468
  function play(id) { location.hash = `#play/${encodeURIComponent(id)}`; }
464
- function go(view) {
469
+ // instant: switch right away, no slide (used when typing on the home search moves you to Games,
470
+ // so the Games search box can take focus before the next key arrives)
471
+ function go(view, { instant = false } = {}) {
465
472
  const target = view === "home" ? "" : `#${view}`;
466
473
  if (location.hash !== target) history.pushState(null, "", target || location.pathname + location.search);
467
- route(() => { if (view !== "recent") window.scrollTo(0, 0); });
474
+ const after = () => { if (view !== "recent") window.scrollTo(0, 0); };
475
+ if (instant) { routeNow(); after(); } else route(after);
468
476
  }
469
477
  function goBack() {
470
478
  if (location.hash.startsWith("#play/")) history.length > 1 ? history.back() : (location.hash = "#games");
@@ -518,6 +526,12 @@
518
526
  // Newest first. Add an entry here with every publish; its version should match package.json.
519
527
  // Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
520
528
  const CHANGELOG = [
529
+ { version: "1.0.35", date: "2026-10-28",
530
+ new: ["πŸ”΄ Live streams: watch Richard live, with its own chat beside the stream", "Quote of the day on the front page, and you can submit your own",
531
+ "πŸ“Έ Take a photo with your camera right in the chat", "Full-screen chat", "Chat titles: add a title next to your name",
532
+ "See how many people are in chat right now", "Chat starts fresh every day at 1:35 PM"],
533
+ fixes: ["Chat doesn't block messages anymore: swear words just get their middle letters hidden",
534
+ "Nicknames can be anything", "No cooldown between messages or photos"] },
521
535
  { version: "1.0.34", date: "2026-10-27",
522
536
  new: ["Send photos in chat: drag and drop, paste, or tap πŸ“·", "Emoji picker and 230 animated stickers (😊 button)",
523
537
  "🚩 Report messages: 3 reports hides a message", "Slow mode and chat lock when chat gets busy"],
@@ -1071,36 +1085,29 @@
1071
1085
  return BAD_WHOLE_WORD.includes(p) || BAD_WHOLE_WORD.includes(w) ||
1072
1086
  [...BAD_ANYWHERE, ...extraWords()].some((b) => w.includes(tight(b)));
1073
1087
  }
1074
- // Blocked content just says this, in red: no hints about which word tripped the filter
1075
- const NOT_ALLOWED = "Not allowed";
1076
- // Returns { text } or { error } when the message can't be sent. Nothing is ever starred out.
1088
+ // Nothing is ever blocked: swear words just get their middle letters hidden ("f**k").
1089
+ // The owner's extra word list (Settings β†’ Tools) is hidden the same way.
1090
+ function maskWord(w) {
1091
+ const letters = [...w];
1092
+ if (letters.length <= 2) return "*".repeat(letters.length);
1093
+ return letters[0] + "*".repeat(letters.length - 2) + letters[letters.length - 1];
1094
+ }
1095
+ function maskText(text) {
1096
+ return String(text).split(/(\s+)/).map((w) => (/\S/.test(w) && isBadWord(w) ? maskWord(w) : w)).join("");
1097
+ }
1098
+ // Returns { text } (masked) or { error } only when there's nothing to send
1077
1099
  function cleanMessage(raw) {
1078
1100
  const text = String(raw).replace(/\s+/g, " ").trim();
1079
1101
  if (!text) return { error: "Type a message first." };
1080
- const folded = fold(text);
1081
- if (/(https?:|www\.|discord\.gg|\b[a-z0-9-]+\s*(\.|dot)\s*(com|net|org|io|gg|xyz|co|me|tv|ly|app|dev|link|ru|us)\b)/i.test(folded)) return { error: NOT_ALLOWED };
1082
- if (/\S+@\S+\.\S+/.test(folded)) return { error: NOT_ALLOWED };
1083
- if (/(\d[\s().-]*){7,}/.test(folded)) return { error: NOT_ALLOWED };
1084
- if (text.split(" ").some(isBadWord)) return { error: NOT_ALLOWED };
1085
- // spaced-out tricks like "f u c k" survive word-by-word checks; catch them on the whole line
1086
- const joined = tight(text.split(" ").filter((w) => !SAFE_WORDS.includes(plain(w))).join(" "));
1087
- if ([...BAD_ANYWHERE, ...extraWords()].some((b) => joined.includes(tight(b)))) return { error: NOT_ALLOWED };
1088
- const sentence = plain(text).replace(/\s+/g, " ");
1089
- if (BAD_PHRASES.some((re) => re.test(sentence))) return { error: NOT_ALLOWED };
1090
- return { text };
1091
- }
1092
- // Teacher titles and staff-sounding names aren't allowed (people were posing as teachers)
1093
- const NAME_TITLES = /^(mr|mrs|ms|miss|mx|dr|sir|madam|coach|prof|professor|principal|teacher|dean|admin|mod|moderator|owner|staff|system)( |_|-|$)/i;
1102
+ return { text: maskText(text).slice(0, 300) };
1103
+ }
1104
+ // Names can be anything up to 16 characters. (The admin code is longer than that, so a mistyped code is
1105
+ // refused instead of being posted as someone's name.) "Richard" stays the owner's.
1094
1106
  function cleanName(raw) {
1095
- // Refuse (don't silently strip) other characters: a wrong or not-yet-saved admin code like "Code123!"
1096
- // must never be posted as a nickname
1097
- if (/[^A-Za-z0-9 _-]/.test(raw)) return { error: "Nicknames can only use letters, numbers, spaces, _ and -." };
1098
- // (the box allows 40 characters so the admin code fits; real nicknames stop at 16)
1099
- const name = raw.replace(/\s+/g, " ").trim();
1100
- if (name.length < 2 || name.length > 16) return { error: "Pick a nickname (2–16 letters)." };
1101
- if (NAME_TITLES.test(name)) return { error: "Nicknames can't use titles like Mr., Ms. or Teacher." };
1102
- if (name.split(/[ _-]/).some(isBadWord) || isBadWord(name.replace(/[ _-]/g, ""))) return { error: NOT_ALLOWED };
1103
- return { name };
1107
+ const name = String(raw).replace(/\s+/g, " ").trim();
1108
+ if (!name) return { error: "Pick a nickname." };
1109
+ if ([...name].length > 16) return { error: "Nicknames can be up to 16 characters." };
1110
+ return { name: maskText(name) };
1104
1111
  }
1105
1112
 
1106
1113
  const chat = {
@@ -1108,9 +1115,12 @@
1108
1115
  settings: {}, // owner's live settings: slowMode (s), locked, words
1109
1116
  mutedUntil: 0, banned: false,
1110
1117
  flags: {}, // message key -> number of people who reported it
1111
- lastText: "", lastTextAt: 0, strikes: [],
1118
+ lastText: "", lastTextAt: 0,
1119
+ room: "main", // "main" (the Chat page / beside games) or "live" (beside the live stream)
1112
1120
  };
1113
- const HIDE_AFTER_REPORTS = 3;
1121
+ const HIDE_AFTER_REPORTS = Infinity;
1122
+ // Each room keeps its own messages, typing and "in chat" list; names, bans, mutes and settings are shared
1123
+ function roomPath(x) { return chat.room === "live" ? `live/chat/${x}` : `chat/${x}`; } // reports are switched off: nothing is hidden automatically
1114
1124
  const ADMIN_NAME = "Richard"; // what the admin's messages show as (reserved: the database refuses it from non-admins)
1115
1125
  function setAdminName() {
1116
1126
  $("chat-name").value = ADMIN_NAME;
@@ -1140,6 +1150,7 @@
1140
1150
  chat.started = true;
1141
1151
  $("chat-form").hidden = false;
1142
1152
  $("chat-name").value = store.get("rug-chat-name", "");
1153
+ $("chat-title").value = store.get("rug-chat-title", "");
1143
1154
  chatNote("Connecting…");
1144
1155
  try {
1145
1156
  await ensureUser(app);
@@ -1148,13 +1159,50 @@
1148
1159
  return;
1149
1160
  }
1150
1161
  if (chat.admin) setAdminName();
1162
+ if (!$("view-live").hidden) renderLive(); // now we know whether this is the owner (Go live panel)
1151
1163
  chatNote("");
1152
1164
  const log = $("chat-log");
1153
1165
  log.innerHTML = `<p class="chat-empty" id="chat-empty">No messages yet. Say hi!</p>`;
1154
1166
  const db = app.database();
1155
1167
  watchChatState(db);
1168
+ listenRoom(db);
1169
+ watchChatReset(db);
1170
+ }
1171
+
1172
+ // Show the current room's messages (called again when the chat moves between the Chat page and Live)
1173
+ // The chat starts fresh every day at 1:35 PM (by this browser's clock): only messages sent since the most
1174
+ // recent 1:35 PM show. Messages over a day old are deleted from the database by whoever has the chat open.
1175
+ const CHAT_RESET = { hour: 13, minute: 35 };
1176
+ function lastChatReset(now = new Date()) {
1177
+ const t = new Date(now.getFullYear(), now.getMonth(), now.getDate(), CHAT_RESET.hour, CHAT_RESET.minute);
1178
+ if (t > now) t.setDate(t.getDate() - 1);
1179
+ return t.getTime();
1180
+ }
1181
+ function watchChatReset(db) {
1182
+ clearInterval(chat.resetTimer);
1183
+ chat.resetTimer = setInterval(() => {
1184
+ if (lastChatReset() !== chat.resetAt) { listenRoom(db); sweepOldMessages(db); } // it's 1:35: clear the screen
1185
+ }, 15000);
1186
+ sweepOldMessages(db);
1187
+ }
1188
+ async function sweepOldMessages(db) {
1189
+ const dayAgo = Date.now() - 86400000;
1190
+ for (const path of ["chat/messages", "live/chat/messages"]) {
1191
+ try {
1192
+ const old = await db.ref(path).orderByChild("ts").endAt(dayAgo).limitToFirst(200).once("value");
1193
+ const changes = {};
1194
+ old.forEach((c) => { changes[`${path}/${c.key}`] = null; });
1195
+ if (Object.keys(changes).length) await db.ref().update(changes);
1196
+ } catch { /* older rules, or someone else already swept */ }
1197
+ }
1198
+ }
1199
+ function listenRoom(db) {
1200
+ const log = $("chat-log"), room = chat.room;
1201
+ log.innerHTML = `<p class="chat-empty" id="chat-empty">${room === "live" ? "No messages yet. Say hi to the stream!" : "No messages yet. Say hi!"}</p>`;
1202
+ $("chat-text").placeholder = room === "live" ? "Chat with the stream…" : "Say something… (drop a photo here)";
1156
1203
  if (chat.ref) chat.ref.off(); // reconnecting (signed in/out): drop the old listener so messages don't double
1157
- const ref = chat.ref = db.ref("chat/messages").orderByChild("ts").limitToLast(60);
1204
+ chat.resetAt = lastChatReset();
1205
+ const ref = chat.ref = db.ref(roomPath("messages")).orderByChild("ts").startAt(chat.resetAt).limitToLast(60);
1158
1206
  ref.on("child_added", (snap) => {
1159
1207
  const m = snap.val();
1160
1208
  const div = renderMessage(snap.key, m);
@@ -1166,7 +1214,7 @@
1166
1214
  if (nearBottom || m.uid === chat.uid) log.scrollTop = log.scrollHeight;
1167
1215
  // pictures load after they're added; keep the view pinned to the bottom when they do
1168
1216
  div.querySelector("img")?.addEventListener("load", () => { if (nearBottom || m.uid === chat.uid) log.scrollTop = log.scrollHeight; }, { once: true });
1169
- noteNewMessage(m, div.classList.contains("mention"));
1217
+ if (room === "main") noteNewMessage(m, div.classList.contains("mention")); // the unread dot is for the regular chat
1170
1218
  });
1171
1219
  // Deleted (by its sender or the owner): disappears for everyone
1172
1220
  ref.on("child_removed", (snap) => {
@@ -1174,6 +1222,20 @@
1174
1222
  if (!log.querySelector(".chat-msg")) log.innerHTML = `<p class="chat-empty" id="chat-empty">No messages yet. Say hi!</p>`;
1175
1223
  });
1176
1224
  startTypingWatch(db);
1225
+ watchHere(db);
1226
+ updateHere();
1227
+ }
1228
+ async function switchRoom(room) {
1229
+ if (room === chat.room) return;
1230
+ stopTyping();
1231
+ typing.ref = null;
1232
+ if (hereOn && hereRef) hereRef.remove().catch(() => {});
1233
+ hereOn = false;
1234
+ hereRef = null;
1235
+ chat.room = room;
1236
+ if (!chat.started || !chat.uid) return;
1237
+ const app = await getFirebase();
1238
+ if (app) listenRoom(app.database());
1177
1239
  }
1178
1240
 
1179
1241
  // One chat row: text, a sticker or a photo, plus its buttons (shown by CSS for who may use them)
@@ -1182,10 +1244,8 @@
1182
1244
  if (!m || typeof m.name !== "string") return null;
1183
1245
  let body;
1184
1246
  if (typeof m.text === "string") {
1185
- // filter again on display: older messages and newly blocked words disappear
1186
- const shown = cleanMessage(m.text).text;
1187
- if (!shown) return null;
1188
- body = escapeHtml(shown).replace(/(^|\s)@([\w-]{2,16})/g, '$1<span class="at">@$2</span>');
1247
+ // mask again on display, so words added to the owner's list later get hidden in old messages too
1248
+ body = escapeHtml(maskText(m.text)).replace(/(^|\s)@([\w-]{2,16})/g, '$1<span class="at">@$2</span>');
1189
1249
  } else if (typeof m.sticker === "string" && STICKERS.includes(m.sticker)) {
1190
1250
  body = `<img class="chat-sticker" src="${STICKER_URL(m.sticker)}" alt="sticker" width="96" height="96" loading="lazy">`; } else if (typeof m.img === "string" && /^data:image\/(webp|jpeg);base64,[A-Za-z0-9+/=]+$/.test(m.img)) {
1191
1251
  body = `<button class="chat-photo-btn" type="button" data-act="view" title="Open photo"><img class="chat-photo" src="${m.img}" alt="Photo from ${escapeHtml(m.name)}" loading="lazy"></button>`;
@@ -1199,10 +1259,10 @@
1199
1259
  div.dataset.name = m.name;
1200
1260
  if (typeof m.text === "string") div.dataset.text = m.text;
1201
1261
  if (!mine && typeof m.text === "string" && mentionsMe(m.text)) div.classList.add("mention");
1202
- div.innerHTML = `${m.admin ? `<span class="badge-admin">⭐ ADMIN</span>` : ""}<span class="who" title="Mention">${escapeHtml(m.name)}</span>` +
1262
+ const title = typeof m.title === "string" && m.title.trim() ? `<span class="chat-title-pill">${escapeHtml(maskText(m.title))}</span>` : "";
1263
+ div.innerHTML = `${m.admin ? `<span class="badge-admin">⭐ ADMIN</span>` : ""}${title}<span class="who" title="Mention">${escapeHtml(maskText(m.name))}</span>` +
1203
1264
  `${body}<span class="when">${t.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}</span>` +
1204
1265
  `<span class="msg-acts">` +
1205
- (mine ? "" : `<button class="mod act-report" type="button" data-act="report" title="Report this message">🚩</button>`) +
1206
1266
  `<button class="mod act-delete" type="button" data-act="delete" title="Delete message">πŸ—‘</button>` +
1207
1267
  (mine ? "" : `<button class="mod owner-only" type="button" data-act="purge" title="Delete everything this person sent">🧹</button>` +
1208
1268
  `<button class="mod owner-only" type="button" data-act="mute" title="Mute this person">πŸ”‡</button>` +
@@ -1246,18 +1306,16 @@
1246
1306
  if (chat.banned) return "You've been banned from sending messages. You can still read.";
1247
1307
  if (chat.mutedUntil > Date.now()) return `You're muted for ${fmtWait(chat.mutedUntil - Date.now())}.`;
1248
1308
  if (chat.settings.locked) return "Chat is locked right now. You can still read.";
1249
- const strike = chat.strikes.filter((t) => Date.now() - t < 120000);
1250
- if (strike.length >= 3) return `Too many blocked messages. Wait ${fmtWait(120000 - (Date.now() - strike[0]))}.`;
1251
1309
  return "";
1252
1310
  }
1253
1311
  function fmtWait(ms) {
1254
1312
  const m = Math.ceil(ms / 60000);
1255
1313
  return m >= 60 * 24 ? `${Math.round(m / 1440)} day${m >= 2880 ? "s" : ""}` : m >= 60 ? `${Math.round(m / 60)} hour${m >= 120 ? "s" : ""}` : `${m} minute${m === 1 ? "" : "s"}`;
1256
1314
  }
1257
- function slowSeconds() { return chat.admin ? 0 : Math.max(3, Number(chat.settings.slowMode) || 0); }
1315
+ function slowSeconds() { return chat.admin ? 0 : Number(chat.settings.slowMode) || 0; } // no cooldown unless the owner turns on slow mode
1258
1316
  function updateChatStatus() {
1259
1317
  const why = blockedReason();
1260
- ["chat-text", "chat-send", "emoji-btn", "photo-btn"].forEach((id) => { if ($(id)) $(id).disabled = !!why; });
1318
+ ["chat-text", "chat-send", "emoji-btn", "photo-btn", "cam-btn"].forEach((id) => { if ($(id)) $(id).disabled = !!why; });
1261
1319
  const slow = Number(chat.settings.slowMode) || 0;
1262
1320
  $("chat-status").textContent = why || (chat.settings.locked ? "πŸ”’ Chat is locked (only you can post)" : slow ? `🐒 Slow mode: one message every ${slow}s` : "");
1263
1321
  $("chat-status").classList.toggle("err", !!why);
@@ -1274,7 +1332,10 @@
1274
1332
  }
1275
1333
  function startTypingWatch(db) {
1276
1334
  db.ref(".info/serverTimeOffset").on("value", (s) => { typing.offset = s.val() || 0; });
1277
- db.ref("chat/typing").on("value", (snap) => { typing.others = snap.val() || {}; renderTyping(); }, () => {});
1335
+ typing.watchRef?.off();
1336
+ typing.others = {};
1337
+ typing.watchRef = db.ref(roomPath("typing"));
1338
+ typing.watchRef.on("value", (snap) => { typing.others = snap.val() || {}; renderTyping(); }, () => {});
1278
1339
  clearInterval(typing.timer);
1279
1340
  typing.timer = setInterval(renderTyping, 1000);
1280
1341
  }
@@ -1295,7 +1356,7 @@
1295
1356
  if (!app) return;
1296
1357
  typing.sentAt = Date.now();
1297
1358
  if (!typing.ref) {
1298
- typing.ref = app.database().ref(`chat/typing/${chat.uid}`);
1359
+ typing.ref = app.database().ref(roomPath(`typing/${chat.uid}`));
1299
1360
  typing.ref.onDisconnect().remove();
1300
1361
  }
1301
1362
  typing.ref.set({ name, ts: window.firebase.database.ServerValue.TIMESTAMP }).catch(() => {});
@@ -1338,7 +1399,7 @@
1338
1399
  await db.ref(`chat/flags/${key}/${chat.uid}`).set(true);
1339
1400
  chatNote(`Reported. Messages with ${HIDE_AFTER_REPORTS} reports are hidden until the owner looks at them.`);
1340
1401
  } else if (act === "delete" && (mine || chat.admin)) {
1341
- await db.ref().update({ [`chat/messages/${key}`]: null, ...(chat.admin ? { [`chat/flags/${key}`]: null } : {}) });
1402
+ await db.ref().update({ [roomPath(`messages/${key}`)]: null });
1342
1403
  } else if (!chat.admin || mine) {
1343
1404
  return;
1344
1405
  } else if (act === "purge") {
@@ -1363,9 +1424,9 @@
1363
1424
  }
1364
1425
  // Every message a person sent (and the reports on them), gone in one write
1365
1426
  async function purgeUser(db, uid) {
1366
- const snap = await db.ref("chat/messages").orderByChild("uid").equalTo(uid).once("value");
1427
+ const snap = await db.ref(roomPath("messages")).orderByChild("uid").equalTo(uid).once("value");
1367
1428
  const changes = {};
1368
- snap.forEach((c) => { changes[`chat/messages/${c.key}`] = null; changes[`chat/flags/${c.key}`] = null; });
1429
+ snap.forEach((c) => { changes[roomPath(`messages/${c.key}`)] = null; });
1369
1430
  if (Object.keys(changes).length) await db.ref().update(changes);
1370
1431
  return snap.numChildren();
1371
1432
  }
@@ -1417,6 +1478,8 @@
1417
1478
  $("admin-tools-row").hidden = !on;
1418
1479
  $("admin-reports").hidden = !on;
1419
1480
  $("admin-chat-tools").hidden = !on;
1481
+ $("admin-quotes").hidden = !on;
1482
+ if (on) { watchQuoteAdmin(); renderQuoteAdmin(); }
1420
1483
  if (on) { watchReports(); watchPunished(app.database()); fillChatTools(); renderReported(); }
1421
1484
  else unwatchReports();
1422
1485
  }
@@ -1638,8 +1701,8 @@
1638
1701
  await renderAdmin();
1639
1702
  });
1640
1703
  $("admin-clear").addEventListener("click", async () => {
1641
- if (!chat.admin || !confirm("Delete every chat message for everyone?")) return;
1642
- try { await (await getFirebase()).database().ref("chat/messages").remove(); }
1704
+ if (!chat.admin || !confirm("Delete every chat message for everyone (regular chat and live chat)?")) return;
1705
+ try { await (await getFirebase()).database().ref().update({ "chat/messages": null, "live/chat/messages": null }); } // both rooms
1643
1706
  catch { alert("Couldn't clear the chat."); }
1644
1707
  });
1645
1708
  }
@@ -1659,16 +1722,8 @@
1659
1722
  }
1660
1723
  }
1661
1724
  const m = cleanMessage($("chat-text").value);
1662
- if (m.error) {
1663
- if (m.error !== "Type a message first.") chat.strikes.push(Date.now()); // 3 blocked tries in 2 minutes = short time-out
1664
- chatNote(m.error, true);
1665
- updateChatStatus();
1666
- return;
1667
- }
1668
- if (!chat.admin && m.text.toLowerCase() === chat.lastText && Date.now() - chat.lastTextAt < 60000) { chatNote("You just sent that. No spamming.", true); return; }
1725
+ if (m.error) { chatNote(m.error, true); return; }
1669
1726
  if (await postMessage({ text: m.text })) {
1670
- chat.lastText = m.text.toLowerCase();
1671
- chat.lastTextAt = Date.now();
1672
1727
  $("chat-text").value = "";
1673
1728
  stopTyping();
1674
1729
  }
@@ -1690,25 +1745,279 @@
1690
1745
  const n = chatSender();
1691
1746
  if (!n) return false;
1692
1747
  if (!chat.admin) store.set("rug-chat-name", n.name); // never save the admin code as a remembered name
1748
+ const title = maskText($("chat-title").value.replace(/\s+/g, " ").trim()).slice(0, 20);
1749
+ store.set("rug-chat-title", title);
1693
1750
  const db = app.database();
1694
- const key = db.ref("chat/messages").push().key;
1751
+ const key = db.ref(roomPath("messages")).push().key;
1695
1752
  const TS = window.firebase.database.ServerValue.TIMESTAMP;
1696
1753
  chat.lastSent = Date.now();
1697
1754
  try {
1698
1755
  await db.ref().update({
1699
- [`chat/messages/${key}`]: { name: n.name, ts: TS, uid: chat.uid, ...fields, ...(chat.admin ? { admin: true } : {}) },
1756
+ [roomPath(`messages/${key}`)]: { name: n.name, ts: TS, uid: chat.uid, ...fields, ...(title ? { title } : {}), ...(chat.admin ? { admin: true } : {}) },
1700
1757
  [`chat/last/${chat.uid}`]: TS,
1701
- ...(fields.img ? { [`chat/photoLast/${chat.uid}`]: TS } : {}),
1702
1758
  });
1703
1759
  stats.bump("chatSent");
1704
1760
  chatNote("");
1705
1761
  return true;
1706
1762
  } catch {
1707
- chatNote(blockedReason() || (fields.img ? "Photo didn't send. You can send one photo every 30 seconds." : NOT_ALLOWED), true);
1763
+ chatNote(blockedReason() || "Didn't send. Try again.", true);
1708
1764
  return false;
1709
1765
  }
1710
1766
  }
1711
1767
 
1768
+ // ---------- Quote of the day ----------
1769
+ // Anyone can submit (quotes/pending, readable only by the owner). The owner approves them into
1770
+ // quotes/approved; the bar at the top shows one of those, a different one each day.
1771
+ const quotes = { approved: [], pending: [], sentAt: 0 };
1772
+ function dayNumber() { const d = new Date(); return Math.floor(new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime() / 86400000); }
1773
+ function showQuoteOfDay() {
1774
+ const list = quotes.approved;
1775
+ const q = list.length ? list[dayNumber() % list.length] : null;
1776
+ $("quote-text").textContent = q ? maskText(q.text) : "No quote yet. Be the first to submit one!";
1777
+ $("quote-text").classList.toggle("is-empty", !q);
1778
+ $("quote-by").textContent = q?.by ? `β€” ${maskText(q.by)}` : "";
1779
+ }
1780
+ async function startQuotes() {
1781
+ const app = await getFirebase();
1782
+ if (!app) return;
1783
+ app.database().ref("quotes/approved").orderByKey().on("value", (s) => {
1784
+ quotes.approved = [];
1785
+ s.forEach((c) => { const v = c.val(); if (v && typeof v.text === "string") quotes.approved.push({ key: c.key, ...v }); });
1786
+ showQuoteOfDay();
1787
+ if (chat.admin) renderQuoteAdmin();
1788
+ }, () => {});
1789
+ }
1790
+ function openQuoteForm() {
1791
+ $("quote-input").value = ""; $("quote-author").value = ""; $("quote-msg").textContent = "";
1792
+ $("quote-msg").classList.remove("err");
1793
+ $("quote-wrap").hidden = false;
1794
+ $("quote-input").focus();
1795
+ }
1796
+ function closeQuoteForm() { $("quote-wrap").hidden = true; }
1797
+ async function sendQuote(e) {
1798
+ e.preventDefault();
1799
+ const text = $("quote-input").value.replace(/\s+/g, " ").trim(), by = $("quote-author").value.replace(/\s+/g, " ").trim();
1800
+ const say = (t, err) => { $("quote-msg").textContent = t; $("quote-msg").classList.toggle("err", !!err); };
1801
+ if (text.length < 3) return say("Type the quote first.", true);
1802
+ if (Date.now() - quotes.sentAt < 60000) return say("You just sent one. Try again in a minute.", true);
1803
+ const app = await getFirebase();
1804
+ if (!app) return say("Quotes aren't switched on for this site.", true);
1805
+ try {
1806
+ const user = chat.uid ? { uid: chat.uid } : await ensureUser(app);
1807
+ const db = app.database(), TS = window.firebase.database.ServerValue.TIMESTAMP;
1808
+ await db.ref().update({
1809
+ [`quotes/pending/${db.ref("quotes/pending").push().key}`]: { text: text.slice(0, 140), ...(by ? { by: by.slice(0, 30) } : {}), uid: user.uid, ts: TS },
1810
+ [`quotes/last/${user.uid}`]: TS,
1811
+ });
1812
+ quotes.sentAt = Date.now();
1813
+ closeQuoteForm();
1814
+ toast("Thanks! Richard will look at your quote.");
1815
+ } catch {
1816
+ say("Couldn't send. Try again in a minute.", true);
1817
+ }
1818
+ }
1819
+ // Owner: pending submissions (approve / delete) and the approved list (delete)
1820
+ let quotesPendingRef = null;
1821
+ async function watchQuoteAdmin() {
1822
+ const app = await getFirebase();
1823
+ if (!app || !chat.admin || quotesPendingRef) return;
1824
+ quotesPendingRef = app.database().ref("quotes/pending");
1825
+ quotesPendingRef.on("value", (s) => {
1826
+ const list = [];
1827
+ s.forEach((c) => { list.push({ key: c.key, ...c.val() }); });
1828
+ quotes.pending = list.reverse();
1829
+ renderQuoteAdmin();
1830
+ }, () => { quotesPendingRef = null; });
1831
+ }
1832
+ function renderQuoteAdmin() {
1833
+ const row = (q, pending) => `<div class="report" data-key="${escapeHtml(q.key)}"><div class="body"><span class="game">β€œ${escapeHtml(q.text)}”</span>` +
1834
+ `${q.by ? `<div class="meta">β€” ${escapeHtml(q.by)}</div>` : ""}</div>` +
1835
+ (pending ? `<button class="mod" type="button" data-q="approve">βœ“ Approve</button>` : "") +
1836
+ `<button class="mod" type="button" data-q="${pending ? "delete" : "unapprove"}" title="Delete">πŸ—‘</button></div>`;
1837
+ const p = quotes.pending;
1838
+ $("quotes-count").textContent = p.length ? `(${p.length})` : "";
1839
+ $("quotes-pending").innerHTML = p.length ? p.map((q) => row(q, true)).join("") : `<p class="none">No new submissions.</p>`;
1840
+ $("quotes-approved").innerHTML = quotes.approved.length ? quotes.approved.map((q) => row(q, false)).join("") : `<p class="none">None yet.</p>`;
1841
+ }
1842
+ function bindQuotes() {
1843
+ $("quote-submit-btn").addEventListener("click", openQuoteForm);
1844
+ $("quote-form").addEventListener("submit", sendQuote);
1845
+ $("quote-close").addEventListener("click", closeQuoteForm);
1846
+ $("quote-cancel").addEventListener("click", closeQuoteForm);
1847
+ $("quote-wrap").addEventListener("click", (e) => { if (e.target === $("quote-wrap")) closeQuoteForm(); });
1848
+ const act = async (e) => {
1849
+ const b = e.target.closest("[data-q]"), row = b?.closest(".report");
1850
+ if (!row || !chat.admin) return;
1851
+ const db = (await getFirebase()).database(), key = row.dataset.key;
1852
+ try {
1853
+ if (b.dataset.q === "approve") {
1854
+ const q = quotes.pending.find((x) => x.key === key);
1855
+ await db.ref().update({ [`quotes/approved/${key}`]: { text: q.text, ...(q.by ? { by: q.by } : {}) }, [`quotes/pending/${key}`]: null });
1856
+ } else if (b.dataset.q === "delete") await db.ref(`quotes/pending/${key}`).remove();
1857
+ else if (b.dataset.q === "unapprove" && confirm("Remove this quote from the rotation?")) await db.ref(`quotes/approved/${key}`).remove();
1858
+ } catch { alert("That didn't work. Are the new database rules published?"); }
1859
+ };
1860
+ $("quotes-pending").addEventListener("click", act);
1861
+ $("quotes-approved").addEventListener("click", act);
1862
+ }
1863
+
1864
+ // ---------- Live stream ----------
1865
+ // The owner streams their screen (with its sound), camera and mic straight to each viewer's browser
1866
+ // (WebRTC). The database only carries the connection set-up messages:
1867
+ // live/state { on, screen, cam, ts } (stream ids, so viewers know which video is which)
1868
+ // live/viewers/<id> { join, offer, answer, oice/*, vice/* } one entry per watching browser
1869
+ // Each viewer gets its own copy of the stream from the owner's computer, so a handful of viewers is
1870
+ // fine; dozens would need a streaming server.
1871
+ const ICE = { iceServers: [{ urls: ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"] }] };
1872
+ const live = { state: null, streams: null, peers: new Map(), viewer: null, audioCtx: null };
1873
+ async function startLiveWatch() {
1874
+ const app = await getFirebase();
1875
+ if (!app) return;
1876
+ app.database().ref("live/state").on("value", (s) => {
1877
+ const st = s.val();
1878
+ const wasOn = !!live.state;
1879
+ live.state = st && st.on ? st : null;
1880
+ document.querySelector('.rail-btn[data-nav="live"]').classList.toggle("is-live", !!live.state);
1881
+ if (live.state && !wasOn && !live.streams) toast("πŸ”΄ Richard is live! Open Live in the side bar to watch.");
1882
+ if (!live.state) stopWatching();
1883
+ if (!$("view-live").hidden) renderLive();
1884
+ }, () => {});
1885
+ }
1886
+ function renderLive() {
1887
+ const on = !!live.state, mine = !!live.streams;
1888
+ $("live-pill").hidden = !on;
1889
+ $("live-owner").hidden = !chat.admin;
1890
+ $("live-go").textContent = mine ? "β–  End stream" : "πŸ”΄ Go live";
1891
+ $("live-lede").textContent = mine ? "You're live. Everyone on the site can watch."
1892
+ : on ? "Richard is live right now." : "Nobody's live right now. When Richard goes live, it shows up here.";
1893
+ $("live-overlay").hidden = mine || !!live.viewer;
1894
+ $("live-overlay-text").textContent = on ? "Richard is live" : "Not live right now";
1895
+ $("live-watch").hidden = !on || mine;
1896
+ updateViewerCount();
1897
+ }
1898
+
1899
+ // -- owner side --
1900
+ async function goLive() {
1901
+ if (live.streams) { await endLive(); return; }
1902
+ const useScreen = $("live-use-screen").checked, useCam = $("live-use-cam").checked, useMic = $("live-use-mic").checked;
1903
+ if (!useScreen && !useCam) { toast("Pick Screen or Camera (or both)."); return; }
1904
+ try {
1905
+ const screen = useScreen ? await navigator.mediaDevices.getDisplayMedia({ video: { frameRate: 30 }, audio: true }) : null;
1906
+ const cam = useCam || useMic ? await navigator.mediaDevices.getUserMedia({ video: useCam ? { width: 640, height: 360 } : false, audio: useMic }) : null;
1907
+ // one sound track: the screen's sound and the mic mixed together
1908
+ live.audioCtx = new AudioContext();
1909
+ const mix = live.audioCtx.createMediaStreamDestination();
1910
+ for (const src of [screen, cam]) if (src?.getAudioTracks().length) live.audioCtx.createMediaStreamSource(new MediaStream(src.getAudioTracks())).connect(mix);
1911
+ const mainVideo = screen ? screen.getVideoTracks() : cam ? cam.getVideoTracks() : [];
1912
+ const screenOut = new MediaStream([...mainVideo, ...mix.stream.getAudioTracks()]);
1913
+ const camOut = screen && cam?.getVideoTracks().length ? new MediaStream(cam.getVideoTracks()) : null;
1914
+ live.streams = { screenOut, camOut, raw: [screen, cam].filter(Boolean) };
1915
+ // preview what you're sending (muted, so no echo)
1916
+ $("live-screen").srcObject = screenOut;
1917
+ $("live-cam").srcObject = camOut;
1918
+ $("live-cam").hidden = !camOut;
1919
+ screen?.getVideoTracks()[0]?.addEventListener("ended", endLive); // "Stop sharing" in the browser bar
1920
+ const db = (await getFirebase()).database();
1921
+ await db.ref("live/viewers").remove();
1922
+ db.ref("live/state").onDisconnect().remove();
1923
+ db.ref("live/viewers").onDisconnect().remove();
1924
+ await db.ref("live/state").set({ on: true, main: screenOut.id, cam: camOut ? camOut.id : null, ts: window.firebase.database.ServerValue.TIMESTAMP });
1925
+ db.ref("live/viewers").on("child_added", (s) => connectViewer(db, s.key));
1926
+ db.ref("live/viewers").on("child_removed", (s) => { live.peers.get(s.key)?.close(); live.peers.delete(s.key); updateViewerCount(); });
1927
+ renderLive();
1928
+ } catch (err) {
1929
+ console.warn(err);
1930
+ live.streams?.raw.forEach((m) => m.getTracks().forEach((t) => t.stop()));
1931
+ live.streams = null;
1932
+ toast("Couldn't start the stream (screen, camera or mic was blocked).");
1933
+ }
1934
+ }
1935
+ function updateViewerCount() { $("live-viewers").textContent = live.streams ? `${live.peers.size} watching` : ""; }
1936
+ async function connectViewer(db, id) {
1937
+ if (!live.streams || live.peers.has(id)) return;
1938
+ const pc = new RTCPeerConnection(ICE);
1939
+ live.peers.set(id, pc);
1940
+ updateViewerCount();
1941
+ const { screenOut, camOut } = live.streams;
1942
+ screenOut.getTracks().forEach((t) => pc.addTrack(t, screenOut));
1943
+ camOut?.getTracks().forEach((t) => pc.addTrack(t, camOut));
1944
+ const ref = db.ref(`live/viewers/${id}`);
1945
+ pc.onicecandidate = (e) => { if (e.candidate) ref.child("oice").push(JSON.stringify(e.candidate)); };
1946
+ pc.onconnectionstatechange = () => { if (["failed", "closed"].includes(pc.connectionState)) { live.peers.delete(id); updateViewerCount(); } };
1947
+ const offer = await pc.createOffer();
1948
+ await pc.setLocalDescription(offer);
1949
+ await ref.child("offer").set({ type: offer.type, sdp: offer.sdp });
1950
+ ref.child("answer").on("value", async (s) => { const a = s.val(); if (a && !pc.currentRemoteDescription) await pc.setRemoteDescription(a).catch(() => {}); });
1951
+ ref.child("vice").on("child_added", (s) => { pc.addIceCandidate(JSON.parse(s.val())).catch(() => {}); });
1952
+ }
1953
+ async function endLive() {
1954
+ const db = (await getFirebase())?.database();
1955
+ if (db) { db.ref("live/viewers").off(); await db.ref("live/state").remove().catch(() => {}); await db.ref("live/viewers").remove().catch(() => {}); }
1956
+ live.peers.forEach((pc) => pc.close());
1957
+ live.peers.clear();
1958
+ live.streams?.raw.forEach((m) => m.getTracks().forEach((t) => t.stop()));
1959
+ live.streams = null;
1960
+ live.audioCtx?.close().catch(() => {});
1961
+ live.audioCtx = null;
1962
+ $("live-screen").srcObject = null; $("live-cam").srcObject = null; $("live-cam").hidden = true;
1963
+ renderLive();
1964
+ }
1965
+
1966
+ // -- viewer side --
1967
+ async function watchLive() {
1968
+ if (!live.state || live.viewer) return;
1969
+ const app = await getFirebase();
1970
+ const user = chat.uid ? { uid: chat.uid } : await ensureUser(app);
1971
+ const ref = app.database().ref(`live/viewers/${user.uid}`);
1972
+ const pc = new RTCPeerConnection(ICE);
1973
+ live.viewer = { pc, ref };
1974
+ pc.ontrack = (e) => {
1975
+ const stream = e.streams[0];
1976
+ if (!stream) return;
1977
+ const isCam = !!live.state?.cam && stream.id === live.state.cam;
1978
+ const el = isCam ? $("live-cam") : $("live-screen");
1979
+ if (el.srcObject !== stream) el.srcObject = stream;
1980
+ if (isCam) { $("live-cam").hidden = false; return; }
1981
+ // sound needs a tap first on some browsers: try with sound, else start muted and offer the button
1982
+ el.muted = false;
1983
+ el.play().catch(() => { el.muted = true; el.play().catch(() => {}); $("live-unmute").hidden = false; });
1984
+ };
1985
+ pc.onicecandidate = (e) => { if (e.candidate) ref.child("vice").push(JSON.stringify(e.candidate)); };
1986
+ pc.onconnectionstatechange = () => {
1987
+ if (pc.connectionState === "failed") { toast("Couldn't connect to the stream (your network may block it)."); stopWatching(); renderLive(); }
1988
+ };
1989
+ await ref.remove().catch(() => {});
1990
+ ref.onDisconnect().remove();
1991
+ await ref.set({ join: window.firebase.database.ServerValue.TIMESTAMP });
1992
+ ref.child("offer").on("value", async (s) => {
1993
+ const o = s.val();
1994
+ if (!o || pc.currentRemoteDescription) return;
1995
+ await pc.setRemoteDescription(o);
1996
+ const ans = await pc.createAnswer();
1997
+ await pc.setLocalDescription(ans);
1998
+ await ref.child("answer").set({ type: ans.type, sdp: ans.sdp });
1999
+ });
2000
+ ref.child("oice").on("child_added", (s) => { pc.addIceCandidate(JSON.parse(s.val())).catch(() => {}); });
2001
+ renderLive();
2002
+ }
2003
+ function stopWatching() {
2004
+ if (!live.viewer) return;
2005
+ const { pc, ref } = live.viewer;
2006
+ ref.child("offer").off();
2007
+ ref.child("oice").off();
2008
+ ref.remove().catch(() => {});
2009
+ pc.close();
2010
+ live.viewer = null;
2011
+ if (!live.streams) { $("live-screen").srcObject = null; $("live-cam").srcObject = null; $("live-cam").hidden = true; }
2012
+ $("live-unmute").hidden = true;
2013
+ }
2014
+ function bindLive() {
2015
+ $("live-go").addEventListener("click", goLive);
2016
+ $("live-watch").addEventListener("click", watchLive);
2017
+ $("live-unmute").addEventListener("click", () => { const v = $("live-screen"); v.muted = false; v.play().catch(() => {}); $("live-unmute").hidden = true; });
2018
+ window.addEventListener("pagehide", () => { if (live.streams) endLive(); });
2019
+ }
2020
+
1712
2021
  // ---------- Emoji picker and stickers ----------
1713
2022
  // Stickers are Google's Noto animated emoji (CC BY 4.0), sent by code so only these can ever appear.
1714
2023
  // Grouped into tabs in the picker; every code here was checked to exist on Google's server
@@ -1796,10 +2105,9 @@
1796
2105
  chatNote("Couldn't check that photo, so it wasn't sent. Try again in a moment.", true);
1797
2106
  return;
1798
2107
  }
2108
+ // the one check that stays: nude photos aren't sent (the chat is full of kids)
1799
2109
  if ((verdict.Porn || 0) > 0.35 || (verdict.Hentai || 0) > 0.35 || (verdict.Sexy || 0) > 0.6) {
1800
- chat.strikes.push(Date.now());
1801
- chatNote(NOT_ALLOWED, true);
1802
- updateChatStatus();
2110
+ chatNote("That photo can't be sent here.", true);
1803
2111
  return;
1804
2112
  }
1805
2113
  const img = await shrinkPhoto(bmp);
@@ -1823,8 +2131,57 @@
1823
2131
  }
1824
2132
  throw new Error("too big");
1825
2133
  }
2134
+ // ---------- πŸ“Έ Take a photo with the camera ----------
2135
+ // Live preview β†’ snapshot (mirrored like a selfie) β†’ "Send to chat" goes through sendPhoto, so it gets
2136
+ // the same nude-photo check and shrinking as any other photo.
2137
+ let camStream = null;
2138
+ async function openCamera() {
2139
+ if (!chatSender()) return; // banned, muted, no nickname…: say so first
2140
+ $("cam-msg").textContent = "";
2141
+ showCamShot(false);
2142
+ $("cam-wrap").hidden = false;
2143
+ try {
2144
+ camStream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: "user", width: { ideal: 1280 }, height: { ideal: 720 } }, audio: false });
2145
+ $("cam-video").srcObject = camStream;
2146
+ } catch {
2147
+ $("cam-msg").textContent = "Couldn't open your camera. Allow camera access in the browser and try again.";
2148
+ $("cam-msg").classList.add("err");
2149
+ }
2150
+ }
2151
+ function showCamShot(taken) {
2152
+ $("cam-video").hidden = taken; $("cam-shot").hidden = !taken;
2153
+ $("cam-snap").hidden = taken; $("cam-retake").hidden = !taken; $("cam-send").hidden = !taken;
2154
+ }
2155
+ function snapCamera() {
2156
+ const v = $("cam-video"), c = $("cam-shot");
2157
+ if (!v.videoWidth) return;
2158
+ c.width = v.videoWidth; c.height = v.videoHeight;
2159
+ const g = c.getContext("2d");
2160
+ g.translate(c.width, 0); g.scale(-1, 1); // mirror, matching the preview
2161
+ g.drawImage(v, 0, 0);
2162
+ showCamShot(true);
2163
+ }
2164
+ function closeCamera() {
2165
+ camStream?.getTracks().forEach((t) => t.stop());
2166
+ camStream = null;
2167
+ $("cam-video").srcObject = null;
2168
+ $("cam-wrap").hidden = true;
2169
+ }
2170
+ function sendCamPhoto() {
2171
+ $("cam-shot").toBlob((blob) => {
2172
+ closeCamera();
2173
+ if (blob) sendPhoto(new File([blob], "camera.jpg", { type: "image/jpeg" }));
2174
+ }, "image/jpeg", 0.9);
2175
+ }
1826
2176
  function bindChatExtras() {
2177
+ $("cam-btn").addEventListener("click", openCamera);
2178
+ $("cam-snap").addEventListener("click", snapCamera);
2179
+ $("cam-retake").addEventListener("click", () => showCamShot(false));
2180
+ $("cam-send").addEventListener("click", sendCamPhoto);
2181
+ $("cam-close").addEventListener("click", closeCamera);
2182
+ $("cam-wrap").addEventListener("click", (e) => { if (e.target === $("cam-wrap")) closeCamera(); });
1827
2183
  $("emoji-btn").addEventListener("click", () => togglePicker());
2184
+ $("chat-full-btn").addEventListener("click", () => setChatFull(!$("chat-box").classList.contains("full")));
1828
2185
  document.addEventListener("pointerdown", (e) => {
1829
2186
  if (!$("picker").hidden && !e.target.closest("#picker, #emoji-btn")) togglePicker(false);
1830
2187
  });
@@ -1850,14 +2207,19 @@
1850
2207
  // There's one chat box: it sits on the Chat page, or in the player's side dock while that's open.
1851
2208
  const CHAT_SEEN_KEY = "rug-chat-seen", CHAT_DOCK_KEY = "rug-chat-dock";
1852
2209
  function dockOpen() { return !els.player.hidden && store.get(CHAT_DOCK_KEY, false); }
1853
- function chatShowing() { return dockOpen() || (els.player.hidden && !$("view-chat").hidden); }
2210
+ function liveShowing() { return els.player.hidden && !$("view-live").hidden; }
2211
+ function chatShowing() { return dockOpen() || (els.player.hidden && !$("view-chat").hidden) || liveShowing(); }
1854
2212
  function placeChatBox() {
1855
2213
  const docked = dockOpen();
1856
2214
  $("chat-dock").hidden = !docked;
1857
2215
  $("dock-btn").setAttribute("aria-pressed", docked);
1858
- const home = docked ? $("chat-dock") : $("view-chat");
2216
+ // the one chat box sits beside a game, beside the live stream, or on the Chat page
2217
+ const home = docked ? $("chat-dock") : liveShowing() ? $("live-chat") : $("view-chat");
2218
+ switchRoom(liveShowing() && !docked ? "live" : "main");
1859
2219
  if ($("chat-box").parentNode !== home) home.appendChild($("chat-box"));
2220
+ if (!chatShowing() && $("chat-box").classList.contains("full")) setChatFull(false);
1860
2221
  if (chatShowing()) markChatSeen();
2222
+ updateHere();
1861
2223
  }
1862
2224
  function toggleDock(open = !store.get(CHAT_DOCK_KEY, false)) {
1863
2225
  store.set(CHAT_DOCK_KEY, open);
@@ -1872,6 +2234,34 @@
1872
2234
  else if (mention) b.classList.add("has-mention");
1873
2235
  });
1874
2236
  }
2237
+ // "N in chat right now": chat/here/<id> exists while this browser has the chat open (or the live stream)
2238
+ let hereRef = null, hereOn = false;
2239
+ async function updateHere() {
2240
+ const want = chatShowing();
2241
+ if (want === hereOn || !chat.uid) return;
2242
+ const app = await getFirebase();
2243
+ if (!app) return;
2244
+ hereOn = want;
2245
+ hereRef ||= app.database().ref(roomPath(`here/${chat.uid}`));
2246
+ if (want) { hereRef.onDisconnect().remove(); hereRef.set(true).catch(() => {}); }
2247
+ else hereRef.remove().catch(() => {});
2248
+ }
2249
+ function watchHere(db) {
2250
+ chat.hereWatch?.off();
2251
+ chat.hereWatch = db.ref(roomPath("here"));
2252
+ const where = chat.room === "live" ? "watching" : "in chat";
2253
+ chat.hereWatch.on("value", (s) => {
2254
+ const n = s.numChildren();
2255
+ $("chat-here-n").textContent = n <= 1 ? `Just you ${where}` : `${n} ${where} right now`;
2256
+ }, () => { $("chat-here-n").textContent = ""; });
2257
+ }
2258
+ // Full-screen chat: the chat box covers the whole page (Esc or the button leaves)
2259
+ function setChatFull(on) {
2260
+ $("chat-box").classList.toggle("full", on);
2261
+ document.body.classList.toggle("chat-full", on);
2262
+ $("chat-full-btn").textContent = on ? "βœ• Exit full screen" : "β›Ά Full screen";
2263
+ if (on) $("chat-text").focus();
2264
+ }
1875
2265
  function markChatSeen() {
1876
2266
  if (chat.newest) store.set(CHAT_SEEN_KEY, chat.newest);
1877
2267
  setUnread(false);
@@ -1919,6 +2309,8 @@
1919
2309
  const keys = CFG.panicKeys || ["`", "]"];
1920
2310
  if (keys.includes(e.key)) { e.preventDefault(); panic(); return; }
1921
2311
  if (!$("report-wrap").hidden) { if (e.key === "Escape") closeReport(); return; }
2312
+ if (!$("cam-wrap").hidden) { if (e.key === "Escape") closeCamera(); return; }
2313
+ if (e.key === "Escape" && $("chat-box").classList.contains("full")) { setChatFull(false); return; }
1922
2314
  if (!$("wheel-wrap").hidden) {
1923
2315
  if (e.key === "Escape") closeWheel();
1924
2316
  else if (e.key === " " && wheel.spinning) { e.preventDefault(); finishWheel(); } // space skips
@@ -1991,8 +2383,9 @@
1991
2383
  els.search.value = els.homeInput.value;
1992
2384
  els.homeInput.value = "";
1993
2385
  setTag("All");
1994
- go("games");
2386
+ go("games", { instant: true });
1995
2387
  els.search.focus();
2388
+ els.search.setSelectionRange(els.search.value.length, els.search.value.length); // keep typing at the end
1996
2389
  renderGrid();
1997
2390
  };
1998
2391
  els.homeInput.addEventListener("input", () => { if (els.homeInput.value.trim()) fromHome(); });
@@ -2171,13 +2564,15 @@
2171
2564
  bindAdmin();
2172
2565
  bindChatTools();
2173
2566
  bindChatExtras();
2567
+ bindQuotes();
2568
+ bindLive();
2174
2569
  bindReports();
2175
2570
  startAnalytics();
2176
2571
  startPresence();
2177
2572
  // Listen to chat from the start so the chat buttons can show a dot for new messages.
2178
2573
  // First visit: only messages from now on count as new.
2179
2574
  if (store.get(CHAT_SEEN_KEY, null) === null) store.set(CHAT_SEEN_KEY, Date.now());
2180
- if (CFG.firebase) openChat();
2575
+ if (CFG.firebase) { openChat(); startQuotes(); startLiveWatch(); }
2181
2576
  // long enough to read a joke or two (skipped when the loading screen is off)
2182
2577
  const minShow = new Promise((r) => setTimeout(r, settings.boot !== false ? 1500 : 0));
2183
2578
  const update = newerVersionUrl(2500);
package/index.html CHANGED
@@ -56,6 +56,9 @@
56
56
  <button class="rail-btn" type="button" data-nav="stats" title="Stats &amp; achievements" aria-label="Stats and achievements">
57
57
  <svg viewBox="0 0 24 24"><path d="M7 3h10v2h4v3a5 5 0 0 1-4.6 5A5 5 0 0 1 13 15.9V18h3v3H8v-3h3v-2.1A5 5 0 0 1 7.6 13 5 5 0 0 1 3 8V5h4V3Zm0 4H5v1a3 3 0 0 0 2 2.8V7Zm12 0h-2v3.8A3 3 0 0 0 19 8V7Z"/></svg>
58
58
  </button>
59
+ <button class="rail-btn live-btn" type="button" data-nav="live" title="Live stream" aria-label="Live stream">
60
+ <svg viewBox="0 0 24 24"><path d="M12 9.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM6.3 6.3l1.4 1.4a6 6 0 0 0 0 8.6l-1.4 1.4a8 8 0 0 1 0-11.4Zm11.4 0a8 8 0 0 1 0 11.4l-1.4-1.4a6 6 0 0 0 0-8.6l1.4-1.4ZM3.5 3.5l1.4 1.4a10 10 0 0 0 0 14.2l-1.4 1.4a12 12 0 0 1 0-17Zm17 0a12 12 0 0 1 0 17l-1.4-1.4a10 10 0 0 0 0-14.2l1.4-1.4Z"/></svg>
61
+ </button>
59
62
  <button class="rail-btn" type="button" data-nav="recent" title="Recently played" aria-label="Recently played">
60
63
  <svg viewBox="0 0 24 24"><path d="M13 3a9 9 0 1 1-8.95 10h2.02A7 7 0 1 0 13 5a6.98 6.98 0 0 0-4.94 2.06L10 9H4V3l2.64 2.64A8.97 8.97 0 0 1 13 3Zm-1 5h2v4.6l3.2 1.9-1 1.7L12 13.7V8Z"/></svg>
61
64
  </button>
@@ -80,6 +83,13 @@
80
83
  <main class="main" id="main" tabindex="-1">
81
84
  <!-- HOME -->
82
85
  <section id="view-home" class="view home">
86
+ <!-- QUOTE OF THE DAY: a bar across the top; approved quotes take turns, a new one each day -->
87
+ <div class="quote-strip" id="quote-card">
88
+ <span class="quote-label">Quote of the day</span>
89
+ <q class="quote-text" id="quote-text">No quote yet. Be the first to submit one!</q>
90
+ <span class="quote-by" id="quote-by"></span>
91
+ <button class="text-btn link" type="button" id="quote-submit-btn">✍ Submit a quote</button>
92
+ </div>
83
93
  <h1 class="wordmark">richardwho</h1>
84
94
  <form class="home-search" id="home-search" role="search">
85
95
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M10.5 3a7.5 7.5 0 0 1 5.96 12.06l4.24 4.24-1.42 1.42-4.24-4.24A7.5 7.5 0 1 1 10.5 3Zm0 2a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z"/></svg>
@@ -88,13 +98,15 @@
88
98
  </form>
89
99
  <p class="home-sub" id="home-sub"></p>
90
100
  <p class="online" id="online" hidden><span class="online-dot"></span><span id="online-count"></span></p>
91
- <div class="bookmark-row">
92
- <!-- Dragged to the bookmarks bar, the link's text becomes the bookmark's name -->
93
- <a class="bookmark-chip" id="bookmark-link" href="https://unpkg.com/@ywkrlerche/richardwho/index.html" draggable="true" title="Drag me to your bookmarks bar"><img id="bookmark-icon" alt=""><span id="bookmark-name">richardwho</span></a>
94
- <button class="bookmark-chip latest" type="button" id="latest-btn" title="Open the newest version of the site">⟳ Latest version</button>
95
- <span class="bookmark-hint"><span class="bookmark-arrow" aria-hidden="true">↑</span> Drag richardwho to your bookmarks bar to get back fast</span>
101
+ <!-- bottom-left corner: bookmark chip, latest version, what's new -->
102
+ <div class="home-corner">
103
+ <div class="bookmark-row">
104
+ <!-- Dragged to the bookmarks bar, the link's text becomes the bookmark's name -->
105
+ <a class="bookmark-chip" id="bookmark-link" href="https://unpkg.com/@ywkrlerche/richardwho/index.html" draggable="true" title="Drag me to your bookmarks bar"><img id="bookmark-icon" alt=""><span id="bookmark-name">richardwho</span></a>
106
+ <button class="bookmark-chip latest" type="button" id="latest-btn" title="Open the newest version of the site">⟳ Latest version</button>
107
+ </div>
108
+ <p class="whats-new-row"><button class="text-btn link whats-new" type="button" data-nav="changelog" id="whats-new-link">What's new in <span id="home-version"></span></button></p>
96
109
  </div>
97
- <p class="whats-new-row"><button class="text-btn link whats-new" type="button" data-nav="changelog" id="whats-new-link">What's new in <span id="home-version"></span></button></p>
98
110
  </section>
99
111
 
100
112
  <!-- GAMES -->
@@ -150,6 +162,10 @@
150
162
  <section id="view-chat" class="view chat" hidden>
151
163
  <header class="games-head"><div><h1>Chat</h1><p class="lede">Be nice. Swears, slurs, links and personal info are blocked. Don't post photos of real people without asking them. 🚩 reports anything bad.</p></div></header>
152
164
  <div class="chat-box" id="chat-box">
165
+ <div class="chat-top">
166
+ <span class="chat-here" id="chat-here"><span class="online-dot"></span><span id="chat-here-n">Connecting…</span></span>
167
+ <button class="text-btn" type="button" id="chat-full-btn" title="Full-screen chat (Esc to leave)">β›Ά Full screen</button>
168
+ </div>
153
169
  <div class="chat-off" id="chat-off" hidden>
154
170
  <p><strong>Chat isn't switched on yet.</strong></p>
155
171
  <p>It needs the site's free Firebase database (see SETUP.md).</p>
@@ -165,9 +181,11 @@
165
181
  </div>
166
182
  <form class="chat-form" id="chat-form" autocomplete="off" hidden>
167
183
  <input id="chat-name" class="chat-name" maxlength="40" placeholder="Nickname" spellcheck="false" aria-label="Nickname">
184
+ <input id="chat-title" class="chat-name chat-title-input" maxlength="20" placeholder="Title" spellcheck="false" aria-label="Your chat title (optional)" title="A title shown next to your name, like β€œPro Gamer” (optional)">
168
185
  <input id="chat-text" class="chat-text" maxlength="200" placeholder="Say something… (drop a photo here)" aria-label="Message">
169
186
  <button class="icon-btn" type="button" id="emoji-btn" title="Emoji and stickers" aria-label="Emoji and stickers" aria-expanded="false" aria-controls="picker">😊</button>
170
- <button class="icon-btn" type="button" id="photo-btn" title="Send a photo" aria-label="Send a photo">πŸ“·</button>
187
+ <button class="icon-btn" type="button" id="photo-btn" title="Send a photo from your computer" aria-label="Send a photo">πŸ“·</button>
188
+ <button class="icon-btn" type="button" id="cam-btn" title="Take a photo with your camera" aria-label="Take a photo with your camera">πŸ“Έ</button>
171
189
  <input type="file" id="photo-input" accept="image/*" hidden>
172
190
  <button class="pill-btn" type="submit" id="chat-send">Send</button>
173
191
  </form>
@@ -203,6 +221,35 @@
203
221
  </section>
204
222
 
205
223
  <!-- SETTINGS -->
224
+ <!-- LIVE STREAM: the owner streams screen + camera + sound; anyone can watch, with chat beside it -->
225
+ <section id="view-live" class="view live" hidden>
226
+ <header class="games-head"><div><h1>Live <span class="live-pill" id="live-pill" hidden>● LIVE</span></h1><p class="lede" id="live-lede">Nobody's live right now. When Richard goes live, it shows up here.</p></div></header>
227
+ <div class="live-layout">
228
+ <div class="live-stage" id="live-stage">
229
+ <video id="live-screen" playsinline autoplay muted></video>
230
+ <video id="live-cam" playsinline autoplay muted hidden></video>
231
+ <div class="live-overlay" id="live-overlay">
232
+ <p id="live-overlay-text">Not live right now</p>
233
+ <button class="pill-btn play" type="button" id="live-watch" hidden>β–Ά Watch live</button>
234
+ </div>
235
+ <button class="pill-btn live-unmute" type="button" id="live-unmute" hidden>πŸ”Š Tap for sound</button>
236
+ </div>
237
+ <div class="live-chat" id="live-chat"></div>
238
+ </div>
239
+ <!-- owner only -->
240
+ <div class="set-group live-owner" id="live-owner" hidden>
241
+ <h2>Go live</h2>
242
+ <p class="set-help">Streams your screen (with its sound), your camera and your mic to everyone on the site. Your browser asks which screen or tab to share.</p>
243
+ <div class="set-row">
244
+ <label class="live-opt"><input type="checkbox" id="live-use-screen" checked> Screen</label>
245
+ <label class="live-opt"><input type="checkbox" id="live-use-cam" checked> Camera</label>
246
+ <label class="live-opt"><input type="checkbox" id="live-use-mic" checked> Mic</label>
247
+ <span class="set-hint" id="live-viewers"></span>
248
+ <button class="pill-btn danger" type="button" id="live-go">πŸ”΄ Go live</button>
249
+ </div>
250
+ </div>
251
+ </section>
252
+
206
253
  <!-- WHAT'S NEW (filled from CHANGELOG in app.js) -->
207
254
  <section id="view-changelog" class="view settings changelog" hidden>
208
255
  <header class="games-head"><div><h1>What's new</h1><p class="lede">Every update to richardwho: new stuff, games and fixes.</p></div></header>
@@ -276,6 +323,13 @@
276
323
  <h3 class="set-sub">Muted and banned</h3>
277
324
  <div class="reports" id="punished-list"></div>
278
325
  </div>
326
+ <div id="admin-quotes" hidden>
327
+ <h3 class="set-sub">Quote submissions <span id="quotes-count"></span></h3>
328
+ <p class="set-help">Approved quotes take turns at the top of the site, a new one each day.</p>
329
+ <div class="reports" id="quotes-pending"></div>
330
+ <h3 class="set-sub">Approved quotes</h3>
331
+ <div class="reports" id="quotes-approved"></div>
332
+ </div>
279
333
  <div id="admin-reports" hidden>
280
334
  <h3 class="set-sub">Game reports and requests <span id="reports-count"></span></h3>
281
335
  <div class="reports" id="reports-list"></div>
@@ -295,6 +349,37 @@
295
349
  </section>
296
350
  </main>
297
351
 
352
+ <!-- TAKE A PHOTO WITH YOUR CAMERA (sent to the chat like any photo) -->
353
+ <div class="wheel-wrap" id="cam-wrap" hidden role="dialog" aria-label="Take a photo">
354
+ <div class="wheel-card cam-card">
355
+ <button class="wheel-x" type="button" id="cam-close" aria-label="Close">βœ•</button>
356
+ <h2>Take a photo</h2>
357
+ <div class="cam-view"><video id="cam-video" playsinline autoplay muted></video><canvas id="cam-shot" hidden></canvas></div>
358
+ <p class="chat-note" id="cam-msg"></p>
359
+ <div class="wheel-actions">
360
+ <button class="pill-btn" type="button" id="cam-retake" hidden>β†Ί Retake</button>
361
+ <button class="pill-btn play" type="button" id="cam-snap">πŸ“Έ Take photo</button>
362
+ <button class="pill-btn play" type="button" id="cam-send" hidden>Send to chat</button>
363
+ </div>
364
+ </div>
365
+ </div>
366
+
367
+ <!-- SUBMIT A QUOTE (goes to the owner for approval) -->
368
+ <div class="wheel-wrap" id="quote-wrap" hidden role="dialog" aria-labelledby="quote-title">
369
+ <form class="wheel-card report-card" id="quote-form" autocomplete="off">
370
+ <button class="wheel-x" type="button" id="quote-close" aria-label="Close">βœ•</button>
371
+ <h2 id="quote-title">Submit a quote</h2>
372
+ <p class="report-sub">If Richard picks it, it shows at the top of the site for a day.</p>
373
+ <textarea class="report-input" id="quote-input" maxlength="140" rows="3" placeholder="The quote…" aria-label="Quote"></textarea>
374
+ <input class="report-input" id="quote-author" maxlength="30" placeholder="Who said it? (optional)" aria-label="Who said it">
375
+ <p class="chat-note" id="quote-msg"></p>
376
+ <div class="wheel-actions">
377
+ <button class="pill-btn" type="button" id="quote-cancel">Cancel</button>
378
+ <button class="pill-btn play" type="submit" id="quote-send">Send</button>
379
+ </div>
380
+ </form>
381
+ </div>
382
+
298
383
  <!-- REPORT A BROKEN GAME / REQUEST A GAME -->
299
384
  <div class="wheel-wrap" id="report-wrap" hidden role="dialog" aria-labelledby="report-title">
300
385
  <form class="wheel-card report-card" id="report-form" autocomplete="off">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywkrlerche/richardwho",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "Richards Unblocked Games",
5
5
  "license": "UNLICENSED",
6
6
  "files": [
package/style.css CHANGED
@@ -389,8 +389,11 @@ body:has(#view-games:not([hidden])) .aurora { opacity: .7; }
389
389
  .stage { position: relative; flex: 1; min-width: 0; }
390
390
  .chat-dock { width: 340px; flex: none; display: flex; border-left: 1px solid rgba(255,255,255,.08); background: #0a0a0c; }
391
391
  .chat-dock .chat-box { flex: 1; height: auto; border: 0; border-radius: 0; min-width: 0; }
392
- .chat-dock .chat-name { width: 90px; }
393
- .chat-dock .chat-form { flex-wrap: wrap; }
392
+ /* Narrow chat (beside a game or the live stream): the message box gets its own full-width line on top */
393
+ .chat-dock .chat-form, .live-chat .chat-form { flex-wrap: wrap; }
394
+ .chat-dock .chat-text, .live-chat .chat-text { flex: 1 1 100%; order: -1; }
395
+ .chat-dock .chat-name, .live-chat .chat-name { flex: 1 1 0; width: auto; min-width: 0; }
396
+ .chat-dock .chat-box .pill-btn, .live-chat .chat-box .pill-btn { padding: 0 14px; }
394
397
  .chat-toggle[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
395
398
  @media (max-width: 720px) { .chat-dock { position: absolute; right: 0; top: 49px; bottom: 0; width: min(340px, 100%); z-index: 2; } }
396
399
 
@@ -549,3 +552,68 @@ body:has(#view-changelog:not([hidden])) .corner-links { display: none; }
549
552
  .clock { top: 8px; right: 8px; }
550
553
  }
551
554
  @media (prefers-reduced-motion: reduce) { .aurora span, .sweep::after, .wordmark, .boot-word { animation: none; } }
555
+
556
+ /* ---------- Chat: top line (people in chat, full screen), titles, full-screen mode ---------- */
557
+ .chat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
558
+ .chat-here { display: inline-flex; align-items: center; gap: 7px; }
559
+ .chat-here .online-dot { width: 7px; height: 7px; }
560
+ .chat-title-input { width: 100px; }
561
+ .chat-title-pill { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 9px; background: color-mix(in srgb, var(--glow-violet, #8b5cf6) 30%, transparent); color: var(--text); font-size: 11px; font-weight: 700; line-height: 18px; vertical-align: 1px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
562
+ .chat-box.full { position: fixed; inset: 0; z-index: 85; height: auto; border-radius: 0; border: 0; background: var(--bg); }
563
+ .chat-box.full .chat-log { padding: 18px max(16px, calc((100vw - 900px) / 2)); }
564
+ .chat-box.full .chat-form, .chat-box.full .chat-top { padding-left: max(12px, calc((100vw - 900px) / 2)); padding-right: max(12px, calc((100vw - 900px) / 2)); }
565
+ body.chat-full { overflow: hidden; }
566
+ @media (max-width: 720px) { .chat-title-input { width: 72px; } }
567
+
568
+ /* ---------- Quote of the day: a long bar across the top of the front page ---------- */
569
+ .quote-strip {
570
+ position: absolute; top: 14px; left: clamp(16px, 3vw, 44px); right: 150px; /* room for the clock */
571
+ display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 16px;
572
+ border: 1px solid var(--line-2); border-radius: 6px; background: color-mix(in srgb, var(--panel) 80%, transparent); font-size: 14px;
573
+ }
574
+ .quote-label { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--glow-cyan, #22d3ee); }
575
+ .quote-text { flex: 0 1 auto; min-width: 0; font-style: italic; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; quotes: "β€œ" "”"; }
576
+ .quote-text.is-empty { font-style: normal; color: var(--muted); quotes: none; }
577
+ .quote-by { flex: none; color: var(--muted); font-size: 13px; }
578
+ .quote-by:empty { display: none; }
579
+ .quote-strip .text-btn.link { flex: none; margin-left: auto; font-size: 13px; }
580
+ .home { position: relative; }
581
+ @media (max-width: 720px) {
582
+ .quote-strip { right: 16px; flex-wrap: wrap; }
583
+ .quote-text { white-space: normal; flex-basis: 100%; order: 1; }
584
+ }
585
+
586
+ /* ---------- Front page, bottom-left corner: bookmark chip, latest version, what's new ---------- */
587
+ .home-corner { position: fixed; left: calc(var(--rail-w) + 14px); bottom: 12px; z-index: 5; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
588
+ .home-corner .bookmark-row { margin: 0; justify-content: flex-start; }
589
+ .home-corner .whats-new-row { margin: 0; }
590
+ @media (max-width: 720px) { .home-corner { position: static; align-items: center; margin-top: 22px; } }
591
+
592
+ /* ---------- Live ---------- */
593
+ .live { padding-top: 26px; padding-bottom: 40px; }
594
+ .live-pill { display: inline-block; vertical-align: middle; margin-left: 8px; padding: 2px 9px; border-radius: 4px; background: #dc2626; color: #fff; font-size: 13px; letter-spacing: .04em; animation: unread-pulse 1.6s ease-in-out infinite; }
595
+ .live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: stretch; margin-bottom: 16px; }
596
+ .live-stage { position: relative; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
597
+ .live-stage video { display: block; }
598
+ #live-screen { width: 100%; height: 100%; object-fit: contain; }
599
+ #live-cam { position: absolute; right: 12px; bottom: 12px; width: 24%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 8px 24px rgba(0,0,0,.6); background: #111; }
600
+ .live-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: #fff; text-align: center; background: radial-gradient(circle at 50% 40%, #1e293b, #000); }
601
+ .live-overlay p { margin: 0; font-size: 18px; font-weight: 700; }
602
+ .live-overlay .pill-btn { height: 40px; padding: 0 20px; background: #dc2626; border-color: #dc2626; }
603
+ .live-unmute { position: absolute; left: 12px; bottom: 12px; }
604
+ .live-chat { min-height: 0; min-width: 0; display: flex; }
605
+ .live-chat .chat-box { flex: 1; height: auto; min-height: 360px; min-width: 0; }
606
+ .live-stage { min-width: 0; }
607
+ .live-owner .set-row { flex-wrap: wrap; }
608
+ .live-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
609
+ .live-owner .pill-btn { height: 38px; padding: 0 18px; }
610
+ .rail-btn.is-live { color: #ef4444; }
611
+ .rail-btn.is-live::before { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px var(--bg), 0 0 10px #ef4444; }
612
+ @media (max-width: 1000px) { .live-layout { grid-template-columns: 1fr; } .live-chat .chat-box { min-height: 420px; } }
613
+ body:has(#view-live:not([hidden])) .corner-links { display: none; }
614
+
615
+ /* Take-a-photo window */
616
+ .cam-card { width: min(560px, 100%); }
617
+ .cam-view { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; }
618
+ .cam-view video, .cam-view canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
619
+ .cam-view video { transform: scaleX(-1); } /* mirror like a selfie camera */