body {
    font-family: 'Microsoft JhengHei', 'PingFang TC', 'Apple LiGothic', 'WenQuanYi Micro Hei', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header {
    background-color: #333;
    color: #fff;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

nav ul li {
    margin: 5px 0;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    padding: 5px 10px;
    transition: color 0.3s;
}

nav ul li a:hover {
    color: #007bff;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

#banner {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    margin-bottom: 20px;
}

.category {
    margin: 40px 0;
}

.category h2 {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    position: relative;
    padding-bottom: 10px;
}

.category h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background-color: #007bff;
}

/* 使用 Grid 佈局確保所有格位寬度絕對統一，解決歐洲區變細的問題 */
.card-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 預設每行 4 格 */
    gap: 20px;
}

.card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

/* 圖片容器：固定高度並確保圖片完整顯示 */
.card-img-wrapper {
    width: 100%;
    height: 180px; /* 固定高度，讓卡片整齊 */
    overflow: hidden;
    border-radius: 5px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff; /* 圖片不夠寬/高時顯示白色背景 */
}

.card img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 關鍵：確保整張圖片完整顯示，不裁切 */
    transition: transform 0.3s ease;
}

.card:hover img {
    transform: scale(1.05);
}

.card h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
    height: 2.4em;
    line-height: 1.2em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

.card p {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
    height: 1.4em;
    line-height: 1.4em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.card a {
    display: block;
    padding: 10px;
    background-color: #007bff;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s;
    margin-top: auto;
}

.card a:hover {
    background-color: #0056b3;
}

footer {
    text-align: center;
    padding: 30px;
    background-color: #333;
    color: #fff;
    margin-top: 50px;
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .card-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    main {
        padding: 15px;
    }
    .card-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    .category h2 {
        font-size: 24px;
    }
    .card-img-wrapper {
        height: 150px; /* 手機版縮小圖片高度 */
    }
}

@media (max-width: 480px) {
    .card-container {
        grid-template-columns: 1fr; /* 小型手機每行 1 格 */
    }
    nav ul {
        gap: 10px;
    }
    nav ul li a {
        font-size: 14px;
    }
}
