/* ================= 大鹅极简美术风格 ================= */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&family=ZCOOL+KuaiLe&display=swap');

* { box-sizing: border-box; }

body {
    margin: 0; padding: 0; display: flex; justify-content: center; align-items: center;
    height: 100vh; background-color: #DCD8C0; font-family: 'Nunito', sans-serif; overflow: hidden; user-select: none;
}

#game-container {
    position: relative; width: 500px; height: 800px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15); border-radius: 12px; overflow: hidden;
}

#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas { 
    display: block; 
    width: 100%; 
    height: 100%; 
    background-color: #F4F1EA; 
    cursor: none; 
}

/* 底部手指操纵区 - 默认隐藏 */
#touch-zone {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to top, rgba(225, 112, 85, 0.15), transparent);
    z-index: 5;
    touch-action: none;
}

/* UI 覆盖层 */
.ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(244, 241, 234, 0.9); backdrop-filter: blur(8px);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s; text-align: center;
}
.ui-layer.active { opacity: 1; pointer-events: auto; }

.ui-title { font-size: 42px; font-weight: 900; color: #2D3436; margin-bottom: 10px; }
.ui-subtitle { font-size: 18px; color: #636E72; margin-bottom: 25px; padding: 0 20px; line-height: 1.5; }
.ui-career { font-size: 24px; font-weight: bold; color: #E17055; margin-bottom: 20px; }

.btn {
    background-color: #E17055; color: white; border: none; padding: 12px 25px;
    font-size: 18px; font-weight: bold; font-family: 'Nunito', sans-serif;
    border-radius: 30px; cursor: pointer; transition: transform 0.1s, background 0.2s;
    margin: 10px; box-shadow: 0 4px 6px rgba(225, 112, 85, 0.3);
    text-decoration: none; display: inline-block; text-align: center;
}
.btn:hover { background-color: #D63031; transform: translateY(-2px); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn-secondary { background-color: #B2BEC3; box-shadow: 0 4px 6px rgba(0,0,0,0.1); color: #2D3436;}
.btn-secondary:hover { background-color: #636E72; color: white;}

/* 顶部信息栏 */
#hud {
    position: absolute; top: 15px; left: 20px; right: 20px;
    display: flex; justify-content: space-between; align-items: flex-start;
    font-size: 18px; font-weight: bold; color: #2D3436; pointer-events: none;
    z-index: 10;
}
.hud-left { display: flex; flex-direction: column; text-align: left; }
.hud-right { text-align: right; color: #E17055; display: flex; align-items: center; gap: 8px; }
#lives-text { font-size: 22px; margin-top: 5px; letter-spacing: 2px;}
#hud-tutorial-btn {
    background: rgba(255,255,255,0.85);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.1s, background 0.2s;
}
#hud-tutorial-btn:hover { background: #FFF; transform: scale(1.1); }

/* ====== 图鉴页面专属样式 ====== */
#tutorial-content {
    width: 85%; max-height: 60%; overflow-y: auto; text-align: left;
    background: rgba(255,255,255,0.8); border-radius: 12px; padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); margin-bottom: 20px;
}
/* 隐藏滚动条 */
#tutorial-content::-webkit-scrollbar { display: none; }
.tut-section { margin-bottom: 20px; }
.tut-title { font-weight: 900; color: #E17055; border-bottom: 2px solid #E17055; padding-bottom: 5px; margin-bottom: 10px; }
.tut-item { display: flex; align-items: center; margin-bottom: 15px; background: #FFF; padding: 10px; border-radius: 8px;}
.tut-icon { font-size: 30px; margin-right: 15px; min-width: 40px; text-align: center;}
.tut-text strong { color: #2D3436; display: block; font-size: 16px; margin-bottom: 2px;}
.tut-text p { margin: 0; font-size: 13px; color: #636E72; line-height: 1.4;}

/* 屏幕中央漂浮字 */
.floating-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 36px; font-weight: 900; color: #E74C3C; opacity: 0; pointer-events: none;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); text-shadow: 2px 2px 0px #FFF;
}
.floating-text.show { opacity: 1; transform: translate(-50%, -80%); }

/* ====== 移动端适配：保持比例，底部操纵区 ====== */
@media (max-width: 600px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        background-color: #F4F1EA;
        padding-top: 60px; /* 顶部留出空间给 HUD */
        padding-bottom: 80px; /* 底部留出操纵区 */
    }

    #game-wrapper {
        position: relative;
        width: 100%;
        max-width: 500px;
        /* 保持 500:800 = 5:8 的宽高比 */
        aspect-ratio: 5/8;
        max-height: calc(100vh - 140px); /* 减去顶部和底部预留 */
    }

    canvas {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* 显示底部操纵区 */
    #touch-zone {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 80px;
        background: linear-gradient(to top, rgba(225, 112, 85, 0.2), transparent 60%);
        z-index: 100;
        touch-action: none;
    }

    /* HUD 固定在顶部 */
    #hud {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        padding: 15px 20px;
        background: rgba(244, 241, 234, 0.95);
        z-index: 200;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .hud-left { 
        flex-direction: row; 
        align-items: center; 
        gap: 15px;
    }

    /* UI 层适配 */
    .ui-layer {
        position: fixed;
        inset: 0;
        z-index: 300;
        padding: 20px;
    }

    .ui-title { 
        font-size: 36px; 
    }
    
    .ui-subtitle { 
        font-size: 16px; 
    }

    #tutorial-content {
        max-height: 55vh;
    }
}

/* 小屏幕手机 */
@media (max-width: 400px) {
    #game-container {
        padding-top: 55px;
        padding-bottom: 70px;
    }

    #game-wrapper {
        aspect-ratio: 5/8;
        max-height: calc(100vh - 125px);
    }

    #hud {
        height: 55px;
        padding: 12px 15px;
        font-size: 16px;
    }

    #lives-text { 
        font-size: 20px; 
    }

    #touch-zone {
        height: 70px;
    }

    .ui-title { 
        font-size: 32px; 
    }
}

