body {
    font-family: 'Tajawal', sans-serif;
    background: linear-gradient(135deg, #ff8787, #5ee4db);
    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;
}

.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, #categories-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;
}

#access-code-container {
    justify-content: center;
    color: white;
    text-align: center;
    z-index: 100;
}

#announcements-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    width: 90%;
    max-width: 400px;
}

#categories-container {
    justify-content: flex-start;
    overflow: hidden;
    color: white;
    text-align: center;
    align-items: center;
}

.categories-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    z-index: 200;
    /* تغيير flex-direction إلى column لوضع الزر الأصفر فوق الأزرق */
    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.3);
}

#access-code {
    padding: 8px;
    font-size: 0.9rem;
    width: 180px;
    max-width: 90%;
    border-radius: 5px;
    z-index: 110;
}

#access-code-container button, #random-start {
    padding: 10px 20px;
    font-size: 1rem;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 120;
    pointer-events: auto;
}

#random-start {
    background: #007bff;
}

#access-code-container button:hover, #random-start:hover {
    transform: scale(1.05);
    background: #218838;
}

#random-start:hover {
    background: #0056b3;
}

#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: 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: #1a1a1a;
}

/* أنماط زر التثبيت داخل الهيدر */
.install-prompt {
    padding: 10px 40px;
    font-size: 1rem;
    background: #f39c12;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 120;
    pointer-events: auto;
}

.install-prompt:hover {
    transform: scale(1.05);
    background: #e08e0b;
}

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

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

h1 {
    color: #fff;
    font-size: 1.5rem;
    margin: 3px 0;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.instructions {
    color: white;
    font-size: 0.9rem;
    margin: 3px 0;
    line-height: 1.2;
}

.main-content {
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    max-height: calc(100vh - 60px);
    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: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#time-input {
    padding: 5px;
    font-size: 0.8rem;
    border: 2px solid #007bff;
    border-radius: 5px;
    width: 50px;
}

#start-timer-button {
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #28a745;
    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: #218838;
}

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

.image-container {
    width: 100%;
    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(0, 0, 0, 0.8);
    color: white;
    padding: 3px 8px;
    font-size: 20px;
    border-radius: 3px;
}

#hint-button {
    background: #f39c12;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    margin: 5px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 160px;
}

#hint-button:hover:not(.disabled) {
    transform: scale(1.05);
    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: #dc3545;
    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;
}

.bottom-container {
    background: white;
    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: #333;
    text-shadow: none;
}

.bottom-container #time-input {
    padding: 5px;
    font-size: 0.8rem;
    border: 2px solid #007bff;
    border-radius: 5px;
    width: 50px;
}

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

.team {
    background: #0069d9;
    color: white;
    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: #28a745;
    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: #218838;
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    color: white;
    text-align: center;
    font-size: 0.8rem;
    padding: 10px 0;
    z-index: 200;
}

.announcement-card {
    background: 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: #333;
}

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

.announcement-card button {
    background: #000;
    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;
    }
    #random-start {
        padding: 8px 16px;
        font-size: 0.9rem;
        margin: 3px;
    }
    .install-prompt {
        padding: 8px 32px;
        font-size: 0.9rem;
        margin: 3px;
    }
    #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;
    }
}

@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;
    }
}