:root {
    --primary-color: #00aaff;
    --bg-color: #050505;
    --header-bg: rgba(0, 0, 0, 0.7);
    --success-color: #ffd700;
    --center-color: #FF8C00;
}

/* --- التعديلات لمنع التمرير --- */
html {
    overflow-y: hidden;
    /* يمنع التمرير الرأسي على مستوى الصفحة */
}

/* --- General and Fixed Styles --- */
body {
    margin: 0;
    background: var(--bg-color);
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    overscroll-behavior-y: none;
    overflow-x: hidden;
    /* ** التعديل الأساسي هنا لمنع التمرير الرأسي في الجسم ** */
    overflow-y: hidden;
    /* ------------------------------------------------ */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-bottom: 100px;
}

header,
footer {
    width: 100%;
    padding: 10px 0;
    background: var(--header-bg);
    backdrop-filter: blur(4px);
    z-index: 10;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    padding: 0 10px;
    height: 60px;
}

.logo-text {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

/* Question Mark Icon next to Logo */
#helpBtn {
    font-size: 20px;
    color: #fff;
    cursor: pointer;
    margin-right: 15px;
    /* Spacing from the logo */
    padding: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Header Controls Container (Centering) */
.header-controls {
    display: flex;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 18px;
    padding: 8px 10px;
    margin: 0 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Reset Button (on the right for LTR) */
#resetBtn {
    font-size: 14px;
    color: #FF6347;
    background: rgba(255, 99, 71, 0.1);
    border: 1px solid #FF6347;
    padding: 5px 10px;
    border-radius: 6px;
    margin-left: auto;
    /* Push to the right for LTR */
}

footer {
    position: fixed;
    bottom: 0;
    font-size: 14px;
    opacity: 0.6;
}

/* --- Best Score Design and Position --- */
#bestScore {
    position: fixed;
    top: 60px;
    left: 0;
    /* Changed to left for LTR */
    font-size: 16px;
    font-weight: bold;
    color: var(--success-color);
    padding: 8px 15px;
    background: rgba(0, 170, 255, 0.2);
    border-bottom-right-radius: 10px;
    /* Adjusted corner */
    border-bottom-left-radius: 0;
    z-index: 9;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

/* --- Attempts Count Design and Position --- */
#attemptsDisplay {
    position: fixed;
    /* التعديل الرئيسي: زيادة قيمة top لتظهر أسفل #bestScore. (60px + 30px تقريباً) */
    top: 110px;
    left: 0;
    /* Changed to left for LTR */
    font-size: 16px;
    font-weight: bold;
    color: var(--secondary-color);
    /* يمكن استخدام لون مختلف لتمييزه عن أفضل نتيجة */
    padding: 8px 15px;
    background: rgba(0, 170, 255, 0.2);
    border-top-right-radius: 0;
    /* تم إزالة تقويس الزاوية العلوية اليمنى ليظهر متجانساً */
    border-bottom-right-radius: 10px;
    /* Adjusted corner */
    border-bottom-left-radius: 0;
    z-index: 9;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

/* يمكن أيضاً إضافة تنسيق للأجهزة الصغيرة إذا لزم الأمر */

@media (max-width: 600px) {
    #attemptsDisplay {
        top: 100px;
        font-size: 14px;
        padding: 5px 10px;
    }

}


/* --- Temporary Message Box (Congrats Message) --- */
#tempMessageBox {
    position: fixed;
    top: 105px;
    left: 50%;
    transform: translateX(-50%);
    /* Adjusted for LTR */
    width: 320px;
    background: #222;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 170, 255, 0.5);
    z-index: 30;
    text-align: center;
    border: 1px solid var(--primary-color);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, top 0.3s ease;
}

#tempMessageBox.show {
    opacity: 1;
    visibility: visible;
}

#messageContent {
    font-size: 15px;
    margin-bottom: 10px;
}

#messageContent strong {
    color: var(--success-color);
}

.temp-share-buttons .btn {
    margin: 0 5px;
    font-size: 12px;
}

#tempMessageBox .btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    transition: all 0.2s ease;
    cursor: pointer;
}


/* --- Canvas and Interaction Styles --- */
#canvas-container {
    position: relative;
    margin: 70px auto 40px auto;
    display: inline-block;
}

#canvas {
    background: #000;
    border: 3px solid var(--primary-color);
    touch-action: none;
    border-radius: 12px;
    display: block;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.3);
    cursor: crosshair;
}

#scoreBox {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 44px;
    font-weight: 900;
    text-shadow: 0 0 10px #000, 0 0 20px rgba(255, 255, 255, 0.3);
    pointer-events: none;
    line-height: 1.3;
}

/* --- Mobile Compatibility (Media Query) --- */
@media (max-width: 800px) {
    #canvas {
        width: 95vw !important;
        height: 95vw !important;
    }

    #scoreBox {
        font-size: 32px;
    }

    #bestScore {
        font-size: 14px;
    }

    .header-controls {
        left: unset;
        transform: unset;
        right: 50px;
        /* Leave space for reset button on the right */
    }

    #helpBtn {
        margin-right: 0;
        margin-left: 15px;
        /* Adjusted spacing for LTR */
    }

    .logo-text {
        position: absolute;
        left: 10px;
    }

    #resetBtn {
        position: absolute;
        right: 10px;
        padding: 5px 8px;
    }

    #tempMessageBox {
        width: calc(100% - 20px);
    }

    .control-btn {
        padding: 6px 8px;
        font-size: 16px;
        margin: 0 2px;
    }
}

/* Media Query لاستهداف الشاشات الصغيرة جداً (أقل من 576 بكسل) */
@media (max-width: 575.98px) {

    /* تقليل حجم الأزرار في رأس الصفحة */
    .control-btn {
        padding: 6px;
        /* تقليل المسافة الداخلية للأزرار */
        width: 30px;
        /* تحديد عرض أصغر */
        height: 30px;
        /* تحديد ارتفاع أصغر */
        font-size: 14px;
        /* تصغير حجم الخط (للأيقونات والنصوص) */
        margin-left: 2px !important;
        /* تقليل المسافة بين الأزرار */
        margin-right: 2px !important;
    }

    /* التأكد من أن زر المساعدة أيضاً يتأثر */
    #helpBtn {
        padding: 6px;
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    /* تقليل المسافة داخل حاويات الأزرار */
    .header-controls {
        margin-right: 5px !important;
        /* تقليل المسافة بين مجموعة أزرار التحكم وزر Reset */
    }

    /* تقليل حجم رمز الشعار إذا كان موجوداً */
    .logo-text {
        font-size: 16px;
    }
}