/* ============================================================
 *  战斗页面 v4 —— 铁血战场·神兵交锋
 *  设计理念：刀光剑影·血火交融·战意滔天
 * ============================================================ */

/* ===== 页面基础布局 ===== */
#page-battle.active {
    background:
        /* 战雾红光 */
        radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--vermillion) 18%, transparent) 0%, transparent 45%),
        radial-gradient(ellipse at 15% 75%, color-mix(in srgb, var(--gold-foil) 8%, transparent) 0%, transparent 35%),
        radial-gradient(ellipse at 85% 65%, color-mix(in srgb, var(--vermillion) 12%, transparent) 0%, transparent 40%),
        /* 底部火光 */
        radial-gradient(ellipse at 50% 100%, color-mix(in srgb, var(--vermillion) 10%, transparent) 0%, transparent 50%),
        /* 基底 */
        linear-gradient(180deg, var(--ink) 0%, color-mix(in srgb, var(--ink) 90%, #0a0604) 100%);
    height: 100vh !important;
    min-height: 0 !important;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
    padding-bottom: 0 !important;
    position: relative;
    display: flex !important;
}

/* 战场氛围叠加层 */
#page-battle.active::before {
    content: '';
    position: absolute;
    /* 兜底：旧内核浏览器（inset 需 87+）四向定位 */
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    /* 兜底：旧内核浏览器（不支持 color-mix）剑气底色 */
    background:
        linear-gradient(45deg, transparent 40%, var(--gold-foil-dim) 50%, transparent 60%),
        linear-gradient(-45deg, transparent 40%, var(--ink-border) 50%, transparent 60%);
    /* 增强：现代浏览器精细剑气纵横 */
    background:
        /* 剑气纵横 */
        linear-gradient(45deg, transparent 40%, color-mix(in srgb, var(--gold-foil) 3%, transparent) 50%, transparent 60%),
        linear-gradient(-45deg, transparent 40%, color-mix(in srgb, var(--vermillion) 3%, transparent) 50%, transparent 60%);
    pointer-events: none;
    z-index: 0;
    animation: battlefield-shimmer 8s ease-in-out infinite;
}
@keyframes battlefield-shimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

#page-battle.active .battle-header { flex: 0 0 auto; position: relative; z-index: 3; }
#page-battle.active .battle-arena {
    flex: 1 1 auto;
    overflow: hidden;
    position: relative;
    z-index: 2;
    padding-bottom: 10px;
    padding-top: 10px;
}
#page-battle.active .battle-toolbar {
    position: fixed;
    bottom: 18px;
    left: auto;
    right: 18px;
    z-index: 10;
    flex: none;
}
#page-battle.active .battle-log-panel {
    position: fixed;
    bottom: 18px;
    left: 18px;
    right: auto;
    width: min(560px, calc(100vw - 360px));
    height: calc(5 * 1.7em + 48px);
    z-index: 12;
    flex: none;
}

/* ===== 战斗标题栏 ===== */
.battle-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--vermillion) 25%, var(--ink)) 0%,
            color-mix(in srgb, var(--vermillion) 15%, var(--ink)) 40%,
            var(--ink) 100%);
    border-bottom: 2px solid var(--vermillion);
    box-shadow:
        0 4px 20px var(--vermillion-glow),
        0 2px 8px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 color-mix(in srgb, var(--vermillion-light) 30%, transparent);
    position: relative;
}
.battle-header::before,
.battle-header::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold-foil));
    transform: translateY(-50%);
    box-shadow: 0 0 8px var(--gold-foil-glow);
}
.battle-header::before { left: 16px; }
.battle-header::after {
    right: 16px;
    background: linear-gradient(90deg, var(--gold-foil), transparent);
}

.battle-header .battle-title {
    font-family: var(--font-title);
    color: var(--gold-foil-light);
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.3em;
    text-shadow:
        0 0 12px var(--gold-foil-glow),
        0 0 24px var(--gold-foil-glow),
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 1px 0 color-mix(in srgb, var(--gold-foil) 50%, #fff);
    -webkit-text-stroke: 0.5px color-mix(in srgb, var(--gold-foil) 30%, transparent);
}

/* ===== 战斗工具栏 ===== */
.battle-toolbar {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    background:
        linear-gradient(180deg, transparent, color-mix(in srgb, var(--ink) 90%, #000));
    border-top: 1px solid var(--ink-border);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}
.battle-toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--vermillion), transparent);
    opacity: 0.5;
}

.battle-tool-btn {
    border: none;
    padding: 10px 28px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-title);
    letter-spacing: 0.15em;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.battle-tool-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}
