/* ==================== 全局重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 主容器 ==================== */
#app {
    width: 100%;
    max-width: 450px;
    aspect-ratio: 9 / 16;
    background: #eadcc8;
    border-radius: 28px;
    box-shadow: 0 12px 60px rgba(120, 80, 50, 0.18);
    display: flex;
    flex-direction: column;
    padding: 2.5%;
    position: relative;
    overflow: hidden;
}


/* ==================== 页眉 ==================== */
#header {
    flex: 0 0 15%;
    background: #e8d8c4;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 14px 8px 14px;
    margin-bottom: 1%;
}

#headerRowTop {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0 4px 0;
}

#timeDisplay {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
    cursor: pointer;
    padding: 2px 16px;
    border-radius: 12px;
    transition: background 0.2s;
    background: rgba(180, 160, 140, 0.15);
}

#timeDisplay:hover {
    background: rgba(180, 160, 140, 0.28);
}

#timeDisplay:active {
    transform: scale(0.96);
}

#worldTimeYear {
    font-size: clamp(18px, 2.4vw, 26px);
    color: #3a3a3a;
    font-weight: 500;
    letter-spacing: 3px;
}

#worldTimeSeason {
    font-size: clamp(13px, 1.6vw, 18px);
    color: #6a6a6a;
    letter-spacing: 2px;
}

#headerRowBottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
    border-top: 1px solid rgba(160, 140, 120, 0.2);
}

/* 左区块 */
#leftGroup {
    display: flex;
    align-items: center;
    gap: 8px;
}

#playerIconWrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#playerIcon {
    font-size: clamp(28px, 3.6vw, 40px);
    cursor: pointer;
    transition: transform 0.15s;
    line-height: 1;
    display: block;
}

#playerIcon:hover {
    transform: scale(1.08);
}

#playerStats {
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    font-size: clamp(13px, 1.6vw, 18px);
}

#playerStats .stat-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    letter-spacing: 0.3px;
}

#playerStats .stat-label {
    color: #6a6a6a;
    font-weight: 400;
    min-width: 32px;
}

#playerStats .stat-value {
    color: #3a3a3a;
    font-weight: 500;
}

/* 右区块 */
#rightGroup {
    display: flex;
    align-items: center;
    gap: 8px;
}

#sceneLocation {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.6;
    font-size: clamp(13px, 1.6vw, 18px);
}

#sceneLocation > * {
    display: block;
}

#sceneLocation .region {
    color: #6a6a6a;
    font-weight: 400;
    letter-spacing: 0.5px;
}

#sceneLocation .county {
    color: #6a6a6a;
    font-weight: 400;
    letter-spacing: 0.3px;
}

#sceneLocation .detail {
    color: #8a8a8a;
    font-weight: 400;
    font-size: clamp(11px, 1.3vw, 14px);
    letter-spacing: 0.3px;
}

#mapBtnWrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#mapBtn {
    background: transparent;
    border: none;
    color: #6a6a6a;
    font-size: clamp(22px, 3vw, 32px);
    cursor: pointer;
    padding: 0;
    transition: color 0.2s, transform 0.15s;
    line-height: 1;
    display: block;
}

#mapBtn:hover {
    color: #3a3a3a;
    transform: scale(1.08);
}


/* ==================== 主区域：场景展示 ==================== */
#sceneArea {
    flex: 0 0 73%;
    background: #e8d8c4;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    min-height: 0;
    margin: 0.5% 0;
}

#sceneBg {
    position: absolute;
    inset: 0;
    background: #e8d8c4;
    pointer-events: none;
}

#sceneLabel {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 204, 184, 0.7);
    padding: 4px 22px;
    border-radius: 30px;
    font-size: clamp(13px, 1.6vw, 18px);
    color: #6a6a6a;
    letter-spacing: 4px;
    pointer-events: none;
    }

/* NPC层 */
#sceneNpcs {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#sceneNpcs .npc {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    padding: 4px 14px;
    background: rgba(240, 232, 220, 0.88);
    border: none;
    border-radius: 20px;
    font-size: clamp(13px, 1.6vw, 18px);
    color: #3a3a3a;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    white-space: nowrap;
}

#sceneNpcs .npc:hover {
    background: rgba(248, 244, 236, 0.95);
    border-color: transparent;
    transform: scale(1.03);
}

#sceneNpcs .npc.friendly {
}
#sceneNpcs .npc.hostile {
}
#sceneNpcs .npc.interactable {
}

