body {
    font-family: 'Segoe UI', sans-serif;
    background: lightblue;
    color: white;
    text-align: center;
    margin: 0;
    padding: 0;
}

.game-container {
    max-width: 700px;
    margin: 50px auto;
    padding: 20px;
    background: black;
    border-radius: 15px;
    box-shadow: gray;
}

.grid {
    display: grid;
    gap: 15px;
    margin-top: 20px;
}

.card {
    width: 100%;
    padding-top: 100%;
    position: relative;
    perspective: 600px;
    cursor: pointer;
}

.inner-card {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    pointer-events: none; /* clicks pass to parent card */
}

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

.front, .back {
    position: absolute;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* needed to flip */
    pointer-events: none;
}

.front {
    background: lightgray;
    z-index: 2; /* front is on top */
}

.back {
    background: white;
    color: black;
    transform: rotateY(180deg);
    z-index: 1; /* back is below */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* prevent emoji overflow */
}

.back span {
    display: block;
    font-size: 2.5rem;
    word-break: break-word; /* ensure emoji sequences stay inside */
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    text-align: center;
}

button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    background: gray;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: white;
}

button:hover {
    background: lightgray;
}

#win-message, #lose-message {
    font-size: 1.5rem;
    margin-top: 20px;
}

.hidden {
    display: none !important;
}

.menu-container {
    max-width: 500px;
    margin: 100px auto;
    padding: 30px;
    background: black;
    border-radius: 15px;
    text-align: center;
    box-shadow: gray;
}

.level-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.level-btn {
    flex: 1;
    padding: 15px 0;
    font-size: 1.2rem;
    border-radius: 10px;
    border: 2px solid white;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

.level-btn.selected, .level-btn:hover {
    background-color: white;
    color: green;
    font-weight: bold;
}