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

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    text-align: center;
    max-width: 800px;
    width: 100%;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2rem;
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #555;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
}

.game-controls {
    margin-bottom: 20px;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 0 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #45a049;
}

button:active {
    transform: scale(0.98);
}

#hintBtn {
    background-color: #2196F3;
}

#hintBtn:hover {
    background-color: #0b7dda;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 10px;
    padding: 20px;
    background-color: #bbada0;
    border-radius: 10px;
    margin-bottom: 20px;
    justify-content: center;
    align-content: center;
}

.card {
    width: 100%;
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    border-radius: 8px;
}

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

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

.card-front {
    background-color: #4CAF50;
    color: white;
}

.card-back {
    background-color: white;
    color: #333;
    transform: rotateY(180deg);
    border: 2px solid #333;
}

.card.selected .card-back {
    background-color: #FFEB3B;
    border-color: #FF9800;
}

.card.matched .card-inner {
    animation: matched 0.6s ease-in-out;
}

@keyframes matched {
    0% { transform: scale(1) rotateY(180deg); }
    50% { transform: scale(1.2) rotateY(180deg); }
    100% { transform: scale(0) rotateY(180deg); }
}

.card.hint .card-back {
    background-color: #FFC107;
    animation: hint-pulse 1s infinite;
}

@keyframes hint-pulse {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

.instructions {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
}

.instructions h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.instructions p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-board {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(8, 1fr);
        gap: 8px;
        padding: 15px;
    }
    
    .card-front, .card-back {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
        font-size: 1rem;
    }
    
    .game-board {
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(10, 1fr);
        gap: 5px;
        padding: 10px;
    }
    
    .card-front, .card-back {
        font-size: 1.2rem;
    }
    
    button {
        padding: 8px 16px;
        font-size: 0.9rem;
        margin: 0 3px;
    }
}

@media (max-width: 360px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(12, 1fr);
    }
    
    .card-front, .card-back {
        font-size: 1rem;
    }
}