/* Khung chat chung (mọi trang) - phong cách tiền sử */
.bc {
  --bc-bg: #2a1a0e;
  --bc-bg2: #3b2614;
  --bc-parch: #ecdcae;
  --bc-parch2: #dcc58a;
  --bc-ink: #3a240f;
  --bc-soft: #6b4a26;
  --bc-wood: #7a4b22;
  --bc-wood-d: #4e2e12;
  --bc-fire: #e8742a;
  --bc-fire2: #f4a83a;
  --bc-leaf: #5c8f2a;
  --bc-blood: #b8382a;
  font-family: "Baloo 2", "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.35;
}
.bc * { box-sizing: border-box; }
.bc button { font: inherit; cursor: pointer; }

/* nút tròn */
.bc-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--bc-wood);
  color: #2d1a08;
  background: linear-gradient(180deg, #ffd27a, var(--bc-fire2) 45%, var(--bc-fire));
  box-shadow: 0 4px 0 #2d1a08, 0 6px 18px rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.bc-btn:hover { filter: brightness(1.07); }
.bc-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #2d1a08; }
.bc-btn svg { width: 28px; height: 28px; }
.bc-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: .78rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  color: #fff;
  background: var(--bc-blood);
  border: 2px solid var(--bc-bg);
}
.bc-badge[hidden] { display: none; }

/* tin mới hiện nhỏ cạnh nút */
.bc-toast {
  position: fixed;
  right: 86px;
  bottom: 24px;
  z-index: 50;
  max-width: min(260px, calc(100vw - 110px));
  padding: 7px 12px;
  border-radius: 12px 12px 4px 12px;
  font-size: .88rem;
  color: var(--bc-ink);
  background: linear-gradient(180deg, var(--bc-parch), var(--bc-parch2));
  border: 2px solid var(--bc-wood);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
  cursor: pointer;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  animation: bc-in .2s ease;
}
.bc-toast[hidden] { display: none; }
.bc-toast b { color: var(--bc-wood-d); }
@keyframes bc-in { from { opacity: 0; transform: translateY(6px); } }

