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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.navbar-logo a {
    color: white;
    text-decoration: none;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.navbar-logo a:hover {
    transform: scale(1.05);
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 30px;
}

.navbar-link {
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    padding: 8px 0;
}

.navbar-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: white;
    transition: width 0.3s ease;
}

.navbar-link:hover::after {
    width: 100%;
}

.navbar-link:hover {
    color: #f0f0f0;
    transform: translateY(-2px);
}

.navbar-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 5px;
}

.navbar-toggle span {
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .navbar-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding: 20px 0;
        gap: 20px;
    }
    
    .navbar-menu.active {
        left: 0;
    }
    
    .navbar-toggle {
        display: flex;
    }
    
    .navbar-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .navbar-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .navbar-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

.puzzle-tool-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.tool-header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.tool-header h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.tool-header p {
    font-size: 18px;
    opacity: 0.9;
}

.tool-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 10px;
}

section h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.6;
}

.upload-area p {
    font-size: 16px;
    margin-bottom: 8px;
    color: #666;
}

.upload-hint {
    font-size: 14px !important;
    color: #999 !important;
}

#file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.image-list {
    min-height: 200px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
    transition: all 0.3s ease;
}

.image-list.has-images {
    background: white;
    border-color: #ddd;
}

.image-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: white;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    cursor: move;
    position: relative;
}

.image-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.image-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.image-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.image-info {
    flex: 1;
}

.image-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #333;
}

.image-dimensions {
    font-size: 12px;
    color: #666;
}

.image-actions {
    display: flex;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 16px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.setting-item input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.setting-item select,
.setting-item input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.setting-item select:focus,
.setting-item input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-item span {
    font-size: 14px;
    font-weight: 500;
    color: #667eea;
    text-align: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 14px;
}

.icon-btn:hover {
    background: #e9ecef;
    transform: scale(1.1);
}

.delete-btn:hover {
    background: #ffebee;
    color: #f44336;
}

.move-btn:hover {
    background: #e3f2fd;
    color: #2196f3;
}

#merge-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
}

.result-container {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 20px;
    background: #fafafa;
    text-align: center;
    min-height: 300px;
    position: relative;
}

.result-image {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.result-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.result-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
}

.close-btn:hover {
    color: #333;
    transform: scale(1.1);
}

.modal-body img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
}

.tool-footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: white;
    font-size: 14px;
    opacity: 0.8;
}

@media (max-width: 768px) {
    .puzzle-tool-container {
        padding: 15px;
    }
    
    .tool-header h1 {
        font-size: 28px;
    }
    
    section {
        padding: 20px;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .image-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .image-thumbnail {
        width: 100px;
        height: 80px;
    }
    
    .image-actions {
        align-self: flex-end;
        position: absolute;
        top: 10px;
        right: 10px;
    }
    
    .result-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .result-controls .btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tool-header h1 {
        font-size: 24px;
    }
    
    .tool-header p {
        font-size: 16px;
    }
    
    section h2 {
        font-size: 18px;
    }
    
    .upload-area {
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 36px;
    }
}