/* --- 1. 基础布局和字体 --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: #e9ecef;
    color: #333;
    margin: 0;
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    overflow: hidden;
}

h2,
h3 {
    color: #1a2e42;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    margin-top: 0;
}

p {
    font-size: 12px;
    color: #8b949e;
    margin-top: -8px;
}

/* --- 2. 页面画框 --- */
#page-wrapper {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 15px;
    background-color: #fcfcfc;
    border: none;
    box-sizing: border-box;
    display: flex;
}

/* --- 3. 三栏布局 --- */
#app-container {
    display: flex;
    gap: 20px;
    width: 100%;
    height: 100%;
    position: relative;
}

#left-panel,
#right-panel {
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    z-index: 10;
    padding: 15px;
}

#left-panel {
    width: 290px;
}

#right-panel {
    width: 250px;
    overflow-y: auto;
}

#middle-panel {
    flex-grow: 1;
    padding: 15px;
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
}

#piece-count {
    font-size: 16px;
    font-weight: normal;
    color: #6c757d;
    margin-left: 10px;
}

#piece-count.full {
    color: #dc3545;
    font-weight: bold;
}

/* --- 4. 左侧选项卡 --- */
.tab-list {
    display: flex;
    gap: 5px;
    margin-top: -10px;
    margin-bottom: 15px;
}

.tab-btn {
    flex-grow: 1;
    padding: 8px 5px;
    /* 稍微调小padding以容纳4个按钮 */
    font-size: 14px;
    font-weight: bold;
    border: 1px solid #ced4da;
    background-color: #f8f9fa;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    /* 防止文字换行 */
}

.tab-btn:hover {
    background-color: #e9ecef;
}

.tab-btn.active {
    color: #fff;
    border-color: #007bff;
    background-color: #007bff;
}

.tab-btn.active[data-quality="金"] {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #343a40;
}

.tab-btn.active[data-quality="紫"] {
    background-color: #8800ff;
    border-color: #8800ff;
}

.tab-btn.active[data-quality="蓝"] {
    background-color: #007bff;
    border-color: #007bff;
}

.tab-btn.active[data-quality="filter"] {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: #fff;
}

#piece-list-container {
    flex-grow: 1;
    overflow-y: auto;
}

#piece-list {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    gap: 10px;
    justify-content: center;
}

/* --- 5. 棋子样式 --- */
.piece {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border: 2px solid #343a40;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: grab;
    text-align: center;
    box-sizing: border-box;
    transition: transform 0.1s ease;
    position: relative;
    width: 60px;
    height: 80px;
    padding-top: 5px;
    background-color: #f8f9fa;
    z-index: 10;
}

.piece:active {
    cursor: grabbing;
    transform: scale(1.1);
    z-index: 100;
}

.piece-avatar {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #ddd;
    pointer-events: none;
    position: relative;
    z-index: 2;
    background-color: #fff;
}

.piece-img-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    background-color: #6c757d;
    color: white;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 1;
}

.piece-name {
    font-size: 12px;
    font-weight: bold;
    margin-top: 4px;
    width: 100%;
    padding: 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.piece.quality-蓝 {
    border-color: #007bff;
    background-color: #e6f2ff;
}

.piece.quality-紫 {
    border-color: #8800ff;
    background-color: #f2e6ff;
}

.piece.quality-金 {
    border-color: #ffc107;
    background-color: #fff3cd;
}

/* 棋盘上的棋子 */
#chessboard .piece {
    cursor: move;
    border: 1px solid #555;
    background-color: #fff;
    width: 58px;
    height: 58px;
    padding-top: 0;
    justify-content: center;
    margin: 1px 0 0 1px;
}

#chessboard .piece .piece-avatar {
    width: 58px;
    height: 58px;
    border: none;
    margin: 0;
    border-radius: 3px;
}

#chessboard .piece .piece-img-placeholder {
    width: 58px;
    height: 58px;
    top: 0;
    left: 0;
    margin: 0;
    border-radius: 3px;
}

#chessboard .piece .piece-name {
    display: none;
}

#chessboard .piece.piece-highlight {
    border-color: #19ff4d;
    box-shadow: 0 0 10px 3px rgba(25, 255, 77, 0.7);
}

.piece-name-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 11;
}

.piece-name-wrapper .piece-name {
    font-size: 11px;
    font-weight: bold;
    color: #333;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    margin: 0;
    text-align: center;
}

.theme-dark .piece-name-wrapper .piece-name {
    color: #fff;
    background-color: rgba(0, 0, 0, 0.6);
}

/* --- 6. 棋盘控制区 --- */
.board-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.board-controls-left {
    display: flex;
    gap: 10px;
    align-items: center;
}

.import-export {
    display: flex;
    gap: 5px;
}

#import-input {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    width: 150px;
}

.board-controls button {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #ced4da;
    background-color: #f8f9fa;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.board-controls button:hover {
    background-color: #e9ecef;
}

#clear-board-btn {
    border-color: #dc3545;
    color: #dc3545;
}

#clear-board-btn:hover {
    background-color: #dc3545;
    color: #fff;
}

#import-btn {
    border-color: #28a745;
    color: #28a745;
}

#import-btn:hover {
    background-color: #28a745;
    color: #fff;
}

.board-hint {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
}

/* --- 7. 棋盘核心 (Flexbox重构版) --- */
.board-wrapper {
    position: relative;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: auto;
    background: #b7dabc;
    border-color: #a4d6ad;
    transition: background-color 0.3s ease;
    align-items: center;
}

.board-wrapper.theme-dark {
    background: #495057;
    border-color: #343a40;
}

.board-wrapper.theme-dark .item-bg {
    background: #6c757d;
    border-color: #909aa3;
}

.board-wrapper.theme-blue {
    background: #e6f2ff;
    border-color: #b3d7ff;
}

.board-wrapper.theme-blue .item-bg {
    background: #cce5ff;
    border-color: #b8daff;
}

/* --- V39: 全向缩放便利贴 --- */
.notes-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 250px;
    height: 200px;
    min-width: 180px;
    min-height: 150px;
    z-index: 100;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
}

/* 拖拽把手 */
.notes-drag-handle {
    height: 28px;
    background-color: rgba(0, 0, 0, 0.05);
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: #6c757d;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    user-select: none;
}

.notes-drag-handle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* 工具栏 */
.notes-toolbar {
    display: flex;
    gap: 5px;
    padding: 4px 8px;
    background-color: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.note-tool-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 13px;
    border-radius: 3px;
    color: #495057;
    transition: background 0.2s;
}

.note-tool-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.color-picker-wrapper {
    position: relative;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}

.color-picker-wrapper:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* 编辑区 */
.board-notes {
    flex-grow: 1;
    padding: 10px;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    color: #2c3e50;
    cursor: text;
    overflow-y: auto;
    background: transparent;
}

.board-notes:empty::before {
    content: attr(placeholder);
    color: rgba(0, 0, 0, 0.4);
    font-style: italic;
    pointer-events: none;
}

/* --- V39 新增: 8个方向的缩放手柄 --- */
.resizer {
    position: absolute;
    width: 10px;
    height: 10px;
    background: transparent;
    z-index: 101;
}

