* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', '微软雅黑', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    height: 100dvh;
}

/* 移动端上下分栏高度变量（dvh 适配手机浏览器地址栏伸缩） */
:root {
    --canvas-h: 58vh;
    --panel-h: 42vh;
}

@supports (height: 1dvh) {
    :root {
        --canvas-h: 58dvh;
        --panel-h: 42dvh;
    }
}

.hidden { display: none !important; }

#game-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

#canvas-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 0.5s ease;
}

/* ==================== 顶部信息栏（更紧凑：分行布局） ==================== */
#top-bar {
    position: relative;
    flex-shrink: 0;
    min-height: 74px;
    background: rgba(0, 0, 0, 0.78);
    display: flex;
    flex-direction: column;
    padding: 4px 12px 6px;
    z-index: 10;
    border-bottom: 2px solid #4CAF50;
    gap: 2px;
}

/* 顶部栏第一行：关卡信息 + 右侧按钮 */
.top-bar-row1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 30px;
}

#stage-info {
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.stage-nav-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    font-size: 13px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.stage-nav-btn:hover:not(:disabled) { background: rgba(76, 175, 80, 0.5); transform: scale(1.1); }
.stage-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

#stage-progress-bar {
    position: relative;
    flex: 1;
    min-width: 48px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(76, 175, 80, 0.4);
}

#stage-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66bb6a);
    transition: width 0.3s;
    width: 0%;
    border-radius: 6px;
}

#stage-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #fff;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.auto-advance-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 3px 7px;
    font-size: 12px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s;
}

.auto-advance-btn.active {
    background: rgba(76, 175, 80, 0.5);
    border-color: #4CAF50;
    color: #fff;
}

.auto-advance-btn:hover { transform: scale(1.05); }

#top-bar-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 顶部栏第二行：和谐点单开一行居中 */
.top-bar-row2 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 24px;
}

#currency-display {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ffd700;
    font-size: 22px;
    font-weight: bold;
    justify-content: center;
    text-shadow: 0 0 3px rgba(255, 215, 0, 0.4);
}

.currency-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.currency-name { color: #ddd; font-size: 12px; font-weight: normal; }

/* 顶部栏功能按钮：图标变大，更紧凑 */
.top-bar-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    min-width: 34px;
    width: 34px;
    height: 32px;
    padding: 0;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    color: #fff;
    line-height: 1;
}

.top-bar-btn:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.08); }

/* ==================== 迷你音乐播放器 ==================== */
#music-player {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 380px;
    flex-shrink: 0;
    margin-left: 10px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(76, 175, 80, 0.4);
    border-radius: 10px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#music-player.playing {
    border-color: rgba(76, 175, 80, 0.8);
    box-shadow: inset 0 0 10px rgba(76, 175, 80, 0.15), 0 0 8px rgba(76, 175, 80, 0.25);
}

.mp-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}

.mp-btn:hover {
    background: rgba(76, 175, 80, 0.45);
    border-color: #4CAF50;
    transform: scale(1.08);
}

.mp-btn svg {
    display: block;
}

.mp-toggle {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    border-color: #66BB6A;
}

#music-player.playing .mp-toggle {
    background: linear-gradient(135deg, #ffb347, #ff6b35);
    border-color: #ffd700;
}

/* 歌名 + 时间信息区：固定宽度，不随曲名长短变化 */
.mp-info {
    flex: 1;
    min-width: 0;
    text-align: center;
    overflow: hidden;
}

.music-title {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    font-size: 12px;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.music-title.marquee {
    /* 让滚动元素宽度等于“歌名 ♪ 歌名 ♪”的实际内容宽度，
       这样 translateX(-50%) 正好移动一个完整歌名+分隔符的宽度，完整显示第二段 */
    width: max-content;
    max-width: none;
    animation: musicScroll 10s linear infinite;
}

@keyframes musicScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.music-time {
    color: #8BC34A;
    font-size: 10px;
    white-space: nowrap;
    margin-top: 1px;
}

/* 播放模式按钮：单曲循环 / 随机播放 */
.mp-mode-btn {
    flex-shrink: 0;
    width: 42px;
    height: 24px;
    font-size: 11px;
    color: #8BC34A;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 195, 74, 0.4);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}

.mp-mode-btn:hover {
    background: rgba(76, 175, 80, 0.25);
}

.mp-mode-btn.active-mode {
    color: #ffd700;
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.12);
}

/* 音量控制：喇叭图标 + 滑条 */
.mp-volume {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.mp-vol-btn {
    width: 26px;
    height: 26px;
}

.mp-volume-slider {
    width: 62px;
    height: 4px;
    accent-color: #4CAF50;
    cursor: pointer;
}

/* ==================== 普通怪物血条（更紧凑，血量数字嵌在血条里） ==================== */
#enemy-health-bar {
    position: relative;
    flex-shrink: 0;
    margin: 8px auto 0;
    width: 88%;
    max-width: 580px;
    background: rgba(0, 0, 0, 0.82);
    border-radius: 8px;
    padding: 6px 10px;
    z-index: 10;
    border: 2px solid #4CAF50;
}

/* 敌人名称：放大 */
#enemy-name {
    color: #fff;
    font-size: 22px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
}

#health-bar-container {
    position: relative;
    width: 100%;
    height: 26px;
    background: #222;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #666;
}

/* 白色缓冲层（先白再掉，延迟显示历史血量） */
.health-buffer-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: linear-gradient(90deg, #fff, #f0f0f0);
    height: 100%;
    transition: width 0.5s ease-out;
    width: 100%;
    z-index: 1;
}

