/* تعديلات أساسية لضبط العرض الكامل */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Tajawal', sans-serif;
    /* ذوق جديد للألوان: تدرج أزرق-رمادي هادئ */
    background: linear-gradient(135deg, #F0F4F8, #D8E2ED); /* Light Blue-Gray to Muted Blue-Gray */
    margin: 0;
    min-height: 100vh;
    width: 100vw;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.sticker {
    position: absolute;
    z-index: 50;
    opacity: 0.8;
}

.sticker-top-left {
    top: 10px;
    left: 10px;
    width: 100px;
    height: 50px;
    background: url('assets/stickers/sticker1.png') no-repeat center;
    background-size: contain;
}

.sticker-bottom-right {
    bottom: 10px;
    right: 10px;
    width: 100px;
    height: 50px;
    background: url('assets/stickers/sticker2.png') no-repeat center;
    background-size: contain;
}

#access-code-container, #start-container, #game-container {
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: height 0.3s ease;
    /* لتجميع العناصر في المنتصف عمودياً */
    justify-content: center;
}

#access-code-container {
    color: #2F4F4F; /* لون نص جديد (Dark Slate Gray) */
    text-align: center;
    z-index: 100;
}

#announcements-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px; /* مسافة ليكون أسفل العناصر الأخرى */
    margin-bottom: 20px; /* مسافة أسفلها */
    width: 90%;
    max-width: 400px;
    z-index: 100; /* للتأكد من ظهورها */
}


#categories-container {
    justify-content: flex-start;
    overflow: hidden;
    color: #2F4F4F; /* لون نص جديد */
    text-align: center;
    align-items: center;
}

.categories-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    background: rgba(240, 244, 248, 0.7); /* خلفية شفافة (Light Blue-Gray) */
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}

#categories-container h2 {
    margin: 10px 0;
    font-size: 1.4rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

#access-code {
    padding: 8px;
    font-size: 0.9rem;
    width: 180px;
    max-width: 90%;
    border-radius: 5px;
    z-index: 110;
    margin-bottom: 8px; /* تقليل المسافة لتقريبها من الزر */
}

/* زر البداية والتأكيد: حجم أكبر وفي المنتصف */
#access-code-container button, #random-start, #start-game {
    padding: 15px 30px;
    font-size: 1.5rem;
    background: #4682B4; /* Steel Blue */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 8px 0; /* مسافة لتقريب العناصر من بعضها */
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 120;
    pointer-events: auto;
    width: auto;
    max-width: 280px;
}

#random-start {
    background: #5F9EA0; /* Cadet Blue - لون مختلف قليلاً لزر البداية العشوائية */
}

#access-code-container button:hover, #random-start:hover, #start-game:hover {
    transform: scale(1.05);
    background: #5F9EA0; /* Cadet Blue */
}

/* زر "أخذ نسخة محلية": تصميم يتماشى مع الثيم */
.install-prompt {
    padding: 12px 25px;
    font-size: 1rem;
    background: #4682B4; /* Steel Blue - نفس لون زر البداية */
    color: white;
    border: none;
    border-radius: 8px; /* زوايا مستديرة مثل بقية الأزرار */
    cursor: pointer;
    margin-top: 15px;
    margin-bottom: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3); /* ظل مشابه للأزرار الأخرى */
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 120;
    pointer-events: auto;
    width: auto;
    max-width: 200px;
    font-weight: bold;
}

.install-prompt:hover {
    transform: scale(1.05);
    background: #5F9EA0; /* Cadet Blue - نفس تأثير الـ hover للأزرار الأخرى */
}

/* زر "الإجابات": تصميم مشابه لزر أخذ نسخة محلية */
.answers-button {
    padding: 12px 25px;
    font-size: 1rem;
    background: #4682B4; /* Steel Blue */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
    margin-bottom: 20px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 120;
    pointer-events: auto;
    width: auto;
    max-width: 200px;
    font-weight: bold;
}

.answers-button:hover {
    transform: scale(1.05);
    background: #5F9EA0; /* Cadet Blue */
}

#categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    padding-bottom: 50px;
    width: 100%;
    max-width: 100%;
    margin-top: 120px;
    margin-bottom: 20px;
    overflow-y: auto;
    height: auto;
    max-height: calc(100vh - 220px);
    box-sizing: border-box;
    scroll-padding-bottom: 50px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.category-card {
    background: #FFFFFF; /* White */
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.category-card:hover {
    transform: scale(1.05);
}

.category-card img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 5px;
}

.category-card p {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: #2F4F4F; /* لون نص جديد */
}

#game-container {
    overflow-y: hidden;
}

.header-section {
    width: 100%;
    text-align: center;
    padding: 3px 0;
}

h1 {
    color: #2F4F4F; /* لون نص جديد */
    font-size: 1.5rem;
    margin: 5px 0;
    font-weight: 700;
    text-shadow: none;
}