/* 顶部 */
.resizer-t {
    top: -5px;
    left: 0;
    width: 100%;
    height: 8px;
    cursor: n-resize;
}

/* 底部 */
.resizer-b {
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 8px;
    cursor: s-resize;
}

/* 左侧 */
.resizer-l {
    top: 0;
    left: -5px;
    width: 8px;
    height: 100%;
    cursor: w-resize;
}

/* 右侧 */
.resizer-r {
    top: 0;
    right: -5px;
    width: 8px;
    height: 100%;
    cursor: e-resize;
}

/* 四角 */
.resizer-tl {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resizer-tr {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resizer-bl {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resizer-br {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* 视觉增强：鼠标悬停在边框时显示明显的高亮线，提示可缩放 */
.notes-wrapper:hover {
    border-color: rgba(0, 123, 255, 0.5);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.resizer-t:hover {
    border-top: 3px solid #007bff;
}

.resizer-b:hover {
    border-bottom: 3px solid #007bff;
}

.resizer-l:hover {
    border-left: 3px solid #007bff;
}

.resizer-r:hover {
    border-right: 3px solid #007bff;
}

/* 角落加点 */
.resizer-tl:hover,
.resizer-tr:hover,
.resizer-bl:hover,
.resizer-br:hover {
    background-color: #007bff;
    border-radius: 50%;
    opacity: 0.8;
}

/* 便利贴主题色适配 */
.board-wrapper.theme-green .notes-wrapper {
    background-color: rgba(255, 255, 255, 0.5);
}

.board-wrapper.theme-dark .notes-wrapper {
    background-color: rgba(40, 44, 52, 0.85);
    border-color: #495057;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.board-wrapper.theme-dark .notes-drag-handle {
    color: #adb5bd;
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom-color: #495057;
}

.board-wrapper.theme-dark .board-notes {
    color: #e9ecef;
}

.board-wrapper.theme-dark .board-notes:empty::before {
    color: rgba(255, 255, 255, 0.3);
}

.board-wrapper.theme-dark .note-tool-btn {
    color: #ced4da;
}

.board-wrapper.theme-blue .notes-wrapper {
    background-color: rgba(255, 255, 255, 0.6);
    border-color: #b8daff;
}

.board-wrapper.theme-blue .board-notes {
    color: #004085;
}

/* 移动端: 取消缩放 */
@media (max-width: 768px) {
    .notes-wrapper {
        position: relative;
        top: 0;
        left: 0;
        width: 95%;
        height: auto;
        min-height: 150px;
        margin: 10px auto;
        resize: none;
        z-index: 10;
    }

    .notes-drag-handle,
    .resizer {
        display: none;
    }
}

/* Grid & Slots 保持不变 */
.board-grid-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-bottom: 0px;
    min-width: fit-content;
}

.board-row {
    display: flex;
    justify-content: center;
    gap: 10px;
 
}

/* ✨ 新增：最后一排不需要负外边距，防止影响棋盘下方的整体布局 */
.board-row:last-child {
    margin-bottom: 0;
}



.board-slot {
    width: 60px;
    height: 60px;
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    background: transparent;
    border: none;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}


.board-slot.item {
    cursor: pointer;
}

.item-bg {
    width: 60px;
    height: 60px;
    position: absolute;
    top: 0;
    left: 0;
    border: 1px dashed #d1d5d9;
    background: #e9ecef;
    transition: all 0.2s;
    z-index: 1;
    border-radius: 4px;
}

.board-slot.item:hover .item-bg {
    background: #d4edda;
    border-color: #8fcc95;
}

.board-slot.drag-over .item-bg {
    background-color: #d4edda;
    border-color: #28a745;
}

/* 杂项保持不变 */
.tips-container {
    background-color: #e6f7ff;
    border: 1px solid #b3e0ff;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
}

.tip-item {
    font-size: 13px;
    color: #0056b3;
    line-height: 1.6;
    margin-bottom: 5px;
}

#synergy-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.synergy-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 14px;
    color: #6c757d;
    border-left: 3px solid #6c757d;
    transition: all 0.2s ease;
    cursor: pointer;
}

.synergy-item.active {
    background-color: #d4edda;
    color: #155724;
    border-left-color: #28a745;
    font-weight: bold;
}

.synergy-item.active-max {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: #ffc107;
}

.synergy-item-info {
    flex-grow: 1;
    pointer-events: none;
}

/* Updated Header Layout and Feedback Link */
.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-feedback-link {
    font-size: 13px;
    color: #495057;
    text-decoration: none;
    background-color: #f8f9fa;
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    /* Fix height */
}

.header-feedback-link:hover {
    color: #007bff;
    background-color: #e7f1ff;
    border-color: #b3d7ff;
    text-decoration: none;
}

.theme-dark .header-feedback-link {
    background-color: #343a40;
    color: #ced4da;
    border-color: #6c757d;
}

.theme-dark .header-feedback-link:hover {
    background-color: #495057;
    color: #fff;
    border-color: #adb5bd;
}

.add-synergy-btn {
    margin-left: 10px;
    padding: 2px 8px;
    font-size: 16px;
    font-weight: bold;
    color: #007bff;
    background-color: #e6f2ff;
    border: 1px solid #007bff;
    border-radius: 50%;
    cursor: pointer;
}

.add-synergy-btn:hover {
    background-color: #007bff;
    color: #fff;
}

/* 羁绊悬浮窗 (复用基础样式，棋子悬浮窗也用这个风格) */
#synergy-tooltip,
#piece-tooltip {
    display: none;
    position: absolute;
    width: 320px;
    /* V42: 稍微加宽以适应头像 */
    background: rgba(40, 44, 52, 0.95);
    color: #f8f9fa;
    border: 1px solid #6c757d;
    border-radius: 8px;
    padding: 12px;
    z-index: 2000;
    /* 确保比任何棋子都高 */
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#synergy-tooltip h4,
#piece-tooltip h4 {
    margin: 0 0 10px 0;
    border-bottom: 1px solid #495057;
    padding-bottom: 5px;
    color: #ffd700;
    /* 金色标题 */
}

/* 棋子技能特有样式 */
.piece-tooltip-skill {
    font-size: 13px;
    line-height: 1.5;
    color: #e9ecef;
}

.synergy-desc {
    font-size: 12px;
    color: #e9ecef;
    font-style: italic;
    margin-bottom: 10px;
    background: #333;
    padding: 5px;
    border-radius: 4px;
}

/* --- V42 更新: 羁绊悬浮窗内部头像网格样式 --- */
.synergy-pieces-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    /* 自适应列，每列最小60px */
    gap: 8px;
    margin-top: 10px;
}

.synergy-tooltip-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.synergy-tooltip-img-wrapper {
    width: 40px;
    height: 40px;
    border: 2px solid #555;
    border-radius: 4px;
    overflow: hidden;
    background: #333;
    transition: border-color 0.2s;
    margin-bottom: 4px;
}

.synergy-tooltip-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 名字样式 */
.synergy-tooltip-name {
    font-size: 10px;
    color: #adb5bd;
    /* 默认灰色 */
}

/* 缺失（未上场）状态：灰色滤镜 */
.synergy-tooltip-item.missing .synergy-tooltip-img {
    filter: grayscale(100%);
    opacity: 0.6;
}

.synergy-tooltip-item.missing .synergy-tooltip-name {
    color: #6c757d;
    /* 更暗的灰色 */
}

/* 激活（已上场）状态：彩色，高亮 */
.synergy-tooltip-item.active .synergy-tooltip-img {
    filter: none;
    opacity: 1;
}

.synergy-tooltip-item.active .synergy-tooltip-name {
    color: #fff;
    /* 亮白色 */
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

/* 激活状态下的边框颜色 (根据品质) */
.synergy-tooltip-item.active .synergy-tooltip-img-wrapper.quality-金 {
    border-color: #ffc107;
}

.synergy-tooltip-item.active .synergy-tooltip-img-wrapper.quality-紫 {
    border-color: #bd69ff;
}

.synergy-tooltip-item.active .synergy-tooltip-img-wrapper.quality-蓝 {
    border-color: #5ba4fc;
}


#message-box {
    display: none;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    background-color: #dc3545;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: top 0.3s, opacity 0.3s;
}

#message-box.success {
    background-color: #28a745;
}