#health-bar-fill {
    position: relative;
    height: 100%;
    background: linear-gradient(90deg, #ff4757, #ff6b81);
    transition: width 0.1s ease;
    width: 100%;
    z-index: 2;
}

/* 血量数字嵌在血条内 */
#health-text {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.95), 1px 1px 2px rgba(0, 0, 0, 0.9);
    z-index: 3;
    margin: 0;
}

/* ==================== Boss血条（紧凑版，血量嵌在血条内） ==================== */
#boss-health-bar {
    position: relative;
    flex-shrink: 0;
    margin: 8px auto 0;
    width: 94%;
    max-width: 780px;
    background: linear-gradient(135deg, rgba(20, 0, 0, 0.95), rgba(40, 0, 0, 0.95));
    border-radius: 10px;
    padding: 8px 16px 10px;
    z-index: 11;
    border: 3px solid #ff4757;
    box-shadow: 0 0 16px rgba(255, 71, 87, 0.5), inset 0 0 12px rgba(255, 0, 0, 0.2);
}

.boss-bar-deco {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 75%;
    background: linear-gradient(180deg, transparent, #ff4757, transparent);
    opacity: 0.4;
    pointer-events: none;
}

#boss-bar-deco-left { left: 4px; }
#boss-bar-deco-right { right: 4px; }

#boss-name {
    color: #ff6b81;
    font-size: 24px;
    text-align: center;
    margin-bottom: 4px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 71, 87, 0.9);
    letter-spacing: 2px;
}

#boss-health-container {
    position: relative;
    width: 100%;
    height: 30px;
    background: #1a0808;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid #ff4757;
}

#boss-health-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255, 255, 255, 0.04) 8px, rgba(255, 255, 255, 0.04) 16px);
    pointer-events: none;
    z-index: 1;
}

.boss-health-buffer-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: linear-gradient(90deg, #ffeaa7, #fdcb6e);
    height: 100%;
    transition: width 0.6s ease-out;
    width: 100%;
    z-index: 2;
}

#boss-health-fill {
    position: relative;
    height: 100%;
    background: linear-gradient(90deg, #c0392b, #e74c3c, #ff4757, #ff6b81);
    transition: width 0.1s ease;
    width: 100%;
    z-index: 3;
}

#boss-health-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent);
}

/* Boss血量数字嵌入血条内 */
#boss-health-text {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.95), 1px 1px 2px rgba(0, 0, 0, 0.9);
    z-index: 5;
    margin: 0;
}

#boss-countdown-label {
    color: #ffa502;
    font-size: 12px;
    text-align: center;
    margin-top: 6px;
    margin-bottom: 4px;
}

#boss-countdown-container {
    width: 100%;
    height: 16px;
    background: #1a1a08;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid #ffa502;
}

#boss-countdown-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffa502, #ff6348);
    transition: width 0.15s linear;
    width: 100%;
}

#boss-countdown-text {
    color: #ffa502;
    text-align: center;
    margin-top: 4px;
    font-size: 14px;
    font-weight: bold;
}

/* Boss战特效 */
.boss-active #enemy-health-bar { display: none !important; }

@keyframes bossPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 71, 87, 0.5), inset 0 0 15px rgba(255, 0, 0, 0.2); }
    50% { box-shadow: 0 0 35px rgba(255, 71, 87, 0.9), inset 0 0 20px rgba(255, 0, 0, 0.4); }
}

.boss-active #boss-health-bar {
    animation: bossPulse 1.5s infinite;
}

/* ==================== 战斗区域 ==================== */
#battle-area {
    position: relative;
    flex: 1;
    min-height: 0;
}

/* 敌人立绘（居中于血条正下方，top 由 JS 动态计算） */
#enemy-unit {
    position: absolute;
    left: 0;
    right: 0;
    top: 10px;
    margin: 0 auto;
    width: 300px;
    height: 380px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    cursor: pointer;
    will-change: transform;
    z-index: 3;
}

#enemy-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    transition: filter 0.1s;
}

#enemy-unit.shaking #enemy-image {
    animation: enemyHitFlash 0.3s ease-out;
}

@keyframes enemyHitFlash {
    0% { transform: scale(1); filter: brightness(1); }
    20% { transform: scale(0.88); filter: brightness(4) saturate(0); }  /* 闪白+收缩 */
    50% { transform: scale(1.12); filter: brightness(1.8); }            /* 放大回弹 */
    100% { transform: scale(1); filter: brightness(1); }                /* 恢复 */
}

/* 敌人死亡动画 */
#enemy-image.dying {
    animation: enemyDeath 0.3s ease-in forwards;
}

#enemy-image.dying.boss-death {
    animation: enemyDeath 1s ease-in forwards;
}

@keyframes enemyDeath {
    0% { filter: none; opacity: 1; transform: scale(1) rotate(0deg); }
    25% { filter: brightness(0.6) sepia(1) saturate(8) hue-rotate(-50deg); opacity: 1; transform: scale(1.05) rotate(0deg); }
    100% { filter: brightness(0.4) sepia(1) saturate(8) hue-rotate(-50deg); opacity: 0; transform: scale(0.1) rotate(720deg); }
}

#enemy-click-area {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

#enemy-click-area:active + #enemy-image {
    filter: brightness(1.3);
}

/* ==================== 主角立绘（绿坝娘 - 右下角）==================== */
#player-unit {
    position: absolute;
    right: 30px;
    bottom: 30px;
    width: 150px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

#player-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.6));
    animation: playerIdle 3s ease-in-out infinite;
}

@keyframes playerIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

#player-unit.attacking #player-image {
    animation: playerAttack 0.3s ease-out;
}

