/* ═══════════════════════════════════════════════
   lobby.css — صالة الألعاب (Tahadi Games)
   ═══════════════════════════════════════════════ */

:root {
  --th-bg:        var(--bg-main);
  --th-card:      var(--bg-card);
  --th-border:    var(--border);
  --th-gold:      var(--gold);
  --th-gold-hov:  var(--gold-hover);
  --th-text:      var(--text);
  --th-text2:     var(--text-muted);
  --th-green:     var(--success);
  --th-red:       var(--danger);
  --th-amber:     var(--warning);
}

.th-lobby-container {
  direction: rtl;
  font-family: 'Almarai', sans-serif;
  min-height: 60vh;
  padding: 24px 16px;
  color: var(--th-text);
}
.th-lobby-container > .th-home-userbar {
    margin: -24px -16px 20px;
}


.th-lobby-gate {
  direction: rtl;
  text-align: center;
  padding: 80px 20px;
  font-family: 'Almarai', sans-serif;
  color: var(--th-text);
}
.th-lobby-gate p { margin-bottom: 20px; font-size: 18px; }

.th-screen { display: none; }
.th-screen.th-active { display: block; }

.th-screen-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--th-gold);
  margin-bottom: 24px;
}

#th-screen-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--th-text2);
}

.th-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--th-border);
  border-top-color: var(--th-gold);
  border-radius: 50%;
  animation: th-spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
.th-spinner-lg {
  width: 60px; height: 60px;
  border-width: 4px;
  margin-bottom: 24px;
}
@keyframes th-spin { to { transform: rotate(360deg); } }

.th-games-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.th-game-card {
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 14px;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
  transition: transform .25s, border-color .25s;
}
.th-game-card:hover {
  border-color: var(--th-gold);
  transform: translateY(-4px);
}
.th-game-card img {
  width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  display: block;
}
.th-game-card .th-game-title {
  font-size: 1rem; font-weight: 800;
  color: var(--th-text); margin: 16px 16px 6px;
}
.th-game-card .th-game-desc {
  font-size: .82rem; color: var(--th-text2);
  margin: 0 16px 14px; line-height: 1.5;
}

.th-btn-back {
  background: none;
  border: 1px solid var(--th-border);
  color: var(--th-text2);
  border-radius: 8px;
  padding: 8px 16px;
  font-family: 'Almarai', sans-serif;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
  transition: border-color 0.2s, color 0.2s;
}
.th-btn-back:hover {
  border-color: var(--th-gold);
  color: var(--th-gold);
}

.th-wallet-bar {
  text-align: center;
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 10px;
  padding: 10px 20px;
  margin-bottom: 24px;
  font-size: 15px;
  color: var(--th-text2);
}
.th-wallet-bar strong, #th-wallet-balance {
  color: var(--th-green);
  font-weight: 700;
}
.th-topup-link {
  margin-right: 12px;
  color: var(--th-gold);
  text-decoration: none;
  font-size: 13px;
}
.th-topup-link:hover { text-decoration: underline; }

.th-tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
}

.th-tier-card {
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 14px;
  padding: 20px 14px;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
}
.th-tier-card:hover {
  border-color: var(--th-gold);
  transform: translateY(-2px);
}
.th-tier-icon  { font-size: 36px; margin-bottom: 8px; }
.th-tier-name  { font-size: 17px; font-weight: 800; margin-bottom: 10px; color: var(--th-text); }
.th-tier-fee   { font-size: 13px; color: var(--th-text2); margin-bottom: 4px; }
.th-tier-prize { font-size: 13px; color: var(--th-text2); margin-bottom: 14px; }
.th-tier-fee strong, .th-tier-prize strong { color: var(--th-text); }

.th-btn-gold {
  display: inline-block;
  background: var(--th-gold);
  color: var(--on-gold) !important;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  font-family: 'Almarai', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  width: 100%;
}
.th-btn-gold:hover { background: var(--th-gold-hov) !important; }

#th-screen-waiting {
  text-align: center;
  padding: 40px 20px;
}
.th-waiting-box {
  max-width: 400px;
  margin: 0 auto;
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 20px;
  padding: 40px 24px;
}
.th-waiting-info {
  color: var(--th-text2);
  font-size: 14px;
  margin-bottom: 20px;
}
.th-waiting-timer {
  font-size: 28px;
  font-weight: 800;
  color: var(--th-amber);
  margin-bottom: 28px;
}
.th-waiting-timer span { font-size: 40px; }

.th-btn-cancel {
  background: transparent;
  border: 1px solid var(--th-red);
  color: var(--th-red);
  border-radius: 10px;
  padding: 10px 24px;
  font-family: 'Almarai', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}
.th-btn-cancel:hover { background: rgba(var(--danger-rgb), 0.1); }

#th-screen-msg {
  text-align: center;
  padding: 60px 20px;
}
.th-msg-box {
  max-width: 360px;
  margin: 0 auto;
  background: var(--th-card);
  border: 1px solid var(--th-border);
  border-radius: 16px;
  padding: 32px 24px;
}
.th-msg-text {
  font-size: 16px;
  color: var(--th-text);
  margin-bottom: 24px;
  line-height: 1.7;
}

@media (max-width: 600px) {
  .th-games-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
  .th-tiers-grid { grid-template-columns: 1fr 1fr; }
  .th-screen-title { font-size: 18px; }
}

/* ── التبويبان (ساحة مجانية / ساحة الاحتراف) ── */
.th-arena-tabs {
    display: flex;
    gap: 10px;
    margin: 18px 0 14px;
    justify-content: center;
}
.th-tab-btn {
    flex: 1;
    max-width: 200px;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: Almarai, sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}
