/* 弓箭史诗 Web 游戏样式 - Glassmorphism 现代暗黑炫酷风格 */

:root {
    --bg-dark: #0a0e17;
    --panel-bg: rgba(18, 25, 41, 0.85);
    --border-color: rgba(64, 196, 255, 0.2);
    --primary-glow: #00e5ff;
    --accent-color: #ff9100;
    --hp-green: #00e676;
    --exp-blue: #29b6f6;
    --text-light: #f0f4f8;
    --text-gold: #ffd700;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-light);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1a233a 0%, #080b12 100%);
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

canvas#gameCanvas {
    background-color: #111827;
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.15);
    border-radius: 12px;
    touch-action: none;
}

/* UI 覆盖层 */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
}

/* 顶部 HUD */
.top-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
}

.bar-container {
    width: 130px;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
}

.hp-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00c853, var(--hp-green));
    box-shadow: 0 0 10px var(--hp-green);
    transition: width 0.2s ease-out;
}

.exp-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #0288d1, var(--exp-blue));
    box-shadow: 0 0 10px var(--exp-blue);
    transition: width 0.2s ease-out;
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* 暂停与控制按钮 */
.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 16px;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 6px;
}

.icon-btn:hover {
    background: rgba(0, 229, 255, 0.25);
    border-color: var(--primary-glow);
    transform: scale(1.08);
}

/* 摇杆控制器 (电竞炫彩透亮风格) */
#joystick-container {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 140px;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    opacity: 0.38;
    transition: opacity 0.25s ease, transform 0.15s ease-out;
}

#joystick-container.dragging {
    opacity: 0.88;
}

.joystick-base {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 70%);
    border: 1.5px solid rgba(0, 229, 255, 0.25);
    backdrop-filter: blur(3px);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#joystick-container.dragging .joystick-base {
    border-color: rgba(0, 229, 255, 0.65);
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.35), inset 0 0 10px rgba(0, 229, 255, 0.15);
}

.joystick-handle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.85) 0%, rgba(0, 131, 143, 0.6) 100%);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.4), inset 0 0 6px rgba(255, 255, 255, 0.5);
    position: absolute;
    will-change: transform;
}

#joystick-container.dragging .joystick-handle {
    background: radial-gradient(circle, rgba(0, 245, 255, 1) 0%, rgba(0, 160, 190, 0.85) 100%);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.8), inset 0 0 8px rgba(255, 255, 255, 0.8);
}

/* 弹窗 Modal 通用 */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 15, 0.88);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-title {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--text-gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin-bottom: 24px;
    text-align: center;
}

/* 已选技能徽章列表 */
.skill-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-glow);
}

/* 天赋树卡片与升级按钮 */
.talent-card {
    background: rgba(18, 25, 41, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.talent-card:hover {
    border-color: var(--primary-glow);
    background: rgba(0, 229, 255, 0.05);
}

.talent-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.talent-name {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-light);
}

.talent-desc {
    font-size: 12px;
    color: #a0aec0;
}

.talent-level {
    font-size: 12px;
    color: var(--primary-glow);
    font-weight: 700;
}

.talent-upgrade-btn {
    background: linear-gradient(135deg, #ffd700 0%, #ff9100 100%);
    color: #000;
    font-weight: 900;
    font-size: 13px;
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.talent-upgrade-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 6px 16px rgba(255, 215, 0, 0.5);
}

.talent-upgrade-btn:disabled {
    background: #4a5568;
    color: #a0aec0;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

/* 技能选择卡片列表 */
.skills-grid {
    display: flex;
    gap: 20px;
    max-width: 900px;
    padding: 10px;
}

.skill-card {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 24px 20px;
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.skill-card:hover {
    transform: translateY(-10px) scale(1.05);
    border-color: var(--primary-glow);
    box-shadow: 0 15px 35px rgba(0, 229, 255, 0.4);
}

.skill-icon {
    font-size: 48px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.4));
}

.skill-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-glow);
    margin-bottom: 10px;
}

.skill-desc {
    font-size: 14px;
    color: #a0aec0;
    line-height: 1.5;
}

/* 按钮风格 */
.btn {
    background: linear-gradient(135deg, #ff9100 0%, #ff3d00 100%);
    color: #fff;
    border: none;
    padding: 14px 36px;
    font-size: 18px;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 145, 0, 0.4);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 25px rgba(255, 145, 0, 0.6);
}

/* 游戏操作提示 */
.controls-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    white-space: nowrap;
}

/* ==========================================
   移动端与竖屏响应式 Media Queries 适配
   ========================================== */

@media (max-width: 650px) {
    #ui-layer {
        padding: 10px;
    }

    /* 顶部 HUD 在小屏重排为双行紧凑布局 */
    .top-hud {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 6px 12px;
        border-radius: 14px;
    }

    .hud-item {
        font-size: 13px;
    }

    /* 行 1: 血条 (左) 与 经验条 (右) */
    .hud-item:nth-child(1) {
        order: 1;
        flex: 1 1 45%;
    }
    .hud-item:nth-child(3) {
        order: 2;
        flex: 1 1 45%;
        justify-content: flex-end;
    }

    /* 行 2: 关卡波次 (左) 与 金币/按钮 (右) */
    .hud-item:nth-child(2) {
        order: 3;
        flex: 1 1 45%;
    }
    .hud-item:nth-child(4) {
        order: 4;
        flex: 1 1 45%;
        justify-content: flex-end;
    }

    .bar-container {
        width: 95px;
        height: 13px;
    }

    .bar-text {
        font-size: 8.5px;
        font-weight: 700;
        white-space: nowrap;
        line-height: 1;
    }

    .icon-btn {
        padding: 4px 8px;
        font-size: 13px;
        margin-left: 4px;
        border-radius: 8px;
    }

    /* 摇杆在手机竖屏向上提至舒适高度 */
    #joystick-container {
        bottom: 75px;
        width: 125px;
        height: 125px;
    }

    .joystick-base {
        width: 115px;
        height: 115px;
    }

    .joystick-handle {
        width: 46px;
        height: 46px;
    }

    .controls-hint {
        font-size: 11px;
        bottom: 12px;
        opacity: 0.7;
    }

    /* Modal 弹窗在小屏自适应 */
    .modal {
        padding: 14px 10px;
    }

    .modal-title {
        font-size: 22px;
        margin-bottom: 14px;
        letter-spacing: 1px;
    }

    /* 大厅强化天赋树 */
    #start-modal img {
        width: 70px !important;
        height: 70px !important;
        margin-bottom: 8px !important;
    }

    #start-modal > div {
        font-size: 15px !important;
        margin-bottom: 12px !important;
    }

    #talents-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .talent-card {
        padding: 8px 10px;
    }

    .talent-name {
        font-size: 13px;
    }

    .talent-desc {
        font-size: 11px;
    }

    .talent-upgrade-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .btn {
        padding: 10px 28px;
        font-size: 16px;
    }

    /* 技能升级选择 弹窗：由横向 3 列转为纵向优雅长条 */
    .skills-grid {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 320px;
        padding: 4px;
        max-height: 75vh;
        overflow-y: auto;
    }

    .skill-card {
        width: 100%;
        flex-direction: row;
        text-align: left;
        padding: 12px 16px;
        gap: 14px;
        align-items: center;
        border-radius: 14px;
    }

    .skill-card:hover {
        transform: scale(1.02);
    }

    .skill-icon {
        font-size: 34px;
        margin-bottom: 0;
    }

    .skill-name {
        font-size: 16px;
        margin-bottom: 2px;
    }

    .skill-desc {
        font-size: 12px;
        line-height: 1.3;
    }
}
