/* 全新深黑红国风主题基调 */
@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=ZCOOL+XiaoWei&family=Noto+Serif+SC:wght@400;600;900&display=swap');

body {
    font-family: 'Noto Serif SC', 'STSong', serif;
    background-color: #1a1412;
}

/* 模拟中间卷宗的复古纸张纹理与明暗过度 */
.bg-paper {
    background-color: #e3d2be;
    background-image: 
        radial-gradient(ellipse at center, rgba(255,255,255,0.42) 0%, rgba(0,0,0,0) 68%),
        radial-gradient(ellipse at left center, rgba(92, 56, 32, 0.16) 0%, rgba(92, 56, 32, 0.08) 18%, rgba(0,0,0,0) 44%),
        radial-gradient(ellipse at right center, rgba(92, 56, 32, 0.18) 0%, rgba(92, 56, 32, 0.08) 18%, rgba(0,0,0,0) 46%),
        linear-gradient(90deg, rgba(48, 28, 18, 0.16) 0%, rgba(0,0,0,0) 4%, rgba(0,0,0,0) 96%, rgba(48, 28, 18, 0.18) 100%),
        url('https://www.transparenttextures.com/patterns/cream-paper.png');
}

.bg-paper::before {
    content: '';
    position: sticky;
    top: 0;
    display: block;
    height: 0;
    pointer-events: none;
    box-shadow: inset 0 0 80px rgba(56, 32, 20, 0.14);
}

/* 标题用马山正书法体，导航用小薇体，正文用思源宋体 */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', 'Noto Serif SC', serif !important;
}

/* 导航分类标题用小薇体 */
.nav-dark h3 {
    font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif !important;
}

.nav-dynasty-toggle {
    text-align: left;
    font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif !important;
}

.nav-caret {
    color: #b89a82;
    transition: transform 0.2s;
}

.nav-dynasty-group:not(.collapsed) .nav-caret {
    transform: rotate(90deg);
}

.nav-dynasty-group.collapsed .nav-dynasty-list {
    display: none;
}

/* 导航栏黑红质感定制 */
.nav-dark::-webkit-scrollbar {
    width: 3px;
}
.nav-dark::-webkit-scrollbar-thumb {
    background: #3e2c26; 
}

/* 自定义整体滚动条风格（古铜色） */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(140, 103, 83, 0.4); 
    border-radius: 0;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(140, 103, 83, 0.8); 
}
.custom-scrollbar-hide::-webkit-scrollbar {
    display: none;
}
.custom-scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 正文排版：模仿古书排布，去掉现代卡片阴影，用菱形标题点缀 */
.story-prose p {
    text-align: justify;
    text-justify: inter-ideograph;
    /* 覆盖掉数据源中可能带有的内联样式 */
    margin-bottom: 1.5rem !important;
    line-height: 2.2;
    position: relative;
    /* 增加段落首行缩进，更像中文排版 */
    text-indent: 2em;
}

/* 修复加粗样式：只有单独成段的首个 <b> 才是标题，普通文本中的 <b> 只加粗不变色不带横线 */
.story-prose b {
    font-weight: bold;
}

/* 专门针对段落开头（或行首）的小标题样式 */
.story-prose p > b:first-child {
    display: block;
    color: #5c1313;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    margin-top: 1rem;
    font-family: 'Ma Shan Zheng', serif;
    border-bottom: 1px dotted rgba(92, 19, 19, 0.3);
    padding-bottom: 0.3rem;
    text-indent: 0; /* 标题不需要首行缩进 */
}

/* 隐藏数据源中自带的硬换行符，避免标题和正文之间空行 */
.story-prose p > b:first-child + br {
    display: none;
}

/* 用 CSS 伪元素画一个赤红色的复古菱形代替原始标题符号 */
.story-prose p > b:first-child::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #8b2323;
    transform: rotate(45deg);
    margin-right: 12px;
    vertical-align: middle;
    margin-top: -2px;
}

