* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #ebc8a5;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

header {
    width: 100vw;
    width: 100dvw;
    height: 10vh;
    height: 10dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-bottom: solid 1px #fff;
    background-color: #0002;
    /* margin-bottom: 10px; */
}

main {
    height: 85vh;
    height: 85dvh;
    padding: 5px;
}

footer {
    width: 100vw;
    width: 100dvw;
    height: 5vh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-top: solid 1px #fff;
    background-color: #0002;
    font-size: 0.9rem;
}

.game-container {
    text-align: center;
    width: 100%;
    /* max-width: 1200px; */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

h1 {
    margin-bottom: 5px;
    color: #333;
    font-size: calc(1.2rem + 1vw);
    font-size: calc(1.2rem + 1dvw);
}

.stats {
    margin-bottom: 10px;
    font-size: calc(0.9rem + 0.3vw);
    font-size: calc(0.9rem + 0.3dvw);
    font-weight: bold;
    color: #555;
}

.stats span {
    margin: 0 10px;
}

#attempts-style {
    margin-top: 15px !important;
}

.grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr); 
    gap: 5px;
    margin: 0 auto;
    width: 100%;
    width: 60vw;
    width: 60dvw;
    max-width: calc(68vh * (10 / 8)); 
    max-width: calc(68dvh * (10 / 8)); 
}

.card {
    aspect-ratio: 1 / 1;
    perspective: 1000px;
    cursor: pointer;
    width: 100%;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.card.matched {
    cursor: default;
    pointer-events: none;
}

.card.matched .card-inner {
    transform: rotateY(180deg);
    opacity: 0.1;
    transition: transform 0.6s, opacity 0.3s 0.6s;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.card-back {
    background-color: #4643f2;
    border: 2px solid #fff;
}

.card-front {
    background-color: #fff;
    transform: rotateY(180deg);
}

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

#restartBtn {
    margin-top: 15px;
    padding: 10px 25px;
    font-size: 1rem;
    font-weight: bold;
    background-color: #2e7d32;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background-color 0.2s, transform 0.1s;
}

#restartBtn:hover {
    background-color: #1b5e20;
}

#restartBtn:active {
    transform: scale(0.98);
}

.hidden {
    display: none !important;
}

.active-player {
    color: #2e7d32 !important;
    font-weight: 900;
    border-bottom: 3px solid #2e7d32;
    padding-bottom: 2px;
}

.attempts-style {
    color: #888;
    font-size: 0.9rem;
}

@media (orientation: portrait) {

    .grid {
        grid-template-columns: repeat(8, 1fr); 
        gap: 4px;
        min-width: 70vw;
        min-width: 70dvw;
        max-width: calc(65vh * (8 / 10)); 
        max-width: calc(65dvh * (8 / 10)); 
    }

    .card {
        perspective: 800px;
    }

    .card-back {
        border: 1px solid #fff; 
    }

    #player1-container,
    #player2-container,
    .attempts-style {
        white-space: nowrap;
        word-break: keep-all;
    }

    .stats {
        margin: 10px;
    }

    #restartBtn {
        margin-top: 10px;
        padding: 8px 20px;
        font-size: 0.9rem;
    }
}