/* =========================================================
   破凡劫 · 水墨淡金主题设计系统 (theme_xianxia.css)
   阶段一·改：明亮水墨纸色为主，彻底避免阴森深黑。
   所有图形均为 SVG/CSS 生成，无 AI 图片 URL。
   ========================================================= */

/* ---------- 根变量：明亮水墨淡金调色板 ---------- */
:root {
    /* 墨色（只用于文字、细线，不用作大面积背景） */
    --xx-ink-900: #2b2318;
    --xx-ink-700: #4a4034;
    --xx-ink-500: #6b6050;
    --xx-ink-300: #9a8f7a;

    /* 淡金 */
    --xx-gold-100: #fff8e1;
    --xx-gold-200: #f3e5ab;
    --xx-gold-300: #e8c96a;
    --xx-gold-400: #d4a843;
    --xx-gold-500: #b8860b;
    --xx-gold-600: #8b6914;

    /* 宣纸 */
    --xx-paper-100: #f7f4ed;
    --xx-paper-200: #efe9da;
    --xx-paper-300: #e6dec9;
    --xx-paper-400: #d9ceba;

    /* 辅助 */
    --xx-red: #c45c3e;
    --xx-green: #5a8f5a;
    --xx-cyan: #6aa8b8;
    --xx-purple: #8a7ab8;

    /* 透明度 */
    --xx-ink-10: rgba(43, 35, 24, 0.10);
    --xx-ink-20: rgba(43, 35, 24, 0.20);
    --xx-ink-40: rgba(43, 35, 24, 0.40);
    --xx-gold-15: rgba(184, 134, 11, 0.15);
    --xx-gold-25: rgba(184, 134, 11, 0.25);
    --xx-gold-40: rgba(184, 134, 11, 0.40);
    --xx-gold-60: rgba(184, 134, 11, 0.60);

    /* 便捷别名 */
    --xx-gold: var(--xx-gold-500);
    --xx-ink: var(--xx-ink-900);
    --xx-paper: var(--xx-paper-100);
    --xx-text: var(--xx-ink-900);
    --xx-text-muted: #7a6e5a;

    /* 尺寸 */
    --xx-radius-sm: 6px;
    --xx-radius: 10px;
    --xx-radius-lg: 16px;
    --xx-safe-top: env(safe-area-inset-top, 0px);
    --xx-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 宣纸纹理背景 ---------- */
.xx-paper-bg,
#xianxia-main {
    background:
        radial-gradient(circle at 20% 8%, rgba(184, 134, 11, 0.06) 0%, transparent 32%),
        radial-gradient(circle at 85% 92%, rgba(106, 168, 184, 0.04) 0%, transparent 28%),
        linear-gradient(180deg, #f7f4ed 0%, #f3efe6 55%, #efe9da 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
    background-blend-mode: normal, normal, normal, overlay;
}

/* ---------- 全局覆盖 ---------- */
body,
#xianxia-main {
    color: var(--xx-text);
    font-family: "STKaiti", "KaiTi", "楷体", "华文楷体", "PingFang SC", "Microsoft YaHei", serif;
}

/* ---------- 卷轴金边 ---------- */
.xx-scroll-top,
.xx-scroll-bottom { position: relative; }
.xx-scroll-top::before,
.xx-scroll-bottom::after {
    content: "";
    position: absolute;
    left: 5%;
    width: 90%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--xx-gold-40), transparent);
    pointer-events: none;
}
.xx-scroll-top::before { top: 0; }
.xx-scroll-bottom::after { bottom: 0; }

/* ---------- 印章 ---------- */
.xx-stamp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border: 1px solid var(--xx-red);
    color: var(--xx-red);
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    background: rgba(196, 92, 62, 0.08);
    box-shadow: inset 0 0 4px rgba(196, 92, 62, 0.12);
    transform: rotate(-2deg);
}
.xx-stamp-gold {
    border-color: var(--xx-gold-500);
    color: var(--xx-gold-600);
    background: var(--xx-gold-15);
    box-shadow: inset 0 0 4px var(--xx-gold-25);
}