.next-event-card {
    margin-top: 2.5rem;
    padding: 1rem 1.1rem;
    border-left: 2px solid #8b2323;
    background: rgba(255, 248, 239, 0.48);
    color: #35251a;
    text-indent: 0;
}

.next-event-card .next-event-label {
    color: #8b2323;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    margin-bottom: 0.4rem;
}

.next-event-card p {
    margin-bottom: 0.7rem !important;
    text-indent: 0;
    line-height: 1.8;
}

.next-event-card a {
    color: #5c1313;
    font-weight: 900;
    border-bottom: 1px solid rgba(92, 19, 19, 0.35);
}

.dynasty-skeleton {
    text-indent: 0;
}

.skeleton-hero {
    min-height: 18rem;
    margin-bottom: 2rem;
    padding: 2rem;
    display: flex;
    align-items: flex-end;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(92, 19, 19, 0.22);
    box-shadow: 0 18px 42px rgba(61, 39, 23, 0.18);
}

.skeleton-hero-content {
    max-width: 34rem;
    color: #f6eadb;
    text-shadow: 0 2px 18px rgba(0,0,0,0.45);
}

.skeleton-kicker {
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    margin-bottom: 0.45rem;
}

.skeleton-hero h2 {
    margin: 0 0 0.55rem;
    font-size: 2rem;
    line-height: 1.15;
    color: #f6d5b6;
}

.skeleton-hero p {
    margin: 0 !important;
    text-indent: 0;
    line-height: 1.75;
}

.skeleton-section {
    margin: 2rem 0;
}

.skeleton-section-title {
    color: #5c1313;
    font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
    font-size: 1.35rem;
    font-weight: 900;
    border-bottom: 1px dotted rgba(92, 19, 19, 0.28);
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

.skeleton-flow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
}

.skeleton-node {
    position: relative;
    min-height: 9.2rem;
    border: 1px solid rgba(92, 19, 19, 0.24);
    border-left: 3px solid #8b2323;
    background: rgba(255, 248, 239, 0.56);
    padding: 0.85rem;
    color: #35251a;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: transform 0.18s, border-color 0.18s, background 0.18s;
}

.skeleton-node:hover {
    transform: translateY(-2px);
    border-color: rgba(92, 19, 19, 0.58);
    background: rgba(255, 248, 239, 0.78);
}

.skeleton-node-index {
    color: #8b2323;
    font-weight: 900;
    font-size: 0.74rem;
    letter-spacing: 0.08em;
}

.skeleton-node-stage {
    color: #8c7a66;
    font-size: 0.72rem;
    font-weight: 800;
}

.skeleton-node strong {
    color: #5c1313;
    font-size: 1rem;
}

.skeleton-node span:last-child {
    color: #705d4d;
    font-size: 0.78rem;
    line-height: 1.55;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.85rem;
}

.skeleton-card {
    border: 1px solid rgba(140, 103, 83, 0.28);
    background: rgba(253, 250, 245, 0.58);
    padding: 1rem;
    color: #35251a;
}

.skeleton-card-crack {
    border-left: 3px solid #8b2323;
}

.skeleton-card-title {
    color: #5c1313;
    font-weight: 900;
    margin-bottom: 0.45rem;
}

.skeleton-card p {
    margin: 0 !important;
    text-indent: 0;
    line-height: 1.8;
    font-size: 0.9rem;
}

.skeleton-takeaway {
    border-left: 2px solid #8b2323;
    background: rgba(255, 248, 239, 0.45);
    padding: 1rem 1.25rem;
}

.skeleton-takeaway ol {
    margin: 0;
    padding-left: 1.2rem;
    line-height: 1.9;
}

.skeleton-takeaway li {
    padding-left: 0.25rem;
}

.answer-mode-panel {
    border-top: 1px dashed rgba(140, 122, 102, 0.45);
    padding-top: 0.75rem;
}

.answer-mode-label {
    color: #8c7a66;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    margin-bottom: 0.5rem;
}