@keyframes playerAttack {
    0% { transform: scale(1) translateY(0); }
    30% { transform: scale(1.15) translateX(-20px) translateY(0); }
    100% { transform: scale(1) translateY(0); }
}

#player-attack-indicator {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    animation: indicatorBounce 0.5s ease-out;
}

#player-auto-indicator {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffd700, #ffa500);
    color: #000;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    animation: autoPulse 1.5s ease-in-out infinite;
}

@keyframes indicatorBounce {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes autoPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

/* ==================== 友军区域（底部交错排列） ==================== */
#friends-container {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    height: 180px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-end;
    justify-content: center;
    gap: 2px;
    overflow: visible;
    z-index: 4;
}

/* 偶数位友军下移一点，形成交错排列效果 */
.friend-unit:nth-child(even) {
    margin-bottom: 20px;
}

.friend-unit {
    width: 80px;
    height: 120px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.friend-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(76, 175, 80, 0.4));
    pointer-events: none;
    animation: friendIdle 3s ease-in-out infinite;
}

@keyframes friendIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.friend-unit.attacking .friend-image {
    animation: friendAttack 0.3s ease-out;
}

@keyframes friendAttack {
    0% { transform: translate(0, 0) scale(1); }
    20% { transform: translate(-10px, -5px) scale(1.08); filter: brightness(1.4); }
    50% { transform: translate(5px, 3px) scale(1.03); }
    100% { transform: translate(0, 0) scale(1); }
}

/* 朋友登场动画 */
.friend-unit.entering .friend-image {
    animation: friendEntrance 0.8s ease-out;
}

@keyframes friendEntrance {
    0% { transform: translateX(200px) scale(0.3); opacity: 0; filter: brightness(3) drop-shadow(0 0 20px #4CAF50); }
    50% { transform: translateX(0) scale(1.2); opacity: 1; filter: brightness(2) drop-shadow(0 0 15px #4CAF50); }
    100% { transform: translateX(0) scale(1); opacity: 1; filter: drop-shadow(0 0 6px rgba(76, 175, 80, 0.4)); }
}

.friend-level {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #ffd700;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 2;
    pointer-events: none;
}

/* 金光柱效果 */
.gold-pillar {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 100%;
    background: linear-gradient(0deg, rgba(255, 215, 0, 0.7) 0%, rgba(255, 215, 0, 0.3) 40%, transparent 100%);
    pointer-events: none;
    z-index: 3;
    animation: goldPillarFade 1.2s ease-out forwards;
}

@keyframes goldPillarFade {
    0% { opacity: 0; transform: translateX(-50%) scaleY(0); }
    20% { opacity: 1; transform: translateX(-50%) scaleY(1); }
    100% { opacity: 0; transform: translateX(-50%) scaleY(1); }
}

/* ==================== 单位升级立绘特效 ==================== */
/* 升级光环：从单位脚下升起扩散的金色光环 */
.level-up-ring {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid #ffd700;
    box-shadow: 0 0 20px #ffd700, inset 0 0 10px rgba(255, 215, 0, 0.5);
    transform: translate(-50%, 50%) scale(0);
    pointer-events: none;
    z-index: 6;
    animation: levelUpRing 1.2s ease-out forwards;
}

@keyframes levelUpRing {
    0% { transform: translate(-50%, 50%) scale(0); opacity: 1; border-width: 4px; }
    40% { transform: translate(-50%, 50%) scale(3.5); opacity: 0.9; border-width: 3px; }
    100% { transform: translate(-50%, 50%) scale(6); opacity: 0; border-width: 1px; }
}

/* 升级星芒：单位头顶爆发金色星芒 */
.level-up-burst {
    position: absolute;
    top: 0;
    left: 50%;
    width: 80px;
    height: 80px;
    transform: translate(-50%, -30%);
    pointer-events: none;
    z-index: 7;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.9) 0%, rgba(255, 215, 0, 0.4) 30%, transparent 70%);
    border-radius: 50%;
    animation: levelUpBurst 0.9s ease-out forwards;
}

@keyframes levelUpBurst {
    0% { transform: translate(-50%, -30%) scale(0); opacity: 1; }
    30% { transform: translate(-50%, -30%) scale(1.4); opacity: 1; }
    100% { transform: translate(-50%, -30%) scale(2); opacity: 0; }
}

/* LV UP 飘字：从单位头顶向上飘升 */
.level-up-text {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -100%);
    color: #ffd700;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.9), 0 0 12px rgba(255, 215, 0, 0.6), 1px 1px 2px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 8;
    white-space: nowrap;
    animation: levelUpText 1.4s ease-out forwards;
}

@keyframes levelUpText {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -100%) scale(1.3); opacity: 1; }
    40% { transform: translate(-50%, -120%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -220%) scale(0.9); opacity: 0; }
}

/* 单位升级时立绘缩放冲击（提升优先级覆盖 friendIdle/playerIdle 动画） */
.level-up-pulse {
    animation: levelUpPulse 0.6s ease-out !important;
    z-index: 10;
    position: relative;
}

@keyframes levelUpPulse {
    0% { filter: brightness(1) drop-shadow(0 0 6px rgba(76, 175, 80, 0.4)); }
    30% { filter: brightness(2.2) drop-shadow(0 0 18px #ffd700); }
    100% { filter: brightness(1) drop-shadow(0 0 6px rgba(76, 175, 80, 0.4)); }
}

/* ==================== 右侧面板 ==================== */
#side-panel {
    width: 320px;
    background: rgba(0, 0, 0, 0.8);
    border-left: 3px solid #4CAF50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    transition: width 0.25s ease;
    flex-shrink: 0;
}

#cards-scroll {
    padding: 8px;
}