.instructions {
    color: #2F4F4F; /* لون نص جديد */
    font-size: 0.9rem;
    margin: 5px 0;
    line-height: 1.2;
}

/* تعديل العرض الكامل للعناصر الأساسية */
.main-content {
    width: 100vw;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    transition: flex-direction 0.3s ease;
}

.timer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 3px 0;
    padding: 3px 0;
    flex-wrap: wrap;
}

#timer {
    font-size: 1.6rem;
    color: #4682B4; /* لون جديد */
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

#time-input {
    padding: 5px;
    font-size: 0.8rem;
    border: 2px solid #4682B4; /* لون جديد */
    border-radius: 5px;
    width: 50px;
}

#start-timer-button {
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #3CB371; /* Medium Sea Green */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, background 0.3s ease;
}

#start-timer-button:hover {
    transform: scale(1.05);
    background: #2E8B57; /* Sea Green */
}

.image-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-container {
    width: 100vw;
    max-width: 100vw;
    aspect-ratio: 4 / 3;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    border: none;
    background: transparent;
    margin: 3px 0;
    max-height: 50vh;
}

#game-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
}

#image-owner {
    position: absolute;
    top: 5px;
    right: 10px;
    background: rgba(47, 79, 79, 0.8); /* لون جديد */
    color: white;
    padding: 3px 8px;
    font-size: 20px;
    border-radius: 3px;
}

/* تعديل نص الحل ليبدأ من اليمين ويمتد لليسار */
#solution-text {
    display: none;
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(47, 79, 79, 0.7);
    color: white;
    padding: 10px 15px;
    font-size: 2rem;
    font-weight: bold;
    border: 2px solid #6A5ACD;
    border-radius: 8px;
    text-align: center;
    direction: rtl;
    z-index: 10;
    width: auto;
    max-width: 90%;
    box-sizing: border-box;
}

/* زر إظهار الحل: في المنتصف (أفقيًا) */
#hint-button {
    background: #6A5ACD; /* Slate Blue */
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    margin: 5px auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 160px;
    width: 100%;
    box-sizing: border-box;
}

#hint-button:hover:not(.disabled) {
    transform: scale(1.05);
    background: #483D8B; /* Dark Slate Blue */
    opacity: 0.9;
}

#hint-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.score-section {
    width: 100%;
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 3px 0;
    align-items: center;
}

.next-round, .return-button {
    background: #3CB371; /* Medium Sea Green */
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 140px;
    width: 100%;
    text-align: center;
}

.next-round:hover, .return-button:hover {
    transform: scale(1.05);
    opacity: 0.9;
    background: #2E8B57; /* Sea Green */
}

.bottom-container {
    background: #EBF2F7; /* Light Sky Blue-ish */
    border-radius: 10px;
    padding: 10px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    margin: 3px auto;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bottom-container .timer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
}

.bottom-container #timer {
    font-size: 1.4rem;
    color: #2F4F4F; /* لون نص جديد */
    text-shadow: none;
}

.bottom-container #time-input {
    padding: 5px;
    font-size: 0.8rem;
    border: 2px solid #4682B4; /* لون جديد */
    border-radius: 5px;
    width: 50px;
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.team {
    background: #DAE4EC; /* Light Blue-Gray */
    color: #2F4F4F; /* لون نص جديد */
    padding: 5px;
    border-radius: 8px;
    width: calc(50% - 6px);
    text-align: center;
    box-sizing: border-box;
}

.team h2 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.team p {
    font-size: 1.1rem;
    margin: 3px 0;
}

.score-button {
    background: #5F9EA0; /* Cadet Blue */
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.3s ease, background 0.3s ease;
    margin: 2px 0;
}

.score-button:hover {
    transform: scale(1.05);
    background: #4682B4; /* Steel Blue */
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(240, 244, 248, 0.7); /* خلفية شفافة (Light Blue-Gray) */
    backdrop-filter: blur(5px);
    color: #2F4F4F; /* لون نص جديد */
    text-align: center;
    font-size: 0.8rem;
    padding: 10px 0;
    z-index: 200;
}

