/* ========================================================= */
/* --- 1. 字体与全局·南明残阳 (动态战火背景) --- */
/* ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&family=Noto+Serif+SC:wght@600;900&display=swap');

body {
    min-height: 100vh;
    background: #120a05;  /* 焦土玄墨 */
    font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
    padding: 20px 12px;
    margin: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* 多层次战火/烟尘动态图案 */
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(180, 60, 30, 0.2) 0%, transparent 35%),
        radial-gradient(circle at 85% 70%, rgba(200, 120, 30, 0.18) 0%, transparent 40%),
        repeating-linear-gradient(45deg, rgba(120, 40, 20, 0.06) 0px, rgba(120, 40, 20, 0.06) 3px, transparent 3px, transparent 12px),
        url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M15 70 Q35 30 55 55 T85 45" stroke="%23b35e2e" fill="none" stroke-width="1.2" opacity="0.2"/><circle cx="30" cy="80" r="8" fill="%23993322" opacity="0.12"/><path d="M70 20 L90 25 L80 45 L60 30 Z" fill="%238b4513" opacity="0.1"/><text x="10" y="25" font-family="Arial" font-size="18" fill="%23b87a4a" opacity="0.2">⚔️</text><text x="70" y="85" font-family="Arial" font-size="22" fill="%23a0522d" opacity="0.15">🏹</text></svg>');
    background-size: 220px 220px, 260px 260px, auto, 150px 150px;
    background-blend-mode: overlay;
    animation: warDrift 30s infinite alternate ease-in-out;
}

@keyframes warDrift {
    0% { background-position: 0% 0%, 100% 100%, 0 0, 0 0; }
    100% { background-position: 8% 10%, 92% 90%, 30px 20px, 25px 35px; }
}

/* 气泡基底 —— 仿古军册残页 */
.cinnamoroll-bubble {
    position: relative;
    margin: 30px 2px;
    border-radius: 16px 4px 16px 4px;
    font-family: 'Noto Sans SC', sans-serif;
    transition: all 0.2s ease-in-out;
    background: #fbf3e6;      /* 牙色宣纸 */
    color: #2c1e12;           /* 深褐，极致清晰 */
    border: 1.5px solid #b35e2e;
    box-shadow: 0 8px 0 #3b1e0e, 0 12px 24px rgba(0,0,0,0.5), inset 0 0 0 1px #efd5b5;
    backdrop-filter: blur(2px);
    word-break: break-word;
}

.cinnamoroll-content {
    padding: 18px 16px !important;
    position: relative;
    z-index: 2;
}

