/* ================= Chat ================= */
#chat-root {
  --cx-bg: #0e1512;
  --cx-panel-line: rgba(255, 255, 255, .08);
  --cx-raised: rgba(255, 255, 255, .04);
  --cx-raised-2: rgba(255, 255, 255, .07);
  --cx-text: #e8eeea;
  --cx-muted: #8a9a91;
  --cx-green: var(--accent, #22c55e);
  --cx-green-text: var(--accent-strong, #4ade80);
  --cx-red: var(--danger, #f87171);
  --cx-amber: var(--warn, #fbbf24);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--cx-text);
}
#chat-root button { font: inherit; cursor: pointer; color: inherit; }
#chat-root svg { display: block; }

/* ---------- launcher ---------- */
.cx-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; align-items: center; gap: .5rem; height: 44px; padding: 0 1rem 0 .85rem;
  border-radius: 22px; border: 1px solid var(--cx-panel-line);
  background: var(--cx-bg); color: var(--cx-text); font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.cx-fab:hover { border-color: rgba(255, 255, 255, .18); background: #131d18; }
.cx-fab svg { color: var(--cx-green-text); }
.cx-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--cx-red); color: #fff;
}

/* ---------- panel ---------- */
.cx-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  width: 340px; height: min(600px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--cx-bg); border: 1px solid var(--cx-panel-line); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
}
.cx-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px 16px; }
.cx-title { display: flex; align-items: baseline; gap: 10px; font-size: 15px; font-weight: 700; }
.cx-online { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--cx-muted); }
.cx-online i { width: 6px; height: 6px; border-radius: 50%; background: var(--cx-green); }

.cx-ibtn {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border: none; border-radius: 8px; background: transparent; color: var(--cx-muted) !important;
}
.cx-ibtn:hover, .cx-ibtn.on { background: var(--cx-raised-2); color: var(--cx-text) !important; }

.cx-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--cx-panel-line); overflow-x: auto; scrollbar-width: none; }
.cx-tabs button {
  flex: none; max-width: 12rem; padding: 8px 10px 9px; border: none; background: none;
  color: var(--cx-muted) !important; font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-tabs button:hover { color: var(--cx-text) !important; }
.cx-tabs button.active { color: var(--cx-text) !important; border-bottom-color: var(--cx-green); }

/* ---------- messages ---------- */
.cx-list { flex: 1; overflow-y: auto; padding: 4px 0 12px; }
.cx-list::-webkit-scrollbar { width: 6px; }
.cx-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .1); border-radius: 3px; }

.cx-day { display: flex; align-items: center; gap: 10px; margin: 14px 16px 4px; font-size: 11px; font-weight: 600; color: var(--cx-muted); }
.cx-day::before, .cx-day::after { content: ""; flex: 1; height: 1px; background: var(--cx-panel-line); }

