/* ========== 全局 ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: 'Segoe UI', 'PingFang SC', Roboto, sans-serif;
    background: #0b0e14;
    color: #e8edf5;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}
#app {
    max-width: 1400px;
    width: 100%;
    background: #141a24;
    border-radius: 24px;
    padding: 24px 28px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    border: 1px solid #2a3344;
}

/* ========== 头部 ========== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2a3344;
}
.header h1 {
    font-weight: 600;
    font-size: 26px;
    background: linear-gradient(135deg, #f0c674, #e6b450);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}
.header .info {
    display: flex;
    gap: 20px;
    font-size: 15px;
    background: #1e2633;
    padding: 6px 18px;
    border-radius: 40px;
    border: 1px solid #2f3a4e;
}
.header .info span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.badge {
    background: #2f3a4e;
    padding: 2px 12px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
}
.badge.alice {
    background: #3a6ea5;
}
.badge.bob {
    background: #a5433a;
}
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.controls button {
    padding: 8px 20px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #2a3344;
    color: #c8d0dd;
    border: 1px solid #3d4a60;
}
.controls button:hover {
    background: #3d4a60;
    color: #fff;
}
.controls button.primary {
    background: #3a6ea5;
    border-color: #4a8ac0;
    color: #fff;
}
.controls button.primary:hover {
    background: #4a8ac0;
}
.controls button.danger {
    background: #a5433a;
    border-color: #c55a4a;
    color: #fff;
}
.controls button.danger:hover {
    background: #c55a4a;
}
.controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== 战场 ========== */
.battlefield {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    min-height: 360px;
}
.side {
    flex: 1;
    background: #10161f;
    border-radius: 16px;
    padding: 16px 14px;
    border: 1px solid #232d3d;
    min-width: 0;
}
.side.alice-side {
    border-color: #3a6ea5;
}
.side.bob-side {
    border-color: #a5433a;
}
.side-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.side-title .tag {
    font-size: 12px;
    background: #1e2633;
    padding: 2px 14px;
    border-radius: 30px;
    color: #8899bb;
}
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