.battle-tool-btn:active::before {
    left: 100%;
}

.battle-tool-btn.retreat {
    background: linear-gradient(135deg, var(--vermillion) 0%, var(--vermillion-light) 50%, var(--vermillion) 100%);
    color: #fff;
    box-shadow:
        0 4px 15px var(--vermillion-glow),
        0 2px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 color-mix(in srgb, #fff 30%, transparent),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    text-shadow:
        0 1px 2px rgba(0,0,0,0.5),
        0 0 8px var(--vermillion-glow);
    border: 1px solid color-mix(in srgb, var(--vermillion-light) 50%, transparent);
}
.battle-tool-btn.retreat:active {
    transform: scale(0.96);
    box-shadow:
        0 2px 8px var(--vermillion-glow),
        0 1px 3px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.battle-tool-btn.quick {
    background: linear-gradient(135deg, var(--jade) 0%, color-mix(in srgb, var(--jade) 70%, #fff) 50%, var(--jade) 100%);
    color: #fff;
    box-shadow:
        0 4px 15px var(--jade-glow),
        0 2px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 color-mix(in srgb, #fff 30%, transparent),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    text-shadow:
        0 1px 2px rgba(0,0,0,0.5),
        0 0 8px var(--jade-glow);
    border: 1px solid color-mix(in srgb, var(--jade) 50%, #fff);
}
.battle-tool-btn.quick:active {
    transform: scale(0.96);
    box-shadow:
        0 2px 8px var(--jade-glow),
        0 1px 3px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===== 对战区域 ===== */
.battle-arena {
    flex: 1 1 auto;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    padding: 16px 12px;
    position: relative;
    min-height: 0;
    gap: 10px;
    overflow: hidden;
}

/* VS 大字 */
.battle-vs {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 900;
    font-family: var(--font-title);
    color: var(--vermillion);
    text-shadow:
        0 0 20px var(--vermillion-glow),
        0 0 40px var(--vermillion-glow),
        0 0 60px var(--vermillion),
        0 4px 8px rgba(0, 0, 0, 0.6),
        0 2px 0 color-mix(in srgb, var(--vermillion-light) 50%, #fff);
    z-index: 1;
    pointer-events: none;
    opacity: 0.7;
    letter-spacing: 0.15em;
    animation: vs-pulse 2s ease-in-out infinite;
    -webkit-text-stroke: 1px color-mix(in srgb, var(--vermillion-light) 30%, transparent);
}
@keyframes vs-pulse {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
    50% { opacity: 0.85; transform: translate(-50%, -50%) scale(1.1); filter: brightness(1.2); }
}

/* 队伍容器 */
.battle-team {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 46%;
    z-index: 2;
    min-height: 0;
    justify-content: center;
}
.battle-team-ally { align-items: flex-start; }
.battle-team-enemy { align-items: flex-end; }

/* 战斗单位卡片 */
.battle-unit {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--ink-elevated) 85%, var(--gold-foil)) 0%,
            var(--ink-elevated) 40%,
            color-mix(in srgb, var(--ink-surface) 95%, var(--gold-foil)) 100%);
    border-radius: 10px;
    padding: 7px 10px 6px 10px;
    width: 100%;
    max-width: 170px;
    border: 1px solid color-mix(in srgb, var(--gold-foil) 25%, transparent);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 66px;
    box-sizing: border-box;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 color-mix(in srgb, var(--gold-foil) 15%, transparent),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* 卡片顶部金边 */
.battle-unit::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--gold-foil) 20%,
        var(--gold-foil-light) 50%,
        var(--gold-foil) 80%,
        transparent 100%);
    box-shadow: 0 0 8px var(--gold-foil-glow);
    opacity: 0.6;
}

/* 卡片侧边光效 */
.battle-unit::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--gold-foil) 30%,
        var(--gold-foil-light) 50%,
        var(--gold-foil) 70%,
        transparent 100%);
    opacity: 0.4;
    box-shadow: 0 0 6px var(--gold-foil-glow);
}
.battle-team-ally .battle-unit::after { left: 0; }
.battle-team-enemy .battle-unit::after {
    right: 0;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--vermillion) 30%,
        var(--vermillion-light) 50%,
        var(--vermillion) 70%,
        transparent 100%);
    box-shadow: 0 0 6px var(--vermillion-glow);
}

