@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@100;200;300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@300;400;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@200;300;400;500;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Readex+Pro:wght@200;300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');

/* تعريف الخطوط العربية */
:root {
    --font-primary: 'Noto Sans Arabic', 'Almarai', 'Tajawal', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-secondary: 'Almarai', 'Noto Sans Arabic', 'Tajawal', sans-serif;
    --font-heading: 'Tajawal', 'Almarai', 'Noto Sans Arabic', sans-serif;
    --font-body: 'Noto Sans Arabic', 'Readex Pro', 'IBM Plex Sans Arabic', sans-serif;
}

/* تطبيق الخطوط العربية */
body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
}

/* --- Professional Numbering for Most Downloaded Games --- */
.most-downloaded .games-grid {
  counter-reset: game-counter !important;
}

.most-downloaded .game-card {
  position: relative;
  overflow: hidden; /* Important for the ribbon effect */
}

.most-downloaded .game-card::before {
  counter-increment: game-counter !important;
  content: counter(game-counter) !important;
  position: absolute;
  top: 15px;
  right: -30px;
  width: 120px;
  height: 30px;
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: #1a1a1a;
  text-align: center;
  line-height: 30px;
  font-weight: 800;
  font-size: 1rem;
  transform: rotate(45deg);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  z-index: 2;
  display: block !important;
}

/* Game Badges - علامات الألعاب */
.game-badge {
  position: absolute;
  top: 15px;
  left: 15px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  color: white;
  z-index: 3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.game-badge.popular {
  background: #ff6b6b;
}

.game-badge.new {
  background: #4ecdc4;
}

/* Game Info Container - حاوية معلومات اللعبة */
.game-info {
  padding: 0.75rem 0.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.game-info h3 {
  margin: 0 0 0.5rem 0;
  padding: 0 0.5rem;
  font-size: 1rem;
  color: #ffffff !important;
  line-height: 1.3;
}

/* Game Stats - إحصائيات اللعبة */
.game-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

/* Rating - التقييم */
.rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.stars {
  color: #ffd700;
  font-size: 0.9rem;
  text-shadow: 0 0 3px rgba(255, 215, 0, 0.5);
}

.rating-text {
  color: #666;
  font-weight: 600;
}

/* Downloads - التحميلات */
.downloads {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: #666;
}

.download-icon {
  font-size: 0.8rem;
  color: #28a745;
}

.download-count {
  font-weight: 600;
  color: #333;
}

/* تحسين تصميم البطاقات */
.most-downloaded .game-card {
  background: #fff;
  border: 1px solid #e1e5e9;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.most-downloaded .game-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  border-color: #d1d5d9;
}

/* تحسين الأرقام الذهبية - تم دمجها مع التعريف الأساسي */

/* تحسين العلامات عند التمرير */
.game-card:hover .game-badge {
  transform: scale(1.05);
  transition: transform 0.2s ease;
}

/* تحسين التقييمات عند التمرير */
.game-card:hover .stars {
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
  transition: text-shadow 0.3s ease;
}

/* تحسين عدد التحميلات عند التمرير */
.game-card:hover .download-icon {
  color: #25a745;
  transform: translateY(-1px);
  transition: all 0.3s ease;
}

/* تحسين الاستجابة للشاشات الصغيرة */
@media (max-width: 768px) {
  .game-stats {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  
  .game-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
  
  .most-downloaded .game-card::before {
    font-size: 0.9rem;
    width: 100px;
    height: 25px;
    line-height: 25px;
  }
}

@media (max-width: 480px) {
  .game-info h3 {
    font-size: 0.9rem;
  }
  
  .game-stats {
    font-size: 0.8rem;
  }
  
  .stars {
    font-size: 0.8rem;
  }
}

/* تسريع رسم البطاقات */
.game-card {
  content-visibility: auto;
  contain-intrinsic-size: 300px 400px; /* fallback حجم تقديري لمنع القفز */
}

/* صور داخل الكروت */
.game-card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
}

body {
    font-family: 'Cairo', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
    direction: rtl;
    text-align: center;
}

header {
    background-color: #161b22;
    padding: 1rem 0;
    border-bottom: 1px solid #30363d;
}

nav {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Language Selector Styles */
.language-selector-container {
    margin-left: 1rem; /* Adjust as needed */
}

#language-selector {
    background-color: #0d1117;
    color: #e6edf3;
    padding: 0.5rem 0.75rem;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none; /* Remove default arrow */
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2012%2012%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20d%3D%22M6%209L0.803848%203.75L11.1962%203.75L6%209Z%22%20fill%3D%22%23e6edf3%22/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem; /* Make space for arrow */
}

#language-selector:hover {
    border-color: #58a6ff;
}

#language-selector:focus {
    outline: none;
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}