.download-link-container {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.download-btn {
    display: block;
    padding: 10px;
    background-color: #007bff;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
}

.download-btn:hover {
    background-color: #0056b3;
}

/* --- V40: 便利贴折叠功能 --- */

/* 折叠按钮样式 */
.note-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #6c757d;
    margin-left: auto;
    /* 靠右对齐 */
    padding: 0 5px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-toggle-btn:hover {
    color: #007bff;
    transform: scale(1.2);
}

/* 折叠状态下的核心样式 */
.notes-wrapper.collapsed {
    /* 使用 !important 覆盖 JS 拖拽缩放设置的内联 width/height */
    width: 140px !important;
    height: 40px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.95);
    /* 折叠时背景稍微不透明一点 */
    border-radius: 12px;
    /* 折叠时圆润一点 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: #ccc;
}

/* 折叠时隐藏：工具栏、内容区、四周缩放手柄 */
.notes-wrapper.collapsed .notes-toolbar,
.notes-wrapper.collapsed .board-notes,
.notes-wrapper.collapsed .resizer {
    display: none !important;
}

/* 折叠时的拖拽栏调整 */
.notes-wrapper.collapsed .notes-drag-handle {
    border-bottom: none;
    /* 移除分割线 */
    height: 100%;
    /* 充满整个小方块 */
    background-color: transparent;
    padding: 0 15px;
    justify-content: space-between;
    /* 文字和按钮两端对齐 */
    font-size: 14px;
}

/* 简单的过渡动画 */
.notes-wrapper {
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s, border-radius 0.3s;
}

/* --- 棋子悬浮窗标签样式 --- */

/* --- 名字旁边的羁绊胶囊 (高对比清晰版) --- */
.tag-synergy {
    display: inline-block;
    vertical-align: middle;
    font-size: 13px;
    padding: 2px 8px;
    margin-left: 8px;
    border-radius: 4px;
    /* 与下方标签统一风格 */

    font-weight: 700;
    line-height: normal;
    position: relative;
    top: -2px;

    /* 采用一种中性偏绿/青的配色，与红蓝金区分开 */
    background-color: #f6ffed;
    /* 实色淡绿 */
    color: #389e0d;
    /* 深绿 */
    border: 1px solid #b7eb8f;
    /* 中等绿边框 */
}

/* --- 棋子特性胶囊 (高对比清晰版) --- */
.piece-tags-container {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.piece-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* 保持大尺寸 */
    padding: 4px 10px;
    /* 稍微紧凑一点点，但依然很大 */
    font-size: 13px;
    /* 清晰的字号 */
    font-weight: 700;
    /* 加粗，让字更实 */
    border-radius: 4px;
    /* 改回稍微方一点的圆角，看起来更像“标签”而非“按钮”，更利于阅读 */

    border: 1px solid;
    /* 加上边框增强轮廓 */
    cursor: default;
}

/* 蓝色 - 内功/外功 */
/* 配色逻辑：极淡蓝底 + 深蓝接近黑的字 */
.tag-blue {
    background-color: #e8f4ff;
    /* 实色淡蓝 */
    color: #0958d9;
    /* 深宝蓝，对比度极高 */
    border-color: #91caff;
    /* 中等蓝边框 */
}

/* 红色 - 近战/远程 */
/* 配色逻辑：极淡红底 + 深红接近黑的字 */
.tag-red {
    background-color: #fff1f0;
    /* 实色淡红 */
    color: #cf1322;
    /* 深红 */
    border-color: #ffa39e;
    /* 中等红边框 */
}

/* 金色 - 功能 */
/* 配色逻辑：极淡黄底 + 深褐接近黑的字 */
.tag-gold {
    background-color: #fffbe6;
    /* 实色淡黄 */
    color: #d48806;
    /* 深褐金 */
    border-color: #ffe58f;
    /* 中等黄边框 */
}

/* --- 8. 筛选功能样式 (新增) --- */

/* 筛选容器 */
.filter-container {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.filter-group {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

/* 筛选标签标题 */
.filter-label {
    font-size: 12px;
    font-weight: bold;
    color: #6c757d;
    margin-right: 4px;
    display: flex;
    align-items: center;
}

/* 筛选胶囊按钮 */
.filter-tag-btn {
    font-size: 12px;
    padding: 2px 8px;
    border: 1px solid #ced4da;
    background-color: #fff;
    border-radius: 12px;
    cursor: pointer;
    color: #495057;
    transition: all 0.2s;
}

.filter-tag-btn:hover {
    background-color: #e9ecef;
}

/* 选中状态 */
.filter-tag-btn.active {
    background-color: #343a40;
    color: #fff;
    border-color: #343a40;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 筛选结果的分组标题 */
.group-header {
    width: 100%;
    font-size: 13px;
    font-weight: bold;
    color: #495057;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 4px;
    margin: 15px 0 10px 0;
}

.group-header:first-child {
    margin-top: 0;
}

/* 筛选模式下的网格容器 */
.group-grid {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    gap: 10px;
    justify-content: center;
}

/* 当处于筛选模式时，主列表不再使用 grid，而是由内部的 .group-grid 接管 */
#piece-list.filter-mode {
    display: block;
}

/* --- 底部鸣谢区域样式 (带名字版) --- */
.credits-section {
    flex-shrink: 0;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.credits-title {
    font-size: 11px;
    color: #8b949e;
    font-weight: bold;
    padding-left: 5px;
}

.credits-avatars {
    display: flex;
    gap: 12px;
    /* 增加一点间距 */
    padding: 0 5px;
    overflow-x: auto;
    /* 允许横向滚动 */
    align-items: flex-start;
    /* 顶部对齐 */
    padding-bottom: 5px;
    /* 给滚动条留点位置 */
}

/* 隐藏滚动条 (Chrome/Safari) */
.credits-avatars::-webkit-scrollbar {
    display: none;
}

.avatar-link {
    display: flex;
    /* 改为 Flex 布局 */
    flex-direction: column;
    /* 垂直排列：上图下文 */
    align-items: center;
    /* 居中对齐 */
    text-decoration: none;
    width: 48px;
    /* 限制宽度，防止名字太长撑乱布局 */
    flex-shrink: 0;
    /* 防止被挤压 */
    transition: transform 0.2s ease;
}

.avatar-link:hover {
    transform: translateY(-3px);
}

.avatar-link img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s;
    display: block;
    margin-bottom: 4px;
    /* 图片和名字的间距 */
}

/* 名字样式 */
.credit-name {
    font-size: 10px;
    /* 字号要小 */
    color: #6c757d;
    /* 灰色文字 */
    text-align: center;
    width: 100%;

    /* 如果名字太长，自动变成省略号... */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-link:hover img {
    border-color: #ffc107;
}

.avatar-link:hover .credit-name {
    color: #333;
    font-weight: bold;
}

/* 悬停时名字变深 */

.avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f3f5;
    color: #adb5bd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 1px dashed #ced4da;
    box-sizing: border-box;
    margin-bottom: 4px;
}

/* --- 底部关于/版权说明区域样式 --- */
.about-section {
    flex-shrink: 0;
    /* 防止被压缩 */
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e9ecef;
    /* 使用虚线与上方的鸣谢区分开 */

    text-align: center;
    font-size: 11px;
    /* 字号较小，保持精致感 */
    color: #8b949e;
    line-height: 1.6;
}

.about-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* 作者链接样式 */
.about-link {
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}

.about-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* 第二行辅助信息 (参考 & AI) */
.sub-info {
    font-size: 10px;
    /* 比作者名更小一点 */
    color: #adb5bd;
}

.divider {
    color: #dee2e6;
    margin: 0 2px;
}

/* 鼠标悬停在 AI 字样上时稍微深一点 */
.sub-info span:hover {
    color: #6c757d;
    cursor: default;
}

/* --- 标题栏迷你时钟样式 --- */
.mini-clock {
    display: flex;
    align-items: center;
    gap: 8px;
    /* 时间和提示语的间距 */
    font-weight: normal;
    /* 重置权重 */
}

.clock-time {
    font-family: "Segoe UI", "Roboto", sans-serif;
    font-size: 15px;
    /* 字号缩小 (原24px) */
    font-weight: bold;
    color: #495057;
    line-height: 1;
    font-feature-settings: "tnum";
    /* 等宽数字，防止跳动 */
}

.clock-tips {
    font-size: 10px;
    /* 字号极小，精致感 */
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    /* 防止换行撑开高度 */

    /* 默认浅蓝风格 */
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.08);
    font-weight: normal;
    letter-spacing: 0.5px;
}

/* 深夜警告样式 (JS会自动切换) */
.clock-tips.late-night {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}


/* --- 阵法系统样式 (新增) --- */

/* 阵法槽位容器 */
.formation-slot-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: auto;
    /* 允许点击 */
}

/* 圆形虚线框 */
.formation-circle {
    width: 44px;
    height: 44px;
    border: 2px dashed #adb5bd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    font-size: 10px;
    color: #adb5bd;
    position: relative;
}

.formation-circle:hover {
    border-color: #007bff;
    color: #007bff;
    background-color: #fff;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 选中状态（实线 + 金色） */
.formation-circle.active {
    border-style: solid;
    border-color: #ffc107;
    background-color: #fff3cd;
    color: #856404;
}

/* 阵法图标 (Demo用文字或图片) */
.formation-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    /* --- ⬇️ 新增代码 ⬇️ --- */
    /* 使用滤镜将图标变为纯黑色，极大提高对比度 */
    filter: grayscale(100%) brightness(0%);
    /* --- ⬆️ 新增代码 ⬆️ --- */
}

/* 下方的阵法名字 */
.formation-name {
    margin-top: 4px;
    font-size: 10px;
    font-weight: bold;
    color: #495057;
    text-align: center;
    white-space: nowrap;
    height: 14px;
    /* 占位防止跳动 */
}

/* 阶段标记 (一阶/二阶/三阶) */
.formation-stage-tag {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #6c757d;
    color: #fff;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 8px;
    transform: scale(0.8);
}

/* 添加备用阵法按钮 */
.add-backup-btn {
    font-size: 11px;
    color: #007bff;
    background: none;
    border: 1px dashed #007bff;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
    white-space: nowrap;
}

.add-backup-btn:hover {
    background: #e6f2ff;
}

/* --- 阵法选择面板 (Modal) --- */
#formation-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2999;
}

