* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

.game-container {
    max-width: 500px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.score-board {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 10px 15px;
    border-radius: 10px;
    color: white;
    min-width: 80px;
}

.score-item .label {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 5px;
}

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

.btn-reset {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-reset:active {
    transform: translateY(0);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    background: #e0e0e0;
    padding: 10px;
    border-radius: 15px;
    margin-bottom: 15px;
    aspect-ratio: 1;
}

.cell {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    position: relative;
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cell:active {
    transform: scale(0.95);
}

.cell.selected {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: pulse 0.6s infinite;
}

.cell.matched {
    animation: matchAnimation 0.5s ease-out forwards;
}

.cell.falling {
    animation: fallAnimation 0.3s ease-in forwards;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.15);
    }
}

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

@keyframes fallAnimation {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-tips {
    text-align: center;
    color: #666;
    font-size: 14px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 10px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    animation: slideUp 0.4s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 28px;
}

.modal-content p {
    color: #666;
    margin-bottom: 15px;
    font-size: 16px;
}

.final-score {
    font-size: 20px;
    font-weight: bold;
    color: #f5576c;
    margin: 20px 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* 方块颜色样式 */
.cell[data-type="0"] {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
}

.cell[data-type="1"] {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
}

.cell[data-type="2"] {
    background: linear-gradient(135deg, #feca57, #ff9ff3);
}

.cell[data-type="3"] {
    background: linear-gradient(135deg, #48dbfb, #0abde3);
}

.cell[data-type="4"] {
    background: linear-gradient(135deg, #ff9ff3, #feca57);
}

.cell[data-type="5"] {
    background: linear-gradient(135deg, #54a0ff, #2e86de);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }
    
    .score-item {
        min-width: 70px;
        padding: 8px 12px;
    }
    
    .score-item .label {
        font-size: 11px;
    }
    
    .score-item .value {
        font-size: 18px;
    }
    
    .btn-reset {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .game-board {
        gap: 4px;
        padding: 8px;
    }
    
    .cell {
        font-size: 20px;
        border-radius: 6px;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .modal-content h2 {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .game-container {
        padding: 10px;
        border-radius: 15px;
    }
    
    .game-header {
        gap: 10px;
    }
    
    .score-board {
        gap: 10px;
    }
    
    .score-item {
        min-width: 60px;
        padding: 6px 10px;
    }
    
    .score-item .label {
        font-size: 10px;
    }
    
    .score-item .value {
        font-size: 16px;
    }
    
    .game-board {
        gap: 3px;
        padding: 6px;
    }
    
    .cell {
        font-size: 18px;
        border-radius: 5px;
    }
    
    .game-tips {
        font-size: 12px;
        padding: 8px;
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .cell:hover {
        transform: none;
    }
}
