/* الدردشة: تنفتح فوق أي صفحة، وألوانها من قالب البوستر */
/* يبقى فوق الصفحة ويتحرك معها، عشان ما يغطي المحتوى وقت النزول */
.chat-open { position: absolute; z-index: 9; inset-inline-start: 12px; top: 80px; display: inline-flex; align-items: center; gap: 7px; min-height: 46px; padding: 8px 14px; border: 3px solid #141414; border-radius: 0; background: #fff; color: #141414; font: inherit; font-size: 15px; font-weight: 700; box-shadow: 4px 4px 0 #141414; cursor: pointer; }
.chat-open.chat-in-game-bar { position: static; min-height: 34px; margin-inline: auto 8px; padding: 3px 10px; border-width: 2px; box-shadow: none; font-size: 14px; }
.chat-open.chat-in-bar { position: static; min-height: 0; padding: 6px 12px; border-width: 2px; background: transparent; box-shadow: none; font-size: 14px; }
.chat-icon { font-size: 18px; line-height: 1; }
.chat-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box; border-radius: 0; background: #d7263d; color: #fff; font-size: 12px; font-weight: 700; line-height: 1; }
.chat-badge[hidden] { display: none; }

.chat-dialog { width: min(420px, calc(100vw - 20px)); height: min(600px, calc(100dvh - 20px)); padding: 0; overflow: hidden; border: 3px solid #141414; border-radius: 0; background: #fff; color: #141414; box-shadow: 7px 7px 0 #141414; font-family: inherit; }
.chat-dialog[open] { display: flex; flex-direction: column; }
.chat-dialog::backdrop { background: rgba(20, 20, 20, .55); }
.chat-head { display: flex; flex: none; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 3px solid #141414; }
.chat-head h2 { margin: 0; color: #141414; font-size: 18px; font-weight: 700; }
.chat-room { min-height: 34px; padding: 3px 10px; border: 2px solid #141414; border-radius: 0; background: #d7263d; color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; direction: ltr; white-space: nowrap; }
.chat-room[hidden] { display: none; }
.chat-room:disabled { background: #f3ecdf; color: #5a5249; font-size: 12px; cursor: default; direction: rtl; }
.chat-close { width: 34px; height: 34px; margin-inline-start: auto; border: 2px solid #141414; border-radius: 0; background: #fff; color: #141414; font: inherit; cursor: pointer; }
.chat-status { display: flex; flex: none; align-items: center; gap: 10px; min-height: 18px; margin: 0; padding: 7px 12px; color: #5a5249; font-size: 13px; }
.chat-with { color: #141414; }
.chat-status small { font-size: 12px; }
.chat-online { color: #141414; font-weight: 700; }
.chat-kick { margin-inline-start: auto; padding: 4px 9px; border: 2px solid #141414; border-radius: 0; background: #141414; color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.chat-offline { flex: none; margin: 0 10px 12px; padding: 10px 12px; border: 2px solid #141414; background: #f3ecdf; color: #141414; font-size: 14px; text-align: center; }
.chat-offline[hidden] { display: none; }
.chat-back { padding: 4px 8px; border: 2px solid #141414; border-radius: 0; background: #fff; color: #141414; font: inherit; font-size: 12px; cursor: pointer; }

.chat-threads { flex: 1; min-height: 0; margin: 0; padding: 0 8px 8px; overflow-y: auto; list-style: none; }
.chat-threads[hidden], .chat-log[hidden] { display: none; }
.chat-thread { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; margin-bottom: 6px; padding: 6px 8px; border: 2px solid #141414; border-radius: 0; background: #fff; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.chat-thread:hover { background: #f3ecdf; }
.chat-thread-info { flex: 1; min-width: 0; }
.chat-thread-info b { display: block; font-weight: 700; }
.chat-thread-info small { display: block; overflow: hidden; color: #5a5249; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.chat-face { display: inline-grid; flex: none; place-items: center; width: 38px; height: 38px; overflow: hidden; border-radius: 0; background: #f3ecdf; font-weight: 700; }
.chat-face img { width: 100%; height: 100%; object-fit: cover; }
.chat-empty { margin: 18px 12px; color: #5a5249; font-size: 14px; text-align: center; }

.chat-log { display: flex; flex: 1; flex-direction: column; gap: 6px; min-height: 0; padding: 4px 10px 10px; overflow-y: auto; }
.chat-msg { max-width: 82%; padding: 7px 11px; border: 2px solid #141414; border-radius: 0; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
.chat-msg.mine { align-self: flex-start; background: #141414; color: #fff; }
.chat-msg.theirs { align-self: flex-end; background: #f3ecdf; color: #141414; }
.chat-msg time { display: block; margin-top: 2px; font-size: 11px; opacity: .75; }
.chat-code { min-width: 170px; text-align: center; }
.chat-code small { display: block; font-size: 12px; }
.chat-code strong { display: block; color: #d7263d; font-size: 24px; letter-spacing: 2px; direction: ltr; }
.chat-msg.mine.chat-code strong { color: #fff; }
.chat-copy { width: 100%; min-height: 36px; margin-top: 5px; border: 2px solid #141414; border-radius: 0; background: #d7263d; color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.chat-enter { display: block; margin-top: 5px; padding: 7px; border: 2px solid #141414; background: #fff; color: #141414; font-size: 14px; font-weight: 700; text-decoration: none; }

.chat-invite { display: block; flex: none; box-sizing: border-box; margin: 0 10px 10px; padding: 9px 12px; border: 3px solid #141414; border-radius: 0; background: #d7263d; color: #fff; font: inherit; font-size: 15px; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; }
.chat-invite[hidden] { display: none; }
a.chat-invite { background: #f3ecdf; color: #141414; }
.chat-error { flex: none; margin: 0; padding: 0 12px; color: #a01414; font-size: 13px; }
.chat-error:empty { display: none; }
.chat-error:not(:empty) { padding-bottom: 8px; }
/* الرئيسية: «مشرفين» في الشريط مكان «ادمن» */
.chat-open.chat-in-home-bar { position: static; min-height: 34px; padding: 4px 11px; border-width: 2px; box-shadow: none; font-size: 13px; }
/* زر دخول الادمن فوق قائمة المشرفين */
.chat-login { display: block; flex: none; margin: 10px 10px 4px; padding: 11px 12px; border-radius: 12px; background: #2746f2; color: #fff; font: inherit; font-size: 15px; font-weight: 800; text-align: center; text-decoration: none; }
.chat-login[hidden] { display: none; }
/* الجوال: زر «مشرفين» يدخل مع باقي أزرار شريط اللعبة في سطر واحد */
@media (max-width: 420px) {
  .site-bar-inner:has(.chat-in-game-bar) { gap: 6px; }
  .site-bar-inner:has(.chat-in-game-bar) .logo { gap: 6px; font-size: 13px; }
  .chat-open.chat-in-game-bar { min-height: 32px; margin-inline: auto 4px; padding: 3px 8px; gap: 4px; font-size: 12px; }
  .site-bar-inner:has(.chat-in-game-bar) .arena-actions { flex-wrap: nowrap; gap: 4px; }
  .site-bar-inner:has(.chat-in-game-bar) .arena-actions .btn.small { padding-inline: 8px; font-size: 12px; }
  /* «القائمة الرئيسية» تصير «الرئيسية»، وإذا ما كفى المكان ينزل الباقي سطر ثاني بدل ما تطلع الصفحة برا الشاشة */
  .site-bar-inner:has(.chat-in-game-bar) { flex-wrap: wrap; row-gap: 6px; }
  .site-bar-inner:has(.chat-in-game-bar) > .logo { font-size: 0; }
  .site-bar-inner:has(.chat-in-game-bar) > .logo .logo-mark { font-size: 16px; }
  .site-bar-inner:has(.chat-in-game-bar) > .logo::after { content: 'الرئيسية'; font-size: 13px; }
}
/* الرئيسية على الجوال: زر البروفايل ومشرفين يمين، والباقي ينزل سطر ثاني بدل ما يتداخلون */
@media (max-width: 440px) {
  .site-bar-inner:has(.chat-in-home-bar) { flex-wrap: wrap; row-gap: 8px; }
  .site-bar-inner:has(.chat-in-home-bar) .site-nav { margin-inline-start: auto; }
}