#formation-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    padding: 15px;
    border: 1px solid #dee2e6;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.modal-title {
    font-weight: bold;
    color: #343a40;
}

.modal-close {
    cursor: pointer;
    color: #999;
    font-size: 18px;
}

.formation-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.formation-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid transparent;
}

.formation-option:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

.formation-option img {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
    filter: grayscale(100%) brightness(0%);
}

.formation-option span {
    font-size: 11px;
    color: #333;
}

/* 阵法详细描述 Tooltip (复用已有的 tooltip 风格) */
#formation-tooltip {
    display: none;
    position: absolute;
    background: rgba(40, 44, 52, 0.95);
    color: #fff;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 3100;
    max-width: 200px;
    pointer-events: none;
    border: 1px solid #ffd700;
}

#formation-tooltip h5 {
    margin: 0 0 5px 0;
    color: #ffd700;
    font-size: 13px;
}

/* --- 阵法系统样式更新 --- */

/* 1. 阵法名字颜色适配暗色模式 */
.board-wrapper.theme-dark .formation-name {
    color: #adb5bd !important;
    /* 暗色模式下变灰白 */
}

.board-wrapper.theme-blue .formation-name {
    color: #004085 !important;
}

/* 2. 控制按钮区域 (第3行第20列) */
.formation-control-wrapper {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.formation-btn {
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid;
    border-radius: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.2s;
    white-space: nowrap;
    width: 50px;
    text-align: center;
}

/* 添加按钮风格 */
.btn-add {
    color: #28a745;
    border-color: #28a745;
}

.btn-add:hover {
    background-color: #28a745;
    color: #fff;
}

/* 删除按钮风格 */
.btn-del {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-del:hover {
    background-color: #dc3545;
    color: #fff;
}

/* 禁用状态 */
.formation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #ccc;
    color: #ccc;
}

/* --- 阵法美化框样式 (修复版) --- */

/* 1. 阵法背景层 (核心: 绝对定位，不影响格子布局) */
.formation-bg-layer {
    position: absolute;
    top: 5px;
    /* 上下留点空隙，不要填满80px高度 */
    bottom: 15px;
    left: -3px;
    /* 向左延伸覆盖间隙 */
    right: -3px;
    /* 向右延伸覆盖间隙 */

    background-color: rgba(255, 255, 255, 0.5);
    border-top: 1px dashed #adb5bd;
    border-bottom: 1px dashed #adb5bd;
    z-index: 0;
    /* 在圆圈下面 */
}

/* 2. 左侧开头 (Col 15): 左边圆角，左边不延伸 */
.formation-bg-start {
    left: 4px;
    /* 缩回来一点，不要突出去 */
    border-left: 1px dashed #adb5bd;
    border-top-left-radius: 30px;
    border-bottom-left-radius: 30px;
}

/* 3. 右侧结尾 (Col 19): 右边圆角，右边不延伸 */
.formation-bg-end {
    right: 4px;
    border-right: 1px dashed #adb5bd;
    border-top-right-radius: 30px;
    border-bottom-right-radius: 30px;
}

/* 4. 中间连接 (Col 16, 17, 18): 纯矩形，左右延伸覆盖缝隙 */
.formation-bg-mid {
    /* 默认样式即可，依靠 left: -3px; right: -3px 连接 */
}

/* 修复内容层级，确保圆圈在背景之上 */
.formation-slot-wrapper {
    position: relative;
    z-index: 1;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 暗色模式适配 */
.board-wrapper.theme-dark .formation-bg-layer {
    background-color: rgba(0, 0, 0, 0.3);
    border-color: #6c757d;
}


/* --- 修复布局居中问题 (粘贴到 style.css 末尾) --- */

/* 1. 确保图标填满且居中 */
.formation-icon-img {
    width: 65% !important;
    /* 稍微改小一点点，留点呼吸感，或者用 70% 也可以 */
    height: 65% !important;
    object-fit: contain;
    display: block;
    /* 消除图片底部的默认间隙 */
    margin: 0 auto;
    /* 强制水平居中 */

    /* 之前的滤镜设置 (保持不变) */
    filter: brightness(0) opacity(0.85);
    transition: filter 0.3s ease;
}

.board-wrapper.theme-dark .formation-icon-img {
    filter: brightness(0) invert(1) opacity(0.9);
}

/* 2. 确保圆圈是 Flex 居中布局 */
.formation-circle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    /* 确保内容不会跑出去 */
    overflow: hidden;
}

/* 3. 确保文字绝对居中 */
.formation-name {
    margin-top: 2px;
    width: 140%;
    /* 宽度给大一点，防止文字换行 */
    margin-left: -20%;
    /* 通过负 margin 拉回来居中 */
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
    /* 不许换行 */
    line-height: 1.2;
    /* 颜色设置 */
    color: #495057;
}

.board-wrapper.theme-dark .formation-name {
    color: #adb5bd !important;
}

/* --- 修复右上角标签消失问题 (请粘贴到 style.css 末尾) --- */

.formation-circle {
    /* 必须允许溢出，否则右上角的“一阶”标签会被切掉 */
    overflow: visible !important;

    /* 保持原来的居中布局 */
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* 确保图标大小合适，不会撑破圆圈 */
.formation-icon-img {
    width: 65% !important;
    height: 65% !important;
    object-fit: contain;
    display: block;
    margin: 0 auto;

    /* 之前的滤镜设置 */
    filter: brightness(0) opacity(0.85);
    transition: filter 0.3s ease;
}

/* 暗色模式适配 */
.board-wrapper.theme-dark .formation-icon-img {
    filter: brightness(0) invert(1) opacity(0.9);
}

/* --- 图标大小调整 (粘贴到 style.css 末尾) --- */

/* 1. 棋盘上的阵法图标：加大 */
.formation-circle .formation-icon-img {
    width: 80% !important;
    /* 从 65% 改为 80%，撑满圆圈 */
    height: 80% !important;
}

/* 2. 弹窗选择面板里的图标：独立加大 */
/* 必须单独指定 .formation-option 下的图片，否则它会继承上面的 80% */
.formation-option .formation-icon-img {
    width: 50px !important;
    /* 强制改成 50像素大图标 */
    height: 50px !important;
    margin: 0 auto 5px auto;
    /* 居中并保持下间距 */
}

/* 3. 稍微调整一下弹窗选项的内边距，给大图标腾位置 */
.formation-option {
    padding: 10px 5px !important;
    /* 增加一点内边距 */
}

/* ==================== ⬇️ 修复字体大小和居中问题 (粘贴到文件最末尾) ⬇️ ==================== */

/* 1. 弹窗选择列表：名字改大、加粗、居中 */
.formation-option span {
    font-size: 13px !important;
    /* 原来是11px，改大 */
    font-weight: bold !important;
    /* 加粗 */
    color: #333;
    margin-top: 4px;
    /* 增加一点与图标的间距 */
    text-align: center;
    /* 确保文字居中 */
    width: 100%;
    /* 占满容器宽度 */
    display: block;
    /* 块级显示，方便居中 */
    line-height: 1.3;
}

/* 2. 棋盘阵法图标下方：名字改大、严格居中 */
.formation-name {
    font-size: 12px !important;
    /* 原来是10px，改大 */
    font-weight: bold !important;
    /* 加粗，让字更清晰 */

    /* --- 居中核心算法 --- */
    /* 原理：因为文字可能比格子(60px)宽，所以设为 160% 宽度让它能放下4个字 
       然后用 margin-left: -30% 把多出来的宽度往左拉回一半，实现绝对居中 
       公式：(100% - 宽度%) / 2 = Margin左移比例
       (100% - 160%) / 2 = -30%
    */
    width: 160% !important;
    margin-left: -30% !important;

    margin-top: 5px !important;
    /* 稍微离圆圈远一点点，不那么拥挤 */
    text-align: center !important;
    /* 文字内容居中 */
    white-space: nowrap !important;
    /* 强制不换行 */

    /* 增加一点文字阴影，防止背景复杂时看不清 */
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
    pointer-events: none;
    /* 防止文字挡住点击 */
}

/* 3. 适配暗色模式下的文字颜色 */
.board-wrapper.theme-dark .formation-name {
    color: #e9ecef !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    /* 暗色模式用深色阴影 */
}

/* ==================== ⬇️ 1. 修复：图标强制黑色 (复制到 style.css 末尾) ⬇️ ==================== */
.formation-icon-img {
    /* 强制纯黑，不透明，层级高 */
    filter: grayscale(100%) brightness(0) opacity(1) !important;
    transition: transform 0.2s ease;
}

/* 覆盖暗色模式设置：强制保持黑色，不要反色变白 */
.board-wrapper.theme-dark .formation-icon-img,
.formation-option .formation-icon-img {
    filter: grayscale(100%) brightness(0) opacity(1) !important;
}

/* ==================== ⬇️ 替换这一块样式 ⬇️ ==================== */
#formation-panel {
    position: absolute;
    /* 改动1：向下挪到 60px，避开顶部的便利贴 */
    top: 60px;
    /* 改动2：改到右边，跟便利贴对齐 */
    right: 10px;
    left: auto;
    /* 确保左边距失效 */

    width: 260px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #ced4da;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999;
    /* 稍微比便利贴(100)高一点即可，或者保持 1000 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.3s, width 0.3s, opacity 0.3s;
}

/* 确保折叠时的高度和宽度正确 */
#formation-panel.collapsed {
    width: 130px !important;
    /* 跟便利贴折叠宽度一致 */
    height: 32px !important;
    /* 跟便利贴折叠高度一致 */
}

/* 暗色模式适配保持不变 */
.board-wrapper.theme-dark #formation-panel {
    background-color: rgba(52, 58, 64, 0.95);
    border-color: #495057;
    color: #f8f9fa;
}