/* ---------- 按钮体系 ---------- */
.xx-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--xx-radius);
    font-size: 13px;
    line-height: 1;
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
    background: linear-gradient(180deg, #fffdf7, #f7f3e8);
    color: var(--xx-ink-700);
    border: 1px solid var(--xx-gold-25);
    box-shadow: 0 2px 8px rgba(43, 35, 24, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.xx-btn:active { transform: translateY(1px) scale(0.98); }
.xx-btn-primary {
    background: linear-gradient(135deg, var(--xx-gold-400), var(--xx-gold-500));
    color: #fff;
    border-color: var(--xx-gold-300);
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.xx-btn-primary:active { background: linear-gradient(135deg, var(--xx-gold-500), var(--xx-gold-600)); }
.xx-btn-ghost {
    background: transparent;
    border-color: var(--xx-gold-40);
    color: var(--xx-ink-700);
}
.xx-btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--xx-radius-sm); }
.xx-btn-circle {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
}

/* ---------- 卡片 ---------- */
.xx-card {
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(247, 244, 237, 0.96));
    border: 1px solid var(--xx-gold-25);
    border-radius: var(--xx-radius);
    padding: 12px;
    box-shadow: 0 4px 14px rgba(43, 35, 24, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(6px);
}
.xx-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--xx-gold-600);
    margin-bottom: 8px;
    letter-spacing: 1px;
}
.xx-card-sub { font-size: 12px; color: var(--xx-text-muted); }

/* ---------- 面板通用 ---------- */
.xx-panel {
    background:
        radial-gradient(circle at 50% 0%, var(--xx-gold-15) 0%, transparent 45%),
        linear-gradient(180deg, rgba(255, 253, 247, 0.96) 0%, rgba(247, 244, 237, 0.98) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    color: var(--xx-text);
    border: 1px solid var(--xx-gold-25);
    border-radius: var(--xx-radius);
}
.xx-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--xx-gold-25);
    background: linear-gradient(90deg, transparent, var(--xx-gold-15), transparent);
}
.xx-panel-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--xx-gold-600);
    letter-spacing: 2px;
}