/* Adjust arrow position for LTR languages */
[dir="ltr"] #language-selector {
    background-position: left 0.75rem center;
    padding-right: 0.75rem;
    padding-left: 2rem;
}

/* Logo Styles - Updated Professional Design */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    position: relative;
}

.logo:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.logo-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.logo-text {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 5px;
    line-height: 1;
    direction: ltr; /* Force left-to-right for logo text */
}

.logo-faza {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 50%, #1abc9c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.8rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    letter-spacing: -0.5px;
    order: 1;
}

.logo-play {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 50%, #f39c12 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    order: 2;
}

/* Responsive logo */
@media (max-width: 768px) {
    .logo-icon {
        width: 32px;
        height: 32px;
    }
    
    .logo-faza {
        font-size: 1.4rem;
    }
    
    .logo-play {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .logo-text {
        display: flex;
        flex-direction: row;
        gap: 5px;
        align-items: baseline;
    }
    
    .logo-faza {
        font-size: 1.2rem;
    }
    
    .logo-play {
        font-size: 1rem;
    }
}

/* Dark mode support */
body.dark-mode .logo {
    filter: brightness(1.1);
}

body.dark-mode .logo-faza {
    background: linear-gradient(135deg, #5dade2 0%, #3498db 50%, #2ecc71 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .logo-play {
    background: linear-gradient(135deg, #ec7063 0%, #e74c3c 50%, #f7dc6f 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

nav a {
    text-decoration: none;
    color: #e6edf3;
    font-size: 1.1rem;
    transition: color 0.3s;
}

nav a:hover, nav ul li a.active {
    color: #58a6ff;
}

main {
    padding: 20px;
}

section {
    margin-bottom: 40px;
}

section h2 {
    font-size: 2em;
    margin-bottom: 20px;
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 10px;
    color: #333;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 2rem auto;
}

.game-card {
    background-color: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-color: #d1d5d9;
}

.game-card img {
    width: 100%;
    height: 170px;
    object-fit: cover;
}

.game-card h3 {
    margin: 1rem 0;
    padding: 0 1rem;
    font-size: 1.2rem;
    flex-grow: 1;
    color: #333;
}

.card-buttons {
    padding: 0 1rem 1rem;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.btn {
    padding: 0.75rem;
    text-decoration: none;
    border-radius: 5px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.3s ease;
    border: none;
    cursor: pointer;
    display: block;
    text-align: center;
    flex-grow: 1;
    min-width: 100px;
}

/* زر "احصل عليها" - أخضر مثل صفحة التطبيقات */
.btn:not(.btn-details) {
    background-color: #2ed573;
    color: white;
    box-shadow: none;
}

.btn:not(.btn-details):hover {
    background-color: #25b864;
}

.btn:not(.btn-details):active {
    background-color: #25b864;
}

/* زر "التفاصيل" - رمادي مثل صفحة التطبيقات */
.btn.details {
    background-color: #555;
    color: white;
}

.btn.details:hover {
    background-color: #444;
}

.btn.details:active {
    background-color: #444;
}

/* تأثير النبض للأزرار */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

footer {
    background-color: #0d1117;
    color: #8b949e;
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 3rem;
    border-top: 1px solid #30363d;
}

.footer-nav {
    margin-bottom: 1rem;
}

.footer-nav a {
    color: #8b949e;
    text-decoration: none;
    margin: 0 15px;
    transition: color 0.3s;
}

.footer-nav a:hover {
    color: #58a6ff;
}

/* WhatsApp Button Style */
.whatsapp-btn {
    display: inline-block;
    background-color: #25D366;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
    margin: 10px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.whatsapp-btn:hover {
    background-color: #128C7E;
    transform: scale(1.05);
}

/* Static Page Styles */
.static-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    text-align: right;
}

.static-page h2 {
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    color: #333;
}

.static-page h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #333;
}

.static-page p {
    line-height: 1.8;
    color: #666;
    margin-bottom: 1rem;
}

/* Hero Section */
.hero {
    background: linear-gradient(rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1)), url('../images/hero-bg.jpg') no-repeat center center/cover;
    padding: 5rem 2rem;
    text-align: center;
    border-bottom: 1px solid #e1e5e9;
}

.hero-text h1 {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    color: #333;
}

.logo-faza {
    background: linear-gradient(to left, #ffb347, #ff4500);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.logo-play {
    background: linear-gradient(to left, #00d1ff, #007bff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.hero-text p {
    font-size: 1.6rem;
    color: #333;
    text-shadow: 1px 1px 6px rgba(255, 255, 255, 0.9);
    margin-top: 1rem;
    letter-spacing: 1.5px;
    font-weight: 400;
}

/* Hero Logo Styles */
.hero-logo {
    text-align: center;
    margin-bottom: 20px;
}

.hero-logo img {
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
    transition: all 0.3s ease;
}

.hero-logo img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 16px rgba(0,0,0,0.4));
}

/* Responsive hero logo */
@media (max-width: 768px) {
    .hero-logo img {
        width: 250px !important;
    }
}

@media (max-width: 480px) {
    .hero-logo img {
        width: 200px !important;
    }
}

/* Search Bar Styles */
.search-container {
    display: flex;
    align-items: center;
}

#search-form {
    display: flex;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}

#search-input {
    border: none;
    background-color: #0d1117;
    color: #e6edf3;
    padding: 0.5rem 0.75rem;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    outline: none;
}

#search-input::placeholder {
    color: #8b949e;
}

