body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #1e3b28;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

.game-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 60px;
}

#cards-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    min-height: 220px;
    perspective: 1000px;
    padding: 0 20px;
}

.card-container {
    width: 150px;
    height: 210px;
    background-color: transparent;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

.card-container.flip .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.card-front {
    transform: rotateY(180deg);
}

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

.controls {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 20px;
}

button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.85);
    padding: 10px 30px;
    border-radius: 6px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    touch-action: manipulation;
    /* Mobile optimization */
}

button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.6);
    color: white;
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Modal */
.modal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    position: relative;
    background: rgba(30, 59, 40, 0.7);
    /* More translucent */
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 30px 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.9);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
}

.close-btn:hover {
    color: white;
}

.modal-content h2 {
    font-weight: 300;
    font-size: 24px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    display: inline-block;
}

.rules-list {
    text-align: left;
    list-style: none;
    padding: 0 10px;
    margin: 10px 0;
}

.rules-list li {
    margin-bottom: 15px;
    font-weight: 300;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.rules-list li strong {
    color: #ffd700;
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.rules-list .example {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    margin-top: 4px;
}

.enjoy {
    margin-top: 20px;
    font-style: italic;
    opacity: 0.8;
}

/* Mobile */
@media (max-width: 600px) {
    .game-container {
        gap: 30px;
    }

    #cards-container {
        gap: 15px;
        min-height: 160px;
    }

    .card-container {
        width: 100px;
        height: 140px;
    }

    .controls {
        gap: 15px;
        margin-top: 10px;
        flex-wrap: wrap;
    }

    button {
        padding: 10px 20px;
        font-size: 11px;
    }

    .modal-content {
        width: 90%;
        padding: 25px 20px;
        max-height: 85vh;
        /* Prevent modal from exceeding screen height */
        overflow-y: auto;
        /* Allow scrolling within modal */
    }

    .close-btn {
        top: 10px;
        right: 15px;
        font-size: 36px;
        z-index: 10;
        color: rgba(255, 255, 255, 0.8);
        /* Slightly muted to match image */
        background: transparent;
        /* Removed circular background */
        width: auto;
        height: auto;
        line-height: normal;
        border-radius: 0;
        text-align: right;
        font-weight: 300;
    }

    .modal-content h2 {
        font-size: 20px;
        margin-top: 10px;
        /* Make space for close button */
    }

    .rules-list li {
        font-size: 13px;
    }
}