* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    overflow: hidden;
    background: #000;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

.hud {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px;
    border-radius: 5px;
    min-width: 200px;
}

.panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    padding: 20px;
    border-radius: 10px;
    min-width: 400px;
    max-width: 600px;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.panel.hidden {
    display: none;
}

.panel h3 {
    margin-bottom: 15px;
    color: #4CAF50;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #ccc;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 14px;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin-right: 8px;
    margin-top: 8px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    margin-right: 5px;
    margin-top: 5px;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background: #0b7dda;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #da190b;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn.active {
    opacity: 0.8;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    line-height: 30px;
}

.close-btn:hover {
    color: #f44336;
}

.attribute-list {
    list-style: none;
    margin-top: 10px;
}

.attribute-item {
    padding: 8px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.attribute-item .key {
    font-weight: bold;
    color: #4CAF50;
}

.attribute-item .value {
    color: #ccc;
}

.dialog-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    min-width: 400px;
    max-width: 600px;
    border: 2px solid #4CAF50;
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.dialog-box.hidden {
    display: none;
}

.dialog-box .dialog-header {
    margin-bottom: 10px;
    border-bottom: 1px solid #4CAF50;
    padding-bottom: 10px;
    position: relative;
    cursor: move;
}

.dialog-box .dialog-controls {
    position: absolute;
    top: 5px;
    right: 5px;
}

.dialog-box .dialog-minimize-btn {
    background: rgba(76, 175, 80, 0.5);
    border: 1px solid #4CAF50;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 20px;
    text-align: center;
    padding: 0;
}

.dialog-box .dialog-minimize-btn:hover {
    background: rgba(76, 175, 80, 0.8);
}

.dialog-box .dialog-content {
    display: flex;
    flex-direction: column;
}

.dialog-box .dialog-title {
    color: #4CAF50;
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
}

.dialog-box .dialog-hint {
    color: #aaa;
    font-size: 12px;
}

.dialog-box .dialog-messages {
    flex: 1;
    overflow-y: auto;
    max-height: 250px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.dialog-box .dialog-message {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    line-height: 1.5;
    word-wrap: break-word;
}

.dialog-box .dialog-message.user {
    background: rgba(33, 150, 243, 0.3);
    border-left: 3px solid #2196F3;
    text-align: right;
}

.dialog-box .dialog-message.npc {
    background: rgba(76, 175, 80, 0.3);
    border-left: 3px solid #4CAF50;
}

.dialog-box .dialog-message.system {
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid #FF9800;
    color: #FF9800;
    font-size: 12px;
}

/* 确保消息内容完整显示 */
.dialog-box .dialog-message {
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-width: 100%;
}

.dialog-box .dialog-message span {
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.npc-name-link {
    word-wrap: normal !important;
    word-break: normal !important;
    white-space: nowrap !important;
}

.dialog-box .dialog-input-area {
    display: flex;
    gap: 10px;
    position: relative;
}

.dialog-box .dialog-input-wrapper {
    flex: 1;
    position: relative;
}

.npc-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #4CAF50;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 5px;
    z-index: 1000;
}

.npc-suggestions.hidden {
    display: none;
}

.npc-suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #fff;
    border-bottom: 1px solid rgba(76, 175, 80, 0.3);
}

.npc-suggestion-item:hover {
    background: rgba(76, 175, 80, 0.3);
}

.npc-suggestion-item:last-child {
    border-bottom: none;
}

.npc-suggestion-item.no-result {
    color: #aaa;
    cursor: default;
}

.npc-suggestion-item.no-result:hover {
    background: transparent;
}

.dialog-box .dialog-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #222;
    color: #fff;
    font-size: 14px;
}

.dialog-box .dialog-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.dialog-box .npc-name {
    color: #4CAF50;
    font-weight: bold;
    margin-bottom: 8px;
}

.dialog-box .dialog-text {
    line-height: 1.6;
}

.dialog-box .close-dialog {
    margin-top: 10px;
    text-align: right;
}