/* 敌方卡片特殊样式 */
.battle-unit.enemy {
    border-color: color-mix(in srgb, var(--vermillion) 30%, transparent);
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--ink-elevated) 85%, var(--vermillion)) 0%,
            var(--ink-elevated) 40%,
            color-mix(in srgb, var(--ink-surface) 95%, var(--vermillion)) 100%);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 color-mix(in srgb, var(--vermillion) 20%, transparent),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}
.battle-unit.enemy::before {
    background: linear-gradient(90deg,
        transparent 0%,
        var(--vermillion) 20%,
        var(--vermillion-light) 50%,
        var(--vermillion) 80%,
        transparent 100%);
    box-shadow: 0 0 8px var(--vermillion-glow);
}

/* 单位名字 */
.battle-unit .unit-name {
    color: var(--gold-foil-light);
    font-size: 12px;
    font-weight: 800;
    font-family: var(--font-title);
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.7),
        0 0 6px var(--gold-foil-glow);
    position: relative;
    z-index: 2;
    line-height: 1.3;
}
.battle-unit.enemy .unit-name {
    color: color-mix(in srgb, var(--vermillion-light) 90%, #fff);
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.7),
        0 0 6px var(--vermillion-glow);
}

/* 血条 */
.battle-unit .unit-hp-bar {
    width: 100%;
    height: 9px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--ink) 80%, #000) 0%,
            var(--ink-border) 50%,
            color-mix(in srgb, var(--ink) 80%, #000) 100%);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 3px;
    position: relative;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3),
        0 1px 0 color-mix(in srgb, var(--gold-foil) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold-foil) 15%, transparent);
}

.battle-unit .unit-hp-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease-out;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, #fff 30%, var(--jade)) 0%,
            var(--jade) 30%,
            color-mix(in srgb, var(--jade) 80%, #2a5a3a) 70%,
            #2a5a3a 100%);
    box-shadow:
        0 0 8px var(--jade-glow),
        inset 0 1px 0 color-mix(in srgb, #fff 40%, transparent);
    position: relative;
}
.battle-unit .unit-hp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.25), transparent);
    border-radius: 4px 4px 0 0;
}

.battle-unit .unit-hp-fill.enemy-fill {
    background:
        linear-gradient(180deg,
            color-mix(in srgb, #fff 30%, var(--vermillion-light)) 0%,
            var(--vermillion-light) 25%,
            var(--vermillion) 55%,
            #6a1515 100%);
    box-shadow:
        0 0 8px var(--vermillion-glow),
        inset 0 1px 0 color-mix(in srgb, #fff 40%, transparent);
}

.battle-unit .unit-hp-text {
    color: #fff;
    font-size: 10px;
    text-align: right;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.9),
        0 0 2px rgba(0, 0, 0, 1),
        1px 1px 1px rgba(0, 0, 0, 0.8),
        -1px -1px 1px rgba(0, 0, 0, 0.8);
    z-index: 2;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* 真元条 */
.battle-unit .unit-sp-bar {
    width: 100%;
    height: 5px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--ink) 80%, #000) 0%,
            var(--ink-border) 50%,
            color-mix(in srgb, var(--ink) 80%, #000) 100%);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 2px;
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.5),
        0 1px 0 color-mix(in srgb, var(--gold-foil) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold-foil) 10%, transparent);
}
.battle-unit .unit-sp-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease-out;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, #fff 35%, #6ab8e8) 0%,
            #4a90c0 40%,
            #2a5080 100%);
    box-shadow:
        0 0 6px rgba(80, 150, 220, 0.5),
        inset 0 1px 0 color-mix(in srgb, #fff 40%, transparent);
    position: relative;
}
.battle-unit .unit-sp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent);
    border-radius: 3px 3px 0 0;
}

.battle-unit .unit-sp-text {
    color: #8ab8d8;
    font-size: 9px;
    text-align: right;
    font-family: var(--font-num);
    font-weight: 600;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.7),
        0 0 4px rgba(80, 150, 220, 0.3);
    line-height: 1.2;
}

/* 空槽位占位 */
.battle-unit.battle-empty {
    background:
        repeating-linear-gradient(
            45deg,
            color-mix(in srgb, var(--ink-border) 30%, transparent) 0px,
            color-mix(in srgb, var(--ink-border) 30%, transparent) 4px,
            transparent 4px,
            transparent 8px
        );
    border: 1px dashed color-mix(in srgb, var(--gold-foil) 15%, transparent);
    min-height: 66px;
    width: 100%;
    box-shadow: none;
    opacity: 0.5;
}
.battle-unit.battle-empty::before,
.battle-unit.battle-empty::after { display: none; }

