* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px; /* 减少body内边距 */
    margin: 0;
    overflow-x: hidden; /* 防止水平溢出 */
}

.container {
    max-width: 1400px; /* 增加最大宽度 */
    width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px; /* 减少容器内边距 */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    position: relative; /* 支持绝对定位的控制按钮 */
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px; /* 减少底部间距 */
    font-size: 2.2em; /* 减小字体 */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.2; /* 优化行高 */
}

h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* 主内容区域 - 左右分栏布局 */
.main-content {
    display: flex;
    gap: 20px;
    width: 100%;
}

/* 左侧主区域 */
.left-main-area {
    flex: 1;
    min-width: 0; /* 防止flex项目溢出 */
}

/* 右侧图片预览区域（已移除，改为点击放大到排名区） */
.image-preview-section {
    display: none; /* 完全隐藏预览区域 */
}

/* 图片放大显示容器（新功能） */
.enlarged-image-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000; /* 确保在最上层 */
    display: none; /* 默认隐藏 */
    cursor: grab;
    transition: all 0.3s ease;
}

.enlarged-image-container.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(0.8); /* 拖动时缩小到80% */
    transition: transform 0.2s ease;
}

/* 拖动目标高亮 */
.free-drop-zone {
    transition: background-color 0.2s ease;
}

.free-drop-zone:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.free-drop-zone[style*="background-color: rgba(255, 255, 255, 0.2)"],
.free-drop-zone.drop-target {
    border: 2px dashed rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.enlarged-image {
    max-width: 500px;
    max-height: 500px;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.enlarged-image-name {
    text-align: center;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    margin-top: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    word-break: break-word;
}

/* 点击背景关闭的遮罩效果 */
.enlarged-image-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: -1;
}

/* 图片上传区域 - 拓宽版本（已弃用，使用bottom-upload-section） */
.image-upload-section {
    display: none; /* 隐藏旧的侧边上传区域 */
}

#imageInput {
    margin-bottom: 15px; /* 减少底部间距 */
    padding: 10px; /* 减少内边距 */
    border: 2px solid #ccc;
    border-radius: 6px; /* 减少圆角 */
    background: white;
    font-size: 0.95em; /* 稍微减小字体 */
    width: 100%;
}

.uploaded-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px; /* 减少间距 */
    min-height: 250px; /* 减少最小高度 */
    padding: 15px; /* 减少内边距 */
    background: white;
    border-radius: 8px; /* 减少圆角 */
    border: 1px solid #ddd; /* 减少边框宽度 */
    flex: 1; /* 占据剩余空间 */
    align-content: flex-start; /* 顶部对齐 */
}