/* ========== 角色卡 ========== */
.char-card {
    background: #1a212d;
    border-radius: 14px;
    padding: 14px 12px 12px;
    border: 1px solid #2a3344;
    transition: all 0.15s;
    position: relative;
    cursor: default;
}
.char-card.clickable {
    cursor: pointer;
    border-color: #f0c674;
    box-shadow: 0 0 12px rgba(240, 198, 116, 0.3);
}
.char-card.clickable:hover {
    background: #232d3d;
    transform: scale(1.02);
}
.char-card.dead {
    opacity: 0.35;
    filter: grayscale(0.7);
    border-color: #3a2a2a;
    cursor: default;
    pointer-events: none;
}
/* ===== 新增：当前行动角色高亮 ===== */
.char-card.acting {
    border-color: #f0c674;
    box-shadow: 0 0 16px rgba(240, 198, 116, 0.45);
}
/* ===== 新增：技能就绪卡片描边 ===== */
.char-card.skill-ready {
    border-color: #6ab0e6;
}
/* ===== 新增：行动中徽标 ===== */
.char-card .spd-badge {
    position: absolute;
    top: -10px;
    right: 10px;
    background: #f0c674;
    color: #1a212d;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 10px;
    border-radius: 20px;
    box-shadow: 0 0 10px rgba(240, 198, 116, 0.5);
}
.char-card .char-id {
    font-weight: 700;
    font-size: 13px;
    color: #8899bb;
    display: inline-block;
    background: #232d3d;
    padding: 0 10px;
    border-radius: 20px;
    margin-bottom: 6px;
}
.char-card .char-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}
.bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    margin-top: 4px;
}
.bar-row .label {
    width: 28px;
    font-weight: 600;
    color: #8899bb;
    flex-shrink: 0;
}
.bar-track {
    flex: 1;
    height: 10px;
    background: #2a3344;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}
.bar-track .fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.25s ease;
}
.bar-track .fill.hp {
    background: linear-gradient(90deg, #d45a4a, #e07a5a);
}
.bar-track .fill.mp {
    background: linear-gradient(90deg, #4a8ac0, #6ab0e6);
}
/* ===== 新增：AV 条背景色（原先缺失导致条不可见） ===== */
.bar-track .fill.spd {
    background: linear-gradient(90deg, #6ab07a, #8ed6a0);
}
.bar-row .value {
    min-width: 36px;
    text-align: right;
    font-size: 11px;
    color: #b0c0dd;
    flex-shrink: 0;
}
.stats-row {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #8899bb;
    margin-top: 6px;
    flex-wrap: wrap;
}
.stats-row span {
    background: #10161f;
    padding: 0 8px;
    border-radius: 12px;
    border: 1px solid #1e2633;
}
.stats-row .highlight {
    color: #e8edf5;
}
.talent-skill {
    font-size: 11px;
    margin-top: 6px;
    color: #99aac8;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
}
.talent-skill .ts-label {
    color: #6a7a99;
}
.talent-skill .ts-val {
    color: #d0dcee;
}

/* ========== 提示 ========== */
.action-hint {
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    padding: 10px;
    margin: 10px 0 0;
    background: #1e2633;
    border-radius: 40px;
    border: 1px solid #2f3a4e;
    color: #f0c674;
    transition: all 0.2s;
    min-height: 48px;
}
.action-hint.idle {
    color: #8899bb;
    border-color: #2a3344;
}

/* ========== 日志 ========== */
.log-section {
    margin-top: 20px;
    border-top: 1px solid #232d3d;
    padding-top: 16px;
}
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.log-header h3 {
    font-size: 15px;
    font-weight: 500;
    color: #99aac8;
}
.log-header .log-clear {
    background: none;
    border: none;
    color: #5a6a88;
    cursor: pointer;
    font-size: 12px;
}
.log-header .log-clear:hover {
    color: #99aac8;
}
.log-box {
    background: #0d121c;
    border-radius: 12px;
    padding: 10px 14px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    border: 1px solid #1a212d;
}
.log-box .log-entry {
    padding: 2px 0;
    border-bottom: 1px solid #141a24;
}
.log-box .log-entry .time {
    color: #4a5a78;
    margin-right: 10px;
}
.log-box .log-entry .msg .hl-dead {
    color: #d45a4a;
    font-weight: 700;
}
.log-box .log-entry .msg .hl-heal {
    color: #6ab07a;
}
.log-box .log-entry .msg .hl-energy {
    color: #6ab0e6;
}
.log-box .log-entry .msg .hl-dmg {
    color: #e07a5a;
}

/* ========== 模态框（通用） ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}
.modal.open {
    display: flex;
}
.modal-content {
    background: #1a212d;
    padding: 30px;
    border-radius: 24px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid #2a3344;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}
.modal-content h2 {
    margin-bottom: 20px;
    color: #f0c674;
    text-align: center;
}
.modal-actions {
    display: flex;
    gap: 14px;
    justify-content: flex-end;
    margin-top: 20px;
}
.modal-actions button {
    padding: 8px 24px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}
.modal-actions #btnApplyEdit {
    background: #3a6ea5;
    color: #fff;
}
.modal-actions #btnApplyEdit:hover {
    background: #4a8ac0;
}
.modal-actions #btnCloseEdit,
.modal-actions #btnCloseCodex {
    background: #2a3344;
    color: #c8d0dd;
}
.modal-actions #btnCloseEdit:hover,
.modal-actions #btnCloseCodex:hover {
    background: #3d4a60;
}

/* ========== 配置 & 教程 ========== */
.setup-content {
    max-width: 800px;
}

/* ---- 教程 ---- */
#tutorialArea {
    background: linear-gradient(145deg, #1a212d, #10161f);
    border-radius: 20px;
    padding: 10px 10px 20px 10px;
    border: 1px solid #2f3a4e;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}
#tutorialStep {
    background: #0d121c;
    padding: 20px 24px;
    border-radius: 14px;
    border: 1px solid #2a3344;
    min-height: 130px;
    margin: 12px 0 16px 0;
    font-size: 16px;
    line-height: 1.8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
#tutorialStep .highlight {
    color: #f0c674;
    font-weight: 600;
}
#tutorialStep .em {
    color: #6ab0e6;
    font-weight: 500;
}
#tutorialStep .title {
    font-size: 20px;
    font-weight: 700;
    color: #f0c674;
    display: block;
    margin-bottom: 6px;
    border-bottom: 1px solid #2a3344;
    padding-bottom: 6px;
}
.tutorial-progress {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 12px 0 16px 0;
}
.tutorial-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #2a3344;
    transition: background 0.3s;
    border: 1px solid #3d4a60;
}
.tutorial-dot.active {
    background: #f0c674;
    border-color: #f0c674;
    box-shadow: 0 0 12px rgba(240,198,116,0.5);
}
.tutorial-dot.done {
    background: #6ab07a;
    border-color: #6ab07a;
}
#tutorialPrev, #tutorialNext, #tutorialSkip {
    padding: 6px 24px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}
