/* ============================================================
   世界游戏聊天界面 - ChatGPT 风格
   ============================================================ */

/* 聊天页容器：固定在导航栏下方铺满可视区域，页面整体不滚动，两个头部都固定 */
#worldgame-chat-page {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    flex-direction: column;
    overflow: hidden;
}

/* 聊天背景：角色卡配置了 chat_background 时由 JS 添加 .has-chat-bg */
#worldgame-chat-page.has-chat-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 有聊天背景时给消息区加半透明遮罩+模糊，保证文字可读（毛玻璃效果） */
#worldgame-chat-page.has-chat-bg #chat-messages {
    background: rgba(13, 12, 10, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* 会话列表项 */
.wg-session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border: 1px solid transparent;
    background: rgba(255,255,255,0.045);
    color: rgba(255,255,255,0.85);
}

.wg-session-item:hover {
    background: rgba(255,255,255,0.09);
}

.wg-session-active {
    background: rgba(0,145,255,0.14);
    border-color: rgba(0,145,255,0.35);
}

.wg-session-active .wg-session-title {
    color: #fff;
}

.wg-session-act {
    opacity: 0.55;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    color: rgba(255,255,255,0.35);
    padding: 0;
}

.wg-session-item:hover .wg-session-act {
    opacity: 1;
}

.wg-session-edit:hover {
    background: rgba(0,145,255,0.15);
    color: #4da6ff;
}

.wg-session-del:hover {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
}

/* 消息行 */
.wg-msg {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    max-width: 768px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

.wg-msg + .wg-msg {
    border-top: 1px solid rgba(255,255,255,0.04);
}

/* 头像 */
.wg-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.wg-avatar-ai {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
}

.wg-avatar-user {
    background: linear-gradient(135deg, #29ccb9, #0091ff);
    color: #fff;
}

/* 用户消息：右对齐 */
.wg-msg-user {
    flex-direction: row-reverse;
}

/* 消息体 */
.wg-msg-body {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(255,255,255,0.88);
}

.wg-msg-body-user {
    text-align: right;
}

.wg-msg-body-ai {
    color: rgba(255,255,255,0.88);
}

/* 叙述中的 { } 系统/环境描写层 */
.wg-inline-env {
    color: rgba(125, 211, 200, 0.85);
}

.wg-msg-error {
    color: #ef4444;
}

/* 选项区域 */
.wg-choices {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wg-choices-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.wg-choice-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wg-choice-btn:hover {
    background: rgba(0,145,255,0.08);
    border-color: rgba(0,145,255,0.3);
    color: #fff;
}

.wg-choice-btn:active {
    transform: scale(0.99);
}

/* 属性面板 */
#char-attributes-panel {
    transition: all 0.2s ease;
}

.wg-attr-row {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.wg-attr-row:last-child {
    border-bottom: none;
}

.wg-attr-label {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    margin-bottom: 2px;
    font-weight: 500;
}

.wg-attr-value {
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    line-height: 1.5;
    word-break: break-all;
}

/* 属性标签 */
.wg-attr-tag {
    display: inline-block;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    margin: 1px 2px 1px 0;
    color: rgba(255,255,255,0.7);
}

.wg-attr-tag-primary {
    background: rgba(0,145,255,0.1);
    color: #4da6ff;
}

.wg-attr-tag-obj {
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.6);
}

/* 进度条 */
.wg-bar {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    letter-spacing: -1px;
    margin-right: 4px;
}

.wg-bar-low { color: #ef4444; }
.wg-bar-mid { color: #f59e0b; }
.wg-bar-high { color: #22c55e; }

/* 输入区域容器 */
.wg-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 8px 8px 8px 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.wg-input-wrap:focus-within {
    border-color: rgba(0,145,255,0.4);
    background: rgba(255,255,255,0.06);
    box-shadow: 0 0 0 1px rgba(0,145,255,0.15), 0 10px 28px -14px rgba(0,145,255,0.35);
}

/* 输入框 */
#chat-input {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    max-height: 180px;
    resize: none;
    background: transparent;
    border: none;
    padding: 9px 0;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255,255,255,0.9);
    outline: none;
    box-shadow: none;
}

#chat-input::placeholder {
    color: rgba(255,255,255,0.22);
}

/* 发送按钮 */
.wg-send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 12px;
    background: var(--gradient);
    background-size: 200% 200%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px -4px rgba(0,145,255,0.55);
}

.wg-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px -4px rgba(0,145,255,0.7);
    animation: gradientShift 3s ease infinite;
}

.wg-send-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.wg-send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.35;
    box-shadow: none;
}

/* 输入提示 */
.wg-input-hint {
    margin-top: 6px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.02em;
    color: rgba(255,255,255,0.22);
    user-select: none;
}

/* 系统提示 */
.wg-system-hint {
    background: rgba(0,145,255,0.04);
    border: 1px solid rgba(0,145,255,0.12);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 12px;
    color: rgba(0,145,255,0.7);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 滚动条 */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.15);
}

#char-attributes-panel::-webkit-scrollbar {
    width: 4px;
}

#char-attributes-panel::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
}

/* 世界设定区块（属性面板内） */
.wg-world-section {
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.03);
}

.wg-world-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.wg-world-header:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.wg-world-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    opacity: 0.5;
}

.wg-world-section.open .wg-world-chevron {
    transform: rotate(90deg);
}