/* 拖拽把手 */
.formation-panel-handle {
    padding: 8px 12px;
    background-color: #f1f3f5;
    border-bottom: 1px solid #dee2e6;
    cursor: move;
    font-size: 13px;
    font-weight: bold;
    color: #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.board-wrapper.theme-dark .formation-panel-handle {
    background-color: #343a40;
    border-bottom-color: #495057;
    color: #e9ecef;
}

/* 折叠按钮 */
.panel-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #6c757d;
    padding: 0 5px;
}

.panel-toggle-btn:hover {
    color: #007bff;
}

/* 内容区域 */
.formation-panel-content {
    padding: 10px;
    overflow-y: auto;
    max-height: 400px;
}

/* 折叠状态样式 */
#formation-panel.collapsed {
    width: 140px !important;
    height: 36px !important;
}

#formation-panel.collapsed .formation-panel-content {
    display: none;
}

/* 阵法行 */
.formation-set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px dashed #ced4da;
}

.board-wrapper.theme-dark .formation-set-row {
    background: rgba(255, 255, 255, 0.05);
    border-color: #6c757d;
}

/* 圆圈容器 */
.formation-slots-group {
    display: flex;
    gap: 8px;
}

/* 小圆圈 */
.panel-formation-circle {
    width: 40px;
    height: 40px;
    border: 1px dashed #adb5bd;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #fff;
    position: relative;
    transition: all 0.2s;
}

