body {
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
}

/* Header */
header {
    background-color: #2a2a2a;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #3b82f6;
    text-decoration: none;
    white-space: nowrap;
}

/* 汉堡菜单按钮 */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: #ccc;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Main Content */
main {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

h2 {
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

/* Image Grid */
#image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.image-card {
    background: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.image-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.card-info {
    padding: 10px;
    font-size: 12px;
    color: #999;
    text-align: center;
    /* 文本截断 - 防止长文件名溢出 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card badges */
.card-badges {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.badge {
    font-size: 12px;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
}

.badge-private {
    color: #ffd700;
}

.badge-owner {
    color: #4a90d9;
}

.loading,
.no-data,
.error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 18px;
}

.error {
    color: #dc3545;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: #2a2a2a;
    padding: 30px;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    display: flex;
    gap: 30px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    font-size: 28px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    color: #999;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.modal-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.preview-section {
    flex: 2;
}

.preview-section img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 4px;
    background: #000;
}

.options-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 14px;
    color: #ccc;
}

select {
    padding: 10px;
    background: #333;
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
    font-size: 16px;
}

.btn-start {
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-start:hover {
    background: #2563eb;
}

/* Image Detail Modal - Story 36 */
.image-detail-modal {
    max-width: 900px;
}

.image-detail-modal .modal-body {
    display: flex;
    gap: 24px;
    width: 100%;
}

.image-detail-modal .preview-section {
    flex: 1.2;
    min-width: 0;
}

.image-detail-modal .preview-section img {
    width: 100%;
    max-height: 450px;
    object-fit: contain;
    border-radius: 8px;
    background: #1a1a1a;
}

.image-detail-modal .info-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 280px;
}

/* Image Info */
.image-info h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #fff;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 13px;
    padding: 4px 0;
}

.info-label {
    color: #888;
    flex-shrink: 0;
}

.info-value {
    color: #fff;
    text-align: right;
    max-width: 180px;
    word-break: break-word;
}

.info-value.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
}

.info-value .tag {
    background: #3a3a3a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #4a90d9;
}

.status-public {
    color: #4ade80;
}

.status-private {
    color: #f59e0b;
}

/* Game Start Section */
.game-start-section {
    padding: 16px;
    background: #1a1a1a;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-start-section .form-group {
    gap: 6px;
}

.game-start-section select {
    padding: 8px 12px;
}

.game-start-section .btn-start {
    margin-top: 4px;
}

/* Game Actions (Start + Leaderboard) */
.game-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.game-actions .btn-start {
    flex: 1;
    margin-top: 0;
}

.btn-leaderboard {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-leaderboard:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Edit Section */
.edit-section {
    padding: 16px;
    background: #2d2d2d;
    border-radius: 8px;
    border: 1px solid #444;
}

.edit-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #f59e0b;
}

.edit-section .form-group {
    margin-bottom: 12px;
}

.edit-section select,
.edit-section input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

/* Tag Editor */
.tag-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}

.edit-tag {
    background: #3a3a3a;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #4a90d9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tag-remove {
    cursor: pointer;
    color: #888;
    font-size: 14px;
}

.tag-remove:hover {
    color: #ff6b6b;
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
}

.radio-label input[type="radio"] {
    cursor: pointer;
}

/* Edit Actions */
.edit-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-save {
    flex: 1;
    padding: 8px 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover {
    background: #059669;
}

.btn-save:disabled {
    background: #555;
    cursor: not-allowed;
}

.btn-delete {
    padding: 8px 12px;
    background: transparent;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #ff6b6b;
    color: white;
}

.btn-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* User Info & Logout Button */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#username-display {
    color: #ccc;
}

.btn-upload {
    background: #4a90d9;
    border: 1px solid #4a90d9;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-upload:hover {
    background: #3a7fc8;
    border-color: #3a7fc8;
}

.btn-records {
    background: #f5a623;
    border: 1px solid #f5a623;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
    margin-left: 8px;
}

.btn-records:hover {
    background: #e09515;
    border-color: #e09515;
}

.btn-admin {
    background: #6366f1;
    border: 1px solid #6366f1;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
    margin-left: 8px;
}

.btn-admin:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

