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

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 750px;
    width: 100%;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* 顶部 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area {
    flex: 1;
}

.site-logo {
    max-height: 40px;
    max-width: 140px;
    object-fit: contain;
}

.domain-area {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.95;
}

/* 轮播 */
.carousel-section {
    position: relative;
    overflow: hidden;
    background: #eee;
}

.carousel {
    position: relative;
    width: 100%;
    height: 180px;
}

.carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.carousel-item.active {
    opacity: 1;
    z-index: 1;
}

.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    color: #999;
    font-size: 16px;
}

.carousel-dots {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    z-index: 2;
}

.carousel-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
}

.carousel-dots span.active {
    background: #fff;
}

/* 搜索 */
.search-section {
    padding: 12px 15px;
    background: #fff;
}

.search-box {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 24px;
    overflow: hidden;
    background: #f8f8f8;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 16px;
    font-size: 14px;
    background: transparent;
}

.search-box button {
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 0 20px;
    font-size: 14px;
    cursor: pointer;
}

/* 横幅广告 */
.banner-section {
    margin: 10px 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.banner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.banner-header em {
    font-style: normal;
    color: #999;
    font-size: 12px;
}

.toggle-btn {
    border: 1px solid #ddd;
    background: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
}

.toggle-btn:active {
    background: #f0f0f0;
}

.banner-list {
    overflow: hidden;
}

.banner-item {
    border-bottom: 1px solid #f0f0f0;
}

.banner-item:last-child {
    border-bottom: none;
}

/* 收起时只显示第一条，其余完全隐藏 */
.banner-list.collapsed .banner-item {
    display: none !important;
}
.banner-list.collapsed .banner-item:first-child,
.banner-list.collapsed .banner-item.first {
    display: block !important;
}

.banner-item img {
    width: 100%;
    display: block;
    max-height: 80px;
    object-fit: cover;
}

.banner-item .banner-text {
    display: block;
    padding: 14px 12px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
}

.banner-item.empty {
    padding: 20px;
    text-align: center;
    color: #999;
}

/* 分类 */
.category-section {
    margin: 10px 15px 20px;
    overflow: hidden; /* 防止网格撑出屏幕 */
}

.category-tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 12px;
}

.cat-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-size: 15px;
    color: #666;
    cursor: pointer;
    position: relative;
}

.cat-tab.active {
    color: #667eea;
    font-weight: 600;
}

.cat-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 20%;
    right: 20%;
    height: 2px;
    background: #667eea;
    border-radius: 1px;
}

.category-content {
    min-height: 200px;
    width: 100%;
    overflow: hidden;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)); /* minmax(0,1fr) 防止撑破 */
    gap: 10px 6px;
    width: 100%;
    box-sizing: border-box;
}

.item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #333;
    min-width: 0; /* 允许在窄屏收缩 */
    max-width: 100%;
}

.item-card .item-logo {
    width: 100%;
    aspect-ratio: 1;
    max-width: 100px;
    border-radius: 12px;
    overflow: hidden;
    background: #f0f0f0;
    border: 1px solid #eee;
}

.item-card .item-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-card .item-btn {
    margin-top: 6px;
    padding: 4px 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.item-card:active .item-btn {
    opacity: 0.85;
}

/* 滚动模式容器 */
.scroll-wrapper {
    overflow: hidden;
    height: 280px;
    position: relative;
}

.scroll-inner {
    transition: transform 0.6s ease;
}

/* 底部 */
.footer {
    padding: 20px 15px;
    text-align: center;
    background: #fafafa;
    border-top: 1px solid #eee;
    font-size: 13px;
    color: #888;
}

.footer-img {
    max-width: 100%;
    height: auto;
}

/* 搜索结果高亮 */
.item-card.hidden {
    display: none;
}

.no-result {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* 响应式兜底（JS 会按屏宽动态计算列数，这里再兜一层） */
@media (max-width: 480px) {
    .item-card .item-btn {
        font-size: 10px;
        padding: 3px 6px;
    }
}

@media (max-width: 360px) {
    .items-grid {
        gap: 8px 4px;
    }
}

/* ========== 跑马灯 ========== */
.marquee-section {
    padding: 8px 15px 0;
    background: #fff;
}

.marquee-wrap {
    display: flex;
    align-items: center;
    background: linear-gradient(90deg, #fff7e6, #fff1f0);
    border: 1px solid #ffe7ba;
    border-radius: 8px;
    padding: 8px 12px;
    overflow: hidden;
}

.marquee-icon {
    flex-shrink: 0;
    margin-right: 8px;
    font-size: 14px;
}

.marquee-track {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

.marquee-text {
    display: inline-block;
    padding-left: 100%;
    animation: marquee-scroll linear infinite;
    font-size: 13px;
    color: #d46b08;
    text-decoration: none;
}

.marquee-text:hover {
    color: #ad4e00;
}

@keyframes marquee-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ========== 弹窗广告 ========== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.65);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.popup-box {
    position: relative;
    max-width: 340px;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    transform: scale(0.9);
    transition: transform 0.25s;
}

.popup-overlay.show .popup-box {
    transform: scale(1);
}

.popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:active {
    background: rgba(0,0,0,0.7);
}

.popup-body {
    min-height: 200px;
}

.popup-body a,
.popup-body img {
    display: block;
    width: 100%;
}

.popup-body img {
    max-height: 70vh;
    object-fit: contain;
    background: #f5f5f5;
}

.popup-indicator {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #999;
    background: #fafafa;
}

/* 分类显示数量由 JS 按 rows×cols 控制 */
