/* ============================================================
   battle.css — 战斗界面样式（Phase 5增强版）
   布局：顶部信息栏 / 战场 / 手牌区 / 底部栏
   组件：悬浮条 / Buff图标 / 敌人卡牌 / 战果展示
   ============================================================ */

#scene-battle {
    z-index: 10;
}

.battle-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: var(--z-content);
}

/* ---- 战斗布局网格 ---- */
.battle-layout {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ---- 顶部信息栏 ---- */
#battle-top-bar {
    flex-shrink: 0;
}

#battle-top-bar > div {
    flex-wrap: wrap;
}

#battle-top-bar > div > div {
    white-space: nowrap;
}

/* ---- 战场区域 ---- */
#battle-field {
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

/* 敌人区域布局 */
#enemy-area {
    flex-wrap: wrap;
}

/* ---- 敌人卡牌 ---- */
.enemy-card {
    user-select: none;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.enemy-card:hover .enemy-card-hp-bar {
    filter: brightness(1.2);
}

/* 敌人血条动画 */
.enemy-card[style*="opacity: 0.3"] {
    transition: opacity 0.5s ease, filter 0.5s ease;
}

/* 敌人卡牌图片 */
.enemy-card img {
    transition: transform 0.3s ease;
}

.enemy-card:hover img {
    transform: scale(1.05);
}

/* 敌人底部信息区域 */
.enemy-card > div:last-child {
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ---- 悬浮条 ---- */
#player-hp-bar div:last-child div,
#sanity-bar div:last-child div,
[id^="enemy-hp-"] div:last-child div {
    transition: width 0.3s ease;
}

/* 玩家护盾指示 */
#player-shield {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ---- 手牌区 ---- */
#hand-area {
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: #3a2a1a transparent;
}

#hand-area::-webkit-scrollbar {
    height: 4px;
}

#hand-area::-webkit-scrollbar-track {
    background: transparent;
}

#hand-area::-webkit-scrollbar-thumb {
    background: #3a2a1a;
    border-radius: 2px;
}

/* ---- 底部栏 ---- */
#battle-bottom-bar {
    flex-shrink: 0;
}

#battle-log {
    scrollbar-width: thin;
    scrollbar-color: #3a2a1a transparent;
    font-family: monospace;
}

#battle-log::-webkit-scrollbar {
    width: 4px;
}

#battle-log::-webkit-scrollbar-track {
    background: transparent;
}

#battle-log::-webkit-scrollbar-thumb {
    background: #3a2a1a;
    border-radius: 2px;
}

/* 结束回合按钮 */
#end-turn-btn:disabled {
    background: linear-gradient(135deg, #3a2a1a, #4a3a2a) !important;
    border-color: #5a4a3a !important;
    color: #6a5a4a !important;
}

#end-turn-btn:disabled:hover {
    filter: none !important;
}

/* ---- 战斗结束界面 ---- */
.battle-end-screen {
    animation: fadeInScale 0.5s ease;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.battle-end-screen button {
    font-weight: bold;
    letter-spacing: 1px;
}

.battle-end-screen button:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

/* ---- 牌库/墓地查看 ---- */
#deck-pile:hover,
#discard-pile:hover,
#exiled-pile:hover {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

/* ---- 目标选择高亮 ---- */
.enemy-card[style*="translateY"] {
    z-index: 10;
}

/* ---- Toast 消息 ---- */
#toast-container div {
    pointer-events: none;
}

/* ---- 响应式适配 ---- */
@media (max-width: 800px) {
    #battle-top-bar {
        font-size: 12px;
        padding: 4px 8px;
    }

    #battle-top-bar > div {
        gap: 8px;
    }

    .enemy-card {
        width: 90px !important;
        height: 135px !important;
    }

    .enemy-card + div {
        width: 90px !important;
    }

    #hand-area {
        padding: 8px 16px !important;
        min-height: 150px !important;
    }

    #end-turn-btn {
        padding: 8px 16px !important;
        font-size: 14px !important;
        min-width: 100px !important;
    }
}

@media (max-width: 600px) {
    .enemy-card {
        width: 70px !important;
        height: 105px !important;
    }

    .enemy-card + div {
        width: 70px !important;
    }

    #battle-bottom-bar {
        grid-template-columns: auto 1fr !important;
    }

    #target-info {
        display: none;
    }
}

