/* Chat compartido (billar, Caos Pixel…): mensajes, emojis, reacciones rápidas y stickers, palabras
   propias, favoritas, silenciar y perfil de quien escribe. Lo usa public/billar/js/chat.js; cada juego
   pone el panel donde quiera (posición y tamaño en su propia hoja). */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 85%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 11px; color: var(--muted); margin: 0 6px 2px; }
.msg .text {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 6px 11px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.msg.me .text { background: #2a1d5c; border-color: #5b3fc4; }
.msg.emoji-only .text { background: none; border: none; font-size: 34px; padding: 0 4px; }
.msg.sys { align-self: center; max-width: 95%; }
.msg.sys .text { background: none; border: none; color: #7f8ea3; font-style: italic; font-size: 12px; text-align: center; padding: 0; }

.quick-reactions {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.quick-reactions button {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 18px;
  padding: 3px 7px;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
  flex: none;
}
.quick-reactions button:hover { border-color: var(--accent); }
.quick-reactions .txt { font-size: 13px; }

.chat-form {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 8px 10px 10px;
}
.chat-form input { flex: 1; min-width: 0; padding: 8px 10px; }
.emoji-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 20px;
  width: 40px;
  cursor: pointer;
}
.emoji-btn:hover { border-color: var(--accent); }
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 10px;
  right: 10px;
  max-height: 210px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.emoji-picker button {
  background: none;
  border: none;
  font-size: 22px;
  padding: 4px 0;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-picker button:hover { background: var(--bg-2); }

/* chat del público */
.msg.spectator .who { color: var(--neon-c); }
/* los bots se distinguen de las personas: otro color y la etiqueta «bot» */
.msg.bot .who { color: var(--neon-p); }
.msg .who-tag.bot-tag { color: var(--neon-p); border-color: var(--neon-p); }
.msg .who-tag {
  margin-left: 5px;
  font: 400 9px var(--pixel-sm);
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0 3px;
  text-transform: uppercase;
}
.chat-form.readonly { opacity: 0.6; }
.chat-form.readonly input { cursor: not-allowed; }

/* ----------------------------------------------------------- stickers de texto (GG, IZI, palabras) */
.word-sticker {
  display: inline-block;
  font-family: var(--pixel);
  font-weight: 400;
  font-style: normal;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 1px;
  padding: 4px 12px 6px;
  border-radius: 8px;
  border: 3px solid #8b5cff;
  background: #120c2e;
  color: #fff;
  text-shadow: 2px 2px 0 #2a1060;
  box-shadow: 0 0 0 2px #0d0620, 0 0 16px rgba(139, 92, 255, 0.55), inset 0 0 12px rgba(139, 92, 255, 0.25);
  -webkit-text-stroke: 0;
  filter: none;
  transform: rotate(-4deg);
  white-space: nowrap;
}
.word-sticker.sticker-word {
  color: #22e0ff;
  border-color: #22e0ff;
  text-shadow: 2px 2px 0 #ff3fd8;
  box-shadow: 0 0 0 2px #0d0620, 0 0 16px rgba(34, 224, 255, 0.5), inset 0 0 12px rgba(255, 63, 216, 0.2);
}
.word-sticker.sticker-gg {
  color: #6bff3b;
  border-color: #6bff3b;
  text-shadow: 2px 2px 0 #1d4a10;
  box-shadow: 0 0 0 2px #0d0620, 0 0 18px rgba(107, 255, 59, 0.55), inset 0 0 12px rgba(107, 255, 59, 0.2);
}
.word-sticker.sticker-izi {
  color: #ffd23f;
  border-color: #ffd23f;
  font-style: italic;
  text-shadow: 2px 2px 0 #7a3d00;
  box-shadow: 0 0 0 2px #0d0620, 0 0 18px rgba(255, 210, 63, 0.55), inset 0 0 12px rgba(255, 140, 0, 0.25);
}
/* versión pequeña: botones de reacción, selector de emojis y editor */
.word-sticker.small {
  font-size: 13px;
  padding: 2px 7px 3px;
  border-width: 2px;
  border-radius: 6px;
  transform: none;
  box-shadow: 0 0 8px rgba(139, 92, 255, 0.35);
  text-shadow: 1px 1px 0 #2a1060;
}
.word-sticker.small.sticker-gg { box-shadow: 0 0 8px rgba(107, 255, 59, 0.35); text-shadow: 1px 1px 0 #1d4a10; }
.word-sticker.small.sticker-izi { box-shadow: 0 0 8px rgba(255, 210, 63, 0.35); text-shadow: 1px 1px 0 #7a3d00; }
.word-sticker.small.sticker-word { box-shadow: 0 0 8px rgba(34, 224, 255, 0.35); text-shadow: 1px 1px 0 #ff3fd8; }
.quick-reactions button.word-sticker { font-size: 13px; padding: 2px 7px 3px; }
.quick-reactions button.word-sticker:hover { filter: brightness(1.25); }
.emoji-picker button.word-sticker { grid-column: span 2; font-size: 14px; }

/* en el chat */
.msg.sticker-msg .text.word-sticker {
  font-size: 26px;
  padding: 4px 12px 6px;
  margin: 4px 6px 6px;
  border-radius: 8px;
}

/* palabras rápidas propias */
.quick-reactions button.custom { border-style: dashed; }
.quick-reactions .quick-edit {
  font-size: 15px;
  padding: 2px 8px;
  color: var(--neon-c);
  border: 1px dashed var(--neon-c);
  background: transparent;
}
.quick-editor {
  margin: 0 10px;
  padding: 10px;
  border: 2px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  display: grid;
  gap: 8px;
}
.qe-head { font-family: var(--pixel); font-size: 14px; }
.qe-head small { font-family: "Rubik", system-ui, sans-serif; color: var(--muted); font-size: 11px; }
.qe-form { display: flex; gap: 6px; }
.qe-form input { flex: 1; min-width: 0; padding: 6px 9px; }
.qe-list { display: flex; flex-wrap: wrap; gap: 8px; }
.qe-list .word-sticker { display: inline-flex; align-items: center; gap: 6px; }
.qe-del {
  border: 0;
  background: none;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  font-size: 11px;
  padding: 0 0 0 2px;
}
.qe-del:hover { color: var(--danger); -webkit-text-fill-color: var(--danger); }
.qe-empty { color: var(--muted); }

.msg.sticker-msg .text.word-sticker { background: #120c2e; border: 3px solid #8b5cff; overflow-wrap: normal; }
.msg.sticker-msg .text.word-sticker.sticker-gg { border-color: #6bff3b; }
.msg.sticker-msg .text.word-sticker.sticker-izi { border-color: #ffd23f; }
.msg.sticker-msg .text.word-sticker.sticker-word { border-color: #22e0ff; }
.qe-form input { width: 0; flex: 1 1 auto; }
.qe-form .btn { flex: none; }
/* IZI y GG en negrita sans: en las fuentes pixel la Z parece un 8 o un 2 */
.word-sticker.sticker-izi, .word-sticker.sticker-gg { font-family: "Rubik", system-ui, sans-serif; font-weight: 700; letter-spacing: 1px; }

/* limpiar el chat (solo en tu pantalla) */
.chat-clear { width: 34px; font-size: 16px; flex: none; }
.chat-clear:hover { border-color: var(--danger); background: rgba(229, 83, 75, 0.12); }
.msg.cleared .text { font-style: italic; }

/* emojis que usas mucho: aparecen solos en las reacciones rápidas */
.quick-reactions button.frequent { position: relative; border-style: dashed; border-color: rgba(255, 210, 63, 0.6); }
.quick-reactions button.frequent::after {
  content: "★";
  position: absolute;
  top: -5px;
  right: -4px;
  font-size: 9px;
  color: #ffd23f;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* silenciar a un jugador en el chat (solo para quien silencia) */
.msg { position: relative; }
.msg .who.can-mute { cursor: var(--cur-hand); }
.msg .who.can-mute:hover { color: var(--neon-c); text-decoration: underline; }
.mute-menu {
  position: absolute;
  top: 16px;
  left: 4px;
  z-index: 5;
  display: grid;
  gap: 4px;
  padding: 6px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}
.mute-menu button {
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  text-align: left;
}
.mute-menu button:hover { border-color: var(--danger); }
.mute-menu small { color: var(--muted); font-size: 11px; padding: 0 4px; }
.mute-menu button:disabled { opacity: 0.6; cursor: default; }
.mute-menu button:disabled:hover { border-color: var(--line); }
.mute-menu .pm-profile:hover, .mute-menu .pm-friend:hover { border-color: var(--neon-c); }

/* alguien nuevo entra como público */
.msg.sys.joined { align-items: center; }
.msg.sys.joined .person-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 4px; }
.person-actions button {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(34, 224, 255, 0.4);
  background: rgba(34, 224, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: var(--cur-hand);
}
.person-actions button:hover { border-color: var(--neon-c); }
.person-actions button:disabled { opacity: 0.6; cursor: default; }
.muted-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.muted-bar b { font-weight: 600; margin-right: 2px; }
.muted-chip {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(229, 83, 75, 0.5);
  background: rgba(229, 83, 75, 0.1);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.muted-chip:hover { border-color: var(--neon-g); background: rgba(107, 255, 59, 0.1); }

/* ---------------------------------------------------------- favoritas (clic derecho en una reacción) */
.fav-menu {
  position: fixed;
  z-index: 300;
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}
.fav-menu > b { padding: 2px 6px 4px; font-size: 20px; line-height: 1.1; text-align: center; border-bottom: 1px solid var(--line); }
.fav-menu button {
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: var(--cur-hand);
}
.fav-menu button:hover { border-color: var(--neon-y, #ffd23f); }
.fav-menu small { color: var(--muted); font-size: 11px; padding: 0 4px; }
.quick-reactions button, .emoji-picker button { -webkit-touch-callout: none; user-select: none; }

/* favoritas: arrastrar para ordenar */
#quick-reactions button.dragging { opacity: 0.35; }
#quick-reactions button.drag-over { outline: 2px dashed var(--neon-g); outline-offset: 2px; }

/* ===== panel del chat de los juegos con salas (public/js/game-chat.js: Caos Pixel, Ajedrez) ===== */
.cx-chat-panel { display: flex; flex-direction: column; height: 380px; min-height: 0; border-radius: 14px; border: 2px solid var(--line-2); background: var(--panel); overflow: hidden; }
.cx-chat-head { padding: 6px 8px; gap: 8px; }
.cx-chat-tabs { display: flex; gap: 4px; }
.cx-chat-tabs button { position: relative; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font: 600 13px "Rubik", system-ui, sans-serif; cursor: pointer; }
.cx-chat-tabs button.on { color: var(--text); border-color: var(--neon-p); background: rgba(139, 92, 255, 0.18); }
.cx-chat-tabs button:disabled { opacity: 0.45; cursor: default; }
.cx-chat-tabs button.unread::after, .cx-chat-btn.unread::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--neon-m); box-shadow: 0 0 6px var(--neon-m); }
.cx-chat-close { display: none; background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; }
.cx-chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cx-chat-body.hidden, .cx-chat-login.hidden { display: none; }
.cx-chat-panel .chat-log { min-height: 0; }
.cx-chat-panel .chat-log.hidden { display: none; }
.cx-chat-login { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 16px; text-align: center; color: var(--muted); }
.cx-chat-login p { margin: 0; }
.cx-chat-panel.in-game { position: absolute; left: 10px; bottom: 10px; z-index: 6; width: min(340px, calc(100% - 20px)); height: min(330px, 55%); background: rgba(20, 25, 54, 0.92); backdrop-filter: blur(3px); }
.cx-chat-panel.in-game .cx-chat-close { display: inline-block; }
.cx-chat-panel.in-game.closed { display: none; }

/* invitación pública a una mesa (chat general de cada juego): se entra desde el mismo chat */
.msg.invite-msg { max-width: 95%; }
.invite-card {
  display: grid; gap: 4px; padding: 8px 10px; border-radius: 10px;
  border: 2px solid rgba(107, 255, 59, 0.55); background: rgba(107, 255, 59, 0.08);
  box-shadow: 0 0 12px rgba(107, 255, 59, 0.12); overflow-wrap: anywhere;
}
.msg.me .invite-card { border-color: #5b3fc4; background: #2a1d5c; box-shadow: none; }
.invite-card b { font-size: 13px; line-height: 1.35; }
.invite-card small { color: var(--muted); font-size: 12px; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.invite-actions .btn { text-decoration: none; }

/* 📌 fijar el chat a la derecha o guardarlo en 💬 (public/js/chat-pin.js) */
.chat-pin-btn {
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 3px 9px;
  border: 1px solid var(--line-2, #3a4486);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 600 12px/1.2 inherit;
  white-space: nowrap;
  cursor: pointer;
}
.chat-pin-btn:hover { color: var(--text); border-color: var(--neon-c, #22e0ff); }
.chat-pin-btn.pinned { border-color: transparent; }
.chat-pin-btn.pinned .pin-lbl { display: none; }
.chat-pin-btn:not(.pinned) { color: var(--text); border-color: var(--neon-p, #8b5cff); background: rgba(139, 92, 255, 0.16); }
.chat-header .chat-pin-btn + .cx-chat-close, .chat-header .chat-pin-btn + .chat-close { margin-left: 6px; }

/* pantallas táctiles: nada del chat por debajo de ~36 px (el dedo no acierta en menos) */
@media (pointer: coarse) {
  .cx-chat-tabs button { min-height: 36px; padding: 7px 12px; }
  .cx-chat-close, .chat-close { min-width: 36px; min-height: 36px; font-size: 16px; }
  .quick-reactions .quick-edit { min-width: 36px; min-height: 36px; }
  .quick-reactions button.word-sticker { min-height: 34px; }
  .chat-pin-btn { min-height: 34px; }
}

/* hora de cada mensaje (public/js/chat-time.js): pequeña debajo; la fecha completa en el title */
.msg .msg-time { font-size: 10px; line-height: 1.2; color: var(--muted); opacity: 0.75; margin: 2px 8px 0; font-variant-numeric: tabular-nums; cursor: default; }
.msg:hover .msg-time { opacity: 1; }

/* menciones con @ (public/billar/js/chat.js): la lista al escribir @, el nick resaltado en el
   mensaje y, si me mencionan a mí, el mensaje marcado */
.quick-reactions .mention-btn { font: 700 15px "Rubik", system-ui, sans-serif; padding: 2px 9px; }
.mention-list {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 4px);
  z-index: 5;
  display: grid;
  gap: 2px;
  max-height: 230px;
  overflow-y: auto;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line-2, var(--line));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.mention-list.hidden { display: none; }
.mention-list button {
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: 600 14px "Rubik", system-ui, sans-serif;
  cursor: pointer;
}
.mention-list button:hover, .mention-list button.on { background: rgba(34, 224, 255, 0.14); color: var(--neon-c, #22e0ff); }
.mention-empty { margin: 4px 8px; color: var(--muted); font-size: 12.5px; }
.msg .mention { font-weight: 700; color: var(--neon-c, #22e0ff); }
.msg .mention.mention-me { color: #0d0620; background: var(--neon-y, #ffd23f); border-radius: 4px; padding: 0 3px; }
.msg.mentions-me .text { border-color: var(--neon-y, #ffd23f); box-shadow: 0 0 0 1px rgba(255, 210, 63, 0.45), 0 0 12px rgba(255, 210, 63, 0.25); }
@media (pointer: coarse) {
  .mention-list button { min-height: 40px; }
}

/* cola de salida: mensaje que aún no confirmó el servidor (o que no se pudo enviar) */
.msg.pending .text { opacity: 0.6; }
.msg .msg-status:empty { display: none; }
.msg .msg-status { font-size: 10px; color: var(--muted, #8b95a7); margin: 2px 6px 0; }
.msg.failed { cursor: pointer; }
.msg.failed .text { opacity: 0.85; border-style: dashed; border-color: #ff6b7a; }
.msg.failed .msg-status { color: #ff8a9a; }

/* responder a un mensaje: la cita encima del mensaje y la barra encima del campo de escribir */
.msg .reply-quote {
  display: block; max-width: 100%; margin: 0 0 3px; padding: 3px 8px; border: 0; border-left: 3px solid var(--neon-y, #ffd23f);
  border-radius: 6px; background: rgba(255, 255, 255, 0.06); color: var(--muted, #8b95a7); font: inherit; font-size: 11px;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.msg .reply-quote b { color: var(--text, #e8ecf3); margin-right: 2px; }
.msg .reply-quote:hover { background: rgba(255, 255, 255, 0.1); }
.msg.flash .text { animation: msg-flash 1.2s ease-out; }
@keyframes msg-flash { 0%, 30% { box-shadow: 0 0 0 2px var(--neon-y, #ffd23f); } 100% { box-shadow: 0 0 0 2px transparent; } }
.chat-reply-bar {
  display: flex; align-items: center; gap: 6px; margin: 0 0 4px; padding: 4px 6px 4px 10px; border-left: 3px solid var(--neon-y, #ffd23f);
  border-radius: 6px; background: rgba(255, 255, 255, 0.06); font-size: 12px; color: var(--muted, #8b95a7);
}
.chat-reply-bar.hidden { display: none; }
.chat-reply-bar > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-reply-bar b { color: var(--text, #e8ecf3); }
.chat-reply-x { flex: none; border: 0; background: none; color: var(--muted, #8b95a7); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.chat-reply-x:hover { color: var(--text, #e8ecf3); }