/* ===== 攻击动画 ===== */
.battle-unit.attacking-left {
    animation: attack-left var(--battle-action-duration, 1ms) cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.battle-unit.attacking-right {
    animation: attack-right var(--battle-action-duration, 1ms) cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes attack-left {
    0%   { transform: translateX(0) scale(1); filter: brightness(1); }
    30%  { transform: translateX(50px) scale(1.15); filter: brightness(1.4) saturate(1.2); }
    45%  { transform: translateX(50px) scale(1.15); filter: brightness(1.4) saturate(1.2); }
    100% { transform: translateX(0) scale(1); filter: brightness(1); }
}
@keyframes attack-right {
    0%   { transform: translateX(0) scale(1); filter: brightness(1); }
    30%  { transform: translateX(-50px) scale(1.15); filter: brightness(1.4) saturate(1.2); }
    45%  { transform: translateX(-50px) scale(1.15); filter: brightness(1.4) saturate(1.2); }
    100% { transform: translateX(0) scale(1); filter: brightness(1); }
}

/* 受击抖动 - 更强烈 */
.battle-unit.hit-shake {
    animation: hit-shake var(--battle-hit-duration, 1ms) cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes hit-shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-8px) rotate(-1deg); filter: brightness(2) saturate(2) hue-rotate(-10deg); }
    30% { transform: translateX(6px) rotate(1deg); filter: brightness(1.5); }
    45% { transform: translateX(-4px); }
    60% { transform: translateX(3px); }
    80% { transform: translateX(-1px); }
}

/* 受击红闪 */
.battle-unit.hit-flash {
    animation: hit-flash var(--battle-hit-duration, 1ms) ease-out;
}
@keyframes hit-flash {
    0% { filter: brightness(1); }
    20% { filter: brightness(2.5) sepia(1) hue-rotate(-50deg) saturate(3); }
    100% { filter: brightness(1); }
}

/* ===== 攻击方式提示 ===== */
.battle-attack-label {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
    font-size: 18px;
    font-weight: 800;
    font-family: var(--font-title);
    color: var(--gold-foil-light);
    text-shadow:
        0 0 12px var(--gold-foil-glow),
        0 0 24px var(--gold-foil-glow),
        0 0 36px var(--gold-foil-glow),
        2px 2px 4px #000,
        -2px -2px 4px #000,
        0 2px 0 color-mix(in srgb, var(--gold-foil) 50%, #fff);
    width: auto;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: center;
    transform: translateX(-50%);
    animation: attack-label-fade 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    letter-spacing: 0.04em;
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.3);
}
.battle-attack-label.skill {
    color: #ffe4e0;
    text-shadow:
        0 0 12px var(--vermillion-glow),
        0 0 24px var(--vermillion-glow),
        0 0 48px var(--vermillion),
        2px 2px 4px #000,
        -2px -2px 4px #000,
        0 2px 0 var(--vermillion-light);
    font-size: 22px;
    font-weight: 900;
}
.battle-attack-label.crit {
    color: #fff;
    text-shadow:
        0 0 16px var(--vermillion-glow),
        0 0 32px var(--vermillion-glow),
        0 0 48px var(--vermillion),
        0 0 64px var(--vermillion-light),
        3px 3px 6px #000,
        -3px -3px 6px #000;
    font-size: clamp(20px, 6vw, 26px);
    font-weight: 900;
    -webkit-text-stroke: 1px var(--vermillion);
}
.battle-attack-label.miss {
    color: var(--paper-secondary);
    text-shadow:
        0 0 8px rgba(200, 184, 152, 0.5),
        1px 1px 2px #000;
    font-size: 16px;
}
.battle-attack-label.evade {
    color: #a0e8f0;
    text-shadow:
        0 0 12px rgba(94, 179, 196, 0.9),
        0 0 24px rgba(94, 179, 196, 0.5),
        2px 2px 4px #000,
        -2px -2px 4px #000;
    font-size: 18px;
    font-weight: 700;
}
.battle-attack-label.counter {
    color: var(--gold-foil-light);
    text-shadow:
        0 0 16px var(--gold-foil-glow),
        0 0 32px var(--gold-foil-glow),
        0 0 48px var(--gold-foil),
        2px 2px 4px #000,
        -2px -2px 4px #000;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.06em;
}
@keyframes attack-label-fade {
    0%   { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.5); }
    15%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.3); }
    30%  { opacity: 1; transform: translateX(-50%) translateY(-10px) scale(1.1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-45px) scale(0.8); }
}

