* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.language-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.lang-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.lang-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 40px;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

h2 {
    color: #444;
    margin: 20px 0 15px 0;
    font-size: 1.3em;
}

.instruction {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    font-style: italic;
}

.grid-visualizer {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.grid-display {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 3px;
    padding: 20px;
    background: #f0f0f0;
    border-radius: 15px;
    border: 3px solid #ddd;
    cursor: crosshair;
    user-select: none;
}

.grid-cell {
    width: 40px;
    height: 40px;
    background: #fff;
    border: 2px solid #ccc;
    border-radius: 5px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.grid-cell:hover {
    background: #e8f2ff;
    border-color: #a0c4ff;
}

.grid-cell.selected {
    background: #667eea;
    border-color: #5a6fd8;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.6);
}

.grid-cell.preview {
    background: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.confirm-section {
    text-align: center;
    margin: 20px 0;
}

.confirm-btn {
    padding: 12px 24px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.confirm-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

.reselect-btn {
    padding: 10px 20px;
    background: #ffc107;
    color: #212529;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.reselect-btn:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.selected-grid {
    color: #666;
    font-style: italic;
    margin-bottom: 20px;
}

.file-upload {
    position: relative;
    display: inline-block;
}

#imageUpload {
    display: none;
}

.upload-label {
    display: inline-block;
    padding: 15px 30px;
    background: #764ba2;
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.upload-label:hover {
    background: #5a3a7a;
    transform: translateY(-2px);
}

.upload-label.disabled {
    background: #ccc;
    cursor: not-allowed;
}

.grid-display:hover .grid-cell.preview {
    display: block;
}

.preview-section {
    margin-top: 30px;
    text-align: center;
}

#originalImage {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    margin: 20px 0;
}

.split-btn, .download-zip-btn {
    padding: 15px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    margin: 20px 0;
    transition: all 0.3s ease;
}

.split-btn:hover, .download-zip-btn:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.results-section {
    margin-top: 30px;
}

.split-images {
    display: grid;
    gap: 10px;
    margin: 20px 0;
    justify-items: center;
    max-width: 100%;
    overflow: hidden;
}


.split-image-container {
    text-align: center;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    min-width: 0;
    max-width: 100%;
}

.split-image {
    width: 100%;
    max-width: 120px;
    max-height: 120px;
    border-radius: 5px;
    margin-bottom: 8px;
    object-fit: cover;
}

.download-btn {
    padding: 6px 12px;
    background: #764ba2;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.download-btn:hover {
    background: #5a3a7a;
    transform: translateY(-1px);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .container {
        max-width: 90%;
        padding: 30px;
    }
    
    .split-image {
        max-width: 100px;
        max-height: 100px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .grid-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .split-image {
        max-width: 80px;
        max-height: 80px;
    }
    
    .download-btn {
        font-size: 11px;
        padding: 4px 8px;
    }
}

@media (max-width: 480px) {
    .split-image {
        max-width: 60px;
        max-height: 60px;
    }
    
    .split-image-container {
        padding: 4px;
    }
}