/* ══════════════════════════════════════════════════════════════════
   LEVEL BADGES — 12 tier, TẤT CẢ ĐỀU CÓ HIỆU ỨNG (shimmer + pulse),
   CHỈ KHÁC NHAU VỀ MÀU. Render bởi chat-v2.js getLevelBadgeHTML()
   ══════════════════════════════════════════════════════════════════ */

.lv {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  font: 800 10px/1 ui-monospace, Menlo, monospace;
  color: #fff;
  letter-spacing: .3px;
  white-space: nowrap;
  border: 1.5px solid rgba(255,255,255,.6);
  position: relative;
  user-select: none;
  vertical-align: middle;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  margin-right: 5px;
  overflow: hidden;
  /* PULSE GLOW chung cho mọi level */
  animation: lv-pulse 2s ease-in-out infinite;
}
.lv .lv-ico {
  width: 10px; height: 10px;
  fill: #fff;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
  flex-shrink: 0;
  position: relative; z-index: 2;
}
.lv .lv-num { font-weight: 900; font-size: 10px; position: relative; z-index: 2; }

/* SHIMMER chung — chạy qua mọi badge */
.lv::before {
  content: ''; position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: lv-shimmer 2.4s infinite;
  pointer-events: none;
  z-index: 1;
}

/* PULSE GLOW dùng box-shadow var để mỗi tier override màu glow riêng */
@keyframes lv-pulse {
  0%,100% { box-shadow: 0 2px 8px var(--lv-glow, rgba(255,255,255,.35)), inset 0 1px 0 rgba(255,255,255,.3); }
  50%     { box-shadow: 0 4px 16px var(--lv-glow-strong, rgba(255,255,255,.6)), inset 0 1px 0 rgba(255,255,255,.5); }
}

@keyframes lv-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ──────── 12 TIER CHỈ KHÁC MÀU ──────── */

