* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    image-rendering: pixelated;
    font-family: 'Press Start 2P', cursive, Arial, sans-serif;
}

body {
    background: #8B4513;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    color: #F5F5DC;
    overflow-x: hidden;
    background-image: 
        linear-gradient(rgba(139, 69, 19, 0.9), rgba(139, 69, 19, 0.9)),
        repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(101, 67, 33, 0.5) 4px, rgba(101, 67, 33, 0.5) 8px);
}

.game-wrapper {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    text-align: center;
    margin-bottom: 15px;
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 4px solid #CD853F;
    border-radius: 0;
    box-shadow: 4px 4px 0 #8B4513;
}

h1 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: #FFD700;
    text-shadow: 2px 2px 0 #8B0000;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.7rem;
    color: #F5F5DC;
    margin-bottom: 5px;
}

.category-indicator {
    display: inline-block;
    background: #8B0000;
    color: white;
    font-size: 0.6rem;
    padding: 3px 8px;
    margin-top: 5px;
    border: 2px solid #8B4513;
    box-shadow: 2px 2px 0 #5D2908;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #A0522D;
    border: 6px solid #8B4513;
    border-radius: 0;
    padding: 15px;
    box-shadow: 
        inset 4px 4px 0 #CD853F,
        inset -4px -4px 0 #8B4513,
        8px 8px 0 rgba(0, 0, 0, 0.3);
    width: 100%;
    margin-bottom: 15px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 15px;
    padding: 0 5px;
}

.info-box {
    font-size: 0.7rem;
    font-weight: bold;
    color: #8B4513;
    background: #FFD700;
    padding: 8px 10px;
    border: 3px solid #8B4513;
    border-radius: 0;
    box-shadow: 3px 3px 0 #8B0000;
    text-align: center;
    flex: 1;
    margin: 0 4px;
}

.game-board {
    display: grid;
    grid-gap: 6px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 500px;
    background: #8B4513;
    padding: 8px;
    border: 4px solid #8B4513;
    border-radius: 0;
    box-shadow: 
        inset 3px 3px 0 #CD853F,
        inset -3px -3px 0 #8B4513;
    position: relative;
}

.cell {
    aspect-ratio: 1;
    background: #F5F5DC;
    border: 3px solid #8B4513;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0 #A0522D;
    user-select: none;
    position: relative;
    overflow: hidden;
    padding: 5px;
}

/* 确保SVG图标正确显示 */
.cell svg {
    width: 60%;
    height: 60%;
    margin-bottom: 5px;
}

/* 非遗名称标签样式 */
.cell .heritage-label {
    font-size: 0.5rem;
    color: #8B4513;
    text-align: center;
    line-height: 1.2;
}

.cell:hover {
    transform: translateY(-2px);
    box-shadow: 3px 3px 0 #A0522D;
}

.cell.selected {
    transform: scale(0.95);
    background: #FFD700;
    box-shadow: 0 0 0 3px #8B0000;
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(0.95); }
    to { transform: scale(1.05); }
}

.cell.matched {
    animation: matchAnimation 0.8s ease forwards;
}

@keyframes matchAnimation {
    0% { 
        transform: scale(1); 
        opacity: 1; 
        background: #F5F5DC;
    }
    25% { 
        transform: scale(1.3); 
        background: #32CD32; 
        box-shadow: 0 0 20px #32CD32;
    }
    50% { 
        transform: scale(1.2) rotate(10deg); 
        opacity: 0.8; 
    }
    75% { 
        transform: scale(1.1) rotate(-10deg); 
        opacity: 0.5;
    }
    100% { 
        transform: scale(0) rotate(0deg); 
        opacity: 0; 
    }
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
}

.cell:active::before {
    opacity: 1;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 20;
}

.controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 10px;
}

.btn {
    background: #CD853F;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 0;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 4px 4px 0 #8B4513;
    transition: all 0.1s ease;
    flex: 1;
    margin: 0 5px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}

.btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #8B4513;
}

.btn-hint {
    background: #32CD32;
    box-shadow: 4px 4px 0 #228B22;
}

.btn-restart {
    background: #8B0000;
    box-shadow: 4px 4px 0 #600000;
}

.btn-album {
    background: #4682B4;
    box-shadow: 4px 4px 0 #2F4F4F;
}

.heritage-info {
    background: #A0522D;
    border: 4px solid #8B4513;
    border-radius: 0;
    padding: 12px;
    margin-top: 10px;
    width: 100%;
    max-width: 500px;
    color: #F5F5DC;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.heritage-info h3 {
    text-align: center;
    margin-bottom: 8px;
    color: #FFD700;
    font-size: 0.9rem;
}

.heritage-description {
    font-size: 0.7rem;
    line-height: 1.4;
    text-align: center;
    color: #F5F5DC;
}

.game-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #8B4513;
    color: white;
    padding: 20px;
    border: 6px solid #CD853F;
    border-radius: 0;
    text-align: center;
    z-index: 100;
    display: none;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
    max-width: 80%;
}

.game-message h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: #FFD700;
}