/* 结算海报 */
.poster-container {
    background: #FFF;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    max-width: 85%;
    text-align: center;
}
#poster-img {
    width: 320px;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}
.poster-hint {
    font-size: 14px;
    color: #636E72;
    margin: 10px 0 0;
}

/* ====== 榜单弹窗 ====== */
#ui-leaderboard .leaderboard-panel {
    width: 85%;
    max-width: 460px;
    max-height: 70vh;
    background: rgba(255,255,255,0.95);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    text-align: left;
}

.leaderboard-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.leaderboard-title {
    font-size: 22px;
    font-weight: 900;
    color: #E17055;
}

.leaderboard-subtitle {
    font-size: 13px;
    color: #636E72;
    margin-bottom: 12px;
    min-height: 20px;
}

.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.leaderboard-tab {
    flex: 1;
    padding: 8px 4px;
    font-size: 13px;
    font-weight: bold;
    font-family: 'Nunito', sans-serif;
    border: none;
    border-radius: 20px;
    background: #E8E4D9;
    color: #636E72;
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-tab.active {
    background: #E17055;
    color: #FFF;
}

#leaderboard-content {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    max-height: 45vh;
    background: #F4F1EA;
    border-radius: 10px;
    padding: 10px;
}

#leaderboard-content::-webkit-scrollbar { display: none; }

.leaderboard-row {
    display: grid;
    grid-template-columns: 48px 1fr 90px;
    gap: 8px;
    align-items: center;
    padding: 8px 6px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 14px;
}

.leaderboard-row:last-child { border-bottom: none; }

.lb-rank { font-weight: bold; color: #E17055; }
.lb-name { color: #2D3436; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { color: #636E72; text-align: right; font-size: 12px; }

.leaderboard-empty {
    text-align: center;
    color: #636E72;
    font-size: 14px;
    padding: 30px 10px;
}

.btn-small {
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 20px;
}

.btn-flat {
    background: transparent;
    color: #E17055;
    box-shadow: none;
    border: 1px solid rgba(225, 112, 85, 0.3);
}

.btn-flat:hover {
    background: rgba(225, 112, 85, 0.1);
    color: #D63031;
}

.hidden { display: none !important; }

/* 横屏提示 */
@media (max-width: 900px) and (orientation: landscape) {
    #game-container::before {
        content: '请竖屏游玩，体验更佳';
        position: fixed;
        inset: 0;
        background: rgba(244, 241, 234, 0.98);
        z-index: 1000;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 24px;
        font-weight: bold;
        color: #E17055;
    }
}