.lv-tier1 {
  background: linear-gradient(135deg, #6b7280, #4b5563);
  --lv-glow: rgba(107,114,128,.55); --lv-glow-strong: rgba(107,114,128,.85);
}
.lv-tier2 {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  --lv-glow: rgba(245,158,11,.55); --lv-glow-strong: rgba(245,158,11,.9);
}
.lv-tier3 {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  --lv-glow: rgba(59,130,246,.55); --lv-glow-strong: rgba(6,182,212,.9);
}
.lv-tier4 {
  background: linear-gradient(135deg, #f59e0b, #fbbf24 40%, #fde047);
  color: #422006; text-shadow: 0 1px 1px rgba(255,255,255,.4);
  --lv-glow: rgba(251,191,36,.6); --lv-glow-strong: rgba(253,224,71,.95);
}
.lv-tier4 .lv-ico { fill: #422006; }
.lv-tier5 {
  background: linear-gradient(135deg, #10b981, #34d399);
  --lv-glow: rgba(16,185,129,.55); --lv-glow-strong: rgba(52,211,153,.9);
}
.lv-tier6 {
  background: linear-gradient(135deg, #06b6d4, #0ea5e9, #67e8f9);
  border-color: rgba(255,255,255,.75);
  --lv-glow: rgba(6,182,212,.6); --lv-glow-strong: rgba(103,232,249,.95);
}
.lv-tier7 {
  background: linear-gradient(135deg, #7c3aed, #a855f7, #c084fc);
  --lv-glow: rgba(168,85,247,.6); --lv-glow-strong: rgba(192,132,252,.95);
}
.lv-tier8 {
  background: linear-gradient(135deg, #ec4899, #f43f5e, #fb7185);
  border-color: rgba(255,255,255,.78);
  --lv-glow: rgba(236,72,153,.65); --lv-glow-strong: rgba(251,113,133,.95);
}
.lv-tier9 {
  background: linear-gradient(135deg, #f97316, #ef4444, #dc2626);
  border-color: rgba(255,200,100,.85);
  --lv-glow: rgba(239,68,68,.7); --lv-glow-strong: rgba(220,38,38,1);
}
.lv-tier10 {
  background: linear-gradient(135deg, #fbbf24, #f43f5e, #a855f7, #fbbf24) 0 0/300% 100%;
  border-color: rgba(255,255,255,.85);
  --lv-glow: rgba(244,63,94,.7); --lv-glow-strong: rgba(168,85,247,1);
  animation: lv-pulse 2s ease-in-out infinite, lv-shift 4s ease-in-out infinite;
}
.lv-tier11 {
  background: linear-gradient(135deg, #ff006e, #fb5607, #ffbe0b, #8338ec, #3a86ff, #06ffa5, #ff006e) 0 0/400% 100%;
  border: 2px solid rgba(255,255,255,.9);
  padding: 3px 9px 3px 6px;
  --lv-glow: rgba(131,56,236,.7); --lv-glow-strong: rgba(255,0,110,.95);
  animation: lv-pulse 1.6s ease-in-out infinite, lv-rainbow 3.5s linear infinite;
}
.lv-tier11 .lv-num { font-size: 11px; }

.lv-vip {
  background: linear-gradient(135deg, #f59e0b 0%, #eab308 25%, #dc2626 50%, #c026d3 75%, #2563eb 100%) 0 0/200% 100%;
  border: 2px solid #ffd700;
  padding: 3px 10px 3px 7px;
  --lv-glow: rgba(220,38,38,.7); --lv-glow-strong: rgba(245,158,11,1);
  animation: lv-pulse 1.5s ease-in-out infinite, lv-shift 2.5s linear infinite;
}
.lv-vip .lv-num { font-size: 11px; font-weight: 900; }

.lv-cskh {
  background: linear-gradient(135deg, #16a34a, #15803d);
  --lv-glow: rgba(22,163,74,.6); --lv-glow-strong: rgba(21,128,61,.95);
}

/* Animation phụ — color shift cho tier10/vip + rainbow cho tier11 */
@keyframes lv-shift {
  0%,100% { background-position: 0 0; }
  50%     { background-position: 100% 0; }
}
@keyframes lv-rainbow {
  0%   { background-position: 0 0; }
  100% { background-position: 400% 0; }
}

/* Mobile: thu nhỏ tí */
@media (max-width: 480px) {
  .lv { padding: 1px 6px 1px 4px; font-size: 9px; }
  .lv .lv-num { font-size: 9px; }
  .lv .lv-ico { width: 9px; height: 9px; }
}

/* ══════════════════════════════════════════════════════════════════
   CHAT MESSAGE EFFECTS — v2 READABILITY FIRST
   - Tên gradient SOLID (không glow blur)
   - Message: WHITE 100% + text-shadow sharp đen — đọc cực rõ trên mọi nền
   - Frame VIP/SVIP: bg đậm hơn để text bên trong nổi bật
   ══════════════════════════════════════════════════════════════════ */

/* ---- Base row ---- */
.msg-row{
  padding: 6px 10px;
  margin: 3px 6px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: #ffffff;
  word-break: break-word;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  animation: msg-slide-in .28s ease-out both;
  transition: background .18s ease;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
.msg-row:hover{ background: rgba(255,255,255,.07); }

@keyframes msg-slide-in{
  0%   { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ---- Name & text base — chữ rõ là ưu tiên ---- */
.msg-name{
  font-weight: 800;
  margin-right: 6px;
  letter-spacing: .1px;
  /* Stroke đen viền chữ giúp tên đọc rõ trên mọi nền */
  text-shadow:
    0 1px 0 rgba(0,0,0,.85),
    0 0 3px rgba(0,0,0,.7);
}
.msg-text{
  color: #ffffff;
  font-weight: 500;
  /* Sharp dark shadow — KHÔNG blur, chỉ tạo viền tách text khỏi nền */
  text-shadow:
    0 1px 0 rgba(0,0,0,.85),
    0 0 2px rgba(0,0,0,.5);
}

/* ---- Per-tier name SOLID color (đậm + bão hòa, viền đen sharp) ---- */
/* KHÔNG dùng gradient + transparent fill nữa vì blur khó đọc */

.msg-row.msg-tier1 .msg-name{ color: #e2e8f0; }
.msg-row.msg-tier2 .msg-name{ color: #fcd34d; }
.msg-row.msg-tier3 .msg-name{ color: #60a5fa; }
.msg-row.msg-tier4 .msg-name{ color: #fde047; }
.msg-row.msg-tier5 .msg-name{ color: #4ade80; }
.msg-row.msg-tier6 .msg-name{ color: #22d3ee; }
.msg-row.msg-tier7 .msg-name{ color: #c084fc; }
.msg-row.msg-tier8 .msg-name{ color: #f472b6; }
.msg-row.msg-tier9 .msg-name{ color: #fb923c; }
.msg-row.msg-tier10 .msg-name{ color: #f472b6; }
.msg-row.msg-tier11 .msg-name{
  /* Tier max riêng có gradient nhẹ + drop-shadow CỰC NHỎ để vẫn đọc rõ */
  background: linear-gradient(90deg, #ff006e, #fb5607, #ffbe0b, #06ffa5, #3a86ff, #8338ec);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.9)) drop-shadow(0 0 1px rgba(0,0,0,.6));
}
.msg-row.msg-cskh .msg-name{ color: #4ade80; }

/* ---- VIP frame: VÀNG, bg đậm hơn để chữ trắng nổi ---- */
.msg-row.msg-vip{
  padding: 7px 12px;
  margin: 5px 6px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(180,83,9,.35), rgba(120,53,15,.45), rgba(180,83,9,.35));
  border: 1px solid rgba(252,211,77,.7);
  box-shadow:
    0 0 0 1px rgba(252,211,77,.15),
    0 2px 12px rgba(245,158,11,.18);
}
.msg-row.msg-vip .msg-name{
  color: #fde047;
  text-shadow:
    0 1px 0 rgba(0,0,0,.9),
    0 0 4px rgba(0,0,0,.6);
}
.msg-row.msg-vip .msg-text{
  color: #ffffff;
  font-weight: 500;
  text-shadow: 0 1px 0 rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.6);
}

/* ---- SVIP frame: TÍM, bg đậm hơn ---- */
.msg-row.msg-svip{
  padding: 7px 12px;
  margin: 5px 6px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(91,33,182,.4), rgba(76,29,149,.5), rgba(91,33,182,.4));
  border: 1px solid rgba(192,132,252,.75);
  box-shadow:
    0 0 0 1px rgba(192,132,252,.18),
    0 2px 12px rgba(168,85,247,.2);
}
.msg-row.msg-svip .msg-name{
  color: #e9d5ff;
  text-shadow:
    0 1px 0 rgba(0,0,0,.9),
    0 0 4px rgba(0,0,0,.6);
}
.msg-row.msg-svip .msg-text{
  color: #ffffff;
  font-weight: 500;
  text-shadow: 0 1px 0 rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.6);
}

/* ---- CSKH bg xanh dịu ---- */
.msg-row.msg-cskh{
  background:
    linear-gradient(135deg, rgba(22,101,52,.3), rgba(20,83,45,.4), rgba(22,101,52,.3));
  border: 1px solid rgba(74,222,128,.5);
}

/* Mobile */
@media (max-width: 480px){
  .msg-row{ padding: 6px 9px; font-size: 13px; margin: 3px 4px; }
  .msg-row.msg-vip,
  .msg-row.msg-svip,
  .msg-row.msg-cskh{ padding: 7px 11px; margin: 4px 4px; }
}

/* ══════════════════════════════════════════════════════════════════
   LIGHT MODE — site dùng html:not(.dark) (Tailwind dark class)
   Mọi override cần !important vì CSS dark được set với specificity bằng nhau
   Palette nhất quán với tailwind-input.css của site:
     body bg #f5f7fb, card #fff, soft #eef2f7, text #1a1f2e
   ══════════════════════════════════════════════════════════════════ */

/* Base row trên light mode: nền trắng dịu + viền nhạt, KHÔNG dùng dark text-shadow */
html:not(.dark) .msg-row{
  color: #1a1f2e !important;
  background: rgba(15,23,42,.04) !important;
  border-color: rgba(15,23,42,.10) !important;
}
html:not(.dark) .msg-row:hover{ background: rgba(15,23,42,.07) !important; }

/* Name + text base — KHÔNG có dark shadow nữa, dùng white shadow nhẹ */
html:not(.dark) .msg-name{
  text-shadow: 0 1px 0 rgba(255,255,255,.7) !important;
}
html:not(.dark) .msg-text{
  color: #1a1f2e !important;
  text-shadow: 0 1px 0 rgba(255,255,255,.7) !important;
}

/* Tier name color — chọn stop ĐẬM (700-800) để contrast tốt trên nền sáng */
html:not(.dark) .msg-row.msg-tier1  .msg-name{ color: #334155 !important; } /* slate-700 */
html:not(.dark) .msg-row.msg-tier2  .msg-name{ color: #b45309 !important; } /* amber-700 */
html:not(.dark) .msg-row.msg-tier3  .msg-name{ color: #1d4ed8 !important; } /* blue-700 */
html:not(.dark) .msg-row.msg-tier4  .msg-name{ color: #a16207 !important; } /* yellow-700 */
html:not(.dark) .msg-row.msg-tier5  .msg-name{ color: #15803d !important; } /* green-700 */
html:not(.dark) .msg-row.msg-tier6  .msg-name{ color: #0e7490 !important; } /* cyan-700 */
html:not(.dark) .msg-row.msg-tier7  .msg-name{ color: #7e22ce !important; } /* purple-700 */
html:not(.dark) .msg-row.msg-tier8  .msg-name{ color: #be185d !important; } /* pink-700 */
html:not(.dark) .msg-row.msg-tier9  .msg-name{ color: #c2410c !important; } /* orange-700 */
html:not(.dark) .msg-row.msg-tier10 .msg-name{ color: #be185d !important; }
html:not(.dark) .msg-row.msg-cskh   .msg-name{ color: #15803d !important; }

/* Tier 11 rainbow trên light mode: bỏ drop-shadow đen, đậm hơn để rõ */
html:not(.dark) .msg-row.msg-tier11 .msg-name{
  background: linear-gradient(90deg, #c2185b, #d84315, #c9851d, #00838f, #1565c0, #6a1b9a) !important;
  -webkit-background-clip: text !important; background-clip: text !important;
  -webkit-text-fill-color: transparent !important; color: transparent !important;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.6)) !important;
}

/* ---- VIP frame light: nền vàng dịu, text nâu đậm dễ đọc ---- */
html:not(.dark) .msg-row.msg-vip{
  background: linear-gradient(135deg, #fef3c7, #fde68a, #fef3c7) !important;
  border: 1.5px solid #d97706 !important;
  box-shadow: 0 1px 0 rgba(217,119,6,.15), 0 2px 8px rgba(217,119,6,.12) !important;
}
html:not(.dark) .msg-row.msg-vip .msg-name{
  color: #78350f !important; /* amber-900 — gần đen, đọc cực rõ */
  text-shadow: 0 1px 0 rgba(255,255,255,.6) !important;
}
html:not(.dark) .msg-row.msg-vip .msg-text{
  color: #422006 !important; /* amber-950 */
  text-shadow: 0 1px 0 rgba(255,255,255,.5) !important;
}

/* ---- SVIP frame light: nền tím dịu ---- */
html:not(.dark) .msg-row.msg-svip{
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff, #f3e8ff) !important;
  border: 1.5px solid #9333ea !important;
  box-shadow: 0 1px 0 rgba(147,51,234,.15), 0 2px 8px rgba(147,51,234,.12) !important;
}
html:not(.dark) .msg-row.msg-svip .msg-name{
  color: #581c87 !important; /* purple-900 */
  text-shadow: 0 1px 0 rgba(255,255,255,.6) !important;
}
html:not(.dark) .msg-row.msg-svip .msg-text{
  color: #3b0764 !important; /* purple-950 */
  text-shadow: 0 1px 0 rgba(255,255,255,.5) !important;
}

/* ---- CSKH frame light: nền xanh lá dịu ---- */
html:not(.dark) .msg-row.msg-cskh{
  background: linear-gradient(135deg, #dcfce7, #bbf7d0, #dcfce7) !important;
  border: 1.5px solid #16a34a !important;
  box-shadow: 0 1px 0 rgba(22,163,74,.15), 0 2px 8px rgba(22,163,74,.12) !important;
}
html:not(.dark) .msg-row.msg-cskh .msg-name{
  color: #14532d !important; /* green-900 */
  text-shadow: 0 1px 0 rgba(255,255,255,.6) !important;
}
html:not(.dark) .msg-row.msg-cskh .msg-text{
  color: #052e16 !important; /* green-950 */
  text-shadow: 0 1px 0 rgba(255,255,255,.5) !important;
}

/* ===== 🏐 CHAT PHONG CÁCH THỂ THAO — 1 MÀU NỀN ĐỒNG NHẤT + ACCENT CAM =====
   Bỏ nền nhiều màu theo cấp/VIP/SVIP: mọi tin dùng CHUNG 1 nền + vạch cam bên trái.
   Đặt CUỐI file để ghi đè các rule nền ở trên (same specificity + !important → rule sau thắng). */
.msg-row,
.msg-row.msg-vip,
.msg-row.msg-svip,
.msg-row.msg-cskh,
.msg-row[class*="msg-tier"]{
  /* GỌN: bỏ nền/viền/vạch cam, thu padding + khoảng cách → khung chat chứa được nhiều tin hơn */
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 3px 8px !important;
  margin: 0 2px !important;
  border-radius: 6px !important;
  line-height: 1.45 !important;
}
.msg-row:hover,
.msg-row.msg-vip:hover,
.msg-row.msg-svip:hover,
.msg-row.msg-cskh:hover{ background: rgba(255,255,255,.06) !important; }
/* Light mode: cũng KHÔNG nền, chỉ nhạt khi rê chuột */
html:not(.dark) .msg-row,
html:not(.dark) .msg-row.msg-vip,
html:not(.dark) .msg-row.msg-svip,
html:not(.dark) .msg-row.msg-cskh,
html:not(.dark) .msg-row[class*="msg-tier"]{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
html:not(.dark) .msg-row:hover,
html:not(.dark) .msg-row.msg-vip:hover,
html:not(.dark) .msg-row.msg-svip:hover,
html:not(.dark) .msg-row.msg-cskh:hover{ background: rgba(15,23,42,.05) !important; }
/* Ô "LVxx" trong chat: CÙNG 1 ĐỘ RỘNG cho MỌI level (LV5 = LV100 = LV999) và cho CẢ 2 loại ô
   → tên người chat thẳng hàng 1 cột. 72px = vừa ô rộng nhất (user thật LV999 ~70px).
   - User thật: .msg-lvchip > pill (avatar 26px đè mép trái, padding-left 27px) → căn giữa chữ
   - Bot/hệ thống: pill X66LB.pillHTML là con TRỰC TIẾP của .msg-row (ảnh huy hiệu 13px bên trong) */
.msg-row > .msg-lvchip > .x66-lvpill-fx{ width: 72px; text-align: center; box-sizing: border-box; }
/* Viên LV trong khung chat: HÌNH CHỮ NHẬT bo góc nhẹ (thay viên thuốc tròn 2 đầu) — inline style đặt 999px nên cần !important */
.msg-row .x66-lvpill-fx{ border-radius: 4px !important; }
.msg-row > .x66-lvpill-fx{ width: 72px; justify-content: center; box-sizing: border-box; margin-right: 3px; } /* +3px + dấu cách ≈ margin 6px của ô user → tên thẳng hàng */
/* 👤 Tin NGƯỜI THẬT — chỉ BLV/admin thấy (chat-v2.js gắn .msg-real[data-real] khi __x66ChatMod).
   Đặt sau rule "nền trong suốt" + cùng/hơn specificity → thắng. Nền xanh nhạt + vạch xanh trái. */
html .msg-row.msg-real[data-real]{
  background: rgba(34,197,94,.14) !important;
  box-shadow: inset 3px 0 0 #22c55e !important;
}
html:not(.dark) .msg-row.msg-real[data-real]{
  background: rgba(34,197,94,.12) !important;
  box-shadow: inset 3px 0 0 #16a34a !important;
}
.msg-real-tag{ display:inline-block; font-size:9px; font-weight:900; letter-spacing:.4px; color:#f8fafc; background:#16a34a;
  padding:0 5px; border-radius:5px; margin-right:4px; vertical-align:middle; line-height:1.6; }
/* Layout chat OBS phòng idol: giữ đường kẻ phân cách (tw-idol-room.ejs) */
.idol-obs-live #chatBody .msg-row{ border-bottom: 1px solid rgba(255,255,255,.06) !important; border-radius: 0 !important; }
html:not(.dark) .idol-obs-live #chatBody .msg-row{ border-bottom: 1px solid rgba(0,0,0,.06) !important; }
/* Chữ nội dung tin: đồng nhất (không bị ép màu theo VIP/SVIP) */
.msg-row.msg-vip .msg-text,
.msg-row.msg-svip .msg-text,
.msg-row.msg-cskh .msg-text{ color: #e5e7eb !important; text-shadow: none !important; }
html:not(.dark) .msg-row.msg-vip .msg-text,
html:not(.dark) .msg-row.msg-svip .msg-text,
html:not(.dark) .msg-row.msg-cskh .msg-text{ color: #1e293b !important; text-shadow: none !important; }
