/* تنسيق عام للعبة */
body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background-color: #fffdeb;
    color: #333;
    text-align: center;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* تنسيق الهيدر */
header {
    background-color: #ffd500;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* لوجو الكتكوت الصغير في الأعلى يميناً */
.app-logo-container {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
}

.app-logo {
    height: 60px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    animation: wiggle 3s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.logo img {
    height: 60px;
    margin-left: 15px;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ff6b00;
    text-shadow: 1px 1px 0px #fff;
}

/* العناوين */
h1 {
    color: #ff6b00;
    margin-top: 0;
    font-size: 2rem;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
}

h2 {
    color: #ff9500;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/* تنسيق منطقة اللعبة */
.game-area {
    background-color: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.game-area::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #ffd500, #ff9500);
}

/* مستويات اللعبة */
.level-indicator {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
}

.level-badge {
    background-color: #eee;
    color: #777;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.level-active {
    background-color: #ffd500;
    color: #333;
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(255, 213, 0, 0.8);
}

.level-complete {
    background-color: #4caf50;
    color: white;
    position: relative;
}

.level-complete::after {
    content: "✓";
    position: absolute;
    font-size: 0.7rem;
    top: -5px;
    right: -3px;
    background-color: white;
    color: #4caf50;
    border-radius: 50%;
    width: 13px;
    height: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #4caf50;
}

/* صندوق السؤال */
.question-box {
    background-color: #f9f9f9;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    border: 2px solid #ffd500;
}

.question-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ff6b00;
    margin-bottom: 15px;
}

/* خيارات الإجابة */
.options-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(50px, 90px));
    gap: 8px;
    justify-content: center;
    margin: 5px 0 15px;
    width: 100%;
}

.option-button {
    background-color: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    text-align: center;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-button:hover {
    background-color: #ffd500;
    border-color: #ffa000;
    transform: translateY(-2px);
}

/* نتيجة الإجابة */
.result-message {
    font-size: 1.1rem;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 10px;
    margin: 15px auto;
    transition: all 0.3s;
    opacity: 0;
    transform: translateY(-20px);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    clear: both;
    display: block;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
}

.visible {
    opacity: 1;
    transform: translateY(0);
}

.correct {
    background-color: #dff2d8;
    color: #4caf50;
    border: 2px solid #4caf50;
}

.incorrect {
    background-color: #ffdde0;
    color: #ff5252;
    border: 2px solid #ff5252;
}

/* تقدم اللعبة */
.progress-container {
    height: 18px;
    background-color: #f5f5f5;
    border-radius: 15px;
    margin-bottom: 15px;
    overflow: visible;
    width: 90%;
    border: 2px solid #f0f0f0;
    position: relative;
    --chick-position: 0px;
}

.progress-container::after {
    content: "🐤";
    position: absolute;
    top: -18px;
    left: var(--chick-position, 0);
    font-size: 20px;
    z-index: 5;
    transition: left 0.5s ease-in-out;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
    animation: bobUpDown 1s infinite alternate ease-in-out;
}

@keyframes bobUpDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(-3px); }
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #ffd500, #ff9500);
    width: 0;
    transition: width 0.5s ease-in-out;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
                rgba(255,255,255,0.1) 0%, 
                rgba(255,255,255,0.3) 50%, 
                rgba(255,255,255,0.1) 100%);
    background-size: 200% 100%;
    animation: progressShine 2s infinite linear;
}

@keyframes progressShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* الأزرار */
.btn {
    background-color: #ffa000;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'Tajawal', sans-serif;
    display: inline-block;
    text-decoration: none;
    margin: 5px;
}

.btn:hover {
    background-color: #ff8500;
}

.btn-secondary {
    background-color: #f5f5f5;
    color: #666;
    border: 2px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e5e5e5;
}

/* رسائل النجاح واللمحات */
.success-message {
    background-color: #f1f9eb;
    border: 2px solid #4caf50;
    color: #3d8b40;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    animation: fadeInUp 0.5s ease-out;
}

.hint-box {
    background-color: #fff9c4;
    border: 2px solid #ffd600;
    color: #866a00;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* عناصر العد أو الصور */
.counting-objects {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
}

.counting-item {
    font-size: 2.5rem;
    animation: bounce 0.5s ease infinite alternate;
}

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

@keyframes bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-10px);
    }
}

