.game-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    margin: 20px auto;
    max-width: 520px;
    width: 95%;
}
.nav-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}
.nav-back:hover { color: var(--text-primary); }
.nav-title { font-size: 1.25rem; font-weight: 800; }

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px auto;
    padding: 0 20px;
    width: 100%;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 440px;
    padding: 16px 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-box { display: flex; flex-direction: column; gap: 4px; }
.stat-icon { font-size: 0.8rem; color: var(--text-secondary); }
.stat-value { font-size: 1.4rem; font-weight: 800; }

.board-wrapper {
    position: relative;
    padding: 20px;
    max-width: 440px;
    width: 100%;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.card {
    aspect-ratio: 1;
    cursor: pointer;
    perspective: 600px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.38s ease;
}

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

.card-back,
.card-front {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-back {
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    font-size: 1.3rem;
    color: var(--text-secondary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
    transition: background 0.2s;
}

.card:hover:not(.matched) .card-back {
    background: var(--hover-bg);
}

.card-front {
    background: var(--glass-bg);
    border: 1px solid rgba(56, 189, 248, 0.25);
    font-size: 2rem;
    transform: rotateY(180deg);
}

.card.matched .card-front {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.card.matched { cursor: default; }

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 14px;
    text-align: center;
    padding: 24px;
}
.overlay.hidden { display: none; }
