/* صفحة ألعابي — بطاقات احترافية بعرض كامل دون قصّ النص */
.my-games-page {
  min-height: 100vh;
  overflow-x: hidden;
}

/* جوال: الوضع العمودي فقط — يتفوّق على إظهار المحتوى في portrait */
@media screen and (max-width: 768px) and (orientation: landscape) {
  body.my-games-page > *:not(.orientation-warning),
  body.my-games-page .my-games-main,
  body.my-games-page .my-games-challenges,
  body.my-games-page .challenges-section.my-games-challenges {
    display: none !important;
  }

  body.my-games-page .orientation-warning {
    display: flex !important;
  }
}

.my-games-page .main-container,
.my-games-page .selected-categories-sidebar {
  display: none !important;
}

.my-games-main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

/* إلغاء تنسيقات لوحة اللوبي — هذه صفحة مستقلة بعرض كامل */
.my-games-page .challenges-section.my-games-challenges,
.my-games-challenges {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  min-height: calc(100vh - 80px);
  overflow: visible !important;
  border: none !important;
  border-left: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 6px clamp(24px, 4.5vw, 64px) 48px !important;
  box-sizing: border-box !important;
  background:
    radial-gradient(ellipse 70% 40% at 80% 0%, rgba(124, 58, 237, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 35% at 10% 20%, rgba(245, 158, 11, 0.08), transparent 50%),
    linear-gradient(180deg, rgba(26, 10, 46, 0.35) 0%, transparent 45%);
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  animation: myGamesFadeIn 0.55s ease-out;
}

.my-games-challenges.challenges-collapsed {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 6px clamp(24px, 4.5vw, 64px) 48px !important;
  overflow: visible !important;
}

.my-games-challenges.challenges-collapsed .saved-challenges,
.my-games-challenges.challenges-collapsed h2 {
  display: revert;
}

.my-games-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 0 0 16px;
  border-bottom: 1px solid rgba(168, 85, 247, 0.22);
  overflow: visible;
}

.my-games-mode-picker {
  margin: 0 0 22px;
  max-width: 640px;
}

/* lobby.css يفرض display:grid فيتجاوز خاصية hidden */
.my-games-mode-picker[hidden],
.game-mode-picker.my-games-mode-picker[hidden] {
  display: none !important;
}

.my-games-mode-picker:not([hidden]) {
  display: grid !important;
}

.my-games-mode-picker .game-mode-option {
  min-height: 88px;
}

.mg-mode-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  font-size: 0.78rem;
  font-weight: 700;
}

.my-games-toolbar h2 {
  margin: 0;
  /* مساحة لنقاط حرف الياء تحت السطر */
  padding: 0.18em 0.12em 0.28em;
  text-align: right;
  font-size: clamp(1.65rem, 3.2vw, 2.15rem);
  font-weight: 900;
  color: #fbbf24;
  line-height: 1.7;
  letter-spacing: 0;
  overflow: visible;
  flex: 1 1 auto;
  min-width: 0;
  text-shadow: 0 0 22px rgba(245, 158, 11, 0.35);
}

.my-games-toolbar h2::after {
  display: none !important;
}

.my-games-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(168, 85, 247, 0.4);
  background: rgba(124, 58, 237, 0.2);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  box-sizing: border-box;
  max-width: 100%;
}

.my-games-refresh-btn:hover {
  background: rgba(124, 58, 237, 0.38);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.25);
}

.my-games-refresh-btn.is-spinning i {
  animation: myGamesSpin 0.85s linear infinite;
}

.my-games-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 16px;
  color: var(--text-muted);
}

.my-games-loader[hidden] {
  display: none !important;
}

.my-games-loader__spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(168, 85, 247, 0.28);
  border-top-color: var(--orange);
  animation: myGamesSpin 0.9s linear infinite;
}

.my-games-loader__label {
  margin: 0;
  font-weight: 600;
}

/* شبكة بطاقات بعرض الصفحة — كل بطاقة بارتفاعها فقط */
.my-games-page .saved-challenges {
  margin: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  align-items: start;
  gap: 22px;
  width: 100%;
  box-sizing: border-box;
}

.my-games-page .saved-challenges > .no-challenges,
.my-games-page .mg-empty-state {
  grid-column: 1 / -1;
  margin: 48px auto 0;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 24px;
  background: rgba(45, 26, 74, 0.45);
  border: 1px dashed rgba(168, 85, 247, 0.35);
  border-radius: 20px;
}

.my-games-page .mg-empty-state i {
  font-size: 2rem;
  color: var(--orange);
  opacity: 0.9;
}

.my-games-page .mg-empty-state p {
  margin: 0;
  color: #ddd;
  font-size: 1.1rem;
}

