/* 暗黑卷轴样式 */
.scroll-container {
    position: relative;
    margin: 50px auto;
    max-width: 900px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.magic-circle-scroll {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Ccircle cx='100' cy='100' r='90' stroke='%238a2be2' stroke-width='1' fill='none' stroke-dasharray='5,5'/%3E%3Ccircle cx='100' cy='100' r='80' stroke='%238a2be2' stroke-width='1' fill='none'/%3E%3Ccircle cx='100' cy='100' r='70' stroke='%238a2be2' stroke-width='1' fill='none'/%3E%3Cpath d='M100 10 L100 30 M100 170 L100 190 M170 100 L190 100 M10 100 L30 100' stroke='%238a2be2' stroke-width='1'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.3;
    z-index: 1;
    animation: rotate 60s linear infinite;
}

.scroll-wrapper {
    width: 100%;
    max-width: 800px;
    perspective: 1000px;
    z-index: 2;
}

.scroll {
    background-color: #2d1f17;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    position: relative;
    transform: rotateX(5deg);
    transition: transform 0.3s ease;
    border: 10px solid #4a3520;
}

.scroll:hover {
    transform: rotateX(0) translateY(-10px);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9), 0 0 30px rgba(138, 43, 226, 0.3);
}

.scroll::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    pointer-events: none;
}

.scroll-header {
    text-align: center;
    padding: 30px;
    border-bottom: 2px solid #8b0000;
    position: relative;
}

.scroll-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #8a2be2;
    margin-bottom: 15px;
}

.scroll-decoration {
    height: 3px;
    width: 100px;
    background: linear-gradient(90deg, transparent, #8a2be2, transparent);
    margin: 0 auto;
}

.scroll-content {
    padding: 40px;
    color: #d4c8b0;
    font-size: 1.1rem;
    line-height: 1.8;
    position: relative;
    min-height: 400px;
    max-height: 800px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.scroll-content::-webkit-scrollbar {
    width: 10px;
}

.scroll-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.scroll-content::-webkit-scrollbar-thumb {
    background: #8a2be2;
    border-radius: 5px;
}

.scroll-content::-webkit-scrollbar-thumb:hover {
    background: #9932cc;
}

/* 世界地图样式 */
.world-map {
    margin: 100px 0;
}

.map-container {
    background-color: var(--card-bg);
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 30px;
    box-shadow: var(--shadow);
    position: relative;
}

.map {
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .map {
        flex-direction: column;
        align-items: center;
    }
}

.map-legend {
    flex: 1;
    min-width: 250px;
    background-color: rgba(40, 20, 30, 0.7);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid rgba(138, 43, 226, 0.5);
}

.map-legend h3 {
    font-family: 'Cinzel', serif;
    color: #8a2be2;
    margin-bottom: 20px;
    text-align: center;
}

.map-legend ul {
    list-style: none;
}

.map-legend li {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 5px;
}

.map-legend li:hover {
    background-color: rgba(138, 43, 226, 0.2);
    transform: translateX(5px);
}

.location-marker {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    box-shadow: 0 0 10px currentColor;
}

.location-marker.abyss {
    background-color: #4b0082;
    color: #4b0082;
}

.location-marker.forest {
    background-color: #006400;
    color: #006400;
}

.location-marker.mountain {
    background-color: #696969;
    color: #696969;
}

.location-marker.desert {
    background-color: #d2b48c;
    color: #d2b48c;
}

.location-marker.city {
    background-color: #8b0000;
    color: #8b0000;
}

.map-image {
    flex: 3;
    position: relative;
    height: 400px;
    border-radius: 10px;
    overflow: hidden;
    background-color: #1a1a1a;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    transition: all 0.3s ease;
    cursor: pointer;
}

.map-image:hover {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.3);
}

.map-overlay {
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Cpath d='M200 100 L300 150 L200 200 L100 150 Z M200 200 L300 250 L200 300 L100 250 Z' stroke='%238a2be2' stroke-width='1' fill='none'/%3E%3Ccircle cx='200' cy='100' r='10' fill='%234b0082'/%3E%3Ccircle cx='300' cy='150' r='10' fill='%23006400'/%3E%3Ccircle cx='200' cy='200' r='10' fill='%23696969'/%3E%3Ccircle cx='100' cy='150' r='10' fill='%23d2b48c'/%3E%3Ccircle cx='200' cy='300' r='10' fill='%238b0000'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* 角色卡片样式 */
.characters {
    margin: 100px 0;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
}

.character-card {
    background-color: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.character-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 35px rgba(138, 43, 226, 0.4);
}

.character-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--primary);
    filter: grayscale(30%) contrast(1.2);
}