/* 物件层 */
#sceneObjects {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#sceneObjects .object {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    padding: 4px 14px;
    background: rgba(232, 220, 208, 0.8);
    border: none;
    border-radius: 20px;
    font-size: clamp(11px, 1.3vw, 14px);
    color: #6a6a6a;
    transition: background 0.2s, border-color 0.2s;
}

#sceneObjects .object:hover {
    background: rgba(240, 232, 220, 0.9);
    border-color: transparent;
}

/* 玩家 */
#scenePlayer {
    position: absolute;
    bottom: 18%;
    left: 50%;
    transform: translateX(-50%);
    width: clamp(28px, 5.5vw, 42px);
    height: clamp(36px, 7vw, 54px);
    background: #a0c080;
    border: none;
    border-radius: 8px;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
}


/* ==================== 页脚 ==================== */
#footer {
    flex: 0 0 10%;
    background: #e8d8c4;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(6px, 1.5vw, 16px);
    min-height: 0;
    padding: 4px 12px;
    margin-top: 1%;
}

.footer-btn {
    background: #dcccb8;
    border: 1px solid #d0c4b0;
    color: #6a6a6a;
    padding: 4px clamp(12px, 1.6vw, 20px);
    border-radius: 30px;
    font-family: inherit;
    font-size: clamp(13px, 1.6vw, 18px);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.8;
    font-weight: 400;
}

.footer-btn:hover {
    background: #eadcc8;
    border-color: #b8a898;
    color: #3a3a3a;
}

.footer-btn:active {
    transform: scale(0.95);
}

#footerReserved {
    color: #8a8a8a;
    font-size: clamp(11px, 1.3vw, 14px);
    padding: 4px clamp(12px, 1.6vw, 20px);
    border: 1px dashed #d0c4b0;
    border-radius: 30px;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 400;
    background: #dcccb8;
}

#footerReserved:hover {
    border-color: #b8a898;
    color: #6a6a6a;
    background: #eadcc8;
}


/* ==================== 面板 ==================== */
.panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;              /* 由内容决定宽度 */
    min-width: 380px;         /* 最小宽度保证战阵显示 */
    max-width: 440px;         /* 最大宽度限制 */
    max-height: 75%;
    background: #f0e8dc;
    border: 1px solid #d4c8b8;
    border-radius: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 60px rgba(80, 60, 40, 0.2);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid #d8ccbc;
    font-size: clamp(16px, 2vw, 22px);
    font-weight: 500;
    color: #3a3a3a;
    flex-shrink: 0;
    background: #e8dcc8;
}

.panel-close {
    background: transparent;
    border: none;
    color: #8a8a8a;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.panel-close:hover {
    color: #3a3a3a;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    color: #6a6a6a;
    font-size: clamp(13px, 1.6vw, 18px);
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid #d8ccbc;
    flex-shrink: 0;
    background: #e8dcc8;
}

.panel-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #6a6a6a;
    padding: 8px 0;
    font-family: inherit;
    font-size: clamp(13px, 1.6vw, 18px);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-weight: 400;
}

.panel-tab:hover {
    color: #3a3a3a;
}

.panel-tab.active {
    color: #3a3a3a;
    border-bottom-color: #c8b888;
}


/* ==================== 遮罩层 ==================== */
#overlay {
    position: absolute;
    inset: 0;
    background: rgba(60, 50, 40, 0.3);
    z-index: 50;
    border-radius: 28px;
    backdrop-filter: blur(2px);
}


/* ==================== 设置按钮 ==================== */
.settings-inline {
    display: inline-block;
    background: #eadcc8;
    border: 1px solid #d0c4b0;
    color: #6a6a6a;
    padding: 4px 16px;
    margin: 4px 4px 4px 0;
    border-radius: 30px;
    font-family: inherit;
    font-size: clamp(13px, 1.6vw, 18px);
    cursor: pointer;
    transition: all 0.2s;
}

.settings-inline:hover {
    background: #f0e8dc;
    border-color: #b8a898;
    color: #3a3a3a;
}


/* ==================== 待开发返回按钮 ==================== */
#devBackBtn {
    display: block;
    margin: 0 auto;
    padding: 8px 32px;
    background: #eadcc8;
    border: 1px solid #d0c4b0;
    color: #6a6a6a;
    border-radius: 30px;
    font-family: inherit;
    font-size: clamp(13px, 1.6vw, 18px);
    cursor: pointer;
    transition: all 0.2s;
}

#devBackBtn:hover {
    background: #f0e8dc;
    border-color: #b8a898;
    color: #3a3a3a;
}


