* {
    box-sizing: border-box;
    user-select: none;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f5f0e6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Noto Sans", sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.reader-container {
    max-width: 600px;
    width: 100%;
    background: #fffcf8;
    border-radius: 32px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 1px solid #e2d8cc;
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 800px;
}

.location-bar {
    background: #f0ebe3;
    padding: 12px 20px;
    font-size: 14px;
    color: #8b7a66;
    border-bottom: 1px solid #e2d8cc;
    text-align: center;
    flex-shrink: 0;
}

.info-bar {
    background: #f0ebe3;
    padding: 6px 20px;
    font-size: 13px;
    color: #6b5e4e;
    border-bottom: 1px solid #e2d8cc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.identity-span, .stats-span {
    white-space: nowrap;
}

.friends-bar {
    background: #f0ebe3;
    padding: 4px 20px;
    font-size: 12px;
    color: #6b5e4e;
    border-bottom: 1px solid #e2d8cc;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.story-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 0 20px;
    background: #fffcf8;
    position: relative; 
}

.story-text {
    color: #2c2a28;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.action-area {
    padding: 12px 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fffcf8;
}

.option-btn {
    background: #f0ebe3;
    border: 1px solid #d9cebf;
    color: #5c4e3d;
    padding: 12px 16px;
    border-radius: 48px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: 0.1s;
    width: 100%;
}
.option-btn:active {
    transform: scale(0.98);
    background: #e6dfd5;
}

/* 选项主内容容器（单列/网格的公共父级） */
.options-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 分区卡片网格（营地等功能分区，A1 方案） */
.camp-zone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.camp-zone-card {
    border: 1px solid #e6ddd0;
    border-radius: 12px;
    padding: 10px;
    background: #fbf7f1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.camp-zone-card--full {
    grid-column: 1 / -1;
}
.camp-zone-title {
    font-size: 13px;
    font-weight: 700;
    color: #8b6914;
    border-bottom: 1px dashed #e6ddd0;
    padding-bottom: 4px;
}
.camp-zone-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 统一底部返回栏（B1 方案：每个场景同一位置） */
.camp-back-bar {
    border-top: 1px solid #e6ddd0;
    padding-top: 10px;
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fffcf8;
}

.path-map {
    background: #faf7f2;
    padding: 8px 20px;
    font-size: 11px;
    color: #b8ab9a;
    white-space: nowrap;
    overflow-x: auto;
    border-top: 1px solid #efe5da;
    font-family: monospace;
    flex-shrink: 0;
}

.utility-bar {
    display: flex;
    justify-content: space-evenly;
    padding: 12px 20px 20px;
    gap: 12px;
    border-top: 1px solid #efe5da;
    background: #fffcf8;
    flex-shrink: 0;
}
.util-btn {
    background: #fff;
    border: 1px solid #d9cebf;
    padding: 8px 12px;
    border-radius: 40px;
    color: #8b7a66;
    font-size: 13px;
    cursor: pointer;
    flex: 1;
    text-align: center;
}
.util-btn:active {
    background: #f5efe8;
}

/* 营地按钮特殊样式 */
#campBtn {
    color: #8b6914;
}

.combat-log { max-height: 300px; overflow-y: auto; margin-bottom: 12px; }

/* 模态框背景 */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 模态框内容 */
.modal-content {
    background-color: #fffcf8;
    border-radius: 20px;
    width: 80%;
    max-width: 400px;
    border: 1px solid #d9cebf;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-family: inherit;
}

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2d8cc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #5c4e3d;
}

.modal-header .close {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #8b7a66;
}

.modal-header .close:hover {
    color: #3a2e22;
}

.inventory-list {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #efe5da;
}

.inventory-item:last-child {
    border-bottom: none;
}

.item-name {
    font-size: 16px;
    color: #2c2a28;
}

.item-quantity {
    font-size: 14px;
    color: #8b7a66;
    margin-left: 8px;
}

.item-use-btn {
    background-color: #f0ebe3;
    border: 1px solid #d9cebf;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    color: #5c4e3d;
}

.item-use-btn:active {
    background-color: #e6dfd5;
}

/* 技能按钮网格布局 */
.skill-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}
.skill-buttons .option-btn {
    width: 100%;
    margin: 0;
    padding: 10px 0;
    font-size: 14px;
}
@media (max-width: 480px) {
    .skill-buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    .skill-buttons .option-btn {
        font-size: 12px;
        padding: 8px 0;
    }
}

/* 浮动提示 */
.game-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 2000;
    pointer-events: none;
    animation: fadeOut 2s ease forwards;
}
@keyframes fadeOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    90% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 信息弹出面板（复modal样式，居中） */
#infoPopup {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#infoPopup .modal-content {
    width: 80%;
    max-width: 400px;
    max-height: 80vh;
}

#infoPopup .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f0ebe3;
    border-bottom: 1px solid #e2d8cc;
    border-radius: 20px 20px 0 0;
}

#infoPopup .modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #3a2e22;
}


/* 伙伴列表样式 */
.friend-checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #efe5da;
}
.friend-checkbox-item input {
    margin-right: 12px;
    transform: scale(1.2);
}
.friend-name {
    flex: 1;
}
.friend-level {
    color: #8b7a66;
    font-size: 12px;
}