.search-btn {
    background-color: #238636;
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.search-btn:hover {
    background-color: #2ea043;
}

/* Responsive Design */
@media (max-width: 992px) {
    nav {
        padding: 0 2rem;
    }
    .games-grid {
        max-width: 90%;
    }
    .hero {
        padding: 4rem 1rem;
    }
    .hero-text h1 {
        font-size: 3rem;
    }
    .hero-text p {
        font-size: 1.3rem;
    }
}

@media (max-width: 768px) {
    .search-container {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }

    #search-form {
        width: 80%;
    }

    #search-input {
        flex-grow: 1;
    }

    nav {
        flex-direction: column;
        gap: 1rem;
    }

    nav ul {
        flex-direction: column;
        padding: 0;
        gap: 1rem;
        align-items: center;
        width: 100%;
    }

    nav ul li {
        width: 100%;
        text-align: center;
        padding: 0.5rem 0;
    }
    
    .hero {
        padding: 3rem 1rem;
    }

    .hero-text h1 {
        font-size: 2.5rem;
    }

    .hero-text p {
        font-size: 1.1rem;
    }

    section h2 {
        font-size: 1.8em;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 576px) {
    body {
        text-align: center;
    }

    .logo {
        margin-bottom: 1rem;
    }

    nav {
        padding: 0 1rem;
    }

    .hero-text h1 {
        font-size: 2.2rem;
    }

    .hero-text p {
        font-size: 1rem;
    }

    .games-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card-buttons {
        flex-direction: column;
        gap: 0.6rem;
        padding: 0.8rem;
    }
    
    .btn {
        width: 100%;
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }

    footer {
        padding: 1rem 0.5rem;
    }

    .footer-nav {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-nav a {
        margin: 0;
    }

    .static-page {
        padding: 1rem;
        text-align: center;
    }
}

/* إخفاء أماكن الإعلانات مؤقتاً - سيتم إزالتها بعد موافقة AdSense */
.ad-container {
    display: none !important;
}

/* إعلانات AdSense */
.ad-container {
    margin: 20px 0;
    text-align: center;
}

.ad-placeholder {
    background: #e9ecef;
    padding: 60px 20px;
    border-radius: 5px;
    color: #6c757d;
    font-weight: bold;
    border: 2px dashed #dee2e6;
}

.ad-sidebar {
    position: sticky;
    top: 20px;
    margin: 20px 0;
}

.ad-responsive {
    max-width: 100%;
    height: auto;
}

/* إعلان في الشريط الجانبي */
.sidebar-ad {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid #e9ecef;
}

/* إعلان بين المحتوى */
.content-ad {
    margin: 30px 0;
    text-align: center;
}

/* إعلان في الفوتر */
.footer-ad {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

/* === UI polish overrides (appended) === */
html { scroll-behavior: smooth; }
*, *::before, *::after { box-sizing: border-box; }

.games-grid { padding: 0 1rem; }

.game-card {
  background: linear-gradient(145deg, #151a21, #161b22);
  border: 1px solid #2b3138;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  transition: transform 120ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(88, 166, 255, 0.18);
  border-color: #415a77;
}

.game-card img {
  height: 180px !important;
  aspect-ratio: auto !important;
  display: block;
}

.game-card h3 {
  margin: 0.85rem 0 0.5rem 0;
  padding: 0 0.75rem;
  font-size: 1.05rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Make the second button visually a details button if no class provided */
.card-buttons a:last-child {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}
.card-buttons a:last-child:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Accessibility focus */
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 3px solid rgba(88, 166, 255, 0.5);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .games-grid { gap: 1.1rem; }
  .game-card img { height: 160px !important; }
}

@media (max-width: 576px) {
  .game-card img { height: 150px !important; }
  .btn { width: 100%; padding: 0.85rem 1rem; font-size: 0.95rem; }
}