/* ========================================================================
   状态面板（Phase 6 — 玩家/怪物状态详情）
   ======================================================================== */

/* 状态面板容器 — 在战场左右两侧 */
#status-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    padding: 8px;
    z-index: 5;
}

.player-status-panel,
.enemy-status-panel {
    pointer-events: auto;
    width: 200px;
    max-height: 100%;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px;
    font-size: 13px;
    scrollbar-width: thin;
    scrollbar-color: #3a2a1a transparent;
}

.player-status-panel {
    border-left: 3px solid #4a8ae8;
}

.enemy-status-panel {
    border-right: 3px solid #e84a4a;
}

.player-status-panel::-webkit-scrollbar,
.enemy-status-panel::-webkit-scrollbar {
    width: 3px;
}

.player-status-panel::-webkit-scrollbar-thumb,
.enemy-status-panel::-webkit-scrollbar-thumb {
    background: #3a2a1a;
    border-radius: 2px;
}

/* 状态面板标题 */
.status-panel-title {
    font-size: 14px;
    font-weight: bold;
    color: #f0e6c8;
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.1);
}

/* 状态分组标题 */
.status-group-title {
    font-size: 12px;
    font-weight: bold;
    color: #b0a080;
    margin: 8px 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 单个状态条目 */
.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin: 2px 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    line-height: 1.5;
}

.status-item .status-icon {
    font-size: 15px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.status-item .status-name {
    color: #e8dcc0;
    flex-grow: 1;
    font-size: 13px;
    font-weight: bold;
}

.status-item .status-duration {
    font-size: 11px;
    font-weight: bold;
    color: #c0b090;
    flex-shrink: 0;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}

/* 正面效果颜色 */
.status-item.positive {
    border-left: 3px solid #4ae86a;
}

/* 负面效果颜色 */
.status-item.negative {
    border-left: 3px solid #e84a4a;
}

/* 无状态提示 */
.status-empty {
    color: #6a5a4a;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    padding: 6px;
    font-style: italic;
}

/* 多怪模式：紧凑状态标签 */
.status-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 3px;
    line-height: 1.5;
    white-space: nowrap;
}

.status-tag-positive {
    background: rgba(74, 232, 106, 0.15);
    border: 1px solid rgba(74, 232, 106, 0.3);
    color: #8aec9a;
}

.status-tag-negative {
    background: rgba(232, 74, 74, 0.15);
    border: 1px solid rgba(232, 74, 74, 0.3);
    color: #ec8a8a;
}

/* ---- 战斗特效预留 ---- */

.battle-damage-number {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #ff4444;
    pointer-events: none;
    animation: damageFloat 1s ease-out forwards;
    z-index: 50;
}

@keyframes damageFloat {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(1.3); }
}

.battle-heal-number {
    color: #44ff44;
}

.battle-shield-number {
    color: #4488ff;
}

/* ========================================================================
   理智阶段屏幕特效（Phase 6）
   ======================================================================== */

/* 清醒 - 正常 */
.sanity-sane {
    transition: box-shadow 0.5s ease;
}

/* 不安 - 轻微闪烁 */
.sanity-uneasy {
    animation: panicFlicker 3s ease-in-out infinite;
    transition: box-shadow 0.5s ease;
}

/* 恐慌 - 闪烁 + 红晕 */
.sanity-panic {
    animation: panicFlicker 1.5s ease-in-out infinite;
    box-shadow: inset 0 0 40px rgba(232, 100, 50, 0.08);
    transition: box-shadow 0.5s ease;
}

/* 狂乱 - 剧烈闪烁 + 红色边框 */
.sanity-frantic {
    animation: panicFlicker 0.6s ease-in-out infinite, franticGlow 2s ease-in-out infinite;
    box-shadow: inset 0 0 60px rgba(232, 50, 50, 0.12);
    transition: box-shadow 0.3s ease;
}

/* 疯狂 - 全屏紫光 + 抖动 */
.sanity-insane {
    animation: screenShake 0.5s ease-in-out infinite, insaneGlow 1.5s ease-in-out infinite;
    box-shadow: inset 0 0 80px rgba(180, 0, 255, 0.15);
    transition: box-shadow 0.3s ease;
}


