/**
 * Memory Match Game Styles
 */

:root {
    --game-gradient-start: #FFD93D;
    --game-gradient-end: #FFA726;
    --card-front-gradient-start: #FF6B6B;
    --card-front-gradient-end: #FFA726;
    --card-match-glow: rgba(255, 217, 61, 0.5);
    --card-shadow: rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--game-gradient-start) 0%, var(--game-gradient-end) 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 with title and stats */
.header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

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

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

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

.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;
}

/* Card grid with 3D perspective for flip effect */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    aspect-ratio: 1;
    perspective: 1000px;
}

/* Individual card with 3D flip animation */
.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);
}

/* Matched cards get a subtle glow effect */
.card.matched .card-front,
.card.matched .card-back {
    box-shadow: 0 0 20px var(--card-match-glow);
}

.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 face-down side with gradient */
.card-front {
    background: linear-gradient(135deg, var(--card-front-gradient-start) 0%, var(--card-front-gradient-end) 100%);
    box-shadow: 0 4px 15px var(--card-shadow);
}

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

/* Card face-up side with symbol */
.card-back {
    background: #fff;
    transform: rotateY(180deg);
    box-shadow: 0 4px 15px var(--card-shadow);
}

/* Win overlay modal */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    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: var(--game-gradient-end);
    margin-bottom: 0.5rem;
}

.overlay-content h2.new-best {
    color: var(--card-front-gradient-start);
}

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

.share-container {
    margin-bottom: 1rem;
}

.restart-btn {
    background: linear-gradient(135deg, var(--game-gradient-start) 0%, var(--game-gradient-end) 100%);
    color: #333;
    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(255, 169, 38, 0.4);
}

.restart-btn:focus-visible {
    outline: 3px solid var(--game-gradient-end);
    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;
    }
}