.announcement-card {
    background: #FFFFFF; /* White */
    border-radius: 10px;
    padding: 8px;
    margin: 3px;
    width: 90%;
    max-width: 300px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.announcement-card h3 {
    margin: 0 0 6px;
    font-size: 0.9rem;
    color: #2F4F4F; /* لون نص جديد */
}

.announcement-card p {
    margin: 0 0 6px;
    font-size: 0.8rem;
    color: #555;
}

.announcement-card button {
    background: #4682B4; /* Steel Blue */
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.announcement-card button:hover {
    transform: scale(1.05);
}

@media (max-width: 600px) {
    #categories-grid {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 3px;
        padding-bottom: 40px;
        margin-top: 100px;
        margin-bottom: 60px;
        height: auto;
        max-height: calc(100vh - 180px);
        scroll-padding-bottom: 40px;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    .category-card {
        padding: 3px;
    }
    .category-card img {
        width: 100%;
        height: auto;
        max-height: 60px;
        object-fit: contain;
        border-radius: 5px;
    }
    .category-card p {
        font-size: 0.7rem;
    }
    /* تعديلات حجم زر البداية وزر التثبيت في الشاشات الصغيرة */
    #access-code-container button, #random-start, #start-game {
        padding: 12px 25px;
        font-size: 1.2rem;
    }
    .install-prompt {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    #categories-container h2 {
        font-size: 1.3rem;
        margin: 15px 0;
    }
    h1 {
        font-size: 1.2rem;
    }
    #timer {
        font-size: 1.4rem;
    }
    .image-container {
        width: 95%;
        max-height: 45vh;
        margin: 3px auto;
    }
    .team h2 {
        font-size: 0.9rem;
    }
    .team p {
        font-size: 1.1rem;
    }
    .hint-button, .score-button, .next-round, .return-button {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    .sticker-top-left, .sticker-bottom-right {
        width: 60px;
        height: 30px;
    }
    .category-card {
        min-width: 100px;
    }
    footer {
        font-size: 0.7rem;
        padding: 8px 0;
    }
    .bottom-container .timer-container {
        padding: 2px;
    }
    .bottom-container #timer {
        font-size: 1.2rem;
    }
    #start-timer-button {
        padding: 5px 10px;
        font-size: 0.7rem;
    }
    /* نص الحل في الشاشات الصغيرة */
    #solution-text {
        font-size: 1.5rem;
        padding: 10px;
    }
}

@media (min-width: 600px) and (orientation: landscape), (min-width: 1024px) {
    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        margin: 0;
    }
    #categories-container {
        width: 100%;
        max-width: 1200px;
        padding: 0;
        margin: 0 auto;
    }
    #categories-grid {
        width: 100%;
        max-width: 1000px;
        padding: 10px;
        padding-bottom: 50px;
        gap: 10px;
        margin-top: 120px;
        margin-bottom: 80px;
        height: auto;
        max-height: calc(100vh - 220px);
        scroll-padding-bottom: 50px;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    #game-container {
        width: 100vw;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        overflow: hidden;
    }
    .header-section {
        width: 100%;
        padding: 5px 0;
    }
    h1 {
        font-size: 1.3rem;
        margin: 2px 0;
    }
    .instructions {
        font-size: 0.8rem;
        margin: 2px 0;
    }
    .main-content {
        width: 100%;
        height: calc(100vh - 80px);
        display: flex;
        flex-direction: row;
        justify-content: stretch;
        align-items: stretch;
        gap: 10px;
        overflow: hidden;
    }
    .image-section {
        flex: 0 0 70%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 0;
        margin: 0;
        height: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    .timer-container {
        width: 100%;
        margin: 0;
        padding: 0;
    }
    .image-container {
        width: calc(100% - 5px);
        margin-right: 5px;
        height: calc(100% - 60px);
        max-height: calc(100% - 60px);
        aspect-ratio: 16 / 9;
        margin: 0;
        padding: 0;
    }
    .score-section {
        flex: 0 0 30%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 0;
        margin: 0;
        height: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    .bottom-container {
        width: calc(100% - 10px);
        max-width: 200px;
        min-height: calc(100% - 60px);
        max-height: calc(100% - 60px);
        padding: 5px;
        margin: 0;
        margin-left: 10px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 10px;
        box-sizing: border-box;
        border-radius: 10px;
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .bottom-container .timer-container {
        padding: 5px;
    }
    .bottom-container #timer {
        font-size: 1.2rem;
    }
    .score-container {
        flex-direction: column;
        gap: 6px;
        width: 100%;
        flex-grow: 0;
    }
    .team {
        width: 100%;
        padding: 3px;
        border-radius: 8px;
        margin: 0;
    }
    .team h2 {
        font-size: 0.8rem;
    }
    .team p {
        font-size: 1rem;
        margin: 3px 0;
    }
    .score-button {
        padding: 4px 8px;
        font-size: 0.7rem;
        margin: 2px 0;
    }
    .button-container {
        gap: 6px;
        margin-top: 5px;
        flex-grow: 0;
    }
    .next-round, .return-button, #hint-button {
        max-width: 140px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    footer {
        width: 100%;
        padding: 5px;
        font-size: 0.6rem;
    }
    #start-timer-button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 360px) {
    h1 {
        font-size: 1.2rem;
    }
    #timer {
        font-size: 1.2rem;
    }
    .image-container {
        width: 100%;
        max-height: 45vh;
    }
    .category-card img {
        max-height: 50px;
    }
    .bottom-container .timer-container {
        padding: 2px;
    }
    .bottom-container #timer {
        font-size: 1.1rem;
    }
    #start-timer-button {
        padding: 5px 10px;
        font-size: 0.7rem;
    }
    /* نص الحل في الشاشات الصغيرة */
    #solution-text {
        font-size: 1.5rem;
        padding: 10px;
    }
}