/* ===== 伤害飘字 ===== */
.battle-damage-float {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
    font-size: 22px;
    font-weight: 900;
    font-family: var(--font-title);
    color: #fff;
    text-shadow:
        0 0 10px var(--vermillion-glow),
        0 0 20px var(--vermillion),
        0 0 30px var(--vermillion-light),
        3px 3px 6px #000,
        -3px -3px 6px #000,
        0 0 2px #000;
    width: auto;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    padding: 0 6px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: center;
    transform: translateX(-50%);
    animation: dmg-float-up 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    letter-spacing: 0.02em;
    -webkit-text-stroke: 1px var(--vermillion);
}
.battle-damage-float.crit {
    font-size: 32px;
    color: #fff;
    animation: dmg-float-up-crit 1.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    text-shadow:
        0 0 16px var(--vermillion-glow),
        0 0 32px var(--vermillion),
        0 0 48px var(--vermillion-light),
        0 0 64px #fff,
        4px 4px 8px #000,
        -4px -4px 8px #000;
    font-weight: 900;
    -webkit-text-stroke: 2px var(--vermillion);
}
.battle-damage-float.skill {
    font-size: 24px;
    color: #fff0d0;
    animation: dmg-float-up-skill 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    text-shadow:
        0 0 12px var(--gold-foil-glow),
        0 0 24px var(--vermillion-glow),
        0 0 36px var(--gold-foil),
        3px 3px 6px #000,
        -3px -3px 6px #000;
    text-align: center;
    line-height: 1.3;
    -webkit-text-stroke: 1px var(--gold-foil);
}
.battle-damage-float.miss {
    font-size: 18px;
    color: var(--paper-secondary);
    animation: dmg-float-up 1.2s ease-out forwards;
    text-shadow:
        0 0 6px rgba(200, 184, 152, 0.5),
        2px 2px 3px #000;
    -webkit-text-stroke: 0;
}
/* 治疗飘字：绿色加血反馈 */
.battle-damage-float.heal {
    font-size: 22px;
    color: #fff;
    animation: dmg-float-up-heal 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    text-shadow:
        0 0 10px var(--jade-glow),
        0 0 20px var(--jade),
        0 0 30px color-mix(in srgb, var(--jade) 60%, #fff),
        3px 3px 6px #000,
        -3px -3px 6px #000;
    -webkit-text-stroke: 1px var(--jade);
}
@keyframes dmg-float-up-heal {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    35%  { opacity: 1; transform: translateX(-50%) translateY(-25px) scale(1.5); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.85); }
}
@keyframes dmg-float-up-skill {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    35%  { opacity: 1; transform: translateX(-50%) translateY(-28px) scale(1.55); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-65px) scale(0.85); }
}
@keyframes dmg-float-up {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    50%  { opacity: 1; transform: translateX(-50%) translateY(-40px) scale(1.1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-75px) scale(0.75); }
}
@keyframes dmg-float-up-crit {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(0.6); }
    12%  { opacity: 1; transform: translateX(-50%) translateY(-8px) scale(1.8); }
    25%  { opacity: 1; transform: translateX(-50%) translateY(-15px) scale(1.4); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-80px) scale(0.7); }
}

/* 死亡消失 */
.battle-unit.unit-dead {
    animation: unit-dead-out var(--battle-death-duration, 1ms) cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}
@keyframes unit-dead-out {
    0% { opacity: 1; transform: scale(1); }
    25% { opacity: 0.9; transform: scale(1.08); filter: brightness(2) saturate(0.3) contrast(1.2); }
    50% { opacity: 0.6; transform: scale(0.95); filter: brightness(1.5) grayscale(0.7); }
    100% { opacity: 0; transform: scale(0.3) translateY(20px); visibility: hidden; pointer-events: none; filter: grayscale(1) brightness(0.5); }
}

