/* ============================================================ */
/* 战斗页面样式（固定尺寸，不缩放）                              */
/* ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #dcccb8;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'PingFang SC', 'Noto Sans SC', 'Courier New', monospace;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
}

/* ---- 主容器 ---- */
#battlePage {
    width: 450px;
    height: 800px;
    background: #eadcc8;
    border-radius: 28px;
    box-shadow: 0 12px 60px rgba(120, 80, 50, 0.18);
    display: flex;
    flex-direction: column;
    padding: 12px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

/* ---- 页眉 ---- */
#battleHeader {
    height: 32px;
    min-height: 32px;
    background: #e8d8c4;
    border-radius: 16px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    flex-shrink: 0;
}

#battleBackBtn {
    background: transparent;
    border: none;
    color: #8a8a8a;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#battleBackBtn:hover {
    color: #3a3a3a;
}

#battleFormation {
    flex: 1;
    font-size: 13px;
    color: #3a3a3a;
    font-weight: 500;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#battleRound {
    font-size: 11px;
    color: #8a8a7a;
    font-weight: 400;
    white-space: nowrap;
}

/* ---- 展示区 ---- */
#battleArena {
    flex: 1;
    min-height: 0;
    background: #e8d8c4;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
    margin: 4px 0;
    gap: 2px;
    position: relative;
}

/* ---- 网格 ---- */
.battle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    width: 348px;
    height: 288px;
    flex-shrink: 0;
}

/* ---- 分隔线 ---- */
#battleDivider {
    height: 28px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #8a7a6a;
    letter-spacing: 6px;
    flex-shrink: 0;
}

/* ---- 格子 ---- */
.battle-cell {
    background: rgba(220, 204, 184, 0.35);
    border: 2px solid #d0c4b0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    padding: 3px 4px 2px 4px;
    position: relative;
    overflow: hidden;
    transition: all 0.15s ease;
}

/* 格子状态 */
.battle-cell.empty {
    border-style: dashed;
    border-color: #c8bca8;
}

.battle-cell.empty .cell-center {
    color: #c8bca8;
    font-size: 24px;
}

.battle-cell.dead {
    opacity: 0.4;
    background: rgba(180, 160, 140, 0.2);
}
.battle-cell.dead .cell-center .alive-emoji {
    display: none;
}
.battle-cell.dead .cell-center .dead-mark {
    display: flex;
}
.battle-cell.dead .hp-fill {
    background: #b8a898 !important;
}

/* 格子内部布局 */
.cell-index {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 9px;
    color: #b8a898;
    font-weight: 400;
    z-index: 1;
}

.cell-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 14px;
    min-height: 14px;
    font-size: 9px;
    color: #6a6a5a;
    padding: 0 2px;
    z-index: 1;
}
.cell-lv {
    color: #8a8a7a;
}
.cell-name {
    color: #3a3a3a;
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.cell-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    position: relative;
    min-height: 0;
}
.cell-center .dead-mark {
    display: none;
    font-size: 24px;
    font-weight: 700;
    color: #8a7a6a;
}
.cell-center .alive-emoji {
    display: flex;
}

.cell-bottom {
    display: flex;
    flex-direction: column;
    gap: 1px;
    height: 12px;
    min-height: 12px;
    padding: 0 1px;
    z-index: 1;
}
.bar-row {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 4px;
    min-height: 4px;
}
.bar-row.sp-row.hidden {
    display: none;
}
.bar-track {
    flex: 1;
    height: 100%;
    background: rgba(160, 140, 120, 0.2);
    border-radius: 3px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.2s ease;
}
.bar-fill.hp {
    background: #7aaa6a;
}
.bar-fill.sp {
    background: #6a8aaa;
}
.bar-label {
    font-size: 6px;
    color: #8a8a7a;
    min-width: 12px;
    text-align: right;
    line-height: 1;
}

/* ---- 动画 ---- */
@keyframes cell-attack {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); background: rgba(200, 168, 106, 0.3); border-color: #c8a86a; }
    100% { transform: scale(1); }
}
.battle-cell.attacking {
    animation: cell-attack 0.35s ease forwards;
}

@keyframes cell-damage {
    0% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}
.battle-cell.damaged {
    animation: cell-damage 0.3s ease forwards;
}

@keyframes float-up {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-40px); }
}
.floating-damage {
    position: fixed;
    font-size: 22px;
    font-weight: 700;
    color: #e53935;
    pointer-events: none;
    z-index: 200;
    animation: float-up 1s ease forwards;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}
.floating-heal {
    color: #43a047;
}

/* ---- 页脚 ---- */
#battleFooter {
    height: 72px;
    min-height: 72px;
    background: #e8d8c4;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    padding: 4px 12px 6px 12px;
    margin-top: 4px;
    flex-shrink: 0;
}

#battleActions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.battle-action {
    background: #dcccb8;
    border: 1px solid #d0c4b0;
    color: #6a6a6a;
    padding: 4px 20px;
    border-radius: 30px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.8;
    font-weight: 400;
}

.battle-action:hover:not(:disabled) {
    background: #eadcc8;
    border-color: #b8a898;
    color: #3a3a3a;
}
.battle-action:active:not(:disabled) {
    transform: scale(0.95);
}
.battle-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#battleStatus {
    height: 20px;
    font-size: 11px;
    color: #8a8a7a;
    text-align: center;
    line-height: 20px;
    letter-spacing: 0.5px;
}

/* ---- 结算浮层 ---- */
#battleResult {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 28px;
    z-index: 50;
    backdrop-filter: blur(4px);
}
#battleResult .result-title {
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
#battleResult .result-sub {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
}
#battleResult .result-btn {
    margin-top: 24px;
    padding: 8px 40px;
    background: #c8a86a;
    border: none;
    border-radius: 30px;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}
#battleResult .result-btn:hover {
    background: #b8985a;
}
#battleResult.victory .result-title {
    color: #ffd54f;
}
#battleResult.defeat .result-title {
    color: #ef5350;
}

/* 结算浮层文字换行 */
#battleResult .result-sub {
    max-width: 80%;
    word-wrap: break-word;
    white-space: pre-wrap;
    text-align: center;
    padding: 0 20px;
}