/* BẠN BÈ — nút ở sảnh, ngăn kéo Bạn bè, thẻ lời mời chơi, khung nhắn tin, thẻ hồ sơ. Mọi selector bắt đầu bằng .bb- hoặc #bb- */

/* Nút ở sảnh + huy hiệu số */
.bb-nut { position: relative; }
.bb-dem { display: none; position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--do); color: #fff; font: 800 .72rem/20px var(--font); text-align: center; box-shadow: 0 0 0 2px var(--mat); }
.bb-dem.co { display: block; }
.tb-dt-ngang .bb-nut .bb-chu, .tb-dt-doc .bb-nut .bb-chu { display: none; }

/* Ngăn kéo */
.bb-nen { position: fixed; inset: 0; z-index: 880; background: rgba(42, 34, 48, 0); transition: background .2s; }
.bb-nen.mo { background: rgba(42, 34, 48, .28); }
.bb-ngan { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--mat); color: var(--chu);
  border-left: 1px solid var(--vien, #eee); box-shadow: var(--bong-lon); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease-out;
  padding-top: env(safe-area-inset-top); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); }
.bb-nen.mo .bb-ngan { transform: none; }
.bb-dau { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px 18px; }
.bb-dau h2 { margin: 0; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.bb-dau h2 .th-ic { color: var(--chinh); font-size: 1.3rem; }

.bb-toi { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; margin: 4px 14px 8px; padding: 10px 12px;
  background: var(--mat-2); border-radius: var(--bo); }
.bb-toi > .av { grid-row: span 2; }
.bb-toi .av.th-av { --av: 46px; }
.bb-toi-ten { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.bb-toi-ten > b { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12em; }
.bb-ma { border: 1px dashed var(--chinh); background: var(--mat); color: var(--chu); border-radius: 999px; padding: 3px 10px; display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; font: inherit; }
.bb-ma small { color: var(--chu-nhat); font-size: .72rem; }
.bb-ma b { letter-spacing: .08em; font-size: .9rem; }
.bb-ma .th-ic { color: var(--chinh); }
.bb-an { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--chu-nhat); cursor: pointer; }
.bb-an input { accent-color: var(--chinh); width: 16px; height: 16px; }

.bb-tab { display: flex; gap: 4px; padding: 0 12px 6px; overflow-x: auto; scrollbar-width: none; flex: none; }
.bb-tab::-webkit-scrollbar { display: none; }
.bb-t { border: 0; background: transparent; padding: .5em .8em; border-radius: 999px; font: 700 .9rem var(--font); color: var(--chu-nhat);
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; }
.bb-t.bat { background: var(--hong-nhat, var(--mat-2)); color: var(--chinh); }
.bb-so { font-style: normal; background: var(--do); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px; font: 800 .7rem/18px var(--font); text-align: center; }

.bb-than { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 10px 16px; overscroll-behavior: contain; }
.bb-nhan { display: flex; justify-content: space-between; color: var(--chu-nhat); font-size: .8rem; font-weight: 700; padding: 4px 8px; text-transform: uppercase; letter-spacing: .04em; }
.bb-goi-y { color: var(--chu-nhat); font-size: .88rem; margin: 6px 8px 10px; }
.bb-trong { text-align: center; color: var(--chu-nhat); padding: 28px 16px; }
.bb-trong p { margin: 6px 0 14px; }
.bb-trong-ic { font-size: 44px; color: var(--phu); display: flex; justify-content: center; }

/* Một dòng người */
.bb-dong { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: var(--bo); min-height: 56px; }
.bb-dong:hover { background: var(--mat-2); }
.bb-dong.den { background: var(--hong-nhat, var(--mat-2)); }
.bb-ai { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.bb-ai > .av.th-av, .bb-av .av.th-av { --av: 42px; }
.bb-ten { min-width: 0; display: flex; flex-direction: column; }
.bb-ten b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-ten small { color: var(--chu-nhat); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-dong.online .bb-ten small { color: var(--la); font-weight: 600; }
.bb-hd { display: flex; align-items: center; gap: 6px; flex: none; }
.bb-hd .th-nut.nho { padding: .4em .8em; font-size: .85rem; }
.bb-nut-nhan { position: relative; }
.bb-nut-nhan .bb-so { position: absolute; top: -5px; right: -5px; }
.bb-the-nho { font-size: .78rem; font-weight: 700; color: var(--chu-nhat); background: var(--mat-2); padding: 4px 10px; border-radius: 999px; }
.bb-av { position: relative; flex: none; display: inline-flex; }
.bb-cham { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: #c9c2cf; box-shadow: 0 0 0 2px var(--mat); }
.bb-av.online .bb-cham { background: var(--la); }
.bb-av.dang-choi .bb-cham { background: var(--cam); }
.bb-av.offline .av { filter: grayscale(.6); opacity: .75; }

.bb-menu { position: absolute; right: 6px; top: calc(100% - 4px); z-index: 5; background: var(--mat); border: 1px solid var(--vien, #eee); border-radius: var(--bo);
  box-shadow: var(--bong-lon); padding: 6px; display: flex; flex-direction: column; min-width: 170px; }
.bb-menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 10px 12px; border-radius: 10px; font: 600 .92rem var(--font); color: var(--chu); cursor: pointer; text-align: left; }
.bb-menu button:hover { background: var(--mat-2); }
.bb-menu button.do { color: var(--do); }

/* Tìm bạn */
.bb-o-tim { display: flex; gap: 8px; margin: 6px 4px 10px; }
.bb-o-tim input { flex: 1; min-width: 0; user-select: text; -webkit-user-select: text; }
.bb-chia-se { margin: 18px 6px 4px; padding: 12px; border-radius: var(--bo); background: var(--mat-2); text-align: center; }
.bb-chia-se p { margin: 0 0 8px; color: var(--chu-nhat); font-size: .88rem; }
.bb-ma-lon b { letter-spacing: .12em; font-size: 1.1rem; }

/* Nhắn tin (thay phần thân của ngăn kéo) */
.bb-ngan.dang-chat > .bb-toi, .bb-ngan.dang-chat > .bb-tab, .bb-ngan.dang-chat > .bb-than { display: none; }
.bb-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.bb-chat-dau { display: flex; align-items: center; gap: 10px; padding: 4px 14px 8px; border-bottom: 1px solid var(--vien, #eee); }
.bb-chat-dau .bb-ai b { font-size: 1.05rem; }
.bb-tin-ds { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.bb-tin { align-self: flex-start; max-width: 80%; background: var(--mat-2); border-radius: 16px 16px 16px 4px; padding: 7px 12px; display: flex; flex-direction: column; }
.bb-tin.toi { align-self: flex-end; background: var(--chinh); color: #fff; border-radius: 16px 16px 4px 16px; }
.bb-tin span { white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.bb-tin small { font-size: .68rem; opacity: .7; align-self: flex-end; }
.bb-chat-nhap { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 10px; border-top: 1px solid var(--vien, #eee); }
.bb-chat-nhap textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; font: inherit; user-select: text; -webkit-user-select: text; }
.bb-chat-nhap.tat { justify-content: center; color: var(--chu-nhat); padding: 14px; }

/* Thẻ lời mời chơi (trên cùng màn hình, cả khi đang chơi) */
#bb-moi-den { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 20px)); pointer-events: none; }
.bb-the-moi { pointer-events: auto; position: relative; overflow: hidden; display: grid; grid-template-columns: auto 1fr auto; gap: 6px 12px; align-items: center;
  background: var(--mat); color: var(--chu); border: 1px solid var(--vien, #eee); border-left: 5px solid var(--chinh); border-radius: var(--bo);
  box-shadow: var(--bong-lon); padding: 10px 12px 12px; }
.bb-the-moi > .av.th-av { --av: 44px; }
.bb-moi-chu { display: flex; flex-direction: column; min-width: 0; }
.bb-moi-chu b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-moi-chu span { color: var(--chinh); font-weight: 800; }
.bb-moi-nut { display: flex; gap: 8px; justify-content: flex-end; }
.bb-vach { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--phu); transform-origin: left; }

/* Chọn trò để mời */
.bb-hop { width: min(560px, 94vw); }
.bb-luoi-tro { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.bb-o-tro { border: 1px solid var(--vien, #eee); background: var(--mat); border-radius: var(--bo); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: 700 .88rem var(--font); color: var(--chu); cursor: pointer; text-align: center; min-height: 44px; }
.bb-o-tro:hover { border-color: var(--chinh); box-shadow: var(--bong); }
.bb-bt { width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; display: grid; place-items: center; font-size: 34px; color: #fff;
  background: linear-gradient(135deg, var(--a), var(--b)); background-size: cover; background-position: center; }
.bb-bt.co-bia { background-color: var(--mat-2); }
.bb-bt svg { width: 1em; height: 1em; }

/* Thẻ hồ sơ */
.bb-ho-so { min-width: min(320px, 80vw); }
.bb-hs-dau { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.bb-hs-dau .av.th-av { --av: 72px; }
.bb-hs-dau > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bb-hs-ten { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; }
.bb-hs-dau small { color: var(--chu-nhat); }
.bb-hs-so { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bb-hs-so > div { background: var(--mat-2); border-radius: var(--bo); padding: 10px 4px; text-align: center; display: flex; flex-direction: column; }
.bb-hs-so b { font-size: 1.15rem; color: var(--chinh); }
.bb-hs-so small { color: var(--chu-nhat); font-size: .75rem; }
.bb-khach { text-align: center; max-width: 380px; }
.bb-khach p { color: var(--chu-nhat); }

/* Điện thoại dọc: tấm trượt từ dưới lên */
.tb-dt-doc .bb-ngan { top: auto; left: 0; width: 100%; height: 88vh; height: 88dvh; border-left: 0; border-radius: 22px 22px 0 0; transform: translateY(100%); }
.tb-dt-doc .bb-nen.mo .bb-ngan { transform: none; }
.tb-dt-doc .bb-dau::before { content: ''; position: absolute; left: 50%; top: 6px; width: 42px; height: 4px; margin-left: -21px; border-radius: 4px; background: var(--vien, #ddd); }
.tb-dt-doc .bb-hs-so { grid-template-columns: repeat(2, 1fr); }
.tb-dt-doc .bb-the-moi { grid-template-columns: auto 1fr; }
.tb-dt-doc .bb-moi-nut { grid-column: 1 / -1; }
.tb-dt-doc .bb-moi-nut .th-nut { flex: 1; }
.tb-dt-doc .bb-hd .th-nut.nho > span:not(.th-ic) { display: none; }

/* Điện thoại ngang: ngăn kéo hẹp hơn, gọn chiều cao */
.tb-dt-ngang .bb-ngan { width: min(440px, 62vw); padding-left: 0; }
.tb-dt-ngang .bb-dau { padding: 6px 10px 2px 14px; }
.tb-dt-ngang .bb-dau h2 { font-size: 1.05rem; }
.tb-dt-ngang .bb-toi { margin: 2px 10px 4px; padding: 6px 10px; }
.tb-dt-ngang .bb-toi .av.th-av { --av: 36px; }
.tb-dt-ngang .bb-an { display: none; }
.tb-dt-ngang .bb-dong { min-height: 48px; padding: 3px 6px; }
.tb-dt-ngang .bb-ai > .av.th-av, .tb-dt-ngang .bb-av .av.th-av { --av: 36px; }
.tb-dt-ngang .bb-hd .th-nut.nho > span:not(.th-ic) { display: none; }
.tb-dt-ngang #bb-moi-den { top: 6px; }
.tb-dt-ngang .bb-the-moi { padding: 6px 10px 8px; }
.tb-dt-ngang .bb-the-moi > .av.th-av { --av: 36px; }
.tb-dt-ngang .bb-luoi-tro { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }

/* Nhắc trong hộp chọn chế độ khi đang mời bạn */
.bb-nhac-moi { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; padding: 8px 12px; border-radius: var(--bo);
  background: var(--hong-nhat, var(--mat-2)); color: var(--chinh); font-weight: 700; font-size: .9rem; }