.btn-leaderboard-nav {
    background: transparent;
    border: 1px solid #f59e0b;
    color: #f59e0b;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
    margin-left: 8px;
}

.btn-leaderboard-nav:hover {
    background: #f59e0b;
    color: white;
}

.btn-logout {
    background: transparent;
    border: 1px solid #666;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.btn-change-password {
    background: transparent;
    border: 1px solid #666;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-change-password:hover {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 20px;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 8px;
}

.filter-header {
    display: none;
}

.filter-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-select {
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
}

.filter-select:hover {
    border-color: #666;
}

.filter-select:focus {
    outline: none;
    border-color: #4a90d9;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.filter-input {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.filter-input:focus {
    outline: none;
    border-color: #4a90d9;
}

.filter-input::placeholder {
    color: #888;
}

/* Responsive */
@media (max-width: 768px) {
    /* 主内容区域底部边距，避免被手机浏览器工具栏遮挡 */
    main {
        padding-bottom: 80px;
    }
    
    /* 可折叠筛选栏 */
    .filter-bar {
        padding: 0;
    }
    
    .filter-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 15px;
        cursor: pointer;
        color: #ccc;
        font-size: 14px;
    }
    
    .filter-header:hover {
        color: #fff;
    }
    
    .filter-arrow {
        transition: transform 0.3s ease;
        font-size: 12px;
    }
    
    .filter-bar.open .filter-arrow {
        transform: rotate(180deg);
    }
    
    .filter-group {
        flex-direction: column;
        max-height: 0;
        overflow: hidden;
        padding: 0 15px;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    
    .filter-bar.open .filter-group {
        max-height: 300px;
        padding: 0 15px 15px;
    }
    
    .filter-select,
    .search-box {
        width: 100%;
        min-width: unset;
    }
    
    .modal-content {
        flex-direction: column;
        padding: 20px;
    }
    
    .image-detail-modal .modal-body {
        flex-direction: column;
    }
    
    .image-detail-modal .info-section {
        min-width: unset;
    }
    
    .image-detail-modal .preview-section img {
        max-height: 250px;
    }

    .preview-section img {
        max-height: 200px;
    }
    
    /* 窄屏响应式导航 */
    .menu-toggle {
        display: flex;
    }
    
    header {
        padding: 12px 20px;
    }
    
    .user-info {
        position: fixed;
        top: 0;
        right: -280px;
        width: 260px;
        height: 100vh;
        background: #2a2a2a;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 70px 20px 20px;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
        transition: right 0.3s ease;
        z-index: 1000;
    }
    
    .user-info.open {
        right: 0;
    }
    
    .user-info > * {
        padding: 12px 15px !important;
        border-radius: 6px;
        margin-bottom: 5px;
        margin-left: 0 !important;
        width: 100% !important;
        box-sizing: border-box;
        display: block !important;
        text-align: center;
        text-decoration: none !important;
        font-size: 14px !important;
    }
    
    #username-display {
        color: #3b82f6;
        font-weight: bold;
        border-bottom: 1px solid #444;
        padding-bottom: 15px !important;
        margin-bottom: 10px;
    }
    
    .edit-actions {
        flex-direction: column;
    }
    
    /* 遮罩层 */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .menu-overlay.active {
        display: block;
    }
    
    /* ========================================
       全局移动端底部安全区修复
       解决三星浏览器等移动端浏览器工具栏遮挡问题
       ======================================== */
    
    /* 所有页面底部留出空间 */
    body {
        padding-bottom: 120px !important;
    }
    
    /* 弹窗/模态框底部按钮区域 */
    .modal-actions,
    .edit-actions,
    .form-actions,
    .dialog-buttons,
    .button-group,
    .upload-modal-footer,
    .modal-footer {
        padding-bottom: 100px !important;
    }
    
    /* 固定定位的底部栏 */
    .bottom-bar,
    .footer-bar,
    .action-bar {
        bottom: 120px !important;
    }
    
    /* 模态框内容区需要可滚动，确保底部按钮可见 */
    .modal-content,
    .upload-modal-content,
    .image-detail-modal {
        max-height: 80vh !important;
        overflow-y: auto !important;
        padding-bottom: 80px !important;
    }
}