.uploaded-image {
    /* 保持图片原始比例，限制最大尺寸 */
    max-width: 85px;
    max-height: 85px;
    width: auto;
    height: auto;
    object-fit: contain; /* 保持比例完整显示 */
    border-radius: 8px; /* 稍微减少圆角 */
    cursor: grab;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.uploaded-image:hover {
    transform: scale(1.1);
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.uploaded-image:active {
    cursor: grabbing;
}

/* 排名区域 */
.ranking-section {
    margin-bottom: 20px; /* 减少底部间距 */
    width: 100%; /* 占满可用宽度 */
}

.ranking-container {
    position: relative;
    height: 450px; /* 调整固定高度：每行90px × 5行 = 450px */
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 背景标签区域 */
.rank-labels-background {
    position: absolute;
    left: 0;
    top: 0;
    width: 100px;
    height: 100%;
    z-index: 1; /* 标签在背景层 */
}

.rank-label-bg {
    position: absolute;
    left: 0;
    width: 100px;
    height: 90px; /* 增大每行高度从70px到90px */
    padding: 20px 10px; /* 增大垂直内边距 */
    font-weight: bold;
    font-size: 1.2em; /* 稍微增大字体 */
    text-align: center;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 2px solid #ddd;
}

/* 不同等级的背景颜色 */
.rank-label-bg[data-rank="s"] {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
}

.rank-label-bg[data-rank="a"] {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.rank-label-bg[data-rank="b"] {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.rank-label-bg[data-rank="c"] {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.rank-label-bg[data-rank="d"] {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

/* 自定义标签的背景颜色 - 使用循环颜色 */
.rank-label-bg[data-rank^="custom_"] {
    /* 默认颜色，如果无法计算索引则使用 */
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

/* 为自定义标签添加不同的颜色 - 基于固定的颜色索引 */
.rank-label-bg[data-rank^="custom_"][data-color-index="1"] {
    background: linear-gradient(135deg, #ff9ff3, #f368e0);
}

.rank-label-bg[data-rank^="custom_"][data-color-index="2"] {
    background: linear-gradient(135deg, #54a0ff, #2e86de);
}

.rank-label-bg[data-rank^="custom_"][data-color-index="3"] {
    background: linear-gradient(135deg, #00d2d3, #01a3a4);
}

.rank-label-bg[data-rank^="custom_"][data-color-index="4"] {
    background: linear-gradient(135deg, #ff9f43, #feca57);
}

.rank-label-bg[data-rank^="custom_"][data-color-index="5"] {
    background: linear-gradient(135deg, #5f27cd, #341f97);
}

.rank-label-bg[data-rank^="custom_"][data-color-index="6"] {
    background: linear-gradient(135deg, #00b894, #00a085);
}

/* 自定义标签删除按钮样式 */
.rank-label-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rank-label-bg:hover .rank-label-delete {
    opacity: 1;
}

.rank-label-delete:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 加号按钮样式 */
.rank-label-add {
    position: absolute;
    top: 25px; /* 在删除按钮下方 */
    right: 5px;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rank-label-bg:hover .rank-label-add {
    opacity: 1;
}

.rank-label-add:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 自由拖拽区域 */
.free-drop-zone {
    position: absolute;
    left: 100px; /* 避开标签区域 */
    right: 0;
    height: 90px; /* 增大每行高度从70px到90px */
    border-bottom: 1px solid #eee;
    z-index: 2; /* 拖拽区域在中间层 */
}

.free-drop-zone[data-rank="s"] {
    top: 0;
}

.free-drop-zone[data-rank="a"] {
    top: 90px;
}

.free-drop-zone[data-rank="b"] {
    top: 180px;
}

.free-drop-zone[data-rank="c"] {
    top: 270px;
}

.free-drop-zone[data-rank="d"] {
    top: 360px;
    border-bottom: 1px solid #eee;
}

/* 不同等级的颜色 */
.rank-label-bg[data-rank="s"] {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
}

.rank-label-bg[data-rank="a"] {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.rank-label-bg[data-rank="b"] {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.rank-label-bg[data-rank="c"] {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.rank-label-bg[data-rank="d"] {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.rank-content {
    flex: 1;
    padding: 10px 15px; /* 减少垂直内边距 */
    min-height: 80px; /* 增大最小高度从60px到80px，匹配新的行高90px */
    background: #f8f9fa;
    border-left: 2px solid #ddd; /* 减少边框宽度 */
    position: relative; /* 支持绝对定位 */
    overflow: hidden; /* 防止图片超出边界 */
}

.drop-zone {
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: scale(1.02);
}

.drop-zone .uploaded-image {
    width: 60px;
    height: 60px;
}



/* 底部图片导入区域 */
.bottom-upload-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 2px dashed #ddd;
    margin-top: 20px;
    width: 100%;
}

/* 图片容器 */
.uploaded-image-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.uploaded-image-container:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* 命名按钮 */
.image-name-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.9);
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.image-name-btn:hover {
    background: rgba(0, 86, 179, 0.95);
    transform: scale(1.1);
}

/* 图片名称显示 */
.image-name-display {
    font-size: 11px;
    color: #666;
    text-align: center;
    max-width: 85px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(248, 249, 250, 0.8);
    transition: all 0.3s ease;
}

.uploaded-image-container:hover .image-name-display {
    color: #333;
    background: rgba(233, 236, 239, 0.9);
}

/* 命名对话框 */
.image-name-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: dialogFadeIn 0.3s ease;
}

@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dialog-content h3 {
    margin: 0 0 16px 0;
    color: #333;
    text-align: center;
}

.dialog-preview {
    text-align: center;
    margin-bottom: 20px;
}

.dialog-preview img {
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dialog-input {
    margin-bottom: 20px;
}

.dialog-input label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.dialog-input input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.dialog-input input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.dialog-buttons .btn {
    padding: 8px 16px;
    font-size: 14px;
    min-width: 80px;
}

.bottom-upload-section h3 {
    margin-bottom: 15px;
    color: #555;
}

.bottom-upload-section #imageInput {
    margin-bottom: 15px;
    padding: 10px;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 0.95em;
    width: 100%;
}

.bottom-upload-section .uploaded-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 120px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    align-content: flex-start;
}

.btn {
    padding: 8px 16px; /* 更紧凑的内边距 */
    border: none;
    border-radius: 16px; /* 适中的圆角 */
    font-size: 0.9em; /* 稍小字体 */
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap; /* 防止按钮文字换行 */
}

/* 统一按钮样式：白色背景黑色文字 */
.btn-primary,
.btn-danger,
.btn-warning,
.btn-info,
.btn-success {
    background: white;
    color: black;
    border: 1px solid #ddd;
}

.btn-primary:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-info:hover,
.btn-success:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 按钮激活状态 */
.btn-primary:active,
.btn-danger:active,
.btn-warning:active,
.btn-success:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .container {
        max-width: 95%; /* 在大屏幕上占更多宽度 */
        padding: 15px;
    }
    
    .left-panel {
        width: 65%; /* 调整占比 */
    }
    
    /* 预览区已移除 */
    .image-preview-section {
        display: none;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .left-main-area {
        width: 100%; /* 全宽 */
    }
    
    /* 预览区已移除 */
    .image-preview-section {
        display: none;
    }
    
    .uploaded-images {
        min-height: 150px;
    }
    
    .bottom-upload-section .uploaded-images {
        min-height: 100px; /* 移动端底部上传区域更小 */
    }
}

@media (max-width: 768px) {
    body {
        padding: 5px; /* 进一步减少body内边距 */
    }
    
    .container {
        padding: 15px;
        border-radius: 10px; /* 减少圆角 */
    }
    
    h1 {
        font-size: 1.8em; /* 减小字体 */
        margin-bottom: 15px;
    }
    
    .rank-row {
        flex-direction: column;
    }
    
    .rank-label {
        width: 100%;
        padding: 12px;
        font-size: 1em;
    }
    
    .rank-content {
        min-height: 50px;
        padding: 8px 12px;
    }
    
    .ranking-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .system-title {
        font-size: 1.3em;
        order: -1; /* 标题放在最上面 */
    }
    
    .header-controls {
        justify-content: center;
        order: 1; /* 控制按钮放在最下面 */
    }
    
    .bottom-upload-section {
        margin-top: 15px;
    }
    
    .btn {
        padding: 8px 20px;
        font-size: 0.9em;
        width: 100%; /* 按钮占满宽度 */
        max-width: 200px;
    }
    
    .uploaded-images {
        min-height: 150px;
        gap: 10px;
        padding: 15px;
    }
    
    .uploaded-image {
        width: 75px;
        height: 75px;
    }
    
    .image-upload-section {
        padding: 15px;
        min-height: 280px;
    }
}

/* 拖拽时的样式 */
.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* 自由定位的图片样式 */
.free-position {
    cursor: grab;
    transition: transform 0.2s ease;
    z-index: 10;
    /* 保持图片比例，但限制在排名区域内 */
    max-width: calc(100% - 100px); /* 减去标签宽度100px */
    max-height: 90px; /* 增大每行高度从70px到90px，确保不超出当前行 */
    /* 强制限制图片高度，防止超出行高 */
    height: 90px !important;
    /* 保持图片比例 */
    width: auto !important;
    /* 确保图片完整显示 */
    object-fit: contain;
}

.free-position:hover {
    transform: none; /* 移除悬停效果 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* 添加轻微阴影 */
}

.free-position:active {
    cursor: grabbing;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); /* 拖拽时的阴影 */
}

/* 添加图片按钮样式 */
.add-image-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    z-index: 10;
}

.add-image-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.add-image-btn:active {
    transform: scale(0.95);
}

.add-icon {
    color: white;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    user-select: none;
}

/* 调整上传图片容器为相对定位 */
.uploaded-images {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 120px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    align-content: flex-start;
}

/* 排名区域头部 */
.ranking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 10px;
}

.rank-title {
    color: #555;
    font-size: 1.2em;
    margin: 0;
    font-weight: 600;
    flex-shrink: 0;
}

.system-title {
    color: #ff6b35;
    font-size: 1.5em;
    margin: 0;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
    cursor: text;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.system-title:hover {
    background-color: rgba(255, 107, 53, 0.1);
}

.system-title:focus {
    outline: 2px solid #ff6b35;
    outline-offset: 2px;
    background-color: rgba(255, 107, 53, 0.05);
}

.header-controls {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: center;
}

/* 设置开关样式 */
/* 设置按钮样式 */
.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
}

.settings-icon {
    font-size: 16px;
    line-height: 1;
}

/* 设置面板样式 */
.settings-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 300px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none;
    border: 1px solid #e0e0e0;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
}

.settings-header h3 {
    margin: 0;
    color: #333;
    font-size: 16px;
}

.close-settings {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-settings:hover {
    background: #e9ecef;
    color: #333;
}

.settings-content {
    padding: 20px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-description {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.setting-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.setting-label {
    font-size: 14px;
    color: #666;
    user-select: none;
    white-space: nowrap;
}

input:checked ~ .setting-label {
    color: #667eea;
    font-weight: 500;
}

/* 空状态提示 - 隐藏拖拽提示文字 */
.empty-hint {
    display: none; /* 完全隐藏拖拽提示文字 */
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 10px;
    font-size: 0.9em;
    width: 100%;
}