/* 击杀闪烁 */
.battle-unit.unit-dead-flash {
    animation: unit-dead-pulse var(--battle-death-duration, 1ms) ease-out;
}
@keyframes unit-dead-pulse {
    0% { filter: brightness(1); }
    30% { filter: brightness(3.5) saturate(2); background: var(--vermillion-glow); box-shadow: 0 0 30px var(--vermillion-glow), 0 0 60px var(--vermillion); }
    60% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* ===== 战斗日志 ===== */
.battle-log-panel {
    overflow-y: auto;
    padding: 34px 14px 10px;
    background:
        linear-gradient(180deg,
            transparent 0%,
            color-mix(in srgb, var(--ink) 85%, #000) 30%,
            var(--ink) 100%);
    font-size: 12px;
    color: var(--paper-secondary);
    line-height: 1.7;
    height: calc(5 * 1.7em + 48px);
    flex-shrink: 0;
    border-top: 1px solid var(--ink-border);
    font-family: var(--font-body);
    position: relative;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid color-mix(in srgb, var(--gold-foil) 24%, transparent);
    border-radius: 10px;
    cursor: pointer;
    transition: height 0.22s ease, width 0.22s ease, background 0.22s ease;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.battle-log-panel.expanded {
    width: min(720px, calc(100vw - 36px));
    height: min(62vh, 520px);
    background: color-mix(in srgb, var(--ink) 88%, transparent);
}
.battle-log-panel::after {
    content: '战斗记录 · 点击展开';
    position: absolute;
    top: 8px;
    left: 14px;
    right: 14px;
    color: var(--gold-foil-light);
    font-family: var(--font-title);
    font-size: 13px;
    letter-spacing: 0.08em;
    pointer-events: none;
}
.battle-log-panel.expanded::after {
    content: '战斗记录 · 点击收起';
}
.battle-log-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-foil), transparent);
    opacity: 0.4;
}

.battle-log-entry {
    padding: 2px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--gold-foil) 6%, transparent);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.battle-defeat-line {
    display: block;
    padding-left: 1.4em;
    color: var(--gold-foil-light);
    font-weight: 600;
}
.battle-log-entry.log-system {
    color: var(--gold-foil-light);
    font-weight: 700;
    font-size: 13px;
    font-family: var(--font-title);
    letter-spacing: 0.08em;
    text-shadow:
        0 0 8px var(--gold-foil-glow),
        0 1px 2px rgba(0, 0, 0, 0.5);
    padding: 4px 0;
}
.battle-log-entry.log-damage {
    color: var(--vermillion-light);
    font-weight: 500;
}
.battle-log-entry.log-heal {
    color: var(--jade);
    font-weight: 500;
}

/* 滚动条美化 */
.battle-log-panel::-webkit-scrollbar { width: 4px; }
.battle-log-panel::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--ink) 50%, transparent);
}
.battle-log-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--gold-foil), var(--gold-foil-light));
    border-radius: 4px;
    box-shadow: 0 0 6px var(--gold-foil-glow);
}

/* ===== 结果弹窗 ===== */
.battle-result-stats {
    color: var(--paper-secondary);
    font-size: 14px;
    line-height: 2;
    margin-bottom: 10px;
    font-family: var(--font-body);
}
.battle-result-stats .stat-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.battle-result-stats .stat-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.battle-result-stats .stat-item .num {
    color: var(--gold-foil-light);
    font-weight: 700;
    font-family: var(--font-num);
    text-shadow: 0 0 6px var(--gold-foil-glow);
    font-size: 15px;
}

.battle-result-body {
    padding: 10px 16px 14px !important;
}

/* 奖励区域 */
.battle-rewards {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--gold-foil) 8%, var(--ink-surface)) 0%,
            var(--ink-surface) 100%);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 8px 0;
    font-size: 13px;
    text-align: left;
    border: 1px solid color-mix(in srgb, var(--gold-foil) 20%, transparent);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 color-mix(in srgb, var(--gold-foil) 10%, transparent);
}
.battle-rewards .reward-sec {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    padding: 4px 0;
    gap: 6px 10px;
}
.battle-rewards .reward-sec + .reward-sec {
    border-top: 1px solid var(--ink-border);
    margin-top: 6px;
    padding-top: 8px;
}
.battle-rewards .reward-title {
    color: var(--gold-foil);
    font-size: 13px;
    flex-shrink: 0;
    font-weight: 700;
    font-family: var(--font-title);
    letter-spacing: 0.08em;
    text-shadow: 0 0 4px var(--gold-foil-glow);
}
.battle-rewards .reward-item {
    color: var(--jade);
    font-size: 13px;
    white-space: nowrap;
    font-weight: 500;
}
.battle-rewards .reward-item .qty {
    color: var(--paper-muted);
    font-family: var(--font-num);
    font-weight: 600;
}
.battle-rewards .reward-pet {
    color: var(--paper-secondary);
    font-size: 13px;
    white-space: nowrap;
}
.battle-rewards .reward-pet .up {
    color: var(--gold-foil-light);
    font-weight: 700;
    text-shadow: 0 0 4px var(--gold-foil-glow);
}
.battle-rewards .reward-brk {
    color: var(--gold-foil-light);
    font-size: 13px;
    width: 100%;
    font-weight: 700;
    text-shadow: 0 0 4px var(--gold-foil-glow);
}