.answer-mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.answer-mode-option {
    border: 1px solid rgba(92, 19, 19, 0.28);
    background: rgba(245, 239, 232, 0.72);
    color: #5c1313;
    padding: 0.65rem 0.75rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.55rem;
    text-align: left;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.answer-mode-option:hover,
.answer-mode-option.active {
    background: #f5efe8;
    border-color: rgba(92, 19, 19, 0.6);
    box-shadow: 0 0 0 2px rgba(92, 19, 19, 0.06);
}

.answer-mode-icon {
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #5c1313;
    font-weight: 800;
}

.answer-mode-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1.2;
}

.answer-mode-option.active .answer-mode-title::after {
    content: '✓';
    margin-left: auto;
    color: #5c1313;
}

.answer-mode-desc {
    display: block;
    margin-top: 0.15rem;
    color: #8c7a66;
    font-size: 0.68rem;
    line-height: 1.25;
}

.chat-use-hint {
    color: #8c7a66;
    font-size: 0.72rem;
    line-height: 1.5;
}

.feedback-open-btn {
    width: 100%;
    border: 1px solid rgba(240, 201, 168, 0.45);
    background: rgba(92, 19, 19, 0.28);
    color: #f0c9a8;
    padding: 0.7rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: center;
}

.sidebar-feedback {
    border-top: 1px dashed #4a362f;
    padding: 0.85rem 1rem 1rem;
    background: #16110f;
}

.sidebar-community {
    border: 1px solid rgba(240, 201, 168, 0.22);
    background: rgba(240, 201, 168, 0.06);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.sidebar-community-label {
    color: #b89a82;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    margin-bottom: 0.45rem;
}

.qq-group-btn {
    width: 100%;
    border: 1px solid rgba(240, 201, 168, 0.5);
    background: rgba(139, 35, 35, 0.42);
    color: #f0c9a8;
    padding: 0.6rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 900;
    text-align: center;
}

.qq-group-btn:hover {
    border-color: #f0c9a8;
    background: rgba(139, 35, 35, 0.62);
}

.sidebar-community-note {
    margin-top: 0.45rem;
    color: #8c7a66;
    font-size: 0.68rem;
    line-height: 1.45;
}

.feedback-open-btn:hover {
    border-color: #f0c9a8;
    background: rgba(139, 35, 35, 0.55);
}

#site-toast {
    position: fixed;
    top: 4.5rem;
    left: 50%;
    z-index: 100;
    transform: translate(-50%, -10px);
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(240, 201, 168, 0.55);
    background: rgba(22, 17, 15, 0.96);
    color: #f0c9a8;
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 800;
    box-shadow: 0 12px 36px rgba(0,0,0,0.35);
    transition: opacity 0.18s, transform 0.18s;
}

#site-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.feedback-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 1rem;
    background: rgba(12, 8, 7, 0.35);
}

.feedback-modal.hidden {
    display: none;
}

.feedback-card {
    width: min(24rem, calc(100vw - 2rem));
    position: relative;
    border: 1px solid rgba(140, 103, 83, 0.45);
    border-left: 3px solid #8b2323;
    background: #efe4d4;
    color: #35251a;
    padding: 1rem;
    box-shadow: 0 18px 60px rgba(0,0,0,0.35);
}

.feedback-close-btn {
    position: absolute;
    right: 0.6rem;
    top: 0.45rem;
    color: #8b2323;
    font-size: 1.35rem;
    line-height: 1;
}

.feedback-title {
    color: #5c1313;
    font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.feedback-copy,
.feedback-email-link {
    color: #705d4d;
    font-size: 0.82rem;
    line-height: 1.7;
}

.feedback-email-link {
    display: inline-block;
    color: #8b2323;
    margin: 0.4rem 0 0.6rem;
    text-decoration: underline;
}

.feedback-email-link.hidden {
    display: none;
}

.feedback-card textarea,
.feedback-card input {
    width: 100%;
    border: 1px solid rgba(140, 122, 102, 0.45);
    background: #f8f2e9;
    color: #35251a;
    padding: 0.7rem 0.8rem;
    outline: none;
    margin-top: 0.6rem;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.feedback-card textarea {
    resize: vertical;
    min-height: 7rem;
}

.feedback-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin-top: 0.8rem;
}

#feedback-status {
    color: #705d4d;
    font-size: 0.78rem;
    line-height: 1.4;
}