/* 面板折叠按钮 */
.panel-toggle-btn {
    position: absolute;
    top: 50%;
    right: 320px;   /* 默认贴在面板左外侧（与面板宽度同步） */
    transform: translateY(-50%);
    width: 22px;
    height: 50px;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    border: 2px solid #4CAF50;
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: right 0.25s ease, background 0.2s;
    padding: 0;
}

.panel-toggle-btn:hover {
    background: linear-gradient(135deg, #66BB6A, #388E3C);
}

/* 折叠状态：面板宽度收缩，按钮贴在最右侧 */
#side-panel.collapsed {
    width: 0;
    border-left-width: 0;
}

#side-panel.collapsed #cards-scroll {
    display: none;
}

#side-panel.collapsed ~ .panel-toggle-btn,
.panel-toggle-btn.collapsed {
    right: 0;
}

/* ==================== 角色卡片 ==================== */
.char-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 6px;
    padding: 5px 6px;
    margin-bottom: 4px;
    display: flex;
    gap: 6px;
    transition: all 0.15s;
}

.char-card:hover { background: rgba(255, 255, 255, 0.12); }

.char-card.locked {
    opacity: 0.7;
    filter: grayscale(0.6);
}

.char-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #4CAF50;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.9);
}

.char-card.locked .char-card-avatar {
    filter: grayscale(1);
    border-color: #555;
}

.char-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.char-card-row1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    font-size: 11px;
}

.char-card-name { font-weight: bold; }
.char-card-level { color: #ffd700; }
.char-card-dps { color: #74b9ff; font-size: 10px; }

.char-card-row2 {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

/* 技能图标三态（加大，突出显示） */
.skill-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    border: 2px solid #444;
    background: #1a1a1a;
}

.skill-icon.locked {
    filter: grayscale(1) brightness(0.45);
    background: #1a1a1a;
    border-color: #333;
    cursor: default;
}

/* 可购买：金框 + 金光，提示可学 */
.skill-icon.available {
    background: #2a2407;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    animation: skillAvailable 1.5s ease-in-out infinite;
}

@keyframes skillAvailable {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.7); }
    50% { box-shadow: 0 0 16px rgba(255, 215, 0, 1); }
}

/* 已购买：绿底绿框，表示已生效 */
.skill-icon.active {
    background: #0e3a1d;
    border-color: #4CAF50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.skill-icon.cooldown {
    background: rgba(60, 60, 60, 0.9);
    border-color: #666;
    filter: brightness(0.5);
}

.skill-icon.cooldown::after {
    content: attr(data-cd);
    position: absolute;
    font-size: 9px;
    color: #fff;
    font-weight: bold;
}

.char-card-row3 {
    display: flex;
    gap: 3px;
}

.upgrade-btn-small {
    flex: 1;
    padding: 2px 2px 1px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    transition: all 0.15s;
    text-align: center;
    line-height: 1.35;
    /* 钱不够时的灰色样式（默认灰态） */
    background: #3a3a3a !important;
    color: #999 !important;
    opacity: 0.65;
    cursor: not-allowed;
    position: relative;
}

/* 够了才亮起（加 .affordable class） */
.upgrade-btn-small.affordable {
    opacity: 1;
    cursor: pointer;
}

.upgrade-btn-small.affordable.lvl1 {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
    color: #fff !important;
    box-shadow: 0 0 4px rgba(118, 75, 162, 0.5);
}