/* 低状态警告快捷按钮 */
.warn-quick-btn {
    flex: 1;
    padding: 12px 0;
    border: 1px solid color-mix(in srgb, var(--gold-foil) 25%, transparent);
    border-radius: 12px;
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--gold-foil) 15%, var(--ink-elevated)) 0%,
            var(--ink-elevated) 100%);
    color: var(--gold-foil-light);
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-family: var(--font-title);
    letter-spacing: 0.1em;
    font-weight: 700;
    text-shadow: 0 0 6px var(--gold-foil-glow);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 color-mix(in srgb, var(--gold-foil) 15%, transparent);
}
.warn-quick-btn:active {
    background: color-mix(in srgb, var(--gold-foil) 20%, transparent);
    transform: scale(0.97);
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===== 屏幕震动效果 ===== */
.battle-screen-shake {
    animation: screen-shake var(--battle-shake-duration, 1ms) ease-out;
}
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-3px, 2px); }
    40% { transform: translate(3px, -2px); }
    60% { transform: translate(-2px, -1px); }
    80% { transform: translate(2px, 1px); }
}

/* ===== 剑气特效 ===== */
.battle-sword-slash {
    position: fixed;
    z-index: 999998;
    pointer-events: none;
    width: 120px;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--gold-foil-light) 30%,
        #fff 50%,
        var(--gold-foil-light) 70%,
        transparent 100%);
    box-shadow:
        0 0 10px var(--gold-foil-glow),
        0 0 20px var(--gold-foil-glow);
    border-radius: 2px;
    animation: sword-slash 0.5s ease-out forwards;
}
@keyframes sword-slash {
    0% { opacity: 0; transform: scaleX(0) rotate(-30deg); }
    30% { opacity: 1; transform: scaleX(1.2) rotate(-15deg); }
    100% { opacity: 0; transform: scaleX(1.5) rotate(0deg); }
}

/* ===== 暴击特效圆环 ===== */
.battle-crit-ring {
    position: fixed;
    z-index: 999997;
    pointer-events: none;
    width: 80px;
    height: 80px;
    border: 3px solid var(--vermillion);
    border-radius: 50%;
    box-shadow:
        0 0 20px var(--vermillion-glow),
        0 0 40px var(--vermillion-glow),
        inset 0 0 20px var(--vermillion-glow);
    animation: crit-ring-expand 0.6s ease-out forwards;
}
@keyframes crit-ring-expand {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
    50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
}

/* ============================================================
 *  浅色主题适配 —— 确保战斗页面在各主题下质感统一
 * ============================================================ */

/* 云雾青 / 宣纸 / 翠竹绿 等浅色主题下，战斗页面保持深色战场氛围 */
html[data-theme="cloudblue"] #page-battle.active,
html[data-theme="paper"] #page-battle.active,
html[data-theme="bamboo"] #page-battle.active,
html[data-theme="purple"] #page-battle.active {
    /* 强制深色战斗背景，确保战斗氛围统一 */
    background:
        radial-gradient(ellipse at 50% 20%, rgba(208, 80, 80, 0.18) 0%, transparent 45%),
        radial-gradient(ellipse at 15% 75%, rgba(200, 168, 112, 0.08) 0%, transparent 35%),
        radial-gradient(ellipse at 85% 65%, rgba(208, 80, 80, 0.12) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 100%, rgba(208, 80, 80, 0.1) 0%, transparent 50%),
        linear-gradient(180deg, #1a1410 0%, #140e0a 100%);
}