/* ==================== 滚动条 ==================== */
.panel-body::-webkit-scrollbar {
    width: 4px;
}
.panel-body::-webkit-scrollbar-track {
    background: transparent;
}
.panel-body::-webkit-scrollbar-thumb {
    background: #d0c4b0;
    border-radius: 4px;
}
.panel-body::-webkit-scrollbar-thumb:hover {
    background: #c0b4a0;
}

/* 光照叠加层（只对 #sceneArea 生效） */
#sceneArea {
    position: relative;
    overflow: hidden;
}

#sceneArea::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    transition: none;
}

/* 1-3月：冬末初春 · 冷，低角度（左上） */
.month-1 #sceneArea::after,
.month-2 #sceneArea::after,
.month-3 #sceneArea::after {
    background: radial-gradient(ellipse at 25% 70%, rgba(200, 220, 240, 0.25), transparent 60%);
}

/* 4-6月：春夏 · 暖，高角度（顶光） */
.month-4 #sceneArea::after,
.month-5 #sceneArea::after,
.month-6 #sceneArea::after {
    background: radial-gradient(ellipse at 50% 15%, rgba(255, 240, 210, 0.25), transparent 60%);
}

/* 7-9月：盛夏 · 暖，顶光偏强 */
.month-7 #sceneArea::after,
.month-8 #sceneArea::after,
.month-9 #sceneArea::after {
    background: radial-gradient(ellipse at 50% 5%, rgba(255, 235, 200, 0.30), transparent 60%);
}

/* 10-12月：秋冬 · 冷，低角度（右上） */
.month-10 #sceneArea::after,
.month-11 #sceneArea::after,
.month-12 #sceneArea::after {
    background: radial-gradient(ellipse at 75% 70%, rgba(180, 200, 220, 0.25), transparent 60%);
}

/* ========== 好友卡片（与战斗格子同尺寸 112×92） ========== */
.friend-card {
    width: 112px;
    height: 92px;
    background: rgba(220, 204, 184, 0.4);
    border: 1px solid #d0c4b0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    padding: 3px 4px 2px 4px;
    flex-shrink: 0;
    overflow: hidden;
}

.friend-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 14px;
    min-height: 14px;
    flex-shrink: 0;
}

.friend-card-emoji {
    font-size: 14px;
    line-height: 1;
}

.friend-card-name {
    font-size: 10px;
    color: #3a3a3a;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52px;
}

.friend-card-lv {
    font-size: 9px;
    color: #8a8a7a;
    font-weight: 400;
}

.friend-card-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    gap: 2px;
}

.friend-card-fragment {
    font-size: 9px;
    color: #6a6a5a;
    font-weight: 400;
}