.upgrade-btn-small.affordable.lvl10 {
    background: linear-gradient(135deg, #f093fb, #f5576c) !important;
    color: #fff !important;
    box-shadow: 0 0 4px rgba(245, 87, 108, 0.5);
}

.upgrade-btn-small.affordable.max {
    background: linear-gradient(135deg, #ffd700, #ffa500) !important;
    color: #000 !important;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
}

/* MAX 按钮上面显示的升级级数（+N），与 MAX 同行突出显示 */
.upgrade-btn-small .max-suffix {
    font-size: 13px;
    color: #ffd700;
    text-shadow: 0 0 6px rgba(255, 160, 0, 0.8);
    margin-left: 2px;
}

/* MAX 按钮下面显示累计所需和谐点的小字 */
.upgrade-btn-small .max-cost {
    display: block;
    font-size: 9px;
    opacity: 0.85;
    margin-top: 1px;
}

.upgrade-btn-small.affordable:hover:not(:disabled) { transform: scale(1.04); }
.upgrade-btn-small:disabled { filter: grayscale(0.5) brightness(0.6); cursor: not-allowed !important; transform: none !important; }

/* 锁定朋友的召唤按钮 — 占满整个右侧 */
.summon-btn-inline {
    width: 100%;
    flex: 1;
    padding: 12px 8px;
    border: 2px solid #333;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    background: #0a0a0a;
    color: #8a8f98;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.summon-btn-inline.affordable {
    border-color: #00e676;
    background: #0a0a0a;
    color: #eafff3;
    text-shadow: 0 0 8px rgba(0, 230, 118, 0.7);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6), 0 0 10px rgba(0, 230, 118, 0.6);
    animation: summonGlow 1.5s ease-in-out infinite;
}

@keyframes summonGlow {
    0%, 100% { border-color: #00e676; box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6), 0 0 10px rgba(0, 230, 118, 0.6); }
    50% { border-color: #3bff9e; box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6), 0 0 18px rgba(0, 230, 118, 1), 0 0 26px rgba(0, 230, 118, 0.4); }
}

.summon-btn-inline.affordable:hover {
    transform: scale(1.03);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 230, 118, 0.9);
}

/* ==================== 技能浮窗 ==================== */
#skill-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #4CAF50;
    border-radius: 6px;
    padding: 8px 12px;
    z-index: 200;
    color: #fff;
    font-size: 12px;
    max-width: 220px;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#skill-tooltip .tt-name { color: #4CAF50; font-weight: bold; margin-bottom: 4px; }
#skill-tooltip .tt-desc { color: #ccc; }
#skill-tooltip .tt-cost { color: #ffd700; margin-top: 4px; }
#skill-tooltip .tt-req { margin-top: 4px; }
#skill-tooltip .tt-owned { color: #4CAF50; font-weight: bold; }
#skill-tooltip .tt-buyable { color: #ffd700; font-weight: bold; }
#skill-tooltip .tt-nowallet { color: #ff8a65; }
#skill-tooltip .tt-locked { color: #999; }

/* ==================== 底部横幅 ==================== */
/* 置于画布中上方垂直居中（在顶部信息栏/新闻条之下），不占用顶部 UI；
   半透明 + pointer-events 穿透，短暂提示不会遮挡可点击区域 */
#banner-notification {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.82);
    border: 2px solid #4CAF50;
    border-radius: 10px;
    padding: 8px 20px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    z-index: 40;
    white-space: nowrap;
    pointer-events: none;
    max-width: 86%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: bannerSlide 0.4s ease-out;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

@keyframes bannerSlide {
    0% { transform: translate(-50%, -24px); opacity: 0; }
    100% { transform: translate(-50%, -50%); opacity: 1; }
}

#banner-notification.gold { border-color: #ffd700; box-shadow: 0 0 15px rgba(255, 215, 0, 0.4); }

/* ==================== 弹窗 ==================== */
.overlay-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#modal-content, .overlay-content {
    background: linear-gradient(135deg, #2d3436 0%, #000000 100%);
    border-radius: 15px;
    padding: 25px;
    max-width: 90%;
    width: 420px;
    max-height: 85%;
    overflow-y: auto;
    border: 3px solid #4CAF50;
}

.overlay-content { width: 460px; }

#modal-title, .overlay-content h2 { color: #4CAF50; text-align: center; margin-bottom: 15px; }
#modal-body { color: #fff; margin-bottom: 15px; }
#modal-buttons, .overlay-buttons { display: flex; gap: 10px; justify-content: center; }

.modal-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
}

.modal-btn.primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
.modal-btn.secondary { background: #555; color: #fff; }
.modal-btn:hover { transform: scale(1.05); }
.modal-btn.danger { background: linear-gradient(135deg, #e74c3c, #c0392b); color: #fff; }

/* ==================== 离线收益弹窗 ==================== */
#offline-earnings-modal .overlay-content {
    width: 340px;
    text-align: center;
    border-color: #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

#offline-earnings-body {
    padding: 16px 0;
    color: #fff;
    line-height: 1.6;
}

#offline-earnings-modal .overlay-buttons {
    margin-top: 16px;
}

/* ==================== 统计页 ==================== */
.stats-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #333;
    color: #fff;
    font-size: 14px;
}

.stats-row .stats-label { color: #aaa; }
.stats-row .stats-value { color: #ffd700; font-weight: bold; }

.stats-section-title {
    color: #4CAF50;
    font-size: 14px;
    margin: 12px 0 6px;
    font-weight: bold;
}

/* ==================== 配置页 ==================== */
.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #333;
    color: #fff;
    font-size: 14px;
}

.config-row .config-label { color: #aaa; }

/* ==================== 飘字 ==================== */
#floating-texts {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.floating-text {
    position: absolute;
    color: #ffd700;
    font-size: 22px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    animation: floatUp 1.2s ease-out forwards;
    pointer-events: none;
}

.floating-text.crit { color: #ff4757; font-size: 30px; text-shadow: 0 0 10px rgba(255, 71, 87, 0.8); }
.floating-text.player { color: #4CAF50; font-size: 20px; }
.floating-text.gold { color: #ffd700; font-size: 26px; }

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    20% { transform: translateY(-15px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-60px) scale(0.9); }
}

/* ==================== 点击特效 ==================== */
#click-effects {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 45;
    overflow: hidden;
}

.click-effect {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px solid #ff6b6b;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: clickRing 0.4s ease-out forwards;
    pointer-events: none;
}

@keyframes clickRing {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(2); }
}

/* ==================== 金币系统（盾牌图标）==================== */
#gold-coins-layer {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 55;
    overflow: hidden;
}

.gold-coin {
    position: absolute;
    width: 32px;
    height: 32px;
    background-image: url('Resources/UI/绿坝logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    transition: none;
    will-change: transform;
}

.gold-coin.flying { pointer-events: none; }
.gold-coin.collected { pointer-events: none; z-index: 60; }
.gold-coin.shine { animation: coinShine 1.5s ease-in-out infinite; }

/* 挨打掉落的小金币，比死亡爆出的略小 */
.gold-coin.hit-coin { width: 24px; height: 24px; opacity: 0.9; }

@keyframes coinShine {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(76, 175, 80, 0.6)); }
    50% { filter: drop-shadow(0 0 10px rgba(76, 175, 80, 1)) drop-shadow(0 0 16px rgba(76, 175, 80, 0.4)); }
}

/* ==================== 边缘游走奖励物（和谐宝箱） ==================== */
/* 类似 Cookie Clicker 的黄金饼干：沿画面边缘游走，点击数次后爆金币 */
#travel-reward {
    position: fixed;
    width: 76px;
    height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    z-index: 58;                 /* 高于金币层(55)，保证可点中 */
    pointer-events: auto;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
    transition: transform 0.12s ease, opacity 0.28s ease;
}

.tr-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
}