/* ---------- 统一弹窗 ---------- */
.xx-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(43, 35, 24, 0.45);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.xx-modal-overlay.active { display: flex; }
.xx-modal {
    width: min(520px, 100%);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.xx-modal-body {
    padding: 16px;
    overflow-y: auto;
    font-size: 14px;
    color: var(--xx-ink-700);
    line-height: 1.7;
}
.xx-modal-close {
    background: transparent;
    border: 1px solid var(--xx-gold-25);
    color: var(--xx-text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.xx-modal-close:hover { color: var(--xx-ink-900); border-color: var(--xx-gold-40); }

/* =========================================================
   旧密集主界面隐藏（保留 DOM 供 app.js 填充数据）
   ========================================================= */
#game-screen {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -100 !important;
    overflow: hidden !important;
}
#game-screen #top-bar,
#game-screen .todo-strip,
#game-screen #bottom-nav,
#game-screen .cult-page-v4,
#game-screen .cult-main-v4,
#game-screen .cult-controls-v4,
#game-screen .cult-func-row,
#game-screen .cult-func-row2,
#game-screen .cult-breakthrough-v4,
#game-screen .cult-event-v4,
#game-screen .cult-todo-v4,
#game-screen .cult-info-v4,
#game-screen .cult-progress-v4,
#game-screen.hidden { display: none !important; }

/* =========================================================
   新主屏壳：#xianxia-main
   ========================================================= */
#xianxia-main {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding-top: var(--xx-safe-top);
    padding-bottom: var(--xx-safe-bottom);
    overflow: hidden;
}
#xianxia-main.hidden { display: none !important; }

/* ---------- 顶部状态栏 ---------- */
.xx-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(247, 244, 237, 0.88));
    border-bottom: 1px solid var(--xx-gold-25);
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}
.xx-topbar::after {
    content: "";
    position: absolute;
    left: 5%;
    bottom: 0;
    width: 90%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--xx-gold-40), transparent);
}
.xx-player-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.xx-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--xx-gold-300), var(--xx-gold-500));
    border: 2px solid var(--xx-gold-400);
    box-shadow: 0 0 12px var(--xx-gold-25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.xx-avatar svg { width: 22px; height: 22px; color: #fff; }
.xx-player-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.xx-player-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--xx-ink-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.xx-player-realm {
    font-size: 11px;
    color: var(--xx-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.xx-resources {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: center;
    min-width: 0;
}
.xx-res-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--xx-ink-700);
    white-space: nowrap;
}
.xx-res-item svg { width: 14px; height: 14px; color: var(--xx-gold-500); flex-shrink: 0; }
.xx-res-item em { font-style: normal; font-weight: 700; color: var(--xx-ink-900); }
.xx-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.xx-top-actions .xx-btn-circle {
    width: 34px;
    height: 34px;
    background: rgba(255, 253, 247, 0.8);
    border-color: var(--xx-gold-25);
}
.xx-top-actions .xx-btn-circle svg { width: 18px; height: 18px; }

/* ---------- 中部修炼区 ---------- */
.xx-cultivate-stage {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 14px;
}

/* 水墨山水背景：淡墨远山、米白天空 */
.xx-landscape {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(circle at 50% 25%, rgba(184, 134, 11, 0.10) 0%, transparent 40%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300' preserveAspectRatio='xMidYMid slice'%3E%3Cdefs%3E%3ClinearGradient id='sky' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23f7f4ed'/%3E%3Cstop offset='55%25' stop-color='%23f0ece2'/%3E%3Cstop offset='100%25' stop-color='%23e6dec9'/%3E%3C/linearGradient%3E%3ClinearGradient id='mt' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%239a8f7a' stop-opacity='0.35'/%3E%3Cstop offset='100%25' stop-color='%23e6dec9' stop-opacity='0.85'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='400' height='300' fill='url(%23sky)'/%3E%3Cpath d='M0 220 C60 180,100 160,160 190 C220 220,260 150,320 170 C360 185,380 210,400 200 L400 300 L0 300 Z' fill='url(%23mt)'/%3E%3Cpath d='M-20 250 C50 230,120 210,200 240 C280 270,340 230,420 260 L420 300 L-20 300 Z' fill='%23d9ceba' opacity='0.85'/%3E%3Ccircle cx='320' cy='60' r='28' fill='%23d4a843' opacity='0.10'/%3E%3Cpath d='M60 100 Q80 70,100 100 T140 100' fill='none' stroke='%23b8860b' stroke-width='0.6' opacity='0.16'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
    opacity: 0.9;
}
.xx-landscape::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, transparent 30%, var(--xx-paper-100) 95%);
}

/* 角色占位 */
.xx-character {
    position: relative;
    z-index: 1;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 40% 30%, rgba(184, 134, 11, 0.18), transparent 55%),
        radial-gradient(circle at 50% 50%, #fffdf7, #f3efe6);
    border: 2px solid var(--xx-gold-40);
    box-shadow: 0 0 30px var(--xx-gold-25), inset 0 0 20px rgba(184, 134, 11, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}
.xx-character svg { width: 64px; height: 64px; color: var(--xx-gold-500); opacity: 0.9; }

/* 修为卷轴进度条 */
.xx-exp-scroll {
    position: relative;
    z-index: 1;
    width: min(520px, 86vw);
    margin-bottom: 18px;
}
.xx-exp-scroll-bar {
    height: 14px;
    border-radius: 7px;
    background: var(--xx-paper-300);
    border: 1px solid var(--xx-gold-25);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(43, 35, 24, 0.12);
}
.xx-exp-scroll-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--xx-gold-500), var(--xx-gold-300), var(--xx-gold-400));
    box-shadow: 0 0 12px var(--xx-gold-40);
    transition: width 0.4s ease;
    position: relative;
}
.xx-exp-scroll-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: xx-shimmer 2.2s infinite linear;
}
.xx-exp-scroll-text {
    text-align: center;
    font-size: 12px;
    color: var(--xx-ink-700);
    margin-top: 6px;
    letter-spacing: 1px;
}