.wg-world-body {
    display: none;
    padding: 4px 10px 10px;
    font-size: 12px;
    line-height: 1.7;
    color: rgba(255,255,255,0.72);
    white-space: pre-wrap;
    word-break: break-word;
}

.wg-world-section.open .wg-world-body {
    display: block;
}

.wg-world-body strong {
    color: rgba(255,255,255,0.92);
    font-weight: 600;
}

.wg-world-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    background: rgba(255,255,255,0.07);
    border-radius: 4px;
    padding: 1px 4px;
}

/* ============================================================
   AI 输出标签渲染（聊天消息内的标签面板）
   ============================================================ */

/* 折叠面板包装：与消息列同宽对齐 */
.wg-output-panel {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 20px 14px;
}

/* 时间 · 地点信息卡（常显） */
.wg-output-timeloc {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 20px 14px;
}

.wg-output-timeloc-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(0,145,255,0.65);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.wg-output-timeloc-body {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.7;
    color: rgba(255,255,255,0.85);
    white-space: pre-wrap;
    word-break: break-word;
}

/* cd_info 系统信息卡（小字弱化，与正文区分） */
.wg-cd-info {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 20px 10px;
}

.wg-cd-info-title {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.wg-cd-info-body {
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 11px;
    line-height: 1.65;
    color: rgba(255,255,255,0.55);
    white-space: pre-wrap;
    word-break: break-word;
}

/* cd_tips 系统提示条 */
.wg-cd-tips {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 20px 14px;
    font-size: 11px;
    line-height: 1.65;
    color: rgba(255,180,90,0.75);
}

/* ============================================================
   编辑精选 - 斜卡片扇形效果（storycrafter 风格）
   ============================================================ */
.worldgame-picks-section {
    margin: 8px 0 30px;
}

/* 卡片背后：分段描述文字缓慢向左滑动（车窗外的风景） */
.worldgame-picks {
    position: relative;
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-top: 44px;      /* 给滑入动画留空间 */
    min-height: 300px;
    margin-bottom: 60px;
    margin-top: -45px;
}

.worldgame-picks-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    z-index: 0;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}

.wg-bg-line {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
}

.wg-marquee {
    display: inline-block;
    white-space: nowrap;
    color: rgba(255,255,255,0.13);
    font-weight: 600;
    letter-spacing: 4px;
    line-height: 1.25;
    animation: wgScenery var(--dur, 30s) linear infinite;
    will-change: transform;
}

.wg-marquee-main {
    color: rgba(0,145,255,0.30);
    letter-spacing: 6px;
    text-shadow: 0 0 24px rgba(0,145,255,0.15);
}

@keyframes wgScenery {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.pick-slot {
    width: min(190px, 22vw);
    margin: 0 -14px;                       /* 底部重叠，形成扇形 */
    transform-origin: 50% 130%;            /* 轴心在卡片底边之下 → 扇形展开 */
    transform: translateY(34px) rotateZ(var(--tilt, 0deg));
    animation: pickSlide .6s cubic-bezier(.16,1,.3,1) calc(var(--picks-index, 0) * 90ms) backwards;
    will-change: transform;
    z-index: calc(10 - var(--picks-index, 0));
    transition: transform .22s cubic-bezier(.16,1,.3,1), z-index .22s;
}

.pick-slot:hover {
    transform: translateY(8px) rotateZ(0deg);
    z-index: 20;
}

@keyframes pickSlide {
    0% {
        transform: translateY(90px) rotateX(-14deg) rotateZ(var(--tilt, 0deg)) scaleY(.92);
        opacity: 0;
    }
    100% {
        transform: translateY(34px) rotateX(0deg) rotateZ(var(--tilt, 0deg)) scaleY(1);
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .worldgame-picks {
        min-height: 200px;
        padding-top: 30px;
    }
    .pick-slot {
        width: min(150px, 26vw);
        margin: 0 -10px;
    }
}

/* ============================================================
   顶部导航 - 无背景按钮 hover 优化
   不再出现白边框，改为文字底部白色下滑线从左侧缓慢延伸至按钮宽度
   ============================================================ */
.nav-tabs .btn {
    position: relative;
    border-color: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    --btn-border: transparent;
    --btn-border-style: none;
    --btn-inset: 0 0 0 0 transparent;
    --btn-shadow: 0 0 0 0 transparent;
}

.nav-tabs .btn:hover {
    --btn-bg: transparent;
    --btn-border: transparent;
    --btn-border-style: none;
    --btn-inset: 0 0 0 0 transparent;
    --btn-shadow: 0 0 0 0 transparent;
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.nav-tabs .btn::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
    opacity: .8;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .5s cubic-bezier(.16,1,.3,1);
}

.nav-tabs .btn:hover::after {
    transform: scaleX(1);
}

/* 移动端头部不展示名字 */
@media (max-width: 640px) {
    #nav-nickname { display: none !important; }
}

/* 剧情规则面板 */
.wg-rule-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    line-height: 1.6;
}
.wg-rule-k {
    color: rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
}
.wg-rule-v {
    color: rgba(255, 255, 255, 0.85);
    text-align: right;
    word-break: break-all;
}
.wg-rule-progress {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin-top: 3px;
}
.wg-rule-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #22d3ee, #6366f1);
    transition: width 0.4s ease;
}
.wg-rule-progress-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    text-align: right;
    margin-top: 2px;
}