.panel-formation-circle:hover {
    border-color: #007bff;
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.panel-formation-circle.active {
    border-style: solid;
    border-color: #ffc107;
    background: #fff3cd;
}

/* 角标 */
.panel-stage-tag {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #6c757d;
    color: #fff;
    font-size: 9px;
    padding: 1px 3px;
    border-radius: 4px;
    transform: scale(0.8);
}

/* 删除按钮 */
.btn-remove-set {
    color: #dc3545;
    background: none;
    border: 1px solid #dc3545;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    padding: 2px 5px;
    margin-left: 5px;
}

.btn-remove-set:hover {
    background: #dc3545;
    color: #fff;
}

/* 添加按钮 */
.btn-add-set-block {
    width: 100%;
    padding: 8px;
    border: 1px dashed #007bff;
    color: #007bff;
    background: rgba(0, 123, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
}

.btn-add-set-block:hover {
    background: rgba(0, 123, 255, 0.15);
}

/* 面板内名字 */
.panel-formation-name {
    font-size: 9px;
    color: #333;
    width: 120%;
    margin-left: -10%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: absolute;
    bottom: -14px;
    font-weight: bold;
}

.board-wrapper.theme-dark .panel-formation-name {
    color: #ccc;
}

/* ==================== ⬇️ 新增：右上角红叉删除按钮样式 ⬇️ ==================== */

/* 1. 修改阵法行容器：增加相对定位，为了让红叉能定位在它身上 */
.formation-set-row {
    position: relative !important;
    /* 关键 */
    display: flex;
    justify-content: center;
    /* 让三个圆圈居中 */
    align-items: center;
    /* 调整内边距，给右上角的叉腾点位置，防止盖住内容 */
    padding: 12px 8px 8px 8px !important;
    margin-bottom: 12px !important;
    border: 1px dashed #ced4da;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.03);
}

/* 2. 定义红叉按钮样式 */
.formation-set-close-btn {
    position: absolute;
    top: -6px;
    /* 往上提，骑在边框上 */
    right: -6px;
    /* 往右提，骑在边框上 */

    width: 18px;
    height: 18px;
    background-color: #dc3545;
    /* 红色背景 */
    color: white;

    border-radius: 50%;
    /* 圆形 */
    border: 2px solid #fff;
    /* 白色描边，增加层次感 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);

    text-align: center;
    line-height: 15px;
    /* 垂直居中文字 */
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;

    /* 禁止选中文字 */
    user-select: none;
    transition: all 0.2s;
}

.formation-set-close-btn:hover {
    background-color: #bd2130;
    transform: scale(1.1);
    /* 悬停稍微放大 */
}

/* 暗色模式适配 */
.board-wrapper.theme-dark .formation-set-close-btn {
    border-color: #343a40;
    /* 暗色模式下描边变深色 */
}

/* 3. 隐藏之前可能存在的旧垃圾桶按钮 (如果有残留的话) */
.btn-remove-set {
    display: none !important;
}


/* ==================== ⬇️ 阵法面板：磨砂玻璃大图标版 ⬇️ ==================== */

/* 1. 面板容器：半透明磨砂玻璃效果 */
#formation-panel {
    position: absolute;
    top: 60px;
    right: 10px;
    /* 稍微加宽一点，容纳大圆圈 */
    width: 280px;

    /* 核心：半透明白底 + 模糊滤镜 */
    background-color: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    /* 磨砂效果 */
    -webkit-backdrop-filter: blur(10px);

    border: 1px solid rgba(255, 255, 255, 0.6);
    /* 半透明边框 */
    border-radius: 12px;
    /* 更圆润的角 */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    /* 柔和的阴影 */

    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* 暗色模式适配：半透明黑底 */
.board-wrapper.theme-dark #formation-panel {
    background-color: rgba(30, 35, 40, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8f9fa;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* 2. 折叠状态 */
#formation-panel.collapsed {
    width: 140px !important;
    height: 40px !important;
    /* 稍微高一点，方便点击 */
    background-color: rgba(255, 255, 255, 0.95);
    /* 折叠时稍微实一点 */
}

.board-wrapper.theme-dark #formation-panel.collapsed {
    background-color: rgba(50, 50, 50, 0.95);
}

/* 3. 面板把手 */
.formation-panel-handle {
    padding: 10px 15px;
    /* 加大点击区域 */
    background-color: rgba(0, 0, 0, 0.03);
    /* 极淡的背景区分 */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: move;
    font-size: 14px;
    /* 字体加大 */
    font-weight: bold;
    color: #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.board-wrapper.theme-dark .formation-panel-handle {
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.1);
    color: #e9ecef;
}