#feedback-submit-btn {
    border: 1px solid #8b2323;
    background: #8b2323;
    color: #fff;
    padding: 0.55rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 800;
    flex-shrink: 0;
}

.game-panel {
    border-left: 2px solid rgba(92, 19, 19, 0.45);
    background: rgba(255, 248, 239, 0.42);
    padding: 1rem;
    margin-bottom: 1rem;
}

.game-panel-title {
    color: #5c1313;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 0.45rem;
}

.game-copy {
    color: #705d4d;
    font-size: 0.86rem;
    line-height: 1.8;
}

.game-setup-row,
.guess-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.6rem;
    margin-top: 0.9rem;
}

.game-setup-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.game-setup-row input,
.guess-input-row input {
    background: #f5efe8;
    border: 1px solid rgba(140, 122, 102, 0.45);
    color: #35251a;
    padding: 0.7rem 0.8rem;
    outline: none;
}

.game-setup-row button,
.guess-input-row button,
.guess-answer-actions button,
.game-secondary-btn {
    border: 1px solid #8b2323;
    color: #8b2323;
    background: rgba(245, 239, 232, 0.72);
    padding: 0.55rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 800;
}

.game-setup-row button,
.guess-input-row button:last-child,
.guess-answer-actions button {
    background: #8b2323;
    color: #fff;
}

.game-status-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.game-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.guess-my-person {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(140, 122, 102, 0.35);
    background: rgba(253, 250, 245, 0.58);
    color: #5c1313;
    font-size: 0.86rem;
    font-weight: 800;
    padding: 0.35rem 0.6rem;
    margin: 0.15rem 0 0.45rem;
}

.guess-log {
    min-height: 18rem;
    max-height: 26rem;
    overflow-y: auto;
    border-top: 1px dashed rgba(140, 122, 102, 0.45);
    border-bottom: 1px dashed rgba(140, 122, 102, 0.45);
    margin: 1rem 0;
    padding: 0.8rem 0;
    display: grid;
    gap: 0.6rem;
}

.guess-log-item {
    max-width: 82%;
    padding: 0.65rem 0.8rem;
    border: 1px solid rgba(140, 122, 102, 0.35);
    background: rgba(253, 250, 245, 0.65);
    color: #35251a;
    line-height: 1.65;
    font-size: 0.9rem;
}

.guess-log-item.user {
    justify-self: end;
}

.guess-log-item.ai {
    border-color: rgba(92, 19, 19, 0.28);
}

.guess-log-item.system {
    justify-self: center;
    max-width: 90%;
    color: #8c7a66;
    background: transparent;
}

.guess-answer-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    margin-bottom: 0.8rem;
}

.game-panel button:disabled,
.guess-input-row input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* 气泡样式重写（脱离色块感，融入整体背景） */
.chat-bubble-user {
    background: transparent !important;
    border: 1px solid rgba(140, 103, 83, 0.3);
    color: #35251a !important;
    border-radius: 4px !important;
    box-shadow: none !important;
}

.chat-bubble-ai {
    background: #fdfaf5 !important;
    border: 1px solid rgba(92, 19, 19, 0.2) !important;
    border-radius: 2px !important;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.02) !important;
    color: #35251a !important;
}

.message-selectable {
    cursor: pointer;
}

.message-selectable .chat-bubble-user,
.message-selectable .chat-bubble-ai {
    transition: border-color 0.2s, box-shadow 0.2s;
}

.message-selectable:hover .chat-bubble-user,
.message-selectable:hover .chat-bubble-ai,
.message-selectable.message-active .chat-bubble-user,
.message-selectable.message-active .chat-bubble-ai {
    border-color: rgba(92, 19, 19, 0.55) !important;
    box-shadow: 0 0 0 2px rgba(92, 19, 19, 0.08) !important;
}

/* 动画部分保持不变 */
@keyframes fadeInSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.bubble-enter {
    animation: fadeInSlideUp 0.3s ease-out forwards;
}

