* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'SimSun', serif;
    overflow: hidden;
    background: #1a0f0a;
    color: #d4af6e;
}

/* 场景容器 */
.scene-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 背景区域 */
.background-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.background-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.background-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c1810 0%, #1a0f0a 100%);
    border: 3px dashed #8b6f47;
    color: #8b6f47;
    font-size: 24px;
    font-weight: bold;
}

/* 渐隐渐现动画 */
.fade-in {
    animation: fadeIn 1s ease-in-out forwards;
}

.fade-out {
    animation: fadeOut 1s ease-in-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* 对话框容器 */
.dialog-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50vh;
    max-height: 50vh;
    z-index: 10;
    padding: 8px 15px 10px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    animation: slideUp 0.5s ease-out;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* 对话框主体 */
.dialog-box {
    position: relative;
    width: 95%;
    max-width: 1200px;
    height: 100%;
    max-height: calc(50vh - 18px);
    background: linear-gradient(to bottom, rgba(245, 230, 211, 0.5) 0%, rgba(232, 212, 184, 0.5) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 3px solid rgba(139, 69, 19, 0.6);
    border-radius: 6px;
    padding: 10px 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.15),
        inset 0 -2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 中国传统边框装饰 */
.dialog-border-top,
.dialog-border-bottom {
    position: absolute;
    left: 12px;
    right: 12px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(139, 69, 19, 0.8) 10%, rgba(139, 69, 19, 0.8) 90%, transparent 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dialog-border-top {
    top: 10px;
}

.dialog-border-bottom {
    bottom: 10px;
}

.dialog-border-left,
.dialog-border-right {
    position: absolute;
    top: 12px;
    bottom: 12px;
    width: 2px;
    background: linear-gradient(180deg, transparent 0%, rgba(139, 69, 19, 0.8) 10%, rgba(139, 69, 19, 0.8) 90%, transparent 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dialog-border-left {
    left: 10px;
}

.dialog-border-right {
    right: 10px;
}

/* 对话框标题 */
.dialog-title {
    font-size: 16px;
    font-weight: bold;
    color: #8b4513;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 2px 2px 6px rgba(255, 255, 255, 0.9), 1px 1px 3px rgba(0, 0, 0, 0.6);
    border-bottom: 2px solid rgba(139, 69, 19, 0.6);
    padding: 6px 8px;
    background: rgba(245, 230, 211, 0.3);
    border-radius: 4px;
    flex-shrink: 0;
}

/* 对话框内容 */
.dialog-content {
    font-size: 14px;
    line-height: 1.5;
    color: #3d2817;
    margin-bottom: 10px;
    text-align: justify;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 4px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.08);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.dialog-content.typing {
    cursor: pointer;
}

.dialog-content.typing::after {
    content: '▋';
    animation: blink 1s infinite;
    color: #8b4513;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* 自定义滚动条样式 */
.dialog-content::-webkit-scrollbar {
    width: 6px;
}

.dialog-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.dialog-content::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.5);
    border-radius: 3px;
}

.dialog-content::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 69, 19, 0.7);
}

.dialog-box::-webkit-scrollbar {
    width: 6px;
}

.dialog-box::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.dialog-box::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.5);
    border-radius: 3px;
}

.dialog-box::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 69, 19, 0.7);
}

.dialog-content p {
    margin: 0.3em 0;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8), 0 1px 1px rgba(0, 0, 0, 0.3);
    font-weight: 500;
}

.dialog-content p:first-child {
    margin-top: 0;
}

.dialog-content p:last-child {
    margin-bottom: 0;
}

/* 角色标识样式 */
.dialog-role {
    display: block;
    font-size: 15px;
    font-weight: bold;
    color: #8b4513;
    margin: 0.5em 0 0.2em 0;
    letter-spacing: 1px;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8), 1px 1px 2px rgba(0, 0, 0, 0.4);
}

.dialog-role:first-child {
    margin-top: 0;
}

.dialog-role + p {
    margin-top: 0.2em;
}

/* 打字机效果 */
.typewriter {
    overflow: hidden;
    border-right: 2px solid #8b4513;
    white-space: nowrap;
    animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: #8b4513;
    }
}

/* 输入选项区域 */
.input-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
    flex-grow: 0;
}

/* 选项按钮 */
.option-btn {
    flex: 1;
    min-width: 120px;
    max-width: 300px;
    padding: 8px 16px;
    font-size: 13px;
    font-family: 'Microsoft YaHei', 'SimSun', serif;
    color: #f5e6d3;
    background: linear-gradient(135deg, #8b4513 0%, #6b3410 100%);
    border: 2px solid #d4af6e;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
}

.option-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
    border-color: #f5e6d3;
    background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
}

.option-btn:hover::before {
    left: 100%;
}

.option-btn:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.option-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .dialog-container {
        padding: 8px 10px;
        max-height: 25vh;
    }

    .dialog-box {
        width: 98%;
        padding: 10px 14px;
        max-height: calc(25vh - 16px);
    }

    .dialog-title {
        font-size: 14px;
        padding: 5px 6px;
        margin-bottom: 6px;
    }

    .dialog-content {
        font-size: 12px;
        padding: 6px 8px;
        max-height: calc(25vh - 120px);
    }

    .dialog-role {
        font-size: 13px;
    }

    .option-btn {
        min-width: 100%;
        padding: 6px 12px;
        font-size: 12px;
    }

    .input-options {
        gap: 8px;
        margin-top: 6px;
        flex-direction: column;
    }
}

/* 加载动画 */
.loading {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.loading.active {
    opacity: 1;
}

/* 模式切换按钮 */
.mode-switch-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    font-size: 12px;
    font-family: 'Microsoft YaHei', 'SimSun', serif;
    color: #f5e6d3;
    background: linear-gradient(135deg, #8b4513 0%, #6b3410 100%);
    border: 2px solid #d4af6e;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mode-switch-btn:hover {
    background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
    transform: translateY(-1px);
}

/* 对话输入容器 */
.chat-input-container {
    margin-top: 10px;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    font-family: 'Microsoft YaHei', 'SimSun', serif;
    color: #3d2817;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(139, 69, 19, 0.6);
    border-radius: 4px;
    outline: none;
    transition: all 0.3s ease;
}

.chat-input:focus {
    border-color: #8b4513;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 8px rgba(139, 69, 19, 0.3);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-family: 'Microsoft YaHei', 'SimSun', serif;
    font-weight: bold;
    color: #f5e6d3;
    background: linear-gradient(135deg, #8b4513 0%, #6b3410 100%);
    border: 2px solid #d4af6e;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    letter-spacing: 1px;
    min-width: 80px;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
    border-color: #f5e6d3;
    background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
}

.send-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 加载指示器 */
.loading-indicator {
    margin-top: 8px;
    padding: 8px;
    text-align: center;
    font-size: 13px;
    color: #8b4513;
    background: rgba(245, 230, 211, 0.5);
    border-radius: 4px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

.loading-indicator::before {
    content: '⏳ ';
    margin-right: 5px;
}

/* 响应式设计 - 对话输入 */
@media (max-width: 768px) {
    .chat-input {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .send-btn {
        font-size: 12px;
        padding: 8px 16px;
        min-width: 70px;
    }
    
    .mode-switch-btn {
        font-size: 11px;
        padding: 5px 10px;
        top: 5px;
        right: 5px;
    }
    
    .loading-indicator {
        font-size: 12px;
        padding: 6px;
    }
}