.my-games-page .mg-empty-cta {
  display: inline-flex;
  margin-top: 6px;
  padding: 10px 18px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 800;
  color: #1a0a2e;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

/* البطاقة */
.my-games-page .challenge-item.mg-card {
  margin: 0;
  width: 100%;
  min-width: 0;
  height: auto;
  align-self: start;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid rgba(168, 85, 247, 0.32);
  background:
    linear-gradient(165deg, rgba(56, 31, 88, 0.88) 0%, rgba(34, 16, 58, 0.92) 55%, rgba(26, 10, 46, 0.9) 100%);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  cursor: default;
  overflow: visible;
  transition: transform 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease;
  animation: myGamesCardIn 0.5s ease-out both;
}

.my-games-page .challenge-item.mg-card:hover {
  transform: translateY(-4px);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(245, 158, 11, 0.12),
    0 0 28px rgba(124, 58, 237, 0.15);
}

.my-games-page .challenge-item:nth-child(1) { animation-delay: 0.04s; }
.my-games-page .challenge-item:nth-child(2) { animation-delay: 0.08s; }
.my-games-page .challenge-item:nth-child(3) { animation-delay: 0.12s; }
.my-games-page .challenge-item:nth-child(4) { animation-delay: 0.16s; }
.my-games-page .challenge-item:nth-child(5) { animation-delay: 0.2s; }
.my-games-page .challenge-item:nth-child(6) { animation-delay: 0.24s; }

.mg-card__top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

/* ثابت: الحالة يمين | الزر وسط (إن وُجد) | التاريخ يسار */
.mg-card__top .mg-status {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.mg-card__top .mg-teams-toggle-btn--inline {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.mg-card__top .mg-card__date {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.mg-status {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.mg-status--live {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(251, 191, 36, 0.45);
}

.mg-status--ready {
  color: #ddd6fe;
  background: rgba(124, 58, 237, 0.28);
  border: 1px solid rgba(168, 85, 247, 0.45);
}

.mg-status--done {
  color: #d1fae5;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.mg-card__date {
  margin: 0 !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted) !important;
  font-size: 0.82rem !important;
  text-align: start !important;
  white-space: nowrap;
}

.mg-card__date i {
  color: rgba(168, 85, 247, 0.85);
}

/* المواجهة — أسماء كاملة بدون قصّ */
.mg-matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.mg-team-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.mg-team-chip__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(245, 158, 11, 0.55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

.mg-team-chip__avatar--letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.mg-team-chip__name {
  display: block;
  width: 100%;
  max-width: 100%;
  color: #fff;
  font-weight: 800;
  font-size: 0.98rem;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.mg-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 4px;
}

.mg-vs span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 8px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.85rem;
  color: #1a0a2e;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.mg-teams-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.mg-teams-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 999px;
  border: 1px solid rgba(168, 85, 247, 0.4);
  background: rgba(124, 58, 237, 0.22);
  color: #e9d5ff;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mg-teams-toggle-btn--inline {
  padding: 4px 10px;
  font-size: 0.72rem;
  line-height: 1;
  min-width: 0;
  white-space: nowrap;
}

.mg-teams-toggle-btn--inline span {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.mg-teams-toggle-btn--inline i {
  font-size: 0.68rem;
  opacity: 0.9;
}

.mg-teams-toggle-btn:hover,
.mg-teams-toggle-btn.is-open {
  background: rgba(124, 58, 237, 0.38);
  border-color: rgba(168, 85, 247, 0.55);
  color: #fff;
}

.mg-teams-expanded {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding-top: 2px;
}

.mg-teams-expanded.visible {
  display: flex;
}

.mg-matchup--lone {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}

.mg-matchup--lone .mg-team-chip {
  max-width: 50%;
}

.mg-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.my-games-page .progress-info {
  margin: 0 !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.my-games-page .progress-info strong {
  color: #fbbf24;
  font-size: 1rem;
  font-weight: 900;
}

.my-games-page .progress-bar {
  margin: 0 !important;
  height: 8px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  overflow: hidden;
}

.my-games-page .progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24 55%, #a855f7);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

.mg-cats-btn {
  margin: 0 !important;
  width: 100% !important;
  justify-content: center;
  padding: 10px 14px !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #e9d5ff !important;
}

.mg-cats-btn:hover {
  background: rgba(124, 58, 237, 0.28) !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
}

.my-games-page .challenge-categories-list {
  margin: 0 !important;
  width: 100%;
  box-sizing: border-box;
}

.my-games-page .challenge-categories-list.visible {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.mg-card__actions {
  margin-top: auto !important;
  padding-top: 4px !important;
  display: flex;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.my-games-page .action-btn {
  flex: 1;
  min-width: 0;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  white-space: nowrap;
}

.my-games-page .nav-item.active,
.my-games-page .mobile-nav-item.active {
  color: #fff;
  background: rgba(124, 58, 237, 0.35);
  box-shadow: 0 0 18px rgba(124, 58, 237, 0.25);
}

@keyframes myGamesFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes myGamesCardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes myGamesSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 992px) {
  .my-games-challenges {
    min-height: calc(100vh - 60px);
    padding: 4px clamp(18px, 4vw, 32px) 36px !important;
  }

  .my-games-challenges.challenges-collapsed {
    padding: 4px clamp(18px, 4vw, 32px) 36px !important;
  }
}

@media (max-width: 600px) {
  .my-games-page .challenges-section.my-games-challenges,
  .my-games-challenges {
    display: flex !important;
    flex-direction: column;
  }

  .my-games-page .saved-challenges {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .mg-matchup {
    gap: 8px;
  }

  .mg-team-chip {
    padding: 10px 8px;
  }

  .mg-team-chip__name {
    font-size: 0.9rem;
  }

  .my-games-refresh-btn span {
    display: none;
  }

  .my-games-page .challenge-categories-list.visible {
    grid-template-columns: 1fr;
  }
}