.th-tab-btn.th-tab-active {
    border-color: var(--gold);
    background: var(--border);
    color: var(--gold);
}
.th-tab-btn:hover:not(.th-tab-active) {
    border-color: var(--text-dim);
    color: var(--text);
}

/* ── ملاحظة الساحة ── */
.th-arena-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 14px;
}

/* ── شريط الرصيد المحدّث ── */
.th-coins-sep {
    color: var(--text-dim);
    margin: 0 4px;
}

/* ── اللقب في شريط الرصيد ── */
#th-rank-display {
    font-size: 13px;
}

/* ── إصلاح شريط الرصيد ── */
.th-wallet-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    margin: 12px 0;
    font-size: 14px;
    color: var(--text);
    direction: rtl;
}
.th-wallet-bar span {
    white-space: nowrap;
}
.th-coins-sep {
    color: var(--border);
    font-size: 18px;
    margin: 0;
}
.th-topup-link {
    background: var(--gold);
    color: var(--bg-main) !important;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    text-decoration: none !important;
    white-space: nowrap;
}
.th-topup-link:hover {
    background: var(--gold-hover);
}
#th-rank-display {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

/* ── نافذة تأكيد إلغاء الغرفة (Modal) ── */
.th-modal-overlay {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(11, 14, 23, 0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.th-modal-overlay.th-modal-active {
    display: flex;
}
.th-modal-box {
    max-width: 360px;
    width: 100%;
    background: var(--th-card);
    border: 1px solid var(--th-red);
    border-radius: 18px;
    padding: 32px 24px;
    text-align: center;
    direction: rtl;
    font-family: 'Almarai', sans-serif;
    animation: th-modal-pop 0.18s ease-out;
}
@keyframes th-modal-pop {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.th-modal-icon { font-size: 40px; margin-bottom: 12px; }
.th-modal-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--th-text);
    margin-bottom: 10px;
}
.th-modal-text {
    font-size: 14px;
    color: var(--th-text2);
    line-height: 1.7;
    margin-bottom: 24px;
}
.th-modal-actions { display: flex; gap: 10px; }
.th-modal-actions .th-btn-cancel { flex: 1; width: auto; }
.th-btn-modal-keep {
    flex: 1;
    background: transparent;
    border: 1px solid var(--th-border);
    color: var(--th-text2);
    border-radius: 10px;
    padding: 11px 16px;
    font-family: 'Almarai', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.th-btn-modal-keep:hover { border-color: var(--th-gold); color: var(--th-gold); }

/* ── نافذة دليل اللعبة (7.4.5) ── */
.th-modal-box-guide {
    border-color: var(--th-gold);
    max-width: 440px;
}
.th-modal-guide-body {
    text-align: right;
    direction: rtl;
    color: var(--th-text2);
    font-size: 14px;
    line-height: 1.8;
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 24px;
    white-space: pre-wrap;
}
.th-modal-guide-body ul,
.th-modal-guide-body ol { padding-right: 20px; margin: 8px 0; }
.th-modal-guide-body li { margin-bottom: 4px; }
.th-modal-guide-body p { margin: 0 0 10px; }
.th-modal-guide-body p:last-child { margin-bottom: 0; }

/* زر دليل اللعبة في كارد اللعبة (7.4.4) */
.th-game-guide-btn {
    width: calc(100% - 32px);
    display: block;
    margin: 0 16px 8px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--th-border);
    color: var(--th-text);
    border-radius: 8px;
    font-family: 'Almarai', sans-serif;
    font-size: .85rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.th-game-guide-btn:hover { border-color: var(--th-gold); color: var(--th-gold); }

.th-game-challenge-btn {
    width: calc(100% - 32px);
    display: block;
    margin: 0 16px 8px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--th-border);
    color: var(--th-text);
    border-radius: 8px;
    font-family: 'Almarai', sans-serif;
    font-size: .85rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.th-game-challenge-btn:hover { border-color: var(--th-gold); color: var(--th-gold); }

.th-game-play-btn {
    width: calc(100% - 32px) !important;
    margin: 4px 16px 12px;
}

/* ── المستويات المعطّلة + شارة قريباً (7.5.7) ── */
.th-tier-disabled {
    opacity: 0.5;
    filter: grayscale(60%);
    pointer-events: none;
}
.th-tier-soon-badge {
    margin-top: 8px;
    display: inline-block;
    background: rgba(var(--danger-rgb), 0.12);
    color: var(--th-red);
    border: 1px solid var(--th-red);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
}

/* ── تعطيل وسبينر ازرار اللعب (7.3.2) ── */
.th-btn-gold:disabled { opacity: 0.6; cursor: not-allowed; }
.th-btn-spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(0,0,0,0.25); border-top-color: var(--on-gold);
    border-radius: 50%; animation: th-spin 0.8s linear infinite;
}
/* أُزيل القيد القديم (nowrap) — الشريط يتوارث الآن من homepage.css الموحّد (7.11.3) */

/* نافذة مشاركة رابط التحدي — 7.8.7 */
.th-share-link-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: var(--th-bg, var(--bg-main));
    border: 1px solid var(--th-border, var(--border));
    border-radius: 8px;
    padding: 12px 14px;
    margin: 16px 0;
    font-family: inherit;
    font-size: 13px;
    color: var(--th-gold, var(--gold));
    text-align: center;
    direction: ltr;
}
.th-share-link-input:focus {
    outline: 1px solid var(--th-gold, var(--gold));
}