.friend-card-bar {
    width: 100%;
    height: 4px;
    background: rgba(160, 140, 120, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.friend-card-bar-fill {
    height: 100%;
    background: #c8a86a;
    border-radius: 3px;
    transition: width 0.1s;
}

#friendList {
    display: grid;
    grid-template-columns: repeat(3, 112px);
    gap: 8px;
    justify-content: center;
    padding: 12px 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ========== 伙伴详情弹窗 ========== */
.friend-action-btn {
    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;
}

.friend-action-btn:hover:not([disabled]) {
    background: #eadcc8;
    border-color: #b8a898;
    color: #3a3a3a;
}

.friend-action-btn:active:not([disabled]) {
    transform: scale(0.95);
}

.friend-action-btn.active {
    background: #c8a86a;
    border-color: #b8985a;
    color: #ffffff;
}

.friend-action-btn.active:hover {
    background: #b8985a;
    border-color: #a8884a;
}

/* ========== 队伍面板 ========== */
.formation-btn {
    background: transparent;
    border: 1px solid #d0c4b0;
    color: #8a8a7a;
    padding: 2px 12px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.6;
}

.formation-btn:hover {
    background: rgba(220,204,184,0.3);
}

.formation-btn.active {
    background: #c8a86a;
    border-color: #b8985a;
    color: #ffffff;
}

.team-slot {
    background: rgba(220,204,184,0.3);
    border: 2px dashed #d0c4b0;
    border-radius: 12px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #8a8a7a;
    transition: all 0.2s;
    min-height: 60px;
    position: relative;
}

.team-slot.filled {
    border: 2px solid #c8a86a;
    background: rgba(200,168,106,0.15);
    cursor: grab;
}

.team-slot.drag-over {
    border-color: #7aaa6a;
    background: rgba(122,170,106,0.15);
}

.team-slot .slot-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
    padding: 4px;
}

.team-slot .slot-emoji {
    font-size: 24px;
    line-height: 1;
}

.team-slot .slot-name {
    font-size: 9px;
    color: #3a3a3a;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.team-slot .slot-lv {
    font-size: 8px;
    color: #8a8a7a;
}

.team-slot .slot-index {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 9px;
    color: #b8a898;
    font-weight: 400;
}

.team-ready-item {
    background: rgba(220,204,184,0.4);
    border: 1px solid #d0c4b0;
    border-radius: 12px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #3a3a3a;
    cursor: grab;
    transition: all 0.2s;
}

.team-ready-item:hover {
    background: rgba(220,204,184,0.6);
}

.team-ready-item .ready-emoji {
    font-size: 16px;
}

.team-ready-item .ready-name {
    font-size: 10px;
    font-weight: 500;
}

/* ========== 背包 ========== */
#inventoryGrid {
    display: grid;
    grid-template-columns: repeat(6, 48px);
    gap: 4px;
    justify-content: center;
    padding: 4px 0;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.inv-item {
    width: 48px;
    height: 52px;
    background: rgba(220, 204, 184, 0.3);
    border: 1px solid #d0c4b0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    transition: all 0.15s;
    box-sizing: border-box;
}

.inv-item:hover {
    background: rgba(220, 204, 184, 0.5);
    border-color: #b8a898;
}

.inv-item .inv-qty {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #3a3a3a;
    background: rgba(220, 204, 184, 0.8);
    padding: 0 4px;
    border-radius: 3px;
    line-height: 1.4;
    z-index: 1;
    pointer-events: none;
}

/* 确保 panel-body 可以滚动 */
#teamPanelBody {
    flex: 1;
    overflow-y: auto !important;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
}
/* 传送按钮 */
.transition-btn {
    background: rgba(60, 40, 20, 0.65) !important;
    border: none;
    border-radius: 8px;
    padding: 6px 10px !important;
    min-width: 55px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.transition-btn:hover {
    background: rgba(80, 55, 25, 0.8) !important;
    border-color: transparent;
}
.transition-btn .elem-icon { display: block; font-size: 1.1rem; margin-bottom: 1px; }
.transition-btn .elem-label { display: block; font-size: 0.6rem; color: #d4c4a0; letter-spacing: 1px; }

/* NPC 人形标签 */
.npc {
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    min-width: auto !important;
}
.npc .elem-icon { display: block; font-size: 1.5rem; text-align: center; margin-bottom: 1px; }
.npc .elem-label { 
    display: block; 
    background: rgba(60, 40, 20, 0.7); 
    border: 1px solid rgba(160, 120, 60, 0.4);
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 0.55rem; 
    color: #d4c4a0; 
    text-align: center;
    white-space: nowrap;
}

/* 公告栏描边 */
.npc .elem-icon[data-emoji="📋"] + .elem-label,
#sceneNpcs .npc:has(.elem-icon:contains('📋')) .elem-label {
    background: rgba(200, 180, 140, 0.3);
    border: 2px solid rgba(180, 140, 80, 0.6);
}

/* 公告栏特殊样式 */
.npc[data-type="interactable"] .elem-label {
    background: rgba(45, 30, 15, 0.7) !important;
    border: 2px solid rgba(180, 140, 80, 0.4) !important;
    color: #d4c4a0 !important;
}
/* 战斗触发样式 */
.npc[data-type="battle_trigger"] .elem-label {
    background: rgba(140, 40, 20, 0.6) !important;
    border-color: rgba(200, 80, 40, 0.5) !important;
}

/* NPC 去边框 */
.npc .elem-label { border: none !important; }
.npc[data-type="interactable"] .elem-label { border: 2px solid rgba(180, 140, 80, 0.3) !important; }

/* 玩家替换 */
#scenePlayer {
    background: rgba(60, 40, 20, 0.75) !important;
    border: none !important;
    border-radius: 8px;
    width: clamp(36px, 6vw, 46px) !important;
    height: clamp(44px, 8vw, 56px) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
#scenePlayer::before {
    content: '👦';
    font-size: 1.2rem;
}
#scenePlayer::after {
    content: '小虾';
    font-size: 0.5rem;
    color: #d4c4a0;
}

/* 去白色边框 */
.npc { outline: none !important; }
.npc .elem-icon { text-shadow: none !important; }
.elem-icon { outline: none !important; text-stroke: none !important; }
.npc * { outline: none !important; }