#tutorialPrev {
    background: #2a3344;
    color: #c8d0dd;
}
#tutorialPrev:hover {
    background: #3d4a60;
}
#tutorialNext {
    background: #3a6ea5;
    color: #fff;
}
#tutorialNext:hover {
    background: #4a8ac0;
}
#tutorialSkip {
    background: #a5433a;
    color: #fff;
}
#tutorialSkip:hover {
    background: #c55a4a;
}

/* ---- 配置表单 ---- */
.char-edit {
    background: #10161f;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid #2a3344;
}
.char-edit h3 {
    color: #99aac8;
    margin-bottom: 10px;
    font-size: 16px;
}
.edit-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: 6px 0;
    align-items: center;
}
.edit-row label {
    font-size: 13px;
    color: #8899bb;
    min-width: 60px;
}
.edit-row input, .edit-row select {
    background: #0d121c;
    border: 1px solid #2a3344;
    border-radius: 6px;
    padding: 4px 8px;
    color: #e8edf5;
    font-size: 13px;
}
.edit-row input {
    width: 60px;
}
.edit-row select {
    width: 140px;
    min-width: 100px;
    cursor: pointer;
}
.edit-row select option {
    background: #1a212d;
}
.edit-row input[type="number"] {
    -moz-appearance: textfield;
}
.edit-row input[type="number"]::-webkit-inner-spin-button,
.edit-row input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.edit-row .info-btn {
    background: #2a3344;
    border: none;
    border-radius: 30px;
    color: #99aac8;
    cursor: pointer;
    font-size: 14px;
    padding: 0 10px;
    line-height: 28px;
}
.edit-row .info-btn:hover {
    background: #3d4a60;
    color: #e8edf5;
}

/* ========== 图鉴 ========== */
.codex-content {
    max-width: 900px;
}
.codex-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}
.codex-col h3 {
    color: #f0c674;
    border-bottom: 1px solid #2a3344;
    padding-bottom: 8px;
    margin-bottom: 12px;
    font-size: 18px;
}
.codex-item {
    background: #10161f;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    border-left: 3px solid #3a6ea5;
}
.codex-item .codex-id {
    font-weight: 700;
    color: #8899bb;
    display: inline-block;
    background: #232d3d;
    padding: 0 10px;
    border-radius: 20px;
    font-size: 12px;
    margin-right: 8px;
}
.codex-item .codex-name {
    font-weight: 600;
    font-size: 15px;
    color: #e8edf5;
}
.codex-item .codex-desc {
    font-size: 13px;
    color: #b0c0dd;
    margin-top: 4px;
}
.codex-item .codex-params {
    font-size: 12px;
    color: #6a7a99;
    margin-top: 2px;
}
.codex-item .codex-params em {
    color: #f0c674;
    font-style: normal;
}