.game-message p {
    margin-bottom: 15px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #8B4513;
    border: 2px solid #F5F5DC;
    border-radius: 0;
    margin: 10px 0;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: #32CD32;
    width: 0%;
    transition: width 0.3s ease;
}

.combo-counter {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    color: #FFD700;
    text-shadow: 2px 2px 0 #8B0000;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
}

/* 难度选择界面 */
.difficulty-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #8B4513;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.difficulty-screen h2 {
    margin-bottom: 30px;
    color: #FFD700;
    text-shadow: 2px 2px 0 #8B0000;
    text-align: center;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.difficulty-btn {
    background: #CD853F;
    color: white;
    border: 4px solid #8B4513;
    padding: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 4px 4px 0 #8B4513;
    transition: all 0.1s ease;
    text-align: center;
}

.difficulty-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #8B4513;
}

.difficulty-btn.easy {
    background: #32CD32;
    box-shadow: 4px 4px 0 #228B22;
}

.difficulty-btn.medium {
    background: #FFA500;
    box-shadow: 4px 4px 0 #CD8500;
}

.difficulty-btn.hard {
    background: #8B0000;
    box-shadow: 4px 4px 0 #600000;
}

.difficulty-info {
    font-size: 0.6rem;
    margin-top: 5px;
    color: #F5F5DC;
}

/* 非遗图鉴 */
.heritage-album {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(139, 69, 19, 0.95);
    z-index: 150;
    overflow-y: auto;
    display: none;
    padding: 20px;
}

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

.album-title {
    color: #FFD700;
    text-shadow: 2px 2px 0 #8B0000;
}

.close-album {
    background: #8B0000;
    color: white;
    border: 3px solid #8B4513;
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 3px 3px 0 #600000;
}

.close-album:active {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 #600000;
}

.heritage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.heritage-card {
    background: #A0522D;
    border: 4px solid #8B4513;
    padding: 15px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s;
}

.heritage-card:hover {
    transform: translateY(-5px);
}

.heritage-card.locked {
    opacity: 0.5;
    filter: grayscale(100%);
    cursor: default;
}

.heritage-icon {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 10px;
}

.heritage-card h3 {
    color: #FFD700;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 8px;
}

.heritage-details {
    font-size: 0.7rem;
    color: #F5F5DC;
    line-height: 1.4;
}

.heritage-category {
    display: inline-block;
    font-size: 0.6rem;
    padding: 2px 5px;
    margin-top: 5px;
    background: #4682B4;
    color: white;
    border-radius: 3px;
}

.heritage-region {
    display: inline-block;
    font-size: 0.6rem;
    padding: 2px 5px;
    margin-top: 5px;
    margin-left: 5px;
    background: #8B0000;
    color: white;
    border-radius: 3px;
}

/* 非遗详情模态框 */
.heritage-detail-modal {
    display: none;
    position: fixed;
    z-index: 300;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
}

.modal-content {
    background-color: #A0522D;
    margin: 5% auto;
    padding: 20px;
    border: 6px solid #8B4513;
    width: 80%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close-modal {
    color: #F5F5DC;
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: #FFD700;
}

.detail-header {
    text-align: center;
    margin-bottom: 20px;
}

.detail-icon {
    margin: 0 auto 15px;
    width: 100px;
    height: 100px;
}

.detail-name {
    color: #FFD700;
    margin-bottom: 10px;
}

.detail-meta {
    font-size: 0.8rem;
    margin-bottom: 15px;
}

.detail-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    margin-bottom: 20px;
    border: 4px solid #8B4513;
}

.detail-description, .detail-history, .detail-features {
    margin-bottom: 15px;
    line-height: 1.6;
}

.detail-description h3, .detail-history h3, .detail-features h3 {
    color: #FFD700;
    margin-bottom: 8px;
    font-size: 1rem;
}

.detail-description p, .detail-history p, .detail-features p {
    font-size: 0.9rem;
}

/* 像素风字体 */
@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    src: url(https://fonts.gstatic.com/s/pressstart2p/v14/e3t4euO8T-267oIAQAu6jDQyK3nVivM.woff2) format('woff2');
}


/* 非遗图鉴图片容器样式 */
.heritage-image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 3px solid #8B4513;
    margin-bottom: 12px;
}

/* 未解锁遮罩层样式 */
.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: #FFD700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    text-align: center;
    padding: 0 10px;
    box-sizing: border-box;
}

/* 非遗卡片内容样式 */
.heritage-card-content {
    padding: 0 5px;
}

/* 详情模态框图标容器样式 */
.detail-icon {
    margin: 0 auto 15px;
    width: 100px;
    height: 100px;
    border: 3px solid #8B4513;
    border-radius: 0;
    overflow: hidden;
}

/* 修复卡片hover效果（确保未解锁卡片无 hover 位移） */
.heritage-card.locked {
    transform: none !important;
    cursor: not-allowed;
}

/* 图片加载失败默认样式 */
.heritage-image-container img[src="images/default-heritage.jpg"] {
    object-fit: contain;
    background: #F5F5DC;
    color: #8B4513;
    font-size: 0.6rem;
    text-align: center;
    line-height: 160px;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .cell .heritage-label {
        font-size: 0.4rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}