/* 地图地点列表 */
.map-location {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    margin: 4px 0;
    background: #f0ebe3;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}
.map-location:hover {
    background: #e6dfd5;
}

.utility-bar {
    display: flex;
    justify-content: space-evenly;
    flex-wrap: wrap;
    padding: 12px 20px 20px;
    gap: 12px;
    border-top: 1px solid #efe5da;
    background: #fffcf8;
    flex-shrink: 0;
}
.util-btn {
    background: #fff;
    border: 1px solid #d9cebf;
    padding: 8px 12px;
    border-radius: 40px;
    color: #8b7a66;
    font-size: 13px;
    cursor: pointer;
    flex: 1 0 auto;
    text-align: center;
    min-width: 70px;
}
@media (max-width: 480px) {
    .util-btn {
        font-size: 11px;
        padding: 6px 8px;
        min-width: 60px;
    }
}

.story-box {
    overflow-anchor: none;
}
.combat-log {
    overflow-anchor: none;
}

/* ==================== 状态页折叠面板 ==================== */
details {
    margin-top: 12px;
}

details > summary {
    list-style: none;
    -webkit-user-select: none;
    user-select: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

details[open] > summary {
    color: #b35a2a;
}

/* ==================== 危险操作按钮 ==================== */
button.map-location[style*="color:#c0392b"] {
    background: #fff0f0;
    border-color: #e8a0a0;
}

button.map-location[style*="color:#c0392b"]:active {
    background: #ffe0e0;
    transform: scale(0.98);
}

/* 装备详情弹窗样式 */
#equipDetailContent .equip-name {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 8px;
}

/* 状态栏/角色面板 装备行：名称在左，卸下按钮靠右同一行 */
.equip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}
.equip-row .equip-name-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.unequip-btn {
    flex: 0 0 auto;
    font-family: inherit;        /* 跟随状态栏正文字体，不套地图按钮异体 */
    font-size: 12px;
    line-height: 1.4;
    padding: 1px 10px;
    background: #fff;
    border: 1px solid #d9cebf;
    border-radius: 12px;
    color: #8b7a66;
    cursor: pointer;
    white-space: nowrap;
}
.unequip-btn:hover {
    background: #f0ebe3;
    color: #5a4a3a;
}
.unequip-btn:active {
    transform: scale(0.97);
}
#equipDetailContent .equip-meta {
    font-size: 14px;
    color: #8b7a66;
    margin-bottom: 12px;
}
#equipDetailContent .equip-stats {
    margin: 8px 0;
    padding: 8px 0;
    border-top: 1px solid #e2d8cc;
}
#equipDetailContent .equip-stats div {
    padding: 2px 0;
}
#equipDetailContent .equip-effects {
    margin: 8px 0;
    padding: 8px 0;
    border-top: 1px solid #e2d8cc;
}
#equipDetailContent .equip-effects div {
    padding: 2px 0;
    color: #2c6b2c;
}
#equipDetailContent .equip-quality-normal { color: #8b7a66; }
#equipDetailContent .equip-quality-special { color: #2a7a9a; }
#equipDetailContent .equip-quality-rare { color: #c8a83a; }

/* 背包中装备名称带品质颜色 */
.inventory-item .item-name.quality-normal { color: #8b7a66; }
.inventory-item .item-name.quality-special { color: #2a7a9a; }
.inventory-item .item-name.quality-rare { color: #c8a83a; }

.story-text {
    transition: transform 0.25s ease, opacity 0.25s ease;
    transform: translateY(15px);
    opacity: 0;
}
.story-text.slide-in {
    transform: translateY(0);
    opacity: 1;
}

/* ===== 战斗 HUD：敌方血条(右上·档位边框) / 我方血条(左下) ===== */
#battleHud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 6;
}
/* 敌方容器：右上，带档位边框暗示战斗难度 */
.hud-enemy-box {
    position: absolute;
    top: 10px;
    right: 12px;
    max-width: 60%;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(20, 16, 12, 0.10);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.hud-enemy-box.tier-normal { border: 2px solid #4caf50; }   /* 普通：绿 */
.hud-enemy-box.tier-elite  { border: 3px solid #2e7bd6; }   /* 精英：蓝·更粗 */
.hud-enemy-box.tier-boss   { border: 5px solid #e53935; }   /* 首领：红·继续加粗 */

/* 我方容器：左下，中性边框，横向一排三个（超出换行） */
.hud-party-box {
    position: absolute;
    bottom: 10px;
    left: 12px;
    max-width: 480px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(120, 120, 120, 0.55);
    background: rgba(20, 16, 12, 0.10);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* 血条本体：轨道为半透底，掉血后红色填充收缩、空缺透出轨道 */
.hud-bar {
    position: relative;
    width: 150px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}
.hud-bar-fill {
    height: 16px;
    border-radius: 6px 0 0 6px;
    transition: width 0.35s ease-out;
}
/* 敌方：红色填充（掉血按比例透明减红） */
.hud-enemy-bar .hud-bar-fill { background: linear-gradient(90deg, #ff7b7b, #c0392b); }
/* 我方：绿色填充（与敌方红色区分，直观分辨敌我） */
.hud-player-bar .hud-bar-fill,
.hud-party-bar .hud-bar-fill { background: linear-gradient(90deg, #7bed9f, #2ed573); }
.hud-bar-label {
    position: absolute;
    top: 0; left: 0; right: 0;
    line-height: 16px;
    text-align: center;
    font-size: 11px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
    white-space: nowrap;
}

/* 战斗态：storyBox 自身不滚动，日志改由 #battleLog 独立嵌套滚动，
   #battleLog 内缩避开 HUD 四角 → 血条永不直接压住日志文字 */
.story-box.in-battle { overflow: hidden; padding: 0; }
#battleLog {
    position: absolute;
    top: 50px; right: 20px; bottom: 72px; left: 20px;
    overflow-y: auto;
    overflow-anchor: none;
    padding: 0;
    color: #2c2a28;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 控制按钮压缩为两行：上一行主操作、下一行技能（可点击） */
.battle-primary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.battle-primary-row .option-btn {
    width: 100%;
    margin: 0;
    font-size: 14px;
    padding: 12px 4px;
}