    @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    body {
        font-family: 'Cairo', sans-serif;
        background: url('img/bg.png') no-repeat center center/cover;
        backdrop-filter: blur(10px);
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: auto; /* تم التأكيد على hidden لتجنب التمرير غير المرغوب فيه */
        position: relative;
        color: white;
    }

    body::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: url('bg.jpg') no-repeat center center / cover;
        filter: blur(8px);
        opacity: 0.4;
        z-index: 0;
        display: none;
    }

    body::after {
        content: '';
        position: absolute;
        inset: 0;
        background: radial-gradient(circle at 20% 50%, rgba(138, 43, 226, 0.3) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(147, 112, 219, 0.3) 0%, transparent 50%),
                    radial-gradient(circle at 40% 80%, rgba(106, 90, 205, 0.3) 0%, transparent 50%);
        backdrop-filter: blur(10px);
        z-index: 0;
    }

    .main-wrapper {
        display: flex;
        gap: 25px;
        position: relative;
        z-index: 1;
        padding: 20px;
        align-items: flex-start;
        flex-wrap: wrap;
        justify-content: center;
    }

    .info-panel {
        display: flex;
        flex-direction: column;
        align-items: center;
        background: linear-gradient(145deg, rgba(25, 25, 50, 0.95), rgba(50, 25, 75, 0.95));
        padding: 20px;
        border-radius: 15px;
        border: 2px solid #9370db;
        box-shadow: 0 15px 30px rgba(75, 0, 130, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
        width: 220px;
        height: auto;
    }

    .game-logo-container {
        margin-bottom: 20px;
    }

    .game-logo {
        width: 100%;
        max-width: 180px;
        height: auto;
        filter: drop-shadow(2px 2px 5px #000);
    }

    .info-box {
        margin-bottom: 15px;
        text-align: center;
        padding: 10px;
        background: linear-gradient(145deg, rgba(147, 112, 219, 0.2), rgba(138, 43, 226, 0.2));
        border-radius: 10px;
        border: 1px solid rgba(147, 112, 219, 0.3);
        width: 100%;
    }

    .info-label {
        font-size: 14px;
        color: #dda0dd;
        margin-bottom: 5px;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    .info-value {
        font-size: 24px;
        font-weight: 700;
        color: #ffffff;
        text-shadow: 0 2px 4px rgba(138, 43, 226, 0.8);
        background: linear-gradient(45deg, #ff6ec7, #b967db, #9370db);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

.game-area {
      width: 100%;
          max-width: 516px; /* ولكن لا تتجاوز هذا الحجم على الشاشات الكبيرة */
    height: auto; /* دع الارتفاع يتحدد بالمحتوى */

    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(145deg, rgba(25, 25, 50, 0.95), rgba(50, 25, 75, 0.95));
    border: 3px solid #9370db;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 20px 40px rgba(75, 0, 130, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 15px;

    /* 👇 ثبيت الحجم */
    width: 516px;
    height: 700px;
    overflow: hidden;
}


    .game-board {
        display: grid;
        gap: 6px;
        background-color: rgba(255,255,255,0.05);
        padding: 15px;
        border-radius: 12px;
        margin-bottom: 20px;
        border: 1px solid #999;
        width: fit-content;
        grid-template-columns: repeat(8, 50px);
    }
    .cell {
        width: 50px;
        height: 50px;
        background-color: rgba(255, 255, 255, 0.08);
        border-radius: 6px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .cell.filled {
        background-color: #9c27b0;
    }

    .cell.preview {
        background-color: rgba(255, 255, 255, 0.1); /* ظل أبيض خفيف */
        position: relative;
    }

    .shapes-container {
        display: flex;
        justify-content: center;
        gap: 20px;
        margin-top: 15px;
        flex-wrap: wrap;
        touch-action: none;

    }

    .shape {
        display: grid;
        cursor: grab;
        background-color: rgba(255, 255, 255, 0.06);
        padding: 10px;
        border-radius: 10px;
        gap: 6px;
        align-content: center;
        
    }

    .shape-cell {
        width: 30px;
        height: 30px;
        background-color: transparent;
        border-radius: 4px;
        margin: 1px;
    }

    .shape-cell.filled {
        background-color: #ba68c8;
    }

    .game-over {
        position: absolute;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.85);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #fff;
        z-index: 5;
        border-radius: 15px;
    }

    .game-over.hidden {
        display: none;
    }

    .game-over h2 {
        color: #fff;
        font-size: 3rem;
        margin-bottom: 10px;
        background: linear-gradient(45deg, #ff6b6b, #e74c3c);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .game-over p {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .game-over button {
        margin-top: 15px;
        padding: 10px 25px;
        font-size: 1.2rem;
        background: linear-gradient(145deg, #9370db, #8a2be2, #6a5acd);
        border: none;
        border-radius: 8px;
        color: white;
        cursor: pointer;
        font-family: 'Cairo', sans-serif;
        transition: all 0.3s ease;
        box-shadow: 0 4px 12px rgba(147, 112, 219, 0.4);
    }

    .game-over button:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(147, 112, 219, 0.6);
    }

    .cell.clearing {
        animation: popFade 0.3s ease-out;
    }

    @keyframes popFade {
        0% {
            transform: scale(1);
            opacity: 1;
        }
        50% {
            transform: scale(1.3);
            opacity: 0.5;
        }
        100% {
            transform: scale(0.8);
            opacity: 0;
        }
    }

    .combo-banner {
        position: fixed;
        top: 25%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.8);
        font-size: 4rem;
        color: #ffe600;
        font-weight: bold;
        text-shadow: 3px 3px 10px #000;
        z-index: 1000;
        opacity: 0;
        transition: all 0.3s ease;
        pointer-events: none;
    }

    .combo-banner.visible {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    /* ستايل الـ Ghost الذي يتم سحبه */
    .drag-image-ghost {
        pointer-events: none; /* مهم جدا لعدم اعتراض أحداث الماوس */
        opacity: 0.8; /* شفافية القطعة المسحوبة */
        z-index: 10000; /* ✅ أعلى z-index لضمان ظهوره فوق كل شيء*/
        /* يمكنك إضافة box-shadow هنا لتأثير ظل إضافي للقطعة المسحوبة */
        /* box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); */
    }


    /* الأنماط الخاصة بلوحة المتصدرين والـ modal */
    .leaderboard-toggle {
        position: fixed;
        top: 15px;
        left: 150px;
        z-index: 9999;
        background: linear-gradient(145deg, #9370db, #8a2be2);
        color: white;
        border: none;
        padding: 10px 15px;
        font-size: 16px;
        border-radius: 10px;
        cursor: pointer;
        font-family: 'Cairo', sans-serif;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        transition: background 0.3s ease;
    }

    .leaderboard-toggle:hover {
        background: linear-gradient(145deg, #a569bd, #9370db);
    }

    .leaderboard {
        justify-items: center;
        position: fixed;
        top: 60px;
        left: 15px;
        width: 320px;
        background: rgba(0, 0, 0, 0.8);
        padding: 15px;
        border-radius: 15px;
        border: 2px solid #9370db;
        z-index: 9998;
        backdrop-filter: blur(10px);
        display: none; /* مخفي افتراضيًا */
        color: white;
        font-family: 'Cairo', sans-serif;
    }

    .leaderboard h3 {
        margin-bottom: 10px;
        font-size: 18px;
        text-align: center;
        color: #dda0dd;
    }

    .leaderboard ol {
        padding-left: 20px;
    }

    .leaderboard li {
        margin-bottom: 8px;
        font-size: 14px;
        direction: ltr; /* عكس اتجاه النص داخل القائمة */
    }

    .name-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
    }

    .name-modal .modal-content {
        background: rgba(50, 25, 75, 0.95);
        padding: 20px;
        border-radius: 15px;
        border: 2px solid #9370db;
        text-align: center;
        width: 300px;
    }

    .name-modal input {
        width: 80%;
        padding: 10px;
        margin: 10px 0;
        border-radius: 8px;
        border: 1px solid #ccc;
        font-family: 'Cairo', sans-serif;
        background-color: rgba(255, 255, 255, 0.1);
        color: white;
    }

    .name-modal button {
        margin: 5px;
        padding: 10px 20px;
        background: linear-gradient(145deg, #9370db, #8a2be2);
        border: none;
        border-radius: 10px;
        color: white;
        font-weight: bold;
        cursor: pointer;
        font-family: 'Cairo', sans-serif;
    }

    /* تعديلات على الميديا كويريز لتناسب الترتيب الجديد */
    @media (max-width: 1024px) {
        .main-wrapper {
            flex-direction: column;
            align-items: center;
            gap: 15px;
        }

        .info-panel,
        .game-area {
            width: 100%;
            max-width: 400px;
        }

        .game-board {
            grid-template-columns: repeat(8, minmax(30px, 1fr));
            width: auto;
            
        }

        .cell {
            width: auto;
            height: auto;
            padding-bottom: 100%;
        }

        .game-over {
            padding: 20px;
        }
    }

    @media (max-width: 480px) {
        .info-panel,
        .game-area {
            width: 95%;
        }

        .game-logo {
            width: 150px;
        }

        .info-value {
            font-size: 20px;
        }

        .game-over h2 {
            font-size: 2.2rem;
        }

        .game-over p {
            font-size: 1rem;
        }

        .game-over button {
            padding: 8px 20px;
            font-size: 1rem;
        }

        .shape {
            padding: 8px;
        }

        .shape-cell {
            width: 25px;
            height: 25px;
        }
    }

    .drag-image-ghost {
    pointer-events: none;
    opacity: 0.8;
    z-index: 10000 !important;
    position: fixed;
}

.cell.preview {
    z-index: 0 !important;
}

@media (max-width: 768px) {
    .cell.preview {
        z-index: 0 !important;
    }

    .drag-image-ghost {
        z-index: 10000 !important;
    }
}
/*
@media (max-width: 768px) {
    .cell.preview {
        position: relative;
        top: -10px; /* ارفع البريفيو فوق الماوس/الصباع بـ 10 بكسل */
       /* z-index: 1 !important;
        transition: top 0.1s ease;
    }
}
/*
@media (max-width: 768px) {
    
    .cell.preview {
        position: relative;
        top: -10px;
        z-index: 1 !important;
        transition: top 0.1s ease;
    }
}
*/
@media (max-width: 768px) {
    .game-area {
        width: 100%;
        max-width: 500px; /* ما تزيدش عن كده */
        height: 100%; /* ثابت ما يتغيرش */
    }

    .shapes-container {
        flex-direction: row; /* جنب بعض */
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        transform: scale(0.8); /* تصغير القطع */
    }

    .shape {
        transform: scale(0.9); /* تصغير إضافي للقطع */
        transform-origin: center;
    }
}

.cell.preview {
    z-index: 1 !important;
}

.drag-image-ghost {
    z-index: 10000 !important;
}

.drag-image-ghost {
    z-index: 10001 !important;
}

.drag-image-ghost {
  position: fixed !important;
  pointer-events: none;
  z-index: 10000 !important;
}

.game-area {
  overflow: visible !important;
}


.back-btn {
    position: fixed;
    top: 20px;
    left: 15px;
    padding: 6px 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 10px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    z-index: 999999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: .25s ease;
  }
  
  .back-btn:hover {
    transform: translateX(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  }
  
  .back-btn .arrow {
    width: 16px;
    height: 16px;
  }
  