/* Board Parlor online chat (chat.js). Colours follow the game's tutorial palette; a game can
   override --chat-accent, --chat-accent-ink, --chat-panel, --chat-ink, --chat-muted, --chat-mine. */
.chat-wrap, .chat-banner, .chat-btn {
  --chat-accent: var(--tut-accent, #ffcf5a);
  --chat-accent-ink: var(--tut-accent-ink, #2a1a08);
  --chat-panel: var(--tut-bubble, #fbf6ee);
  --chat-ink: var(--tut-ink, #1d1d24);
  --chat-muted: var(--tut-muted, #6d6878);
  --chat-mine: var(--chat-accent);
}

/* the button (in the top bar, next to the menu; both in one slot so grid top bars keep their columns) */
.chat-slot { display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; justify-self: end; flex: none; }
.chat-btn { position: relative; }
.chat-btn svg { display: block; margin: auto; }
.chat-btn.floating {
  position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 60;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--chat-accent); color: var(--chat-accent-ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.chat-badge {
  position: absolute; top: 2px; right: 0; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: #e5484d; color: #fff; font: 800 11px/19px system-ui, -apple-system, sans-serif; text-align: center;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); pointer-events: none; animation: chat-pop .25s ease-out;
}

/* a new message while the chat is closed */
.chat-banner {
  position: fixed; top: max(58px, calc(env(safe-area-inset-top) + 52px)); left: 50%; transform: translateX(-50%); z-index: 70;
  width: min(92vw, 440px); display: flex; gap: 6px; align-items: baseline; text-align: left;
  padding: 11px 15px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--chat-panel); color: var(--chat-ink); font: 15px/1.35 system-ui, -apple-system, sans-serif;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: chat-drop .22s ease-out;
}
.chat-banner .chat-who { flex: none; }
.chat-banner .chat-said { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the panel */
.chat-wrap { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.chat-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); }
.chat-panel {
  position: relative; width: 100%; max-width: 520px; max-height: min(70vh, 560px); display: flex; flex-direction: column;
  background: var(--chat-panel); color: var(--chat-ink); border-radius: 20px 20px 0 0;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .3);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; animation: chat-up .18s ease-out;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; }
.chat-title { margin: 0; font-size: 17px; font-weight: 750; }
.chat-close { width: 40px; height: 40px; border: 0; border-radius: 12px; background: none; color: var(--chat-muted); font-size: 26px; line-height: 1; cursor: pointer; }
.chat-list { list-style: none; margin: 0; padding: 4px 2px 8px; overflow-y: auto; flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { max-width: 82%; display: flex; flex-direction: column; }
.chat-msg .chat-text { padding: 7px 12px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-msg.theirs { align-self: flex-start; }
.chat-msg .chat-name { font-size: 12px; font-weight: 700; color: var(--chat-muted); margin: 0 0 2px 6px; }
.chat-msg.theirs .chat-text { background: rgba(0, 0, 0, .07); border-bottom-left-radius: 5px; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.mine .chat-text { background: var(--chat-mine); color: var(--chat-accent-ink); border-bottom-right-radius: 5px; }
.chat-msg.sending .chat-text { opacity: .6; }
.chat-msg.failed .chat-text { opacity: .6; }
.chat-retry { margin-top: 3px; padding: 2px 4px; border: 0; background: none; color: #c0392b; font: 600 12px/1.3 system-ui, sans-serif; cursor: pointer; text-align: right; }
.chat-note { align-self: center; font-size: 12px; color: var(--chat-muted); padding: 4px 0; }
.chat-empty { align-self: center; margin: auto 0; text-align: center; font-size: 14px; color: var(--chat-muted); padding: 16px 8px; }
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-q { flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 18px; background: rgba(0, 0, 0, .07); color: var(--chat-ink); font: 600 14px/1 system-ui, sans-serif; cursor: pointer; }
.chat-row { display: flex; gap: 8px; }
.chat-input {
  flex: 1 1 auto; min-width: 0; min-height: 46px; padding: 0 14px; border-radius: 23px;
  border: 1.5px solid rgba(0, 0, 0, .16); background: #fff; color: #1d1d24; font: 16px/1.2 system-ui, -apple-system, sans-serif;
}
.chat-input:focus { outline: none; border-color: var(--chat-accent); box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); }
.chat-send { flex: none; min-height: 46px; padding: 0 18px; border: 0; border-radius: 23px; background: var(--chat-accent); color: var(--chat-accent-ink); font: 750 15px/1 system-ui, sans-serif; cursor: pointer; }
.chat-q:active, .chat-send:active { transform: translateY(1px); }

@keyframes chat-up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes chat-drop { from { transform: translate(-50%, -10px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes chat-pop { from { transform: scale(.4); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-panel, .chat-banner, .chat-badge { animation: none; } }
