body {
    align-items: flex-start;
}

/* Pair selector */
.size-selector {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.size-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.size-btn.active,
.size-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Grid */
.grid-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.card-grid {
    display: grid;
    gap: 0.75rem;
}

.card-grid.pairs-4 { grid-template-columns: repeat(4, 110px); }
.card-grid.pairs-6 { grid-template-columns: repeat(4, 110px); }
.card-grid.pairs-8 { grid-template-columns: repeat(4, 110px); }

/* Card */
.card {
    width: 110px;
    height: 124px;
    cursor: pointer;
    perspective: 600px;
    user-select: none;
}

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

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

.card-back,
.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    box-sizing: border-box;
}

.card-back {
    background: var(--primary-color);
    color: white;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.card-front {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    transform: rotateY(180deg);
    font-size: 3rem;
}

.card.matched .card-front {
    background: #d1fae5;
    border-color: #6ee7b7;
}

/* Locked state */
.card-grid.locked .card:not(.flipped):not(.matched) {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

/* Action area */
.action-area {
    display: flex;
    justify-content: center;
    min-height: 56px;
    margin-bottom: 1rem;
}

.return-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 3rem;
    border-radius: 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: opacity 0.2s;
}

.return-btn:hover {
    opacity: 0.82;
}

/* Game controls */
.game-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.game-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: var(--muted-text);
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.game-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Result */
.result {
    text-align: center;
    padding: 1.25rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.result.success {
    background: #d1fae5;
    color: #065f46;
    border: 2px solid #a7f3d0;
}

.hidden {
    display: none;
}

/* Mobile */
@media (max-width: 480px) {
    .card { width: 80px; height: 92px; }
    .card-front { font-size: 2.6rem; }
    .card-grid.pairs-4 { grid-template-columns: repeat(4, 80px); }
    .card-grid.pairs-6 { grid-template-columns: repeat(4, 80px); }
    .card-grid.pairs-8 { grid-template-columns: repeat(4, 80px); }
}
