* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', sans-serif;
    background-color: #f0f8ff;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    width: 95%;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
}

.game-mode {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.mode-btn {
    padding: 8px 16px;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.mode-btn.active {
    background-color: #2980b9;
}

.mode-btn:hover {
    background-color: #7f8c8d;
}

.mode-btn.active:hover {
    background-color: #2471a3;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.timer {
    font-size: 18px;
    font-weight: bold;
}

button {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

.game-board {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.grid-5x4 {
  grid-template-columns: repeat(5, 1fr); /* 修改为5列 */
  grid-template-rows: repeat(4, 1fr);    /* 修改为4行 */
}

.card {
    height: 80px;
    background-color: #3498db;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: black;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s, background-color 0.3s;
    border: 2px solid transparent;
}
/* 添加不匹配时的动画类 */
.card.not-matched {
    animation: notMatchedAnimation 1s;
    border: 2px solid #e74c3c;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

@keyframes notMatchedAnimation {
    0% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1);
    }
    75% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        border-color: transparent;
        box-shadow: none;
    }
}

/* 普通模式的卡片颜色 */
.card[data-mode="normal"][data-type="symbol"] {
    background-color: #fcb4bc;
}
.card[data-mode="normal"][data-type="name"] {
    background-color: #bcdcfc;
}

/* 困难模式的卡片颜色 */
.card[data-mode="hard"][data-type="number"] {
    background-color: #fcb4bc;
}
.card[data-mode="hard"][data-type="name"] {
    background-color: #bcdcfc;
}

/* 挑战模式的卡片颜色 */
.card[data-mode="challenge"][data-type="symbol"] {
    background-color: #fcb4bc;
}
.card[data-mode="challenge"][data-type="number"] {
    background-color: #bcdcfc;
}

.card:hover {
    transform: scale(1.02);
}

.card.flipped {
    background-color: #2ecc71;
    border: 2px solid #27ae60;
    box-shadow: 0 0 10px rgba(39, 174, 96, 0.5);
}

.card.matched {
    background-color: #27ae60;
    cursor: default;
    animation: matchedAnimation 0.5s forwards;
    border: none;
    box-shadow: none;
}
@keyframes matchedAnimation {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    25% {
        opacity: 1;
        transform: scale(1.1);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
    75% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

.game-result {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    text-align: center;
}

.game-result h2 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.game-result p {
    margin-bottom: 15px;
    font-size: 18px;
}

.clear-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.clear-btn:hover {
    background-color: #c0392b;
}

#player-name {
    padding: 8px;
    margin-right: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.leaderboard {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.leaderboard h2 {
    text-align: center;
    margin-bottom: 15px;
    color: #2c3e50;
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    gap: 10px;
}

.leaderboard-tab {
    padding: 5px 15px;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.leaderboard-tab.active {
    background-color: #2980b9;
}
.mode-select {
    padding: 8px 16px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    outline: none;
}

.mode-select:hover {
    border-color: #2980b9;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f2f2f2;
    font-weight: bold;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f1f1f1;
}

@media screen and (max-width: 768px) {
    .card {
        height: 60px;
        font-size: 16px;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .timer {
        font-size: 16px;
    }

    button, .mode-select {
        font-size: 14px;
        padding: 6px 12px;
    }

    h1 {
        font-size: 24px;
    }

    .leaderboard-tabs {
        flex-wrap: wrap;
    }

    .leaderboard-tab {
        font-size: 12px;
        padding: 4px 10px;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px 5px;
    }
}

@media screen and (max-width: 480px) {
    .card {
        height: 50px;
        font-size: 14px;
    }

    .container {
        padding: 10px;
    }

    .game-board {
        gap: 5px;
    }
}