/* =============================================================== */
/* ========== 移动端竖屏适配 (屏幕宽度 ≤ 768px) ========== */
@media (max-width: 768px) {
    /* 调整整体内边距 */
    #app {
        padding: 12px 10px 20px;
        border-radius: 16px;
    }

    /* 头部：标题缩小，信息折叠 */
    .header h1 {
        font-size: 20px;
    }
    .header .info {
        font-size: 12px;
        padding: 4px 12px;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .controls button {
        font-size: 13px;
        padding: 8px 14px;
        flex: 1 1 auto;
        min-width: 70px;
    }

    /* 战场改为上下排列（竖屏） */
    .battlefield {
        flex-direction: column;
        gap: 16px;
    }
    .side {
        padding: 12px 10px;
    }
    .side-title {
        font-size: 15px;
    }

    /* 角色卡片改为两列 */
    .char-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* 角色卡内部字体缩小 */
    .char-card {
        padding: 10px 8px;
    }
    .char-card .char-name {
        font-size: 13px;
    }
    .bar-row {
        font-size: 10px;
    }
    .bar-row .label {
        width: 22px;
    }
    .bar-track {
        height: 8px;
    }
    .stats-row {
        font-size: 10px;
        gap: 6px;
    }
    .stats-row span {
        padding: 0 6px;
    }
    .talent-skill {
        font-size: 10px;
    }

    /* 提示文字 */
    .action-hint {
        font-size: 14px;
        padding: 8px;
        min-height: 40px;
        margin: 6px 0 0;
    }

    /* 日志 */
    .log-box {
        max-height: 150px;
        font-size: 12px;
        padding: 6px 10px;
    }
    .log-header h3 {
        font-size: 13px;
    }

    /* 模态框 */
    .modal-content {
        padding: 16px;
        max-width: 95%;
        border-radius: 16px;
    }
    .modal-content h2 {
        font-size: 18px;
    }
    .modal-actions button {
        font-size: 12px;
        padding: 6px 16px;
    }

    /* 配置表单 */
    .char-edit {
        padding: 10px;
    }
    .edit-row {
        gap: 6px 10px;
    }
    .edit-row label {
        font-size: 12px;
        min-width: 50px;
    }
    .edit-row input {
        width: 50px;
        font-size: 12px;
    }
    .edit-row select {
        width: 120px;
        font-size: 12px;
    }
    .edit-row .info-btn {
        font-size: 12px;
        line-height: 24px;
        padding: 0 8px;
    }

    /* 教程 */
    #tutorialStep {
        font-size: 14px;
        padding: 14px 16px;
        min-height: 100px;
    }
    #tutorialStep .title {
        font-size: 17px;
    }
    #tutorialPrev, #tutorialNext, #tutorialSkip {
        font-size: 12px;
        padding: 5px 16px;
    }

    /* 图鉴 */
    .codex-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .codex-item .codex-name {
        font-size: 14px;
    }
    .codex-item .codex-desc {
        font-size: 12px;
    }

    /* 底部行动面板（如果有） */
    #actionPanel {
        min-width: unset;
        width: 90%;
        padding: 12px 16px;
        bottom: 16px;
        border-radius: 12px;
    }
    #actionPanel .action-btn {
        font-size: 13px;
        padding: 6px 14px;
    }
}

/* 非常小的屏幕（宽度 ≤ 480px）进一步优化 */
@media (max-width: 480px) {
    .char-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .char-card {
        padding: 8px 6px;
    }
    .bar-row .label {
        width: 18px;
        font-size: 9px;
    }
    .bar-row .value {
        font-size: 9px;
        min-width: 28px;
    }
    .stats-row span {
        font-size: 9px;
        padding: 0 4px;
    }
    .edit-row select {
        width: 100px;
        font-size: 11px;
    }
    .edit-row input {
        width: 44px;
        font-size: 11px;
    }
    .controls button {
        font-size: 11px;
        padding: 6px 10px;
        min-width: 60px;
    }
}
