* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    min-height: 100vh;
    background: #1a1a1a;
    color: white;
    position: relative;
}

.custom-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease-in-out;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.5) 50%,
        rgba(0, 0, 0, 0.7) 100%
    );
    pointer-events: none;
}

.background-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7));
}

.category-selection {
    background: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 15px;
    margin: 20px 0;
    width: 80%;
    max-width: 500px;
}

.selection-group {
    margin: 15px 0;
    text-align: center;
}

.selection-group h3 {
    margin-bottom: 10px;
    color: #fff;
    font-size: 1.2em;
}

select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 5px;
}

.game-container {
    width: 100%;
    min-height: 100vh;
    padding: 20px;
}

.score-container {
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    margin-bottom: 20px;
}

.cards-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.card {
    background: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    width: 300px;
}

.card img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px;
}

.vs {
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

button {
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    margin: 5px;
    transition: all 0.3s ease;
}

button:hover {
    background: #45a049;
    transform: scale(1.05);
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.comments-section {
    margin-top: 30px;
    width: 80%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
}

#commentsContainer {
    max-height: 200px;
    overflow-y: auto;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
}

#commentInput {
    width: 100%;
    height: 80px;
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    resize: none;
}

.comment {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    margin: 5px 0;
    border-radius: 5px;
    text-align: left;
}

.music-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #4CAF50;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.music-toggle:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

.music-icon {
    font-size: 24px;
}

.music-toggle.muted {
    opacity: 0.5;
}

.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
    padding: 10px;
    border-radius: 10px;
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #4CAF50;
    border-radius: 5px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.language-btn:hover {
    background: #4CAF50;
    transform: translateY(-2px);
}

.language-btn.active {
    background: #4CAF50;
}

.flag-icon {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

.copyright {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.copyright p {
    margin: 5px 0;
}

.copyright p:first-child {
    font-weight: 500;
}

/* Adjust for RTL languages */
[dir="rtl"] .copyright {
    direction: ltr; /* Keep copyright text left-to-right */
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 700px) {
    html, body {
        font-size: 16px;
        min-height: 100vh;
        width: 100vw;
        overflow-x: hidden;
    }
    .background-screen,
    .game-over {
        padding: 5vw 2vw;
        min-height: 100vh;
        min-width: 100vw;
    }
    .category-selection {
        width: 100%;
        padding: 4vw 2vw;
        font-size: 1em;
        margin: 10px 0;
        max-width: 100vw;
    }
    .selection-group h3 {
        font-size: 1.1em;
    }
    .cards-container {
        flex-direction: column;
        gap: 12px;
        padding: 0;
        align-items: stretch;
    }
    .card {
        width: 98vw;
        max-width: 98vw;
        margin: 0 auto;
        padding: 10px 2vw;
        font-size: 1em;
    }
    .card img {
        height: 38vw;
        min-height: 120px;
        max-height: 220px;
        margin-bottom: 8px;
    }
    .vs {
        font-size: 2em;
        margin: 8px 0;
    }
    .score-container {
        padding: 8px 2vw;
        font-size: 1em;
        margin-bottom: 10px;
    }
    button, .language-btn {
        font-size: 1em;
        padding: 12px 0;
        width: 48vw;
        max-width: 300px;
        margin: 6px auto;
        display: block;
        border-radius: 8px;
    }
    .buttons {
        display: flex;
        flex-direction: row;
        gap: 10px;
        justify-content: center;
    }
    .music-toggle {
        width: 40px;
        height: 40px;
        bottom: 10px;
        right: 10px;
    }
    .music-icon {
        font-size: 18px;
    }
    .language-selector {
        top: 8px;
        right: 8px;
        gap: 4px;
        padding: 4px;
    }
    .comments-section {
        width: 99vw;
        max-width: 99vw;
        padding: 8px 2vw;
        font-size: 1em;
    }
    #commentInput {
        height: 48px;
        font-size: 1em;
    }
    .copyright {
        font-size: 0.8rem;
        padding: 4px 8px;
        bottom: 2px;
        left: 0;
        right: 0;
        width: 100vw;
        transform: none;
        border-radius: 0;
    }
}

/* Prevent landscape play on mobile */
@media (max-width: 700px) and (orientation: landscape) {
    body > *:not(.rotate-overlay) {
        display: none !important;
    }
    .rotate-overlay {
        display: flex !important;
    }
}

.rotate-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.95);
    color: #fff;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 2em;
    padding: 40px 20px;
    line-height: 1.3;
    pointer-events: all;
    transition: opacity 0.3s;
}
