/* Base & Reset */
:root {
  --bg-primary: #07090e;
  --bg-surface: #0f131c;
  --bg-card: #151a26;
  --bg-card-hover: #1c2333;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(255, 255, 255, 0.2);
  --text-main: #f0f3f8;
  --text-muted: #8c9ba5;
  --text-dim: #5a6674;
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-arabic: 'Segoe UI', Tahoma, 'Cairo', system-ui, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}

[dir="rtl"] {
  font-family: var(--font-arabic);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 20% 15%, rgba(0, 240, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 15%, rgba(157, 0, 255, 0.04) 0%, transparent 40%);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

/* Header & Top Bar */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(7, 9, 14, 0.85);
  border-bottom: 1px solid var(--border-color);
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
}

.brand-nav img {
  height: 38px;
  width: auto;
  border-radius: 6px;
  filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.4));
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: linear-gradient(90deg, #00a2ff 0%, #ffffff 50%, #9d00ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.lang-btn, .refresh-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

.lang-btn:hover, .refresh-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-color-active);
  transform: translateY(-1px);
}

/* Hero & Portal */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.hero-section {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.hero-main-title {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.hero-arabic-desc {
  font-size: 1.3rem;
  color: #c9d5e8;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.hero-tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

/* Service Portal Cards */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
}

.portal-card {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.portal-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  transition: var(--transition);
}

.portal-card.ps-portal::before {
  background: linear-gradient(90deg, #00a2ff, #00b4d8);
}

.portal-card.void-portal::before {
  background: linear-gradient(90deg, #9d00ff, #e040fb);
}

.portal-card:hover {
  transform: translateY(-8px);
  border-color: rgba(255, 255, 255, 0.25);
}

.portal-card.ps-portal:hover {
  box-shadow: 0 20px 45px -10px rgba(0, 240, 255, 0.3);
  border-color: rgba(0, 240, 255, 0.5);
}

.portal-card.void-portal:hover {
  box-shadow: 0 20px 45px -10px rgba(157, 0, 255, 0.3);
  border-color: rgba(157, 0, 255, 0.5);
}

.portal-logo-wrapper {
  width: 110px;
  height: 110px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  padding: 10px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.portal-card:hover .portal-logo-wrapper {
  transform: scale(1.08);
}

.portal-card.ps-portal .portal-logo-wrapper {
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.2);
}

.portal-card.void-portal .portal-logo-wrapper {
  box-shadow: 0 0 25px rgba(157, 0, 255, 0.2);
}

.portal-logo-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.portal-name {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 0.3rem;
}

.portal-edition {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.ps-text {
  color: #00a2ff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.void-text {
  color: #b026ff;
  text-shadow: 0 0 12px rgba(176, 38, 255, 0.4);
}

.portal-tiers-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.portal-btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: var(--transition);
}

.ps-btn {
  background: linear-gradient(135deg, #00a2ff, #0077b6);
  color: #030810;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.3);
}

.ps-btn:hover {
  background: linear-gradient(135deg, #33f3ff, #0096c7);
  box-shadow: 0 6px 25px rgba(0, 240, 255, 0.5);
}

.void-btn {
  background: linear-gradient(135deg, #9d00ff, #6a00f4);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(157, 0, 255, 0.3);
}

.void-btn:hover {
  background: linear-gradient(135deg, #b026ff, #7b2cbf);
  box-shadow: 0 6px 25px rgba(157, 0, 255, 0.5);
}

/* Service View Section */
.service-view {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.service-view.active {
  display: block;
}

.service-header {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.service-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.service-title-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.service-logo {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  object-fit: cover;
}

.service-title-text h1 {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.service-title-text span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.back-home-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  transition: var(--transition);
}

.back-home-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

/* Tier Tabs */
.tier-tabs-bar {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
}

.tier-tab {
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  white-space: nowrap;
}

.tier-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.tier-tab .tier-count {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
}

/* Controls Bar (Search, Filter, Sort) */
.controls-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1.1rem;
  pointer-events: none;
}

[dir="rtl"] .search-icon {
  right: 1.1rem;
}

[dir="ltr"] .search-icon {
  left: 1.1rem;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

[dir="rtl"] .search-input {
  padding-right: 2.8rem;
}

[dir="ltr"] .search-input {
  padding-left: 2.8rem;
}

.search-input:focus {
  border-color: var(--border-color-active);
  background: var(--bg-card);
}

.select-wrap select {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.2rem;
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-wrap select:focus {
  border-color: var(--border-color-active);
}

/* Status Banner */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.8rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Games Grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.5rem;
}

.game-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  position: relative;
}

.game-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 255, 255, 0.2);
}

.card-img-wrap {
  position: relative;
  width: 100%;
  padding-top: 135%; /* 3:4 aspect ratio */
  background: #11141c;
  overflow: hidden;
}

.card-img-wrap img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.game-card:hover .card-img-wrap img {
  transform: scale(1.05);
}

.card-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 2;
}

.tier-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.year-badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.75);
  color: #f0f3f8;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 0.6rem;
}

.game-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: auto;
}

.platforms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.platform-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 10;
  transition: var(--transition);
}

[dir="rtl"] .modal-close-btn {
  right: auto;
  left: 15px;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-header-hero {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: #0f121b;
}

.modal-header-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.65);
}

.modal-hero-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to top, var(--bg-surface), transparent);
}

.modal-body {
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.modal-game-title {
  font-size: 1.6rem;
  font-weight: 900;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.modal-meta-item span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.modal-meta-item p {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-desc-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.modal-desc-text {
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.65;
}

/* Empty State & Loader */
.loading-state, .empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #00a2ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

/* Footer */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background: rgba(7, 9, 14, 0.95);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer-brands {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.8rem;
}

.footer-brand-tag {
  font-weight: 800;
  letter-spacing: 1px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero-main-title {
    font-size: 2rem;
  }
  .controls-bar {
    grid-template-columns: 1fr;
  }
  .portal-grid {
    grid-template-columns: 1fr;
  }
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .card-body {
    padding: 0.65rem;
  }
  .game-title {
    font-size: 0.85rem;
  }
}