.character-card:hover .character-image {
    filter: grayscale(0%) contrast(1);
    transform: scale(1.05);
}

.character-info {
    padding: 20px;
}

.character-name {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 10px;
}

.character-role {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.character-bio {
    font-size: 0.9rem;
    color: var(--text-dark);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all 0.3s ease;
}

.character-card.expanded .character-bio {
    -webkit-line-clamp: unset;
    max-height: none;
}

.character-card.expanded .character-image {
    height: 400px;
    filter: grayscale(0%) contrast(1);
}

/* 背景遮罩 */
.character-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.character-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 关闭按钮 */
.close-character {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: #8b0000;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.character-card:hover .close-character {
    opacity: 1;
}

.character-card.expanded .close-character {
    opacity: 1;
}

/* 章节渐入动画 */
.lore-chapter {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.lore-chapter.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 魔法粒子效果 */
.magic-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

/* 地域详情模态框 */
#area-modal .modal-content {
    max-width: 900px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .scroll-content {
        padding: 20px;
        font-size: 1rem;
        /* 移动端适配：暗黑卷轴转为可滑动的垂直内容区 */
        max-height: none;
        overflow-y: visible;
    }
    
    .character-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
    
    .character-image {
        height: 200px;
    }
    
    .character-card.expanded {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .scroll-header h2 {
        font-size: 1.5rem;
    }
    
    .map-container {
        padding: 15px;
    }
    
    .map-legend {
        min-width: 100%;
    }
    
    .map-image {
        height: 300px;
    }
    
    .character-grid {
        grid-template-columns: 1fr;
    }
}

/* 角色详情展开样式 */
.character-card.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    background-color: var(--dark-bg);
    border: 2px solid var(--primary);
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.6);
    z-index: 1001;
    overflow-y: auto;
    padding: 30px;
    animation: characterExpand 0.5s ease-out;
    opacity: 1;
}

@keyframes characterExpand {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.character-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.character-overlay.active {
    display: block;
    opacity: 1;
}

.character-card .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.character-card.expanded .close-button {
    display: flex;
}

.character-card .close-button:hover {
    background-color: var(--secondary);
    transform: scale(1.1);
}

.character-bio.expanded {
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: 20px;
    color: #e0e0e0;
}

.character-ability {
    background-color: rgba(138, 43, 226, 0.1);
    padding: 15px;
    border-left: 3px solid var(--primary);
    margin: 20px 0;
}

.character-ability h4 {
    color: var(--primary);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
}

.character-quote {
    margin-top: 25px;
    padding: 15px;
    background-color: rgba(139, 0, 0, 0.1);
    border-left: 3px solid var(--secondary);
}

.character-quote blockquote {
    font-style: italic;
    color: #d0d0d0;
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
}

/* 魔法粒子效果 */
.magic-particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.magic-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

/* 章节动画 */
.chapter-fade-in {
    animation: chapterFadeIn 1s ease-out forwards;
    opacity: 0;
}

@keyframes chapterFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
        color: #333;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        color: var(--primary);
    }
}

.content-fade-in {
    animation: contentFadeIn 1s ease-out forwards;
    opacity: 0;
}

@keyframes contentFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滚动动画 */
.scroll-fade-in {
    animation: scrollFadeIn 1.5s ease-out forwards;
    opacity: 0;
}

@keyframes scrollFadeIn {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 确保初始状态下动画类不会生效 */
h3, .lore-chapter > p, .character-card, .map-container {
    opacity: 0;
}

/* 确保动画效果在延迟后生效 */
h2 {
    opacity: 0;
}

/* 添加一些悬停效果 */
.character-card:hover .character-info {
    transform: translateY(-10px);
}

.character-card:hover {
    box-shadow: 0 15px 30px rgba(138, 43, 226, 0.4);
}