/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 导航栏样式 */
.navbar {
    background-color: #333;
    color: white;
    padding: 15px 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.navbar-logo {
    font-size: 1.8rem;
    font-weight: bold;
}

.navbar-nav {
    display: flex;
    gap: 20px;
}

.nav-item {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-item:hover, .nav-item.active {
    background-color: #555;
}

/* 主内容区域样式 */
.main-content {
    padding-top: 80px; /* 为导航栏留出空间 */
    min-height: calc(100vh - 140px); /* 减去导航栏和页脚的高度 */
}

.page {
    display: none;
    padding: 40px 0;
}

.page.active {
    display: block;
}

.page-title {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.2rem;
    color: #333;
}

/* 游戏网格布局 */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

/* 游戏卡片样式 */
.game-card {
    perspective: 1000px;
    cursor: pointer;
    height: 400px;
}

.game-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.game-card:hover .game-card-inner {
    transform: rotateY(180deg);
}

.game-card-front, .game-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.game-card-front {
    background-color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-card-back {
    background-color: #4CAF50;
    color: white;
    transform: rotateY(180deg);
    align-items: center;
    justify-content: center;
}

.game-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 15px;
}

.game-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.game-description {
    font-size: 1rem;
    color: #666;
    line-height: 1.5;
}

.start-game-btn {
    background-color: white;
    color: #4CAF50;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

.start-game-btn:hover {
    background-color: #333;
    color: white;
}

/* 游戏页面样式 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.game-page-title {
    font-size: 2rem;
    color: #333;
}

.back-btn {
    background-color: #333;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.back-btn:hover {
    background-color: #555;
}

.game-container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.score-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.lives-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: #d9534f;
}

.restart-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.restart-btn:hover {
    background-color: #0056b3;
}

/* 游戏画布样式 */
.game-canvas {
    display: block;
    margin: 0 auto 20px;
    border: 2px solid #333;
    border-radius: 4px;
    background-color: #f0f0f0;
}

/* 2048游戏板样式 */
.game-board {
    width: 400px;
    height: 400px;
    margin: 0 auto 20px;
    background-color: #bbada0;
    border-radius: 6px;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 15px;
}

.game-board .tile {
    background-color: #cdc1b4;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    color: #776e65;
    transition: all 0.2s ease;
}

/* 游戏说明样式 */
.game-instructions {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.game-instructions h3 {
    margin-bottom: 10px;
    color: #333;
}

.game-instructions p {
    color: #666;
    line-height: 1.6;
}

/* 关于页面样式 */
.about-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.about-content h3 {
    margin: 20px 0 10px;
    color: #333;
}

.about-content ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.about-content li {
    margin-bottom: 8px;
}

/* 页脚样式 */
.footer {
    background-color: #333;
    color: white;
    padding: 20px 0;
    text-align: center;
}

.copyright {
    margin: 0;
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .navbar-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .main-content {
        padding-top: 120px;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-info {
        justify-content: center;
    }
    
    .game-board {
        width: 320px;
        height: 320px;
    }
    
    .game-canvas {
        max-width: 100%;
        height: auto;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1.8rem;
    }
    
    .game-card {
        height: 350px;
    }
    
    .game-image {
        height: 160px;
    }
    
    .game-board {
        width: 280px;
        height: 280px;
        padding: 10px;
        gap: 10px;
    }
    
    .game-board .tile {
        font-size: 24px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page.active {
    animation: fadeIn 0.5s ease-out;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}