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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #4b79a1 100%);
    min-height: 100vh;
    color: #333;
    padding: 20px;
    user-select: none;
}

.game-container {
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    color: #1e3c72;
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: 700;
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    font-weight: 600;
}

.stat span {
    color: #2a5298;
    font-weight: 700;
}

.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.difficulty-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 15px;
    border-radius: 8px;
    border: 2px solid #4b79a1;
}

.difficulty-controls select {
    padding: 5px 10px;
    border: 1px solid #4b79a1;
    border-radius: 5px;
    background: white;
    color: #1e3c72;
    font-weight: 600;
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: #2a5298;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(42, 82, 152, 0.3);
}

.btn:hover {
    background: #1e3c72;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(42, 82, 152, 0.4);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.game-board {
    display: grid;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    perspective: 1000px;
}

.game-board.easy {
    grid-template-columns: repeat(3, 1fr);
    max-width: 400px;
    margin: 0 auto 30px;
}

.game-board.medium {
    grid-template-columns: repeat(4, 1fr);
    max-width: 500px;
    margin: 0 auto 30px;
}

.game-board.hard {
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
    margin: 0 auto 30px;
}

.game-board.expert {
    grid-template-columns: repeat(6, 1fr);
    max-width: 720px;
    margin: 0 auto 30px;
}

.card-container {
    position: relative;
    width: 100px;
    height: 140px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

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

.card-container.matched {
    opacity: 0.6;
}

.card-container.matched.flipped {
    transform: rotateY(180deg) scale(0.95);
}

.card-container.matched:not(.flipped) {
    transform: scale(0.95);
}

.card-container.shake {
    animation: shake 0.5s ease-in-out;
}

.card-container.shake.flipped {
    animation: shakeFlipped 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes shakeFlipped {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-5px); }
    75% { transform: rotateY(180deg) translateX(5px); }
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.card-face.front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: rotateY(180deg);
}

.card-face.back {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    position: relative;
    overflow: hidden;
}

.card-face.back::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

.card-face.back::after {
    content: '🂠';
    font-size: 40px;
    opacity: 0.7;
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.card-value {
    font-size: 20px;
    font-weight: bold;
}

.card-suit {
    font-size: 28px;
}

.card-suit.red {
    color: #e74c3c;
}

.card-suit.black {
    color: #2c3e50;
}

.game-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.score-info, .tips {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #4b79a1;
}

.score-info h3, .tips h3 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.score-info ul, .tips ul {
    list-style: none;
    padding-left: 0;
}

.score-info li, .tips li {
    margin-bottom: 8px;
    padding-left: 25px;
    position: relative;
}

.score-info li::before {
    content: "🎯";
    position: absolute;
    left: 0;
}

.tips li::before {
    content: "💡";
    position: absolute;
    left: 0;
}

.game-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-message.show {
    display: flex;
}

.message-content {
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 3px solid #2a5298;
    max-width: 400px;
}

.message-content h2 {
    color: #1e3c72;
    margin-bottom: 20px;
    font-size: 2em;
}

.final-stats {
    margin-bottom: 20px;
}

.final-stats p {
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #2c3e50;
}

.rating {
    font-size: 2em;
    margin-bottom: 20px;
}

.leaderboard {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #4b79a1;
}

.leaderboard h3 {
    color: #1e3c72;
    margin-bottom: 15px;
    text-align: center;
}

.records {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(42, 82, 152, 0.1);
    border-radius: 8px;
    border: 1px solid #4b79a1;
}

.record-item .difficulty {
    font-weight: bold;
    color: #1e3c72;
}

.record-item .time {
    color: #2a5298;
    font-weight: 600;
}

.record-item .score {
    color: #2c3e50;
    font-weight: 600;
}

.celebration {
    animation: celebration 2s ease-in-out;
}

@keyframes celebration {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(2deg); }
    75% { transform: scale(1.1) rotate(-2deg); }
}

.perfect-game {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    animation: perfectGlow 2s ease-in-out infinite alternate;
}

@keyframes perfectGlow {
    from { box-shadow: 0 0 20px #FFD700; }
    to { box-shadow: 0 0 30px #FF8C00; }
}

/* 设置模态框 */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.settings-modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #1e3c72;
    margin-bottom: 20px;
    text-align: center;
}

.setting-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.setting-group label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 120px;
}

.setting-group select,
.setting-group input[type="range"] {
    flex: 1;
    min-width: 150px;
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* 按钮尺寸变体 */
.btn.small {
    padding: 6px 12px;
    font-size: 0.9em;
}

/* 排行榜增强 */
.leaderboard-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

/* 成就系统 */
.achievements-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #4b79a1;
    margin-top: 20px;
}

.achievements-panel h3 {
    color: #1e3c72;
    margin-bottom: 15px;
    text-align: center;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.achievement-item {
    background: rgba(42, 82, 152, 0.1);
    padding: 15px;
    border-radius: 10px;
    border: 2px solid transparent;
    text-align: center;
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    border-color: #FFD700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.1));
}

.achievement-item .achievement-icon {
    font-size: 2em;
    margin-bottom: 10px;
    opacity: 0.5;
}

.achievement-item.unlocked .achievement-icon {
    opacity: 1;
    animation: achievementGlow 1s ease-in-out infinite alternate;
}

@keyframes achievementGlow {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.achievement-item .achievement-name {
    font-weight: bold;
    color: #1e3c72;
    margin-bottom: 5px;
}

.achievement-item .achievement-desc {
    font-size: 0.9em;
    color: #666;
}

.achievement-item .achievement-progress {
    margin-top: 8px;
    font-size: 0.8em;
    color: #2a5298;
}

/* 卡牌主题变体 */
.theme-modern .card-face.front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
}

.theme-nature .card-face.front {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
}

.theme-numbers .card-face.front {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.theme-numbers .card-suit {
    display: none;
}

.theme-numbers .card-value {
    font-size: 36px;
}

/* 连击效果 */
.combo-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 1.5em;
    font-weight: bold;
    z-index: 1500;
    animation: comboShow 2s forwards;
    pointer-events: none;
}

@keyframes comboShow {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
    
    .game-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-board.easy {
        max-width: 320px;
    }
    
    .game-board.medium {
        max-width: 400px;
    }
    
    .game-board.hard {
        max-width: 480px;
    }
    
    .game-board.expert {
        max-width: 540px;
    }
    
    .card-container {
        width: 80px;
        height: 112px;
    }
    
    .card-face {
        font-size: 20px;
    }
    
    .card-value {
        font-size: 16px;
    }
    
    .card-suit {
        font-size: 22px;
    }
    
    .game-info {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .card-container {
        width: 70px;
        height: 98px;
    }
    
    .card-face {
        font-size: 18px;
    }
    
    .card-value {
        font-size: 14px;
    }
    
    .card-suit {
        font-size: 20px;
    }
}