/* 4. 每一行阵法容器 */
.formation-set-row {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 加大间距 */
    padding: 15px 10px 20px 10px !important;
    margin-bottom: 10px;

    /* 每一行也给一个极淡的背景，增加层次感 */
    background: rgba(255, 255, 255, 0.3);
    border: 1px dashed rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.board-wrapper.theme-dark .formation-set-row {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

/* 5. 圆圈放大！ */
.panel-formation-circle {
    /* 从 40px 改为 55px，显著变大 */
    width: 55px !important;
    height: 55px !important;

    border: 2px dashed #adb5bd;
    /* 边框加粗一点 */
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #fff;
    /* 圆圈内部保持纯白，突出图标 */
    position: relative;
    transition: transform 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    /* 给圆圈加点立体感 */
}

.board-wrapper.theme-dark .panel-formation-circle {
    background: #2b2d30;
    /* 暗色模式圆圈底色 */
    border-color: #6c757d;
}

.panel-formation-circle:hover {
    border-color: #007bff;
    transform: scale(1.1);
    /* 悬停放大更多 */
}

.panel-formation-circle.active {
    border-style: solid;
    border-color: #ffc107;
    background: #fff9db;
    /* 激活时淡黄色背景 */
}

.board-wrapper.theme-dark .panel-formation-circle.active {
    background: #444;
    border-color: #ffc107;
}

/* 6. 图标放大！ */
.panel-formation-circle .formation-icon-img {
    /* 强制图标填满圆圈的 75% */
    width: 75% !important;
    height: 75% !important;
    filter: grayscale(100%) brightness(0) opacity(0.9);
    /* 保持黑色高对比 */
}

.board-wrapper.theme-dark .panel-formation-circle .formation-icon-img {
    /* 暗色模式图标变白，高亮显示 */
    filter: grayscale(100%) brightness(100) opacity(1) !important;
}

/* 7. 文字放大并优化可见性 */
.panel-formation-name {
    font-size: 11px;
    /* 加大字号 (原9px) */
    font-weight: bold;
    color: #212529;

    width: 160%;
    margin-left: -30%;
    text-align: center;
    position: absolute;
    bottom: -18px;
    /* 往下挪，不挡住圆圈 */

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    /* 关键：给文字加个白边（光晕），防止背景杂乱看不清 */
    text-shadow: 0 1px 2px rgba(255, 255, 255, 1), 0 0 5px rgba(255, 255, 255, 0.8);
}

.board-wrapper.theme-dark .panel-formation-name {
    color: #e9ecef;
    /* 暗色模式加黑边 */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 0 3px rgba(0, 0, 0, 0.8);
}

/* 8. 右上角红叉适配 */
.formation-set-close-btn {
    top: -8px !important;
    right: -8px !important;
    width: 20px;
    height: 20px;
    line-height: 16px;
    font-size: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* 9. 圆圈右上角的阶数标记 (一阶/二阶) */
.panel-stage-tag {
    top: -5px;
    right: -5px;
    font-size: 10px;
    padding: 2px 5px;
    border: 1px solid #fff;
    /* 加白边增加分割感 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ==================== ⬇️ 性能优化：解决拖动卡顿与延迟 ⬇️ ==================== */

/* 当元素拥有 .is-dragging 类名时 (即正在拖动中) */
.is-dragging {
    /* 1. 核心修复：关闭过渡动画，让面板紧跟鼠标，不再“慢半拍” */
    transition: none !important;

    /* 2. 性能优化：拖动时暂时关闭磨砂滤镜，减轻显卡负担 */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;

    /* 3. 视觉反馈：拖动时背景稍微变实一点，方便看清位置 */
    background-color: rgba(255, 255, 255, 0.9) !important;
    border-color: #007bff !important;
    /* 边框变蓝提示正在操作 */
    z-index: 9999 !important;
    /* 确保拖动时在最上层 */
}

/* 暗色模式下的拖动样式 */
.board-wrapper.theme-dark .is-dragging {
    background-color: rgba(60, 60, 60, 0.95) !important;
    border-color: #007bff !important;
}

/* ==================== ⬇️ 阵法名字优化：加大与居中 ⬇️ ==================== */
.panel-formation-name {
    /* 1. 字体加大 */
    font-size: 13px !important;
    /* 原来是11px，这里改大 */
    font-weight: 800 !important;
    /* 特粗字体，更清晰 */

    /* 2. 核心：绝对居中算法 */
    width: auto !important;
    /* 宽度自动，不限制死 */
    min-width: 100px;
    /* 给个最小宽度确保文字能排开 */

    left: 50% !important;
    /* 定位到圆圈的水平中心点 */
    margin-left: 0 !important;
    /* 清除旧的 margin 偏移 */
    transform: translateX(-50%) !important;
    /* 向左回退自身的一半，实现完美居中 */

    /* 3. 垂直位置微调 */
    bottom: -24px !important;
    /* 字体变大了，往下挪一点，不要挡住圆圈 */

    /* 4. 其他视觉优化 */
    text-align: center !important;
    white-space: nowrap !important;
    /* 强制不换行 */
    z-index: 10;

    /* 增强文字描边，防止背景干扰 */
    text-shadow:
        0 1px 2px rgba(255, 255, 255, 1),
        0 0 4px rgba(255, 255, 255, 0.8),
        -1px 0 0 rgba(255, 255, 255, 0.8),
        1px 0 0 rgba(255, 255, 255, 0.8);
}

/* 暗色模式下的文字描边适配 */
.board-wrapper.theme-dark .panel-formation-name {
    color: #f8f9fa !important;
    text-shadow:
        0 1px 3px rgba(0, 0, 0, 1),
        0 0 2px rgba(0, 0, 0, 0.8);
}

/* ==================== ⬇️ 阵法面板缩放功能支持 ⬇️ ==================== */

/* 1. 设置缩放基点为右上角 */
#formation-panel {
    /* 关键：让缩放以右上角为锚点，这样缩放时面板位置不会乱飘 */
    transform-origin: top right;
    /* 确保默认比例为1 */
    transform: scale(1);
    /* 稍微优化一下缩放时的渲染画质 */
    backface-visibility: hidden;
}

/* 2. 缩放滑块的样式 (放在标题栏里) */
.formation-scale-slider {
    width: 60px;
    /* 滑块宽度 */
    height: 4px;
    margin-right: 8px;
    /* 跟折叠按钮拉开距离 */
    vertical-align: middle;
    cursor: pointer;
    -webkit-appearance: none;
    /* 去掉默认丑陋的样式 */
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    outline: none;
    opacity: 0.6;
    transition: opacity 0.2s;
}

/* 鼠标悬停变亮 */
.formation-scale-slider:hover {
    opacity: 1;
}

/* 滑块的圆点样式 */
.formation-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #007bff;
    /* 蓝色圆点 */
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

/* 暗色模式适配 */
.board-wrapper.theme-dark .formation-scale-slider {
    background: rgba(255, 255, 255, 0.2);
}

.board-wrapper.theme-dark .formation-scale-slider::-webkit-slider-thumb {
    background: #ffc107;
    /* 暗色模式用黄色圆点 */
}

/* 折叠时隐藏滑块，保持标题栏简洁 */
#formation-panel.collapsed .formation-scale-slider {
    display: none !important;
}

/* --- New Year Theme (Refinement V46 - Animated & Glass) --- */
body.theme-newyear {
    background-image: url('image/new_year_bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

body.theme-newyear #page-wrapper {
    background: transparent;
    padding: 20px;
}

/* Panels - Warm Cream/Yellow Background with Stronger Gold Border */
body.theme-newyear #left-panel,
body.theme-newyear #right-panel,
body.theme-newyear #middle-panel {
    background-color: #fffaf0;
    /* Floral White */
    border: 3px solid #e1b12c;
    /* Gold */
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3), 0 4px 12px rgba(139, 0, 0, 0.4);
}

/* Board Wrapper - Distinct from panels */
body.theme-newyear .board-wrapper {
    background: url('image/chessboard-bg-newyear.png') center/cover no-repeat;
    border: 2px solid #e1b12c;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2), inset 0 0 20px rgba(139, 0, 0, 0.1);
    background-size: 160% 160%;
}

body.theme-newyear .board-wrapper .item-bg {
    background: rgba(255, 255, 255, 0.75);
    /* 调高不透明度，减少背景干扰 */
    border: 1px solid rgba(225, 177, 44, 0.8);
    /* 使用实色金边 */
    backdrop-filter: blur(4px);
    /* 增加模糊度，提升质感 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* 增加微弱阴影使其立体 */
}

body.theme-newyear .board-slot.item:hover .item-bg {
    background: #ffecb3;
    border-color: #ff9800;
}

/* Headers */
body.theme-newyear h2,
body.theme-newyear h3 {
    color: #c0392b;
    border-bottom: 2px dashed #f1c40f;
    text-shadow: 0 1px 0 rgba(255, 255, 200, 0.5);
}

/* Text adjustments */
body.theme-newyear .board-hint {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}

/* Tab Buttons */
body.theme-newyear .tab-btn.active {
    background-color: #c0392b;
    /* Tech Red */
    border-color: #96281b;
    color: #ffd700;
    /* Gold Text */
    font-weight: bold;
}

body.theme-newyear .tab-btn.active[data-quality="金"] {
    background-color: #f1c40f;
    color: #8b0000;
}

/* Board Controls Buttons - Festive Style */
body.theme-newyear .board-controls button {
    border: 2px solid #e1b12c;
    color: #8b0000;
    background: linear-gradient(to bottom, #fff, #fff8e1);
    font-weight: bold;
}

body.theme-newyear .board-controls button:hover {
    background-color: #ffe082;
    color: #b71c1c;
    border-color: #ff9800;
}

/* Credits / Footer */
body.theme-newyear .credits-title,
body.theme-newyear .about-section {
    color: #d35400;
    font-weight: bold;
}

/* Toggle Button Highlight in New Year Theme */
body.theme-newyear #toggle-bg-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #ffd700;
    border: 2px solid #ffd700;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

body.theme-newyear #toggle-bg-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-1px);
}

/* Glassmorphism Tooltips (V47 - Grey High Contrast) */
body.theme-newyear #synergy-tooltip,
body.theme-newyear #piece-tooltip,
body.theme-newyear #formation-tooltip {
    /* Dark Gray Glass */
    background: rgba(45, 45, 45, 0.95) !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);

    /* White Text for Contrast on Dark Background */
    color: #ffffff !important;
    border: 1px solid rgba(255, 215, 0, 0.8) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3) !important;
    text-shadow: none !important;
}