/* الفوتر */
footer {
    background-color: #ffd500;
    padding: 15px;
    margin-top: 40px;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

footer p {
    margin: 0;
    color: #333;
}

/* تكييف للشاشات الصغيرة */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }
    
    .game-area {
        padding: 15px 10px;
        margin-bottom: 15px;
    }
    
    .question-text {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .option-button {
        padding: 8px;
        font-size: 1.1rem;
        min-width: 50px;
    }
    
    .options-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 10px;
    }
    
    .counting-objects {
        gap: 8px;
        margin: 10px 0;
    }
    
    .counting-item {
        font-size: 2rem;
    }
    
    .btn {
        padding: 8px 15px;
        font-size: 1rem;
        margin: 3px;
    }
    
    h1 {
        font-size: 1.6rem;
        margin-bottom: 10px;
    }
    
    .progress-container {
        height: 15px;
        margin-bottom: 15px;
    }
    
    .question-box {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    /* تحسينات إضافية للموبايل */
    .result-message {
        font-size: 0.9rem;
        padding: 6px 10px;
        margin-bottom: 10px;
        position: relative;
        clear: both;
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    
    .game-content {
        display: flex;
        flex-direction: column;
    }
    
    .feedback-message {
        font-size: 1rem;
        padding: 8px;
        margin: 10px 0;
    }
    
    /* تنظيم العناصر بشكل عمودي للموبايل */
    .game-layout-mobile {
        display: flex;
        flex-direction: column;
    }
    
    /* تحسين تنسيق زر العودة */
    .btn-secondary {
        margin-top: 10px;
    }
    
    /* تقليل التباعد بين العناصر */
    .level-indicator {
        margin-bottom: 10px;
    }
}

/* تكييف إضافي للشاشات الصغيرة جدًا (الموبايل) */
@media (max-width: 480px) {
    .option-button {
        padding: 6px;
        font-size: 1rem;
        min-height: 40px;
    }
    
    .options-container {
        grid-template-columns: repeat(2, minmax(50px, 80px));
        gap: 6px;
    }
    
    .result-message {
        font-size: 0.8rem;
        padding: 5px 8px;
        margin: 8px auto;
        height: auto;
        white-space: normal;
    }
    
    .correct, .incorrect {
        border-width: 1px;
    }
    
    .question-box {
        padding: 8px;
        margin-bottom: 8px;
        border-width: 1px;
    }
    
    .counting-objects {
        gap: 5px;
        margin: 8px 0;
    }
    
    .counting-item {
        font-size: 1.8rem;
    }
    
    /* تخصيص إضافي لتجنب التداخل بين العناصر */
    .result-message.visible {
        margin-top: 10px;
        margin-bottom: 10px;
    }
}

/* تحريك للعناصر */
.animated {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* تنسيق عناصر الاحتفال */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    opacity: 0.8;
    top: -20px;
    z-index: 20;
    pointer-events: none;
    animation: confettiFall 3s ease-in-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(300px) rotate(720deg);
        opacity: 0;
    }
}

/* نمط لعرض النتائج النهائية */
.results-box {
    background-color: #fff;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    margin-top: 20px;
    border: 3px solid #ffd500;
    max-width: 500px;
    margin: 0 auto;
}

.results-title {
    font-size: 1.8rem;
    color: #ff6b00;
    margin-bottom: 15px;
}

.score-display {
    font-size: 3rem;
    font-weight: bold;
    color: #ff9500;
    margin: 15px 0;
}

.star-rating {
    font-size: 2.5rem;
    color: #ffd500;
    margin: 10px 0;
}

.star-rating .filled {
    color: #ffd500;
}

.star-rating .empty {
    color: #ddd;
}

/* توضيحات بصرية للعمليات الحسابية */
.math-operation {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ff6b00;
    margin: 20px 0;
    direction: ltr;
}

.math-symbol {
    color: #ff9500;
    margin: 0 10px;
}

/* ضبط العناصر للتنسيق مع RTL */
.rtl-fix {
    direction: ltr;
    display: inline-block;
}

/* تنسيق زخرفي للقائمة الرئيسية */
.menu-title {
    font-size: 1.6rem;
    font-weight: bold;
    color: #ff6b00;
    margin: 20px 0;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
}

.menu-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
}

.menu-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 240px;
    height: 180px;
    background: white;
    border: 4px solid #ffd500;
    border-radius: 25px;
    box-shadow: 0 8px 20px rgba(255, 150, 0, 0.2);
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    position: relative;
    overflow: hidden;
}

.menu-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(to right, #ffd500, #ff9500);
    border-radius: 5px 5px 0 0;
}

.menu-button:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(255, 150, 0, 0.3);
    border-color: #ff9500;
}

.menu-button:active {
    transform: translateY(0);
    box-shadow: 0 5px 10px rgba(255, 150, 0, 0.2);
}

.menu-button-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.menu-button:hover .menu-button-icon {
    transform: scale(1.2) rotate(10deg);
}

.menu-button span {
    font-size: 1.6rem;
    font-weight: bold;
    color: #ff6b00;
}

/* تكييف للشاشات الصغيرة */
@media (max-width: 768px) {
    .menu-button {
        width: 200px;
        height: 150px;
        padding: 10px;
    }
    
    .menu-button-icon {
        font-size: 3.5rem;
        margin-bottom: 10px;
    }
    
    .menu-button span {
        font-size: 1.4rem;
    }
    
    .app-logo {
        height: 50px;
    }
}

@media (max-width: 480px) {
    .menu-button {
        width: 160px;
        height: 120px;
    }
    
    .menu-button-icon {
        font-size: 3rem;
        margin-bottom: 8px;
    }
    
    .menu-button span {
        font-size: 1.2rem;
    }
    
    .app-logo {
        height: 40px;
    }
    
    .app-logo-container {
        top: 10px;
        right: 10px;
    }
}