/* ========================================================= */
/* --- 2. AI气泡：南明·史笔如铁 (系统/说书人) 赤金紫气 --- */
/* ========================================================= */
.cinnamoroll-bubble.ai-bubble {
    background: linear-gradient(145deg, #fdf4e3, #f0ddc8);
    border-left: 8px solid #7a2e1a;      /* 凝血暗红 */
    border-right: 1px solid #b87a4a;
    box-shadow: 0 6px 0 #4a1e0e, 0 12px 24px #00000080, inset 0 0 0 1px #ebd5b0;
}

.cinnamoroll-bubble.ai-bubble::before {
    content: "📜 南明邸报 · 史笔如铁";
    position: absolute;
    top: -26px; left: 0px;
    font-size: 14px;
    font-weight: bold;
    color: #f0d5b0;
    background: #5a2a1a;
    padding: 3px 16px 3px 10px;
    border-radius: 30px 8px 0 0;
    border-left: 4px solid #b3470b;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.4);
    letter-spacing: 2px;
    text-shadow: 1px 1px 0 #2a0e05;
}

.cinnamoroll-bubble.ai-bubble::after {
    content: '⚔️';
    position: absolute;
    bottom: 5px; right: 10px;
    font-size: 24px;
    color: #7a2e1a;
    opacity: 0.3;
    z-index: 1;
    transform: rotate(15deg);
}

/* ========================================================= */
/* --- 3. User气泡：义军·铁血丹心 (玩家/墨柒) 烽火朱砂 --- */
/* ========================================================= */
.cinnamoroll-bubble.user-bubble {
    background: #fcf2e2;
    border-right: 8px solid #9e3d0e;      /* 烽火赤 */
    border-left: 1px solid #b87a4a;
    box-shadow: 0 6px 0 #4a1e0e, 0 12px 24px #00000080, inset 0 0 0 1px #ebd5b0;
}

.cinnamoroll-bubble.user-bubble::before {
    content: "🏮 义军·从军状";
    position: absolute;
    top: -26px; right: 0px;
    font-size: 14px;
    font-weight: bold;
    color: #fce4c8;
    background: #6b2a12;
    padding: 3px 10px 3px 16px;
    border-radius: 8px 30px 0 0;
    border-right: 4px solid #d46b2e;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.4);
    letter-spacing: 2px;
    text-shadow: 1px 1px 0 #2a0e05;
}

.cinnamoroll-bubble.user-bubble::after {
    content: '義';
    position: absolute;
    top: 8px; left: 10px;
    font-size: 20px;
    font-family: 'Noto Serif SC', serif;
    font-weight: 900;
    color: #c0392b;                /* 朱砂红，醒目 */
    border: 2px solid #c0392b;
    padding: 2px 6px;
    border-radius: 2px;
    opacity: 0.85;
    z-index: 1;
    background: #fbf3e6cc;
    box-shadow: 0 2px 6px #00000040;
    text-shadow: none;
}

/* ========================================================= */
/* --- 4. 消息文本 —— 绝对清晰，变色字体高对比 --- */
/* ========================================================= */
.inazuma-message-text {
    font-size: 16px;
    line-height: 1.8;
    text-align: justify;
    overflow-wrap: break-word;
    word-wrap: break-word;
    color: #2c1e12;   /* 深褐，极致清晰 */
}

/* 加粗：忠烈·朱砂红 */
.inazuma-message-text strong {
    color: #c0392b !important;
    font-weight: 800;
    text-shadow: 0 0 1px #ffdddd;
}

/* 斜体：谋略·冷月蓝 (清冽) */
.inazuma-message-text em {
    color: #1a5f6b !important;
    font-style: italic;
    font-weight: 500;
}

/* 加粗斜体：天命·赤金 (奢华) */
.inazuma-message-text strong em,
.inazuma-message-text em strong {
    color: #b8860b !important;
    text-shadow: 0 0 4px #f1cf9b;
    font-weight: 800;
}

/* 标题：浓墨重彩 */
.inazuma-message-text h1,
.inazuma-message-text h2,
.inazuma-message-text h3 {
    color: #1a0e0b !important;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 4px;
    margin: 12px 0 8px;
    font-family: 'Noto Serif SC', serif;
    font-weight: 700;
}

/* 删除线：城破/殉国 */
.inazuma-message-text del {
    color: #7f6e5d;
    text-decoration: line-through;
}

/* ========================================================= */
/* --- 5. 代码块：军策·武备志 (清晰仿古) --- */
/* ========================================================= */
pre {
    margin: 16px 0px !important;
    padding: 34px 12px 10px 12px !important;
    background: #e8d6c0 !important;
    border-radius: 6px 2px 6px 2px;
    border: 1.5px solid #8b4513;
    position: relative;
    overflow-x: auto;
    box-shadow: inset 0 0 15px #00000020, 0 4px 0 #5a2a1a;
}

pre::before {
    content: "📖 军策·秘本";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 28px;
    background: #7a3e1e;
    color: #f5e1c8;
    font-size: 13px;
    font-weight: bold;
    line-height: 28px;
    padding-left: 12px;
    border-bottom: 2px solid #4a1e0e;
    letter-spacing: 2px;
    border-radius: 4px 0 0 0;
}

pre code {
    font-family: 'Consolas', 'Courier New', monospace !important;
    font-size: 14px !important;
    color: #1c0e06 !important;
    font-weight: 600 !important;
    line-height: 1.6 !important;
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
}

pre code strong { color: #c0392b !important; }
pre code em { color: #1a5f6b !important; }

/* ========================================================= */
/* --- 6. 引用块：檄文/遗言 --- */
/* ========================================================= */
blockquote {
    margin: 14px 0;
    padding: 14px 18px;
    background: #e8d6c0d0;
    border-left: 6px solid #8b4513;
    color: #2c1a0c !important;
    font-weight: 600 !important;
    font-size: 15px;
    font-style: italic;
    border-radius: 0 20px 20px 0;
    box-shadow: inset 0 0 10px #b4925a;
}

blockquote strong { color: #b3470b !important; }

/* 分割线：烽烟 */
hr {
    border: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #8b3a1e, #c96b3c, #8b3a1e, transparent);
    margin: 24px 0;
    opacity: 0.8;
}

/* 链接 */
a {
    color: #8b4513;
    font-weight: bold;
    text-decoration: underline wavy #b8860b;
}

/* ========================================================= */
/* --- 7. 移动端优化 (手机完美适配) --- */
/* ========================================================= */
@media (max-width: 600px) {
    body { padding: 16px 8px; }
    .cinnamoroll-bubble { margin: 22px 2px; }
    .cinnamoroll-content { padding: 14px 12px !important; }
    .cinnamoroll-bubble::before { top: -22px; font-size: 12px; }
    .inazuma-message-text { font-size: 15px; }
}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>明末风播放器 - 古筝定制版</title>
    <style>
        body {
            /* 页面背景装饰，实际使用时可删除。使用水墨灰作为底色测试透明度 */
            background-color: #e4e0d8; 
            background-image: repeating-linear-gradient(45deg, #dcd8d0 25%, transparent 25%, transparent 75%, #dcd8d0 75%, #dcd8d0), repeating-linear-gradient(45deg, #dcd8d0 25%, #e4e0d8 25%, #e4e0d8 75%, #dcd8d0 75%, #dcd8d0);
            background-position: 0 0, 10px 10px;
            background-size: 20px 20px;
            margin: 0;
            padding: 0;
        }

        /* --- 古筝悬浮按钮 (完全透明，不遮挡文字) --- */
        #player-trigger {
            position: fixed;
            left: 20px; 
            top: 50%;
            transform: translateY(-50%);
            /* 尺寸适配古筝修长的比例 */
            width: 40px;
            height: 75px;
            background-color: transparent; 
            border: none;
            z-index: 1000;
            cursor: pointer;
            transition: left 0.5s cubic-bezier(0.25, 1, 0.25, 1);

            /* 古筝 SVG 图案：水墨黛黑/紫檀色 */
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 120'%3E%3C!-- 琴体轮廓 --%3E%3Cpath d='M15,10 Q30,5 45,10 L50,110 Q30,115 10,110 Z' fill='none' stroke='rgba(50, 40, 35, 0.9)' stroke-width='3'/%3E%3C!-- 琴弦 --%3E%3Cline x1='18' y1='10' x2='20' y2='110' stroke='rgba(50, 40, 35, 0.6)' stroke-width='1.5'/%3E%3Cline x1='24' y1='10' x2='26' y2='110' stroke='rgba(50, 40, 35, 0.6)' stroke-width='1.5'/%3E%3Cline x1='30' y1='9' x2='32' y2='111' stroke='rgba(50, 40, 35, 0.6)' stroke-width='1.5'/%3E%3Cline x1='36' y1='10' x2='38' y2='110' stroke='rgba(50, 40, 35, 0.6)' stroke-width='1.5'/%3E%3Cline x1='42' y1='10' x2='44' y2='110' stroke='rgba(50, 40, 35, 0.6)' stroke-width='1.5'/%3E%3C!-- 琴码 (雁柱) --%3E%3Cpath d='M16,30 L22,32 M22,45 L28,47 M28,60 L34,62 M34,75 L40,77 M40,90 L46,92' stroke='rgba(50, 40, 35, 0.9)' stroke-width='2.5' stroke-linecap='round'/%3E%3C!-- 琴头/尾装饰线 --%3E%3Cpath d='M14,20 L46,20 M12,100 L48,100' stroke='rgba(50, 40, 35, 0.9)' stroke-width='2'/%3E%3C/svg%3E");
            background-size: contain; 
            background-repeat: no-repeat;
            background-position: center;

            /* 抚琴的轻微律动感 */
            animation: zheng-float 3s infinite alternate ease-in-out;
            user-select: none; 
        }

        @keyframes zheng-float {
            0% { transform: translateY(-50%) scale(1); filter: drop-shadow(0 0 2px rgba(50, 40, 35, 0.3)); }
            100% { transform: translateY(-52%) scale(1.05); filter: drop-shadow(0 4px 6px rgba(50, 40, 35, 0.5)); }
        }

        /* 悬停时：明末特有的“朱砂暗红” */
        #player-trigger:hover {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 120'%3E%3Cpath d='M15,10 Q30,5 45,10 L50,110 Q30,115 10,110 Z' fill='rgba(139, 26, 26, 0.05)' stroke='rgba(139, 26, 26, 0.9)' stroke-width='3'/%3E%3Cline x1='18' y1='10' x2='20' y2='110' stroke='rgba(139, 26, 26, 0.6)' stroke-width='1.5'/%3E%3Cline x1='24' y1='10' x2='26' y2='110' stroke='rgba(139, 26, 26, 0.6)' stroke-width='1.5'/%3E%3Cline x1='30' y1='9' x2='32' y2='111' stroke='rgba(139, 26, 26, 0.6)' stroke-width='1.5'/%3E%3Cline x1='36' y1='10' x2='38' y2='110' stroke='rgba(139, 26, 26, 0.6)' stroke-width='1.5'/%3E%3Cline x1='42' y1='10' x2='44' y2='110' stroke='rgba(139, 26, 26, 0.6)' stroke-width='1.5'/%3E%3Cpath d='M16,30 L22,32 M22,45 L28,47 M28,60 L34,62 M34,75 L40,77 M40,90 L46,92' stroke='rgba(139, 26, 26, 0.9)' stroke-width='2.5' stroke-linecap='round'/%3E%3Cpath d='M14,20 L46,20 M12,100 L48,100' stroke='rgba(139, 26, 26, 0.9)' stroke-width='2'/%3E%3C/svg%3E");
            filter: drop-shadow(0 0 10px rgba(139, 26, 26, 0.6));
        }

        /* --- 明末风 播放器面板 --- */
        #player-panel {
            position: fixed;
            left: -320px; 
            top: 50%;
            transform: translateY(-50%);
            width: 320px;
            /* 材质：紫檀黑/水墨底色 */
            background: rgba(30, 26, 24, 0.95);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(139, 26, 26, 0.3);
            border-left: none;
            box-shadow: 8px 0 25px rgba(0,0,0,0.6);
            border-radius: 0 8px 8px 0;
            z-index: 999;
            transition: left 0.5s cubic-bezier(0.25, 1, 0.25, 1);
            overflow: hidden;
            font-family: "KaiTi", "STKaiti", "Microsoft YaHei", serif; /* 默认楷体，更符合明代刻本风格 */
        }

        #player-panel.active {
            left: 0;
        }

        .panel-header {
            background-color: #8b1a1a; /* 朱砂红 */
            color: #e8e0d0; /* 宣纸白 */
            padding: 16px;
            font-size: 16px;
            font-weight: bold;
            text-align: center;
            letter-spacing: 5px; /* 增加字间距，提升古意 */
            border-bottom: 2px solid #4a1515;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }

        .playlist {
            list-style: none;
            padding: 0;
            margin: 0;
            max-height: 400px; 
            overflow-y: auto;
        }

        .playlist li {
            padding: 14px 20px;
            border-bottom: 1px dashed rgba(232, 224, 208, 0.15); /* 虚线宛如旧纸折痕 */
            cursor: pointer;
            font-size: 15px;
            color: #b5aba0; /* 暗宣纸色 */
            transition: all 0.3s;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .playlist li:hover {
            background-color: rgba(139, 26, 26, 0.15); /* 悬停泛起暗红 */
            color: #e8e0d0;
            padding-left: 25px; /* 悬停时文字微微右移的细节 */
        }

        .playlist li.playing {
            color: #d13a3a; /* 泣血红 */
            font-weight: bold;
            background-color: rgba(139, 26, 26, 0.2);
            padding-left: 20px;
        }

        .playlist li.playing::after {
            content: "ılılı"; 
            font-size: 11px;
            color: #d13a3a;
            animation: sound-wave 1.2s infinite alternate;
        }

        @keyframes sound-wave {
            0% { opacity: 0.3; }
            100% { opacity: 1; }
        }
        
        .playlist::-webkit-scrollbar { width: 4px; }
        .playlist::-webkit-scrollbar-thumb { background-color: rgba(139, 26, 26, 0.5); border-radius: 2px; }
        .playlist::-webkit-scrollbar-track { background-color: rgba(30, 26, 24, 0.95); }
    </style>
</head>
<body>

    <div id="player-trigger"></div>

    <div id="player-panel">
        <div class="panel-header">明末雅集</div>
        <ul id="playlist" class="playlist">
            <li data-src="https://music.163.com/song/media/outer/url?id=1840551391.mp3">秦王破阵乐</li>
            <li data-src="https://music.163.com/song/media/outer/url?id=460298162.mp3">短歌行</li>
            <li data-src="https://music.163.com/song/media/outer/url?id=302891.mp3">故人叹</li>
            <li data-src="https://music.163.com/song/media/outer/url?id=34014045.mp3">兰君</li>
        </ul>
        <audio id="audio-player" style="display:none;"></audio>
    </div>

    <script>
        const trigger = document.getElementById('player-trigger');
        const panel = document.getElementById('player-panel');
        const audio = document.getElementById('audio-player');
        const songs = document.querySelectorAll('.playlist li');
        let currentPlaying = null;

        trigger.addEventListener('click', () => {
            panel.classList.toggle('active');
            
            // 调整古筝按钮展开后的位置偏移量
            if (panel.classList.contains('active')) {
                trigger.style.left = '330px'; 
            } else {
                trigger.style.left = '20px';
            }
        });

        songs.forEach((song) => {
            song.addEventListener('click', function() {
                const src = this.getAttribute('data-src');

                if (currentPlaying === this && !audio.paused) {
                    audio.pause();
                    this.classList.remove('playing');
                    return;
                }

                songs.forEach(s => s.classList.remove('playing'));
                
                this.classList.add('playing');
                if (audio.src !== src) {
                    audio.src = src;
                }
                
                audio.play().catch(error => {
                    console.log("音律受限，播放暂停:", error);
                });
                
                currentPlaying = this;
            });
        });

        audio.addEventListener('ended', () => {
            if (currentPlaying) {
                let nextSong = currentPlaying.nextElementSibling;
                if (!nextSong) {
                    nextSong = songs[0]; 
                }
                nextSong.click();
            }
        });
    </script>

</body>
</html>