.cx-group { display: flex; gap: 10px; padding: 6px 16px 2px; }
.cx-avatar {
  width: 32px; height: 32px; flex: none; margin-top: 2px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: hsl(var(--hue) 30% 26%); color: hsl(var(--hue) 55% 82%);
}
.cx-body { min-width: 0; flex: 1; }
.cx-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 1px; font-size: 12px; color: var(--cx-muted); }
.cx-name { color: var(--cx-text); font-weight: 600; font-size: 13px; }
.cx-group.mine .cx-name { color: var(--cx-green-text); }
.cx-chip { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 0 4px; border-radius: 4px; background: var(--cx-raised-2); color: var(--cx-muted); line-height: 16px; }
.cx-chip-clan { color: #e5c76b; background: rgba(229, 199, 107, .1); }
.cx-meta time { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; }

.cx-item { position: relative; margin: 0 -8px; padding: 2px 8px; border-radius: 6px; }
.cx-item:hover, .cx-item.show-tools { background: var(--cx-raised); }
.cx-text { white-space: pre-wrap; overflow-wrap: anywhere; color: #d7dfda; }
.cx-note { font-size: 12px; color: var(--cx-muted); margin: 2px 0 6px; }
.cx-item .tk + .cx-text { margin-top: 6px; }

.cx-tools {
  position: absolute; right: 4px; top: -14px; z-index: 2;
  display: none; align-items: center; gap: 1px; padding: 2px;
  border-radius: 8px; background: #17221c; border: 1px solid var(--cx-panel-line); box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.cx-item:hover > .cx-tools, .cx-item.show-tools > .cx-tools { display: flex; }
.cx-tool { border: none; background: none; width: 28px; height: 26px; border-radius: 6px; font-size: 14px; display: grid; place-items: center; }
.cx-tool:hover { background: var(--cx-raised-2); }
.cx-tool-icon { color: var(--cx-muted) !important; }
.cx-tool-icon:hover { color: var(--cx-red) !important; }

.cx-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cx-react {
  display: flex; align-items: center; gap: 4px; height: 24px; padding: 0 7px;
  border-radius: 6px; font-size: 13px; background: var(--cx-raised-2); border: 1px solid transparent;
}
.cx-react span { font-size: 12px; font-weight: 600; color: var(--cx-muted); }
.cx-react.mine { border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .1); }
.cx-react.mine span { color: var(--cx-green-text); }

.cx-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0 32px; text-align: center; color: var(--cx-muted); font-size: 13px; }
.cx-empty b { color: var(--cx-text); font-size: 14px; }

/* ---------- bet receipt ---------- */
.tk {
  max-width: 320px; border-radius: 10px; overflow: hidden;
  background: #121c17; border: 1px solid var(--cx-panel-line); border-left: 3px solid var(--cx-muted);
  font-variant-numeric: tabular-nums;
}
.tk-won { border-left-color: var(--cx-green); }
.tk-lost { border-left-color: var(--cx-red); }
.tk-open { border-left-color: #60a5fa; }
.tk-void { border-left-color: var(--cx-amber); }

.tk-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--cx-panel-line); }
.tk-kind { font-size: 12px; font-weight: 600; color: var(--cx-muted); text-transform: uppercase; letter-spacing: .05em; }
.tk-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; background: var(--cx-raised-2); color: var(--cx-muted); }
.tk-won .tk-status { background: rgba(34, 197, 94, .14); color: var(--cx-green-text); }
.tk-lost .tk-status { background: rgba(248, 113, 113, .14); color: var(--cx-red); }
.tk-open .tk-status { background: rgba(96, 165, 250, .14); color: #93c5fd; }
.tk-void .tk-status { background: rgba(251, 191, 36, .14); color: var(--cx-amber); }

.tk-legs { padding: 4px 12px; }
.tk-leg { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; }
.tk-leg + .tk-leg { border-top: 1px solid rgba(255, 255, 255, .05); }
.tk-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.tk-leg.won .tk-dot { background: var(--cx-green); }
.tk-leg.lost .tk-dot { background: var(--cx-red); }
.tk-leg.void .tk-dot { background: var(--cx-amber); }
.tk-leg-main { min-width: 0; }
.tk-teams { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-pick { font-size: 12px; color: var(--cx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-pick b { color: #c9d4cd; font-weight: 600; }
.tk-leg-side { display: flex; flex-direction: column; align-items: flex-end; }
.tk-leg-side b { font-size: 13px; }
.tk-leg-side small { font-size: 11px; color: var(--cx-muted); }
.tk-more { font-size: 12px; color: var(--cx-muted); padding: 4px 0 6px 18px; }

.tk-foot { display: grid; grid-template-columns: 1fr 1fr 1.3fr; border-top: 1px solid var(--cx-panel-line); background: rgba(0, 0, 0, .15); }
.tk-foot > div { display: flex; flex-direction: column; padding: 7px 12px; }
.tk-foot > div + div { border-left: 1px solid var(--cx-panel-line); }
.tk-foot small { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--cx-muted); }
.tk-foot b { font-size: 14px; }
.tk-won .tk-return b { color: var(--cx-green-text); }
.tk-lost .tk-return b { color: var(--cx-muted); }

/* ---------- composer & trays ---------- */
.cx-err { margin: 0 12px 6px; padding: 7px 10px; border-radius: 8px; font-size: 12px; color: #fecaca; background: rgba(248, 113, 113, .12); }
.cx-composer { display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--cx-panel-line); }
.cx-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; padding: 0 4px;
  border-radius: 10px; background: var(--cx-raised-2); border: 1px solid transparent;
}
.cx-field:focus-within { border-color: rgba(34, 197, 94, .55); }
.cx-input { flex: 1; min-width: 0; width: 100%; height: 38px; padding: 0 6px; border: none; outline: none; background: transparent; color: var(--cx-text); font: inherit; }
.cx-input::placeholder { color: #6f7f76; }
.cx-input-box { height: 38px; padding: 0 12px; border-radius: 10px; background: var(--cx-raised-2); border: 1px solid transparent; }
.cx-input-box:focus { border-color: rgba(34, 197, 94, .55); }
.cx-send {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; border: none;
  background: var(--cx-green); color: #052e16 !important;
}
.cx-send:hover { filter: brightness(1.08); }
.cx-login { padding: 14px; text-align: center; color: var(--cx-muted); border-top: 1px solid var(--cx-panel-line); font-size: 13px; }

.cx-tray { border-top: 1px solid var(--cx-panel-line); padding: 10px 12px; max-height: 240px; overflow-y: auto; }
.cx-emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.cx-emojis button { border: none; background: none; height: 34px; font-size: 18px; border-radius: 6px; }
.cx-emojis button:hover { background: var(--cx-raised-2); }
.cx-tray-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--cx-muted); margin-bottom: 8px; }
.cx-muted { color: var(--cx-muted); font-size: 13px; }
.cx-pick {
  width: 100%; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; margin-bottom: 4px; border-radius: 8px; text-align: left; font-variant-numeric: tabular-nums;
  background: var(--cx-raised); border: 1px solid var(--cx-panel-line);
}
.cx-pick:hover { background: var(--cx-raised-2); }
.cx-pick .tk-status { text-align: center; }
.cx-pick-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-pick.tk-won b { color: var(--cx-green-text); }

/* ---------- share dialog ---------- */
.cx-share { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-top: 1px solid var(--cx-panel-line); background: #101915; }
.cx-share-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.cx-share .tk { max-width: none; }
.cx-seg { display: flex; padding: 3px; gap: 3px; border-radius: 9px; background: var(--cx-raised-2); }
.cx-seg button {
  flex: 1; min-width: 0; padding: 6px 8px; border: none; border-radius: 7px; background: none;
  color: var(--cx-muted) !important; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-seg button.active { background: #1f2b25; color: var(--cx-text) !important; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.cx-primary {
  height: 40px; border: none; border-radius: 10px; font-weight: 700;
  background: var(--cx-green); color: #052e16 !important;
}
.cx-primary:hover { filter: brightness(1.08); }

/* ---------- "Share" button on My Bets ---------- */
.share-btn { margin-right: .4rem; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .cx-fab { bottom: 76px; right: 14px; height: 42px; }
  .cx-panel { inset: 0; width: auto; height: auto; border: none; border-radius: 0; z-index: 55; }
  .cx-share { max-height: 75vh; overflow-y: auto; }
}
@media (hover: none) {
  .cx-item:hover { background: none; }
  .cx-item:hover > .cx-tools { display: none; }
  .cx-item.show-tools { background: var(--cx-raised); }
  .cx-item.show-tools > .cx-tools { display: flex; }
}

/* Keep the page's global input styles out of the chat field */
#chat-root .cx-field .cx-input, #chat-root .cx-field .cx-input:focus { outline: none; box-shadow: none; border: none; background: transparent; }
#chat-root .cx-input-box:focus { outline: none; box-shadow: none; }
.cx-share { overflow-y: auto; max-height: 80%; }
.cx-share > * { flex-shrink: 0; }

/* level chip next to names (colour follows the rank tier) */
.cx-lvl { color: #c9d4cd; }
.cx-lvl.lvl-amateur { color: #93c5fd; background: rgba(147, 197, 253, .12); }
.cx-lvl.lvl-semipro { color: #86efac; background: rgba(134, 239, 172, .12); }
.cx-lvl.lvl-pro { color: #c4b5fd; background: rgba(196, 181, 253, .14); }
.cx-lvl.lvl-elite { color: #fda4af; background: rgba(253, 164, 175, .14); }
.cx-lvl.lvl-legend { color: #fcd34d; background: rgba(252, 211, 77, .16); }

/* ---------- shared ticket: actions ---------- */
.tk-foot { border-bottom: 1px solid var(--cx-panel-line); }
.tk > .tk-foot:last-child { border-bottom: none; }
.tk-actions { display: flex; gap: 6px; padding: 8px 10px; }
.tk-btn {
  flex: 1; height: 30px; border-radius: 7px; font-size: 12px; font-weight: 600;
  background: var(--cx-raised-2); border: 1px solid var(--cx-panel-line); color: var(--cx-text) !important;
}
.tk-btn:hover { border-color: rgba(255, 255, 255, .2); }
.tk-copy { background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .45); color: var(--cx-green-text) !important; }
.tk-copy:hover { background: rgba(34, 197, 94, .22); }
.tk-head + .tk-foot { border-top: none; }