.tr-visual::before {           /* 金色渐变底盘（钱袋/宝箱底座） */
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 22px;
    background: radial-gradient(circle at 50% 32%, #fff3b5 0%, #ffd35c 45%, #f0a818 80%, #c87b0a 100%);
    border: 3px solid #ffdf8f;
    box-shadow: inset 0 -6px 12px rgba(160, 90, 0, 0.45), 0 0 0 3px rgba(255, 215, 0, 0.28);
    animation: trFloatPulse 1.4s ease-in-out infinite;
}

.tr-visual > span {             /* 宝箱 emoji */
    position: relative;
    font-size: 44px;
    line-height: 1;
    z-index: 1;
    animation: trBob 1s ease-in-out infinite;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35));
}

.tr-hint {
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(30, 20, 0, 0.75);
    color: #ffe9a8;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
}

/* 血量条（代表需要点击几次） */
.tr-hpbar {
    width: 64px;
    height: 7px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 215, 0, 0.5);
    overflow: hidden;
    position: relative;
}
.tr-hpfill {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffd35c, #ffe68f);
    border-radius: 5px;
    transition: width 0.12s ease;
}
.tr-clicks {
    font-size: 10px;
    color: #fff3c2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    line-height: 1;
}

/* 点击时的「破裂」回弹 */
#travel-reward.breaking .tr-visual {
    animation: trBreak 0.22s ease;
}
#travel-reward.breaking .tr-visual::before {
    filter: brightness(1.6);
}

/* 击破瞬间放大消失 */
#travel-reward.pop {
    pointer-events: none;
    animation: trPop 0.32s ease-out forwards;
}

/* 超时溜走 */
#travel-reward.leave {
    pointer-events: none;
    opacity: 0;
    transform: translateX(30px) rotate(15deg) scale(0.7);
}

/* 奖励物专用点击环形特效 */
.tr-click-ring {
    border-color: #ffdf8f !important;
}

/* 奖励物爆出的小金币（稍大、更有存在感） */
.gold-coin.reward-coin {
    width: 36px;
    height: 36px;
}

@keyframes trFloatPulse {
    0%, 100% { box-shadow: inset 0 -6px 12px rgba(160, 90, 0, 0.45), 0 0 0 3px rgba(255, 215, 0, 0.28); }
    50%      { box-shadow: inset 0 -6px 12px rgba(160, 90, 0, 0.45), 0 0 10px 4px rgba(255, 215, 0, 0.55); }
}
@keyframes trBob {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-6px) scale(1.06); }
}
@keyframes trBreak {
    0%   { transform: scale(1) rotate(0deg); }
    35%  { transform: scale(1.25) rotate(-6deg); }
    70%  { transform: scale(0.9) rotate(4deg); }
    100% { transform: scale(1) rotate(0deg); }
}
@keyframes trPop {
    0%   { opacity: 1; transform: scale(1); }
    50%  { opacity: 1; transform: scale(1.35); filter: brightness(2); }
    100% { opacity: 0; transform: scale(0.3); }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #4CAF50; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #45a049; }

/* ==================== 主角技能按钮栏（左上角浮动，避开顶部和新闻条） ==================== */
#player-skills-bar {
    position: absolute;
    top: 8px;           /* 位于战斗区内顶部，天然避开血条 */
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 15;
    pointer-events: auto;
}

.pskill-btn {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2d3436 0%, #1a1a2e 100%);
    border: 2px solid #4CAF50;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.pskill-btn:hover {
    transform: translateY(-2px);
    border-color: #66BB6A;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

.pskill-btn.on-cd {
    filter: grayscale(0.6);
    cursor: not-allowed;
}

.pskill-btn.active {
    border-color: #7CFC00;
    box-shadow: 0 0 12px rgba(124, 252, 0, 0.7);
    animation: pskillActivePulse 1s ease-in-out infinite;
}

@keyframes pskillActivePulse {
    0%, 100% { box-shadow: 0 0 8px rgba(124, 252, 0, 0.5); }
    50% { box-shadow: 0 0 16px rgba(124, 252, 0, 0.9); }
}

.pskill-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    color: #fff;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

/* 扇形 CD 遮罩（由 JS 设置 conic-gradient） */
.pskill-cd-overlay {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    z-index: 2;
    pointer-events: none;
}

/* CD 倒计时文字 */
.pskill-cd-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 1);
    z-index: 3;
    display: none;
    pointer-events: none;
}

/* tooltip（技能按钮为纵向，tooltip 在按钮右侧显示） */
.pskill-tooltip {
    position: absolute;
    top: 50%;
    left: calc(100% + 10px);
    transform: translateY(-50%);
    width: 200px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #4CAF50;
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.pskill-btn:hover .pskill-tooltip {
    opacity: 1;
}

.pskill-name {
    color: #4CAF50;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 4px;
}

.pskill-desc {
    color: #ddd;
    margin-bottom: 4px;
}

.pskill-meta {
    color: #ffd700;
    font-size: 11px;
}

/* ==================== 友军/主角 buff 特效 ==================== */

/* buff 剩余时长标签容器 */
.buff-indicators {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 2px;
    z-index: 8;
    pointer-events: none;
    white-space: nowrap;
}

.buff-timer {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-shadow: 0 0 2px rgba(0, 0, 0, 1);
}

/* 各类 buff 的视觉特效（光晕，叠加在角色头像上） */
#player-unit.buff-speed, .friend-unit.buff-speed {
    filter: drop-shadow(0 0 8px rgba(124, 252, 0, 0.9));
}

#player-unit.buff-atk, .friend-unit.buff-atk {
    filter: drop-shadow(0 0 8px rgba(255, 80, 80, 0.9));
}

