/* --- 全局设定 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #222; /* 电脑端深色背景 */
    display: flex;
    justify-content: center;
    min-height: 100vh; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow-y: auto; 
    padding: 20px 0; 
}

/* --- 手机视口容器 --- */
#mobile-viewport {
    width: 100%;
    max-width: 430px; 
    height: auto; 
    min-height: 100vh; 
    position: relative;
    background-color: #fff;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

@media screen and (max-width: 500px) {
    body { padding: 0; background-color: #fff; }
    #mobile-viewport {
        max-width: 100%;
        box-shadow: none;
        min-height: 100vh;
        border-radius: 0;
    }
}

/* --- 1. 顶部 Logo --- */
.top-logo {
    position: absolute;
    top: 60px; 
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    
    /* 关键：层级最高，浮在开屏图(999)上面 */
    z-index: 1001; 
    
    pointer-events: none;
}
.top-logo img { 
    /* 关键：限制大小，防止Logo巨大 */
    height: 45px; 
    width: auto; 
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2)); 
}

/* --- 2. 第一屏：换装主区域 --- */
.app-container {
    width: 100%;
    height: 750px; 
    position: relative; 
    display: flex;
    flex-direction: row;
    
    /* 游戏背景 */
    background-image: url('https://station.cornernorth.com/popbing/images/bg.jpg'); 
    background-size: cover;
    background-position: center top;
}

/* 左侧模特区域 */
.preview-area {
    flex: 0.8; 
    position: relative;
    height: 100%;
    margin-right: -10px; 
}

.layer {
    position: absolute;
    width: 125%; 
    height: auto;
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    pointer-events: none;
    /* 游戏内容的层级较低 */
    z-index: 100; 
}
/* 衣服层级微调 */
.base { z-index: 101; }
.pants { z-index: 102; }
.shoes { z-index: 103; }
.top { z-index: 104; }
.glasses { z-index: 105; }

/* 右侧控制面板 */
.control-panel {
    flex: 0.7; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 10px;
    z-index: 110;
    gap: 0px; 
}

.control-row {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    height: 90px; margin-bottom: 0;
}
.arrow-btn { width: 20px; height: 40px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.arrow-btn:active { transform: scale(0.8); }
.arrow-btn img { width: 100%; height: 100%; object-fit: contain; }

.icon-display { width: auto; height: 100%; display: flex; align-items: center; justify-content: center; }
.icon-display img { max-width: 100%; max-height: 90%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }

/* 保存按钮 */
.btn-container {
    position: absolute;
    bottom: 90px; 
    left: 50%; 
    transform: translateX(-50%);
    width: 220px; 
    height: auto;
    z-index: 120; 
    cursor: pointer;
}
.btn-container:active { transform: translateX(-50%) scale(0.95); }
.img-btn { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); }

/* --- 3. 底部信息区 --- */
.bottom-info-area {
    position: relative; 
    width: 100%;
    height: auto; 
    min-height: 350px; 
    background-image: url('https://station.cornernorth.com/popbing/images/bottom_bg.png'); 
    background-size: cover;
    background-position: center top;
    
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 15px; padding-top: 45px; padding-bottom: 40px; 
    
    /* 关键：层级最高，浮在开屏图(999)上面 */
    z-index: 1001; 
    
    border-top-left-radius: 30px; border-top-right-radius: 30px; margin-top: -60px; 
}
.link-btn { display: block; width: calc(100% - 40px); max-width: 400px; height: auto; transition: transform 0.1s; }
.link-btn:active { transform: scale(0.95); }
.link-btn img { width: 100%; height: auto; max-height: 85px; object-fit: contain; }

.bottom-logo { margin-top: 20px; margin-bottom: 30px; width: 100%; display: flex; justify-content: center; }
.bottom-logo img { height: 70px; width: auto; opacity: 0.9; }

/* 动画 */
@keyframes nudgeLeft { 0%,40%,100% {transform: translateX(0);} 20% {transform: translateX(-3px);} }
@keyframes nudgeRight { 0%,40%,100% {transform: translateX(0);} 20% {transform: translateX(3px);} }
.control-row .arrow-btn:first-child img { animation: nudgeLeft 2s infinite ease-in-out; }
.control-row .arrow-btn:last-child img { animation: nudgeRight 2s infinite ease-in-out; }
.arrow-btn:active img { animation: none; }

/* --- 弹窗与长按保存支持 --- */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 99999; justify-content: center; align-items: center; }
.modal-content { background: white; padding: 20px; border-radius: 12px; text-align: center; width: 80%; max-width: 350px; }

#final-image { 
    width: 100%; 
    border-radius: 5px; 
    margin: 10px 0; 
    /* 允许iOS长按呼出菜单的关键属性 */
    pointer-events: auto; 
    -webkit-touch-callout: default; 
    -webkit-user-select: none;
    user-select: none;
}

/* 长按提示文字 */
.save-tip {
    display: none; /* 电脑端隐藏 */
}
@media screen and (max-width: 500px) {
    .save-tip {
        display: block;
        font-size: 14px;
        color: #f82b49;
        margin-bottom: 12px;
    }
}

.save-btn { display: inline-block; padding: 8px 25px; background: #333; color: white; text-decoration: none; border-radius: 20px; font-size: 14px; }
.close-btn { position: absolute; top: 5px; right: 10px; font-size: 24px; color: #666; cursor:pointer;}


/* ============================ */
/* --- 开屏引导页 (盖子) --- */
/* ============================ */
#welcome-screen {
    position: absolute;
    /* 1. 限制在 app-container 内部 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; 
    
    /* 2. 背景图作为不透明底板，遮挡游戏内容 */
    background-image: url('https://station.cornernorth.com/popbing/images/bg.jpg'); 
    background-size: cover;
    background-position: center top; 
    
    /* 3. 层级：Logo(1001) > Welcome(999) > Game(100) */
    z-index: 999; 
    
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

#welcome-screen img {
    /* 4. 铺满全屏，无侧边距 */
    width: 100%;
    height: 100%;
    object-fit: cover; /* 铺满且裁切边缘，不变形 */
    display: block;
}

.hidden-screen {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ============================ */
/* --- 新增：加载进度页样式 --- */
/* ============================ */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff; /* 纯白背景 */
    z-index: 999999; /* 必须是最高的，比弹窗还高 */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-box {
    width: 80%;
    text-align: center;
}

.loading-logo {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
    color: #333;
    letter-spacing: 2px;
}

/* 进度条槽 */
.progress-bar-bg {
    width: 100%;
    height: 10px;
    background-color: #eee;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

/* 进度条填充 (动态变化宽度) */
#progress-bar-fill {
    width: 0%; /* 初始为 0 */
    height: 100%;
    background-color: #333; /* 黑色进度条，简约风 */
    transition: width 0.2s; /* 增加一点丝滑过渡 */
}

#progress-text {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.loading-hint {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}