/* 总战力 */
.xx-power {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 18px;
    font-size: 13px;
    color: var(--xx-text-muted);
    letter-spacing: 1px;
}
.xx-power em {
    font-style: normal;
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: transparent;
    background: linear-gradient(90deg, var(--xx-gold-500), var(--xx-gold-300), var(--xx-gold-500));
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 2px 8px rgba(184, 134, 11, 0.18);
}

/* 修炼动作按钮 */
.xx-cult-actions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: min(540px, 90vw);
}
.xx-cult-actions .xx-btn { min-width: 76px; padding: 10px 18px; font-size: 14px; }
.xx-cult-actions .xx-btn-primary { min-width: 90px; font-size: 15px; }

/* ---------- 底部 Dock ---------- */
.xx-dock {
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(247, 244, 237, 0.98));
    border-top: 1px solid var(--xx-gold-25);
    padding: 10px 12px calc(10px + var(--xx-safe-bottom));
    position: relative;
    z-index: 30;
}
.xx-dock::before {
    content: "";
    position: absolute;
    left: 5%;
    top: 0;
    width: 90%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--xx-gold-40), transparent);
}
.xx-dock-primary,
.xx-dock-daily {
    display: flex;
    justify-content: space-around;
    gap: 8px;
}
.xx-dock-daily {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(184, 134, 11, 0.18);
}
.xx-dock-btn {
    flex: 1;
    max-width: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 2px;
    border-radius: var(--xx-radius);
    background: transparent;
    border: 1px solid transparent;
    color: var(--xx-text-muted);
    cursor: pointer;
    transition: all 0.18s ease;
}
.xx-dock-btn svg { width: 22px; height: 22px; color: currentColor; }
.xx-dock-btn span { font-size: 11px; white-space: nowrap; }
.xx-dock-btn:active,
.xx-dock-btn.active {
    color: var(--xx-gold-600);
    background: var(--xx-gold-15);
    border-color: var(--xx-gold-25);
    transform: translateY(-2px);
}
.xx-dock-btn.xx-dock-more { position: relative; }
.xx-dock-btn.xx-dock-more::after {
    content: "";
    position: absolute;
    right: 2px;
    top: 2px;
    width: 6px;
    height: 6px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}
.xx-dock-btn.xx-dock-more.open::after { transform: rotate(-135deg); top: 6px; }

/* 更多抽屉 */
.xx-dock-drawer {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, padding 0.28s ease;
}
.xx-dock-drawer.open { max-height: 220px; padding-top: 10px; margin-top: 8px; border-top: 1px dashed rgba(184, 134, 11, 0.18); }
.xx-dock-drawer .xx-dock-btn { max-width: none; }

/* ---------- 今日事项胶囊 ---------- */
.xx-today-capsule {
    position: relative;
    z-index: 20;
    margin: 8px 14px 0;
    padding: 6px 12px;
    background: rgba(255, 253, 247, 0.88);
    border: 1px solid var(--xx-gold-25);
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--xx-text-muted);
    overflow-x: auto;
    scrollbar-width: none;
}
.xx-today-capsule::-webkit-scrollbar { display: none; }
.xx-today-capsule .xx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--xx-gold-400); flex-shrink: 0; }
.xx-today-capsule .xx-item { white-space: nowrap; }
.xx-today-capsule .xx-item.done { opacity: 0.55; text-decoration: line-through; }

/* ---------- 动画 ---------- */
@keyframes xx-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
@keyframes xx-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes xx-glow-pulse {
    0%, 100% { box-shadow: 0 0 18px var(--xx-gold-25); }
    50% { box-shadow: 0 0 28px var(--xx-gold-40); }
}
.xx-character { animation: xx-float 4s ease-in-out infinite, xx-glow-pulse 3s ease-in-out infinite; }

/* ---------- 响应式 ---------- */
@media (max-width: 380px) {
    .xx-resources { gap: 8px; }
    .xx-res-item { font-size: 11px; }
    .xx-res-item svg { width: 12px; height: 12px; }
    .xx-dock-btn svg { width: 20px; height: 20px; }
    .xx-dock-btn span { font-size: 10px; }
}
@media (min-width: 520px) {
    .xx-dock { padding-left: max(12px, calc(50% - 260px)); padding-right: max(12px, calc(50% - 260px)); }
}
