* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f5f5f7;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header & Navigation --- */
.header {
    width: 100%; max-width: 1200px; margin: 0 auto;
    position: sticky; top: 0;
    background: rgba(255,255,255,0.95);
    padding: 15px 20px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #e1e1e1;
    z-index: 100;
    flex-shrink: 0;
}
body[data-screen-mode="desktop"] .header { display: none; }

.logo {
    font-weight: 900;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    line-height: 1;
}
.logo svg { height: 1em; width: auto; display: block; }

.nav-tabs { display: flex; align-items: center; }
.nav-tabs .tab { margin-left: 15px; cursor: pointer; color: #666; font-weight: 500; white-space: nowrap; }
.nav-tabs .tab.active { color: #ff2442; font-weight: 700; }

/* --- Main Container --- */
.main-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 40px;
    flex-grow: 1;
}

/* --- Mobile View Container (默认为移动端视图) --- */
.mobile-view-container {
    width: 100%;
    max-width: 450px;
    padding: 0 15px;
    /* 默认显示，由媒体查询控制 */
    display: block;
}

/* --- Phone Model (默认为隐藏) --- */
.phone-model {
    /* 默认隐藏，由媒体查询控制 */
    display: none;
    width: 380px;
    height: 720px;
    background: #111;
    border-radius: 40px;
    padding: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    position: relative;
    border: 4px solid #333;
    flex-shrink: 0;
}

.phone-header {
    background: #111;
    color: white;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
    padding: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}
.phone-header .logo {
    color: white;
    font-size: 18px;
}
.phone-logo-svg {
    width: 18px;
    height: 18px;
}

.phone-screen {
    background: #fff;
    width: 100%;
    height: calc(100% - 66px);
    border-radius: 0;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.phone-screen::-webkit-scrollbar { display: none; }

.phone-nav-sticky {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #e1e1e1;
    padding: 8px 0;
    display: flex;
    justify-content: center;
}

.phone-nav-bar .nav-tabs .tab {
    margin: 0 12px;
    font-size: 14px;
    padding: 4px 2px;
}

.phone-notch { display: none; }

.phone-bottom-bar {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

/* --- Waterfall & Cards --- */
.card { background: #fff; border-radius: 14px; overflow: hidden; margin-bottom: 15px; break-inside: avoid; box-shadow: 0 4px 12px rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.03); width: 100%; display: inline-block; }
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(0,0,0,0.12); transition: 0.2s; }
.card-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #e0e0e0; display: block; }
.card-content { padding: 12px; }
.app-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.app-icon { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; display: block; flex-shrink: 0; }
.app-title { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #111; }
.developer-name { font-size: 12px; color: #777; display: block; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-row { display: flex; justify-content: space-between; font-size: 11px; color: #888; margin-bottom: 10px; background: #f9f9f9; padding: 5px 8px; border-radius: 6px; }
.rating { color: #ff8f00; font-weight: 700; }
.app-link { display: block; width: 100%; text-align: center; background: #ff2442; color: white; text-decoration: none; padding: 8px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.app-link:hover { background: #e0002a; }

/* --- Waterfall Containers --- */
.waterfall-container { width: 100%; }
.mobile-view-container .waterfall-container { column-count: 1; column-gap: 15px; }
@media (min-width: 768px) { .mobile-view-container .waterfall-container { column-count: 2; } }
@media (min-width: 1024px) { .mobile-view-container .waterfall-container { column-count: 3; } }
.phone-content { column-count: 1 !important; padding: 10px; }

/* --- Loading Indicators & Sentinel --- */
.loading-indicator, .end-indicator {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: #888;
    break-inside: avoid;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f5f5f7;
}
#page-scroll-sentinel, #phone-scroll-sentinel { height: 1px; width: 100%; }
.loader { width: 16px; height: 16px; border: 2px solid #ddd; border-top-color: #ff2442; border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   媒体查询 - 核心修复
   ========================================================================== */

/* 桌面模式：屏幕宽度 > 1024px */
@media (min-width: 1025px) {
    .main-container {
        /* flex-direction: row; /* 默认值，保持水平 */
        gap: 40px;
    }
    .mobile-view-container {
        display: none; /* 隐藏移动端视图 */
    }
    .phone-model {
        display: block; /* 显示手机模型 */
    }
}

/* 移动模式：屏幕宽度 <= 1024px */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column; /* 垂直排列 */
        align-items: stretch; /* 拉伸子元素 */
        gap: 0;
        padding: 0;
    }
    .mobile-view-container {
        display: block; /* 显示移动端视图 */
        max-width: 100%;
    }
    .phone-model {
        display: none; /* 隐藏手机模型 */
    }
}