#player-unit.buff-gold, .friend-unit.buff-gold {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.9));
}

#player-unit.buff-crit, .friend-unit.buff-crit {
    filter: drop-shadow(0 0 8px rgba(186, 85, 211, 0.9));
}

#player-unit.buff-player, .friend-unit.buff-player {
    filter: drop-shadow(0 0 10px rgba(255, 140, 0, 0.95));
}

#player-unit.buff-team, .friend-unit.buff-team {
    filter: drop-shadow(0 0 9px rgba(64, 156, 255, 0.95));
}

/* 多个 buff 同时存在时，后加的 class 的 filter 会覆盖前者。
   为避免丢失视觉，使用 box-shadow 在角色外围再画一圈光环 */
#player-unit[class*="buff-"]::after, .friend-unit[class*="buff-"]::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 8px;
    border: 2px dashed rgba(124, 252, 0, 0.6);
    animation: buffRingRotate 3s linear infinite;
    pointer-events: none;
    z-index: 7;
}

@keyframes buffRingRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 和谐点小飘字（每次挨打掉落） */
.floating-text.harmony-gain {
    color: #ffd700;
    font-size: 14px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
    animation: harmonyFloat 1s ease-out forwards;
}

@keyframes harmonyFloat {
    0% { opacity: 0; transform: translateY(0); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-30px); }
}

/* ==================== 敌人对话框 ==================== */
.speech-bubble {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.92);
    color: #333;
    padding: 8px 16px;
    border-radius: 18px;
    font-size: 14px;
    white-space: nowrap;
    max-width: 280px;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.speech-bubble.bubble-show {
    opacity: 1;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-style: solid;
    border-width: 10px 8px 0 8px;
    border-color: rgba(255, 255, 255, 0.92) transparent transparent transparent;
}

/* ==================== 顶部新闻滚动条 ==================== */
#news-ticker {
    position: relative;
    flex-shrink: 0;
    height: 22px;
    background: rgba(0, 0, 0, 0.78);
    overflow: hidden;
    z-index: 9;
    border-bottom: 1px solid rgba(76, 175, 80, 0.3);
    display: flex;
    align-items: center;
}

#news-ticker-text {
    color: #4CAF50;
    font-size: 11px;
    white-space: nowrap;
    will-change: transform;
    /* 旧版：整条替换 + 单次滚动动画，已改为 JS 追加式持续滚动 */
    /* padding-left: 100%; animation: newsScroll 40s linear infinite; */
}

#news-ticker-text .news-msg {
    display: inline;
}

#news-ticker-text .news-gap {
    display: inline;
    white-space: pre;
}

#news-ticker-label {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(76, 175, 80, 0.9);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 0 8px;
    display: flex;
    align-items: center;
    z-index: 2;
    border-radius: 0 8px 8px 0;
}