/* khung chat */
.bc-panel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 60;
  width: 360px;
  height: min(540px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  color: var(--bc-ink);
  background: linear-gradient(180deg, var(--bc-parch), var(--bc-parch2));
  border: 3px solid var(--bc-wood);
  box-shadow: 0 6px 0 var(--bc-wood-d), 0 12px 34px rgba(0, 0, 0, .55);
  animation: bc-in .18s ease;
}
.bc-panel[hidden] { display: none; }
.bc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  color: var(--bc-parch);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .10) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, #9a6230, var(--bc-wood) 55%, var(--bc-wood-d));
}
.bc-title { flex: 1; min-width: 0; }
.bc-title b { display: block; font-size: 1.05rem; text-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.bc-title small { display: block; font-size: .75rem; opacity: .85; }
.bc-title small::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #7ed957; margin-right: 5px; vertical-align: 1px; }
.bc-icon {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  color: var(--bc-parch);
  background: rgba(0, 0, 0, .2);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.bc-icon:hover { background: rgba(0, 0, 0, .35); }
.bc-icon.off { opacity: .55; }

.bc-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  overscroll-behavior: contain;
}
.bc-empty { text-align: center; color: var(--bc-soft); font-size: .9rem; margin-top: 30%; }
.bc-msg { margin: 0 0 8px; font-size: .92rem; word-wrap: break-word; overflow-wrap: anywhere; position: relative; }
.bc-msg .bc-meta { display: flex; align-items: baseline; gap: 6px; }
.bc-name { font-weight: 800; }
.bc-time { font-size: .72rem; color: var(--bc-soft); }
.bc-text { display: block; }
.bc-star { color: var(--bc-fire); margin-right: 2px; }
.bc-adm { font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .45; margin-left: 2px; }
.bc-msg.admin .bc-text { padding: 3px 8px; border-radius: 8px; background: rgba(232, 116, 42, .15); }
.bc-msg.sys {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: .85rem;
  color: var(--bc-soft);
  background: rgba(90, 58, 26, .1);
}
.bc-msg.sys a { color: #9a4a12; font-weight: 800; margin-left: 4px; }
.bc-msg.mine .bc-name::after { content: " (bạn)"; font-weight: 600; font-size: .75rem; color: var(--bc-soft); }
.bc-tools { position: absolute; top: 0; right: 0; display: none; gap: 4px; }
.bc-msg:hover .bc-tools { display: flex; }
.bc-tools button {
  border: 1px solid rgba(90, 58, 26, .4);
  border-radius: 6px;
  padding: 0 6px;
  font-size: .72rem;
  color: var(--bc-blood);
  background: #fffaf0;
}

.bc-foot { padding: 8px 10px 10px; border-top: 2px solid rgba(90, 58, 26, .25); }
.bc-who { display: flex; justify-content: space-between; font-size: .78rem; color: var(--bc-soft); margin-bottom: 5px; }
.bc-who button { border: none; background: none; padding: 0; color: #9a4a12; font-weight: 700; font-size: .78rem; }
.bc-row { display: flex; gap: 6px; }
.bc-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 2px solid var(--bc-wood);
  border-radius: 9px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  color: var(--bc-ink);
  background: #fffaf0;
}
.bc-row input:focus { outline: none; border-color: var(--bc-fire); }
.bc-send {
  min-width: 64px;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  font-weight: 800;
  color: #2d1a08;
  background: linear-gradient(180deg, var(--bc-fire2), var(--bc-fire));
  box-shadow: 0 2px 0 #2d1a08;
}
.bc-send:disabled { opacity: .55; cursor: default; }
.bc-err { min-height: 1em; margin-top: 4px; font-size: .78rem; color: var(--bc-blood); }
.bc-err:empty { display: none; }
.bc-key { margin-top: 6px; }
.bc-key[hidden] { display: none; }

/* điện thoại: khung chat chiếm cả màn hình, nút nhỏ hơn */
@media (max-width: 600px) {
  .bc-panel { inset: 0; width: auto; height: auto; border-radius: 0; border: none; }
  .bc-btn { width: 50px; height: 50px; right: 12px; bottom: 12px; }
  .bc-toast { right: 72px; bottom: 16px; }
  .bc-row input { font-size: 16px; } /* tránh iPhone tự phóng to khi gõ */
}
/* trang Chơi Ngay / Xem trận trên điện thoại: nút nhỏ ở góc trên, không đè bàn phím */
@media (hover: none) and (pointer: coarse), (max-width: 700px) {
  .bc.bc-top .bc-btn { top: 6px; bottom: auto; right: 8px; width: 38px; height: 38px; border-width: 2px; box-shadow: 0 2px 0 #2d1a08; }
  .bc.bc-top .bc-btn svg { width: 20px; height: 20px; }
  .bc.bc-top .bc-badge { top: -5px; right: -5px; min-width: 18px; height: 18px; line-height: 18px; font-size: .68rem; padding: 0 4px; }
  .bc.bc-top .bc-toast { top: 8px; bottom: auto; right: 54px; border-radius: 12px 4px 12px 12px; font-size: .82rem; padding: 5px 10px; }
}

/* thông báo ghim trên đầu trang */
.bc-notice {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 44px 7px 14px;
  font-size: .92rem;
  font-weight: 700;
  color: #2d1a08;
  background: linear-gradient(180deg, #ffd27a, #f4a83a);
  border-bottom: 3px solid #7a4b22;
}
.bc-notice-ic { flex: none; font-size: 1.1rem; }
.bc-notice-tx { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bc-notice button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  color: #2d1a08;
  background: rgba(0, 0, 0, .12);
}
.bc-msg.sys.notice { color: #3a240f; background: rgba(244, 168, 58, .35); border: 1px solid rgba(232, 116, 42, .5); }
.bc-err a { color: #9a4a12; font-weight: 800; }
.bc-row input:disabled { opacity: .6; }
.bc-who[hidden] { display: none; }

/* popup giữa màn hình (thông báo cập nhật...) */
.bc-pop-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 10, 2, .55);
}
.bc-pop {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px 20px 16px;
  color: var(--bc-ink);
  background: linear-gradient(180deg, var(--bc-parch), var(--bc-parch2));
  border: 4px solid var(--bc-wood);
  border-radius: 14px;
  box-shadow: 0 6px 0 var(--bc-wood-d), 0 14px 40px rgba(0, 0, 0, .5);
}
.bc-pop-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  color: var(--bc-ink);
  background: transparent;
  font-size: 1rem;
}
.bc-pop-x:hover { background: rgba(0, 0, 0, .08); }
.bc-pop-title { margin: 0 26px 8px 0; font-size: 1.2rem; font-weight: 800; color: var(--bc-wood-d); }
.bc-pop-text { white-space: pre-line; overflow-wrap: anywhere; font-size: .98rem; }
.bc-pop-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.bc-pop-go, .bc-pop-close {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 800;
  text-decoration: none;
  border: 2px solid var(--bc-wood);
}
.bc-pop-go { color: #2d1a08; background: linear-gradient(180deg, var(--bc-fire2), var(--bc-fire)); box-shadow: 0 3px 0 var(--bc-wood-d); }
.bc-pop-close { color: var(--bc-ink); background: transparent; }