/* 浅色主题下的战斗标题栏 */
html[data-theme="cloudblue"] .battle-header,
html[data-theme="paper"] .battle-header,
html[data-theme="bamboo"] .battle-header,
html[data-theme="purple"] .battle-header {
    background:
        linear-gradient(180deg,
            rgba(180, 50, 50, 0.9) 0%,
            rgba(150, 40, 40, 0.8) 40%,
            #1a1410 100%);
    border-bottom-color: #c04040;
}

/* 浅色主题下的战斗单位卡片 - 保持深色质感 */
html[data-theme="cloudblue"] .battle-unit,
html[data-theme="paper"] .battle-unit,
html[data-theme="bamboo"] .battle-unit,
html[data-theme="purple"] .battle-unit {
    background:
        linear-gradient(135deg,
            rgba(60, 50, 40, 0.95) 0%,
            rgba(40, 32, 26, 0.95) 40%,
            rgba(35, 28, 22, 0.95) 100%);
    border-color: rgba(200, 168, 112, 0.25);
}

html[data-theme="cloudblue"] .battle-unit.enemy,
html[data-theme="paper"] .battle-unit.enemy,
html[data-theme="bamboo"] .battle-unit.enemy,
html[data-theme="purple"] .battle-unit.enemy {
    background:
        linear-gradient(135deg,
            rgba(80, 40, 40, 0.95) 0%,
            rgba(50, 28, 28, 0.95) 40%,
            rgba(40, 22, 22, 0.95) 100%);
    border-color: rgba(208, 80, 80, 0.3);
}

/* 浅色主题下的单位名字 - 金色保持不变 */
html[data-theme="cloudblue"] .battle-unit .unit-name,
html[data-theme="paper"] .battle-unit .unit-name,
html[data-theme="bamboo"] .battle-unit .unit-name,
html[data-theme="purple"] .battle-unit .unit-name {
    color: #dcc090;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.7),
        0 0 6px rgba(200, 168, 112, 0.4);
}

html[data-theme="cloudblue"] .battle-unit.enemy .unit-name,
html[data-theme="paper"] .battle-unit.enemy .unit-name,
html[data-theme="bamboo"] .battle-unit.enemy .unit-name,
html[data-theme="purple"] .battle-unit.enemy .unit-name {
    color: #e08070;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.7),
        0 0 6px rgba(208, 80, 80, 0.4);
}

/* 浅色主题下的战斗日志 - 深色背景 */
html[data-theme="cloudblue"] .battle-log-panel,
html[data-theme="paper"] .battle-log-panel,
html[data-theme="bamboo"] .battle-log-panel,
html[data-theme="purple"] .battle-log-panel {
    background:
        linear-gradient(180deg,
            transparent 0%,
            rgba(20, 14, 10, 0.9) 30%,
            #1a1410 100%);
    color: #c8b898;
    border-top-color: rgba(200, 168, 112, 0.15);
}

html[data-theme="cloudblue"] .battle-log-entry.log-system,
html[data-theme="paper"] .battle-log-entry.log-system,
html[data-theme="bamboo"] .battle-log-entry.log-system,
html[data-theme="purple"] .battle-log-entry.log-system {
    color: #dcc090;
}

html[data-theme="cloudblue"] .battle-log-entry.log-damage,
html[data-theme="paper"] .battle-log-entry.log-damage,
html[data-theme="bamboo"] .battle-log-entry.log-damage,
html[data-theme="purple"] .battle-log-entry.log-damage {
    color: #e07070;
}

html[data-theme="cloudblue"] .battle-log-entry.log-heal,
html[data-theme="paper"] .battle-log-entry.log-heal,
html[data-theme="bamboo"] .battle-log-entry.log-heal,
html[data-theme="purple"] .battle-log-entry.log-heal {
    color: #7ab890;
}

/* 浅色主题下的战斗标题文字 */
html[data-theme="cloudblue"] .battle-header .battle-title,
html[data-theme="paper"] .battle-header .battle-title,
html[data-theme="bamboo"] .battle-header .battle-title,
html[data-theme="purple"] .battle-header .battle-title {
    color: #dcc090;
}

/* 浅色主题下的血条文字 - 确保白色清晰 */
html[data-theme="cloudblue"] .battle-unit .unit-hp-text,
html[data-theme="paper"] .battle-unit .unit-hp-text,
html[data-theme="bamboo"] .battle-unit .unit-hp-text,
html[data-theme="purple"] .battle-unit .unit-hp-text {
    color: #fff;
}

/* 浅色主题下的 VS 文字 */
html[data-theme="cloudblue"] .battle-vs,
html[data-theme="paper"] .battle-vs,
html[data-theme="bamboo"] .battle-vs,
html[data-theme="purple"] .battle-vs {
    color: #c04040;
}

/* 浅色主题下的真元条文字 */
html[data-theme="cloudblue"] .battle-unit .unit-sp-text,
html[data-theme="paper"] .battle-unit .unit-sp-text,
html[data-theme="bamboo"] .battle-unit .unit-sp-text,
html[data-theme="purple"] .battle-unit .unit-sp-text {
    color: #a09078;
}

/* 浅色主题下的工具栏背景 */
html[data-theme="cloudblue"] .battle-toolbar,
html[data-theme="paper"] .battle-toolbar,
html[data-theme="bamboo"] .battle-toolbar,
html[data-theme="purple"] .battle-toolbar {
    background:
        linear-gradient(180deg, transparent, rgba(20, 14, 10, 0.9));
    border-top-color: rgba(200, 168, 112, 0.12);
}