@keyframes ellipsis {
  to { width: 1.25em; }
}
#chat-spinner.active {
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
    animation: ellipsis steps(4,end) 1.5s infinite;
    content: "\2026";
    width: 0px;
}

/* ======== 移动端响应式布局 ======== */
@media (max-width: 1023px) {
    #mobile-topbar {
        display: flex !important;
    }

    .mobile-feedback-top-btn {
        border: 1px solid rgba(240, 201, 168, 0.55);
        background: rgba(139, 35, 35, 0.42);
        color: #f0c9a8;
        padding: 0.35rem 0.55rem;
        font-size: 0.72rem;
        font-weight: 800;
        letter-spacing: 0.06em;
        line-height: 1.1;
        min-width: 2.7rem;
    }

    .mobile-topbar-actions {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

    .mobile-feedback-top-btn:active {
        background: rgba(139, 35, 35, 0.68);
    }

    #mobile-tabs {
        display: flex !important;
    }

    #mobile-tabs button {
        min-width: 0;
        line-height: 1.25;
    }

    #main-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 45;
        transform: translateX(-100%);
        width: 260px;
    }

    #main-sidebar.mobile-open {
        transform: translateX(0);
    }

    #nav-container {
        overscroll-behavior: contain;
        padding-bottom: 100px !important;
    }

    #mobile-sidebar-overlay.mobile-open {
        display: block !important;
    }

    #story-section,
    #chat-section {
        display: none;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        bottom: 48px;
        width: 100%;
    }

    #story-section.mobile-active,
    #chat-section.mobile-active {
        display: flex;
    }

    #story-section.mobile-active {
        display: block;
    }

    #story-container {
        padding: 1.5rem 1rem 5rem 1rem !important;
    }

    #story-title {
        font-size: 1.5rem !important;
    }

    #story-image-container {
        height: 12rem !important;
    }

    .story-prose {
        font-size: 15px !important;
    }

    .story-prose p > b:first-child {
        font-size: 1.1rem !important;
    }

    .skeleton-hero {
        min-height: 14rem;
        margin-bottom: 1.5rem;
        padding: 1.2rem;
        background-position: center right;
    }

    .skeleton-kicker {
        font-size: 0.68rem;
    }

    .skeleton-hero h2 {
        font-size: 1.45rem;
        line-height: 1.25;
    }

    .skeleton-hero p {
        font-size: 0.86rem;
        line-height: 1.65;
    }

    .skeleton-section {
        margin: 1.45rem 0;
    }

    .skeleton-section-title {
        font-size: 1.15rem;
    }

    .skeleton-flow,
    .skeleton-grid {
        grid-template-columns: 1fr;
    }

    .skeleton-node {
        min-height: auto;
    }

    .skeleton-takeaway {
        padding: 0.9rem 1rem;
    }

    #chat-section header {
        padding: 1rem 1rem 0.75rem 1rem !important;
    }

    #chat-section header h2 {
        font-size: 1.25rem !important;
    }

    #chat-history-container {
        padding: 1rem !important;
    }

    #chat-section footer {
        padding: 0.75rem !important;
    }

    #chat-form {
        gap: 0.5rem !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .game-setup-row,
    .guess-input-row {
        grid-template-columns: 1fr;
    }

    .game-status-row {
        display: grid;
    }

    .game-actions {
        justify-content: flex-start;
    }

    #chat-input {
        padding: 0.6rem 0.75rem !important;
        font-size: 16px !important;
    }

    #chat-submit {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        font-size: 0.75rem !important;
    }

    #character-buttons {
        gap: 0.375rem !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    #character-buttons button {
        padding: 0.25rem 0.625rem !important;
        font-size: 0.7rem !important;
    }

    #btn-clear-chat {
        padding: 0.25rem 0.625rem !important;
        font-size: 0.65rem !important;
    }

    .chat-bubble-user,
    .chat-bubble-ai {
        max-width: 92% !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
    }

    .feedback-modal {
        align-items: center;
    }
}
