/* 寻梦移动站 — ST 手游风格排版参考 */
:root {
    --xm-primary: var(--wap-primary, #3d77ff);
    --xm-primary-dark: var(--wap-primary-dark, #2597ff);
    --xm-primary-grad: linear-gradient(42deg, #3d77ff, #58d7fc);
    --xm-badge-grad: linear-gradient(90deg, #4ac6ff, #2597ff);
    --xm-bg: #f9f9f9;
    --xm-sidebar-bg: #f1f7fd;
    --xm-card: #ffffff;
    --xm-text: #333333;
    --xm-muted: #8f8f8f;
    --xm-border: #eceef2;
    --xm-tab-h: 50px;
    --xm-safe-b: env(safe-area-inset-bottom, 0px);
    --xm-page-max: 540px;
    --xm-wap-header-h: 96px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.xm-wap-body {
    margin: 0 auto;
    max-width: var(--xm-page-max);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--xm-text);
    background: var(--xm-bg);
    background-image: linear-gradient(180deg, rgba(61, 119, 255, 0.1) 0%, rgba(249, 249, 249, 0) 220px);
    background-repeat: no-repeat;
    padding-bottom: calc(var(--xm-tab-h) + var(--xm-safe-b) + 12px);
    overflow-x: hidden;
}
a { color: var(--xm-primary); text-decoration: none; }
img { max-width: 100%; display: block; }

/* 顶栏 */
.xm-wap-header {
    background: rgba(249, 249, 249, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: none;
    padding: 10px 12px 8px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    z-index: 50;
}
.xm-wap-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    margin-bottom: 10px;
}
.xm-wap-brand-link img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    background: #f3f4f6;
}
.xm-wap-brand-text { display: flex; flex-direction: column; min-width: 0; }
.xm-wap-brand-text strong { font-size: 16px; line-height: 1.25; }
.xm-wap-brand-text em {
    font-style: normal;
    font-size: 11px;
    color: var(--xm-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.xm-wap-search { display: flex; gap: 8px; }
.xm-wap-search input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}
.xm-wap-search button {
    border: none;
    border-radius: 20px;
    background: var(--xm-primary-grad);
    color: #fff;
    font-weight: 600;
    padding: 0 16px;
}

.xm-wap-main { padding: 0 0 8px; max-width: var(--xm-page-max); margin: 0 auto; overflow-x: hidden; }

/* 区块 */
.xm-block {
    background: var(--xm-card);
    border-radius: 10px;
    padding: 12px;
    margin: 0 10px 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.xm-block--flush { padding-top: 0; overflow: hidden; }
.xm-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.xm-block-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.xm-flame { font-style: normal; }
.xm-block-more { font-size: 13px; color: var(--xm-muted); white-space: nowrap; }
.xm-empty-tip { text-align: center; color: var(--xm-muted); padding: 20px 8px; margin: 0; }

/* 类型 Tab */
.xm-type-tabs-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.xm-type-tabs-bar .xm-type-tabs {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}
.xm-type-tabs-more {
    flex-shrink: 0;
    line-height: 1;
}
.xm-block-head .xm-type-tabs-more {
    margin-left: 8px;
}
.xm-type-tabs-more .xm-block-more {
    display: none;
}
.xm-type-tabs-more .xm-block-more.is-active {
    display: block;
}

/* 轮播 */
.xm-banner { padding: 0; overflow: hidden; }
.xm-banner-track { position: relative; aspect-ratio: 16/7; background: #e5e7eb; }
.xm-banner-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .35s;
}
.xm-banner-slide.is-active { opacity: 1; z-index: 1; }
.xm-banner-slide img { width: 100%; height: 100%; object-fit: cover; }
.xm-banner-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0 10px;
}
.xm-banner-dots button {
    width: 6px; height: 6px; border: none; border-radius: 50%;
    background: #d1d5db; padding: 0;
}
.xm-banner-dots button.is-active { background: var(--xm-primary); width: 16px; border-radius: 999px; }

/* 置顶 carousel */
.xm-carousel-viewport { position: relative; border-radius: 10px; overflow: hidden; }
.xm-carousel-slide { display: none; }
.xm-carousel-slide.is-active { display: block; }
.xm-carousel-slide a { display: block; color: inherit; position: relative; }
.xm-carousel-slide img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #eee; }
.xm-carousel-caption {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 24px 10px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,.72));
    color: #fff;
}
.xm-carousel-caption h3 { margin: 0 0 4px; font-size: 15px; }
.xm-carousel-caption p { margin: 0; font-size: 12px; opacity: .92; line-height: 1.4; }

/* 类型 Tab 列表 */
.xm-type-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 10px;
    padding-bottom: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.xm-type-tabs::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
.xm-type-tabs--sm { margin-top: 0; }
.xm-type-tab {
    flex-shrink: 0;
    border: 1px solid var(--xm-border);
    background: #fafafa;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--xm-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.xm-type-tab.is-active {
    background: var(--xm-primary-grad);
    border-color: transparent;
    color: #fff;
}
.xm-type-panel-body:not(.is-active),
.xm-hot-panel-body:not(.is-active) {
    display: none !important;
}
.xm-type-panel-body.is-active,
.xm-hot-panel-body.is-active {
    display: block;
}

.xm-icon-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.xm-icon-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
.xm-icon-item {
    flex: 0 0 72px;
    text-align: center;
    color: inherit;
    font-size: 11px;
}
.xm-icon-item img {
    width: 56px; height: 56px;
    border-radius: 12px;
    object-fit: cover;
    margin: 0 auto 4px;
    background: #f3f4f6;
}
.xm-icon-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 游戏网格 */
.xm-game-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.xm-game-tile { color: inherit; display: block; }
.xm-game-tile-cover {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f3f4f6;
    aspect-ratio: 1/1;
}
.xm-game-tile-cover img { width: 100%; height: 100%; object-fit: cover; }
.xm-game-tile-badge {
    position: absolute; left: 6px; top: 6px;
    background: rgba(239,68,68,.92);
    color: #fff; font-size: 10px;
    padding: 2px 6px; border-radius: 4px;
}
.xm-game-tile-title {
    margin: 6px 2px 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 排行榜 */
.xm-rank-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.xm-rank-tabs button {
    flex: 1;
    border: 1px solid var(--xm-border);
    background: #fafafa;
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
}
.xm-rank-tabs button.is-active {
    background: var(--xm-primary-grad);
    border-color: transparent;
    color: #fff;
}
.xm-rank-list { list-style: none; margin: 0; padding: 0; }
.xm-rank-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--xm-border);
}
.xm-rank-list li:last-child { border-bottom: none; }
.xm-rank-no {
    width: 22px; text-align: center;
    font-weight: 700; color: var(--xm-primary); flex-shrink: 0;
}
.xm-rank-list a { color: inherit; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 资讯 */
.xm-news-list { list-style: none; margin: 0; padding: 0; }
.xm-news-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 0; border-bottom: 1px solid var(--xm-border);
}
.xm-news-list li:last-child { border-bottom: none; }
.xm-news-list a { color: inherit; flex: 1; line-height: 1.4; }
.xm-news-list time { font-size: 12px; color: var(--xm-muted); flex-shrink: 0; }

/* 筛选 */
.xm-filter-bar { display: flex; border-bottom: 1px solid var(--xm-border); }
.xm-filter-bar a {
    flex: 1; text-align: center; padding: 12px 8px;
    color: var(--xm-muted); font-weight: 600;
    border-bottom: 2px solid transparent;
}
.xm-filter-bar a.is-active { color: var(--xm-primary); border-bottom-color: var(--xm-primary); }
.xm-type-scroll {
    display: flex; gap: 8px; overflow-x: auto;
    padding: 10px 12px; margin: 0 -12px;
}
.xm-chip {
    flex-shrink: 0; padding: 6px 12px; border-radius: 999px;
    background: #f3f4f6; color: var(--xm-text); font-size: 13px;
}
.xm-chip.is-active { background: var(--xm-primary-grad); color: #fff; }
body.xm-wap-games-list .xm-wap-main {
    padding: 0;
    overflow: hidden;
}

/* ST 风格 — 分类页左右分栏（右侧独立滚动，左侧固定） */
.xm-st-games-page {
    margin: 0;
    height: calc(100vh - var(--xm-wap-header-h) - var(--xm-tab-h) - var(--xm-safe-b));
    overflow: hidden;
}
.xm-st-games-layout {
    display: flex;
    align-items: stretch;
    height: 100%;
    min-height: 0;
}
.xm-st-sidebar {
    width: 52px;
    flex-shrink: 0;
    background: var(--xm-sidebar-bg);
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.xm-st-sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
.xm-st-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 8px 4px;
    text-align: center;
    font-size: 12px;
    line-height: 1.25;
    color: #000;
    word-break: break-all;
}
.xm-st-sidebar-item.is-active {
    background: var(--xm-primary-grad);
    color: #fff;
    font-weight: 600;
}
.xm-st-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.xm-st-sort-bar {
    display: flex;
    flex-shrink: 0;
    margin: 8px 10px 6px;
    background: #f3f5f8;
    border-radius: 8px;
    overflow: hidden;
}
.xm-st-game-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.xm-st-game-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
.xm-st-sort-bar a {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    font-size: 14px;
    color: var(--xm-muted);
    font-weight: 600;
}
.xm-st-sort-bar a.is-active {
    color: var(--xm-text);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.xm-st-game-list {
    padding: 0 10px 8px;
}
.xm-st-game-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 10px;
    color: inherit;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.xm-st-rank {
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    border-bottom-right-radius: 8px;
}
.xm-st-rank--1 { background: linear-gradient(135deg, #ff6b3d, #ff3d3d); }
.xm-st-rank--2 { background: linear-gradient(135deg, #ffb03d, #ff8c3d); }
.xm-st-rank--3 { background: linear-gradient(135deg, #58d7fc, #3d77ff); }
.xm-st-rank--n { background: #d8dee8; color: #666; font-weight: 600; }
.xm-st-game-row__logo {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 14px;
    object-fit: cover;
    background: #f3f4f6;
}
.xm-st-game-row--ranked .xm-st-game-row__logo { margin-left: 6px; }
.xm-st-game-row__info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.xm-st-game-row__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.xm-st-game-row__meta {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--xm-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.xm-st-game-row__welfare {
    margin: 2px 0 0;
    font-size: 12px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.xm-st-game-row__badge {
    flex-shrink: 0;
    min-width: 48px;
    padding: 0 8px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    background: var(--xm-badge-grad);
    border-radius: 999px;
}
.xm-st-load-more,
.xm-st-load-end {
    display: block;
    margin: 4px 10px 12px;
    padding: 12px;
    text-align: center;
    font-size: 13px;
    border-radius: 10px;
}
.xm-st-load-more {
    background: #fff;
    color: var(--xm-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.xm-st-load-end { color: var(--xm-muted); }

.xm-st-load-sentinel {
    height: 1px;
    margin: 0;
    padding: 0;
    pointer-events: none;
}
.xm-st-load-status {
    padding: 10px 12px 14px;
    text-align: center;
    font-size: 13px;
    color: var(--xm-muted);
}
.xm-st-load-status__loading {
    color: var(--xm-primary);
    font-weight: 600;
}
.xm-st-load-status [hidden] { display: none !important; }

.xm-st-game-list--inset { padding: 0; }

.xm-pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 12px; font-size: 13px; }

/* 页脚 */
.xm-wap-footer {
    max-width: var(--xm-page-max);
    margin: 0 auto 8px;
    padding: 0 12px;
    text-align: center;
}
.xm-wap-footer-links {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
    margin-bottom: 6px;
}
.xm-wap-footer-links a { font-size: 12px; color: var(--xm-muted); }
.xm-wap-footer-copy { margin: 0; font-size: 11px; color: #9ca3af; line-height: 1.5; }

/* 底部 Tab */
.xm-wap-tabbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--xm-page-max);
    bottom: 0;
    z-index: 100;
    display: flex;
    height: calc(var(--xm-tab-h) + var(--xm-safe-b));
    padding-bottom: var(--xm-safe-b);
    background: #fff;
    border-top: none;
    box-shadow: 0 -2px 10px rgba(191, 191, 191, 0.25);
}
.xm-wap-tab {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--xm-muted); font-size: 10px;
}
.xm-wap-tab.is-active { color: var(--xm-primary); font-weight: 600; }
.xm-wap-tab-icon { font-size: 18px; line-height: 1; }

/* 详情 / 文章 / 旧页兼容 */
.wap-detail, .wap-article-detail, .wap-page-detail, .wap-box-page, .wap-contact-page,
.xm-detail { padding: 0; }
.wap-block, .xm-detail-block { margin-bottom: 14px; }
.wap-block h2, .xm-detail-block h2 { margin: 0 0 8px; font-size: 15px; }
.wap-rich, .xm-rich { font-size: 14px; line-height: 1.65; word-break: break-word; }
.wap-rich img, .xm-rich img { border-radius: 8px; margin: 8px 0; max-width: 100%; }
.wap-btn-primary, .xm-btn {
    display: inline-block; margin-top: 12px; padding: 12px 24px;
    border-radius: 999px; background: var(--xm-primary); color: #fff !important; font-weight: 600;
}
.wap-detail-head { display: flex; gap: 12px; margin-bottom: 12px; }
.wap-detail-cover { width: 88px; height: 88px; border-radius: 14px; object-fit: cover; }
.wap-screenshots { display: flex; gap: 8px; overflow-x: auto; }
.wap-screenshots img { height: 160px; width: auto; border-radius: 8px; flex-shrink: 0; }
.wap-article-list { list-style: none; margin: 0; padding: 0; }
.wap-article-list li { border-bottom: 1px solid var(--xm-border); }
.wap-article-list a { display: block; padding: 10px 0; color: inherit; }
.wap-rank-list { list-style: none; margin: 0; padding: 0; }
.wap-rank-list li { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.wap-rank-num { width: 24px; text-align: center; font-weight: 700; color: var(--xm-primary); }

/* 游戏详情 */
.xm-detail-hero { padding: 14px; }
.xm-detail-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.xm-detail-cover {
    width: 88px; height: 88px; flex-shrink: 0;
    border-radius: 16px; object-fit: cover; background: #f3f4f6;
}
.xm-detail-intro { min-width: 0; flex: 1; }
.xm-detail-intro h1 { margin: 0 0 6px; font-size: 17px; line-height: 1.35; word-break: break-word; }
.xm-detail-meta { margin: 0 0 4px; font-size: 12px; color: var(--xm-muted); }
.xm-detail-section-title { margin: 0 0 10px; font-size: 15px; font-weight: 700; }

.xm-dl-btns { display: flex; flex-direction: column; gap: 10px; }
.xm-dl-btn {
    display: block; width: 100%; box-sizing: border-box;
    text-align: center; padding: 12px 16px; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600; color: #fff !important; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.xm-dl-btn:disabled { opacity: .7; }
.xm-dl-android { background: #52a825; }
.xm-dl-ios { background: #3b9bdb; }
.xm-dl-admin { background: #6b4fc4; }
.xm-dl-box { background: #e09518; }

.xm-video-wrap {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #000;
}
.xm-video-mp4 {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    max-height: 240px;
    object-fit: contain;
    vertical-align: top;
}
.xm-video-ratio {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
}
.xm-video-ratio iframe {
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    border: 0;
}
.xm-screenshots {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.xm-screenshot-thumb,
.xm-screenshots img {
    height: 160px;
    width: auto;
    border-radius: 8px;
    flex-shrink: 0;
}
.xm-screenshot-thumb img {
    height: 160px;
    width: auto;
    max-width: none;
    border-radius: 8px;
}

@media (min-width: 768px) {
    body.xm-wap-body,
    .xm-wap-main,
    .xm-wap-footer,
    .xm-wap-tabbar { max-width: var(--xm-page-max); }
    .xm-game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