/* Fix text colors inside dark glass tooltip */
body.theme-newyear #synergy-tooltip h4,
body.theme-newyear #formation-tooltip h5,
body.theme-newyear #piece-tooltip h4 {
    color: #ffd700 !important;
    /* Gold Title */
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    text-shadow: none !important;
}

body.theme-newyear #synergy-tooltip .synergy-desc,
body.theme-newyear #piece-tooltip .piece-tooltip-skill {
    color: #e0e0e0 !important;
    font-weight: 500;
}

/* Fix piece names inside synergy tooltip */
body.theme-newyear .synergy-tooltip-item .synergy-tooltip-name {
    color: #ffffff !important;
    text-shadow: none !important;
    font-weight: bold;
}

body.theme-newyear .synergy-tooltip-item.active .synergy-tooltip-name {
    color: #ffd700 !important;
    /* Gold for active pieces */
}

/* Ensure even if it has inline styles or other active classes */
body.theme-newyear .synergy-tooltip-item div[style*="color: black"],
body.theme-newyear .synergy-tooltip-item div[style*="color: #000"] {
    color: #ffffff !important;
}

/* Synergy & Piece List Items Adaptation (V48 - Synergy Reverted to White) */
body.theme-newyear .piece {
    background: rgba(255, 250, 240, 0.7);
    /* Floral White Semi-transparent for Pieces */
    border-color: #e1b12c;
}

body.theme-newyear .synergy-item {
    background: #ffffff;
    /* Reverted to White for Clarity */
    border-color: #e1b12c;
    /* Keep the Gold Border */
}

body.theme-newyear .synergy-item.active {
    background-color: #e0f7fa !important;
    /* Cyan Light Bg */
    color: #006064 !important;
    /* Dark Cyan Text */
    border-left-color: #00bcd4 !important;
    /* Bright Cyan Border */
    font-weight: bold;
}

body.theme-newyear .synergy-item.active-max {
    background-color: #f3e5f5 !important;
    /* Light Purple Bg */
    color: #4a148c !important;
    /* Dark Purple Text */
    border-left-color: #9c27b0 !important;
    /* Bright Purple Border */
}

body.theme-newyear .synergy-header {
    background: linear-gradient(to right, #ffd700, #ffb300);
    /* Richer Gold */
    color: #8b0000;
    text-shadow: none;
    font-weight: bold;
    border-radius: 4px 4px 0 0;
}

/* Circular Add Button Aesthetics (V47) */
body.theme-newyear .add-synergy-btn {
    /* Shape */
    width: 24px;
    height: 24px;
    border-radius: 50%;

    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;

    /* Visuals - Minimalist */
    background: #fff;
    border: 1px solid #e1b12c;
    color: #e1b12c;
    /* Gold Plus Sign */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

    /* Spacing override */
    margin-left: 8px;
    transition: all 0.3s ease;
}

body.theme-newyear .add-synergy-btn:hover {
    background: #e1b12c;
    color: #fff;
    transform: rotate(90deg);
    /* Playful rotation */
    box-shadow: 0 2px 8px rgba(225, 177, 44, 0.4);
}

/* Explicit Body Backgrounds for Classic Themes */
body.theme-green,
body.theme-blue,
body.theme-dark {
    background-color: #e9ecef;
    /* Classic Grey */
    background-image: none;
}

/* Ensure Green Theme is Explicit */
.board-wrapper.theme-green {
    background: #b7dabc;
    border-color: #a4d6ad;
}

.board-wrapper.theme-green .item-bg {
    background: #e9ecef;
    border-color: #d1d5d9;
}

/* Ensure Blue Theme is Explicit */
.board-wrapper.theme-blue {
    background: #cce5ff;
    /* Pale Blue */
    border-color: #b8daff;
}

.board-wrapper.theme-blue .item-bg {
    background: #f8f9fa;
    border-color: #dee2e6;
}

/* Ensure Dark Theme is Explicit */
.board-wrapper.theme-dark {
    background: #343a40;
    border-color: #454d55;
    color: #f8f9fa;
}
/* 确保棋盘格子具备相对定位基准 */
.board-slot {
    position: relative;
}

/* 完美的圆形攻击范围圈样式 */
.attack-range-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 算法核心：靠平移实现完美圆心对齐 */
    
    border: 2px dashed rgba(255, 193, 7, 0.65); /* 金色虚线圈，契合游戏金边视觉 */
    background-color: rgba(255, 193, 7, 0.05); /* 淡淡的半透明金色填充层 */
    border-radius: 50%; /* 变成完美圆形的关键 */
    
    /* ⚡ 极其重要：鼠标事件穿透 */
    /* 确保攻击圈绝对不会阻挡鼠标对格子的拖拽、点击放置、右键清除等原有操作 */
    pointer-events: none; 
    
    z-index: 80; /* 悬浮在格子与棋子之上，但低于技能悬浮窗 */
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.15); /* 淡淡的柔和外发光 */
    
    /* 丝滑的过渡动效：拖拽到不同格子时，范围圈放大缩小带有平滑动画 */
    transition: width 0.15s ease-out, height 0.15s ease-out; 
    
    /* 选配：赋予虚线圈一呼一吸的灵动呼吸微动效 */
    animation: rangeCirclePulse 2.5s infinite ease-in-out;
}

@keyframes rangeCirclePulse {
    0% { opacity: 0.75; }
    50% { opacity: 1; }
    100% { opacity: 0.75; }
}
/* ==========================================
   🎯 修复攻击范围中心点偏移与高亮对齐问题
   ========================================== */