/* 对话框滚动条样式 */
.dialog-box .dialog-messages::-webkit-scrollbar {
    width: 6px;
}

.dialog-box .dialog-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.dialog-box .dialog-messages::-webkit-scrollbar-thumb {
    background: #4CAF50;
    border-radius: 3px;
}

.dialog-box .dialog-messages::-webkit-scrollbar-thumb:hover {
    background: #45a049;
}

/* NPC行为日志面板 */
.npc-behavior-log {
    position: absolute;
    top: 100px;
    right: 10px;
    width: 400px;
    max-height: 500px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #4CAF50;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    z-index: 1000;
    pointer-events: auto;
}

.npc-behavior-log .log-title {
    background: rgba(76, 175, 80, 0.3);
    padding: 10px 15px;
    font-weight: bold;
    border-bottom: 1px solid #4CAF50;
    color: #4CAF50;
}

.npc-behavior-log .log-content {
    max-height: 450px;
    overflow-y: auto;
    padding: 10px;
}

.npc-behavior-log .log-entry {
    padding: 8px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
    line-height: 1.5;
    word-wrap: break-word;
    transition: background 0.2s;
}

.npc-behavior-log .log-entry:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* 滚动条样式 */
.npc-behavior-log .log-content::-webkit-scrollbar {
    width: 6px;
}

.npc-behavior-log .log-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.npc-behavior-log .log-content::-webkit-scrollbar-thumb {
    background: #4CAF50;
    border-radius: 3px;
}

.npc-behavior-log .log-content::-webkit-scrollbar-thumb:hover {
    background: #45a049;
}

/* 标签页样式 */
.tab-btn {
    padding: 8px 16px;
    margin-right: 5px;
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid #4CAF50;
    color: #fff;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
}

.tab-btn.active {
    background: rgba(76, 175, 80, 0.6);
    border-bottom: none;
}

.tab-content {
    display: none;
    padding: 15px;
    border-top: 1px solid #4CAF50;
}

.tab-content.active {
    display: block;
}

/* 表格样式 */
.relationship-table, .trade-table, .letter-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.relationship-table th, .trade-table th, .letter-table th {
    background: rgba(76, 175, 80, 0.3);
    padding: 8px;
    text-align: left;
    border: 1px solid #4CAF50;
}

.relationship-table td, .trade-table td, .letter-table td {
    padding: 8px;
    border: 1px solid #555;
}

.relationship-table tr:hover, .trade-table tr:hover, .letter-table tr:hover {
    background: rgba(76, 175, 80, 0.1);
}

.positive {
    color: #4CAF50;
}

.negative {
    color: #f44336;
}

.unread {
    font-weight: bold;
    background: rgba(255, 193, 7, 0.2);
}

/* 帖子样式 */
.post-item {
    border: 1px solid #555;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
}

.post-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.post-time {
    color: #aaa;
    font-size: 12px;
}

.post-content {
    margin: 10px 0;
    line-height: 1.6;
}

.post-image, .post-video {
    margin: 10px 0;
    border-radius: 4px;
}

.post-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

.comment-item {
    padding: 8px;
    margin: 5px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.comment-time {
    color: #aaa;
    font-size: 11px;
    margin-left: 10px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .panel {
        width: 90vw !important;
        max-width: 90vw !important;
        max-height: 80vh !important;
        font-size: 14px;
        padding: 15px;
    }
    
    .hud {
        font-size: 12px;
        padding: 10px;
        min-width: 150px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
        margin: 5px;
    }
    
    .hud-section {
        margin-bottom: 10px;
    }
    
    #game-canvas {
        width: 100vw;
        height: 100vh;
    }
    
    .dialog-box {
        min-width: 90vw;
        max-width: 90vw;
        bottom: 10px;
        left: 5vw;
        transform: none;
    }
    
    .npc-behavior-log {
        width: 90vw;
        max-width: 90vw;
        right: 5vw;
        top: 100px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    .panel-header {
        min-height: 44px;
    }
    
    .close-btn {
        width: 44px;
        height: 44px;
        line-height: 44px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        min-height: 44px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
}
