/* Matching Game Styles */

.matching-setup {
    text-align: center;
    padding: 2rem;
}

.matching-setup h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.matching-setup .setup-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.setup-options button {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.setup-options button:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-purple);
    transform: scale(1.05);
}

.matching-waiting {
    text-align: center;
    padding: 3rem;
}

/* Game Board */
.matching-game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.matching-scoreboard {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    max-width: 600px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: bold;
}

.score-hud {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-value {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.turn-indicator {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.turn-indicator.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--accent-purple);
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

[data-theme="kawaii"] .turn-indicator.active {
    background: rgba(236, 72, 153, 0.2);
    border-color: var(--accent-magenta);
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.3);
}

/* Grid Layouts */
.matching-grid {
    display: grid;
    gap: 10px;
    margin: 0 auto;
    perspective: 1000px;
    width: 100%;
    justify-content: center;
}

.matching-grid.layout-4x4 {
    grid-template-columns: repeat(4, 1fr);
    /* Approx 80px -> 100px per card */
    max-width: 450px;
}

.matching-grid.layout-5x6 {
    grid-template-columns: repeat(5, 1fr);
    max-width: 550px;
}

/* Card Styling */
.matching-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1; /* Make it square */
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.matching-card.flipped, .matching-card.matched {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border: 2px solid var(--border-color);
    overflow: hidden;
}

.card-back {
    /* "Back" of the card is what you see before flipping */
    background: linear-gradient(135deg, #c026d3, #db2777);
    color: white;
    font-size: 2rem;
}

[data-theme="kawaii"] .card-back {
    background: linear-gradient(135deg, #f472b6, #fbcfe8);
}

.card-front {
    /* The image side */
    background: var(--bg-card);
    transform: rotateY(180deg);
}

.card-front img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.matching-card.matched .card-front {
    opacity: 0.9;
}

.matching-card.matched.matched-by-p1 .card-front {
    box-shadow: inset 0 0 15px var(--accent-purple);
    border-color: var(--accent-purple);
}

.matching-card.matched.matched-by-p2 .card-front {
    box-shadow: inset 0 0 15px var(--accent-yellow);
    border-color: var(--accent-yellow);
}

[data-theme="kawaii"] .matching-card.matched.matched-by-p1 .card-front {
    box-shadow: inset 0 0 15px var(--accent-magenta);
    border-color: var(--accent-magenta);
}

[data-theme="kawaii"] .matching-card.matched.matched-by-p2 .card-front {
    box-shadow: inset 0 0 15px var(--accent-yellow);
    border-color: var(--accent-yellow);
}

/* Game Over overlay */
.matching-game-over {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.game-over-box {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 16px;
    text-align: center;
    border: 2px solid var(--accent-purple);
    box-shadow: 0 10px 40px var(--shadow);
}

.game-over-box h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-magenta));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-over-box p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

@media (max-width: 640px) {
    .matching-scoreboard {
        font-size: 1rem;
        padding: 0.5rem;
    }
    .score-value {
        font-size: 1.2rem;
    }
    .matching-grid {
        gap: 5px;
    }
    .matching-grid.layout-5x6 {
        /* On small screens, shrink the grid appropriately */
        max-width: 100%;
    }
}
