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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.game-container {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* 游戏头部 */
.game-header {
    background: linear-gradient(135deg, #ff6b6b, #ffa726);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-header h1 {
    font-size: 1.5rem;
    font-weight: bold;
}

.controls {
    display: flex;
    gap: 10px;
}

.sound-btn, .menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sound-btn:hover, .menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* 游戏信息 */
.game-info {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.info-item {
    text-align: center;
}

.label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 2px;
}

.info-item span:last-child {
    font-weight: bold;
    color: #333;
    font-size: 1rem;
}

/* 游戏板 */
.game-board {
    padding: 20px;
    display: grid;
    gap: 8px;
    justify-content: center;
    min-height: 400px;
}

.game-board.easy {
    grid-template-columns: repeat(6, 1fr);
}

.game-board.medium {
    grid-template-columns: repeat(8, 1fr);
}

.game-board.hard {
    grid-template-columns: repeat(10, 1fr);
}

/* 游戏卡片 */
.card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: auto;
    touch-action: manipulation;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1), transparent);
    pointer-events: none;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.card.selected {
    background: linear-gradient(135deg, #ff6b6b, #ffa726);
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(255, 107, 107, 0.3);
}

.card.matched {
    background: linear-gradient(135deg, #51cf66, #40c057);
    animation: matchAnimation 0.6s ease;
    pointer-events: none;
}

.card.hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

.card.hint {
    background: linear-gradient(135deg, #4CAF50, #45a049) !important;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    animation: hintPulse 1s ease-in-out infinite alternate;
}

@keyframes matchAnimation {
    0% { transform: scale(1); }
    50% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1); }
}

/* 弹窗样式 */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

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

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5rem;
}

/* 难度按钮 */
.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.difficulty-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.difficulty-btn.easy {
    background: linear-gradient(135deg, #51cf66, #40c057);
}

.difficulty-btn.medium {
    background: linear-gradient(135deg, #ffa726, #ff9800);
}

.difficulty-btn.hard {
    background: linear-gradient(135deg, #ff6b6b, #f44336);
}

.difficulty-btn .emoji {
    font-size: 2rem;
}

.difficulty-btn .text {
    font-size: 1.2rem;
    font-weight: bold;
    flex: 1;
    text-align: left;
}

.difficulty-btn .desc {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 游戏统计 */
.game-stats {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.game-stats p {
    margin: 5px 0;
    font-size: 1.1rem;
}

/* 按钮样式 */
.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn.secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e9ecef;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 480px) {
    .game-container {
        margin: 5px;
        border-radius: 15px;
    }
    
    .game-header h1 {
        font-size: 1.3rem;
    }
    
    .game-board {
        padding: 15px;
        gap: 6px;
    }
    
    .card {
        font-size: 1.2rem;
        border-radius: 8px;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
}

@media (max-height: 700px) {
    .game-board {
        min-height: 300px;
    }
    
    .card {
        font-size: 1.2rem;
    }
}

/* 连接线动画 */
.connection-line {
    position: absolute;
    background: #ff6b6b;
    height: 3px;
    border-radius: 2px;
    z-index: 100;
    animation: lineAnimation 0.5s ease;
}

@keyframes lineAnimation {
    0% { 
        opacity: 0;
        transform: scaleX(0);
    }
    100% { 
        opacity: 1;
        transform: scaleX(1);
    }
}

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

@keyframes reshuffleAnimation {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-10deg);
    }
    15% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
    }
    30% { 
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
    70% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
    100% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) rotate(10deg);
    }
}

@keyframes hintPulse {
    0% { 
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    }
    100% { 
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.9);
    }
}

@keyframes hintAnimation {
    0% { 
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.8);
    }
    15% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1.05);
    }
    85% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    100% { 
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.8);
    }
}