/* ==================== 移动端适配（统一覆盖，避免与基础规则叠加 !important） ==================== */
@media (max-width: 768px) {
    #game-container { flex-direction: column; }
    #canvas-wrapper { height: var(--canvas-h); flex: 0 0 auto; }
    #side-panel { width: 100%; height: var(--panel-h); flex: 0 0 auto; border-left: none; border-top: 3px solid #4CAF50; }
    #side-panel.collapsed { height: 0; border-top-width: 0; }
    /* 面板收起时画布铺满释放出的空间，不再留下空白 */
    #game-container.panel-collapsed #canvas-wrapper { height: auto; flex: 1 1 auto; min-height: var(--canvas-h); }

    /* 移动端按钮改为贴在画布与面板分界处中间 */
    .panel-toggle-btn {
        right: auto;
        left: 50%;
        top: var(--canvas-h);
        transform: translate(-50%, -50%);
        width: 52px;
        height: 22px;
        font-size: 12px;
        border-radius: 0 0 8px 8px;
        border: 2px solid #4CAF50;
        border-top: none;
    }
    .panel-toggle-btn.collapsed {
        transform: translate(-50%, -100%);
    }
    /* 面板收起且画布铺满时，收起按钮跟随到画面底部 */
    #game-container.panel-collapsed .panel-toggle-btn,
    #game-container.panel-collapsed .panel-toggle-btn.collapsed {
        top: auto;
        bottom: 4px;
        transform: translateX(-50%);
        border-radius: 8px 8px 0 0;
        border: 2px solid #4CAF50;
        border-bottom: none;
    }
    #side-panel.collapsed ~ .panel-toggle-btn { right: auto; }

    /* 顶部栏：紧凑但不溢出 */
    #top-bar { min-height: 62px; padding: 4px 8px; }
    .top-bar-row1 { min-height: 30px; flex-wrap: wrap; gap: 4px 6px; }
    .top-bar-row2 { min-height: 22px; }
    #stage-info { font-size: 12px; gap: 3px; flex: 1 1 auto; min-width: 0; }
    #top-bar-right { flex-shrink: 0; }
    .stage-nav-btn { width: 22px; height: 22px; font-size: 11px; border-radius: 3px; }
    #stage-progress-bar { flex: 1; min-width: 30px; height: 16px; }
    #stage-progress-text { font-size: 9px; }
    .auto-advance-btn { font-size: 10px; padding: 2px 5px; }
    #currency-display { font-size: 18px; gap: 4px; }
    .currency-icon { width: 20px; height: 20px; }
    .currency-name { font-size: 12px; }
    .top-bar-btn { width: 30px; height: 28px; min-width: 30px; font-size: 16px; }
    /* 窄屏：音乐播放器单独一行放在最上部，关卡信息在其之下 */
    #music-player { order: -1; flex-basis: 100%; width: 100%; margin-left: 0; gap: 8px; padding: 5px 10px; }
    .mp-btn { width: 32px; height: 32px; }
    .music-title { font-size: 13px; }
    .music-time { font-size: 11px; }
    .mp-mode-btn { width: 48px; height: 26px; font-size: 12px; }

    #news-ticker { height: 20px; }
    #news-ticker-text { font-size: 11px; }
    #news-ticker-label { font-size: 10px; padding: 0 7px; }

    /* 血条：文档流内自动排列，不再与战斗区重叠 */
    #enemy-health-bar { width: 96%; padding: 4px 8px; margin: 6px auto 0; }
    #enemy-name { font-size: 16px; margin-bottom: 2px; }
    #health-bar-container { height: 18px; }
    #health-text { font-size: 11px; }

    #boss-health-bar { width: 96%; padding: 6px 10px 8px; margin: 6px auto 0; }
    #boss-name { font-size: 16px; margin-bottom: 3px; }
    #boss-health-container { height: 22px; }
    #boss-health-text { font-size: 12px; }
    #boss-countdown-label { font-size: 10px; margin-top: 4px; margin-bottom: 2px; }
    #boss-countdown-container { height: 12px; }
    #boss-countdown-text { font-size: 12px; margin-top: 2px; }

    /* 技能按钮栏：在战斗区内 */
    #player-skills-bar { top: 6px; left: 6px; gap: 4px; }
    .pskill-btn { width: 40px; height: 40px; border-radius: 9px; }
    .pskill-icon { font-size: 18px; }
    .pskill-cd-text { font-size: 12px; }
    .pskill-tooltip { width: 150px; font-size: 11px; left: calc(100% + 6px); }

    /* 单位尺寸：JS 会按战斗区实际高度再缩放 */
    #enemy-unit { width: 140px; height: 200px; }
    #player-unit { width: 70px; height: 100px; right: 8px; bottom: 10px; }
    #player-attack-indicator { font-size: 13px; padding: 3px 10px; }
    #player-auto-indicator { font-size: 11px; padding: 2px 8px; }

    /* 友军单行排列；overflow 裁剪由容器隐藏，不再横向滚动，避免出现滚动条闪烁 */
    #friends-container { left: 4px; right: 72px; bottom: 4px; height: 62px; gap: 1px; flex-wrap: nowrap; overflow: hidden; justify-content: flex-start; align-items: flex-end; }
    .friend-unit { width: 38px; height: 60px; }
    .friend-unit:nth-child(even) { margin-bottom: 0; }
    /* 手机端缩小朋友攻击/登场位移，避免被容器裁剪 + 减少抖动 */
    .friend-unit .friend-image { animation: none; }
    .friend-unit.attacking .friend-image { animation: friendAttackMobile 0.22s ease-out; }
    @keyframes friendAttackMobile {
        0% { transform: translate(0, 0) scale(1); }
        30% { transform: translate(-4px, -2px) scale(1.05); }
        100% { transform: translate(0, 0) scale(1); }
    }
    .friend-level { font-size: 9px; padding: 1px 5px; }
    .buff-timer { font-size: 9px; padding: 1px 3px; }

    /* 右侧面板卡片 */
    .char-card { padding: 5px; }
    .char-card-avatar { width: 38px; height: 38px; }
    .char-card-row1 { font-size: 13px; }
    .char-card-dps { font-size: 11px; }
    .skill-icon { width: 20px; height: 20px; font-size: 11px; }
    .upgrade-btn-small { font-size: 11px; padding: 3px 2px 1px; }
    .upgrade-btn-small .max-cost { font-size: 9px; margin-top: 0; }
    .summon-btn-inline { font-size: 14px; padding: 10px 6px; }

    /* 弹窗与文字 */
    #banner-notification { font-size: 13px; padding: 7px 12px; top: 38%; }
    #modal-content, .overlay-content { width: 94%; max-width: 94%; padding: 18px; }
    .modal-btn { font-size: 14px; padding: 10px 14px; }
    .stats-row { font-size: 13px; padding: 8px 0; }
    .stats-section-title { font-size: 14px; }
    .config-row { font-size: 13px; padding: 10px 0; }
    .floating-text { font-size: 18px; }
    .floating-text.crit { font-size: 22px; }
    .floating-text.player { font-size: 16px; }
    .floating-text.gold { font-size: 20px; }
    .floating-text.harmony-gain { font-size: 13px; }
    .speech-bubble { font-size: 12px; padding: 6px 12px; max-width: 200px; }
    .gold-coin { width: 20px; height: 20px; }
    .gold-coin.hit-coin { width: 18px; height: 18px; }
}

/* ==================== 手机横屏（短高度）：恢复左右分栏，避免上下分栏过矮导致单位掉出画面 ==================== */
@media (max-width: 768px) and (orientation: landscape) {
    #game-container { flex-direction: row; }
    #canvas-wrapper { height: auto; flex: 1; }
    #side-panel { width: 300px; flex: 0 0 300px; height: auto; border-left: 3px solid #4CAF50; border-top: none; }
    #side-panel.collapsed { width: 0; flex-basis: 0; }

    .panel-toggle-btn {
        left: auto;
        right: 300px;
        top: 50%;
        transform: translateY(-50%);
        width: 22px;
        height: 50px;
        border: 2px solid #4CAF50;
        border-right: none;
        border-radius: 8px 0 0 8px;
    }
    .panel-toggle-btn.collapsed {
        right: 0;
        transform: translateY(-50%);
    }
    /* 覆盖竖屏块中更高优先级的 #side-panel.collapsed ~ 规则 */
    #side-panel.collapsed ~ .panel-toggle-btn {
        right: 0;
        left: auto;
    }
}

