/**
 * Memory Match Game Styles
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.game-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.stats {
    display: flex;
    gap: 0.5rem;
}

.stat-box {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(4px);
}

.stat-box .label {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
}

.stat-box .value {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.best-score {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    min-height: 1.25rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    aspect-ratio: 1;
    perspective: 1000px;
}

.card {
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.4s ease;
    aspect-ratio: 1;
}

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

.card.matched {
    transform: rotateY(180deg);
}

.card.matched .card-front,
.card.matched .card-back {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
}

.card-front {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.card-front::after {
    content: '?';
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
}

.card-back {
    background: #fff;
    transform: rotateY(180deg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: #fff;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
    font-size: 1.75rem;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.overlay-content h2.new-best {
    color: #f5576c;
}

.overlay-content p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

.restart-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.restart-btn:focus-visible {
    outline: 3px solid #764ba2;
    outline-offset: 2px;
}

/* Home link */
.home-link {
    margin-top: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.home-link:hover {
    color: #fff;
    text-decoration: underline;
}

.home-link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 400px) {
    .game-container {
        padding: 0.5rem;
    }

    .title {
        font-size: 1.25rem;
    }

    .grid {
        gap: 6px;
    }

    .card-front::after {
        font-size: 1.25rem;
    }

    .card-back {
        font-size: 1.5rem;
    }
}
